@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,36 +0,0 @@
|
|
|
1
|
-
import type {LocaleMappings} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {ENV_VARS} from '../common/constants';
|
|
5
|
-
import {MAPPINGS} from '../common/env';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// NOTE: Dissallowing slash and any whitespace in 2nd capture group.
|
|
9
|
-
const PROJECT_CONFIG_REGEXP = /^([\w-]+):([^/\s]+)(\/[\w.-]+)?$/i;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export function getLocaleMappings(): LocaleMappings {
|
|
13
|
-
const str = MAPPINGS;
|
|
14
|
-
if (!str?.length) {
|
|
15
|
-
throw new Error(`Did you forget to define "${ENV_VARS.MAPPINGS}" environmental variable?
|
|
16
|
-
Format: <default-language>:<default-repository-name>/<default-site-path>,<language>:<repository-name>/<site-path>,...`);
|
|
17
|
-
}
|
|
18
|
-
return str.split(',').reduce((config, prjStr, index: number) => {
|
|
19
|
-
const trimmedprjStr = prjStr.trim();
|
|
20
|
-
if (!trimmedprjStr.length) {
|
|
21
|
-
return config;
|
|
22
|
-
}
|
|
23
|
-
const matches: RegExpExecArray = PROJECT_CONFIG_REGEXP.exec(trimmedprjStr);
|
|
24
|
-
if (!matches?.length) {
|
|
25
|
-
throw new Error(`Project "${prjStr}" doesn't match format: <default-language>:<default-repository-name>/<default-site-path>,<language>:<repository-name>/<site-path>`);
|
|
26
|
-
}
|
|
27
|
-
const [_full, lang, project, site] = matches;
|
|
28
|
-
config[lang] = {
|
|
29
|
-
default: index === 0,
|
|
30
|
-
project,
|
|
31
|
-
site,
|
|
32
|
-
locale: lang,
|
|
33
|
-
};
|
|
34
|
-
return config;
|
|
35
|
-
}, {});
|
|
36
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type {Context} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
RENDER_MODE,
|
|
6
|
-
RENDER_MODE_HEADER,
|
|
7
|
-
} from '../common/constants';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const getRenderMode = (context: Context): RENDER_MODE => {
|
|
11
|
-
const value = context.headers?.get(RENDER_MODE_HEADER);
|
|
12
|
-
const enumValue = RENDER_MODE[(value as keyof typeof RENDER_MODE)?.toUpperCase()];
|
|
13
|
-
return enumValue || RENDER_MODE[process.env.RENDER_MODE] || RENDER_MODE.NEXT;
|
|
14
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type {Context} from '../types';
|
|
2
|
-
import {PROJECT_ID_HEADER} from '../common/constants';
|
|
3
|
-
import {getLocaleMappings} from './getLocaleMappings';
|
|
4
|
-
import {getLocaleMappingByProjectId} from './getLocaleMappingByProjectId';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function getRequestLocaleInfo(context: Context) {
|
|
8
|
-
let locale: string;
|
|
9
|
-
const configs = getLocaleMappings();
|
|
10
|
-
const locales = Object.keys(configs);
|
|
11
|
-
const defaultLocale = locales.find((locale) => configs[locale].default);
|
|
12
|
-
const projectId = context.headers?.get(PROJECT_ID_HEADER);
|
|
13
|
-
if (projectId) {
|
|
14
|
-
locale = getLocaleMappingByProjectId(projectId, false)?.locale;
|
|
15
|
-
|
|
16
|
-
} else {
|
|
17
|
-
locale = context.locale;
|
|
18
|
-
/* Disabled to prevent situation when www.site.com redirects to www.site.com/no when accept-header is set to 'no'
|
|
19
|
-
|
|
20
|
-
if (!locale) {
|
|
21
|
-
const acceptLang = context.headers?.get('accept-language') || '';
|
|
22
|
-
const langs = new Negotiator({headers: {'accept-language': acceptLang}}).languages();
|
|
23
|
-
locale = localeMatcher(langs, locales, defaultLocale);
|
|
24
|
-
}*/
|
|
25
|
-
if (!locale) {
|
|
26
|
-
locale = defaultLocale;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return {locale, locales, defaultLocale};
|
|
30
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type {Context} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {XP_BASE_URL_HEADER} from '../common/constants';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const getXpBaseUrl = (context: Context): string => {
|
|
8
|
-
const header = context.headers?.get(XP_BASE_URL_HEADER) || '/';
|
|
9
|
-
|
|
10
|
-
// TODO: workaround for XP pattern controller mapping not picked up in edit mode
|
|
11
|
-
return header.replace(/\/edit\//, '/inline/');
|
|
12
|
-
};
|
package/src/utils/indent.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// sanitizes text according to graphql naming spec http://spec.graphql.org/October2021/#sec-Names
|
|
2
|
-
export const sanitizeGraphqlName = (text: string) => {
|
|
3
|
-
if (!text || text.trim().length === 0) {
|
|
4
|
-
return '';
|
|
5
|
-
}
|
|
6
|
-
let result = text.replace(/([^0-9A-Za-z])+/g, '_');
|
|
7
|
-
if (result.length > 0 && /[0-9]/.test(result.charAt(0))) {
|
|
8
|
-
result = '_' + result;
|
|
9
|
-
}
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import React, {Suspense} from 'react';
|
|
2
|
-
import type {BaseComponentProps, MetaData, PageComponent} from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {PORTAL_COMPONENT_ATTRIBUTE, RENDER_MODE, XP_COMPONENT_TYPE} from '../common/constants';
|
|
6
|
-
import {IS_DEV_MODE} from '../common/env';
|
|
7
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
8
|
-
import Empty from './Empty';
|
|
9
|
-
import getClientHydratedHtml from '../client/getClientHydratedHtml';
|
|
10
|
-
import {enonicDebug} from '../utils/enonicLog';
|
|
11
|
-
import {getServerRenderedHtml} from '../server/getServerRenderedHtml';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const BaseComponent = ({component, meta, common}: BaseComponentProps) => {
|
|
15
|
-
const {type, error} = component;
|
|
16
|
-
const cmpData = component[type];
|
|
17
|
-
const descriptor = cmpData && 'descriptor' in cmpData ? cmpData.descriptor : undefined;
|
|
18
|
-
|
|
19
|
-
let ComponentView: JSX.Element | null;
|
|
20
|
-
|
|
21
|
-
enonicDebug('BaseComponent', type, cmpData);
|
|
22
|
-
|
|
23
|
-
if (error) {
|
|
24
|
-
// renders error component when rendering whole page
|
|
25
|
-
console.warn(`BaseComponent: ${type} '${descriptor}' error: ${error}`);
|
|
26
|
-
ComponentView = shouldShowErrorView(meta) ? <ErrorComponent type={type} reason={error} descriptor={descriptor}/> : <Empty/>;
|
|
27
|
-
|
|
28
|
-
} else {
|
|
29
|
-
|
|
30
|
-
const ViewFn = ComponentRegistry.getComponent(type)?.view;
|
|
31
|
-
if (!ViewFn) {
|
|
32
|
-
// show missing component kind, i.e. 'part', 'layout', 'text'
|
|
33
|
-
console.warn(`BaseComponent: can not render component '${type}': no next view or catch-all defined`);
|
|
34
|
-
ComponentView = shouldShowMissingView(meta) ? <MissingComponent type={type} descriptor={descriptor}/> : <Empty/>;
|
|
35
|
-
|
|
36
|
-
} else {
|
|
37
|
-
const cmpAttrs = createComponentAttrs(component, meta, common);
|
|
38
|
-
ComponentView = <ViewFn {...cmpAttrs}/>;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// need to display a placeholder if descriptor is empty as component is not initialized yet
|
|
43
|
-
if (descriptor && shouldShowPlaceholderView(meta) && isComponentOutputEmpty(ComponentView)) {
|
|
44
|
-
ComponentView = <PlaceholderComponent type={type} descriptor={descriptor}/>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (meta.renderMode === RENDER_MODE.EDIT) {
|
|
48
|
-
return (
|
|
49
|
-
<div {...createEditorAttrs(type)}>
|
|
50
|
-
{ComponentView}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
} else {
|
|
54
|
-
// do not make component wrappers in live mode
|
|
55
|
-
return ComponentView;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
export default BaseComponent;
|
|
59
|
-
|
|
60
|
-
/*
|
|
61
|
-
* Used for displaying components with missing implementations on the page, while rendering whole page
|
|
62
|
-
*/
|
|
63
|
-
export const MissingComponent = ({descriptor, type}: { descriptor?: string, type: string }) => {
|
|
64
|
-
return (
|
|
65
|
-
<div style={{
|
|
66
|
-
border: '2px dashed lightgrey',
|
|
67
|
-
padding: '16px',
|
|
68
|
-
}}>
|
|
69
|
-
<h3 style={{margin: 0}}>Missing component</h3>
|
|
70
|
-
<p style={{marginBottom: 0, color: 'grey'}}>
|
|
71
|
-
Missing {type} with descriptor: <strong>{descriptor}</strong>. Did you forget to register it ?
|
|
72
|
-
</p>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const isComponentOutputEmpty = (component: React.ReactElement) => {
|
|
78
|
-
if (typeof document !== 'undefined') {
|
|
79
|
-
// render component on the client to see if it's empty
|
|
80
|
-
return !getClientHydratedHtml(component)?.length;
|
|
81
|
-
} else {
|
|
82
|
-
// render component on the server to see if it's empty
|
|
83
|
-
// Suspense is needed to render component on the server
|
|
84
|
-
return getServerRenderedHtml(<Suspense fallback={<p>Loading...</p>}>{component}</Suspense>) === '<!--$--><!--/$-->';
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export function shouldShowMissingView(meta: MetaData): boolean {
|
|
89
|
-
return IS_DEV_MODE || meta.renderMode !== RENDER_MODE.NEXT;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/*
|
|
93
|
-
* Used for displaying components with errors on the page, while rendering whole page
|
|
94
|
-
*/
|
|
95
|
-
export const ErrorComponent = ({type, descriptor, reason}: { type?: string, descriptor?: string, reason: string }) => {
|
|
96
|
-
return (
|
|
97
|
-
<div style={{
|
|
98
|
-
border: '2px solid red',
|
|
99
|
-
padding: '16px',
|
|
100
|
-
}}>
|
|
101
|
-
<h3 style={{margin: 0, textTransform: 'capitalize'}}>{reason ? reason : 'Unknown error'}</h3>
|
|
102
|
-
{descriptor && <p style={{color: 'grey'}}>{`${type}: ${descriptor}`}</p>}
|
|
103
|
-
</div>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export function shouldShowErrorView(meta: MetaData): boolean {
|
|
108
|
-
return meta.renderMode === RENDER_MODE.EDIT;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function createEditorAttrs(type: XP_COMPONENT_TYPE): Record<string,string> {
|
|
112
|
-
return {
|
|
113
|
-
[PORTAL_COMPONENT_ATTRIBUTE]: type,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function createComponentAttrs(component: PageComponent, meta: MetaData, common?: any): Record<string,any> {
|
|
118
|
-
const {type, data, error} = component;
|
|
119
|
-
const cmpAttrs: Record<string,any> = {
|
|
120
|
-
component: component[type],
|
|
121
|
-
path: component.path,
|
|
122
|
-
meta,
|
|
123
|
-
common,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
if (data) {
|
|
127
|
-
cmpAttrs.data = data;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (error) {
|
|
131
|
-
cmpAttrs.error = error;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (component.type === XP_COMPONENT_TYPE.LAYOUT) {
|
|
135
|
-
// add regions to layout because they are not present in component[component.type] above
|
|
136
|
-
cmpAttrs.regions = component.regions;
|
|
137
|
-
}
|
|
138
|
-
return cmpAttrs;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export const PlaceholderComponent = ({type, descriptor}: { type?: string, descriptor?: string }) => {
|
|
142
|
-
return (
|
|
143
|
-
<div style={{
|
|
144
|
-
border: '2px solid lightgrey',
|
|
145
|
-
padding: '16px',
|
|
146
|
-
}}>
|
|
147
|
-
<h3 style={{margin: 0, textTransform: 'capitalize'}}>Empty output</h3>
|
|
148
|
-
{descriptor && <p style={{color: 'grey'}}>{`${type} '${descriptor}' output is empty`}</p>}
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export function shouldShowPlaceholderView(meta: MetaData): boolean {
|
|
154
|
-
return meta.renderMode === RENDER_MODE.EDIT;
|
|
155
|
-
}
|
|
156
|
-
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type {BasePageProps, FetchContentResult} from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
6
|
-
import BasePage from './BasePage';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const BaseContent = (props: FetchContentResult) => {
|
|
10
|
-
const {common, meta, page} = props;
|
|
11
|
-
|
|
12
|
-
if (!meta?.type) {
|
|
13
|
-
console.warn("BaseContent props are missing 'meta.type'");
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const pageData = page?.page;
|
|
18
|
-
const pageDesc = pageData?.descriptor;
|
|
19
|
-
const typeDef = ComponentRegistry.getContentType(meta.type);
|
|
20
|
-
const ContentTypeView = typeDef?.view;
|
|
21
|
-
|
|
22
|
-
if (ContentTypeView && !typeDef?.catchAll) {
|
|
23
|
-
return <ContentTypeView {...props}/>;
|
|
24
|
-
} else if (pageDesc) {
|
|
25
|
-
const pageAttrs: BasePageProps = {
|
|
26
|
-
component: pageData,
|
|
27
|
-
path: page?.path,
|
|
28
|
-
meta,
|
|
29
|
-
common,
|
|
30
|
-
};
|
|
31
|
-
if (page?.data) {
|
|
32
|
-
pageAttrs.data = page.data;
|
|
33
|
-
}
|
|
34
|
-
if (page?.error) {
|
|
35
|
-
pageAttrs.error = page.error;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return <BasePage {...pageAttrs}/>;
|
|
39
|
-
} else if (ContentTypeView) {
|
|
40
|
-
return <ContentTypeView {...props}/>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log(`BaseContent: can not render ${meta.type}: no content type or page view defined`);
|
|
44
|
-
return null;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default BaseContent;
|
package/src/views/BaseLayout.tsx
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type {BaseLayoutProps} from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
6
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
7
|
-
import {MissingComponent, shouldShowMissingView} from './BaseComponent';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const BaseLayout = (props: BaseLayoutProps) => {
|
|
11
|
-
|
|
12
|
-
const {component, common, regions, meta, path} = props;
|
|
13
|
-
let layoutSelection;
|
|
14
|
-
if (component) {
|
|
15
|
-
layoutSelection = ComponentRegistry.getLayout(component.descriptor);
|
|
16
|
-
}
|
|
17
|
-
const SelectedLayoutView = layoutSelection?.view;
|
|
18
|
-
if (SelectedLayoutView) {
|
|
19
|
-
return <SelectedLayoutView layout={{descriptor: component?.descriptor, regions: regions || {}, config: component?.config}}
|
|
20
|
-
path={path}
|
|
21
|
-
common={common}
|
|
22
|
-
meta={meta}/>;
|
|
23
|
-
} else if (component?.descriptor) {
|
|
24
|
-
// empty descriptor usually means uninitialized layout
|
|
25
|
-
console.warn(`BaseLayout: can not render layout '${component?.descriptor}': no next view or catch-all defined`);
|
|
26
|
-
if (shouldShowMissingView(meta)) {
|
|
27
|
-
return <MissingComponent type={XP_COMPONENT_TYPE.LAYOUT} descriptor={component.descriptor}/>;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default BaseLayout;
|
package/src/views/BaseMacro.tsx
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type {BaseMacroProps, MacroConfig} from '../types';
|
|
2
|
-
|
|
3
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
4
|
-
import {RENDER_MODE} from '../common/constants';
|
|
5
|
-
import {sanitizeGraphqlName} from '../utils/sanitizeGraphqlName';
|
|
6
|
-
import HTMLReactParser from 'html-react-parser';
|
|
7
|
-
import {shouldShowMissingView, MissingComponent} from './BaseComponent';
|
|
8
|
-
import React from 'react';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const unescape = require('unescape');
|
|
12
|
-
|
|
13
|
-
export const MACRO_DISABLE = 'system:disable';
|
|
14
|
-
export const MACRO_EMBED = 'system:embed';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const BaseMacro = (props: BaseMacroProps) => {
|
|
18
|
-
const {data, children, meta, renderInEditMode} = props;
|
|
19
|
-
|
|
20
|
-
let config = data.config?.[sanitizeGraphqlName(data.name)] ?? {};
|
|
21
|
-
if (data.descriptor !== MACRO_DISABLE) {
|
|
22
|
-
// do not do any processing for disable macro
|
|
23
|
-
config = normalizeValue(config);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!renderInEditMode && meta?.renderMode === RENDER_MODE.EDIT) {
|
|
27
|
-
const attrs = formatAttributes(config);
|
|
28
|
-
if (config.body) {
|
|
29
|
-
// NB. config body takes precedence over children
|
|
30
|
-
|
|
31
|
-
// do not parse system macros (embed, disable) in edit mode
|
|
32
|
-
// but parse others because panel macros (for instance) wants its content to be html, not string
|
|
33
|
-
// TODO: should we make this behavior configurable ?
|
|
34
|
-
const bodyString = !data.descriptor.startsWith('system:') ? HTMLReactParser(config.body) : config.body;
|
|
35
|
-
return <>
|
|
36
|
-
{`[${data.name}${attrs}]`}
|
|
37
|
-
{bodyString}
|
|
38
|
-
{`[/${data.name}]`}
|
|
39
|
-
</>;
|
|
40
|
-
} else if (children) {
|
|
41
|
-
return <>
|
|
42
|
-
{`[${data.name}${attrs}]`}
|
|
43
|
-
{children}
|
|
44
|
-
{`[/${data.name}]`}
|
|
45
|
-
</>;
|
|
46
|
-
} else {
|
|
47
|
-
return <>
|
|
48
|
-
{`[${data.name}${attrs}/]`}
|
|
49
|
-
</>;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const macro = ComponentRegistry.getMacro(data.descriptor);
|
|
54
|
-
const MacroView = macro?.view;
|
|
55
|
-
if (MacroView) {
|
|
56
|
-
return <MacroView name={data.name} config={config} meta={meta}>{children}</MacroView>;
|
|
57
|
-
} else if (data.descriptor) {
|
|
58
|
-
console.warn(`BaseMacro: can not render macro '${data.descriptor}': no next view or catch-all defined`);
|
|
59
|
-
if (shouldShowMissingView(meta)) {
|
|
60
|
-
return <MissingComponent type="macro" descriptor={data.descriptor}/>;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
function normalizeValue(value: any): any {
|
|
67
|
-
let parsedVal: any;
|
|
68
|
-
if (value instanceof Array) {
|
|
69
|
-
parsedVal = value.map(normalizeValue);
|
|
70
|
-
} else if (value instanceof Object) {
|
|
71
|
-
parsedVal = {};
|
|
72
|
-
Object.entries(value).forEach(entry => parsedVal[entry[0]] = normalizeValue(entry[1]));
|
|
73
|
-
} else if (typeof value === 'string') {
|
|
74
|
-
const unescapedValue = unescape(value);
|
|
75
|
-
if (unescapedValue.startsWith('[') && unescapedValue.endsWith(']')) {
|
|
76
|
-
// Wicked array notation: "[Value 1, Value 2]"
|
|
77
|
-
parsedVal = unescapedValue.substring(1, unescapedValue.length - 1).split(/,\s*/);
|
|
78
|
-
} else {
|
|
79
|
-
try {
|
|
80
|
-
parsedVal = JSON.parse(unescapedValue);
|
|
81
|
-
} catch (e) {
|
|
82
|
-
// simple string or wrongly formatted JSON
|
|
83
|
-
parsedVal = unescapedValue;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
// most likely a number or unknown type
|
|
88
|
-
parsedVal = value;
|
|
89
|
-
}
|
|
90
|
-
return parsedVal;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function formatAttributes(config: MacroConfig): string {
|
|
94
|
-
const attrs: string[] = Object.entries(config)
|
|
95
|
-
.filter(entry => entry[0] !== 'body')
|
|
96
|
-
.reduce<string[]>((accum, entry) => {
|
|
97
|
-
// concat to make sure we account for arrays
|
|
98
|
-
[].concat(normalizeValue(entry[1])).forEach(val => accum.push(`${entry[0]}="${val}"`));
|
|
99
|
-
return accum;
|
|
100
|
-
}, []);
|
|
101
|
-
|
|
102
|
-
return attrs.length ? ` ${attrs.join(' ')}` : '';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export default BaseMacro;
|
package/src/views/BasePage.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type {BasePageProps} from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
6
|
-
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
7
|
-
import {ErrorComponent, MissingComponent, shouldShowErrorView, shouldShowMissingView} from './BaseComponent';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const BasePage = (props: BasePageProps) => {
|
|
11
|
-
const {component, data, common, error, meta, path} = props;
|
|
12
|
-
const desc = component?.descriptor;
|
|
13
|
-
if (error) {
|
|
14
|
-
console.warn(`BasePage: '${desc}' error: ${error}`);
|
|
15
|
-
if (shouldShowErrorView(meta)) {
|
|
16
|
-
return <ErrorComponent reason={error} descriptor={desc} type={XP_COMPONENT_TYPE.PAGE}/>;
|
|
17
|
-
} else {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
let pageDef;
|
|
22
|
-
if (desc) {
|
|
23
|
-
pageDef = ComponentRegistry.getPage(desc);
|
|
24
|
-
}
|
|
25
|
-
const PageView = pageDef?.view;
|
|
26
|
-
if (PageView) {
|
|
27
|
-
return <PageView page={component}
|
|
28
|
-
path={path}
|
|
29
|
-
data={data}
|
|
30
|
-
common={common}
|
|
31
|
-
meta={meta}/>;
|
|
32
|
-
} else if (component?.descriptor) {
|
|
33
|
-
// empty descriptor usually means uninitialized page
|
|
34
|
-
console.warn(`BasePage: can not render page '${desc}': no next view or catch-all defined`);
|
|
35
|
-
if (shouldShowMissingView(meta)) {
|
|
36
|
-
return <MissingComponent type={XP_COMPONENT_TYPE.PAGE} descriptor={component.descriptor}/>;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default BasePage;
|
package/src/views/BasePart.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type {BasePartProps} from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
6
|
-
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
7
|
-
import {MissingComponent, shouldShowMissingView} from './BaseComponent';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const BasePart = (props: BasePartProps) => {
|
|
11
|
-
const {component, data, common, meta, path} = props;
|
|
12
|
-
|
|
13
|
-
let partSelection;
|
|
14
|
-
if (component) {
|
|
15
|
-
partSelection = ComponentRegistry.getPart(component.descriptor);
|
|
16
|
-
}
|
|
17
|
-
const SelectedPartView = partSelection?.view;
|
|
18
|
-
if (SelectedPartView) {
|
|
19
|
-
return <SelectedPartView part={component}
|
|
20
|
-
path={path}
|
|
21
|
-
data={data}
|
|
22
|
-
common={common}
|
|
23
|
-
meta={meta}/>;
|
|
24
|
-
} else if (component?.descriptor) {
|
|
25
|
-
// empty descriptor usually means uninitialized part
|
|
26
|
-
console.warn(`BasePart: can not render part '${component.descriptor}': no next view or catch-all defined`);
|
|
27
|
-
if (shouldShowMissingView(meta)) {
|
|
28
|
-
return <MissingComponent type={XP_COMPONENT_TYPE.PART} descriptor={component.descriptor}/>;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default BasePart;
|
package/src/views/Empty.tsx
DELETED
package/src/views/Fragment.tsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type {FragmentProps, PageComponent} from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {FRAGMENT_DEFAULT_REGION_NAME, XP_COMPONENT_TYPE} from '../common/constants';
|
|
6
|
-
import BaseComponent, {MissingComponent, shouldShowMissingView} from './BaseComponent';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const FragmentView = (props: FragmentProps) => {
|
|
10
|
-
const {component, page} = props;
|
|
11
|
-
const comps: PageComponent[] = [];
|
|
12
|
-
if (page) {
|
|
13
|
-
// rendering whole page
|
|
14
|
-
const regions = page.regions || {};
|
|
15
|
-
const regionComps = regions[FRAGMENT_DEFAULT_REGION_NAME]?.components;
|
|
16
|
-
if (regionComps) {
|
|
17
|
-
comps.push(...regionComps);
|
|
18
|
-
}
|
|
19
|
-
} else if (component?.fragment) {
|
|
20
|
-
// rendering a part of a page
|
|
21
|
-
comps.push(...component.fragment.components);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!comps.length && shouldShowMissingView(props.meta)) {
|
|
25
|
-
return <MissingComponent type={XP_COMPONENT_TYPE.FRAGMENT} descriptor={page?.descriptor || component?.id}/>;
|
|
26
|
-
} else {
|
|
27
|
-
const {common, meta} = props;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<>
|
|
31
|
-
{
|
|
32
|
-
comps.map((comp: PageComponent, i: number) => (
|
|
33
|
-
<BaseComponent key={i} component={comp} common={common} meta={meta}/>
|
|
34
|
-
))
|
|
35
|
-
}
|
|
36
|
-
</>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default FragmentView;
|
package/src/views/MainView.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type {FetchContentResult} from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {XP_REQUEST_TYPE} from '../common/constants';
|
|
6
|
-
import SingleComponent from './SingleComponent';
|
|
7
|
-
import BaseContent from './BaseContent';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const _MainView = (props: FetchContentResult) => {
|
|
11
|
-
const {meta} = props;
|
|
12
|
-
|
|
13
|
-
// Single-component render:
|
|
14
|
-
if (meta?.requestType === XP_REQUEST_TYPE.COMPONENT) {
|
|
15
|
-
return <SingleComponent {...props} />;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// meta.requestType="type", and hence content-type based, is standard view for now.
|
|
19
|
-
return <BaseContent {...props} />;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default _MainView;
|
package/src/views/PropsView.tsx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
label: string
|
|
5
|
-
data: any
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const PropsView = (props: any) => {
|
|
9
|
-
return (
|
|
10
|
-
<div className='debug'
|
|
11
|
-
style={{margin: '10px', padding: '10px', border: '2px solid lightgrey'}}>
|
|
12
|
-
<DataDump label='Page' data={props.page}/>
|
|
13
|
-
<DataDump label='Part' data={props.part}/>
|
|
14
|
-
<DataDump label='Layout' data={props.layout}/>
|
|
15
|
-
<DataDump label='Data' data={props.data}/>
|
|
16
|
-
<DataDump label='Common' data={props.common}/>
|
|
17
|
-
</div>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default PropsView;
|
|
22
|
-
|
|
23
|
-
const DataDump = ({label, data}: Props) => (
|
|
24
|
-
(data && (
|
|
25
|
-
<>
|
|
26
|
-
{label && (
|
|
27
|
-
<h5 style={{marginTop: '0', marginBottom: '0'}}>{label}:</h5>
|
|
28
|
-
)}
|
|
29
|
-
<pre style={{
|
|
30
|
-
fontSize: '.8em',
|
|
31
|
-
width: '100%',
|
|
32
|
-
whiteSpace: 'pre-wrap',
|
|
33
|
-
wordWrap: 'break-word',
|
|
34
|
-
}}>{JSON.stringify(data, null, 2)}</pre>
|
|
35
|
-
</>
|
|
36
|
-
)
|
|
37
|
-
) || null
|
|
38
|
-
);
|