@sitecore-content-sdk/core 1.3.0-canary.9 → 1.4.0-canary.2
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/README.md +7 -7
- package/dist/cjs/cache-client.js +55 -54
- package/dist/cjs/client/constants.js +7 -7
- package/dist/cjs/client/edge-proxy.js +24 -22
- package/dist/cjs/client/index.js +15 -15
- package/dist/cjs/client/models.js +2 -2
- package/dist/cjs/client/sitecore-client.js +421 -419
- package/dist/cjs/client/utils.js +47 -46
- package/dist/cjs/config/define-config.js +194 -193
- package/dist/cjs/config/index.js +7 -7
- package/dist/cjs/config/models.js +12 -11
- package/dist/cjs/config-cli/define-cli-config.js +23 -22
- package/dist/cjs/config-cli/index.js +7 -7
- package/dist/cjs/config-cli/models.js +8 -7
- package/dist/cjs/constants.js +49 -17
- package/dist/cjs/debug.js +48 -46
- package/dist/cjs/editing/codegen/index.js +14 -9
- package/dist/cjs/editing/codegen/preview.js +277 -193
- package/dist/cjs/editing/component-layout-service.js +62 -61
- package/dist/cjs/editing/design-library.js +183 -126
- package/dist/cjs/editing/editing-service.js +75 -74
- package/dist/cjs/editing/index.js +33 -27
- package/dist/cjs/editing/metadata.js +42 -42
- package/dist/cjs/editing/models.js +44 -38
- package/dist/cjs/editing/utils.js +108 -90
- package/dist/cjs/form/form.js +81 -78
- package/dist/cjs/form/index.js +7 -7
- package/dist/cjs/graphql-request-client.js +108 -107
- package/dist/cjs/i18n/dictionary-service.js +122 -121
- package/dist/cjs/i18n/index.js +7 -7
- package/dist/cjs/i18n/utils.js +16 -15
- package/dist/cjs/index.js +60 -60
- package/dist/cjs/layout/content-styles.js +72 -71
- package/dist/cjs/layout/index.js +24 -24
- package/dist/cjs/layout/layout-service.js +62 -57
- package/dist/cjs/layout/models.js +39 -34
- package/dist/cjs/layout/themes.js +76 -75
- package/dist/cjs/layout/utils.js +117 -110
- package/dist/cjs/media/index.js +38 -38
- package/dist/cjs/media/media-api.js +100 -96
- package/dist/cjs/models.js +2 -2
- package/dist/cjs/native-fetcher.js +194 -179
- package/dist/cjs/personalize/index.js +15 -15
- package/dist/cjs/personalize/layout-personalizer.js +98 -97
- package/dist/cjs/personalize/personalize-service.js +98 -94
- package/dist/cjs/personalize/utils.js +143 -136
- package/dist/cjs/retries.js +43 -42
- package/dist/cjs/site/error-pages-service.js +65 -64
- package/dist/cjs/site/index.js +26 -26
- package/dist/cjs/site/models.js +2 -2
- package/dist/cjs/site/redirects-service.js +94 -81
- package/dist/cjs/site/robots-service.js +66 -65
- package/dist/cjs/site/site-resolver.js +73 -72
- package/dist/cjs/site/siteinfo-service.js +84 -80
- package/dist/cjs/site/sitemap-xml-service.js +84 -83
- package/dist/cjs/site/sitepath-service.js +165 -164
- package/dist/cjs/site/utils.js +55 -47
- package/dist/cjs/sitecore-service-base.js +36 -36
- package/dist/cjs/tools/auth/flow.js +65 -64
- package/dist/cjs/tools/auth/index.js +5 -5
- package/dist/cjs/tools/auth/models.js +2 -2
- package/dist/cjs/tools/auth/tenant-store.js +38 -38
- package/dist/cjs/tools/codegen/component-generation.js +52 -50
- package/dist/cjs/tools/codegen/extract-files.js +105 -107
- package/dist/cjs/tools/codegen/import-map.js +401 -349
- package/dist/cjs/tools/codegen/utils.js +418 -418
- package/dist/cjs/tools/generate-map.js +2 -2
- package/dist/cjs/tools/generateMetadata.js +36 -35
- package/dist/cjs/tools/generateSites.js +59 -58
- package/dist/cjs/tools/index.js +75 -73
- package/dist/cjs/tools/scaffold.js +60 -59
- package/dist/cjs/tools/templating/components.js +96 -266
- package/dist/cjs/tools/templating/index.js +11 -14
- package/dist/cjs/tools/templating/plugins.js +80 -78
- package/dist/cjs/tools/templating/utils.js +67 -66
- package/dist/cjs/utils/ensurePath.js +20 -20
- package/dist/cjs/utils/env.js +28 -27
- package/dist/cjs/utils/globalCache.js +55 -0
- package/dist/cjs/utils/index.js +26 -21
- package/dist/cjs/utils/is-server.js +11 -10
- package/dist/cjs/utils/normalize-url.js +5 -5
- package/dist/cjs/utils/timeout-promise.js +31 -31
- package/dist/cjs/utils/utils.js +254 -229
- package/dist/esm/cache-client.js +51 -50
- package/dist/esm/client/constants.js +4 -4
- package/dist/esm/client/edge-proxy.js +19 -17
- package/dist/esm/client/index.js +5 -5
- package/dist/esm/client/models.js +1 -1
- package/dist/esm/client/sitecore-client.js +414 -412
- package/dist/esm/client/utils.js +43 -42
- package/dist/esm/config/define-config.js +188 -187
- package/dist/esm/config/index.js +2 -2
- package/dist/esm/config/models.js +9 -8
- package/dist/esm/config-cli/define-cli-config.js +19 -18
- package/dist/esm/config-cli/index.js +2 -2
- package/dist/esm/config-cli/models.js +5 -4
- package/dist/esm/constants.js +46 -14
- package/dist/esm/debug.js +41 -39
- package/dist/esm/editing/codegen/index.js +1 -1
- package/dist/esm/editing/codegen/preview.js +263 -185
- package/dist/esm/editing/component-layout-service.js +55 -54
- package/dist/esm/editing/design-library.js +171 -117
- package/dist/esm/editing/editing-service.js +68 -67
- package/dist/esm/editing/index.js +6 -5
- package/dist/esm/editing/metadata.js +39 -39
- package/dist/esm/editing/models.js +41 -35
- package/dist/esm/editing/utils.js +98 -80
- package/dist/esm/form/form.js +72 -69
- package/dist/esm/form/index.js +1 -1
- package/dist/esm/graphql-request-client.js +101 -100
- package/dist/esm/i18n/dictionary-service.js +115 -114
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/i18n/utils.js +13 -12
- package/dist/esm/index.js +13 -13
- package/dist/esm/layout/content-styles.js +64 -63
- package/dist/esm/layout/index.js +6 -6
- package/dist/esm/layout/layout-service.js +55 -50
- package/dist/esm/layout/models.js +36 -31
- package/dist/esm/layout/themes.js +71 -70
- package/dist/esm/layout/utils.js +109 -102
- package/dist/esm/media/index.js +2 -2
- package/dist/esm/media/media-api.js +90 -86
- package/dist/esm/models.js +1 -1
- package/dist/esm/native-fetcher.js +187 -172
- package/dist/esm/personalize/index.js +3 -3
- package/dist/esm/personalize/layout-personalizer.js +93 -92
- package/dist/esm/personalize/personalize-service.js +91 -87
- package/dist/esm/personalize/utils.js +135 -128
- package/dist/esm/retries.js +39 -38
- package/dist/esm/site/error-pages-service.js +58 -57
- package/dist/esm/site/index.js +8 -8
- package/dist/esm/site/models.js +1 -1
- package/dist/esm/site/redirects-service.js +87 -74
- package/dist/esm/site/robots-service.js +59 -58
- package/dist/esm/site/site-resolver.js +69 -68
- package/dist/esm/site/siteinfo-service.js +77 -73
- package/dist/esm/site/sitemap-xml-service.js +77 -76
- package/dist/esm/site/sitepath-service.js +157 -156
- package/dist/esm/site/utils.js +49 -41
- package/dist/esm/sitecore-service-base.js +29 -29
- package/dist/esm/tools/auth/flow.js +62 -61
- package/dist/esm/tools/auth/index.js +1 -1
- package/dist/esm/tools/auth/models.js +1 -1
- package/dist/esm/tools/auth/tenant-store.js +35 -35
- package/dist/esm/tools/codegen/component-generation.js +44 -42
- package/dist/esm/tools/codegen/extract-files.js +99 -101
- package/dist/esm/tools/codegen/import-map.js +358 -306
- package/dist/esm/tools/codegen/utils.js +373 -373
- package/dist/esm/tools/generate-map.js +1 -1
- package/dist/esm/tools/generateMetadata.js +29 -28
- package/dist/esm/tools/generateSites.js +52 -51
- package/dist/esm/tools/index.js +28 -27
- package/dist/esm/tools/scaffold.js +52 -51
- package/dist/esm/tools/templating/components.js +59 -223
- package/dist/esm/tools/templating/index.js +3 -3
- package/dist/esm/tools/templating/plugins.js +72 -70
- package/dist/esm/tools/templating/utils.js +59 -58
- package/dist/esm/utils/ensurePath.js +13 -13
- package/dist/esm/utils/env.js +24 -23
- package/dist/esm/utils/globalCache.js +49 -0
- package/dist/esm/utils/index.js +4 -3
- package/dist/esm/utils/is-server.js +9 -8
- package/dist/esm/utils/normalize-url.js +1 -1
- package/dist/esm/utils/timeout-promise.js +28 -28
- package/dist/esm/utils/utils.js +238 -213
- package/package.json +73 -5
- package/types/cache-client.d.ts +68 -64
- package/types/cache-client.d.ts.map +1 -0
- package/types/client/constants.d.ts +5 -4
- package/types/client/constants.d.ts.map +1 -0
- package/types/client/edge-proxy.d.ts +18 -15
- package/types/client/edge-proxy.d.ts.map +1 -0
- package/types/client/index.d.ts +8 -7
- package/types/client/index.d.ts.map +1 -0
- package/types/client/models.d.ts +21 -19
- package/types/client/models.d.ts.map +1 -0
- package/types/client/sitecore-client.d.ts +338 -327
- package/types/client/sitecore-client.d.ts.map +1 -0
- package/types/client/utils.d.ts +15 -9
- package/types/client/utils.d.ts.map +1 -0
- package/types/config/define-config.d.ts +20 -18
- package/types/config/define-config.d.ts.map +1 -0
- package/types/config/index.d.ts +3 -2
- package/types/config/index.d.ts.map +1 -0
- package/types/config/models.d.ts +287 -268
- package/types/config/models.d.ts.map +1 -0
- package/types/config-cli/define-cli-config.d.ts +9 -7
- package/types/config-cli/define-cli-config.d.ts.map +1 -0
- package/types/config-cli/index.d.ts +3 -2
- package/types/config-cli/index.d.ts.map +1 -0
- package/types/config-cli/models.d.ts +6 -4
- package/types/config-cli/models.d.ts.map +1 -0
- package/types/constants.d.ts +44 -11
- package/types/constants.d.ts.map +1 -0
- package/types/debug.d.ts +35 -28
- package/types/debug.d.ts.map +1 -0
- package/types/editing/codegen/index.d.ts +2 -1
- package/types/editing/codegen/index.d.ts.map +1 -0
- package/types/editing/codegen/preview.d.ts +256 -195
- package/types/editing/codegen/preview.d.ts.map +1 -0
- package/types/editing/component-layout-service.d.ts +84 -80
- package/types/editing/component-layout-service.d.ts.map +1 -0
- package/types/editing/design-library.d.ts +111 -63
- package/types/editing/design-library.d.ts.map +1 -0
- package/types/editing/editing-service.d.ts +72 -62
- package/types/editing/editing-service.d.ts.map +1 -0
- package/types/editing/index.d.ts +7 -6
- package/types/editing/index.d.ts.map +1 -0
- package/types/editing/metadata.d.ts +8 -7
- package/types/editing/metadata.d.ts.map +1 -0
- package/types/editing/models.d.ts +103 -92
- package/types/editing/models.d.ts.map +1 -0
- package/types/editing/utils.d.ts +91 -74
- package/types/editing/utils.d.ts.map +1 -0
- package/types/form/form.d.ts +25 -21
- package/types/form/form.d.ts.map +1 -0
- package/types/form/index.d.ts +2 -1
- package/types/form/index.d.ts.map +1 -0
- package/types/graphql-request-client.d.ts +112 -105
- package/types/graphql-request-client.d.ts.map +1 -0
- package/types/i18n/dictionary-service.d.ts +135 -131
- package/types/i18n/dictionary-service.d.ts.map +1 -0
- package/types/i18n/index.d.ts +3 -2
- package/types/i18n/index.d.ts.map +1 -0
- package/types/i18n/utils.d.ts +9 -7
- package/types/i18n/utils.d.ts.map +1 -0
- package/types/index.d.ts +13 -12
- package/types/index.d.ts.map +1 -0
- package/types/layout/content-styles.d.ts +20 -18
- package/types/layout/content-styles.d.ts.map +1 -0
- package/types/layout/index.d.ts +6 -5
- package/types/layout/index.d.ts.map +1 -0
- package/types/layout/layout-service.d.ts +45 -35
- package/types/layout/layout-service.d.ts.map +1 -0
- package/types/layout/models.d.ts +174 -151
- package/types/layout/models.d.ts.map +1 -0
- package/types/layout/themes.d.ts +13 -11
- package/types/layout/themes.d.ts.map +1 -0
- package/types/layout/utils.d.ts +56 -41
- package/types/layout/utils.d.ts.map +1 -0
- package/types/media/index.d.ts +3 -2
- package/types/media/index.d.ts.map +1 -0
- package/types/media/media-api.d.ts +60 -55
- package/types/media/media-api.d.ts.map +1 -0
- package/types/models.d.ts +94 -84
- package/types/models.d.ts.map +1 -0
- package/types/native-fetcher.d.ts +124 -114
- package/types/native-fetcher.d.ts.map +1 -0
- package/types/personalize/index.d.ts +4 -3
- package/types/personalize/index.d.ts.map +1 -0
- package/types/personalize/layout-personalizer.d.ts +29 -27
- package/types/personalize/layout-personalizer.d.ts.map +1 -0
- package/types/personalize/personalize-service.d.ts +90 -80
- package/types/personalize/personalize-service.d.ts.map +1 -0
- package/types/personalize/utils.d.ts +78 -69
- package/types/personalize/utils.d.ts.map +1 -0
- package/types/retries.d.ts +26 -24
- package/types/retries.d.ts.map +1 -0
- package/types/site/error-pages-service.d.ts +64 -57
- package/types/site/error-pages-service.d.ts.map +1 -0
- package/types/site/index.d.ts +10 -9
- package/types/site/index.d.ts.map +1 -0
- package/types/site/models.d.ts +23 -18
- package/types/site/models.d.ts.map +1 -0
- package/types/site/redirects-service.d.ts +92 -69
- package/types/site/redirects-service.d.ts.map +1 -0
- package/types/site/robots-service.d.ts +57 -50
- package/types/site/robots-service.d.ts.map +1 -0
- package/types/site/site-resolver.d.ts +28 -26
- package/types/site/site-resolver.d.ts.map +1 -0
- package/types/site/siteinfo-service.d.ts +65 -52
- package/types/site/siteinfo-service.d.ts.map +1 -0
- package/types/site/sitemap-xml-service.d.ts +63 -56
- package/types/site/sitemap-xml-service.d.ts.map +1 -0
- package/types/site/sitepath-service.d.ts +137 -134
- package/types/site/sitepath-service.d.ts.map +1 -0
- package/types/site/utils.d.ts +41 -28
- package/types/site/utils.d.ts.map +1 -0
- package/types/sitecore-service-base.d.ts +31 -30
- package/types/sitecore-service-base.d.ts.map +1 -0
- package/types/tools/auth/flow.d.ts +29 -27
- package/types/tools/auth/flow.d.ts.map +1 -0
- package/types/tools/auth/index.d.ts +2 -1
- package/types/tools/auth/index.d.ts.map +1 -0
- package/types/tools/auth/models.d.ts +35 -33
- package/types/tools/auth/models.d.ts.map +1 -0
- package/types/tools/auth/tenant-store.d.ts +12 -11
- package/types/tools/auth/tenant-store.d.ts.map +1 -0
- package/types/tools/codegen/component-generation.d.ts +50 -47
- package/types/tools/codegen/component-generation.d.ts.map +1 -0
- package/types/tools/codegen/extract-files.d.ts +24 -22
- package/types/tools/codegen/extract-files.d.ts.map +1 -0
- package/types/tools/codegen/import-map.d.ts +103 -70
- package/types/tools/codegen/import-map.d.ts.map +1 -0
- package/types/tools/codegen/utils.d.ts +76 -75
- package/types/tools/codegen/utils.d.ts.map +1 -0
- package/types/tools/generate-map.d.ts +36 -26
- package/types/tools/generate-map.d.ts.map +1 -0
- package/types/tools/generateMetadata.d.ts +24 -22
- package/types/tools/generateMetadata.d.ts.map +1 -0
- package/types/tools/generateSites.d.ts +25 -22
- package/types/tools/generateSites.d.ts.map +1 -0
- package/types/tools/index.d.ts +22 -20
- package/types/tools/index.d.ts.map +1 -0
- package/types/tools/scaffold.d.ts +27 -25
- package/types/tools/scaffold.d.ts.map +1 -0
- package/types/tools/templating/components.d.ts +104 -103
- package/types/tools/templating/components.d.ts.map +1 -0
- package/types/tools/templating/index.d.ts +4 -3
- package/types/tools/templating/index.d.ts.map +1 -0
- package/types/tools/templating/plugins.d.ts +71 -67
- package/types/tools/templating/plugins.d.ts.map +1 -0
- package/types/tools/templating/utils.d.ts +42 -40
- package/types/tools/templating/utils.d.ts.map +1 -0
- package/types/utils/ensurePath.d.ts +7 -6
- package/types/utils/ensurePath.d.ts.map +1 -0
- package/types/utils/env.d.ts +9 -7
- package/types/utils/env.d.ts.map +1 -0
- package/types/utils/globalCache.d.ts +37 -0
- package/types/utils/globalCache.d.ts.map +1 -0
- package/types/utils/index.d.ts +5 -3
- package/types/utils/index.d.ts.map +1 -0
- package/types/utils/is-server.d.ts +8 -6
- package/types/utils/is-server.d.ts.map +1 -0
- package/types/utils/normalize-url.d.ts +2 -1
- package/types/utils/normalize-url.d.ts.map +1 -0
- package/types/utils/timeout-promise.d.ts +18 -17
- package/types/utils/timeout-promise.d.ts.map +1 -0
- package/types/utils/utils.d.ts +104 -79
- package/types/utils/utils.d.ts.map +1 -0
- package/client.js +0 -1
- package/codegen.js +0 -1
- package/config-cli.js +0 -1
- package/config.js +0 -1
- package/editing.js +0 -1
- package/i18n.js +0 -1
- package/layout.js +0 -1
- package/media.js +0 -1
- package/personalize.js +0 -1
- package/site.js +0 -1
- package/tools.js +0 -1
- package/utils.js +0 -1
|
@@ -1,193 +1,277 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addComponentPreviewHandler = exports.DesignLibraryPreviewError = void 0;
|
|
4
|
-
exports.buildComponentDependencies = buildComponentDependencies;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Error occurred during component
|
|
36
|
-
*/
|
|
37
|
-
DesignLibraryPreviewError["
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*
|
|
160
|
-
* @param {
|
|
161
|
-
* @
|
|
162
|
-
* @
|
|
163
|
-
* @
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendErrorEvent = exports.createComponentInstance = exports.addServerComponentPreviewHandler = exports.addComponentPreviewHandler = exports.DesignLibraryPreviewError = void 0;
|
|
4
|
+
exports.buildComponentDependencies = buildComponentDependencies;
|
|
5
|
+
exports.addStyleElement = addStyleElement;
|
|
6
|
+
exports.getDesignLibraryComponentPreviewErrorEvent = getDesignLibraryComponentPreviewErrorEvent;
|
|
7
|
+
exports.getDesignLibraryComponentPropsEvent = getDesignLibraryComponentPropsEvent;
|
|
8
|
+
exports.getDesignLibraryImportMapEvent = getDesignLibraryImportMapEvent;
|
|
9
|
+
exports.getImportMapInfo = getImportMapInfo;
|
|
10
|
+
exports.isImportEntryInfoArray = isImportEntryInfoArray;
|
|
11
|
+
const design_library_1 = require("../design-library");
|
|
12
|
+
/**
|
|
13
|
+
* Event to send import map to design library
|
|
14
|
+
*/
|
|
15
|
+
const DESIGN_LIBRARY_IMPORT_MAP_EVENT_NAME = 'component:generation:import-map';
|
|
16
|
+
/**
|
|
17
|
+
* Event to send component props to design library
|
|
18
|
+
*/
|
|
19
|
+
const DESIGN_LIBRARY_COMPONENT_PROPS_EVENT_NAME = 'component:generation:component-props';
|
|
20
|
+
/**
|
|
21
|
+
* Event to receive component data from design library
|
|
22
|
+
*/
|
|
23
|
+
const DESIGN_LIBRARY_COMPONENT_PREVIEW_EVENT_NAME = 'component:generation:component-preview';
|
|
24
|
+
/**
|
|
25
|
+
* Event to send component error to design library
|
|
26
|
+
*/
|
|
27
|
+
const DESIGN_LIBRARY_COMPONENT_PREVIEW_ERROR_EVENT_NAME = 'component:generation:component-preview-error';
|
|
28
|
+
/**
|
|
29
|
+
* Enumeration of error types for the design library preview.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
var DesignLibraryPreviewError;
|
|
33
|
+
(function (DesignLibraryPreviewError) {
|
|
34
|
+
/**
|
|
35
|
+
* Error occurred during component rendering.
|
|
36
|
+
*/
|
|
37
|
+
DesignLibraryPreviewError["Render"] = "render";
|
|
38
|
+
/**
|
|
39
|
+
* Error occurred during component and event handlers initialization.
|
|
40
|
+
*/
|
|
41
|
+
DesignLibraryPreviewError["RenderInit"] = "render-init";
|
|
42
|
+
})(DesignLibraryPreviewError || (exports.DesignLibraryPreviewError = DesignLibraryPreviewError = {}));
|
|
43
|
+
/**
|
|
44
|
+
* Builds the component dependencies from the component imports and the import map.
|
|
45
|
+
* @param {ComponentImport[]} componentImports - The component imports.
|
|
46
|
+
* @param {ImportEntry[]} importMap - The import map to be used for the component.
|
|
47
|
+
* @returns {Array<{ name: string; value: unknown }>} The component dependencies.
|
|
48
|
+
*/
|
|
49
|
+
function buildComponentDependencies(componentImports, importMap) {
|
|
50
|
+
const successful = [];
|
|
51
|
+
const missing = {
|
|
52
|
+
modules: [],
|
|
53
|
+
exports: [],
|
|
54
|
+
};
|
|
55
|
+
componentImports.forEach((componentImport) => {
|
|
56
|
+
const moduleEntry = importMap.find((entry) => entry.module === componentImport.module);
|
|
57
|
+
if (!moduleEntry) {
|
|
58
|
+
missing.modules.push({
|
|
59
|
+
module: componentImport.module,
|
|
60
|
+
alias: componentImport.alias,
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const exportEntry = moduleEntry.exports.find((exp) => exp.name === componentImport.export);
|
|
65
|
+
if (!exportEntry) {
|
|
66
|
+
missing.exports.push({
|
|
67
|
+
alias: componentImport.alias,
|
|
68
|
+
export: componentImport.export,
|
|
69
|
+
module: componentImport.module,
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
return successful.push({
|
|
74
|
+
name: componentImport.alias,
|
|
75
|
+
value: exportEntry.value,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
successful,
|
|
80
|
+
missing,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Adds the browser-side event handler for 'component:generation:component-preview' message used in Design Library
|
|
85
|
+
* The event should contain the component code, styles and imports.
|
|
86
|
+
* @param {ImportEntry[]} importMap - The import map to be used for the component.
|
|
87
|
+
* @param {Function} callback callback to be called after component is received
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
const addComponentPreviewHandler = (importMap, callback) => {
|
|
91
|
+
if (!window)
|
|
92
|
+
return;
|
|
93
|
+
const handler = (e) => {
|
|
94
|
+
const eventArgs = e.data;
|
|
95
|
+
try {
|
|
96
|
+
if (!(0, design_library_1.validateEvent)(e, DESIGN_LIBRARY_COMPONENT_PREVIEW_EVENT_NAME)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
console.debug('Component Library: message received', eventArgs);
|
|
100
|
+
const Component = (0, exports.createComponentInstance)(importMap, eventArgs);
|
|
101
|
+
addStyleElement(eventArgs.message.styles.content);
|
|
102
|
+
callback(null, Component);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
(0, exports.sendErrorEvent)(eventArgs.message.uid, error, DesignLibraryPreviewError.RenderInit);
|
|
106
|
+
callback(error, null);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
window.addEventListener('message', handler);
|
|
110
|
+
const unsubscribe = () => {
|
|
111
|
+
window.removeEventListener('message', handler);
|
|
112
|
+
};
|
|
113
|
+
return unsubscribe;
|
|
114
|
+
};
|
|
115
|
+
exports.addComponentPreviewHandler = addComponentPreviewHandler;
|
|
116
|
+
/**
|
|
117
|
+
* Adds the browser-side event handler for 'component:generation:component-preview' message used in Design Library for server components
|
|
118
|
+
* The event should contain the component code, styles and imports.
|
|
119
|
+
* @param {Function} callback callback to be called after component is received
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
const addServerComponentPreviewHandler = (callback) => {
|
|
123
|
+
const handler = (e) => {
|
|
124
|
+
if (!(0, design_library_1.validateEvent)(e, DESIGN_LIBRARY_COMPONENT_PREVIEW_EVENT_NAME)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
console.debug('Component Library: message received', e.data);
|
|
128
|
+
callback(e.data);
|
|
129
|
+
};
|
|
130
|
+
window.addEventListener('message', handler);
|
|
131
|
+
const unsubscribe = () => {
|
|
132
|
+
window.removeEventListener('message', handler);
|
|
133
|
+
};
|
|
134
|
+
return unsubscribe;
|
|
135
|
+
};
|
|
136
|
+
exports.addServerComponentPreviewHandler = addServerComponentPreviewHandler;
|
|
137
|
+
/**
|
|
138
|
+
* Adds <style> element in the document head with the provided CSS.
|
|
139
|
+
* If an existing style element with the id "content-sdk-style-preview" is found, it is removed
|
|
140
|
+
* to prevent duplicates
|
|
141
|
+
* @param {string} stylesContent - The raw CSS text to inject into the style element.
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
function addStyleElement(stylesContent) {
|
|
145
|
+
const styleId = 'content-sdk-style-preview';
|
|
146
|
+
const styleElement = document.getElementById(styleId);
|
|
147
|
+
// remove existing style element if it exists to avoid duplicates
|
|
148
|
+
if (styleElement) {
|
|
149
|
+
styleElement.remove();
|
|
150
|
+
}
|
|
151
|
+
// create new style element and attach it to DOM
|
|
152
|
+
const style = document.createElement('style');
|
|
153
|
+
style.setAttribute('id', styleId);
|
|
154
|
+
style.innerHTML = stylesContent;
|
|
155
|
+
document.head.appendChild(style);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Dynamically creates a React component instance from provided importMap and from code, styles, and dependencies provided in the preview event.
|
|
159
|
+
* @param {ImportEntry[]} importMap - The import map containing module and export references that might be injected as dependencies in the provided code.
|
|
160
|
+
* @param {ComponentPreviewEventArgs} previewEventArgs - The event arguments containing the component code, styles, and import definitions.
|
|
161
|
+
* @returns The dynamically created React component instance.
|
|
162
|
+
* @throws If any required modules or exports are missing from the import map, an error is thrown describing the missing dependencies.
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
const createComponentInstance = (importMap, previewEventArgs) => {
|
|
166
|
+
const { message } = previewEventArgs;
|
|
167
|
+
const dependencies = buildComponentDependencies(message.imports, importMap);
|
|
168
|
+
if (dependencies.missing.modules.length > 0 || dependencies.missing.exports.length > 0) {
|
|
169
|
+
let errorMessage = '';
|
|
170
|
+
dependencies.missing.modules.forEach((mod) => {
|
|
171
|
+
errorMessage += `Missing module: '${mod.module}' with alias: '${mod.alias}'\n`;
|
|
172
|
+
});
|
|
173
|
+
dependencies.missing.exports.forEach((exp) => {
|
|
174
|
+
const alias = exp.export !== exp.alias ? ` with alias: '${exp.alias}'` : '';
|
|
175
|
+
errorMessage += `Missing export: '${exp.export}' from module: '${exp.module}'${alias}\n`;
|
|
176
|
+
});
|
|
177
|
+
throw errorMessage;
|
|
178
|
+
}
|
|
179
|
+
const importNames = dependencies.successful.map((entry) => entry.name);
|
|
180
|
+
const importInstances = dependencies.successful.map((entry) => entry.value);
|
|
181
|
+
const exports = { Component: null };
|
|
182
|
+
const componentFn = new Function('exports', message.styles.styleImport.name, ...importNames, message.code.content);
|
|
183
|
+
// Function will set exports.Component
|
|
184
|
+
componentFn(exports, message.styles.styleImport.content, ...importInstances);
|
|
185
|
+
return exports.Component;
|
|
186
|
+
};
|
|
187
|
+
exports.createComponentInstance = createComponentInstance;
|
|
188
|
+
/**
|
|
189
|
+
* Generates a DesignLibraryComponentPreviewErrorEvent with the given uid and error.
|
|
190
|
+
* @param {string} uid - The unique identifier for the event.
|
|
191
|
+
* @param {unknown} error - The error to be sent.
|
|
192
|
+
* @param {DesignLibraryPreviewError} type - The type of error.
|
|
193
|
+
* @returns An object representing the DesignLibraryComponentPreviewErrorEvent.
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
function getDesignLibraryComponentPreviewErrorEvent(uid, error, type) {
|
|
197
|
+
return {
|
|
198
|
+
name: DESIGN_LIBRARY_COMPONENT_PREVIEW_ERROR_EVENT_NAME,
|
|
199
|
+
message: { uid, error, type },
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Generates a DesignLibraryComponentPropsEvent with the given uid, fields and parameters.
|
|
204
|
+
* @param {string} uid - The unique identifier for the event.
|
|
205
|
+
* @param {ComponentFields} fields - The fields of the component.
|
|
206
|
+
* @param {ComponentParams} parameters - The parameters of the component.
|
|
207
|
+
* @returns An object representing the DesignLibraryComponentPropsEvent.
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
210
|
+
function getDesignLibraryComponentPropsEvent(uid, fields = {}, parameters = {}) {
|
|
211
|
+
return {
|
|
212
|
+
name: DESIGN_LIBRARY_COMPONENT_PROPS_EVENT_NAME,
|
|
213
|
+
message: {
|
|
214
|
+
uid,
|
|
215
|
+
fields,
|
|
216
|
+
parameters,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Generates a DesignLibraryImportMapEvent with the given uid and importMap.
|
|
222
|
+
* @param {string} uid - The unique identifier for the event.
|
|
223
|
+
* @param {ImportEntry[]} importMap - The imports map to be sent.
|
|
224
|
+
* @returns An object representing the DesignLibraryImportMapEvent.
|
|
225
|
+
* @internal
|
|
226
|
+
*/
|
|
227
|
+
function getDesignLibraryImportMapEvent(uid, importMap) {
|
|
228
|
+
const importMapPayload = isImportEntryInfoArray(importMap)
|
|
229
|
+
? importMap
|
|
230
|
+
: getImportMapInfo(importMap);
|
|
231
|
+
return {
|
|
232
|
+
name: DESIGN_LIBRARY_IMPORT_MAP_EVENT_NAME,
|
|
233
|
+
message: {
|
|
234
|
+
uid,
|
|
235
|
+
importMap: importMapPayload,
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Generates the payload for the import map to be sent to design library.
|
|
241
|
+
* @param {ImportEntry[]} importMap - The imports map to be sent.
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
function getImportMapInfo(importMap) {
|
|
245
|
+
return importMap.map((entry) => ({
|
|
246
|
+
module: entry.module,
|
|
247
|
+
exports: entry.exports.map((exp) => exp.name),
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Type guard for ImportEntryInfo[]
|
|
252
|
+
* @param {unknown} data import entry data to check
|
|
253
|
+
* @returns true if the data is ImportEntryInfo array
|
|
254
|
+
*/
|
|
255
|
+
function isImportEntryInfoArray(data) {
|
|
256
|
+
return (Array.isArray(data) &&
|
|
257
|
+
data.length > 0 &&
|
|
258
|
+
typeof data[0].module === 'string' &&
|
|
259
|
+
Array.isArray(data[0].exports) &&
|
|
260
|
+
typeof data[0].exports[0] === 'string');
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Sends a component preview error event to the design library
|
|
264
|
+
* @param {string} uid - The unique identifier of the component that's being edited.
|
|
265
|
+
* @param {unknown} error - The error object or message to be sent.
|
|
266
|
+
* @param {DesignLibraryPreviewError} type - The type of error, as defined in DesignLibraryPreviewError.
|
|
267
|
+
* @internal
|
|
268
|
+
*/
|
|
269
|
+
const sendErrorEvent = (uid, error, type) => {
|
|
270
|
+
const errorEvent = getDesignLibraryComponentPreviewErrorEvent(uid, error, type);
|
|
271
|
+
console.error('Component Library: sending error event', errorEvent);
|
|
272
|
+
if (typeof window !== 'undefined') {
|
|
273
|
+
const target = window.parent && window.parent !== window ? window.parent : window;
|
|
274
|
+
target.postMessage(errorEvent, '*');
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
exports.sendErrorEvent = sendErrorEvent;
|
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ComponentLayoutService = void 0;
|
|
7
|
-
const native_fetcher_1 = require("../native-fetcher");
|
|
8
|
-
const debug_1 = __importDefault(require("../debug"));
|
|
9
|
-
const constants_1 = require("../constants");
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const models_1 = require("./models");
|
|
12
|
-
/**
|
|
13
|
-
* REST service that enables Design Library functionality.
|
|
14
|
-
* Returns layout data for a single rendered component.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ComponentLayoutService = void 0;
|
|
7
|
+
const native_fetcher_1 = require("../native-fetcher");
|
|
8
|
+
const debug_1 = __importDefault(require("../debug"));
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const models_1 = require("./models");
|
|
12
|
+
/**
|
|
13
|
+
* REST service that enables Design Library functionality.
|
|
14
|
+
* Returns layout data for a single rendered component.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class ComponentLayoutService {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
fetchComponentData(params, fetchOptions) {
|
|
22
|
+
const fetcher = new native_fetcher_1.NativeDataFetcher({ debugger: debug_1.default.layout });
|
|
23
|
+
debug_1.default.layout('fetching component with uid %s for %s %s %s %s', params.componentUid, params.itemId, params.language, params.siteName, params.dataSourceId);
|
|
24
|
+
return fetcher
|
|
25
|
+
.get(this.getFetchUrl(params), Object.assign(Object.assign({}, fetchOptions), { headers: Object.assign(Object.assign({}, fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.headers), { sc_editMode: `${params.mode === models_1.DesignLibraryMode.Metadata}` }) }))
|
|
26
|
+
.then((response) => response.data)
|
|
27
|
+
.catch((error) => {
|
|
28
|
+
var _a;
|
|
29
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
30
|
+
return error.response.data;
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
getComponentFetchParams(params) {
|
|
36
|
+
// Choose the correct Edge ID per environment
|
|
37
|
+
const sitecoreContextId = this.config.contextId || this.config.clientContextId;
|
|
38
|
+
if (!sitecoreContextId) {
|
|
38
39
|
throw new Error(`ComponentLayoutService misconfigured: contextId is missing.
|
|
39
|
-
Provide contextId on the server, and clientContextId in the browser if you need to full client-side functionality.`);
|
|
40
|
-
}
|
|
41
|
-
// strip undefined fields
|
|
42
|
-
return JSON.parse(JSON.stringify({
|
|
43
|
-
sitecoreContextId,
|
|
44
|
-
item: params.itemId,
|
|
45
|
-
uid: params.componentUid,
|
|
46
|
-
dataSourceId: params.dataSourceId,
|
|
47
|
-
renderingItemId: params.renderingId,
|
|
48
|
-
version: params.version,
|
|
49
|
-
sc_site: params.siteName,
|
|
50
|
-
sc_lang: params.language || 'en',
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get the fetch URL for the partial layout data endpoint
|
|
55
|
-
* @param {ComponentLayoutRequestParams} params - The parameters for the request
|
|
56
|
-
* @returns {string} The fetch URL for the component data
|
|
57
|
-
*/
|
|
58
|
-
getFetchUrl(params) {
|
|
59
|
-
return (0, utils_1.resolveUrl)(`${this.config.edgeUrl || constants_1.SITECORE_EDGE_URL_DEFAULT}/layout/component`, this.getComponentFetchParams(params));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.ComponentLayoutService = ComponentLayoutService;
|
|
40
|
+
Provide contextId on the server, and clientContextId in the browser if you need to full client-side functionality.`);
|
|
41
|
+
}
|
|
42
|
+
// strip undefined fields
|
|
43
|
+
return JSON.parse(JSON.stringify({
|
|
44
|
+
sitecoreContextId,
|
|
45
|
+
item: params.itemId,
|
|
46
|
+
uid: params.componentUid,
|
|
47
|
+
dataSourceId: params.dataSourceId,
|
|
48
|
+
renderingItemId: params.renderingId,
|
|
49
|
+
version: params.version,
|
|
50
|
+
sc_site: params.siteName,
|
|
51
|
+
sc_lang: params.language || 'en',
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the fetch URL for the partial layout data endpoint
|
|
56
|
+
* @param {ComponentLayoutRequestParams} params - The parameters for the request
|
|
57
|
+
* @returns {string} The fetch URL for the component data
|
|
58
|
+
*/
|
|
59
|
+
getFetchUrl(params) {
|
|
60
|
+
return (0, utils_1.resolveUrl)(`${this.config.edgeUrl || constants_1.SITECORE_EDGE_URL_DEFAULT}/layout/component`, this.getComponentFetchParams(params));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.ComponentLayoutService = ComponentLayoutService;
|