@enonic/nextjs-adapter 3.2.2 → 3.3.0-B2
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/{baseMappings.js → dist/baseMappings.js} +9 -9
- package/dist/baseMappings.js.map +1 -0
- package/dist/client/getClientHydratedHtml.jsx.map +1 -0
- package/dist/client.js.map +1 -0
- package/{common → dist/common}/ComponentRegistry.js +1 -1
- package/dist/common/ComponentRegistry.js.map +1 -0
- package/dist/common/UrlProcessor.js.map +1 -0
- package/dist/common/constants.js.map +1 -0
- package/{common → dist/common}/env.js +1 -1
- package/dist/common/env.js.map +1 -0
- package/dist/guillotine/applyProcessors.js.map +1 -0
- package/dist/guillotine/buildComponentTree.js.map +1 -0
- package/{guillotine → dist/guillotine}/buildErrorResponse.js +3 -3
- package/dist/guillotine/buildErrorResponse.js.map +1 -0
- package/{guillotine → dist/guillotine}/buildPage.js +1 -1
- package/dist/guillotine/buildPage.js.map +1 -0
- package/{guillotine → dist/guillotine}/collectComponentDescriptors.d.ts +1 -1
- package/{guillotine → dist/guillotine}/collectComponentDescriptors.js +4 -4
- package/dist/guillotine/collectComponentDescriptors.js.map +1 -0
- package/{guillotine → dist/guillotine}/combineMultipleQueries.js +1 -1
- package/dist/guillotine/combineMultipleQueries.js.map +1 -0
- package/{guillotine → dist/guillotine}/createMetaData.d.ts +1 -1
- package/{guillotine → dist/guillotine}/createMetaData.js +2 -2
- package/dist/guillotine/createMetaData.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchContent.js +10 -10
- package/dist/guillotine/fetchContent.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchContentData.js +2 -2
- package/dist/guillotine/fetchContentData.js.map +1 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchContentPathsForLocale.js +4 -4
- package/dist/guillotine/fetchContentPathsForLocale.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchFromApi.js +7 -7
- package/dist/guillotine/fetchFromApi.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchGuillotine.js +6 -6
- package/dist/guillotine/fetchGuillotine.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchMetaData.js +4 -4
- package/dist/guillotine/fetchMetaData.js.map +1 -0
- package/{guillotine → dist/guillotine}/getCleanContentPathArrayOrThrow400.js +1 -1
- package/dist/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -0
- package/dist/guillotine/getComponentConfig.js.map +1 -0
- package/dist/guillotine/getContentAndComponentPaths.js.map +1 -0
- package/dist/guillotine/getMetaData.js.map +1 -0
- package/{guillotine → dist/guillotine}/getParentRegion.js +1 -1
- package/dist/guillotine/getParentRegion.js.map +1 -0
- package/{guillotine → dist/guillotine}/getQueryAndVariables.js +2 -2
- package/dist/guillotine/getQueryAndVariables.js.map +1 -0
- package/dist/guillotine/metadata/configQuery.js.map +1 -0
- package/dist/guillotine/metadata/richTextQuery.js.map +1 -0
- package/{guillotine → dist/guillotine}/parseComponentPath.js +3 -3
- package/dist/guillotine/parseComponentPath.js.map +1 -0
- package/dist/guillotine/prefixFragmentCmpPath.js.map +1 -0
- package/dist/guillotine/processComponentConfig.js.map +1 -0
- package/dist/guillotine/restrictComponentsToPath.js.map +1 -0
- package/dist/guillotine/validateData.js.map +1 -0
- package/dist/guillotine/validateNotFound.js.map +1 -0
- package/dist/guillotine/validateShortcut.js.map +1 -0
- package/{i18n → dist/i18n}/LocaleContext.d.ts +1 -1
- package/{i18n → dist/i18n}/LocaleContext.jsx +3 -3
- package/dist/i18n/LocaleContext.jsx.map +1 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/{index.d.ts → dist/index.d.ts} +3 -3
- package/{index.js → dist/index.js} +3 -3
- package/dist/index.js.map +1 -0
- package/dist/query/Shortcut.js.map +1 -0
- package/dist/server/getServerRenderedHtml.js.map +1 -0
- package/dist/server.js.map +1 -0
- package/{types → dist/types}/component.js.map +1 -1
- package/{types → dist/types}/componentProps.d.ts +2 -1
- package/dist/types/componentProps.js.map +1 -0
- package/{types → dist/types}/guillotine.d.ts +1 -1
- package/{types → dist/types}/guillotine.js.map +1 -1
- package/dist/types/i18n.js.map +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/next.js.map +1 -0
- package/dist/types/util.js.map +1 -0
- package/dist/utils/addLineNumbers.js.map +1 -0
- package/{utils → dist/utils}/buildGuillotineRequestHeaders.d.ts +1 -1
- package/{utils → dist/utils}/buildGuillotineRequestHeaders.js +3 -3
- package/dist/utils/buildGuillotineRequestHeaders.js.map +1 -0
- package/dist/utils/commonChars.js.map +1 -0
- package/dist/utils/enonicLog.js.map +1 -0
- package/dist/utils/fixDoubleSlashes.js.map +1 -0
- package/dist/utils/getAllLocales.js.map +1 -0
- package/dist/utils/getContentApiUrl.js.map +1 -0
- package/dist/utils/getLocaleMapping.js.map +1 -0
- package/dist/utils/getLocaleMappingByLocale.js.map +1 -0
- package/dist/utils/getLocaleMappingByProjectId.js.map +1 -0
- package/{utils → dist/utils}/getLocaleMappings.js +1 -1
- package/dist/utils/getLocaleMappings.js.map +1 -0
- package/{utils → dist/utils}/getRenderMode.js +1 -1
- package/dist/utils/getRenderMode.js.map +1 -0
- package/dist/utils/getRequestLocaleInfo.js.map +1 -0
- package/dist/utils/getXpBaseUrl.js.map +1 -0
- package/dist/utils/indent.js.map +1 -0
- package/dist/utils/sanitizeGraphqlName.js.map +1 -0
- package/{views → dist/views}/BaseComponent.d.ts +1 -1
- package/{views → dist/views}/BaseComponent.jsx +5 -5
- package/dist/views/BaseComponent.jsx.map +1 -0
- package/{views → dist/views}/BaseContent.jsx +1 -1
- package/dist/views/BaseContent.jsx.map +1 -0
- package/dist/views/BaseLayout.jsx.map +1 -0
- package/dist/views/BaseMacro.jsx.map +1 -0
- package/dist/views/BasePage.jsx.map +1 -0
- package/dist/views/BasePart.jsx.map +1 -0
- package/dist/views/Empty.jsx.map +1 -0
- package/dist/views/Fragment.jsx.map +1 -0
- package/dist/views/MainView.jsx.map +1 -0
- package/{views → dist/views}/PropsView.jsx +1 -1
- package/dist/views/PropsView.jsx.map +1 -0
- package/dist/views/Region.jsx.map +1 -0
- package/dist/views/RichTextView.jsx +65 -0
- package/dist/views/RichTextView.jsx.map +1 -0
- package/dist/views/SingleComponent.jsx.map +1 -0
- package/dist/views/StaticContent.jsx.map +1 -0
- package/dist/views/Text.jsx.map +1 -0
- package/dist/views/macros/DefaultMacro.jsx.map +1 -0
- package/dist/views/macros/DisableMacro.jsx.map +1 -0
- package/package.json +49 -42
- package/baseMappings.js.map +0 -1
- package/client/getClientHydratedHtml.jsx.map +0 -1
- package/client.js.map +0 -1
- package/common/ComponentRegistry.js.map +0 -1
- package/common/UrlProcessor.js.map +0 -1
- package/common/constants.js.map +0 -1
- package/common/env.js.map +0 -1
- package/guillotine/applyProcessors.js.map +0 -1
- package/guillotine/buildComponentTree.js.map +0 -1
- package/guillotine/buildErrorResponse.js.map +0 -1
- package/guillotine/buildPage.js.map +0 -1
- package/guillotine/collectComponentDescriptors.js.map +0 -1
- package/guillotine/combineMultipleQueries.js.map +0 -1
- package/guillotine/createMetaData.js.map +0 -1
- package/guillotine/fetchContent.js.map +0 -1
- package/guillotine/fetchContentData.js.map +0 -1
- package/guillotine/fetchContentPathsForAllLocales.js.map +0 -1
- package/guillotine/fetchContentPathsForLocale.js.map +0 -1
- package/guillotine/fetchFromApi.js.map +0 -1
- package/guillotine/fetchGuillotine.js.map +0 -1
- package/guillotine/fetchMetaData.js.map +0 -1
- package/guillotine/getCleanContentPathArrayOrThrow400.js.map +0 -1
- package/guillotine/getComponentConfig.js.map +0 -1
- package/guillotine/getContentAndComponentPaths.js.map +0 -1
- package/guillotine/getMetaData.js.map +0 -1
- package/guillotine/getParentRegion.js.map +0 -1
- package/guillotine/getQueryAndVariables.js.map +0 -1
- package/guillotine/metadata/configQuery.js.map +0 -1
- package/guillotine/metadata/richTextQuery.js.map +0 -1
- package/guillotine/parseComponentPath.js.map +0 -1
- package/guillotine/prefixFragmentCmpPath.js.map +0 -1
- package/guillotine/processComponentConfig.js.map +0 -1
- package/guillotine/restrictComponentsToPath.js.map +0 -1
- package/guillotine/validateData.js.map +0 -1
- package/guillotine/validateNotFound.js.map +0 -1
- package/guillotine/validateShortcut.js.map +0 -1
- package/i18n/LocaleContext.jsx.map +0 -1
- package/i18n/i18n.js.map +0 -1
- package/index.js.map +0 -1
- package/query/Shortcut.js.map +0 -1
- package/server/getServerRenderedHtml.js.map +0 -1
- package/server.js.map +0 -1
- package/src/baseMappings.ts +0 -53
- package/src/client/getClientHydratedHtml.tsx +0 -12
- package/src/client.ts +0 -2
- package/src/common/ComponentRegistry.ts +0 -162
- package/src/common/UrlProcessor.ts +0 -172
- package/src/common/constants.ts +0 -92
- package/src/common/env.ts +0 -41
- package/src/guillotine/applyProcessors.ts +0 -38
- package/src/guillotine/buildComponentTree.ts +0 -57
- package/src/guillotine/buildErrorResponse.ts +0 -35
- package/src/guillotine/buildPage.ts +0 -15
- package/src/guillotine/collectComponentDescriptors.ts +0 -63
- package/src/guillotine/combineMultipleQueries.ts +0 -75
- package/src/guillotine/createMetaData.ts +0 -72
- package/src/guillotine/fetchContent.ts +0 -246
- package/src/guillotine/fetchContentData.ts +0 -37
- package/src/guillotine/fetchContentPathsForAllLocales.ts +0 -21
- package/src/guillotine/fetchContentPathsForLocale.ts +0 -43
- package/src/guillotine/fetchFromApi.ts +0 -76
- package/src/guillotine/fetchGuillotine.ts +0 -76
- package/src/guillotine/fetchMetaData.ts +0 -31
- package/src/guillotine/getCleanContentPathArrayOrThrow400.ts +0 -22
- package/src/guillotine/getComponentConfig.ts +0 -7
- package/src/guillotine/getContentAndComponentPaths.ts +0 -11
- package/src/guillotine/getMetaData.ts +0 -74
- package/src/guillotine/getParentRegion.ts +0 -54
- package/src/guillotine/getQueryAndVariables.ts +0 -52
- package/src/guillotine/metadata/configQuery.ts +0 -46
- package/src/guillotine/metadata/richTextQuery.ts +0 -49
- package/src/guillotine/parseComponentPath.ts +0 -29
- package/src/guillotine/prefixFragmentCmpPath.ts +0 -13
- package/src/guillotine/processComponentConfig.ts +0 -38
- package/src/guillotine/restrictComponentsToPath.ts +0 -48
- package/src/guillotine/validateData.ts +0 -11
- package/src/guillotine/validateNotFound.ts +0 -20
- package/src/guillotine/validateShortcut.ts +0 -43
- package/src/i18n/LocaleContext.tsx +0 -59
- package/src/i18n/i18n.ts +0 -57
- package/src/index.ts +0 -42
- package/src/query/Shortcut.ts +0 -18
- package/src/server/getServerRenderedHtml.ts +0 -3
- package/src/server.ts +0 -5
- package/src/types/component.ts +0 -131
- package/src/types/componentProps.ts +0 -142
- package/src/types/guillotine.ts +0 -428
- package/src/types/i18n.ts +0 -8
- package/src/types/index.ts +0 -62
- package/src/types/next.ts +0 -7
- package/src/types/util.ts +0 -5
- package/src/utils/addLineNumbers.ts +0 -3
- package/src/utils/buildGuillotineRequestHeaders.ts +0 -32
- package/src/utils/commonChars.ts +0 -16
- package/src/utils/enonicLog.ts +0 -28
- package/src/utils/fixDoubleSlashes.ts +0 -3
- package/src/utils/getAllLocales.ts +0 -6
- package/src/utils/getContentApiUrl.ts +0 -20
- package/src/utils/getLocaleMapping.ts +0 -24
- package/src/utils/getLocaleMappingByLocale.ts +0 -19
- package/src/utils/getLocaleMappingByProjectId.ts +0 -21
- package/src/utils/getLocaleMappings.ts +0 -36
- package/src/utils/getRenderMode.ts +0 -14
- package/src/utils/getRequestLocaleInfo.ts +0 -30
- package/src/utils/getXpBaseUrl.ts +0 -12
- package/src/utils/indent.ts +0 -4
- package/src/utils/sanitizeGraphqlName.ts +0 -11
- package/src/views/BaseComponent.tsx +0 -156
- package/src/views/BaseContent.tsx +0 -47
- package/src/views/BaseLayout.tsx +0 -33
- package/src/views/BaseMacro.tsx +0 -105
- package/src/views/BasePage.tsx +0 -42
- package/src/views/BasePart.tsx +0 -34
- package/src/views/Empty.tsx +0 -5
- package/src/views/Fragment.tsx +0 -41
- package/src/views/MainView.tsx +0 -22
- package/src/views/PropsView.tsx +0 -38
- package/src/views/Region.tsx +0 -76
- package/src/views/RichTextView.tsx +0 -63
- package/src/views/SingleComponent.tsx +0 -19
- package/src/views/StaticContent.tsx +0 -39
- package/src/views/Text.tsx +0 -19
- package/src/views/macros/DefaultMacro.tsx +0 -9
- package/src/views/macros/DisableMacro.tsx +0 -8
- package/types/componentProps.js.map +0 -1
- package/types/i18n.js.map +0 -1
- package/types/index.js.map +0 -1
- package/types/next.js.map +0 -1
- package/types/util.js.map +0 -1
- package/utils/addLineNumbers.js.map +0 -1
- package/utils/buildGuillotineRequestHeaders.js.map +0 -1
- package/utils/commonChars.js.map +0 -1
- package/utils/enonicLog.js.map +0 -1
- package/utils/fixDoubleSlashes.js.map +0 -1
- package/utils/getAllLocales.js.map +0 -1
- package/utils/getContentApiUrl.js.map +0 -1
- package/utils/getLocaleMapping.js.map +0 -1
- package/utils/getLocaleMappingByLocale.js.map +0 -1
- package/utils/getLocaleMappingByProjectId.js.map +0 -1
- package/utils/getLocaleMappings.js.map +0 -1
- package/utils/getRenderMode.js.map +0 -1
- package/utils/getRequestLocaleInfo.js.map +0 -1
- package/utils/getXpBaseUrl.js.map +0 -1
- package/utils/indent.js.map +0 -1
- package/utils/sanitizeGraphqlName.js.map +0 -1
- package/views/BaseComponent.jsx.map +0 -1
- package/views/BaseContent.jsx.map +0 -1
- package/views/BaseLayout.jsx.map +0 -1
- package/views/BaseMacro.jsx.map +0 -1
- package/views/BasePage.jsx.map +0 -1
- package/views/BasePart.jsx.map +0 -1
- package/views/Empty.jsx.map +0 -1
- package/views/Fragment.jsx.map +0 -1
- package/views/MainView.jsx.map +0 -1
- package/views/PropsView.jsx.map +0 -1
- package/views/Region.jsx.map +0 -1
- package/views/RichTextView.jsx +0 -39
- package/views/RichTextView.jsx.map +0 -1
- package/views/SingleComponent.jsx.map +0 -1
- package/views/StaticContent.jsx.map +0 -1
- package/views/Text.jsx.map +0 -1
- package/views/macros/DefaultMacro.jsx.map +0 -1
- package/views/macros/DisableMacro.jsx.map +0 -1
- /package/{baseMappings.d.ts → dist/baseMappings.d.ts} +0 -0
- /package/{client → dist/client}/getClientHydratedHtml.d.ts +0 -0
- /package/{client → dist/client}/getClientHydratedHtml.jsx +0 -0
- /package/{client.d.ts → dist/client.d.ts} +0 -0
- /package/{client.js → dist/client.js} +0 -0
- /package/{common → dist/common}/ComponentRegistry.d.ts +0 -0
- /package/{common → dist/common}/UrlProcessor.d.ts +0 -0
- /package/{common → dist/common}/UrlProcessor.js +0 -0
- /package/{common → dist/common}/constants.d.ts +0 -0
- /package/{common → dist/common}/constants.js +0 -0
- /package/{common → dist/common}/env.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/applyProcessors.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/applyProcessors.js +0 -0
- /package/{guillotine → dist/guillotine}/buildComponentTree.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/buildComponentTree.js +0 -0
- /package/{guillotine → dist/guillotine}/buildErrorResponse.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/buildPage.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/combineMultipleQueries.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContent.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentPathsForAllLocales.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentPathsForAllLocales.js +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentPathsForLocale.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchFromApi.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchGuillotine.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchMetaData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getCleanContentPathArrayOrThrow400.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getComponentConfig.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getComponentConfig.js +0 -0
- /package/{guillotine → dist/guillotine}/getContentAndComponentPaths.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getContentAndComponentPaths.js +0 -0
- /package/{guillotine → dist/guillotine}/getMetaData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getMetaData.js +0 -0
- /package/{guillotine → dist/guillotine}/getParentRegion.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getQueryAndVariables.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/metadata/configQuery.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/metadata/configQuery.js +0 -0
- /package/{guillotine → dist/guillotine}/metadata/richTextQuery.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/metadata/richTextQuery.js +0 -0
- /package/{guillotine → dist/guillotine}/parseComponentPath.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/prefixFragmentCmpPath.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/prefixFragmentCmpPath.js +0 -0
- /package/{guillotine → dist/guillotine}/processComponentConfig.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/processComponentConfig.js +0 -0
- /package/{guillotine → dist/guillotine}/restrictComponentsToPath.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/restrictComponentsToPath.js +0 -0
- /package/{guillotine → dist/guillotine}/validateData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/validateData.js +0 -0
- /package/{guillotine → dist/guillotine}/validateNotFound.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/validateNotFound.js +0 -0
- /package/{guillotine → dist/guillotine}/validateShortcut.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/validateShortcut.js +0 -0
- /package/{i18n → dist/i18n}/i18n.d.ts +0 -0
- /package/{i18n → dist/i18n}/i18n.js +0 -0
- /package/{query → dist/query}/Shortcut.d.ts +0 -0
- /package/{query → dist/query}/Shortcut.js +0 -0
- /package/{server → dist/server}/getServerRenderedHtml.d.ts +0 -0
- /package/{server → dist/server}/getServerRenderedHtml.js +0 -0
- /package/{server.d.ts → dist/server.d.ts} +0 -0
- /package/{server.js → dist/server.js} +0 -0
- /package/{types → dist/types}/component.d.ts +0 -0
- /package/{types → dist/types}/component.js +0 -0
- /package/{types → dist/types}/componentProps.js +0 -0
- /package/{types → dist/types}/guillotine.js +0 -0
- /package/{types → dist/types}/i18n.d.ts +0 -0
- /package/{types → dist/types}/i18n.js +0 -0
- /package/{types → dist/types}/index.d.ts +0 -0
- /package/{types → dist/types}/index.js +0 -0
- /package/{types → dist/types}/next.d.ts +0 -0
- /package/{types → dist/types}/next.js +0 -0
- /package/{types → dist/types}/util.d.ts +0 -0
- /package/{types → dist/types}/util.js +0 -0
- /package/{utils → dist/utils}/addLineNumbers.d.ts +0 -0
- /package/{utils → dist/utils}/addLineNumbers.js +0 -0
- /package/{utils → dist/utils}/commonChars.d.ts +0 -0
- /package/{utils → dist/utils}/commonChars.js +0 -0
- /package/{utils → dist/utils}/enonicLog.d.ts +0 -0
- /package/{utils → dist/utils}/enonicLog.js +0 -0
- /package/{utils → dist/utils}/fixDoubleSlashes.d.ts +0 -0
- /package/{utils → dist/utils}/fixDoubleSlashes.js +0 -0
- /package/{utils → dist/utils}/getAllLocales.d.ts +0 -0
- /package/{utils → dist/utils}/getAllLocales.js +0 -0
- /package/{utils → dist/utils}/getContentApiUrl.d.ts +0 -0
- /package/{utils → dist/utils}/getContentApiUrl.js +0 -0
- /package/{utils → dist/utils}/getLocaleMapping.d.ts +0 -0
- /package/{utils → dist/utils}/getLocaleMapping.js +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByLocale.d.ts +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByLocale.js +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByProjectId.d.ts +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByProjectId.js +0 -0
- /package/{utils → dist/utils}/getLocaleMappings.d.ts +0 -0
- /package/{utils → dist/utils}/getRenderMode.d.ts +0 -0
- /package/{utils → dist/utils}/getRequestLocaleInfo.d.ts +0 -0
- /package/{utils → dist/utils}/getRequestLocaleInfo.js +0 -0
- /package/{utils → dist/utils}/getXpBaseUrl.d.ts +0 -0
- /package/{utils → dist/utils}/getXpBaseUrl.js +0 -0
- /package/{utils → dist/utils}/indent.d.ts +0 -0
- /package/{utils → dist/utils}/indent.js +0 -0
- /package/{utils → dist/utils}/sanitizeGraphqlName.d.ts +0 -0
- /package/{utils → dist/utils}/sanitizeGraphqlName.js +0 -0
- /package/{views → dist/views}/BaseContent.d.ts +0 -0
- /package/{views → dist/views}/BaseLayout.d.ts +0 -0
- /package/{views → dist/views}/BaseLayout.jsx +0 -0
- /package/{views → dist/views}/BaseMacro.d.ts +0 -0
- /package/{views → dist/views}/BaseMacro.jsx +0 -0
- /package/{views → dist/views}/BasePage.d.ts +0 -0
- /package/{views → dist/views}/BasePage.jsx +0 -0
- /package/{views → dist/views}/BasePart.d.ts +0 -0
- /package/{views → dist/views}/BasePart.jsx +0 -0
- /package/{views → dist/views}/Empty.d.ts +0 -0
- /package/{views → dist/views}/Empty.jsx +0 -0
- /package/{views → dist/views}/Fragment.d.ts +0 -0
- /package/{views → dist/views}/Fragment.jsx +0 -0
- /package/{views → dist/views}/MainView.d.ts +0 -0
- /package/{views → dist/views}/MainView.jsx +0 -0
- /package/{views → dist/views}/PropsView.d.ts +0 -0
- /package/{views → dist/views}/Region.d.ts +0 -0
- /package/{views → dist/views}/Region.jsx +0 -0
- /package/{views → dist/views}/RichTextView.d.ts +0 -0
- /package/{views → dist/views}/SingleComponent.d.ts +0 -0
- /package/{views → dist/views}/SingleComponent.jsx +0 -0
- /package/{views → dist/views}/StaticContent.d.ts +0 -0
- /package/{views → dist/views}/StaticContent.jsx +0 -0
- /package/{views → dist/views}/Text.d.ts +0 -0
- /package/{views → dist/views}/Text.jsx +0 -0
- /package/{views → dist/views}/macros/DefaultMacro.d.ts +0 -0
- /package/{views → dist/views}/macros/DefaultMacro.jsx +0 -0
- /package/{views → dist/views}/macros/DisableMacro.d.ts +0 -0
- /package/{views → dist/views}/macros/DisableMacro.jsx +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/** Checks a site-relative contentPath as a slash-delimited string or a string array, and returns a pure site-relative path string (no double slashes, starts with a slash, does not end with one). */
|
|
2
|
-
export const getCleanContentPathArrayOrThrow400 = (contentPath: string | string[] | undefined): string => {
|
|
3
|
-
if (contentPath === undefined) {
|
|
4
|
-
return '';
|
|
5
|
-
}
|
|
6
|
-
const isArray = Array.isArray(contentPath);
|
|
7
|
-
|
|
8
|
-
if (!isArray) {
|
|
9
|
-
if (typeof contentPath !== 'string') {
|
|
10
|
-
throw Error(JSON.stringify({
|
|
11
|
-
code: 400,
|
|
12
|
-
message: `Unexpected target content _path: contentPath must be a string or pure string array (contentPath=${JSON.stringify(
|
|
13
|
-
contentPath)})`,
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return contentPath;
|
|
18
|
-
|
|
19
|
-
} else {
|
|
20
|
-
return (contentPath).join('/');
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const COMPONENT_PATH_KEY = /\/?_\/component/; // first slash is optional for root components
|
|
2
|
-
|
|
3
|
-
export const getContentAndComponentPaths = (requestPath: string): string[] => {
|
|
4
|
-
let contentPath, componentPath;
|
|
5
|
-
if (COMPONENT_PATH_KEY.test(requestPath)) {
|
|
6
|
-
[contentPath, componentPath] = requestPath.split(COMPONENT_PATH_KEY);
|
|
7
|
-
} else {
|
|
8
|
-
contentPath = requestPath;
|
|
9
|
-
}
|
|
10
|
-
return [contentPath, componentPath];
|
|
11
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
2
|
-
import {configQuery} from './metadata/configQuery';
|
|
3
|
-
import {richTextQuery} from './metadata/richTextQuery';
|
|
4
|
-
import {indent} from '../utils/indent';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const partConfigQuery = (): string => {
|
|
8
|
-
return configQuery(ComponentRegistry.getParts());
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const layoutConfigQuery = (): string => {
|
|
12
|
-
return configQuery(ComponentRegistry.getLayouts());
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const pageConfigQuery = (): string => {
|
|
16
|
-
return configQuery(ComponentRegistry.getPages());
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/*
|
|
21
|
-
IMPORTANT: make sure to transform your queries into functions too when using this function inside them !!!
|
|
22
|
-
*/
|
|
23
|
-
const componentsQuery = () => `type
|
|
24
|
-
path
|
|
25
|
-
page {
|
|
26
|
-
descriptor
|
|
27
|
-
${indent(pageConfigQuery(), 4)}
|
|
28
|
-
template {
|
|
29
|
-
_path
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
layout {
|
|
33
|
-
descriptor
|
|
34
|
-
${indent(layoutConfigQuery(), 4)}
|
|
35
|
-
}
|
|
36
|
-
text {
|
|
37
|
-
${indent(richTextQuery('value'), 4)}
|
|
38
|
-
}
|
|
39
|
-
part {
|
|
40
|
-
descriptor
|
|
41
|
-
${indent(partConfigQuery(), 4)}
|
|
42
|
-
}
|
|
43
|
-
image {
|
|
44
|
-
caption
|
|
45
|
-
image {
|
|
46
|
-
imageUrl (type:absolute, scale: "width-768")
|
|
47
|
-
}
|
|
48
|
-
}`;
|
|
49
|
-
|
|
50
|
-
// THIS QUERY DOES NOT SUPPORT NESTED FRAGMENTS
|
|
51
|
-
export const pageFragmentQuery = () => `components(resolveFragment: false, resolveTemplate: true) {
|
|
52
|
-
fragment {
|
|
53
|
-
id
|
|
54
|
-
fragment {
|
|
55
|
-
components {
|
|
56
|
-
${indent(componentsQuery(),16)}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
${indent(componentsQuery(),4)}
|
|
61
|
-
}`;
|
|
62
|
-
|
|
63
|
-
export function getMetaQuery(pageFragment?: string): string {
|
|
64
|
-
return `query($path:ID!) {
|
|
65
|
-
guillotine {
|
|
66
|
-
get(key:$path) {
|
|
67
|
-
_id
|
|
68
|
-
_path
|
|
69
|
-
type
|
|
70
|
-
${indent(pageFragment || '', 12)}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}`;
|
|
74
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type {PageComponent, PageRegion, PathFragment, RegionTree} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
5
|
-
import {prefixFragmentCmpPath} from './prefixFragmentCmpPath';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function getParentRegion(
|
|
9
|
-
source: RegionTree,
|
|
10
|
-
contentType: string,
|
|
11
|
-
cmpPath: PathFragment[],
|
|
12
|
-
components: PageComponent[] = [],
|
|
13
|
-
createMissing ? : boolean,
|
|
14
|
-
): PageRegion | undefined {
|
|
15
|
-
let currentTree: RegionTree = source;
|
|
16
|
-
let currentRegion: PageRegion | undefined;
|
|
17
|
-
let parentPath = '';
|
|
18
|
-
|
|
19
|
-
for (let i = 0; i < cmpPath.length; i++) {
|
|
20
|
-
const pathFragment = cmpPath[i];
|
|
21
|
-
const regionName = pathFragment.region;
|
|
22
|
-
parentPath += `/${pathFragment.region}/${pathFragment.index}`;
|
|
23
|
-
currentRegion = currentTree[regionName];
|
|
24
|
-
|
|
25
|
-
if (!currentRegion) {
|
|
26
|
-
if (createMissing) {
|
|
27
|
-
currentRegion = {
|
|
28
|
-
name: regionName,
|
|
29
|
-
components: [],
|
|
30
|
-
};
|
|
31
|
-
currentTree[regionName] = currentRegion;
|
|
32
|
-
} else {
|
|
33
|
-
throw new Error(`Region [${regionName}] was not found`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (i < cmpPath.length - 1) {
|
|
38
|
-
// look for layouts inside if this is not the last path fragment
|
|
39
|
-
|
|
40
|
-
const layout = components.find((cmp: PageComponent) => {
|
|
41
|
-
return cmp.type === XP_COMPONENT_TYPE.LAYOUT && prefixFragmentCmpPath(contentType, cmp.path) === parentPath;
|
|
42
|
-
});
|
|
43
|
-
if (!layout) {
|
|
44
|
-
throw new Error(`Layout [${parentPath}] not found among components, but needed for component [${JSON.stringify(cmpPath, null, 2)}]`);
|
|
45
|
-
}
|
|
46
|
-
if (!layout.regions) {
|
|
47
|
-
layout.regions = {};
|
|
48
|
-
}
|
|
49
|
-
currentTree = layout.regions;
|
|
50
|
-
}
|
|
51
|
-
} // for
|
|
52
|
-
|
|
53
|
-
return currentRegion;
|
|
54
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Context,
|
|
3
|
-
QueryAndVariables,
|
|
4
|
-
SelectedQueryMaybeVariablesFunc,
|
|
5
|
-
} from '../types';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function getQueryAndVariables(
|
|
9
|
-
type: string,
|
|
10
|
-
path: string,
|
|
11
|
-
context: Context,
|
|
12
|
-
selectedQuery?: SelectedQueryMaybeVariablesFunc,
|
|
13
|
-
config?: any,
|
|
14
|
-
): QueryAndVariables | undefined {
|
|
15
|
-
|
|
16
|
-
let query, getVariables;
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
typeof selectedQuery === 'string' || typeof selectedQuery === 'function'
|
|
20
|
-
) {
|
|
21
|
-
query = selectedQuery;
|
|
22
|
-
|
|
23
|
-
} else if (Array.isArray(selectedQuery)) {
|
|
24
|
-
query = selectedQuery[0];
|
|
25
|
-
getVariables = selectedQuery[1];
|
|
26
|
-
|
|
27
|
-
} else if (typeof selectedQuery === 'object') {
|
|
28
|
-
query = selectedQuery.query;
|
|
29
|
-
getVariables = selectedQuery.variables;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (getVariables && typeof getVariables !== 'function') {
|
|
33
|
-
throw Error(`getVariables for content type ${type} should be a function, not: ${typeof getVariables}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (query && typeof query !== 'string' && typeof query !== 'function') {
|
|
37
|
-
throw Error(`Query for content type ${type} should be a string or function, not: ${typeof query}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (typeof query === 'function') {
|
|
41
|
-
query = query(path, context, config);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (query) {
|
|
45
|
-
return {
|
|
46
|
-
query,
|
|
47
|
-
variables: getVariables ? getVariables(path, context, config) : {
|
|
48
|
-
path,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type {ComponentDefinition} from '../../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {sanitizeGraphqlName} from '../../utils/sanitizeGraphqlName';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const configQuery = (
|
|
8
|
-
list: [string, ComponentDefinition][],
|
|
9
|
-
includeAppName = true,
|
|
10
|
-
canUseConfigAsJson = true,
|
|
11
|
-
): string => {
|
|
12
|
-
const hasQueryList = list?.filter(([key, def]) => def.configQuery) || [];
|
|
13
|
-
if (hasQueryList.length === 0) {
|
|
14
|
-
return canUseConfigAsJson ? 'configAsJson' : '';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const configsByApp: Record<string,string[]> = {};
|
|
18
|
-
hasQueryList
|
|
19
|
-
.forEach((entry) => {
|
|
20
|
-
const nameParts = entry[0].split(':');
|
|
21
|
-
if (nameParts.length === 2) {
|
|
22
|
-
const sanitizedAppName = sanitizeGraphqlName(nameParts[0]);
|
|
23
|
-
let existingConfigs = configsByApp[sanitizedAppName];
|
|
24
|
-
if (!existingConfigs) {
|
|
25
|
-
existingConfigs = [];
|
|
26
|
-
configsByApp[sanitizedAppName] = existingConfigs;
|
|
27
|
-
}
|
|
28
|
-
existingConfigs.push(`${sanitizeGraphqlName(nameParts[1])}${entry[1].configQuery}`);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Still query for configAsJson if at least one item has no configQuery defined
|
|
33
|
-
const configAsJsonQuery = canUseConfigAsJson && hasQueryList.length < list.length ? 'configAsJson' : '';
|
|
34
|
-
|
|
35
|
-
if (!includeAppName) {
|
|
36
|
-
return `${configAsJsonQuery}
|
|
37
|
-
config {
|
|
38
|
-
${Object.values(configsByApp).reduce((arr, curr) => arr.concat(curr), []).join('\n')}
|
|
39
|
-
}`;
|
|
40
|
-
} else {
|
|
41
|
-
return `${configAsJsonQuery}
|
|
42
|
-
config {
|
|
43
|
-
${Object.entries(configsByApp).map(entry => entry[0] + '{\n' + entry[1].join('\n') + '\n}')}
|
|
44
|
-
}`;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {ComponentRegistry} from '../../common/ComponentRegistry';
|
|
2
|
-
import {configQuery} from './configQuery';
|
|
3
|
-
import {indent} from '../../utils/indent';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const macroConfigQuery = (): string => {
|
|
7
|
-
return configQuery(ComponentRegistry.getMacros(), false, false);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const richTextQuery = (fieldName: string) => {
|
|
11
|
-
return `${fieldName}(processHtml:{type:absolute, imageWidths:[400, 800, 1200], imageSizes:"(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"}) {
|
|
12
|
-
processedHtml
|
|
13
|
-
macros {
|
|
14
|
-
ref
|
|
15
|
-
name
|
|
16
|
-
descriptor
|
|
17
|
-
${indent(macroConfigQuery(), 8)}
|
|
18
|
-
}
|
|
19
|
-
links {
|
|
20
|
-
ref
|
|
21
|
-
uri
|
|
22
|
-
content {
|
|
23
|
-
_id
|
|
24
|
-
}
|
|
25
|
-
media {
|
|
26
|
-
content {
|
|
27
|
-
_id
|
|
28
|
-
... on media_Image {
|
|
29
|
-
mediaUrl(type: absolute)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
intent
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
images {
|
|
36
|
-
ref
|
|
37
|
-
image {
|
|
38
|
-
_id
|
|
39
|
-
... on media_Image {
|
|
40
|
-
imageUrl(scale: "width(768)", type:absolute)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
style {
|
|
44
|
-
name
|
|
45
|
-
aspectRatio
|
|
46
|
-
filter
|
|
47
|
-
}
|
|
48
|
-
}}`;
|
|
49
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type {PathFragment} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
FRAGMENT_CONTENTTYPE_NAME,
|
|
6
|
-
FRAGMENT_DEFAULT_REGION_NAME,
|
|
7
|
-
} from '../common/constants';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export function parseComponentPath(contentType: string, path: string): PathFragment[] {
|
|
11
|
-
const matches: PathFragment[] = [];
|
|
12
|
-
let match;
|
|
13
|
-
const myRegexp = /(?:(\w+)\/(\d+))+/g;
|
|
14
|
-
while ((match = myRegexp.exec(path)) !== null) {
|
|
15
|
-
matches.push({
|
|
16
|
-
region: match[1],
|
|
17
|
-
index: +match[2],
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
if (contentType === FRAGMENT_CONTENTTYPE_NAME) {
|
|
21
|
-
// there is no main region in fragment content and the root component has '/' path
|
|
22
|
-
// prepend FRAGMENT_DEFAULT_REGION_NAME to path to conform to page structure
|
|
23
|
-
matches.unshift({
|
|
24
|
-
region: FRAGMENT_DEFAULT_REGION_NAME,
|
|
25
|
-
index: 0,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return matches;
|
|
29
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {FRAGMENT_CONTENTTYPE_NAME, FRAGMENT_DEFAULT_REGION_NAME} from '../common/constants';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function prefixFragmentCmpPath(contentType: string, path: string): string {
|
|
5
|
-
if (contentType !== FRAGMENT_CONTENTTYPE_NAME) {
|
|
6
|
-
return path;
|
|
7
|
-
} else {
|
|
8
|
-
// prepend FRAGMENT_DEFAULT_REGION_NAME to path to conform to page structure
|
|
9
|
-
// so that component with path '/' becomes /FRAGMENT_DEFAULT_REGION_NAME/0
|
|
10
|
-
// path /left/1 becomes /FRAGMENT_DEFAULT_REGION_NAME/0/left/1
|
|
11
|
-
return `/${FRAGMENT_DEFAULT_REGION_NAME}/0${path === '/' ? '' : path}`;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type {PageComponent} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {sanitizeGraphqlName} from '../utils/sanitizeGraphqlName';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function processComponentConfig(
|
|
8
|
-
myAppName: string,
|
|
9
|
-
myAppNameDashed: string,
|
|
10
|
-
cmp: PageComponent,
|
|
11
|
-
): void {
|
|
12
|
-
const cmpData = cmp[cmp.type];
|
|
13
|
-
if (cmpData && 'descriptor' in cmpData && cmpData.descriptor) {
|
|
14
|
-
const [appName, cmpName] = cmpData.descriptor.split(':');
|
|
15
|
-
if (appName !== myAppName) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
let config;
|
|
19
|
-
const configArray: object[] = [];
|
|
20
|
-
if ('configAsJson' in cmpData && cmpData.configAsJson && cmpData.configAsJson[myAppNameDashed]) {
|
|
21
|
-
config = cmpData.configAsJson[myAppNameDashed][cmpName];
|
|
22
|
-
if (config) {
|
|
23
|
-
configArray.push(config);
|
|
24
|
-
delete cmpData.configAsJson;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const sanitizedAppName = sanitizeGraphqlName(appName);
|
|
28
|
-
if ('config' in cmpData && cmpData.config && cmpData.config[sanitizedAppName]) {
|
|
29
|
-
config = cmpData.config[sanitizedAppName][sanitizeGraphqlName(cmpName)];
|
|
30
|
-
if (config) {
|
|
31
|
-
configArray.push(config);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (configArray.length) {
|
|
35
|
-
cmpData.config = Object.assign({}, ...configArray);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type {PageComponent} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
5
|
-
import {parseComponentPath} from './parseComponentPath';
|
|
6
|
-
import {prefixFragmentCmpPath} from './prefixFragmentCmpPath';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function restrictComponentsToPath(
|
|
10
|
-
contentType: string,
|
|
11
|
-
components?: PageComponent[],
|
|
12
|
-
componentPath?: string,
|
|
13
|
-
): PageComponent[] {
|
|
14
|
-
if (!componentPath || !components?.length) {
|
|
15
|
-
return components || [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// filter components to the requested one only
|
|
19
|
-
const component = components.find(cmp => {
|
|
20
|
-
return cmp.path === componentPath;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!component) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let result: PageComponent[] = [component];
|
|
28
|
-
if (component.type !== XP_COMPONENT_TYPE.LAYOUT) {
|
|
29
|
-
// remember to include all parent layouts too !
|
|
30
|
-
const cmpPath = parseComponentPath(contentType, component.path);
|
|
31
|
-
for (let i = cmpPath.length - 2; i >= 0; i--) {
|
|
32
|
-
const parentPath = cmpPath[i];
|
|
33
|
-
const parentCmp = components.find(cmp => {
|
|
34
|
-
return prefixFragmentCmpPath(contentType, cmp.path) === `/${parentPath.region}/${parentPath.index}`;
|
|
35
|
-
});
|
|
36
|
-
if (parentCmp) {
|
|
37
|
-
result.unshift(parentCmp);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
// It's a layout, include child components
|
|
42
|
-
const childCmps = components.filter(cmp => cmp.path !== component.path && cmp.path.startsWith(component.path));
|
|
43
|
-
if (childCmps.length) {
|
|
44
|
-
result = result.concat(childCmps);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type {FetchContentResult} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {validateNotFound} from './validateNotFound';
|
|
5
|
-
import {validateShortcut} from './validateShortcut';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function validateData(props: FetchContentResult): void {
|
|
9
|
-
validateNotFound(props);
|
|
10
|
-
validateShortcut(props);
|
|
11
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type {FetchContentResult} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {notFound} from 'next/navigation';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function validateNotFound(props: FetchContentResult): void {
|
|
8
|
-
const {error} = props;
|
|
9
|
-
if (error) {
|
|
10
|
-
switch (error.code) {
|
|
11
|
-
case '404':
|
|
12
|
-
console.warn(error.code, error.message);
|
|
13
|
-
notFound();
|
|
14
|
-
break;
|
|
15
|
-
default:
|
|
16
|
-
console.error(error.code, error.message);
|
|
17
|
-
throw new Error(error.message);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type {FetchContentResult} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {notFound, redirect, RedirectType} from 'next/navigation';
|
|
5
|
-
import {RENDER_MODE} from '../common/constants';
|
|
6
|
-
import {IS_DEV_MODE} from '../common/env';
|
|
7
|
-
import {UrlProcessor} from '../common/UrlProcessor';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export function validateShortcut(props: FetchContentResult): void {
|
|
11
|
-
const {data, meta, error} = props;
|
|
12
|
-
const dataObj = data?.get?.data;
|
|
13
|
-
const pageUrl = dataObj?.target?.pageUrl;
|
|
14
|
-
const parameters = dataObj?.parameters;
|
|
15
|
-
if (meta.type === 'base:shortcut' && pageUrl) {
|
|
16
|
-
if (meta.renderMode !== RENDER_MODE.NEXT) {
|
|
17
|
-
// do not show shortcut targets in preview/edit mode
|
|
18
|
-
console.warn(404, `Shortcuts are not available in ${meta.renderMode} render mode`);
|
|
19
|
-
notFound();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let destination = UrlProcessor.process(pageUrl, meta, true);
|
|
23
|
-
if (parameters) {
|
|
24
|
-
const searchParams = parameters.map(({name, value}) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`).join('&');
|
|
25
|
-
destination += '?' + searchParams;
|
|
26
|
-
}
|
|
27
|
-
console.debug(`Redirecting shortcut content [${meta.path}] to`, destination);
|
|
28
|
-
redirect(destination, RedirectType.replace);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// we can not set 418 for static paths,
|
|
32
|
-
// but we can show 404 instead to be handled in CS
|
|
33
|
-
const canNotRender = meta && !meta.canRender && meta.renderMode !== RENDER_MODE.EDIT;
|
|
34
|
-
|
|
35
|
-
const catchAllInNextProdMode = meta.renderMode === RENDER_MODE.NEXT && !IS_DEV_MODE && meta.catchAll;
|
|
36
|
-
|
|
37
|
-
const isNotFound = (error && error.code === '404') || canNotRender || catchAllInNextProdMode;
|
|
38
|
-
|
|
39
|
-
if (isNotFound) {
|
|
40
|
-
console.warn(404, `Can not render content at [${meta.path}]`);
|
|
41
|
-
notFound();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import type {Dict, LocaleContextType} from '../types';
|
|
3
|
-
|
|
4
|
-
import React, {createContext, useContext, useEffect, useState} from 'react';
|
|
5
|
-
import {getPhrase, loadPhrases} from './i18n';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const LocaleContext = createContext<LocaleContextType>({
|
|
9
|
-
dictionary: {},
|
|
10
|
-
locale: '',
|
|
11
|
-
localize: (key: string, ...args: any[]) => key,
|
|
12
|
-
setLocale: (locale: string) => Promise.resolve({}),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const useLocaleContext = () => useContext(LocaleContext);
|
|
16
|
-
|
|
17
|
-
export const LocaleContextProvider = ({
|
|
18
|
-
children,
|
|
19
|
-
locale: localeProps = '',
|
|
20
|
-
}: {
|
|
21
|
-
children: any
|
|
22
|
-
locale?: string
|
|
23
|
-
}) => {
|
|
24
|
-
const [currentLocale, setLocaleState] = useState(localeProps);
|
|
25
|
-
const [dictionary, setPhrasesState] = useState<Dict>({});
|
|
26
|
-
const [isLoaded, setLoadedState] = useState(false);
|
|
27
|
-
|
|
28
|
-
const setLocale = async (locale: string): Promise<Dict> => {
|
|
29
|
-
setLocaleState(locale);
|
|
30
|
-
setLoadedState(false);
|
|
31
|
-
|
|
32
|
-
return loadPhrases(locale).then((phrases) => {
|
|
33
|
-
setPhrasesState(phrases);
|
|
34
|
-
setLoadedState(true);
|
|
35
|
-
return phrases;
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (localeProps) {
|
|
41
|
-
void setLocale(localeProps); // void to avoid @typescript-eslint/no-floating-promises
|
|
42
|
-
}
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
const localize = (key: string, ...args: any[]) => {
|
|
46
|
-
return isLoaded ? getPhrase(currentLocale, dictionary, key, ...args) : key;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<LocaleContext.Provider value={{
|
|
51
|
-
setLocale,
|
|
52
|
-
locale: currentLocale,
|
|
53
|
-
dictionary,
|
|
54
|
-
localize,
|
|
55
|
-
}}>
|
|
56
|
-
{children}
|
|
57
|
-
</LocaleContext.Provider>
|
|
58
|
-
);
|
|
59
|
-
};
|
package/src/i18n/i18n.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type {Dict} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export class I18n {
|
|
5
|
-
private static locale = '';
|
|
6
|
-
private static dictionary: Dict = {};
|
|
7
|
-
private static isLoaded = false;
|
|
8
|
-
|
|
9
|
-
public static async setLocale(locale: string): Promise<Dict> {
|
|
10
|
-
this.locale = locale;
|
|
11
|
-
this.isLoaded = false;
|
|
12
|
-
|
|
13
|
-
return loadPhrases(locale).then((phrases) => {
|
|
14
|
-
this.dictionary = phrases;
|
|
15
|
-
this.isLoaded = true;
|
|
16
|
-
return phrases;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public static localize(key: string, ...args: any[]): string {
|
|
21
|
-
return this.isLoaded ? getPhrase(this.locale, this.dictionary, key, ...args) : key;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public static getLocale() {
|
|
25
|
-
return this.locale;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public static getDictionary() {
|
|
29
|
-
return this.dictionary;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const loadPhrases = async (locale: string): Promise<Dict> => {
|
|
34
|
-
return import(`@phrases/${locale}.json`)
|
|
35
|
-
.then((module) => module.default)
|
|
36
|
-
.catch((e) => {
|
|
37
|
-
console.error(`Failed to load phrases for locale "${locale}"`, e);
|
|
38
|
-
return {};
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const getPhrase = (locale: string, dict: Dict, key: string, ...args: any[]) => {
|
|
43
|
-
const template = dict[key];
|
|
44
|
-
if (!template) {
|
|
45
|
-
console.warn(`Missing localization phrase for locale "${locale}": <${key}>`);
|
|
46
|
-
return `<${key}>`;
|
|
47
|
-
}
|
|
48
|
-
if (args.length) {
|
|
49
|
-
let index = -1;
|
|
50
|
-
return template.replace(/{(\d+)?}/g, (match, digit) => {
|
|
51
|
-
index++;
|
|
52
|
-
return args[digit || index] ?? match;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return template;
|
|
56
|
-
};
|
|
57
|
-
|