-
Notifications
You must be signed in to change notification settings - Fork 81
Avoid portal dependencies from reference external CDN #4931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tung2744
merged 6 commits into
authgear:main
from
louischan-oursky:dev-2357-self-host-portal-dependency-assets
Dec 11, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
117fb00
Upgrade fluentui to latest v8
louischan-oursky 89459fe
Fix type error in mergeStyles.ts
louischan-oursky f36a96c
Fix type error in ChoiceButton
louischan-oursky ad075ad
Remove a warning from eslint
louischan-oursky 7ba5654
Self-host FluentUI assets
louischan-oursky a5fbefe
Bundle monaco-editor source code
louischan-oursky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -x | ||
|
|
||
| # This is how we self-host the runtime assets of FluentUI. | ||
| # | ||
| # We utilize the public directory feature of Vite. | ||
| # See https://v2.vitejs.dev/guide/assets.html#the-public-directory | ||
| # This feature merely copies the files in the public directory to the root of the outDir. | ||
| # Since we use FileServer to serve asset, assets have to be put in the asset directory. | ||
| # We automate this copy process with a NPM postinstall script. (This script) | ||
| # | ||
| # Finally we tell fluentui to load the assets from the portal backend, instead of from the default CDN. | ||
| # This is done with window.FabricConfig. | ||
|
|
||
| # In docker build, the postinstall runs before the src are copied. | ||
| # So we run mkdir -p to ensure the directory exist. | ||
| mkdir -p ./src/public/shared-assets/ | ||
| # In case you wonder why we do not just use shell expansion here, | ||
| # if ./src/public/shared-assets is really empty, sh DOES NOT expand, and take '*' literally. | ||
| # Since we do not have such a file, the command will fail. | ||
| find ./src/public/shared-assets -name 'fabric-icons-*.woff' -print -exec rm '{}' \; | ||
| # When window.FabricConfig.iconBaseUrl is set, it loads the font directly in the directory. | ||
| # So we just copy the fonts to outDir. | ||
| cp -r ./node_modules/@fluentui/font-icons-mdl2/fonts/. ./src/public/shared-assets/. | ||
|
|
||
| # When window.FabricConfig.fontBaseUrl is set, it loads the font with a certain structure. | ||
| # The original URL is https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 | ||
| # When fontBaseUrl is set, the URL looks like https://origin/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 | ||
|
|
||
| # FluentUI actually has support for many fonts. | ||
| # For the full list of the fonts it may load at runtime, see ./node_modules/@fluentui/react/dist/css/fabric.css | ||
| # Since our site is lang=en, it will ever load "Segoe UI Web (West European)" | ||
| # So we just download and copy them. | ||
| # Since this process has to be done once only, the following commands are commented out. | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-light.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff2 | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-light.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semilight.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff2 | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semilight.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-regular.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff2 | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-regular.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semibold.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff2 | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-semibold.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff2 | ||
| # wget https://static2.sharepointonline.com/files/fabric/assets/fonts/segoeui-westeuropean/segoeui-bold.woff -O ./src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+37.5 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff
Binary file not shown.
Binary file added
BIN
+32.2 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-bold.woff2
Binary file not shown.
Binary file added
BIN
+33 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff
Binary file not shown.
Binary file added
BIN
+28.1 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-light.woff2
Binary file not shown.
Binary file added
BIN
+41.2 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff
Binary file not shown.
Binary file added
BIN
+35.5 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-regular.woff2
Binary file not shown.
Binary file added
BIN
+36.4 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff
Binary file not shown.
Binary file added
BIN
+31.1 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semibold.woff2
Binary file not shown.
Binary file added
BIN
+34.5 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff
Binary file not shown.
Binary file added
BIN
+29.2 KB
portal/src/public/shared-assets/fonts/segoeui-westeuropean/segoeui-semilight.woff2
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,32 @@ | ||
| import { useCallback, useMemo } from "react"; | ||
| import { IStyleFunctionOrObject, IStyleSet } from "@fluentui/react"; | ||
| import { IStyleFunctionOrObject } from "@fluentui/react"; | ||
| import { | ||
| concatStyleSetsWithProps, | ||
| concatStyleSets, | ||
| IConcatenatedStyleSet, | ||
| IStyleSetBase, | ||
| } from "@fluentui/merge-styles"; | ||
|
|
||
| export function useMergedStyles<TStylesProps, IStyleSet>( | ||
| ...styless: (IStyleFunctionOrObject<TStylesProps, IStyleSet> | undefined)[] | ||
| ): IStyleFunctionOrObject<TStylesProps, IStyleSet> { | ||
| export function useMergedStyles<TStylesProps, TStyleSet extends IStyleSetBase>( | ||
| ...styless: (IStyleFunctionOrObject<TStylesProps, TStyleSet> | undefined)[] | ||
| ): ( | ||
| props: TStylesProps | ||
| ) => ReturnType<typeof concatStyleSetsWithProps<TStylesProps, TStyleSet>> { | ||
| return useCallback( | ||
| (props) => { | ||
| return concatStyleSetsWithProps(props, ...styless); | ||
| }, | ||
| // eslint-disable-next-line | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| [...styless] | ||
| ); | ||
| } | ||
|
|
||
| export function useMergedStylesPlain( | ||
| // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents | ||
| ...styless: (IStyleSet | undefined)[] | ||
| ): IConcatenatedStyleSet<IStyleSet> { | ||
| export function useMergedStylesPlain<TStyleSet extends IStyleSetBase>( | ||
| ...styless: (TStyleSet | undefined)[] | ||
| ): IConcatenatedStyleSet<TStyleSet> { | ||
| return useMemo( | ||
| () => concatStyleSets(...styless), | ||
| // eslint-disable-next-line | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| [...styless] | ||
| ) as IConcatenatedStyleSet<IStyleSet>; | ||
| ) as IConcatenatedStyleSet<TStyleSet>; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to commit the files in shared-assets? 🤔
Or they should be generated after npm install?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The postinstall script was intended to automate the update of these files, not for generating the files after npm install. Having the
publicdirectory contain we will serve with a simplegit checkoutis easier to understand.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. But I am worried about the repo size :sosad: