@sitecore-jss/sitecore-jss-nextjs 22.0.0-canary.9 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -202
- package/README.md +12 -10
- package/context.d.ts +1 -0
- package/context.js +1 -0
- package/dist/cjs/ComponentBuilder.js +63 -0
- package/dist/cjs/components/BYOCWrapper.js +47 -0
- package/dist/cjs/components/FEaaSWrapper.js +49 -0
- package/dist/cjs/components/Link.js +5 -4
- package/dist/cjs/components/NextImage.js +3 -14
- package/dist/cjs/components/RichText.js +11 -15
- package/dist/cjs/context/context.js +83 -0
- package/dist/cjs/context/index.js +5 -0
- package/dist/cjs/editing/constants.js +6 -0
- package/dist/cjs/editing/editing-config-middleware.js +49 -0
- package/dist/cjs/editing/editing-data-middleware.js +3 -3
- package/dist/cjs/editing/editing-data-service.js +16 -8
- package/dist/cjs/editing/editing-render-middleware.js +25 -11
- package/dist/cjs/editing/feaas-render-middleware.js +87 -0
- package/dist/cjs/editing/index.js +7 -1
- package/dist/cjs/editing/render-middleware.js +27 -0
- package/dist/cjs/editing/vercel-editing-data-cache.js +48 -0
- package/dist/cjs/graphql/index.js +7 -0
- package/dist/cjs/index.js +38 -14
- package/dist/cjs/middleware/index.js +3 -5
- package/dist/cjs/middleware/middleware.js +18 -2
- package/dist/cjs/middleware/multisite-middleware.js +14 -8
- package/dist/cjs/middleware/personalize-middleware.js +62 -56
- package/dist/cjs/middleware/redirects-middleware.js +64 -21
- package/dist/cjs/services/base-graphql-sitemap-service.js +7 -6
- package/dist/cjs/services/component-props-service.js +6 -6
- package/dist/cjs/site/index.js +5 -0
- package/dist/cjs/utils/index.js +11 -0
- package/dist/cjs/{utils.js → utils/utils.js} +7 -16
- package/dist/esm/ComponentBuilder.js +59 -0
- package/dist/esm/components/BYOCWrapper.js +42 -0
- package/dist/esm/components/FEaaSWrapper.js +44 -0
- package/dist/esm/components/Link.js +5 -4
- package/dist/esm/components/NextImage.js +2 -12
- package/dist/esm/components/RichText.js +11 -15
- package/dist/esm/context/context.js +79 -0
- package/dist/esm/context/index.js +1 -0
- package/dist/esm/editing/constants.js +3 -0
- package/dist/esm/editing/editing-config-middleware.js +45 -0
- package/dist/esm/editing/editing-data-middleware.js +2 -2
- package/dist/esm/editing/editing-data-service.js +14 -6
- package/dist/esm/editing/editing-render-middleware.js +25 -11
- package/dist/esm/editing/feaas-render-middleware.js +83 -0
- package/dist/esm/editing/index.js +3 -0
- package/dist/esm/editing/render-middleware.js +23 -0
- package/dist/esm/editing/vercel-editing-data-cache.js +44 -0
- package/dist/esm/graphql/index.js +1 -0
- package/dist/esm/index.js +10 -7
- package/dist/esm/middleware/index.js +1 -2
- package/dist/esm/middleware/middleware.js +18 -2
- package/dist/esm/middleware/multisite-middleware.js +14 -8
- package/dist/esm/middleware/personalize-middleware.js +65 -59
- package/dist/esm/middleware/redirects-middleware.js +64 -21
- package/dist/esm/services/base-graphql-sitemap-service.js +7 -6
- package/dist/esm/services/component-props-service.js +6 -6
- package/dist/esm/site/index.js +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/{utils.js → utils/utils.js} +7 -13
- package/graphql.d.ts +1 -0
- package/graphql.js +1 -0
- package/package.json +15 -12
- package/site.d.ts +1 -0
- package/site.js +1 -0
- package/types/ComponentBuilder.d.ts +61 -0
- package/types/components/BYOCWrapper.d.ts +19 -0
- package/types/components/ComponentPropsContext.d.ts +1 -0
- package/types/components/FEaaSWrapper.d.ts +21 -0
- package/types/components/Link.d.ts +2 -1
- package/types/components/NextImage.d.ts +3 -3
- package/types/components/Placeholder.d.ts +3 -1
- package/types/components/RichText.d.ts +6 -4
- package/types/context/context.d.ts +116 -0
- package/types/context/index.d.ts +1 -0
- package/types/editing/constants.d.ts +3 -0
- package/types/editing/editing-config-middleware.d.ts +29 -0
- package/types/editing/editing-data-service.d.ts +12 -4
- package/types/editing/editing-render-middleware.d.ts +2 -1
- package/types/editing/feaas-render-middleware.d.ts +32 -0
- package/types/editing/index.d.ts +3 -0
- package/types/editing/render-middleware.d.ts +15 -0
- package/types/editing/vercel-editing-data-cache.d.ts +19 -0
- package/types/graphql/index.d.ts +1 -0
- package/types/index.d.ts +12 -9
- package/types/middleware/index.d.ts +1 -2
- package/types/middleware/middleware.d.ts +8 -0
- package/types/middleware/multisite-middleware.d.ts +15 -0
- package/types/middleware/personalize-middleware.d.ts +53 -14
- package/types/middleware/redirects-middleware.d.ts +1 -1
- package/types/services/base-graphql-sitemap-service.d.ts +7 -10
- package/types/services/component-props-service.d.ts +2 -2
- package/types/sharedTypes/component-props.d.ts +5 -1
- package/types/sharedTypes/module-factory.d.ts +33 -0
- package/types/site/index.d.ts +1 -0
- package/types/utils/index.d.ts +2 -0
- package/types/{utils.d.ts → utils/utils.d.ts} +2 -0
- package/utils.d.ts +1 -0
- package/utils.js +1 -0
- package/types/sharedTypes/component-module.d.ts +0 -13
- /package/dist/cjs/sharedTypes/{component-module.js → module-factory.js} +0 -0
- /package/dist/esm/sharedTypes/{component-module.js → module-factory.js} +0 -0
|
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss/graphql';
|
|
11
10
|
import { debug } from '@sitecore-jss/sitecore-jss';
|
|
12
11
|
import { getPersonalizedRewrite } from '@sitecore-jss/sitecore-jss/personalize';
|
|
13
12
|
/** @private */
|
|
@@ -32,7 +31,7 @@ query ${usesPersonalize ? 'PersonalizeSitemapQuery' : 'DefaultSitemapQuery'}(
|
|
|
32
31
|
$language: String!
|
|
33
32
|
$includedPaths: [String]
|
|
34
33
|
$excludedPaths: [String]
|
|
35
|
-
$pageSize: Int =
|
|
34
|
+
$pageSize: Int = 100
|
|
36
35
|
$after: String
|
|
37
36
|
) {
|
|
38
37
|
site {
|
|
@@ -128,7 +127,7 @@ export class BaseGraphQLSitemapService {
|
|
|
128
127
|
getTranformedPaths(siteName, languages, formatStaticPath) {
|
|
129
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
129
|
const paths = new Array();
|
|
131
|
-
|
|
130
|
+
for (const language of languages) {
|
|
132
131
|
if (language === '') {
|
|
133
132
|
throw new RangeError(languageEmptyError);
|
|
134
133
|
}
|
|
@@ -136,7 +135,7 @@ export class BaseGraphQLSitemapService {
|
|
|
136
135
|
const results = yield this.fetchLanguageSitePaths(language, siteName);
|
|
137
136
|
const transformedPaths = yield this.transformLanguageSitePaths(results, formatStaticPath, language);
|
|
138
137
|
paths.push(...transformedPaths);
|
|
139
|
-
}
|
|
138
|
+
}
|
|
140
139
|
return paths;
|
|
141
140
|
});
|
|
142
141
|
}
|
|
@@ -191,8 +190,10 @@ export class BaseGraphQLSitemapService {
|
|
|
191
190
|
* @returns {GraphQLClient} implementation
|
|
192
191
|
*/
|
|
193
192
|
getGraphQLClient() {
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
if (!this.options.clientFactory) {
|
|
194
|
+
throw new Error('clientFactory needs to be provided when initializing GraphQL client.');
|
|
195
|
+
}
|
|
196
|
+
return this.options.clientFactory({
|
|
196
197
|
debugger: debug.sitemap,
|
|
197
198
|
});
|
|
198
199
|
}
|
|
@@ -17,9 +17,9 @@ export class ComponentPropsService {
|
|
|
17
17
|
*/
|
|
18
18
|
fetchServerSideComponentProps(params) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const {
|
|
20
|
+
const { moduleFactory, layoutData, context } = params;
|
|
21
21
|
const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const module = yield
|
|
22
|
+
const module = yield moduleFactory(componentName);
|
|
23
23
|
return module === null || module === void 0 ? void 0 : module.getServerSideProps;
|
|
24
24
|
});
|
|
25
25
|
return this.fetchComponentProps(fetchFunctionFactory, layoutData, context);
|
|
@@ -33,9 +33,9 @@ export class ComponentPropsService {
|
|
|
33
33
|
*/
|
|
34
34
|
fetchStaticComponentProps(params) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const {
|
|
36
|
+
const { moduleFactory, layoutData, context } = params;
|
|
37
37
|
const fetchFunctionFactory = (componentName) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const module = yield
|
|
38
|
+
const module = yield moduleFactory(componentName);
|
|
39
39
|
return module === null || module === void 0 ? void 0 : module.getStaticProps;
|
|
40
40
|
});
|
|
41
41
|
return this.fetchComponentProps(fetchFunctionFactory, layoutData, context);
|
|
@@ -122,11 +122,11 @@ export class ComponentPropsService {
|
|
|
122
122
|
componentProps[uid] = result;
|
|
123
123
|
})
|
|
124
124
|
.catch((error) => {
|
|
125
|
-
const errLog = `Error during preload data for component ${uid}: ${error.message ||
|
|
126
|
-
error}`;
|
|
125
|
+
const errLog = `Error during preload data for component ${req.rendering.componentName} (${uid}): ${error.message || error}`;
|
|
127
126
|
console.error(chalk.red(errLog));
|
|
128
127
|
componentProps[uid] = {
|
|
129
128
|
error: error.message || errLog,
|
|
129
|
+
componentName: req.rendering.componentName,
|
|
130
130
|
};
|
|
131
131
|
});
|
|
132
132
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SiteResolver } from '@sitecore-jss/sitecore-jss/site';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
1
|
import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/utils';
|
|
3
2
|
/**
|
|
4
3
|
* Get the publicUrl.
|
|
@@ -6,25 +5,20 @@ import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/u
|
|
|
6
5
|
* This is set to http://localhost:3000 by default.
|
|
7
6
|
* VERCEL_URL is provided by Vercel in case if we are in Preview deployment (deployment based on the custom branch),
|
|
8
7
|
* preview deployment has unique url, we don't know exact url.
|
|
8
|
+
* Similarly, DEPLOY_URL is provided by Netlify and would give us the deploy URL
|
|
9
|
+
* In production non-editing environments it is desirable to use relative urls, so in that case set PUBLIC_URL = ''
|
|
9
10
|
*/
|
|
10
11
|
export const getPublicUrl = () => {
|
|
11
|
-
if (process.env.VERCEL_URL)
|
|
12
|
-
return `https://${process.env.VERCEL_URL}`;
|
|
13
12
|
let url = process.env.PUBLIC_URL;
|
|
14
13
|
if (url === undefined) {
|
|
15
|
-
|
|
14
|
+
if (process.env.NETLIFY && process.env.DEPLOY_URL)
|
|
15
|
+
return process.env.DEPLOY_URL;
|
|
16
|
+
if (process.env.VERCEL_URL)
|
|
17
|
+
return `https://${process.env.VERCEL_URL}`;
|
|
16
18
|
url = 'http://localhost:3000';
|
|
17
19
|
}
|
|
18
|
-
else {
|
|
19
|
-
try {
|
|
20
|
-
new URL(url);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
throw new Error(`The PUBLIC_URL environment variable '${url}' is not a valid URL.`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
20
|
// Ensure no trailing slash
|
|
27
|
-
return url.
|
|
21
|
+
return url.replace(/\/$/, '');
|
|
28
22
|
};
|
|
29
23
|
/**
|
|
30
24
|
* Since Sitecore editors do not support Fast Refresh:
|
package/graphql.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/graphql/index';
|
package/graphql.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/cjs/graphql/index');
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "22.0.0
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig-esm.json",
|
|
9
9
|
"clean": "del-cli dist types",
|
|
10
|
-
"lint": "eslint ./src/**/*.tsx ./src/**/*.ts",
|
|
10
|
+
"lint": "eslint \"./src/**/*.tsx\" \"./src/**/*.ts\"",
|
|
11
11
|
"test": "mocha --require ./test/setup.js \"./src/**/*.test.ts\" \"./src/**/*.test.tsx\" --exit",
|
|
12
12
|
"prepublishOnly": "npm run build",
|
|
13
13
|
"coverage": "nyc npm test",
|
|
14
|
-
"generate-docs": "npx typedoc --plugin typedoc-plugin-markdown --readme none --out ../../ref-docs/sitecore-jss-nextjs --entryPoints src/index.ts --entryPoints src/monitoring/index.ts --entryPoints src/editing/index.ts --entryPoints src/middleware/index.ts --githubPages false"
|
|
14
|
+
"generate-docs": "npx typedoc --plugin typedoc-plugin-markdown --readme none --out ../../ref-docs/sitecore-jss-nextjs --entryPoints src/index.ts --entryPoints src/monitoring/index.ts --entryPoints src/editing/index.ts --entryPoints src/middleware/index.ts --entryPoints src/context/index.ts --entryPoints src/utils/index.ts --entryPoints src/site/index.ts --entryPoints src/graphql/index.ts --githubPages false"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
18
|
-
"npm": ">=6"
|
|
17
|
+
"node": ">=18"
|
|
19
18
|
},
|
|
20
19
|
"author": {
|
|
21
20
|
"name": "Sitecore Corporation",
|
|
@@ -30,6 +29,7 @@
|
|
|
30
29
|
"url": "https://github.com/sitecore/jss/issues"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
32
|
+
"@sitecore-cloudsdk/personalize": "^0.3.0",
|
|
33
33
|
"@types/chai": "^4.3.4",
|
|
34
34
|
"@types/chai-as-promised": "^7.1.5",
|
|
35
35
|
"@types/chai-string": "^1.4.2",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/mocha": "^10.0.1",
|
|
38
38
|
"@types/node": "~18.11.18",
|
|
39
39
|
"@types/prop-types": "^15.7.5",
|
|
40
|
-
"@types/react": "^18.
|
|
40
|
+
"@types/react": "^18.2.22",
|
|
41
41
|
"@types/react-dom": "^18.0.10",
|
|
42
42
|
"@types/sinon": "^10.0.13",
|
|
43
43
|
"@types/sinon-chai": "^3.2.9",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"eslint-plugin-react": "^7.32.1",
|
|
55
55
|
"jsdom": "^21.1.0",
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
|
-
"next": "^
|
|
57
|
+
"next": "^14.1.0",
|
|
58
58
|
"nock": "^13.3.0",
|
|
59
59
|
"nyc": "^15.1.0",
|
|
60
60
|
"react": "^18.2.0",
|
|
@@ -65,14 +65,17 @@
|
|
|
65
65
|
"typescript": "~4.9.4"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"
|
|
68
|
+
"@sitecore-cloudsdk/events": "^0.3.0",
|
|
69
|
+
"@sitecore-cloudsdk/personalize": "^0.3.0",
|
|
70
|
+
"next": "^14.1.0",
|
|
69
71
|
"react": "^18.2.0",
|
|
70
72
|
"react-dom": "^18.2.0"
|
|
71
73
|
},
|
|
72
74
|
"dependencies": {
|
|
73
|
-
"@sitecore-jss/sitecore-jss": "
|
|
74
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "
|
|
75
|
-
"@sitecore-jss/sitecore-jss-react": "
|
|
75
|
+
"@sitecore-jss/sitecore-jss": "22.0.0",
|
|
76
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "22.0.0",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-react": "22.0.0",
|
|
78
|
+
"@vercel/kv": "^0.2.1",
|
|
76
79
|
"node-html-parser": "^6.1.4",
|
|
77
80
|
"prop-types": "^15.8.1",
|
|
78
81
|
"regex-parser": "^2.2.11",
|
|
@@ -80,7 +83,7 @@
|
|
|
80
83
|
},
|
|
81
84
|
"description": "",
|
|
82
85
|
"types": "types/index.d.ts",
|
|
83
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "2a5fe700fd75e19e4107b39630cce823fc1af08e",
|
|
84
87
|
"files": [
|
|
85
88
|
"dist",
|
|
86
89
|
"types",
|
package/site.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/site/index';
|
package/site.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/cjs/site/index');
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
2
|
+
import { ComponentFactory } from '@sitecore-jss/sitecore-jss-react';
|
|
3
|
+
import { Module, ModuleFactory } from './sharedTypes/module-factory';
|
|
4
|
+
import { ComponentType } from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a component that can be imported dynamically
|
|
7
|
+
*/
|
|
8
|
+
export type LazyModule = {
|
|
9
|
+
module: () => Promise<Module>;
|
|
10
|
+
element: (isEditing?: boolean) => ComponentType;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Component is a module or a lazy module
|
|
14
|
+
*/
|
|
15
|
+
type Component = Module | LazyModule | ComponentType;
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for ComponentBuilder
|
|
18
|
+
*/
|
|
19
|
+
export type ComponentBuilderConfig<Component> = {
|
|
20
|
+
/**
|
|
21
|
+
* List of components to be stored
|
|
22
|
+
*/
|
|
23
|
+
components: Map<string, Component>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for ComponentFactory
|
|
27
|
+
*/
|
|
28
|
+
type ComponentFactoryConfig = {
|
|
29
|
+
isEditing?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Nextjs implementation of component builder class for building components based on the configuration.
|
|
33
|
+
*/
|
|
34
|
+
export declare class ComponentBuilder {
|
|
35
|
+
protected config: ComponentBuilderConfig<Component>;
|
|
36
|
+
/**
|
|
37
|
+
* List of components to be stored
|
|
38
|
+
*/
|
|
39
|
+
protected components: Map<string, Component>;
|
|
40
|
+
/**
|
|
41
|
+
* SXA uses custom default export name
|
|
42
|
+
*/
|
|
43
|
+
protected DEFAULT_EXPORT_NAME: string;
|
|
44
|
+
constructor(config: ComponentBuilderConfig<Component>);
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new instance of module factory
|
|
47
|
+
* Module factory provides a module (file) including all exports.
|
|
48
|
+
* Module can be imported dynamically or statically.
|
|
49
|
+
* @returns {ModuleFactory} Module factory implementation
|
|
50
|
+
*/
|
|
51
|
+
getModuleFactory(): ModuleFactory;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new instance of component factory
|
|
54
|
+
* Component can be imported dynamically or statically.
|
|
55
|
+
* @param {Object} [config] Component factory configuration
|
|
56
|
+
* @param {boolean} [config.isEditing] Indicates if component factory is used in editing mode
|
|
57
|
+
* @returns {ComponentFactory} Component factory implementation
|
|
58
|
+
*/
|
|
59
|
+
getComponentFactory({ isEditing }?: ComponentFactoryConfig): ComponentFactory;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BYOCWrapper } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
+
import { GetStaticComponentProps, GetServerSideComponentProps } from '../sharedTypes/component-props';
|
|
3
|
+
/**
|
|
4
|
+
* This is a repackaged version of the React BYOCWrapper component with support for
|
|
5
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Will be called during SSG
|
|
9
|
+
* @param {ComponentRendering} rendering
|
|
10
|
+
* @returns {GetStaticPropsContext} context
|
|
11
|
+
*/
|
|
12
|
+
export declare const getStaticProps: GetStaticComponentProps;
|
|
13
|
+
/**
|
|
14
|
+
* Will be called during SSR
|
|
15
|
+
* @param {ComponentRendering} rendering
|
|
16
|
+
* @returns {GetStaticPropsContext} context
|
|
17
|
+
*/
|
|
18
|
+
export declare const getServerSideProps: GetServerSideComponentProps;
|
|
19
|
+
export default BYOCWrapper;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FEaaSWrapper } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
+
import { GetStaticComponentProps, GetServerSideComponentProps } from '../sharedTypes/component-props';
|
|
3
|
+
/**
|
|
4
|
+
* This is a repackaged version of the React FEaaSWrapper component with support for
|
|
5
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Will be called during SSG
|
|
9
|
+
* @param {ComponentRendering} rendering
|
|
10
|
+
* @param {LayoutServiceData} layoutData
|
|
11
|
+
* @returns {GetStaticPropsContext} context
|
|
12
|
+
*/
|
|
13
|
+
export declare const getStaticProps: GetStaticComponentProps;
|
|
14
|
+
/**
|
|
15
|
+
* Will be called during SSR
|
|
16
|
+
* @param {ComponentRendering} rendering
|
|
17
|
+
* @param {LayoutServiceData} layoutData
|
|
18
|
+
* @returns {GetStaticPropsContext} context
|
|
19
|
+
*/
|
|
20
|
+
export declare const getServerSideProps: GetServerSideComponentProps;
|
|
21
|
+
export default FEaaSWrapper;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { LinkProps as ReactLinkProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
4
|
export type LinkProps = ReactLinkProps & {
|
|
@@ -7,4 +8,4 @@ export type LinkProps = ReactLinkProps & {
|
|
|
7
8
|
*/
|
|
8
9
|
internalLinkMatcher?: RegExp;
|
|
9
10
|
};
|
|
10
|
-
export declare const Link: React.ForwardRefExoticComponent<
|
|
11
|
+
export declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { ImageProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
|
-
import {
|
|
4
|
-
type NextImageProps =
|
|
5
|
-
export declare const sitecoreLoader: ImageLoader;
|
|
4
|
+
import { ImageProps as NextImageProperties } from 'next/image';
|
|
5
|
+
type NextImageProps = ImageProps & Partial<NextImageProperties>;
|
|
6
6
|
export declare const NextImage: React.FC<NextImageProps>;
|
|
7
7
|
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
2
|
+
import React from 'react';
|
|
1
3
|
import { PlaceholderComponentProps } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
-
export declare const Placeholder: (props: PlaceholderComponentProps) => JSX.Element;
|
|
4
|
+
export declare const Placeholder: (props: PlaceholderComponentProps) => React.JSX.Element;
|
|
@@ -6,6 +6,12 @@ export type RichTextProps = ReactRichTextProps & {
|
|
|
6
6
|
* @default 'a[href^="/"]'
|
|
7
7
|
*/
|
|
8
8
|
internalLinksSelector?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Controls the prefetch of internal links. This can be beneficial if you have RichText fields
|
|
11
|
+
* with large numbers of internal links in them.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
prefetchLinks?: boolean;
|
|
9
15
|
};
|
|
10
16
|
export declare const RichText: {
|
|
11
17
|
(props: RichTextProps): JSX.Element;
|
|
@@ -18,9 +24,5 @@ export declare const RichText: {
|
|
|
18
24
|
editable: PropTypes.Requireable<boolean>;
|
|
19
25
|
internalLinksSelector: PropTypes.Requireable<string>;
|
|
20
26
|
};
|
|
21
|
-
defaultProps: {
|
|
22
|
-
tag: string;
|
|
23
|
-
editable: boolean;
|
|
24
|
-
};
|
|
25
27
|
displayName: string;
|
|
26
28
|
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
+
/**
|
|
3
|
+
* Software Development Kit (SDK) instance
|
|
4
|
+
*/
|
|
5
|
+
export type SDK<SDKType = unknown> = {
|
|
6
|
+
/**
|
|
7
|
+
* The Software Development Kit (SDK) library instance
|
|
8
|
+
*/
|
|
9
|
+
sdk: SDKType;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes the Software Development Kit (SDK)
|
|
12
|
+
*/
|
|
13
|
+
init: (props: InitSDKProps) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Software Development Kits (SDKs) to be initialized
|
|
17
|
+
*/
|
|
18
|
+
type SDKModulesType = Record<string, SDK>;
|
|
19
|
+
/**
|
|
20
|
+
* Properties that are passed to the Context.
|
|
21
|
+
*/
|
|
22
|
+
export interface ContextInitProps {
|
|
23
|
+
/**
|
|
24
|
+
* Your Sitecore site name
|
|
25
|
+
*/
|
|
26
|
+
siteName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Sitecore page state (normal, preview, edit)
|
|
29
|
+
*/
|
|
30
|
+
pageState?: LayoutServicePageState;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configuration that is passed to the Context.
|
|
34
|
+
*/
|
|
35
|
+
export interface ContextConfig<SDKModules extends SDKModulesType> {
|
|
36
|
+
/**
|
|
37
|
+
* Your Sitecore Edge URL
|
|
38
|
+
*/
|
|
39
|
+
sitecoreEdgeUrl: string;
|
|
40
|
+
/**
|
|
41
|
+
* Your Sitecore Edge Context ID
|
|
42
|
+
*/
|
|
43
|
+
sitecoreEdgeContextId: string;
|
|
44
|
+
/**
|
|
45
|
+
* Your Sitecore site name
|
|
46
|
+
*/
|
|
47
|
+
siteName: string;
|
|
48
|
+
/**
|
|
49
|
+
* Software Development Kits (SDKs) to be initialized
|
|
50
|
+
*/
|
|
51
|
+
sdks: {
|
|
52
|
+
[module in keyof SDKModules]: SDKModules[module];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Properties that are passed to the Software Development Kit (SDK) initialization function.
|
|
57
|
+
*/
|
|
58
|
+
type InitSDKProps = Omit<ContextConfig<SDKModulesType>, 'sdks'>;
|
|
59
|
+
/**
|
|
60
|
+
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
61
|
+
*/
|
|
62
|
+
export declare class Context<SDKModules extends SDKModulesType> {
|
|
63
|
+
protected props: ContextConfig<SDKModules>;
|
|
64
|
+
/**
|
|
65
|
+
* Indicates whether the Context and SDK(s) have been initialized
|
|
66
|
+
*/
|
|
67
|
+
isInitialized: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The Sitecore Edge URL
|
|
70
|
+
*/
|
|
71
|
+
readonly sitecoreEdgeUrl: string;
|
|
72
|
+
/**
|
|
73
|
+
* The Sitecore Edge Context ID
|
|
74
|
+
*/
|
|
75
|
+
readonly sitecoreEdgeContextId: string;
|
|
76
|
+
/**
|
|
77
|
+
* The Sitecore site name
|
|
78
|
+
*/
|
|
79
|
+
siteName: string;
|
|
80
|
+
/**
|
|
81
|
+
* Sitecore page state (normal, preview, edit)
|
|
82
|
+
*/
|
|
83
|
+
pageState: LayoutServicePageState;
|
|
84
|
+
/**
|
|
85
|
+
* Software Development Kits (SDKs) to be initialized
|
|
86
|
+
*/
|
|
87
|
+
readonly sdks: {
|
|
88
|
+
[module in keyof SDKModules]?: SDKModules[module]['sdk'];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Promises for the SDKs
|
|
92
|
+
*/
|
|
93
|
+
protected sdkPromises: {
|
|
94
|
+
[module in keyof SDKModules]?: Promise<SDKModules[module]['sdk']>;
|
|
95
|
+
};
|
|
96
|
+
protected sdkErrors: {
|
|
97
|
+
[module in keyof SDKModules]?: string;
|
|
98
|
+
};
|
|
99
|
+
constructor(props: ContextConfig<SDKModules>);
|
|
100
|
+
init(props?: ContextInitProps): void;
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
103
|
+
*
|
|
104
|
+
* @param {string} name SDK name
|
|
105
|
+
* @returns initialized SDK
|
|
106
|
+
*/
|
|
107
|
+
getSDK: <T extends keyof SDKModules>(name: T) => Promise<SDKModules[T]["sdk"]>;
|
|
108
|
+
/**
|
|
109
|
+
* Initializes the Software Development Kit (SDK)
|
|
110
|
+
*
|
|
111
|
+
* @param {T} name SDK name
|
|
112
|
+
* @returns {void}
|
|
113
|
+
*/
|
|
114
|
+
protected initSDK<T extends keyof SDKModules>(name: T): void;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Context, ContextConfig, SDK } from './context';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { Metadata } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
3
|
+
export type EditingConfigMiddlewareConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* Components available in the application
|
|
6
|
+
*/
|
|
7
|
+
components: string[] | Map<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Application metadata
|
|
10
|
+
*/
|
|
11
|
+
metadata: Metadata;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Middleware / handler used in the editing config API route in xmcloud add on (e.g. '/api/editing/config')
|
|
15
|
+
* provides configuration information to determine feature compatibility on Pages side.
|
|
16
|
+
*/
|
|
17
|
+
export declare class EditingConfigMiddleware {
|
|
18
|
+
protected config: EditingConfigMiddlewareConfig;
|
|
19
|
+
/**
|
|
20
|
+
* @param {EditingConfigMiddlewareConfig} [config] Editing configuration middleware config
|
|
21
|
+
*/
|
|
22
|
+
constructor(config: EditingConfigMiddlewareConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Gets the Next.js API route handler
|
|
25
|
+
* @returns middleware handler
|
|
26
|
+
*/
|
|
27
|
+
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
28
|
+
private handler;
|
|
29
|
+
}
|
|
@@ -2,13 +2,15 @@ import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
|
2
2
|
import { EditingData } from './editing-data';
|
|
3
3
|
import { EditingDataCache } from './editing-data-cache';
|
|
4
4
|
import { PreviewData } from 'next';
|
|
5
|
-
export declare const QUERY_PARAM_EDITING_SECRET = "secret";
|
|
6
5
|
/**
|
|
7
6
|
* Data for Next.js Preview (Editing) mode
|
|
8
7
|
*/
|
|
9
8
|
export interface EditingPreviewData {
|
|
10
9
|
key: string;
|
|
11
10
|
serverUrl?: string;
|
|
11
|
+
params?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Defines an editing data service implementation
|
|
@@ -20,7 +22,9 @@ export interface EditingDataService {
|
|
|
20
22
|
* @param {string} serverUrl The server url e.g. which can be used for further API requests
|
|
21
23
|
* @returns The {@link EditingPreviewData} containing the information to use for retrieval
|
|
22
24
|
*/
|
|
23
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
25
|
+
setEditingData(data: EditingData, serverUrl: string, params?: {
|
|
26
|
+
[key: string]: string;
|
|
27
|
+
}): Promise<EditingPreviewData>;
|
|
24
28
|
/**
|
|
25
29
|
* Retrieves Sitecore editor payload data
|
|
26
30
|
* @param {PreviewData} previewData Editing preview data containing the information to use for retrieval
|
|
@@ -107,14 +111,18 @@ export declare class ServerlessEditingDataService implements EditingDataService
|
|
|
107
111
|
* @param {string} serverUrl The server url to use for subsequent data API requests
|
|
108
112
|
* @returns {Promise} The {@link EditingPreviewData} containing the generated key and serverUrl to use for retrieval
|
|
109
113
|
*/
|
|
110
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
114
|
+
setEditingData(data: EditingData, serverUrl: string, params?: {
|
|
115
|
+
[key: string]: string;
|
|
116
|
+
}): Promise<EditingPreviewData>;
|
|
111
117
|
/**
|
|
112
118
|
* Retrieves Sitecore editor payload data by key
|
|
113
119
|
* @param {PreviewData} previewData Editing preview data containing the key and serverUrl to use for retrieval
|
|
114
120
|
* @returns {Promise} The {@link EditingData}
|
|
115
121
|
*/
|
|
116
122
|
getEditingData(previewData: PreviewData): Promise<EditingData | undefined>;
|
|
117
|
-
protected getUrl(serverUrl: string, key: string
|
|
123
|
+
protected getUrl(serverUrl: string, key: string, params?: {
|
|
124
|
+
[key: string]: string;
|
|
125
|
+
}): string;
|
|
118
126
|
}
|
|
119
127
|
/**
|
|
120
128
|
* The `EditingDataService` default instance.
|
|
@@ -2,6 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
|
|
|
2
2
|
import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
3
3
|
import { EditingData } from './editing-data';
|
|
4
4
|
import { EditingDataService } from './editing-data-service';
|
|
5
|
+
import { RenderMiddlewareBase } from './render-middleware';
|
|
5
6
|
export interface EditingRenderMiddlewareConfig {
|
|
6
7
|
/**
|
|
7
8
|
* The `AxiosDataFetcher` instance to use for API requests.
|
|
@@ -41,7 +42,7 @@ export interface EditingRenderMiddlewareConfig {
|
|
|
41
42
|
* Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
|
|
42
43
|
* which is required for Sitecore editing support.
|
|
43
44
|
*/
|
|
44
|
-
export declare class EditingRenderMiddleware {
|
|
45
|
+
export declare class EditingRenderMiddleware extends RenderMiddlewareBase {
|
|
45
46
|
private editingDataService;
|
|
46
47
|
private dataFetcher;
|
|
47
48
|
private resolvePageUrl;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { RenderMiddlewareBase } from './render-middleware';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for `FEAASRenderMiddleware`.
|
|
5
|
+
*/
|
|
6
|
+
export interface FEAASRenderMiddlewareConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Defines FEAAS page route to render.
|
|
9
|
+
* This may be necessary for certain custom Next.js routing configurations.
|
|
10
|
+
* @default /feaas/render
|
|
11
|
+
*/
|
|
12
|
+
pageUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Middleware / handler for use in the feaas render Next.js API route (e.g. '/api/editing/feaas/render')
|
|
16
|
+
* which is required for Sitecore editing support.
|
|
17
|
+
*/
|
|
18
|
+
export declare class FEAASRenderMiddleware extends RenderMiddlewareBase {
|
|
19
|
+
protected config?: FEAASRenderMiddlewareConfig | undefined;
|
|
20
|
+
private pageUrl;
|
|
21
|
+
private defaultPageUrl;
|
|
22
|
+
/**
|
|
23
|
+
* @param {EditingRenderMiddlewareConfig} [config] Editing render middleware config
|
|
24
|
+
*/
|
|
25
|
+
constructor(config?: FEAASRenderMiddlewareConfig | undefined);
|
|
26
|
+
/**
|
|
27
|
+
* Gets the Next.js API route handler
|
|
28
|
+
* @returns route handler
|
|
29
|
+
*/
|
|
30
|
+
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
31
|
+
private handler;
|
|
32
|
+
}
|
package/types/editing/index.d.ts
CHANGED
|
@@ -3,3 +3,6 @@ export { EditingDataCache, EditingDataDiskCache } from './editing-data-cache';
|
|
|
3
3
|
export { EditingDataMiddleware, EditingDataMiddlewareConfig } from './editing-data-middleware';
|
|
4
4
|
export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, } from './editing-render-middleware';
|
|
5
5
|
export { EditingPreviewData, EditingDataService, BasicEditingDataService, BasicEditingDataServiceConfig, ServerlessEditingDataService, ServerlessEditingDataServiceConfig, editingDataService, } from './editing-data-service';
|
|
6
|
+
export { VercelEditingDataCache } from './vercel-editing-data-cache';
|
|
7
|
+
export { FEAASRenderMiddleware, FEAASRenderMiddlewareConfig } from './feaas-render-middleware';
|
|
8
|
+
export { EditingConfigMiddleware, EditingConfigMiddlewareConfig, } from './editing-config-middleware';
|