@webiny/app 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.d.ts +26 -0
- package/App.js +95 -0
- package/App.js.map +1 -0
- package/AppContainer.d.ts +23 -0
- package/AppContainer.js +9 -0
- package/AppContainer.js.map +1 -0
- package/apollo-client/InMemoryCache.d.ts +4 -3
- package/apollo-client/InMemoryCache.js +13 -52
- package/apollo-client/InMemoryCache.js.map +1 -0
- package/apollo-client/IntrospectionFragmentMatcher.d.ts +11 -0
- package/apollo-client/IntrospectionFragmentMatcher.js +45 -0
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -0
- package/components/Image.d.ts +3 -3
- package/components/Image.js +12 -17
- package/components/Image.js.map +1 -0
- package/components/Routes.d.ts +2 -2
- package/components/Routes.js +20 -19
- package/components/Routes.js.map +1 -0
- package/components/View.d.ts +1 -1
- package/components/View.js +13 -17
- package/components/View.js.map +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +4 -1
- package/components/index.js.map +1 -0
- package/config/RouterConfig/Route.d.ts +30 -0
- package/config/RouterConfig/Route.js +42 -0
- package/config/RouterConfig/Route.js.map +1 -0
- package/config/RouterConfig.d.ts +32 -0
- package/config/RouterConfig.js +18 -0
- package/config/RouterConfig.js.map +1 -0
- package/config.d.ts +8 -0
- package/config.js +25 -0
- package/config.js.map +1 -0
- package/contexts/Ui/index.d.ts +5 -8
- package/contexts/Ui/index.js +27 -64
- package/contexts/Ui/index.js.map +1 -0
- package/core/DebounceRender.d.ts +12 -0
- package/core/DebounceRender.js +31 -0
- package/core/DebounceRender.js.map +1 -0
- package/core/Plugin.d.ts +8 -0
- package/core/Plugin.js +14 -0
- package/core/Plugin.js.map +1 -0
- package/core/Plugins.d.ts +15 -0
- package/core/Plugins.js +39 -0
- package/core/Plugins.js.map +1 -0
- package/core/Provider.d.ts +8 -0
- package/core/Provider.js +18 -0
- package/core/Provider.js.map +1 -0
- package/core/Routes.d.ts +6 -0
- package/core/Routes.js +34 -0
- package/core/Routes.js.map +1 -0
- package/core/createProvider.d.ts +10 -0
- package/core/createProvider.js +9 -0
- package/core/createProvider.js.map +1 -0
- package/core/createProviderPlugin.d.ts +8 -0
- package/core/createProviderPlugin.js +17 -0
- package/core/createProviderPlugin.js.map +1 -0
- package/hooks/useAutocomplete/index.js +3 -1
- package/hooks/useAutocomplete/index.js.map +1 -0
- package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -1
- package/hooks/useAutocomplete/useAutocomplete.js +11 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
- package/hooks/useDataList/functions/getData.d.ts +1 -1
- package/hooks/useDataList/functions/getData.js +3 -3
- package/hooks/useDataList/functions/getData.js.map +1 -0
- package/hooks/useDataList/functions/getError.d.ts +1 -1
- package/hooks/useDataList/functions/getError.js +3 -3
- package/hooks/useDataList/functions/getError.js.map +1 -0
- package/hooks/useDataList/functions/getMeta.d.ts +1 -1
- package/hooks/useDataList/functions/getMeta.js +3 -3
- package/hooks/useDataList/functions/getMeta.js.map +1 -0
- package/hooks/useDataList/functions/index.js +3 -1
- package/hooks/useDataList/functions/index.js.map +1 -0
- package/hooks/useDataList/functions/searchDataByKey.d.ts +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +5 -8
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
- package/hooks/useDataList/index.js +3 -1
- package/hooks/useDataList/index.js.map +1 -0
- package/hooks/useDataList/useDataList.d.ts +6 -6
- package/hooks/useDataList/useDataList.js +80 -90
- package/hooks/useDataList/useDataList.js.map +1 -0
- package/hooks/useDataList/utils/index.js +3 -1
- package/hooks/useDataList/utils/index.js.map +1 -0
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +9 -3
- package/hooks/useDataList/utils/prepareLoadListParams.js +35 -31
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +13 -4
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +13 -9
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
- package/hooks/useDataList/utils/types.d.ts +21 -15
- package/hooks/useDataList/utils/types.js +3 -1
- package/hooks/useDataList/utils/types.js.map +1 -0
- package/hooks/useHandler.d.ts +11 -1
- package/hooks/useHandler.js +13 -6
- package/hooks/useHandler.js.map +1 -0
- package/hooks/useHandlers.d.ts +4 -4
- package/hooks/useHandlers.js +15 -11
- package/hooks/useHandlers.js.map +1 -0
- package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
- package/hooks/useRegisterLegacyPlugin.js +11 -0
- package/hooks/useRegisterLegacyPlugin.js.map +1 -0
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +5 -3
- package/hooks/useUi.js.map +1 -0
- package/i18n/i18n.js +3 -1
- package/i18n/i18n.js.map +1 -0
- package/i18n/index.js +3 -1
- package/i18n/index.js.map +1 -0
- package/index.d.ts +17 -0
- package/index.js +20 -0
- package/index.js.map +1 -0
- package/package.json +27 -27
- package/plugins/AddQuerySelectionPlugin.d.ts +10 -3
- package/plugins/AddQuerySelectionPlugin.js +63 -92
- package/plugins/AddQuerySelectionPlugin.js.map +1 -0
- package/plugins/ApolloCacheObjectIdPlugin.d.ts +8 -8
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -36
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
- package/plugins/ApolloDynamicLink.d.ts +3 -1
- package/plugins/ApolloDynamicLink.js +19 -50
- package/plugins/ApolloDynamicLink.js.map +1 -0
- package/plugins/ApolloLinkPlugin.d.ts +6 -6
- package/plugins/ApolloLinkPlugin.js +18 -39
- package/plugins/ApolloLinkPlugin.js.map +1 -0
- package/plugins/ConsoleLinkPlugin.js +19 -40
- package/plugins/ConsoleLinkPlugin.js.map +1 -0
- package/plugins/LocaleHeaderLinkPlugin.d.ts +3 -7
- package/plugins/LocaleHeaderLinkPlugin.js +22 -51
- package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +13 -5
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +21 -31
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +8 -2
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +76 -7
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +6 -4
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +20 -16
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin.js +20 -35
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
- package/plugins/OmitTypenameLinkPlugin.js +11 -31
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +3 -3
- package/plugins/RoutePlugin.js +12 -32
- package/plugins/RoutePlugin.js.map +1 -0
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -7
- package/plugins/TenantHeaderLinkPlugin.js +29 -61
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
- package/plugins/ViewPlugin.d.ts +5 -5
- package/plugins/ViewPlugin.js +15 -37
- package/plugins/ViewPlugin.js.map +1 -0
- package/plugins/image.d.ts +1 -1
- package/plugins/image.js +65 -85
- package/plugins/image.js.map +1 -0
- package/plugins/index.d.ts +3 -3
- package/plugins/index.js +35 -42
- package/plugins/index.js.map +1 -0
- package/react-butterfiles/Files.d.ts +69 -0
- package/react-butterfiles/Files.js +227 -0
- package/react-butterfiles/Files.js.map +1 -0
- package/react-butterfiles/index.d.ts +2 -0
- package/react-butterfiles/index.js +4 -0
- package/react-butterfiles/index.js.map +1 -0
- package/react-butterfiles/utils/generateId.d.ts +1 -0
- package/react-butterfiles/utils/generateId.js +5 -0
- package/react-butterfiles/utils/generateId.js.map +1 -0
- package/react-butterfiles/utils/readFileContent.d.ts +1 -0
- package/react-butterfiles/utils/readFileContent.js +15 -0
- package/react-butterfiles/utils/readFileContent.js.map +1 -0
- package/renderApp.d.ts +2 -0
- package/renderApp.js +9 -0
- package/renderApp.js.map +1 -0
- package/types.d.ts +29 -24
- package/types.js +13 -1
- package/types.js.map +1 -0
- package/utils/createGenericContext.d.ts +13 -0
- package/utils/createGenericContext.js +25 -0
- package/utils/createGenericContext.js.map +1 -0
- package/utils/createHashing.d.ts +2 -0
- package/utils/createHashing.js +18 -0
- package/utils/createHashing.js.map +1 -0
- package/utils/getApiUrl.d.ts +1 -0
- package/utils/getApiUrl.js +5 -0
- package/utils/getApiUrl.js.map +1 -0
- package/utils/getGqlApiUrl.d.ts +1 -0
- package/utils/getGqlApiUrl.js +6 -0
- package/utils/getGqlApiUrl.js.map +1 -0
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
- package/utils/getHeadlessCmsGqlApiUrl.js +12 -0
- package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
- package/utils/getLocaleCode.d.ts +6 -0
- package/utils/getLocaleCode.js +33 -0
- package/utils/getLocaleCode.js.map +1 -0
- package/utils/getPrerenderId.d.ts +6 -0
- package/utils/getPrerenderId.js +5 -0
- package/utils/getPrerenderId.js.map +1 -0
- package/utils/getTenantId.d.ts +6 -0
- package/utils/getTenantId.js +45 -0
- package/utils/getTenantId.js.map +1 -0
- package/utils/index.d.ts +10 -0
- package/utils/index.js +12 -0
- package/utils/index.js.map +1 -0
- package/utils/isLocalhost.d.ts +1 -0
- package/utils/isLocalhost.js +7 -0
- package/utils/isLocalhost.js.map +1 -0
- package/utils/isPrerendering.d.ts +1 -0
- package/utils/isPrerendering.js +5 -0
- package/utils/isPrerendering.js.map +1 -0
- package/utils/legacyPluginToReactComponent.d.ts +7 -0
- package/utils/legacyPluginToReactComponent.js +14 -0
- package/utils/legacyPluginToReactComponent.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","bytes","minimatch","readFileContent","generateId","Files","Component","defaultProps","accept","multiple","maxSize","multipleMaxSize","multipleMaxCount","convertToBase64","input","browseFilesPassedParams","id","validateFiles","files","props","errors","multipleFileSize","length","push","type","index","file","Array","isArray","some","sizeAsBytes","size","maxMultipleMaxSize","multipleCount","processSelectedFiles","eventFiles","onSuccess","onError","callbacks","map","name","src","base64","i","value","onDropFilesHandler","e","dataTransfer","browseFilesHandler","click","render","createElement","Fragment","children","getLabelProps","htmlFor","browseFiles","getDropZoneProps","onDragOver","onDrop","rest","preventDefault","ref","join","style","display","onChange","target"],"sources":["Files.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport minimatch from \"minimatch\";\nimport { readFileContent } from \"./utils/readFileContent\";\nimport { generateId } from \"./utils/generateId\";\n\nexport type SelectedFile = {\n id: string;\n name: string;\n type: string;\n size: number;\n src: {\n file: File;\n base64: string | null;\n };\n};\n\nexport type FileError = {\n id: string;\n type:\n | \"unsupportedFileType\"\n | \"maxSizeExceeded\"\n | \"multipleMaxSizeExceeded\"\n | \"multipleMaxCountExceeded\"\n | \"multipleNotAllowed\";\n index?: number;\n file?: SelectedFile | File;\n multipleFileSize?: number;\n multipleMaxSize?: number;\n multipleMaxCount?: number;\n multipleCount?: number;\n};\n\nexport type BrowseFilesParams = {\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type RenderPropParams = {\n browseFiles: (params: BrowseFilesParams) => void;\n getDropZoneProps: (additionalProps: any) => any;\n getLabelProps: (additionalProps: any) => any;\n validateFiles: (files: SelectedFile[] | File[]) => FileError[];\n};\n\nexport type FilesRules = {\n accept: string[];\n multiple: boolean;\n maxSize: string;\n multipleMaxSize: string;\n multipleMaxCount: number | null;\n convertToBase64: boolean;\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type Props = FilesRules & {\n children: (params: RenderPropParams) => React.ReactNode;\n id?: string;\n};\n\nexport class Files extends React.Component<Props> {\n static defaultProps = {\n accept: [],\n multiple: false,\n maxSize: \"2mb\",\n multipleMaxSize: \"10mb\",\n multipleMaxCount: null,\n convertToBase64: false\n };\n\n input: HTMLInputElement | null = null;\n browseFilesPassedParams: BrowseFilesParams | null = null;\n id: string = generateId();\n\n validateFiles = (files: SelectedFile[] | File[]): FileError[] => {\n const { multiple, multipleMaxSize, multipleMaxCount, accept, maxSize } = this.props;\n\n const errors: FileError[] = [];\n let multipleFileSize = 0;\n\n if (!multiple && files.length > 1) {\n errors.push({\n id: generateId(),\n type: \"multipleNotAllowed\"\n });\n\n return errors;\n }\n\n for (let index = 0; index < files.length; index++) {\n const file = files[index];\n\n if (\n Array.isArray(accept) &&\n accept.length &&\n !accept.some(type => minimatch(file.type, type))\n ) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"unsupportedFileType\"\n });\n } else if (maxSize) {\n const sizeAsBytes = bytes(maxSize);\n if (sizeAsBytes && file.size > sizeAsBytes) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"maxSizeExceeded\"\n });\n }\n }\n\n if (multiple) {\n multipleFileSize += file.size;\n }\n }\n\n if (multiple) {\n const maxMultipleMaxSize = bytes(multipleMaxSize);\n\n if (maxMultipleMaxSize && multipleMaxSize && multipleFileSize > maxMultipleMaxSize) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxSizeExceeded\",\n multipleFileSize,\n multipleMaxSize: maxMultipleMaxSize\n });\n }\n\n if (multipleMaxCount && files.length > multipleMaxCount) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxCountExceeded\",\n multipleCount: files.length,\n multipleMaxCount\n });\n }\n }\n\n return errors;\n };\n\n processSelectedFiles = async (eventFiles: Array<File>) => {\n if (eventFiles.length === 0) {\n return;\n }\n\n const { convertToBase64, onSuccess, onError } = this.props;\n const { browseFilesPassedParams } = this;\n const callbacks = {\n onSuccess,\n onError\n };\n\n if (browseFilesPassedParams && browseFilesPassedParams.onSuccess) {\n callbacks.onSuccess = browseFilesPassedParams.onSuccess;\n }\n\n if (browseFilesPassedParams && browseFilesPassedParams.onError) {\n callbacks.onError = browseFilesPassedParams.onError;\n }\n\n const files: SelectedFile[] = [...eventFiles].map(file => {\n return {\n id: generateId(),\n name: file.name,\n type: file.type,\n size: file.size,\n src: {\n file,\n base64: null\n }\n };\n });\n\n const errors = this.validateFiles(files);\n\n if (errors.length) {\n callbacks.onError && callbacks.onError(errors, files);\n } else {\n if (convertToBase64) {\n for (let i = 0; i < files.length; i++) {\n const file = files[i].src.file;\n files[i].src.base64 = await readFileContent(file);\n }\n }\n\n callbacks.onSuccess && callbacks.onSuccess(files);\n }\n\n // Reset the browseFiles arguments.\n if (this.input) {\n this.input.value = \"\";\n }\n this.browseFilesPassedParams = null;\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n onDropFilesHandler = async ({ e, onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n e.dataTransfer &&\n e.dataTransfer.files &&\n (await this.processSelectedFiles(e.dataTransfer.files));\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n browseFilesHandler = ({ onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n this.input && this.input.click();\n };\n\n override render() {\n const { multiple, accept, id } = this.props;\n return (\n <React.Fragment>\n {this.props.children({\n getLabelProps: (props: any) => {\n return {\n ...props,\n htmlFor: id || this.id\n };\n },\n validateFiles: this.validateFiles,\n browseFiles: ({ onSuccess, onError }: BrowseFilesParams = {}) => {\n this.browseFilesHandler({ onSuccess, onError });\n },\n getDropZoneProps: ({\n onSuccess,\n onError,\n onDragOver,\n onDrop,\n ...rest\n }: any = {}) => {\n return {\n ...rest,\n onDragOver: (e: DragEvent) => {\n e.preventDefault();\n typeof onDragOver === \"function\" && onDragOver();\n },\n onDrop: async (e: DragEvent) => {\n e.preventDefault();\n typeof onDrop === \"function\" && onDrop();\n this.onDropFilesHandler({ e, onSuccess, onError });\n }\n };\n }\n })}\n\n <input\n id={id || this.id}\n ref={ref => {\n if (ref) {\n this.input = ref;\n }\n }}\n accept={accept.join(\",\")}\n style={{ display: \"none\" }}\n type=\"file\"\n multiple={multiple}\n onChange={e =>\n this.processSelectedFiles((e.target.files as any as Array<File>) ?? [])\n }\n />\n </React.Fragment>\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,WAAW;AACjC,SAASC,eAAe;AACxB,SAASC,UAAU;AAyDnB,OAAO,MAAMC,KAAK,SAASL,KAAK,CAACM,SAAS,CAAQ;EAC9C,OAAOC,YAAY,GAAG;IAClBC,MAAM,EAAE,EAAE;IACVC,QAAQ,EAAE,KAAK;IACfC,OAAO,EAAE,KAAK;IACdC,eAAe,EAAE,MAAM;IACvBC,gBAAgB,EAAE,IAAI;IACtBC,eAAe,EAAE;EACrB,CAAC;EAEDC,KAAK,GAA4B,IAAI;EACrCC,uBAAuB,GAA6B,IAAI;EACxDC,EAAE,GAAWZ,UAAU,CAAC,CAAC;EAEzBa,aAAa,GAAIC,KAA8B,IAAkB;IAC7D,MAAM;MAAET,QAAQ;MAAEE,eAAe;MAAEC,gBAAgB;MAAEJ,MAAM;MAAEE;IAAQ,CAAC,GAAG,IAAI,CAACS,KAAK;IAEnF,MAAMC,MAAmB,GAAG,EAAE;IAC9B,IAAIC,gBAAgB,GAAG,CAAC;IAExB,IAAI,CAACZ,QAAQ,IAAIS,KAAK,CAACI,MAAM,GAAG,CAAC,EAAE;MAC/BF,MAAM,CAACG,IAAI,CAAC;QACRP,EAAE,EAAEZ,UAAU,CAAC,CAAC;QAChBoB,IAAI,EAAE;MACV,CAAC,CAAC;MAEF,OAAOJ,MAAM;IACjB;IAEA,KAAK,IAAIK,KAAK,GAAG,CAAC,EA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AI,CAAC,GAAG,CAAE;MACzBC,KAAK,EAAE;QAAEC,OAAO,EAAE;MAAO,CAAE;MAC3BzC,IAAI,EAAC,MAAM;MACXf,QAAQ,EAAEA,QAAS;MACnByD,QAAQ,EAAEpB,CAAC,IACP,IAAI,CAACZ,oBAAoB,CAAEY,CAAC,CAACqB,MAAM,CAACjD,KAAK,IAA2B,EAAE;IACzE,CACJ,CACW,CAAC;EAEzB;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Files"],"sources":["index.ts"],"sourcesContent":["import { Files } from \"./Files\";\n\nexport default Files;\n"],"mappings":"AAAA,SAASA,KAAK;AAEd,eAAeA,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateId: () => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["generateId","Math","random","toString","substr"],"sources":["generateId.ts"],"sourcesContent":["export const generateId = () => {\n return \"_\" + Math.random().toString(36).substr(2, 9);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAGA,CAAA,KAAM;EAC5B,OAAO,GAAG,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readFileContent: (file: File) => Promise<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const readFileContent = async file => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const reader = new window.FileReader();
|
|
4
|
+
reader.onload = function (e) {
|
|
5
|
+
if (e.target) {
|
|
6
|
+
resolve(e.target.result);
|
|
7
|
+
} else {
|
|
8
|
+
reject(`Unable to read file contents!`);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
reader.readAsDataURL(file);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=readFileContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["readFileContent","file","Promise","resolve","reject","reader","window","FileReader","onload","e","target","result","readAsDataURL"],"sources":["readFileContent.ts"],"sourcesContent":["export const readFileContent = async (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new window.FileReader();\n reader.onload = function (e) {\n if (e.target) {\n resolve(e.target.result as string);\n } else {\n reject(`Unable to read file contents!`);\n }\n };\n\n reader.readAsDataURL(file);\n });\n};\n"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAG,MAAOC,IAAU,IAAK;EACjD,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMC,MAAM,GAAG,IAAIC,MAAM,CAACC,UAAU,CAAC,CAAC;IACtCF,MAAM,CAACG,MAAM,GAAG,UAAUC,CAAC,EAAE;MACzB,IAAIA,CAAC,CAACC,MAAM,EAAE;QACVP,OAAO,CAACM,CAAC,CAACC,MAAM,CAACC,MAAgB,CAAC;MACtC,CAAC,MAAM;QACHP,MAAM,CAAC,+BAA+B,CAAC;MAC3C;IACJ,CAAC;IAEDC,MAAM,CAACO,aAAa,CAACX,IAAI,CAAC;EAC9B,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/renderApp.d.ts
ADDED
package/renderApp.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ReactDOMClient from "react-dom/client";
|
|
2
|
+
export const renderApp = app => {
|
|
3
|
+
const container = document.getElementById("root");
|
|
4
|
+
const root = ReactDOMClient.createRoot(container);
|
|
5
|
+
root.render(app);
|
|
6
|
+
return root;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=renderApp.js.map
|
package/renderApp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ReactDOMClient","renderApp","app","container","document","getElementById","root","createRoot","render"],"sources":["renderApp.tsx"],"sourcesContent":["import type { Root } from \"react-dom/client\";\nimport ReactDOMClient from \"react-dom/client\";\n\nexport const renderApp = (app: JSX.Element): Root => {\n const container = document.getElementById(\"root\")!;\n\n const root = ReactDOMClient.createRoot(container);\n root.render(app);\n return root;\n};\n"],"mappings":"AACA,OAAOA,cAAc,MAAM,kBAAkB;AAE7C,OAAO,MAAMC,SAAS,GAAIC,GAAgB,IAAW;EACjD,MAAMC,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,MAAM,CAAE;EAElD,MAAMC,IAAI,GAAGN,cAAc,CAACO,UAAU,CAACJ,SAAS,CAAC;EACjDG,IAAI,CAACE,MAAM,CAACN,GAAG,CAAC;EAChB,OAAOI,IAAI;AACf,CAAC","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,28 +1,35 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import type * as React from "react";
|
|
2
2
|
import { Plugin } from "@webiny/plugins/types";
|
|
3
|
-
import { ApolloClient } from "apollo-client";
|
|
4
|
-
import { CSSProperties } from "react";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
export declare type UploadOptions = {
|
|
3
|
+
import type { ApolloClient } from "apollo-client";
|
|
4
|
+
import type { CSSProperties } from "react";
|
|
5
|
+
export type GenericRecordKey = string | number | symbol;
|
|
6
|
+
export type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;
|
|
7
|
+
export type UploadOptions = {
|
|
10
8
|
apolloClient: ApolloClient<object>;
|
|
9
|
+
onProgress?: (params: {
|
|
10
|
+
sent: number;
|
|
11
|
+
total: number;
|
|
12
|
+
percentage: number;
|
|
13
|
+
}) => void;
|
|
11
14
|
};
|
|
12
|
-
export
|
|
15
|
+
export type UiStatePlugin = Plugin & {
|
|
13
16
|
type: "ui-state";
|
|
14
17
|
render(): React.ReactElement;
|
|
15
18
|
};
|
|
16
|
-
export
|
|
19
|
+
export interface UploadedFile {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
type: string;
|
|
23
|
+
size: number;
|
|
24
|
+
key: string;
|
|
25
|
+
}
|
|
26
|
+
export type FileUploaderPlugin = Plugin & {
|
|
17
27
|
type: "file-uploader";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export declare type AppFileManagerStoragePlugin = Plugin & {
|
|
21
|
-
type: "app-file-manager-storage";
|
|
22
|
-
upload(file: File, options: UploadOptions): Promise<any>;
|
|
28
|
+
name: "file-uploader";
|
|
29
|
+
upload(file: File, options: UploadOptions): Promise<UploadedFile>;
|
|
23
30
|
};
|
|
24
31
|
export { Plugin };
|
|
25
|
-
export
|
|
32
|
+
export interface ImageProps {
|
|
26
33
|
src: string;
|
|
27
34
|
preset?: string;
|
|
28
35
|
transform?: {
|
|
@@ -35,15 +42,17 @@ export declare type ImageProps = {
|
|
|
35
42
|
title?: string;
|
|
36
43
|
alt?: string;
|
|
37
44
|
style?: CSSProperties;
|
|
38
|
-
|
|
45
|
+
width?: string | number;
|
|
46
|
+
height?: string | number;
|
|
47
|
+
}
|
|
39
48
|
/**
|
|
40
49
|
* "getImageSrc" has to be defined as a separate property, so its functionality can be reused outside of
|
|
41
50
|
* the Image component. This is ideal in cases where manual creation of image src is needed.
|
|
42
51
|
*/
|
|
43
|
-
export
|
|
52
|
+
export type ImageComponentPlugin = Plugin & {
|
|
44
53
|
type: "image-component";
|
|
45
54
|
render: (props: ImageProps) => React.ReactElement;
|
|
46
|
-
getImageSrc: (props?:
|
|
55
|
+
getImageSrc: (props?: Record<string, any>) => string;
|
|
47
56
|
presets: {
|
|
48
57
|
[key: string]: any;
|
|
49
58
|
};
|
|
@@ -52,11 +61,7 @@ export declare type ImageComponentPlugin = Plugin & {
|
|
|
52
61
|
* Enables registering new routes.
|
|
53
62
|
* @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route
|
|
54
63
|
*/
|
|
55
|
-
export
|
|
64
|
+
export type RoutePlugin = Plugin & {
|
|
56
65
|
type: "route";
|
|
57
66
|
route: React.ReactElement;
|
|
58
67
|
};
|
|
59
|
-
export declare type CacheGetObjectIdPlugin = Plugin & {
|
|
60
|
-
type: "cache-get-object-id";
|
|
61
|
-
getObjectId(obj: Record<string, any>): string | undefined;
|
|
62
|
-
};
|
package/types.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins/types";
|
|
2
|
-
export { Plugin };
|
|
2
|
+
export { Plugin };
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* "getImageSrc" has to be defined as a separate property, so its functionality can be reused outside of
|
|
6
|
+
* the Image component. This is ideal in cases where manual creation of image src is needed.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Enables registering new routes.
|
|
11
|
+
* @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Plugin"],"sources":["types.ts"],"sourcesContent":["import type * as React from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport type { ApolloClient } from \"apollo-client\";\nimport type { CSSProperties } from \"react\";\n\nexport type GenericRecordKey = string | number | symbol;\n\nexport type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;\n\nexport type UploadOptions = {\n apolloClient: ApolloClient<object>;\n onProgress?: (params: { sent: number; total: number; percentage: number }) => void;\n};\n\nexport type UiStatePlugin = Plugin & {\n type: \"ui-state\";\n render(): React.ReactElement;\n};\n\nexport interface UploadedFile {\n id: string;\n name: string;\n type: string;\n size: number;\n key: string;\n}\n\nexport type FileUploaderPlugin = Plugin & {\n type: \"file-uploader\";\n name: \"file-uploader\";\n upload(file: File, options: UploadOptions): Promise<UploadedFile>;\n};\n\nexport { Plugin };\n\nexport interface ImageProps {\n src: string;\n preset?: string;\n transform?: {\n [key: string]: any;\n };\n // \"auto\" is a special keyword - if present, plugins insert their own srcSet.\n srcSet?: { [key: string]: any } | \"auto\";\n className?: string;\n title?: string;\n alt?: string;\n style?: CSSProperties;\n width?: string | number;\n height?: string | number;\n}\n\n/**\n * \"getImageSrc\" has to be defined as a separate property, so its functionality can be reused outside of\n * the Image component. This is ideal in cases where manual creation of image src is needed.\n */\nexport type ImageComponentPlugin = Plugin & {\n type: \"image-component\";\n render: (props: ImageProps) => React.ReactElement;\n getImageSrc: (props?: Record<string, any>) => string;\n presets: { [key: string]: any };\n};\n\n/**\n * Enables registering new routes.\n * @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route\n */\nexport type RoutePlugin = Plugin & {\n type: \"route\";\n route: React.ReactElement;\n};\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,uBAAuB;AAgC9C,SAASA,MAAM;;AAkBf;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type CreateGenericContext<T = any> = T;
|
|
3
|
+
type GenericContextProviderProps<T> = T & {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare function createGenericContext<T>(name: string): {
|
|
7
|
+
Provider: {
|
|
8
|
+
({ children, ...props }: GenericContextProviderProps<T>): React.JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
useHook: () => NonNullable<T>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { createContext } from "react";
|
|
2
|
+
export function createGenericContext(name) {
|
|
3
|
+
const GenericContext = /*#__PURE__*/createContext(undefined);
|
|
4
|
+
function Provider({
|
|
5
|
+
children,
|
|
6
|
+
...props
|
|
7
|
+
}) {
|
|
8
|
+
return /*#__PURE__*/React.createElement(GenericContext.Provider, {
|
|
9
|
+
value: props
|
|
10
|
+
}, children);
|
|
11
|
+
}
|
|
12
|
+
Provider.displayName = `${name}Provider`;
|
|
13
|
+
return {
|
|
14
|
+
Provider,
|
|
15
|
+
useHook: () => {
|
|
16
|
+
const context = React.useContext(GenericContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw Error(`Context provider for "${name}" is missing in the component tree!`);
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=createGenericContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createContext","createGenericContext","name","GenericContext","undefined","Provider","children","props","createElement","value","displayName","useHook","context","useContext","Error"],"sources":["createGenericContext.tsx"],"sourcesContent":["import React, { createContext } from \"react\";\n\nexport type CreateGenericContext<T = any> = T;\n\ntype GenericContextProviderProps<T> = T & {\n children: React.ReactNode;\n};\n\nexport function createGenericContext<T>(name: string) {\n const GenericContext = createContext<CreateGenericContext | undefined>(undefined);\n\n function Provider({ children, ...props }: GenericContextProviderProps<T>) {\n return <GenericContext.Provider value={props}>{children}</GenericContext.Provider>;\n }\n\n Provider.displayName = `${name}Provider`;\n\n return {\n Provider,\n useHook: () => {\n const context = React.useContext<CreateGenericContext<T>>(\n GenericContext as unknown as React.Context<CreateGenericContext<T>>\n );\n\n if (!context) {\n throw Error(`Context provider for \"${name}\" is missing in the component tree!`);\n }\n\n return context;\n }\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,QAAQ,OAAO;AAQ5C,OAAO,SAASC,oBAAoBA,CAAIC,IAAY,EAAE;EAClD,MAAMC,cAAc,gBAAGH,aAAa,CAAmCI,SAAS,CAAC;EAEjF,SAASC,QAAQA,CAAC;IAAEC,QAAQ;IAAE,GAAGC;EAAsC,CAAC,EAAE;IACtE,oBAAOR,KAAA,CAAAS,aAAA,CAACL,cAAc,CAACE,QAAQ;MAACI,KAAK,EAAEF;IAAM,GAAED,QAAkC,CAAC;EACtF;EAEAD,QAAQ,CAACK,WAAW,GAAG,GAAGR,IAAI,UAAU;EAExC,OAAO;IACHG,QAAQ;IACRM,OAAO,EAAEA,CAAA,KAAM;MACX,MAAMC,OAAO,GAAGb,KAAK,CAACc,UAAU,CAC5BV,cACJ,CAAC;MAED,IAAI,CAACS,OAAO,EAAE;QACV,MAAME,KAAK,CAAC,yBAAyBZ,IAAI,qCAAqC,CAAC;MACnF;MAEA,OAAOU,OAAO;IAClB;EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const createHashing = algorithm => {
|
|
2
|
+
return async value => {
|
|
3
|
+
const data = JSON.stringify(value);
|
|
4
|
+
return new Promise(resolve => {
|
|
5
|
+
window.crypto.subtle.digest(algorithm, new TextEncoder().encode(data)).then(encoded => {
|
|
6
|
+
const hexes = [];
|
|
7
|
+
const view = new DataView(encoded);
|
|
8
|
+
for (let i = 0; i < view.byteLength; i += 4) {
|
|
9
|
+
hexes.push(("00000000" + view.getUint32(i).toString(16)).slice(-8));
|
|
10
|
+
}
|
|
11
|
+
const hash = hexes.join("");
|
|
12
|
+
resolve(hash);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=createHashing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createHashing","algorithm","value","data","JSON","stringify","Promise","resolve","window","crypto","subtle","digest","TextEncoder","encode","then","encoded","hexes","view","DataView","i","byteLength","push","getUint32","toString","slice","hash","join"],"sources":["createHashing.ts"],"sourcesContent":["export type IHashingAlgorithm = \"SHA-1\" | \"SHA-256\" | \"SHA-512\";\n\nexport const createHashing = (algorithm: IHashingAlgorithm) => {\n return async (value: unknown) => {\n const data = JSON.stringify(value);\n return new Promise<string>(resolve => {\n window.crypto.subtle.digest(algorithm, new TextEncoder().encode(data)).then(encoded => {\n const hexes: string[] = [];\n const view = new DataView(encoded);\n for (let i = 0; i < view.byteLength; i += 4) {\n hexes.push((\"00000000\" + view.getUint32(i).toString(16)).slice(-8));\n }\n const hash = hexes.join(\"\");\n resolve(hash);\n });\n });\n };\n};\n"],"mappings":"AAEA,OAAO,MAAMA,aAAa,GAAIC,SAA4B,IAAK;EAC3D,OAAO,MAAOC,KAAc,IAAK;IAC7B,MAAMC,IAAI,GAAGC,IAAI,CAACC,SAAS,CAACH,KAAK,CAAC;IAClC,OAAO,IAAII,OAAO,CAASC,OAAO,IAAI;MAClCC,MAAM,CAACC,MAAM,CAACC,MAAM,CAACC,MAAM,CAACV,SAAS,EAAE,IAAIW,WAAW,CAAC,CAAC,CAACC,MAAM,CAACV,IAAI,CAAC,CAAC,CAACW,IAAI,CAACC,OAAO,IAAI;QACnF,MAAMC,KAAe,GAAG,EAAE;QAC1B,MAAMC,IAAI,GAAG,IAAIC,QAAQ,CAACH,OAAO,CAAC;QAClC,KAAK,IAAII,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,UAAU,EAAED,CAAC,IAAI,CAAC,EAAE;UACzCH,KAAK,CAACK,IAAI,CAAC,CAAC,UAAU,GAAGJ,IAAI,CAACK,SAAS,CAACH,CAAC,CAAC,CAACI,QAAQ,CAAC,EAAE,CAAC,EAAEC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvE;QACA,MAAMC,IAAI,GAAGT,KAAK,CAACU,IAAI,CAAC,EAAE,CAAC;QAC3BnB,OAAO,CAACkB,IAAI,CAAC;MACjB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getApiUrl: (path?: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getApiUrl","path","process","env","REACT_APP_API_URL"],"sources":["getApiUrl.ts"],"sourcesContent":["export const getApiUrl = (path = \"\"): string => {\n return process.env.REACT_APP_API_URL + path;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAGA,CAACC,IAAI,GAAG,EAAE,KAAa;EAC5C,OAAOC,OAAO,CAACC,GAAG,CAACC,iBAAiB,GAAGH,IAAI;AAC/C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGqlApiUrl: () => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getApiUrl","getGqlApiUrl"],"sources":["getGqlApiUrl.ts"],"sourcesContent":["import { getApiUrl } from \"./getApiUrl\";\n\nexport const getGqlApiUrl = (): string => {\n return getApiUrl(\"/graphql\");\n};\n"],"mappings":"AAAA,SAASA,SAAS;AAElB,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAc;EACtC,OAAOD,SAAS,CAAC,UAAU,CAAC;AAChC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getApiUrl } from "./getApiUrl";
|
|
2
|
+
import { getLocaleCode } from "./getLocaleCode";
|
|
3
|
+
export const getHeadlessCmsGqlApiUrl = () => {
|
|
4
|
+
const locale = getLocaleCode();
|
|
5
|
+
return {
|
|
6
|
+
preview: getApiUrl(`/cms/preview/${locale}`),
|
|
7
|
+
read: getApiUrl(`/cms/read/${locale}`),
|
|
8
|
+
manage: getApiUrl(`/cms/manage/${locale}`)
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=getHeadlessCmsGqlApiUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getApiUrl","getLocaleCode","getHeadlessCmsGqlApiUrl","locale","preview","read","manage"],"sources":["getHeadlessCmsGqlApiUrl.ts"],"sourcesContent":["import { getApiUrl } from \"./getApiUrl\";\nimport { getLocaleCode } from \"./getLocaleCode\";\n\nexport const getHeadlessCmsGqlApiUrl = (): { preview: string; read: string; manage: string } => {\n const locale = getLocaleCode();\n return {\n preview: getApiUrl(`/cms/preview/${locale}`),\n read: getApiUrl(`/cms/read/${locale}`),\n manage: getApiUrl(`/cms/manage/${locale}`)\n };\n};\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,SAASC,aAAa;AAEtB,OAAO,MAAMC,uBAAuB,GAAGA,CAAA,KAAyD;EAC5F,MAAMC,MAAM,GAAGF,aAAa,CAAC,CAAC;EAC9B,OAAO;IACHG,OAAO,EAAEJ,SAAS,CAAC,gBAAgBG,MAAM,EAAE,CAAC;IAC5CE,IAAI,EAAEL,SAAS,CAAC,aAAaG,MAAM,EAAE,CAAC;IACtCG,MAAM,EAAEN,SAAS,CAAC,eAAeG,MAAM,EAAE;EAC7C,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isLocalhost } from "./isLocalhost";
|
|
2
|
+
export const getLocaleCode = () => {
|
|
3
|
+
// 1. Get locale via the `__locale` query param. Useful when doing page previews.
|
|
4
|
+
let locale = new URLSearchParams(location.search).get("__locale");
|
|
5
|
+
if (locale) {
|
|
6
|
+
return locale;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 2. Get locale via `window.__PS_RENDER_LOCALE__`. Used with prerendered pages.
|
|
10
|
+
locale = window.__PS_RENDER_LOCALE__;
|
|
11
|
+
if (locale) {
|
|
12
|
+
return locale;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 3. Get locale via `window.localStorage.webiny_i18n_locale`. Used within the Admin app.
|
|
16
|
+
const localesByContext = window.localStorage.webiny_i18n_locale;
|
|
17
|
+
if (localesByContext) {
|
|
18
|
+
// The `localesByContext` is a string that contains locales for all available
|
|
19
|
+
// "locale contexts", for example: `default:en-US;content:en-US;`. Here, we
|
|
20
|
+
// want to extract the locale for the "content" locale context.
|
|
21
|
+
const [, matchedLocale] = localesByContext.match(/content:(.*?);/);
|
|
22
|
+
return matchedLocale;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_LOCALE_CODE`
|
|
26
|
+
// and `WEBINY_ADMIN_LOCALE_CODE` environment variables into consideration.
|
|
27
|
+
if (isLocalhost()) {
|
|
28
|
+
return process.env.WEBINY_WEBSITE_LOCALE_CODE || process.env.WEBINY_ADMIN_LOCALE_CODE || null;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=getLocaleCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isLocalhost","getLocaleCode","locale","URLSearchParams","location","search","get","window","__PS_RENDER_LOCALE__","localesByContext","localStorage","webiny_i18n_locale","matchedLocale","match","process","env","WEBINY_WEBSITE_LOCALE_CODE","WEBINY_ADMIN_LOCALE_CODE"],"sources":["getLocaleCode.ts"],"sourcesContent":["import { isLocalhost } from \"./isLocalhost\";\n\ndeclare global {\n interface Window {\n __PS_RENDER_LOCALE__: string;\n }\n}\n\nexport const getLocaleCode = (): string | null => {\n // 1. Get locale via the `__locale` query param. Useful when doing page previews.\n let locale = new URLSearchParams(location.search).get(\"__locale\");\n if (locale) {\n return locale;\n }\n\n // 2. Get locale via `window.__PS_RENDER_LOCALE__`. Used with prerendered pages.\n locale = window.__PS_RENDER_LOCALE__;\n if (locale) {\n return locale;\n }\n\n // 3. Get locale via `window.localStorage.webiny_i18n_locale`. Used within the Admin app.\n const localesByContext = window.localStorage.webiny_i18n_locale;\n if (localesByContext) {\n // The `localesByContext` is a string that contains locales for all available\n // \"locale contexts\", for example: `default:en-US;content:en-US;`. Here, we\n // want to extract the locale for the \"content\" locale context.\n const [, matchedLocale] = localesByContext.match(/content:(.*?);/);\n return matchedLocale;\n }\n\n // 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_LOCALE_CODE`\n // and `WEBINY_ADMIN_LOCALE_CODE` environment variables into consideration.\n if (isLocalhost()) {\n return (\n process.env.WEBINY_WEBSITE_LOCALE_CODE || process.env.WEBINY_ADMIN_LOCALE_CODE || null\n );\n }\n\n return null;\n};\n"],"mappings":"AAAA,SAASA,WAAW;AAQpB,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAqB;EAC9C;EACA,IAAIC,MAAM,GAAG,IAAIC,eAAe,CAACC,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,CAAC,UAAU,CAAC;EACjE,IAAIJ,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACAA,MAAM,GAAGK,MAAM,CAACC,oBAAoB;EACpC,IAAIN,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACA,MAAMO,gBAAgB,GAAGF,MAAM,CAACG,YAAY,CAACC,kBAAkB;EAC/D,IAAIF,gBAAgB,EAAE;IAClB;IACA;IACA;IACA,MAAM,GAAGG,aAAa,CAAC,GAAGH,gBAAgB,CAACI,KAAK,CAAC,gBAAgB,CAAC;IAClE,OAAOD,aAAa;EACxB;;EAEA;EACA;EACA,IAAIZ,WAAW,CAAC,CAAC,EAAE;IACf,OACIc,OAAO,CAACC,GAAG,CAACC,0BAA0B,IAAIF,OAAO,CAACC,GAAG,CAACE,wBAAwB,IAAI,IAAI;EAE9F;EAEA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getPrerenderId","window"],"sources":["getPrerenderId.ts"],"sourcesContent":["declare global {\n interface Window {\n __PS_RENDER_ID__: string;\n }\n}\n\nexport const getPrerenderId = (): string | null => {\n return window[\"__PS_RENDER_ID__\"] || null;\n};\n"],"mappings":"AAMA,OAAO,MAAMA,cAAc,GAAGA,CAAA,KAAqB;EAC/C,OAAOC,MAAM,CAAC,kBAAkB,CAAC,IAAI,IAAI;AAC7C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isLocalhost } from "./isLocalhost";
|
|
2
|
+
export const getTenantId = () => {
|
|
3
|
+
const urlSearchParams = new URLSearchParams(location.search);
|
|
4
|
+
|
|
5
|
+
// 1. Get tenant via the `__tenant` query param. Useful when doing page previews.
|
|
6
|
+
let tenant = urlSearchParams.get("__tenant");
|
|
7
|
+
if (tenant) {
|
|
8
|
+
return tenant;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 1. Get tenant via the `tenantId` query param. Useful within the Admin app.
|
|
12
|
+
tenant = urlSearchParams.get("tenantId");
|
|
13
|
+
if (tenant) {
|
|
14
|
+
return tenant;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 2. Get tenant via `window.__PS_RENDER_TENANT__`. Used with prerendered pages.
|
|
18
|
+
tenant = window.__PS_RENDER_TENANT__;
|
|
19
|
+
if (tenant) {
|
|
20
|
+
return tenant;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 3. Get tenant via `window.localStorage.webiny_tenant`. Used within the Admin app.
|
|
24
|
+
tenant = window.localStorage.webiny_tenant;
|
|
25
|
+
if (tenant) {
|
|
26
|
+
try {
|
|
27
|
+
const value = JSON.parse(tenant);
|
|
28
|
+
if (value) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// do nothing
|
|
33
|
+
}
|
|
34
|
+
return tenant;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_TENANT_ID`
|
|
38
|
+
// and `WEBINY_ADMIN_TENANT_ID` environment variables into consideration.
|
|
39
|
+
if (isLocalhost()) {
|
|
40
|
+
return process.env.WEBINY_WEBSITE_TENANT_ID || process.env.WEBINY_ADMIN_TENANT_ID || null;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=getTenantId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isLocalhost","getTenantId","urlSearchParams","URLSearchParams","location","search","tenant","get","window","__PS_RENDER_TENANT__","localStorage","webiny_tenant","value","JSON","parse","process","env","WEBINY_WEBSITE_TENANT_ID","WEBINY_ADMIN_TENANT_ID"],"sources":["getTenantId.ts"],"sourcesContent":["import { isLocalhost } from \"~/utils/isLocalhost\";\n\ndeclare global {\n interface Window {\n __PS_RENDER_TENANT__: string;\n }\n}\n\nexport const getTenantId = (): string | null => {\n const urlSearchParams = new URLSearchParams(location.search);\n\n // 1. Get tenant via the `__tenant` query param. Useful when doing page previews.\n let tenant = urlSearchParams.get(\"__tenant\");\n if (tenant) {\n return tenant;\n }\n\n // 1. Get tenant via the `tenantId` query param. Useful within the Admin app.\n tenant = urlSearchParams.get(\"tenantId\");\n if (tenant) {\n return tenant;\n }\n\n // 2. Get tenant via `window.__PS_RENDER_TENANT__`. Used with prerendered pages.\n tenant = window.__PS_RENDER_TENANT__;\n if (tenant) {\n return tenant;\n }\n\n // 3. Get tenant via `window.localStorage.webiny_tenant`. Used within the Admin app.\n tenant = window.localStorage.webiny_tenant;\n if (tenant) {\n try {\n const value = JSON.parse(tenant);\n if (value) {\n return value;\n }\n } catch {\n // do nothing\n }\n return tenant;\n }\n\n // 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_TENANT_ID`\n // and `WEBINY_ADMIN_TENANT_ID` environment variables into consideration.\n if (isLocalhost()) {\n return process.env.WEBINY_WEBSITE_TENANT_ID || process.env.WEBINY_ADMIN_TENANT_ID || null;\n }\n\n return null;\n};\n"],"mappings":"AAAA,SAASA,WAAW;AAQpB,OAAO,MAAMC,WAAW,GAAGA,CAAA,KAAqB;EAC5C,MAAMC,eAAe,GAAG,IAAIC,eAAe,CAACC,QAAQ,CAACC,MAAM,CAAC;;EAE5D;EACA,IAAIC,MAAM,GAAGJ,eAAe,CAACK,GAAG,CAAC,UAAU,CAAC;EAC5C,IAAID,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACAA,MAAM,GAAGJ,eAAe,CAACK,GAAG,CAAC,UAAU,CAAC;EACxC,IAAID,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACAA,MAAM,GAAGE,MAAM,CAACC,oBAAoB;EACpC,IAAIH,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACAA,MAAM,GAAGE,MAAM,CAACE,YAAY,CAACC,aAAa;EAC1C,IAAIL,MAAM,EAAE;IACR,IAAI;MACA,MAAMM,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACR,MAAM,CAAC;MAChC,IAAIM,KAAK,EAAE;QACP,OAAOA,KAAK;MAChB;IACJ,CAAC,CAAC,MAAM;MACJ;IAAA;IAEJ,OAAON,MAAM;EACjB;;EAEA;EACA;EACA,IAAIN,WAAW,CAAC,CAAC,EAAE;IACf,OAAOe,OAAO,CAACC,GAAG,CAACC,wBAAwB,IAAIF,OAAO,CAACC,GAAG,CAACE,sBAAsB,IAAI,IAAI;EAC7F;EAEA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./createHashing";
|
|
2
|
+
export * from "./getApiUrl";
|
|
3
|
+
export * from "./getGqlApiUrl";
|
|
4
|
+
export * from "./getHeadlessCmsGqlApiUrl";
|
|
5
|
+
export * from "./getLocaleCode";
|
|
6
|
+
export * from "./getPrerenderId";
|
|
7
|
+
export * from "./getTenantId";
|
|
8
|
+
export * from "./isLocalhost";
|
|
9
|
+
export * from "./isPrerendering";
|
|
10
|
+
export * from "./legacyPluginToReactComponent";
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./createHashing";
|
|
2
|
+
export * from "./getApiUrl";
|
|
3
|
+
export * from "./getGqlApiUrl";
|
|
4
|
+
export * from "./getHeadlessCmsGqlApiUrl";
|
|
5
|
+
export * from "./getLocaleCode";
|
|
6
|
+
export * from "./getPrerenderId";
|
|
7
|
+
export * from "./getTenantId";
|
|
8
|
+
export * from "./isLocalhost";
|
|
9
|
+
export * from "./isPrerendering";
|
|
10
|
+
export * from "./legacyPluginToReactComponent";
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createHashing\";\nexport * from \"./getApiUrl\";\nexport * from \"./getGqlApiUrl\";\nexport * from \"./getHeadlessCmsGqlApiUrl\";\nexport * from \"./getLocaleCode\";\nexport * from \"./getPrerenderId\";\nexport * from \"./getTenantId\";\nexport * from \"./isLocalhost\";\nexport * from \"./isPrerendering\";\nexport * from \"./legacyPluginToReactComponent\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isLocalhost: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["INCLUDES","isLocalhost","href","window","location","some","current","includes"],"sources":["isLocalhost.ts"],"sourcesContent":["const INCLUDES = [\"localhost\", \"127.0.0.1\"];\n\nexport const isLocalhost = () => {\n const href = window.location.href;\n return INCLUDES.some(current => href.includes(current));\n};\n"],"mappings":"AAAA,MAAMA,QAAQ,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC;AAE3C,OAAO,MAAMC,WAAW,GAAGA,CAAA,KAAM;EAC7B,MAAMC,IAAI,GAAGC,MAAM,CAACC,QAAQ,CAACF,IAAI;EACjC,OAAOF,QAAQ,CAACK,IAAI,CAACC,OAAO,IAAIJ,IAAI,CAACK,QAAQ,CAACD,OAAO,CAAC,CAAC;AAC3D,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isPrerendering: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isPrerendering","window"],"sources":["isPrerendering.ts"],"sourcesContent":["export const isPrerendering = (): boolean => {\n return \"__PS_RENDER__\" in window;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAGA,CAAA,KAAe;EACzC,OAAO,eAAe,IAAIC,MAAM;AACpC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export interface LegacyPluginToReactComponentParams<TProps extends Record<string, any>> {
|
|
3
|
+
pluginType: string;
|
|
4
|
+
componentDisplayName: string;
|
|
5
|
+
mapProps?: (props: TProps) => TProps;
|
|
6
|
+
}
|
|
7
|
+
export declare const legacyPluginToReactComponent: <TProps extends Record<string, any>>(params: LegacyPluginToReactComponentParams<TProps>) => React.FunctionComponent<TProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRegisterLegacyPlugin } from "../hooks/useRegisterLegacyPlugin";
|
|
2
|
+
export const legacyPluginToReactComponent = function (params) {
|
|
3
|
+
const Component = props => {
|
|
4
|
+
const plugin = Object.assign({
|
|
5
|
+
type: params.pluginType
|
|
6
|
+
}, params.mapProps ? params.mapProps(props) : props);
|
|
7
|
+
useRegisterLegacyPlugin(plugin);
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
Component.displayName = params.componentDisplayName;
|
|
11
|
+
return Component;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=legacyPluginToReactComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useRegisterLegacyPlugin","legacyPluginToReactComponent","params","Component","props","plugin","Object","assign","type","pluginType","mapProps","displayName","componentDisplayName"],"sources":["legacyPluginToReactComponent.ts"],"sourcesContent":["import type React from \"react\";\nimport { useRegisterLegacyPlugin } from \"~/hooks/useRegisterLegacyPlugin\";\n\nexport interface LegacyPluginToReactComponentParams<TProps extends Record<string, any>> {\n pluginType: string;\n componentDisplayName: string;\n mapProps?: (props: TProps) => TProps;\n}\n\nexport const legacyPluginToReactComponent = function <TProps extends Record<string, any>>(\n params: LegacyPluginToReactComponentParams<TProps>\n) {\n const Component: React.ComponentType<TProps> = props => {\n const plugin = Object.assign(\n { type: params.pluginType },\n params.mapProps ? params.mapProps(props) : props\n );\n useRegisterLegacyPlugin(plugin);\n return null;\n };\n\n Component.displayName = params.componentDisplayName;\n\n return Component;\n};\n"],"mappings":"AACA,SAASA,uBAAuB;AAQhC,OAAO,MAAMC,4BAA4B,GAAG,SAAAA,CACxCC,MAAkD,EACpD;EACE,MAAMC,SAAsC,GAAGC,KAAK,IAAI;IACpD,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CACxB;MAAEC,IAAI,EAAEN,MAAM,CAACO;IAAW,CAAC,EAC3BP,MAAM,CAACQ,QAAQ,GAAGR,MAAM,CAACQ,QAAQ,CAACN,KAAK,CAAC,GAAGA,KAC/C,CAAC;IACDJ,uBAAuB,CAACK,MAAM,CAAC;IAC/B,OAAO,IAAI;EACf,CAAC;EAEDF,SAAS,CAACQ,WAAW,GAAGT,MAAM,CAACU,oBAAoB;EAEnD,OAAOT,SAAS;AACpB,CAAC","ignoreList":[]}
|