@sitecore-content-sdk/nextjs 0.1.0-beta.34 → 0.1.0-beta.35

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.
Files changed (32) hide show
  1. package/dist/cjs/client/sitecore-nextjs-client.js +4 -4
  2. package/dist/cjs/editing/editing-config-middleware.js +1 -3
  3. package/dist/cjs/index.js +2 -4
  4. package/dist/cjs/services/component-props-service.js +13 -9
  5. package/dist/cjs/tools/index.js +0 -15
  6. package/dist/esm/client/sitecore-nextjs-client.js +4 -4
  7. package/dist/esm/editing/editing-config-middleware.js +1 -3
  8. package/dist/esm/index.js +0 -1
  9. package/dist/esm/services/component-props-service.js +13 -9
  10. package/dist/esm/tools/index.js +0 -1
  11. package/package.json +4 -4
  12. package/types/client/sitecore-nextjs-client.d.ts +5 -5
  13. package/types/editing/editing-config-middleware.d.ts +3 -1
  14. package/types/index.d.ts +2 -4
  15. package/types/services/component-props-service.d.ts +4 -3
  16. package/types/sharedTypes/component-props.d.ts +18 -0
  17. package/types/tools/index.d.ts +0 -1
  18. package/dist/cjs/ComponentBuilder.js +0 -63
  19. package/dist/cjs/sharedTypes/module-factory.js +0 -2
  20. package/dist/cjs/tools/templating/generate-component-builder.js +0 -71
  21. package/dist/cjs/tools/templating/index.js +0 -7
  22. package/dist/cjs/tools/templating/templates/component-builder.js +0 -59
  23. package/dist/esm/ComponentBuilder.js +0 -59
  24. package/dist/esm/sharedTypes/module-factory.js +0 -1
  25. package/dist/esm/tools/templating/generate-component-builder.js +0 -63
  26. package/dist/esm/tools/templating/index.js +0 -2
  27. package/dist/esm/tools/templating/templates/component-builder.js +0 -55
  28. package/types/ComponentBuilder.d.ts +0 -59
  29. package/types/sharedTypes/module-factory.d.ts +0 -32
  30. package/types/tools/templating/generate-component-builder.d.ts +0 -45
  31. package/types/tools/templating/index.d.ts +0 -2
  32. package/types/tools/templating/templates/component-builder.d.ts +0 -7
@@ -70,14 +70,14 @@ class SitecoreNextjsClient extends client_1.SitecoreClient {
70
70
  });
71
71
  }
72
72
  /**
73
- * Parses components from nextjs component factory and layoutData, executes getServerProps/getStaticProps methods
73
+ * Parses components from nextjs component map and layoutData, executes getServerProps/getStaticProps methods
74
74
  * and returns resulting props from components
75
75
  * @param {LayoutServiceData} layoutData layout data to parse compnents from
76
76
  * @param {PreviewData} context Nextjs preview data
77
- * @param {ModuleFactory} moduleFactory module factory to use for component parsing
77
+ * @param {ComponentMap<NextjsJssComponent>} components component map to get props for
78
78
  * @returns {ComponentPropsCollection} component props
79
79
  */
80
- getComponentData(layoutData, context, moduleFactory) {
80
+ getComponentData(layoutData, context, components) {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  let componentProps = {};
83
83
  if (!layoutData.sitecore.route)
@@ -86,7 +86,7 @@ class SitecoreNextjsClient extends client_1.SitecoreClient {
86
86
  componentProps = yield this.componentPropsService.fetchComponentProps({
87
87
  layoutData: layoutData,
88
88
  context,
89
- moduleFactory,
89
+ components,
90
90
  });
91
91
  const errors = Object.keys(componentProps)
92
92
  .map((id) => {
@@ -41,9 +41,7 @@ class EditingConfigMiddleware {
41
41
  // CORS headers are set by enforceCors
42
42
  return res.status(204).send(null);
43
43
  }
44
- const components = Array.isArray(this.config.components)
45
- ? this.config.components
46
- : Array.from(this.config.components.keys());
44
+ const components = Array.from(this.config.components.keys());
47
45
  return res.status(200).json({
48
46
  components,
49
47
  packages: this.config.metadata.packages,
package/dist/cjs/index.js CHANGED
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.DesignLibrary = exports.File = exports.getDesignLibraryStylesheetLinks = exports.BYOCComponent = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.DateField = exports.Text = exports.Image = exports.ComponentBuilder = exports.BYOCWrapper = exports.FEaaSWrapper = exports.NextImage = exports.Placeholder = exports.RichText = exports.Link = exports.useComponentProps = exports.ComponentPropsContext = exports.ComponentPropsReactContext = exports.normalizeSiteRewrite = exports.getSiteRewriteData = exports.getSiteRewrite = exports.GraphQLSiteInfoService = exports.SiteResolver = exports.GraphQLRobotsService = exports.GraphQLErrorPagesService = exports.GraphQLSitemapXmlService = exports.GraphQLSitePathService = exports.ComponentPropsService = exports.CdpHelper = exports.normalizePersonalizedRewrite = exports.getGroomedVariantIds = exports.getPersonalizedRewriteData = exports.getPersonalizedRewrite = exports.personalizeLayout = exports.GraphQLDictionaryService = exports.mediaApi = exports.RestComponentLayoutService = exports.RenderingType = exports.EditMode = exports.getContentStylesheetLink = exports.getFieldValue = exports.getChildPlaceholder = exports.GraphQLLayoutService = exports.LayoutServicePageState = exports.MemoryCacheClient = exports.debug = exports.enableDebug = exports.NativeDataFetcher = exports.constants = void 0;
37
- exports.Form = exports.EditingScripts = exports.withEmptyFieldEditingComponent = exports.withFieldMetadata = exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.DefaultEmptyFieldEditingComponentText = exports.DefaultEmptyFieldEditingComponentImage = void 0;
36
+ exports.DefaultEmptyFieldEditingComponentImage = exports.DesignLibrary = exports.File = exports.getDesignLibraryStylesheetLinks = exports.BYOCComponent = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.DateField = exports.Text = exports.Image = exports.BYOCWrapper = exports.FEaaSWrapper = exports.NextImage = exports.Placeholder = exports.RichText = exports.Link = exports.useComponentProps = exports.ComponentPropsContext = exports.ComponentPropsReactContext = exports.normalizeSiteRewrite = exports.getSiteRewriteData = exports.getSiteRewrite = exports.GraphQLSiteInfoService = exports.SiteResolver = exports.GraphQLRobotsService = exports.GraphQLErrorPagesService = exports.GraphQLSitemapXmlService = exports.GraphQLSitePathService = exports.ComponentPropsService = exports.CdpHelper = exports.normalizePersonalizedRewrite = exports.getGroomedVariantIds = exports.getPersonalizedRewriteData = exports.getPersonalizedRewrite = exports.personalizeLayout = exports.GraphQLDictionaryService = exports.mediaApi = exports.RestComponentLayoutService = exports.RenderingType = exports.EditMode = exports.getContentStylesheetLink = exports.getFieldValue = exports.getChildPlaceholder = exports.GraphQLLayoutService = exports.LayoutServicePageState = exports.MemoryCacheClient = exports.debug = exports.enableDebug = exports.NativeDataFetcher = exports.constants = void 0;
37
+ exports.Form = exports.EditingScripts = exports.withEmptyFieldEditingComponent = exports.withFieldMetadata = exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.DefaultEmptyFieldEditingComponentText = void 0;
38
38
  var core_1 = require("@sitecore-content-sdk/core");
39
39
  Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return core_1.constants; } });
40
40
  // generic data access
@@ -92,8 +92,6 @@ const FEaaSWrapper = __importStar(require("./components/FEaaSWrapper"));
92
92
  exports.FEaaSWrapper = FEaaSWrapper;
93
93
  const BYOCWrapper = __importStar(require("./components/BYOCWrapper"));
94
94
  exports.BYOCWrapper = BYOCWrapper;
95
- var ComponentBuilder_1 = require("./ComponentBuilder");
96
- Object.defineProperty(exports, "ComponentBuilder", { enumerable: true, get: function () { return ComponentBuilder_1.ComponentBuilder; } });
97
95
  var react_1 = require("@sitecore-content-sdk/react");
98
96
  Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return react_1.Image; } });
99
97
  Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return react_1.Text; } });
@@ -18,12 +18,9 @@ class ComponentPropsService {
18
18
  fetchComponentProps(params) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  var _a, _b;
21
- const { layoutData, context, moduleFactory } = params;
21
+ const { layoutData, context, components } = params;
22
22
  if (this.isServerSidePropsContext(context)) {
23
- const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () {
24
- const module = yield moduleFactory(componentName);
25
- return module === null || module === void 0 ? void 0 : module.getServerSideProps;
26
- });
23
+ const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = (yield this.getModule(components, componentName))) === null || _a === void 0 ? void 0 : _a.getServerSideProps; });
27
24
  const requests = yield this.collectRequests({
28
25
  placeholders: (_a = layoutData.sitecore.route) === null || _a === void 0 ? void 0 : _a.placeholders,
29
26
  fetchFunctionFactory,
@@ -33,10 +30,7 @@ class ComponentPropsService {
33
30
  return yield this.execRequests(requests);
34
31
  }
35
32
  else {
36
- const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () {
37
- const module = yield moduleFactory(componentName);
38
- return module === null || module === void 0 ? void 0 : module.getStaticProps;
39
- });
33
+ const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = (yield this.getModule(components, componentName))) === null || _a === void 0 ? void 0 : _a.getStaticProps; });
40
34
  const requests = yield this.collectRequests({
41
35
  placeholders: (_b = layoutData.sitecore.route) === null || _b === void 0 ? void 0 : _b.placeholders,
42
36
  fetchFunctionFactory,
@@ -150,5 +144,15 @@ class ComponentPropsService {
150
144
  isServerSidePropsContext(context) {
151
145
  return context.req !== undefined;
152
146
  }
147
+ getModule(components, componentName) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ var _a;
150
+ const component = components.get(componentName);
151
+ if (!component)
152
+ return null;
153
+ const module = component.dynamicModule ? yield ((_a = component === null || component === void 0 ? void 0 : component.dynamicModule) === null || _a === void 0 ? void 0 : _a.call(component)) : component;
154
+ return module;
155
+ });
156
+ }
153
157
  }
154
158
  exports.ComponentPropsService = ComponentPropsService;
@@ -1,18 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
3
  exports.ModuleType = exports.generatePlugins = exports.getComponentList = exports.generateMetadata = exports.generateSites = void 0;
18
4
  var tools_1 = require("@sitecore-content-sdk/core/tools");
@@ -21,4 +7,3 @@ Object.defineProperty(exports, "generateMetadata", { enumerable: true, get: func
21
7
  Object.defineProperty(exports, "getComponentList", { enumerable: true, get: function () { return tools_1.getComponentList; } });
22
8
  Object.defineProperty(exports, "generatePlugins", { enumerable: true, get: function () { return tools_1.generatePlugins; } });
23
9
  Object.defineProperty(exports, "ModuleType", { enumerable: true, get: function () { return tools_1.ModuleType; } });
24
- __exportStar(require("./templating"), exports);
@@ -67,14 +67,14 @@ export class SitecoreNextjsClient extends SitecoreClient {
67
67
  });
68
68
  }
69
69
  /**
70
- * Parses components from nextjs component factory and layoutData, executes getServerProps/getStaticProps methods
70
+ * Parses components from nextjs component map and layoutData, executes getServerProps/getStaticProps methods
71
71
  * and returns resulting props from components
72
72
  * @param {LayoutServiceData} layoutData layout data to parse compnents from
73
73
  * @param {PreviewData} context Nextjs preview data
74
- * @param {ModuleFactory} moduleFactory module factory to use for component parsing
74
+ * @param {ComponentMap<NextjsJssComponent>} components component map to get props for
75
75
  * @returns {ComponentPropsCollection} component props
76
76
  */
77
- getComponentData(layoutData, context, moduleFactory) {
77
+ getComponentData(layoutData, context, components) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
79
  let componentProps = {};
80
80
  if (!layoutData.sitecore.route)
@@ -83,7 +83,7 @@ export class SitecoreNextjsClient extends SitecoreClient {
83
83
  componentProps = yield this.componentPropsService.fetchComponentProps({
84
84
  layoutData: layoutData,
85
85
  context,
86
- moduleFactory,
86
+ components,
87
87
  });
88
88
  const errors = Object.keys(componentProps)
89
89
  .map((id) => {
@@ -38,9 +38,7 @@ export class EditingConfigMiddleware {
38
38
  // CORS headers are set by enforceCors
39
39
  return res.status(204).send(null);
40
40
  }
41
- const components = Array.isArray(this.config.components)
42
- ? this.config.components
43
- : Array.from(this.config.components.keys());
41
+ const components = Array.from(this.config.components.keys());
44
42
  return res.status(200).json({
45
43
  components,
46
44
  packages: this.config.metadata.packages,
package/dist/esm/index.js CHANGED
@@ -18,5 +18,4 @@ import * as FEaaSWrapper from './components/FEaaSWrapper';
18
18
  import * as BYOCWrapper from './components/BYOCWrapper';
19
19
  export { FEaaSWrapper };
20
20
  export { BYOCWrapper };
21
- export { ComponentBuilder } from './ComponentBuilder';
22
21
  export { Image, Text, DateField, FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, getDesignLibraryStylesheetLinks, File, DesignLibrary, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, Form, } from '@sitecore-content-sdk/react';
@@ -12,12 +12,9 @@ export class ComponentPropsService {
12
12
  fetchComponentProps(params) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  var _a, _b;
15
- const { layoutData, context, moduleFactory } = params;
15
+ const { layoutData, context, components } = params;
16
16
  if (this.isServerSidePropsContext(context)) {
17
- const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () {
18
- const module = yield moduleFactory(componentName);
19
- return module === null || module === void 0 ? void 0 : module.getServerSideProps;
20
- });
17
+ const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = (yield this.getModule(components, componentName))) === null || _a === void 0 ? void 0 : _a.getServerSideProps; });
21
18
  const requests = yield this.collectRequests({
22
19
  placeholders: (_a = layoutData.sitecore.route) === null || _a === void 0 ? void 0 : _a.placeholders,
23
20
  fetchFunctionFactory,
@@ -27,10 +24,7 @@ export class ComponentPropsService {
27
24
  return yield this.execRequests(requests);
28
25
  }
29
26
  else {
30
- const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () {
31
- const module = yield moduleFactory(componentName);
32
- return module === null || module === void 0 ? void 0 : module.getStaticProps;
33
- });
27
+ const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = (yield this.getModule(components, componentName))) === null || _a === void 0 ? void 0 : _a.getStaticProps; });
34
28
  const requests = yield this.collectRequests({
35
29
  placeholders: (_b = layoutData.sitecore.route) === null || _b === void 0 ? void 0 : _b.placeholders,
36
30
  fetchFunctionFactory,
@@ -144,4 +138,14 @@ export class ComponentPropsService {
144
138
  isServerSidePropsContext(context) {
145
139
  return context.req !== undefined;
146
140
  }
141
+ getModule(components, componentName) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ var _a;
144
+ const component = components.get(componentName);
145
+ if (!component)
146
+ return null;
147
+ const module = component.dynamicModule ? yield ((_a = component === null || component === void 0 ? void 0 : component.dynamicModule) === null || _a === void 0 ? void 0 : _a.call(component)) : component;
148
+ return module;
149
+ });
150
+ }
147
151
  }
@@ -1,2 +1 @@
1
1
  export { generateSites, generateMetadata, getComponentList, generatePlugins, ModuleType, } from '@sitecore-content-sdk/core/tools';
2
- export * from './templating';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/nextjs",
3
- "version": "0.1.0-beta.34",
3
+ "version": "0.1.0-beta.35",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -75,8 +75,8 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@babel/parser": "^7.26.10",
78
- "@sitecore-content-sdk/core": "0.1.0-beta.34",
79
- "@sitecore-content-sdk/react": "0.1.0-beta.34",
78
+ "@sitecore-content-sdk/core": "0.1.0-beta.35",
79
+ "@sitecore-content-sdk/react": "0.1.0-beta.35",
80
80
  "@vercel/kv": "^3.0.0",
81
81
  "prop-types": "^15.8.1",
82
82
  "recast": "^0.23.11",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "description": "",
87
87
  "types": "types/index.d.ts",
88
- "gitHead": "671c575e11cd9e99e816b02b6ebd4620d2476304",
88
+ "gitHead": "160a0bdb91edbe88e3382e0ee1503203024c09b0",
89
89
  "files": [
90
90
  "dist",
91
91
  "types",
@@ -1,10 +1,10 @@
1
1
  import { FetchOptions, Page, PageOptions, SitecoreClient, SitecoreClientInit } from '@sitecore-content-sdk/core/client';
2
- import { ComponentPropsCollection } from '../sharedTypes/component-props';
2
+ import { ComponentPropsCollection, NextjsJssComponent } from '../sharedTypes/component-props';
3
3
  import { GetServerSidePropsContext, GetStaticPropsContext, PreviewData } from 'next';
4
4
  import { LayoutServiceData } from '@sitecore-content-sdk/core/layout';
5
5
  import { ComponentPropsService } from '../services/component-props-service';
6
- import { ModuleFactory } from '../sharedTypes/module-factory';
7
6
  import { SiteInfo } from '../site';
7
+ import { ComponentMap } from '@sitecore-content-sdk/react';
8
8
  export type NextjsPage = Page & {
9
9
  componentProps?: ComponentPropsCollection;
10
10
  notFound?: boolean;
@@ -28,13 +28,13 @@ export declare class SitecoreNextjsClient extends SitecoreClient {
28
28
  */
29
29
  getPreview(previewData: PreviewData, fetchOptions?: FetchOptions): Promise<NextjsPage | null>;
30
30
  /**
31
- * Parses components from nextjs component factory and layoutData, executes getServerProps/getStaticProps methods
31
+ * Parses components from nextjs component map and layoutData, executes getServerProps/getStaticProps methods
32
32
  * and returns resulting props from components
33
33
  * @param {LayoutServiceData} layoutData layout data to parse compnents from
34
34
  * @param {PreviewData} context Nextjs preview data
35
- * @param {ModuleFactory} moduleFactory module factory to use for component parsing
35
+ * @param {ComponentMap<NextjsJssComponent>} components component map to get props for
36
36
  * @returns {ComponentPropsCollection} component props
37
37
  */
38
- getComponentData(layoutData: LayoutServiceData, context: GetServerSidePropsContext | GetStaticPropsContext, moduleFactory: ModuleFactory): Promise<ComponentPropsCollection>;
38
+ getComponentData(layoutData: LayoutServiceData, context: GetServerSidePropsContext | GetStaticPropsContext, components: ComponentMap<NextjsJssComponent>): Promise<ComponentPropsCollection>;
39
39
  protected getComponentPropsService(): ComponentPropsService;
40
40
  }
@@ -1,10 +1,12 @@
1
1
  import { NextApiRequest, NextApiResponse } from 'next';
2
2
  import { Metadata } from '@sitecore-content-sdk/core/editing';
3
+ import { ComponentMap } from '@sitecore-content-sdk/react';
4
+ import { NextjsJssComponent } from '../sharedTypes/component-props';
3
5
  export type EditingConfigMiddlewareConfig = {
4
6
  /**
5
7
  * Components available in the application
6
8
  */
7
- components: string[] | Map<string, unknown>;
9
+ components: ComponentMap<NextjsJssComponent>;
8
10
  /**
9
11
  * Application metadata
10
12
  */
package/types/index.d.ts CHANGED
@@ -5,9 +5,8 @@ export { RestComponentLayoutService } from '@sitecore-content-sdk/core/editing';
5
5
  export { mediaApi } from '@sitecore-content-sdk/core/media';
6
6
  export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, } from '@sitecore-content-sdk/core/i18n';
7
7
  export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, getGroomedVariantIds, normalizePersonalizedRewrite, CdpHelper, } from '@sitecore-content-sdk/core/personalize';
8
- export { ComponentPropsCollection, ComponentPropsError, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
8
+ export { ComponentPropsCollection, ComponentPropsError, GetStaticComponentProps, GetServerSideComponentProps, NextjsJssComponent, } from './sharedTypes/component-props';
9
9
  export { SitecorePageProps } from './sharedTypes/sitecore-page-props';
10
- export { ModuleFactory, Module } from './sharedTypes/module-factory';
11
10
  export { ComponentPropsService } from './services/component-props-service';
12
11
  export { GraphQLSitePathService, GraphQLSitePathServiceConfig, } from '@sitecore-content-sdk/core/site';
13
12
  export { StaticPath } from '@sitecore-content-sdk/core';
@@ -21,5 +20,4 @@ import * as FEaaSWrapper from './components/FEaaSWrapper';
21
20
  import * as BYOCWrapper from './components/BYOCWrapper';
22
21
  export { FEaaSWrapper };
23
22
  export { BYOCWrapper };
24
- export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
25
- export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getDesignLibraryStylesheetLinks, File, FileField, RichTextField, DesignLibrary, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, WithSitecoreContextOptions, WithSitecoreContextProps, WithSitecoreContextHocProps, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, Form, } from '@sitecore-content-sdk/react';
23
+ export { ComponentMap, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getDesignLibraryStylesheetLinks, File, FileField, RichTextField, DesignLibrary, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, WithSitecoreContextOptions, WithSitecoreContextProps, WithSitecoreContextHocProps, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, Form, } from '@sitecore-content-sdk/react';
@@ -1,11 +1,11 @@
1
1
  import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
2
2
  import { LayoutServiceData, ComponentRendering, PlaceholdersData } from '@sitecore-content-sdk/core/layout';
3
- import { ComponentPropsCollection, ComponentPropsFetchFunction } from '../sharedTypes/component-props';
4
- import { ModuleFactory } from '../sharedTypes/module-factory';
3
+ import { ComponentPropsCollection, ComponentPropsFetchFunction, NextjsJssComponent } from '../sharedTypes/component-props';
4
+ import { ComponentMap } from '@sitecore-content-sdk/react';
5
5
  export type FetchComponentPropsArguments<NextContext> = {
6
6
  layoutData: LayoutServiceData;
7
7
  context: NextContext;
8
- moduleFactory: ModuleFactory;
8
+ components: ComponentMap<NextjsJssComponent>;
9
9
  };
10
10
  export type ComponentPropsRequest<NextContext> = {
11
11
  fetch: ComponentPropsFetchFunction<NextContext>;
@@ -60,5 +60,6 @@ export declare class ComponentPropsService {
60
60
  * @param {GetServerSidePropsContext | GetStaticPropsContext} context
61
61
  */
62
62
  private isServerSidePropsContext;
63
+ private getModule;
63
64
  }
64
65
  export {};
@@ -1,5 +1,6 @@
1
1
  import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
2
2
  import { ComponentRendering, LayoutServiceData } from '@sitecore-content-sdk/core/layout';
3
+ import { ReactJssComponent } from '@sitecore-content-sdk/react';
3
4
  export type ComponentPropsError = {
4
5
  error: string;
5
6
  componentName: string;
@@ -24,3 +25,20 @@ export type GetServerSideComponentProps = ComponentPropsFetchFunction<GetServerS
24
25
  * Shape of getStaticProps function on component level
25
26
  */
26
27
  export type GetStaticComponentProps = ComponentPropsFetchFunction<GetStaticPropsContext>;
28
+ /**
29
+ * Represents a nextjs component import
30
+ */
31
+ export type NextjsJssComponent = ReactJssComponent & {
32
+ /**
33
+ * function for component level data fetching in SSR mode
34
+ */
35
+ getServerSideProps?: GetServerSideComponentProps;
36
+ /**
37
+ * function for component level data fetching in SSG mode
38
+ */
39
+ getStaticProps?: GetStaticComponentProps;
40
+ /**
41
+ * Optional dynamic import for lazy components - allows component props retrieval
42
+ */
43
+ dynamicModule?: () => Promise<ReactJssComponent>;
44
+ };
@@ -1,2 +1 @@
1
1
  export { generateSites, GenerateSitesConfig, generateMetadata, ComponentFile, PackageDefinition, getComponentList, PluginDefinition, generatePlugins, ModuleType, } from '@sitecore-content-sdk/core/tools';
2
- export * from './templating';
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComponentBuilder = void 0;
4
- /**
5
- * Nextjs implementation of component builder class for building components based on the configuration.
6
- */
7
- class ComponentBuilder {
8
- constructor(config) {
9
- this.config = config;
10
- /**
11
- * SXA uses custom default export name
12
- */
13
- this.DEFAULT_EXPORT_NAME = 'Default';
14
- this.components = new Map([...config.components]);
15
- }
16
- /**
17
- * Creates a new instance of module factory
18
- * Module factory provides a module (file) including all exports.
19
- * Module can be imported dynamically or statically.
20
- * @returns {ModuleFactory} Module factory implementation
21
- */
22
- getModuleFactory() {
23
- return (componentName) => {
24
- const component = this.components.get(componentName);
25
- if (!component)
26
- return null;
27
- // check if module should be imported dynamically
28
- if (component.module) {
29
- return component.module();
30
- }
31
- return component;
32
- };
33
- }
34
- /**
35
- * Creates a new instance of component factory
36
- * Component can be imported dynamically or statically.
37
- * @param {object} [config] Component factory configuration
38
- * @param {boolean} [config.isEditing] Indicates if component factory is used in editing mode
39
- * @returns {ComponentFactory} Component factory implementation
40
- */
41
- getComponentFactory({ isEditing } = {}) {
42
- return (componentName, exportName) => {
43
- const component = this.components.get(componentName);
44
- if (!component)
45
- return null;
46
- // check if component should be imported dynamically
47
- if (component.element) {
48
- // Editing mode doesn't work well with dynamic components in nextjs: dynamic components are not displayed without refresh after a rendering is added.
49
- // This happens beacuse Sitecore editors simply insert updated HTML generated on server side. This conflicts with nextjs dynamic logic as no HTML gets rendered for dynamic component
50
- // So we use require() to obtain dynamic components in editing mode while preserving dynamic logic for non-editing scenarios
51
- // As we need to be able to seamlessly work with dynamic components in both editing and normal modes, different componentFactory functions will be passed to app
52
- return component.element(isEditing);
53
- }
54
- if (exportName && exportName !== this.DEFAULT_EXPORT_NAME) {
55
- return component[exportName];
56
- }
57
- return (component.Default ||
58
- component.default ||
59
- component);
60
- };
61
- }
62
- }
63
- exports.ComponentBuilder = ComponentBuilder;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,71 +0,0 @@
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.generateComponentBuilder = generateComponentBuilder;
7
- exports.watchComponentBuilder = watchComponentBuilder;
8
- exports.writeComponentBuilder = writeComponentBuilder;
9
- const path_1 = __importDefault(require("path"));
10
- const fs_1 = __importDefault(require("fs"));
11
- const component_builder_1 = require("./templates/component-builder");
12
- const tools_1 = require("@sitecore-content-sdk/core/tools");
13
- const utils_1 = require("./utils");
14
- // Default destination path for component builder
15
- const defaultComponentBuilderOutputPath = 'src/temp/componentBuilder.ts';
16
- const defaultComponentRootPath = 'src/components';
17
- /**
18
- * Generate component builder based on provided settings
19
- * @param {object} [settings] settings for component builder generation
20
- * @param {string} [settings.componentRootPath] path to components root
21
- * @param {string} [settings.componentBuilderOutputPath] path to component builder output
22
- * @param {PackageDefinition[]} [settings.packages] list of packages to include in component builder
23
- * @param {ComponentFile[]} [settings.components] list of components to include in component builder
24
- * @param {boolean} [settings.watch] whether to watch for changes to component builder sources
25
- */
26
- function generateComponentBuilder({ componentRootPath = defaultComponentRootPath, componentBuilderOutputPath = defaultComponentBuilderOutputPath, packages = [], components = [], watch, } = {}) {
27
- if (watch) {
28
- watchComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components });
29
- }
30
- else {
31
- writeComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components });
32
- }
33
- }
34
- /**
35
- * Watch for changes to component builder sources
36
- * @param {object} settings settings for component builder generation
37
- * @param {string} settings.componentRootPath path to components root
38
- * @param {string} settings.componentBuilderOutputPath path to component builder output
39
- * @param {PackageDefinition[]} settings.packages list of packages to include in component builder
40
- * @param {ComponentFile[]} settings.components list of components to include in component builder
41
- */
42
- function watchComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components, }) {
43
- console.log(`Watching for changes to component builder sources in ${componentRootPath}...`);
44
- (0, utils_1.watchItems)([componentRootPath], writeComponentBuilder.bind(null, {
45
- componentRootPath,
46
- componentBuilderOutputPath,
47
- packages,
48
- components,
49
- }));
50
- }
51
- /**
52
- * Write component builder to file
53
- * @param {object} settings settings for component builder generation
54
- * @param {string} settings.componentRootPath path to components root
55
- * @param {string} settings.componentBuilderOutputPath path to component builder output
56
- * @param {PackageDefinition[]} settings.packages list of packages to include in component builder
57
- * @param {ComponentFile[]} settings.components list of components to include in component builder
58
- */
59
- function writeComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components, }) {
60
- const items = [
61
- ...packages,
62
- ...components,
63
- ...(0, tools_1.getComponentList)(componentRootPath),
64
- ];
65
- const componentBuilderPath = path_1.default.resolve(componentBuilderOutputPath);
66
- const fileContent = (0, component_builder_1.getComponentBuilderTemplate)(items);
67
- console.log(`Writing component builder to ${componentBuilderPath}`);
68
- fs_1.default.writeFileSync(componentBuilderPath, fileContent, {
69
- encoding: 'utf8',
70
- });
71
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComponentBuilderTemplate = exports.generateComponentBuilder = void 0;
4
- var generate_component_builder_1 = require("./generate-component-builder");
5
- Object.defineProperty(exports, "generateComponentBuilder", { enumerable: true, get: function () { return generate_component_builder_1.generateComponentBuilder; } });
6
- var component_builder_1 = require("./templates/component-builder");
7
- Object.defineProperty(exports, "getComponentBuilderTemplate", { enumerable: true, get: function () { return component_builder_1.getComponentBuilderTemplate; } });
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComponentBuilderTemplate = void 0;
4
- const isLazyLoadingModule = (componentPath) => componentPath.includes('.dynamic');
5
- const removeDynamicModuleNameEnding = (moduleName) => moduleName.replace(/\.?dynamic$/i, '');
6
- /**
7
- * Generate component builder template
8
- * @param {(PackageDefinition | ComponentFile)[]} components components to include in component builder
9
- * @returns generated component builder template
10
- */
11
- const getComponentBuilderTemplate = (components) => {
12
- const componentFiles = components.filter((component) => component.componentName);
13
- const packages = components.filter((component) => component.components);
14
- const hasLazyModules = componentFiles.find((component) => isLazyLoadingModule(component.path));
15
- return `/* eslint-disable */
16
- // Do not edit this file, it is auto-generated at build time!
17
- // See scripts/generate-component-builder/index.ts to modify the generation of this file.
18
-
19
- ${hasLazyModules ? "import dynamic from 'next/dynamic';" : ''}
20
- import { ComponentBuilder } from '@sitecore-content-sdk/nextjs';
21
-
22
- ${packages
23
- .map((pkg) => {
24
- const list = pkg.components.map((c) => c.moduleName).join(', ');
25
- return `import { ${list} } from '${pkg.name}';\n`;
26
- })
27
- .join('')}
28
- ${componentFiles
29
- .map((component) => {
30
- if (isLazyLoadingModule(component.path)) {
31
- const moduleName = removeDynamicModuleNameEnding(component.moduleName);
32
- return `const ${moduleName} = {
33
- module: () => import('${component.path}'),
34
- element: (isEditing?: boolean) => isEditing ? require('${component.path}')?.default : dynamic(${moduleName}.module)
35
- }`;
36
- }
37
- return `import * as ${component.moduleName} from '${component.path}';`;
38
- })
39
- .join('\n')}
40
-
41
- export const components = new Map();
42
- ${packages
43
- .map((p) => p.components.map((component) => `components.set('${component.componentName}', ${component.moduleName});\n`))
44
- .flat()
45
- .join('')}
46
- ${componentFiles
47
- .map((component) => `components.set('${isLazyLoadingModule(component.path)
48
- ? removeDynamicModuleNameEnding(component.componentName)
49
- : component.componentName}', ${isLazyLoadingModule(component.path)
50
- ? removeDynamicModuleNameEnding(component.moduleName)
51
- : component.moduleName});`)
52
- .join('\n')}
53
-
54
- export const componentBuilder = new ComponentBuilder({ components });
55
-
56
- export const moduleFactory = componentBuilder.getModuleFactory();
57
- `;
58
- };
59
- exports.getComponentBuilderTemplate = getComponentBuilderTemplate;
@@ -1,59 +0,0 @@
1
- /**
2
- * Nextjs implementation of component builder class for building components based on the configuration.
3
- */
4
- export class ComponentBuilder {
5
- constructor(config) {
6
- this.config = config;
7
- /**
8
- * SXA uses custom default export name
9
- */
10
- this.DEFAULT_EXPORT_NAME = 'Default';
11
- this.components = new Map([...config.components]);
12
- }
13
- /**
14
- * Creates a new instance of module factory
15
- * Module factory provides a module (file) including all exports.
16
- * Module can be imported dynamically or statically.
17
- * @returns {ModuleFactory} Module factory implementation
18
- */
19
- getModuleFactory() {
20
- return (componentName) => {
21
- const component = this.components.get(componentName);
22
- if (!component)
23
- return null;
24
- // check if module should be imported dynamically
25
- if (component.module) {
26
- return component.module();
27
- }
28
- return component;
29
- };
30
- }
31
- /**
32
- * Creates a new instance of component factory
33
- * Component can be imported dynamically or statically.
34
- * @param {object} [config] Component factory configuration
35
- * @param {boolean} [config.isEditing] Indicates if component factory is used in editing mode
36
- * @returns {ComponentFactory} Component factory implementation
37
- */
38
- getComponentFactory({ isEditing } = {}) {
39
- return (componentName, exportName) => {
40
- const component = this.components.get(componentName);
41
- if (!component)
42
- return null;
43
- // check if component should be imported dynamically
44
- if (component.element) {
45
- // Editing mode doesn't work well with dynamic components in nextjs: dynamic components are not displayed without refresh after a rendering is added.
46
- // This happens beacuse Sitecore editors simply insert updated HTML generated on server side. This conflicts with nextjs dynamic logic as no HTML gets rendered for dynamic component
47
- // So we use require() to obtain dynamic components in editing mode while preserving dynamic logic for non-editing scenarios
48
- // As we need to be able to seamlessly work with dynamic components in both editing and normal modes, different componentFactory functions will be passed to app
49
- return component.element(isEditing);
50
- }
51
- if (exportName && exportName !== this.DEFAULT_EXPORT_NAME) {
52
- return component[exportName];
53
- }
54
- return (component.Default ||
55
- component.default ||
56
- component);
57
- };
58
- }
59
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,63 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs';
3
- import { getComponentBuilderTemplate } from './templates/component-builder';
4
- import { getComponentList, } from '@sitecore-content-sdk/core/tools';
5
- import { watchItems } from './utils';
6
- // Default destination path for component builder
7
- const defaultComponentBuilderOutputPath = 'src/temp/componentBuilder.ts';
8
- const defaultComponentRootPath = 'src/components';
9
- /**
10
- * Generate component builder based on provided settings
11
- * @param {object} [settings] settings for component builder generation
12
- * @param {string} [settings.componentRootPath] path to components root
13
- * @param {string} [settings.componentBuilderOutputPath] path to component builder output
14
- * @param {PackageDefinition[]} [settings.packages] list of packages to include in component builder
15
- * @param {ComponentFile[]} [settings.components] list of components to include in component builder
16
- * @param {boolean} [settings.watch] whether to watch for changes to component builder sources
17
- */
18
- export function generateComponentBuilder({ componentRootPath = defaultComponentRootPath, componentBuilderOutputPath = defaultComponentBuilderOutputPath, packages = [], components = [], watch, } = {}) {
19
- if (watch) {
20
- watchComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components });
21
- }
22
- else {
23
- writeComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components });
24
- }
25
- }
26
- /**
27
- * Watch for changes to component builder sources
28
- * @param {object} settings settings for component builder generation
29
- * @param {string} settings.componentRootPath path to components root
30
- * @param {string} settings.componentBuilderOutputPath path to component builder output
31
- * @param {PackageDefinition[]} settings.packages list of packages to include in component builder
32
- * @param {ComponentFile[]} settings.components list of components to include in component builder
33
- */
34
- export function watchComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components, }) {
35
- console.log(`Watching for changes to component builder sources in ${componentRootPath}...`);
36
- watchItems([componentRootPath], writeComponentBuilder.bind(null, {
37
- componentRootPath,
38
- componentBuilderOutputPath,
39
- packages,
40
- components,
41
- }));
42
- }
43
- /**
44
- * Write component builder to file
45
- * @param {object} settings settings for component builder generation
46
- * @param {string} settings.componentRootPath path to components root
47
- * @param {string} settings.componentBuilderOutputPath path to component builder output
48
- * @param {PackageDefinition[]} settings.packages list of packages to include in component builder
49
- * @param {ComponentFile[]} settings.components list of components to include in component builder
50
- */
51
- export function writeComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components, }) {
52
- const items = [
53
- ...packages,
54
- ...components,
55
- ...getComponentList(componentRootPath),
56
- ];
57
- const componentBuilderPath = path.resolve(componentBuilderOutputPath);
58
- const fileContent = getComponentBuilderTemplate(items);
59
- console.log(`Writing component builder to ${componentBuilderPath}`);
60
- fs.writeFileSync(componentBuilderPath, fileContent, {
61
- encoding: 'utf8',
62
- });
63
- }
@@ -1,2 +0,0 @@
1
- export { generateComponentBuilder } from './generate-component-builder';
2
- export { getComponentBuilderTemplate } from './templates/component-builder';
@@ -1,55 +0,0 @@
1
- const isLazyLoadingModule = (componentPath) => componentPath.includes('.dynamic');
2
- const removeDynamicModuleNameEnding = (moduleName) => moduleName.replace(/\.?dynamic$/i, '');
3
- /**
4
- * Generate component builder template
5
- * @param {(PackageDefinition | ComponentFile)[]} components components to include in component builder
6
- * @returns generated component builder template
7
- */
8
- export const getComponentBuilderTemplate = (components) => {
9
- const componentFiles = components.filter((component) => component.componentName);
10
- const packages = components.filter((component) => component.components);
11
- const hasLazyModules = componentFiles.find((component) => isLazyLoadingModule(component.path));
12
- return `/* eslint-disable */
13
- // Do not edit this file, it is auto-generated at build time!
14
- // See scripts/generate-component-builder/index.ts to modify the generation of this file.
15
-
16
- ${hasLazyModules ? "import dynamic from 'next/dynamic';" : ''}
17
- import { ComponentBuilder } from '@sitecore-content-sdk/nextjs';
18
-
19
- ${packages
20
- .map((pkg) => {
21
- const list = pkg.components.map((c) => c.moduleName).join(', ');
22
- return `import { ${list} } from '${pkg.name}';\n`;
23
- })
24
- .join('')}
25
- ${componentFiles
26
- .map((component) => {
27
- if (isLazyLoadingModule(component.path)) {
28
- const moduleName = removeDynamicModuleNameEnding(component.moduleName);
29
- return `const ${moduleName} = {
30
- module: () => import('${component.path}'),
31
- element: (isEditing?: boolean) => isEditing ? require('${component.path}')?.default : dynamic(${moduleName}.module)
32
- }`;
33
- }
34
- return `import * as ${component.moduleName} from '${component.path}';`;
35
- })
36
- .join('\n')}
37
-
38
- export const components = new Map();
39
- ${packages
40
- .map((p) => p.components.map((component) => `components.set('${component.componentName}', ${component.moduleName});\n`))
41
- .flat()
42
- .join('')}
43
- ${componentFiles
44
- .map((component) => `components.set('${isLazyLoadingModule(component.path)
45
- ? removeDynamicModuleNameEnding(component.componentName)
46
- : component.componentName}', ${isLazyLoadingModule(component.path)
47
- ? removeDynamicModuleNameEnding(component.moduleName)
48
- : component.moduleName});`)
49
- .join('\n')}
50
-
51
- export const componentBuilder = new ComponentBuilder({ components });
52
-
53
- export const moduleFactory = componentBuilder.getModuleFactory();
54
- `;
55
- };
@@ -1,59 +0,0 @@
1
- import { ComponentFactory, JssComponentType } from '@sitecore-content-sdk/react';
2
- import { Module, ModuleFactory } from './sharedTypes/module-factory';
3
- /**
4
- * Represents a component that can be imported dynamically
5
- */
6
- export type LazyModule = {
7
- module: () => Promise<Module>;
8
- element: (isEditing?: boolean) => JssComponentType;
9
- };
10
- /**
11
- * Component is a module or a lazy module
12
- */
13
- type Component = Module | LazyModule | JssComponentType;
14
- /**
15
- * Configuration for ComponentBuilder
16
- */
17
- export type ComponentBuilderConfig<Component> = {
18
- /**
19
- * List of components to be stored
20
- */
21
- components: Map<string, Component>;
22
- };
23
- /**
24
- * Configuration for ComponentFactory
25
- */
26
- type ComponentFactoryConfig = {
27
- isEditing?: boolean;
28
- };
29
- /**
30
- * Nextjs implementation of component builder class for building components based on the configuration.
31
- */
32
- export declare class ComponentBuilder {
33
- protected config: ComponentBuilderConfig<Component>;
34
- /**
35
- * List of components to be stored
36
- */
37
- protected components: Map<string, Component>;
38
- /**
39
- * SXA uses custom default export name
40
- */
41
- protected DEFAULT_EXPORT_NAME: string;
42
- constructor(config: ComponentBuilderConfig<Component>);
43
- /**
44
- * Creates a new instance of module factory
45
- * Module factory provides a module (file) including all exports.
46
- * Module can be imported dynamically or statically.
47
- * @returns {ModuleFactory} Module factory implementation
48
- */
49
- getModuleFactory(): ModuleFactory;
50
- /**
51
- * Creates a new instance of component factory
52
- * Component can be imported dynamically or statically.
53
- * @param {object} [config] Component factory configuration
54
- * @param {boolean} [config.isEditing] Indicates if component factory is used in editing mode
55
- * @returns {ComponentFactory} Component factory implementation
56
- */
57
- getComponentFactory({ isEditing }?: ComponentFactoryConfig): ComponentFactory;
58
- }
59
- export {};
@@ -1,32 +0,0 @@
1
- import { ComponentType } from 'react';
2
- import { GetServerSideComponentProps, GetStaticComponentProps } from './component-props';
3
- /**
4
- * Represents a module (file)
5
- */
6
- export type Module = {
7
- /**
8
- * Default SXA export
9
- */
10
- Default?: ComponentType;
11
- /**
12
- * Default Next.js export
13
- */
14
- default?: ComponentType;
15
- /**
16
- * function for component level data fetching in SSR mode
17
- */
18
- getServerSideProps?: GetServerSideComponentProps;
19
- /**
20
- * function for component level data fetching in SSG mode
21
- */
22
- getStaticProps?: GetStaticComponentProps;
23
- } & {
24
- /**
25
- * Custom exports
26
- */
27
- [key: string]: ComponentType;
28
- };
29
- /**
30
- * Represents a module factory
31
- */
32
- export type ModuleFactory = (componentName: string) => Module | Promise<Module> | null;
@@ -1,45 +0,0 @@
1
- import { ComponentFile, PackageDefinition } from '@sitecore-content-sdk/core/tools';
2
- /**
3
- * Generate component builder based on provided settings
4
- * @param {object} [settings] settings for component builder generation
5
- * @param {string} [settings.componentRootPath] path to components root
6
- * @param {string} [settings.componentBuilderOutputPath] path to component builder output
7
- * @param {PackageDefinition[]} [settings.packages] list of packages to include in component builder
8
- * @param {ComponentFile[]} [settings.components] list of components to include in component builder
9
- * @param {boolean} [settings.watch] whether to watch for changes to component builder sources
10
- */
11
- export declare function generateComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components, watch, }?: {
12
- componentRootPath?: string;
13
- componentBuilderOutputPath?: string;
14
- packages?: PackageDefinition[];
15
- components?: ComponentFile[];
16
- watch?: boolean;
17
- }): void;
18
- /**
19
- * Watch for changes to component builder sources
20
- * @param {object} settings settings for component builder generation
21
- * @param {string} settings.componentRootPath path to components root
22
- * @param {string} settings.componentBuilderOutputPath path to component builder output
23
- * @param {PackageDefinition[]} settings.packages list of packages to include in component builder
24
- * @param {ComponentFile[]} settings.components list of components to include in component builder
25
- */
26
- export declare function watchComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components, }: {
27
- componentRootPath: string;
28
- componentBuilderOutputPath: string;
29
- packages: PackageDefinition[];
30
- components: ComponentFile[];
31
- }): void;
32
- /**
33
- * Write component builder to file
34
- * @param {object} settings settings for component builder generation
35
- * @param {string} settings.componentRootPath path to components root
36
- * @param {string} settings.componentBuilderOutputPath path to component builder output
37
- * @param {PackageDefinition[]} settings.packages list of packages to include in component builder
38
- * @param {ComponentFile[]} settings.components list of components to include in component builder
39
- */
40
- export declare function writeComponentBuilder({ componentRootPath, componentBuilderOutputPath, packages, components, }: {
41
- componentRootPath: string;
42
- componentBuilderOutputPath: string;
43
- packages: PackageDefinition[];
44
- components: ComponentFile[];
45
- }): void;
@@ -1,2 +0,0 @@
1
- export { generateComponentBuilder } from './generate-component-builder';
2
- export { getComponentBuilderTemplate } from './templates/component-builder';
@@ -1,7 +0,0 @@
1
- import { ComponentFile, PackageDefinition } from '@sitecore-content-sdk/core/tools';
2
- /**
3
- * Generate component builder template
4
- * @param {(PackageDefinition | ComponentFile)[]} components components to include in component builder
5
- * @returns generated component builder template
6
- */
7
- export declare const getComponentBuilderTemplate: (components: (PackageDefinition | ComponentFile)[]) => string;