@webiny/app 5.44.1-beta.0 → 5.45.0-beta.0
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 +5 -13
- package/App.js +70 -87
- package/App.js.map +1 -1
- package/AppContainer.d.ts +23 -0
- package/AppContainer.js +9 -0
- package/AppContainer.js.map +1 -0
- package/README.md +7 -15
- package/apollo-client/InMemoryCache.d.ts +3 -2
- package/apollo-client/InMemoryCache.js +16 -47
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.d.ts +2 -2
- package/apollo-client/IntrospectionFragmentMatcher.js +33 -50
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.d.ts +1 -2
- package/components/Image.js +11 -19
- package/components/Image.js.map +1 -1
- package/components/index.d.ts +1 -2
- package/components/index.js +1 -19
- package/components/index.js.map +1 -1
- package/config/RouterConfig/Route.d.ts +29 -0
- package/config/RouterConfig/Route.js +33 -0
- package/config/RouterConfig/Route.js.map +1 -0
- package/config/RouterConfig.d.ts +31 -0
- package/config/RouterConfig.js +18 -0
- package/config/RouterConfig.js.map +1 -0
- package/config.js +9 -15
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +28 -52
- package/contexts/Ui/index.js.map +1 -1
- package/core/DebounceRender.js +13 -24
- package/core/DebounceRender.js.map +1 -1
- package/core/Plugin.d.ts +1 -1
- package/core/Plugin.js +11 -19
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.d.ts +1 -1
- package/core/Plugins.js +20 -25
- package/core/Plugins.js.map +1 -1
- package/core/Provider.d.ts +1 -1
- package/core/Provider.js +9 -13
- package/core/Provider.js.map +1 -1
- package/core/Routes.d.ts +2 -1
- package/core/Routes.js +13 -23
- package/core/Routes.js.map +1 -1
- package/core/createProvider.d.ts +2 -2
- package/core/createProvider.js +1 -7
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.d.ts +1 -1
- package/core/createProviderPlugin.js +4 -10
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.d.ts +9 -0
- package/errors/AuthenticationErrorEvent.js +10 -0
- package/errors/AuthenticationErrorEvent.js.map +1 -0
- package/errors/NetworkErrorEvent.d.ts +15 -0
- package/errors/NetworkErrorEvent.js +10 -0
- package/errors/NetworkErrorEvent.js.map +1 -0
- package/errors/abstractions.d.ts +12 -0
- package/errors/abstractions.js +5 -0
- package/errors/abstractions.js.map +1 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.js +6 -0
- package/errors/index.js.map +1 -0
- package/exports/admin/envConfig.d.ts +1 -0
- package/exports/admin/envConfig.js +3 -0
- package/exports/admin/envConfig.js.map +1 -0
- package/exports/admin/graphqlClient.d.ts +1 -0
- package/exports/admin/graphqlClient.js +3 -0
- package/exports/admin/graphqlClient.js.map +1 -0
- package/exports/admin/localStorage.d.ts +2 -0
- package/exports/admin/localStorage.js +4 -0
- package/exports/admin/localStorage.js.map +1 -0
- package/exports/admin/router.d.ts +4 -0
- package/exports/admin/router.js +6 -0
- package/exports/admin/router.js.map +1 -0
- package/exports/admin/security.d.ts +1 -0
- package/exports/admin/security.js +3 -0
- package/exports/admin/security.js.map +1 -0
- package/exports/admin.d.ts +6 -0
- package/exports/admin.js +8 -0
- package/exports/admin.js.map +1 -0
- package/features/envConfig/EnvConfig.d.ts +6 -0
- package/features/envConfig/EnvConfig.js +14 -0
- package/features/envConfig/EnvConfig.js.map +1 -0
- package/features/envConfig/abstractions.d.ts +27 -0
- package/features/envConfig/abstractions.js +4 -0
- package/features/envConfig/abstractions.js.map +1 -0
- package/features/envConfig/feature.d.ts +17 -0
- package/features/envConfig/feature.js +14 -0
- package/features/envConfig/feature.js.map +1 -0
- package/features/envConfig/index.d.ts +1 -0
- package/features/envConfig/index.js +3 -0
- package/features/envConfig/index.js.map +1 -0
- package/features/eventPublisher/EventPublisher.d.ts +8 -0
- package/features/eventPublisher/EventPublisher.js +27 -0
- package/features/eventPublisher/EventPublisher.js.map +1 -0
- package/features/eventPublisher/abstractions.d.ts +18 -0
- package/features/eventPublisher/abstractions.js +14 -0
- package/features/eventPublisher/abstractions.js.map +1 -0
- package/features/eventPublisher/feature.d.ts +1 -0
- package/features/eventPublisher/feature.js +11 -0
- package/features/eventPublisher/feature.js.map +1 -0
- package/features/eventPublisher/index.d.ts +3 -0
- package/features/eventPublisher/index.js +4 -0
- package/features/eventPublisher/index.js.map +1 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.d.ts +13 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js +35 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -0
- package/features/graphqlClient/BatchingGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/BatchingGraphQLClient.js +164 -0
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -0
- package/features/graphqlClient/FetchGraphQLClient.d.ts +10 -0
- package/features/graphqlClient/FetchGraphQLClient.js +62 -0
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -0
- package/features/graphqlClient/NetworkErrorPublishing.d.ts +14 -0
- package/features/graphqlClient/NetworkErrorPublishing.js +55 -0
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -0
- package/features/graphqlClient/RequestValue.d.ts +20 -0
- package/features/graphqlClient/RequestValue.js +42 -0
- package/features/graphqlClient/RequestValue.js.map +1 -0
- package/features/graphqlClient/RetryGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/RetryGraphQLClient.js +54 -0
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.d.ts +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +350 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -0
- package/features/graphqlClient/abstractions.d.ts +17 -0
- package/features/graphqlClient/abstractions.js +4 -0
- package/features/graphqlClient/abstractions.js.map +1 -0
- package/features/graphqlClient/feature.d.ts +6 -0
- package/features/graphqlClient/feature.js +31 -0
- package/features/graphqlClient/feature.js.map +1 -0
- package/features/graphqlClient/index.d.ts +1 -0
- package/features/graphqlClient/index.js +3 -0
- package/features/graphqlClient/index.js.map +1 -0
- package/features/graphqlClient/types.d.ts +5 -0
- package/features/graphqlClient/types.js +3 -0
- package/features/graphqlClient/types.js.map +1 -0
- package/features/localStorage/BrowserLocalStorageGateway.d.ts +9 -0
- package/features/localStorage/BrowserLocalStorageGateway.js +68 -0
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -0
- package/features/localStorage/LocalStorage.d.ts +12 -0
- package/features/localStorage/LocalStorage.js +31 -0
- package/features/localStorage/LocalStorage.js.map +1 -0
- package/features/localStorage/LocalStorageRepository.d.ts +20 -0
- package/features/localStorage/LocalStorageRepository.js +95 -0
- package/features/localStorage/LocalStorageRepository.js.map +1 -0
- package/features/localStorage/abstractions.d.ts +48 -0
- package/features/localStorage/abstractions.js +19 -0
- package/features/localStorage/abstractions.js.map +1 -0
- package/features/localStorage/feature.d.ts +12 -0
- package/features/localStorage/feature.js +34 -0
- package/features/localStorage/feature.js.map +1 -0
- package/features/localStorage/index.d.ts +1 -0
- package/features/localStorage/index.js +3 -0
- package/features/localStorage/index.js.map +1 -0
- package/features/router/HistoryRouterGateway.d.ts +18 -0
- package/features/router/HistoryRouterGateway.js +82 -0
- package/features/router/HistoryRouterGateway.js.map +1 -0
- package/features/router/HistoryRouterGateway.test.d.ts +1 -0
- package/features/router/HistoryRouterGateway.test.js +204 -0
- package/features/router/HistoryRouterGateway.test.js.map +1 -0
- package/features/router/Route.d.ts +19 -0
- package/features/router/Route.js +59 -0
- package/features/router/Route.js.map +1 -0
- package/features/router/RouteUrl.d.ts +85 -0
- package/features/router/RouteUrl.js +232 -0
- package/features/router/RouteUrl.js.map +1 -0
- package/features/router/Router.d.ts +45 -0
- package/features/router/Router.js +129 -0
- package/features/router/Router.js.map +1 -0
- package/features/router/RouterPresenter.d.ts +17 -0
- package/features/router/RouterPresenter.js +45 -0
- package/features/router/RouterPresenter.js.map +1 -0
- package/features/router/RouterRepository.d.ts +21 -0
- package/features/router/RouterRepository.js +71 -0
- package/features/router/RouterRepository.js.map +1 -0
- package/features/router/RouterRepository.test.d.ts +1 -0
- package/features/router/RouterRepository.test.js +154 -0
- package/features/router/RouterRepository.test.js.map +1 -0
- package/features/router/abstractions.d.ts +68 -0
- package/features/router/abstractions.js +15 -0
- package/features/router/abstractions.js.map +1 -0
- package/features/router/feature.d.ts +4 -0
- package/features/router/feature.js +18 -0
- package/features/router/feature.js.map +1 -0
- package/features/router/index.d.ts +1 -0
- package/features/router/index.js +3 -0
- package/features/router/index.js.map +1 -0
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +3 -0
- package/helpers/InterfaceGenerator/date.js.map +1 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +3 -0
- package/helpers/InterfaceGenerator/id.js.map +1 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +3 -0
- package/helpers/InterfaceGenerator/identity.js.map +1 -0
- package/helpers/InterfaceGenerator/index.d.ts +5 -0
- package/helpers/InterfaceGenerator/index.js +3 -0
- package/helpers/InterfaceGenerator/index.js.map +1 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +3 -0
- package/helpers/InterfaceGenerator/numeric.js.map +1 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +3 -0
- package/helpers/InterfaceGenerator/truthful.js.map +1 -0
- package/hooks/useAutocomplete/index.d.ts +1 -1
- package/hooks/useAutocomplete/index.js +1 -12
- package/hooks/useAutocomplete/index.js.map +1 -1
- package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
- package/hooks/useAutocomplete/useAutocomplete.js +6 -16
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -11
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -11
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -11
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.d.ts +3 -3
- package/hooks/useDataList/functions/index.js +3 -27
- package/hooks/useDataList/functions/index.js.map +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +4 -10
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.d.ts +1 -1
- package/hooks/useDataList/index.js +1 -12
- package/hooks/useDataList/index.js.map +1 -1
- package/hooks/useDataList/useDataList.d.ts +2 -3
- package/hooks/useDataList/useDataList.js +74 -94
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.d.ts +1 -2
- package/hooks/useDataList/utils/index.js +1 -20
- package/hooks/useDataList/utils/index.js.map +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js +10 -16
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +7 -12
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +11 -17
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.d.ts +1 -1
- package/hooks/useRegisterLegacyPlugin.js +5 -11
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +4 -10
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +5 -13
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -13
- package/i18n/index.js.map +1 -1
- package/index.d.ts +23 -15
- package/index.js +25 -177
- package/index.js.map +1 -1
- package/package.json +25 -22
- package/plugins/AddQuerySelectionPlugin.d.ts +2 -2
- package/plugins/AddQuerySelectionPlugin.js +61 -107
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -31
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.d.ts +3 -2
- package/plugins/ApolloDynamicLink.js +19 -46
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.d.ts +1 -1
- package/plugins/ApolloLinkPlugin.js +18 -37
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.d.ts +1 -1
- package/plugins/ConsoleLinkPlugin.js +20 -41
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +8 -13
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +35 -58
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.d.ts +14 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.d.ts +2 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +4 -5
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +68 -12
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.d.ts +8 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js +18 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +3 -3
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +10 -25
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.d.ts +4 -1
- package/plugins/NetworkErrorLinkPlugin.js +60 -37
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.d.ts +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +11 -30
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -3
- package/plugins/TenantHeaderLinkPlugin.js +29 -48
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.d.ts +6 -0
- package/plugins/components/Image.js +19 -0
- package/plugins/components/Image.js.map +1 -0
- package/plugins/image.d.ts +1 -1
- package/plugins/image.js +46 -53
- package/plugins/image.js.map +1 -1
- package/plugins/index.d.ts +4 -4
- package/plugins/index.js +31 -53
- package/plugins/index.js.map +1 -1
- package/presentation/localStorage/index.d.ts +3 -0
- package/presentation/localStorage/index.js +5 -0
- package/presentation/localStorage/index.js.map +1 -0
- package/presentation/localStorage/useLocalStorage.d.ts +6 -0
- package/presentation/localStorage/useLocalStorage.js +21 -0
- package/presentation/localStorage/useLocalStorage.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValue.d.ts +1 -0
- package/presentation/localStorage/useLocalStorageValue.js +20 -0
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValues.d.ts +5 -0
- package/presentation/localStorage/useLocalStorageValues.js +39 -0
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -0
- package/presentation/router/RouteElementRegistry.d.ts +14 -0
- package/presentation/router/RouteElementRegistry.js +32 -0
- package/presentation/router/RouteElementRegistry.js.map +1 -0
- package/presentation/router/abstractions.d.ts +13 -0
- package/presentation/router/abstractions.js +4 -0
- package/presentation/router/abstractions.js.map +1 -0
- package/presentation/router/components/RouteContent.d.ts +2 -0
- package/presentation/router/components/RouteContent.js +17 -0
- package/presentation/router/components/RouteContent.js.map +1 -0
- package/presentation/router/components/RouteLink.d.ts +50 -0
- package/presentation/router/components/RouteLink.js +22 -0
- package/presentation/router/components/RouteLink.js.map +1 -0
- package/presentation/router/components/SimpleLink.d.ts +44 -0
- package/presentation/router/components/SimpleLink.js +30 -0
- package/presentation/router/components/SimpleLink.js.map +1 -0
- package/presentation/router/hooks/useRoute.d.ts +6 -0
- package/presentation/router/hooks/useRoute.js +30 -0
- package/presentation/router/hooks/useRoute.js.map +1 -0
- package/presentation/router/hooks/useRouter.d.ts +7 -0
- package/presentation/router/hooks/useRouter.js +26 -0
- package/presentation/router/hooks/useRouter.js.map +1 -0
- package/presentation/router/index.d.ts +4 -0
- package/presentation/router/index.js +5 -0
- package/presentation/router/index.js.map +1 -0
- package/presentation/router/types.d.ts +5 -0
- package/presentation/router/types.js +3 -0
- package/presentation/router/types.js.map +1 -0
- package/react-butterfiles/Files.js +208 -235
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/file.todo +1 -0
- package/react-butterfiles/index.d.ts +1 -1
- package/react-butterfiles/index.js +2 -8
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +1 -7
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +4 -10
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.d.ts +1 -1
- package/renderApp.js +4 -11
- package/renderApp.js.map +1 -1
- package/router.d.ts +5 -0
- package/router.js +8 -0
- package/router.js.map +1 -0
- package/shared/di/DiContainerProvider.d.ts +8 -0
- package/shared/di/DiContainerProvider.js +17 -0
- package/shared/di/DiContainerProvider.js.map +1 -0
- package/shared/di/createFeature.d.ts +11 -0
- package/shared/di/createFeature.js +11 -0
- package/shared/di/createFeature.js.map +1 -0
- package/shared/di/useFeature.d.ts +2 -0
- package/shared/di/useFeature.js +18 -0
- package/shared/di/useFeature.js.map +1 -0
- package/types.d.ts +9 -6
- package/types.js +1 -12
- package/types.js.map +1 -1
- package/utils/createGenericContext.js +13 -22
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +9 -15
- package/utils/createHashing.js.map +1 -1
- package/utils/index.d.ts +2 -10
- package/utils/index.js +2 -115
- package/utils/index.js.map +1 -1
- package/utils/legacyPluginToReactComponent.d.ts +1 -1
- package/utils/legacyPluginToReactComponent.js +5 -11
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/Routes.d.ts +0 -2
- package/components/Routes.js +0 -46
- package/components/Routes.js.map +0 -1
- package/components/View.d.ts +0 -8
- package/components/View.js +0 -31
- package/components/View.js.map +0 -1
- package/core/AddRoute.d.ts +0 -21
- package/core/AddRoute.js +0 -21
- package/core/AddRoute.js.map +0 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -30
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
- package/hooks/useDataList/utils/types.d.ts +0 -40
- package/hooks/useDataList/utils/types.js +0 -7
- package/hooks/useDataList/utils/types.js.map +0 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -10
- package/plugins/LocaleHeaderLinkPlugin.js +0 -49
- package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -12
- package/plugins/RoutePlugin.js +0 -35
- package/plugins/RoutePlugin.js.map +0 -1
- package/plugins/ViewPlugin.d.ts +0 -14
- package/plugins/ViewPlugin.js +0 -40
- package/plugins/ViewPlugin.js.map +0 -1
- package/utils/getApiUrl.d.ts +0 -1
- package/utils/getApiUrl.js +0 -12
- package/utils/getApiUrl.js.map +0 -1
- package/utils/getGqlApiUrl.d.ts +0 -1
- package/utils/getGqlApiUrl.js +0 -12
- package/utils/getGqlApiUrl.js.map +0 -1
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +0 -5
- package/utils/getHeadlessCmsGqlApiUrl.js +0 -18
- package/utils/getHeadlessCmsGqlApiUrl.js.map +0 -1
- package/utils/getLocaleCode.d.ts +0 -6
- package/utils/getLocaleCode.js +0 -43
- package/utils/getLocaleCode.js.map +0 -1
- package/utils/getPrerenderId.d.ts +0 -6
- package/utils/getPrerenderId.js +0 -11
- package/utils/getPrerenderId.js.map +0 -1
- package/utils/getTenantId.d.ts +0 -6
- package/utils/getTenantId.js +0 -51
- package/utils/getTenantId.js.map +0 -1
- package/utils/isLocalhost.d.ts +0 -1
- package/utils/isLocalhost.js +0 -15
- package/utils/isLocalhost.js.map +0 -1
- package/utils/isPrerendering.d.ts +0 -1
- package/utils/isPrerendering.js +0 -11
- package/utils/isPrerendering.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_bytes","_minimatch","_readFileContent","_generateId","_excluded","Files","exports","_React$Component","_this","_classCallCheck2","default","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","generateId","files","_this$props","props","multiple","multipleMaxSize","multipleMaxCount","accept","maxSize","errors","multipleFileSize","push","id","type","_loop","file","index","isArray","some","minimatch","sizeAsBytes","bytes","size","maxMultipleMaxSize","multipleCount","eventFiles","_this$props2","convertToBase64","onSuccess","onError","_this2","browseFilesPassedParams","callbacks","_toConsumableArray2","map","name","src","base64","validateFiles","i","readFileContent","input","value","_ref","e","dataTransfer","processSelectedFiles","_ref2","click","_inherits2","_createClass2","key","render","_this3","_this$props3","createElement","Fragment","children","getLabelProps","_objectSpread2","htmlFor","browseFiles","_ref3","undefined","browseFilesHandler","getDropZoneProps","_ref4","onDragOver","onDrop","rest","_objectWithoutProperties2","preventDefault","onDropFilesHandler","ref","join","style","display","onChange","target","React","Component"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAAgD,IAAAK,SAAA;AAAA,IAyDnCC,KAAK,GAAAC,OAAA,CAAAD,KAAA,0BAAAE,gBA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AM,KAAK,UAAU,IAAIA,OAAM,CAAC,CAAC;cACxCf,MAAI,CAACmB,kBAAkB,CAAC;gBAAE5B,CAAC,EAADA,CAAC;gBAAEhB,SAAS,EAATA,SAAS;gBAAEC,OAAO,EAAPA;cAAQ,CAAC,CAAC;YACtD;UAAC;QAET;MACJ,CAAC,CAAC,eAEFpD,MAAA,CAAAa,OAAA,CAAAiE,aAAA;QACI3C,EAAE,EAAEA,EAAE,IAAI,IAAI,CAACA,EAAG;QAClB6D,GAAG,EAAE,SAALA,GAAGA,CAAEA,KAAG,EAAI;UACR,IAAIA,KAAG,EAAE;YACLpB,MAAI,CAACZ,KAAK,GAAGgC,KAAG;UACpB;QACJ,CAAE;QACFlE,MAAM,EAAEA,MAAM,CAACmE,IAAI,CAAC,GAAG,CAAE;QACzBC,KAAK,EAAE;UAAEC,OAAO,EAAE;QAAO,CAAE;QAC3B/D,IAAI,EAAC,MAAM;QACXT,QAAQ,EAAEA,QAAS;QACnByE,QAAQ,EAAE,SAAVA,QAAQA,CAAEjC,CAAC;UAAA,OACPS,MAAI,CAACP,oBAAoB,CAAEF,CAAC,CAACkC,MAAM,CAAC7E,KAAK,IAA2B,EAAE,CAAC;QAAA;MAC1E,CACJ,CACW,CAAC;IAEzB;EAAC;AAAA,EApNsB8E,cAAK,CAACC,SAAS;AAAA,IAAAjF,gBAAA,CAAAT,OAAA,EAA7BL,KAAK,kBACQ;EAClBsB,MAAM,EAAE,EAAE;EACVH,QAAQ,EAAE,KAAK;EACfI,OAAO,EAAE,KAAK;EACdH,eAAe,EAAE,MAAM;EACvBC,gBAAgB,EAAE,IAAI;EACtBqB,eAAe,EAAE;AACrB,CAAC","ignoreList":[]}
|
|
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.js\";\nimport { generateId } from \"./utils/generateId.js\";\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.process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B,EAAE;IACzE,CACJ,CACW,CAAC;EAEzB;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
delete this folder?
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Files } from "./Files";
|
|
1
|
+
import { Files } from "./Files.js";
|
|
2
2
|
export default Files;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _Files = require("./Files");
|
|
8
|
-
var _default = exports.default = _Files.Files;
|
|
1
|
+
import { Files } from "./Files.js";
|
|
2
|
+
export default Files;
|
|
9
3
|
|
|
10
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Files"],"sources":["index.ts"],"sourcesContent":["import { Files } from \"./Files.js\";\n\nexport default Files;\n"],"mappings":"AAAA,SAASA,KAAK;AAEd,eAAeA,KAAK","ignoreList":[]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateId = void 0;
|
|
7
|
-
var generateId = exports.generateId = function generateId() {
|
|
1
|
+
export const generateId = () => {
|
|
8
2
|
return "_" + Math.random().toString(36).substr(2, 9);
|
|
9
3
|
};
|
|
10
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["generateId","
|
|
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":[]}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.readFileContent = void 0;
|
|
7
|
-
var readFileContent = exports.readFileContent = async function readFileContent(file) {
|
|
8
|
-
return new Promise(function (resolve, reject) {
|
|
9
|
-
var reader = new window.FileReader();
|
|
1
|
+
export const readFileContent = async file => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const reader = new window.FileReader();
|
|
10
4
|
reader.onload = function (e) {
|
|
11
5
|
if (e.target) {
|
|
12
6
|
resolve(e.target.result);
|
|
13
7
|
} else {
|
|
14
|
-
reject(
|
|
8
|
+
reject(`Unable to read file contents!`);
|
|
15
9
|
}
|
|
16
10
|
};
|
|
17
11
|
reader.readAsDataURL(file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["readFileContent","
|
|
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
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Root } from "react-dom/client";
|
|
1
|
+
import type { Root } from "react-dom/client";
|
|
2
2
|
export declare const renderApp: (app: JSX.Element) => Root;
|
package/renderApp.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.renderApp = void 0;
|
|
8
|
-
var _client = _interopRequireDefault(require("react-dom/client"));
|
|
9
|
-
var renderApp = exports.renderApp = function renderApp(app) {
|
|
10
|
-
var container = document.getElementById("root");
|
|
11
|
-
var root = _client.default.createRoot(container);
|
|
1
|
+
import ReactDOMClient from "react-dom/client";
|
|
2
|
+
export const renderApp = app => {
|
|
3
|
+
const container = document.getElementById("root");
|
|
4
|
+
const root = ReactDOMClient.createRoot(container);
|
|
12
5
|
root.render(app);
|
|
13
6
|
return root;
|
|
14
7
|
};
|
package/renderApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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/router.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Route } from "./features/router/Route.js";
|
|
2
|
+
export { useRouter } from "./presentation/router/hooks/useRouter.js";
|
|
3
|
+
export { useRoute } from "./presentation/router/hooks/useRoute.js";
|
|
4
|
+
export { RouteLink, type RouteLinkProps } from "./presentation/router/components/RouteLink.js";
|
|
5
|
+
export { SimpleLink, type SimpleLinkProps } from "./presentation/router/components/SimpleLink.js";
|
package/router.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Router
|
|
2
|
+
export { Route } from "./features/router/Route.js";
|
|
3
|
+
export { useRouter } from "./presentation/router/hooks/useRouter.js";
|
|
4
|
+
export { useRoute } from "./presentation/router/hooks/useRoute.js";
|
|
5
|
+
export { RouteLink } from "./presentation/router/components/RouteLink.js";
|
|
6
|
+
export { SimpleLink } from "./presentation/router/components/SimpleLink.js";
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=router.js.map
|
package/router.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Route","useRouter","useRoute","RouteLink","SimpleLink"],"sources":["router.ts"],"sourcesContent":["// Router\nexport { Route } from \"./features/router/Route.js\";\nexport { useRouter } from \"./presentation/router/hooks/useRouter.js\";\nexport { useRoute } from \"./presentation/router/hooks/useRoute.js\";\nexport { RouteLink, type RouteLinkProps } from \"./presentation/router/components/RouteLink.js\";\nexport { SimpleLink, type SimpleLinkProps } from \"./presentation/router/components/SimpleLink.js\";\n"],"mappings":"AAAA;AACA,SAASA,KAAK;AACd,SAASC,SAAS;AAClB,SAASC,QAAQ;AACjB,SAASC,SAAS;AAClB,SAASC,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Container } from "@webiny/di";
|
|
3
|
+
export interface DiContainerProviderProps {
|
|
4
|
+
container: Container;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const DiContainerProvider: ({ container, children }: DiContainerProviderProps) => React.JSX.Element;
|
|
8
|
+
export declare const useContainer: () => Container;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createGenericContext } from "../../utils/createGenericContext.js";
|
|
3
|
+
const DiContainerContext = createGenericContext("DiContainer");
|
|
4
|
+
export const DiContainerProvider = ({
|
|
5
|
+
container,
|
|
6
|
+
children
|
|
7
|
+
}) => {
|
|
8
|
+
return /*#__PURE__*/React.createElement(DiContainerContext.Provider, {
|
|
9
|
+
container: container
|
|
10
|
+
}, children);
|
|
11
|
+
};
|
|
12
|
+
export const useContainer = () => {
|
|
13
|
+
const context = DiContainerContext.useHook();
|
|
14
|
+
return context.container;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=DiContainerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createGenericContext","DiContainerContext","DiContainerProvider","container","children","createElement","Provider","useContainer","context","useHook"],"sources":["DiContainerProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { Container } from \"@webiny/di\";\nimport { createGenericContext } from \"~/utils/createGenericContext.js\";\n\ntype DiContainerContext = { container: Container };\n\nconst DiContainerContext = createGenericContext<DiContainerContext>(\"DiContainer\");\n\nexport interface DiContainerProviderProps {\n container: Container;\n children: React.ReactNode;\n}\n\nexport const DiContainerProvider = ({ container, children }: DiContainerProviderProps) => {\n return (\n <DiContainerContext.Provider container={container}>{children}</DiContainerContext.Provider>\n );\n};\n\nexport const useContainer = () => {\n const context = DiContainerContext.useHook();\n\n return context.container;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,oBAAoB;AAI7B,MAAMC,kBAAkB,GAAGD,oBAAoB,CAAqB,aAAa,CAAC;AAOlF,OAAO,MAAME,mBAAmB,GAAGA,CAAC;EAAEC,SAAS;EAAEC;AAAmC,CAAC,KAAK;EACtF,oBACIL,KAAA,CAAAM,aAAA,CAACJ,kBAAkB,CAACK,QAAQ;IAACH,SAAS,EAAEA;EAAU,GAAEC,QAAsC,CAAC;AAEnG,CAAC;AAED,OAAO,MAAMG,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAMC,OAAO,GAAGP,kBAAkB,CAACQ,OAAO,CAAC,CAAC;EAE5C,OAAOD,OAAO,CAACL,SAAS;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Container } from "@webiny/di";
|
|
2
|
+
export interface FeatureDefinition<TExports = any, TParams extends any[] = []> {
|
|
3
|
+
name: string;
|
|
4
|
+
register: (container: Container, ...args: TParams) => void;
|
|
5
|
+
resolve: (container: Container) => TExports;
|
|
6
|
+
}
|
|
7
|
+
export declare function createFeature<TExports = any, TParams extends any[] = []>(def: {
|
|
8
|
+
name: string;
|
|
9
|
+
register: (container: Container, ...args: TParams) => void;
|
|
10
|
+
resolve: (container: Container) => TExports;
|
|
11
|
+
}): FeatureDefinition<TExports, TParams>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","def","name","register","resolve","container"],"sources":["createFeature.ts"],"sourcesContent":["import { Container } from \"@webiny/di\";\n\nexport interface FeatureDefinition<TExports = any, TParams extends any[] = []> {\n name: string;\n register: (container: Container, ...args: TParams) => void;\n resolve: (container: Container) => TExports;\n}\n\nexport function createFeature<\n TExports = any,\n TParams extends any[] = [] // tuple for extra args\n>(def: {\n name: string;\n register: (container: Container, ...args: TParams) => void;\n resolve: (container: Container) => TExports;\n}): FeatureDefinition<TExports, TParams> {\n return {\n name: def.name,\n register: def.register,\n resolve: (container: Container): TExports => {\n return def.resolve(container);\n }\n };\n}\n"],"mappings":"AAQA,OAAO,SAASA,aAAaA,CAG3BC,GAID,EAAwC;EACrC,OAAO;IACHC,IAAI,EAAED,GAAG,CAACC,IAAI;IACdC,QAAQ,EAAEF,GAAG,CAACE,QAAQ;IACtBC,OAAO,EAAGC,SAAoB,IAAe;MACzC,OAAOJ,GAAG,CAACG,OAAO,CAACC,SAAS,CAAC;IACjC;EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContainer } from "./DiContainerProvider.js";
|
|
2
|
+
const featureCache = new WeakMap();
|
|
3
|
+
export function useFeature(feature) {
|
|
4
|
+
const container = useContainer();
|
|
5
|
+
let featureMap = featureCache.get(container);
|
|
6
|
+
if (!featureMap) {
|
|
7
|
+
featureMap = new Map();
|
|
8
|
+
featureCache.set(container, featureMap);
|
|
9
|
+
}
|
|
10
|
+
if (featureMap.has(feature.name)) {
|
|
11
|
+
return featureMap.get(feature.name);
|
|
12
|
+
}
|
|
13
|
+
const exports = feature.resolve(container);
|
|
14
|
+
featureMap.set(feature.name, exports);
|
|
15
|
+
return exports;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=useFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContainer","featureCache","WeakMap","useFeature","feature","container","featureMap","get","Map","set","has","name","exports","resolve"],"sources":["useFeature.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { useContainer } from \"./DiContainerProvider.js\";\nimport { FeatureDefinition } from \"./createFeature.js\";\n\nconst featureCache = new WeakMap<Container, Map<string, unknown>>();\n\nexport function useFeature<TExports>(feature: FeatureDefinition<TExports, any[]>): TExports {\n const container = useContainer();\n\n let featureMap = featureCache.get(container);\n if (!featureMap) {\n featureMap = new Map();\n featureCache.set(container, featureMap);\n }\n\n if (featureMap.has(feature.name)) {\n return featureMap.get(feature.name) as TExports;\n }\n\n const exports = feature.resolve(container);\n featureMap.set(feature.name, exports);\n return exports;\n}\n"],"mappings":"AACA,SAASA,YAAY;AAGrB,MAAMC,YAAY,GAAG,IAAIC,OAAO,CAAkC,CAAC;AAEnE,OAAO,SAASC,UAAUA,CAAWC,OAA2C,EAAY;EACxF,MAAMC,SAAS,GAAGL,YAAY,CAAC,CAAC;EAEhC,IAAIM,UAAU,GAAGL,YAAY,CAACM,GAAG,CAACF,SAAS,CAAC;EAC5C,IAAI,CAACC,UAAU,EAAE;IACbA,UAAU,GAAG,IAAIE,GAAG,CAAC,CAAC;IACtBP,YAAY,CAACQ,GAAG,CAACJ,SAAS,EAAEC,UAAU,CAAC;EAC3C;EAEA,IAAIA,UAAU,CAACI,GAAG,CAACN,OAAO,CAACO,IAAI,CAAC,EAAE;IAC9B,OAAOL,UAAU,CAACC,GAAG,CAACH,OAAO,CAACO,IAAI,CAAC;EACvC;EAEA,MAAMC,OAAO,GAAGR,OAAO,CAACS,OAAO,CAACR,SAAS,CAAC;EAC1CC,UAAU,CAACG,GAAG,CAACL,OAAO,CAACO,IAAI,EAAEC,OAAO,CAAC;EACrC,OAAOA,OAAO;AAClB","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
3
|
+
import { Plugin } from "@webiny/plugins/types.js";
|
|
4
|
+
import type { ApolloClient } from "apollo-client";
|
|
5
5
|
export type GenericRecordKey = string | number | symbol;
|
|
6
6
|
export type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;
|
|
7
|
+
export type NonEmptyArray<T> = [T, ...T[]];
|
|
7
8
|
export type UploadOptions = {
|
|
8
9
|
apolloClient: ApolloClient<object>;
|
|
9
10
|
onProgress?: (params: {
|
|
@@ -28,7 +29,7 @@ export type FileUploaderPlugin = Plugin & {
|
|
|
28
29
|
name: "file-uploader";
|
|
29
30
|
upload(file: File, options: UploadOptions): Promise<UploadedFile>;
|
|
30
31
|
};
|
|
31
|
-
export { Plugin };
|
|
32
|
+
export type { Plugin };
|
|
32
33
|
export interface ImageProps {
|
|
33
34
|
src: string;
|
|
34
35
|
preset?: string;
|
|
@@ -63,5 +64,7 @@ export type ImageComponentPlugin = Plugin & {
|
|
|
63
64
|
*/
|
|
64
65
|
export type RoutePlugin = Plugin & {
|
|
65
66
|
type: "route";
|
|
66
|
-
route: React.ReactElement
|
|
67
|
+
route: React.ReactElement<{
|
|
68
|
+
path: string;
|
|
69
|
+
}>;
|
|
67
70
|
};
|
package/types.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Plugin", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _types.Plugin;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _types = require("@webiny/plugins/types");
|
|
1
|
+
export {};
|
|
13
2
|
|
|
14
3
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { Plugin } from \"@webiny/plugins/types.js\";\nimport type { ApolloClient } from \"apollo-client\";\n\nexport type GenericRecordKey = string | number | symbol;\n\nexport type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\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 type { 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<{ path: string }>;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _excluded = ["children"];
|
|
12
|
-
function createGenericContext(name) {
|
|
13
|
-
var GenericContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
14
|
-
function Provider(_ref) {
|
|
15
|
-
var children = _ref.children,
|
|
16
|
-
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
17
|
-
return /*#__PURE__*/_react.default.createElement(GenericContext.Provider, {
|
|
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, {
|
|
18
9
|
value: props
|
|
19
10
|
}, children);
|
|
20
11
|
}
|
|
21
|
-
Provider.displayName =
|
|
12
|
+
Provider.displayName = `${name}Provider`;
|
|
22
13
|
return {
|
|
23
|
-
Provider
|
|
24
|
-
useHook:
|
|
25
|
-
|
|
14
|
+
Provider,
|
|
15
|
+
useHook: () => {
|
|
16
|
+
const context = React.useContext(GenericContext);
|
|
26
17
|
if (!context) {
|
|
27
|
-
throw Error(
|
|
18
|
+
throw Error(`Context provider for "${name}" is missing in the component tree!`);
|
|
28
19
|
}
|
|
29
20
|
return context;
|
|
30
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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":[]}
|
package/utils/createHashing.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var data = JSON.stringify(value);
|
|
10
|
-
return new Promise(function (resolve) {
|
|
11
|
-
window.crypto.subtle.digest(algorithm, new TextEncoder().encode(data)).then(function (encoded) {
|
|
12
|
-
var hexes = [];
|
|
13
|
-
var view = new DataView(encoded);
|
|
14
|
-
for (var i = 0; i < view.byteLength; i += 4) {
|
|
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) {
|
|
15
9
|
hexes.push(("00000000" + view.getUint32(i).toString(16)).slice(-8));
|
|
16
10
|
}
|
|
17
|
-
|
|
11
|
+
const hash = hexes.join("");
|
|
18
12
|
resolve(hash);
|
|
19
13
|
});
|
|
20
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createHashing","
|
|
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":[]}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
export * from "./createHashing";
|
|
2
|
-
export * from "./
|
|
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";
|
|
1
|
+
export * from "./createHashing.js";
|
|
2
|
+
export * from "./legacyPluginToReactComponent.js";
|
package/utils/index.js
CHANGED
|
@@ -1,117 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _createHashing = require("./createHashing");
|
|
7
|
-
Object.keys(_createHashing).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _createHashing[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _createHashing[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _getApiUrl = require("./getApiUrl");
|
|
18
|
-
Object.keys(_getApiUrl).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _getApiUrl[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function get() {
|
|
24
|
-
return _getApiUrl[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _getGqlApiUrl = require("./getGqlApiUrl");
|
|
29
|
-
Object.keys(_getGqlApiUrl).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _getGqlApiUrl[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function get() {
|
|
35
|
-
return _getGqlApiUrl[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _getHeadlessCmsGqlApiUrl = require("./getHeadlessCmsGqlApiUrl");
|
|
40
|
-
Object.keys(_getHeadlessCmsGqlApiUrl).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _getHeadlessCmsGqlApiUrl[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function get() {
|
|
46
|
-
return _getHeadlessCmsGqlApiUrl[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _getLocaleCode = require("./getLocaleCode");
|
|
51
|
-
Object.keys(_getLocaleCode).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _getLocaleCode[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function get() {
|
|
57
|
-
return _getLocaleCode[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _getPrerenderId = require("./getPrerenderId");
|
|
62
|
-
Object.keys(_getPrerenderId).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _getPrerenderId[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function get() {
|
|
68
|
-
return _getPrerenderId[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _getTenantId = require("./getTenantId");
|
|
73
|
-
Object.keys(_getTenantId).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _getTenantId[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function get() {
|
|
79
|
-
return _getTenantId[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
var _isLocalhost = require("./isLocalhost");
|
|
84
|
-
Object.keys(_isLocalhost).forEach(function (key) {
|
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
|
86
|
-
if (key in exports && exports[key] === _isLocalhost[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function get() {
|
|
90
|
-
return _isLocalhost[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
var _isPrerendering = require("./isPrerendering");
|
|
95
|
-
Object.keys(_isPrerendering).forEach(function (key) {
|
|
96
|
-
if (key === "default" || key === "__esModule") return;
|
|
97
|
-
if (key in exports && exports[key] === _isPrerendering[key]) return;
|
|
98
|
-
Object.defineProperty(exports, key, {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function get() {
|
|
101
|
-
return _isPrerendering[key];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
var _legacyPluginToReactComponent = require("./legacyPluginToReactComponent");
|
|
106
|
-
Object.keys(_legacyPluginToReactComponent).forEach(function (key) {
|
|
107
|
-
if (key === "default" || key === "__esModule") return;
|
|
108
|
-
if (key in exports && exports[key] === _legacyPluginToReactComponent[key]) return;
|
|
109
|
-
Object.defineProperty(exports, key, {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function get() {
|
|
112
|
-
return _legacyPluginToReactComponent[key];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
1
|
+
export * from "./createHashing.js";
|
|
2
|
+
export * from "./legacyPluginToReactComponent.js";
|
|
116
3
|
|
|
117
4
|
//# sourceMappingURL=index.js.map
|