@uniformdev/canvas-next-rsc 19.69.0 → 19.73.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/dist/UniformComposition-38e22896.d.ts +61 -0
- package/dist/component.d.mts +76 -0
- package/dist/component.d.ts +76 -0
- package/dist/component.js +218 -0
- package/dist/component.mjs +182 -0
- package/dist/config.d.mts +6 -0
- package/dist/config.d.ts +6 -1
- package/dist/config.js +56 -29
- package/dist/config.mjs +41 -0
- package/dist/handler.d.mts +12 -0
- package/dist/handler.d.ts +12 -2
- package/dist/handler.js +703 -2
- package/dist/handler.mjs +682 -0
- package/dist/{client/manifestClient.d.ts → index.d.mts} +100 -18
- package/dist/index.d.ts +243 -23
- package/dist/index.esm.js +977 -0
- package/dist/index.js +1013 -29
- package/dist/index.mjs +977 -0
- package/package.json +23 -15
- package/dist/actions/updateContext.d.ts +0 -2
- package/dist/actions/updateContext.js +0 -17
- package/dist/client/canvasClient.d.ts +0 -5
- package/dist/client/canvasClient.js +0 -53
- package/dist/client/manifestClient.js +0 -33
- package/dist/client/projectMapClient.d.ts +0 -5
- package/dist/client/projectMapClient.js +0 -17
- package/dist/client/routeClient.d.ts +0 -5
- package/dist/client/routeClient.js +0 -68
- package/dist/components/DefaultNotImplementedComponent.d.ts +0 -2
- package/dist/components/DefaultNotImplementedComponent.js +0 -45
- package/dist/components/GoogleTagManagerAnalytics.d.ts +0 -3
- package/dist/components/GoogleTagManagerAnalytics.js +0 -44
- package/dist/components/UniformComponent.d.ts +0 -25
- package/dist/components/UniformComponent.js +0 -14
- package/dist/components/UniformComposition.d.ts +0 -40
- package/dist/components/UniformComposition.js +0 -35
- package/dist/components/UniformContext.d.ts +0 -8
- package/dist/components/UniformContext.js +0 -19
- package/dist/components/UniformRichText.d.ts +0 -38
- package/dist/components/UniformRichText.js +0 -15
- package/dist/components/UniformRichTextNode.d.ts +0 -10
- package/dist/components/UniformRichTextNode.js +0 -49
- package/dist/components/UniformScript.d.ts +0 -3
- package/dist/components/UniformScript.js +0 -49
- package/dist/components/UniformSlot.d.ts +0 -40
- package/dist/components/UniformSlot.js +0 -38
- package/dist/components/UniformText.d.ts +0 -6
- package/dist/components/UniformText.js +0 -5
- package/dist/components/__tests__/evaluateComposition.spec.d.ts +0 -1
- package/dist/components/__tests__/evaluateComposition.spec.js +0 -80
- package/dist/components/convertComponentToProps.d.ts +0 -14
- package/dist/components/convertComponentToProps.js +0 -22
- package/dist/components/evaluateComposition.d.ts +0 -22
- package/dist/components/evaluateComposition.js +0 -183
- package/dist/components/getEnrichmentTags.d.ts +0 -3
- package/dist/components/getEnrichmentTags.js +0 -13
- package/dist/components/getUniformContext.d.ts +0 -6
- package/dist/components/getUniformContext.js +0 -17
- package/dist/components/nodes/HeadingRichTextNode.d.ts +0 -2
- package/dist/components/nodes/HeadingRichTextNode.js +0 -6
- package/dist/components/nodes/LinebreakRichTextNode.d.ts +0 -2
- package/dist/components/nodes/LinebreakRichTextNode.js +0 -4
- package/dist/components/nodes/LinkRichTextNode.d.ts +0 -2
- package/dist/components/nodes/LinkRichTextNode.js +0 -6
- package/dist/components/nodes/ListItemRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ListItemRichTextNode.js +0 -5
- package/dist/components/nodes/ListRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ListRichTextNode.js +0 -6
- package/dist/components/nodes/ParagraphRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ParagraphRichTextNode.js +0 -6
- package/dist/components/nodes/TabRichTextNode.d.ts +0 -2
- package/dist/components/nodes/TabRichTextNode.js +0 -4
- package/dist/components/nodes/TextRichTextNode.d.ts +0 -2
- package/dist/components/nodes/TextRichTextNode.js +0 -9
- package/dist/components/renderComponent.d.ts +0 -15
- package/dist/components/renderComponent.js +0 -52
- package/dist/components/resolvePath.d.ts +0 -5
- package/dist/components/resolvePath.js +0 -34
- package/dist/components/retrieveRoute.d.ts +0 -141
- package/dist/components/retrieveRoute.js +0 -146
- package/dist/components/types.d.ts +0 -11
- package/dist/components/types.js +0 -1
- package/dist/config/helpers.d.ts +0 -17
- package/dist/config/helpers.js +0 -34
- package/dist/config/models.d.ts +0 -51
- package/dist/config/models.js +0 -1
- package/dist/cookie/index.d.ts +0 -12
- package/dist/cookie/index.js +0 -21
- package/dist/handler/createPreviewGETRouteHandler.d.ts +0 -1
- package/dist/handler/createPreviewGETRouteHandler.js +0 -43
- package/dist/handler/createPreviewPOSTRouteHandler.d.ts +0 -1
- package/dist/handler/createPreviewPOSTRouteHandler.js +0 -88
- package/dist/handler/createUniformRouteHandler.d.ts +0 -4
- package/dist/handler/createUniformRouteHandler.js +0 -10
- package/dist/handler/helpers.d.ts +0 -19
- package/dist/handler/helpers.js +0 -148
- package/dist/handler/messages/handleCompositionChanged.d.ts +0 -2
- package/dist/handler/messages/handleCompositionChanged.js +0 -9
- package/dist/handler/messages/handleCompositionDeleted.d.ts +0 -2
- package/dist/handler/messages/handleCompositionDeleted.js +0 -9
- package/dist/handler/messages/handleCompositionPublished.d.ts +0 -2
- package/dist/handler/messages/handleCompositionPublished.js +0 -9
- package/dist/handler/messages/handleManifestPublished.d.ts +0 -2
- package/dist/handler/messages/handleManifestPublished.js +0 -10
- package/dist/handler/messages/handleProjectMapNodeDelete.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeDelete.js +0 -21
- package/dist/handler/messages/handleProjectMapNodeInsert.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeInsert.js +0 -21
- package/dist/handler/messages/handleProjectMapNodeUpdate.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeUpdate.js +0 -22
- package/dist/handler/messages/handleRedirectDelete.d.ts +0 -2
- package/dist/handler/messages/handleRedirectDelete.js +0 -15
- package/dist/handler/messages/handleRedirectInsert.d.ts +0 -2
- package/dist/handler/messages/handleRedirectInsert.js +0 -15
- package/dist/handler/messages/handleRedirectUpdate.d.ts +0 -2
- package/dist/handler/messages/handleRedirectUpdate.js +0 -15
- package/dist/hooks/useForgetMe.d.ts +0 -4
- package/dist/hooks/useForgetMe.js +0 -10
- package/dist/hooks/useToggleConsent.d.ts +0 -7
- package/dist/hooks/useToggleConsent.js +0 -22
- package/dist/hooks/useUniformContext.d.ts +0 -1
- package/dist/hooks/useUniformContext.js +0 -3
- package/dist/models/index.d.ts +0 -30
- package/dist/models/index.js +0 -1
- package/dist/register/componentStore.d.ts +0 -1
- package/dist/register/componentStore.js +0 -2
- package/dist/register/componentStoreResolver.d.ts +0 -2
- package/dist/register/componentStoreResolver.js +0 -5
- package/dist/register/createComponentStore.d.ts +0 -12
- package/dist/register/createComponentStore.js +0 -13
- package/dist/register/createComponentStoreResolver.d.ts +0 -9
- package/dist/register/createComponentStoreResolver.js +0 -9
- package/dist/register/getTypeWithVariant.d.ts +0 -1
- package/dist/register/getTypeWithVariant.js +0 -1
- package/dist/register/registerUniformComponent.d.ts +0 -6
- package/dist/register/registerUniformComponent.js +0 -8
- package/dist/resolve/resolveChildren.d.ts +0 -10
- package/dist/resolve/resolveChildren.js +0 -20
- package/dist/score/index.d.ts +0 -3
- package/dist/score/index.js +0 -114
- package/dist/utils/__tests__/apply.spec.d.ts +0 -1
- package/dist/utils/__tests__/apply.spec.js +0 -358
- package/dist/utils/__tests__/diff.spec.d.ts +0 -1
- package/dist/utils/__tests__/diff.spec.js +0 -394
- package/dist/utils/apply.d.ts +0 -6
- package/dist/utils/apply.js +0 -124
- package/dist/utils/comp.d.ts +0 -16
- package/dist/utils/comp.js +0 -65
- package/dist/utils/diff.d.ts +0 -44
- package/dist/utils/diff.js +0 -144
- package/dist/utils/draft.d.ts +0 -12
- package/dist/utils/draft.js +0 -22
- package/dist/utils/tag.d.ts +0 -2
- package/dist/utils/tag.js +0 -7
- package/dist/utils/url.d.ts +0 -1
- package/dist/utils/url.js +0 -10
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.73.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"build": "tsup",
|
|
7
|
+
"dev": "tsup --watch",
|
|
8
8
|
"lint": "eslint \"**/*.{ts,tsx}\" --fix",
|
|
9
9
|
"test": "jest --maxWorkers=1 --passWithNoTests"
|
|
10
10
|
},
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"require": "./dist/config.js",
|
|
27
27
|
"import": "./dist/config.js",
|
|
28
28
|
"types": "./dist/config.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./component": {
|
|
31
|
+
"require": "./dist/component.js",
|
|
32
|
+
"import": "./dist/component.js",
|
|
33
|
+
"types": "./dist/component.d.ts"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"typesVersions": {
|
|
@@ -38,6 +43,9 @@
|
|
|
38
43
|
],
|
|
39
44
|
"config": [
|
|
40
45
|
"./dist/config.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"component": [
|
|
48
|
+
"./dist/component.d.ts"
|
|
41
49
|
]
|
|
42
50
|
}
|
|
43
51
|
},
|
|
@@ -45,8 +53,6 @@
|
|
|
45
53
|
"/dist"
|
|
46
54
|
],
|
|
47
55
|
"devDependencies": {
|
|
48
|
-
"@types/gtag.js": "^0.0.14",
|
|
49
|
-
"@types/js-cookie": "^3.0.3",
|
|
50
56
|
"@types/node": "^18.0.0",
|
|
51
57
|
"@types/react": "^18.2.20",
|
|
52
58
|
"eslint": "^8.11.0",
|
|
@@ -55,16 +61,18 @@
|
|
|
55
61
|
"react-dom": "18.2.0"
|
|
56
62
|
},
|
|
57
63
|
"dependencies": {
|
|
58
|
-
"@uniformdev/canvas": "19.
|
|
59
|
-
"@uniformdev/canvas-
|
|
60
|
-
"@uniformdev/
|
|
61
|
-
"@uniformdev/
|
|
62
|
-
"@uniformdev/
|
|
63
|
-
"@uniformdev/
|
|
64
|
-
"@uniformdev/
|
|
64
|
+
"@uniformdev/canvas": "19.73.0",
|
|
65
|
+
"@uniformdev/canvas-next-rsc-client": "^19.73.0",
|
|
66
|
+
"@uniformdev/canvas-next-rsc-shared": "^19.73.0",
|
|
67
|
+
"@uniformdev/canvas-react": "19.73.0",
|
|
68
|
+
"@uniformdev/context": "19.73.0",
|
|
69
|
+
"@uniformdev/project-map": "19.73.0",
|
|
70
|
+
"@uniformdev/redirect": "19.73.0",
|
|
71
|
+
"@uniformdev/richtext": "19.73.0",
|
|
72
|
+
"@uniformdev/webhooks": "19.73.0",
|
|
65
73
|
"@vercel/edge-config": "^0.4.0",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
74
|
+
"encoding": "^0.1.13",
|
|
75
|
+
"server-only": "^0.0.1",
|
|
68
76
|
"svix": "^1.5.0"
|
|
69
77
|
},
|
|
70
78
|
"engines": {
|
|
@@ -78,5 +86,5 @@
|
|
|
78
86
|
"publishConfig": {
|
|
79
87
|
"access": "public"
|
|
80
88
|
},
|
|
81
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "1376a707cf81b8ff1d032cfc5c927c8eb213e713"
|
|
82
90
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use server';
|
|
2
|
-
import { UNIFORM_DEFAULT_COOKIE_NAME } from '@uniformdev/context';
|
|
3
|
-
import { cookies } from 'next/headers';
|
|
4
|
-
import { getUniformContext } from '../components/getUniformContext';
|
|
5
|
-
import { serializeCookie } from '../score';
|
|
6
|
-
export const updateContextAction = async (options) => {
|
|
7
|
-
var _a;
|
|
8
|
-
const context = await getUniformContext({
|
|
9
|
-
cookieValue: (_a = cookies().get(UNIFORM_DEFAULT_COOKIE_NAME)) === null || _a === void 0 ? void 0 : _a.value,
|
|
10
|
-
});
|
|
11
|
-
if (!context.storage.data.consent) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
await context.update(options);
|
|
15
|
-
const scoreCookie = serializeCookie(context.storage.data);
|
|
16
|
-
cookies().set(UNIFORM_DEFAULT_COOKIE_NAME, scoreCookie);
|
|
17
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { CanvasClient } from '@uniformdev/canvas';
|
|
2
|
-
import { isDevelopmentEnvironment } from '../utils/draft';
|
|
3
|
-
import { buildCompositionTag } from '../utils/tag';
|
|
4
|
-
export const getCanvasClient = (options) => {
|
|
5
|
-
return new CanvasClient({
|
|
6
|
-
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
7
|
-
apiHost: process.env.UNIFORM_API_HOST,
|
|
8
|
-
apiKey: process.env.UNIFORM_API_KEY,
|
|
9
|
-
edgeApiHost: process.env.UNIFORM_EDGE_API_HOST,
|
|
10
|
-
fetch: (req, init) => {
|
|
11
|
-
let requestedUrl;
|
|
12
|
-
if (typeof req === 'string') {
|
|
13
|
-
requestedUrl = new URL(req);
|
|
14
|
-
}
|
|
15
|
-
else if (req instanceof URL) {
|
|
16
|
-
requestedUrl = req;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
requestedUrl = new URL(req.url);
|
|
20
|
-
}
|
|
21
|
-
const tags = [];
|
|
22
|
-
if (requestedUrl) {
|
|
23
|
-
// this is here so this code breaks if parameters change here
|
|
24
|
-
const compositionIdKey = 'compositionId';
|
|
25
|
-
const compositionIdsKey = 'compositionIDs';
|
|
26
|
-
const compositionId = requestedUrl.searchParams.get(compositionIdKey);
|
|
27
|
-
const compositionIds = requestedUrl.searchParams.get(compositionIdsKey);
|
|
28
|
-
if (compositionId) {
|
|
29
|
-
tags.push(buildCompositionTag(compositionId));
|
|
30
|
-
}
|
|
31
|
-
if (compositionIds) {
|
|
32
|
-
const ids = compositionIds.split(',');
|
|
33
|
-
for (let i = 0; i < ids.length; i++) {
|
|
34
|
-
tags.push(buildCompositionTag(ids[i]));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
let revalidate = options === null || options === void 0 ? void 0 : options.revalidate;
|
|
39
|
-
let noCache = false;
|
|
40
|
-
if (revalidate === -1 || isDevelopmentEnvironment()) {
|
|
41
|
-
noCache = true;
|
|
42
|
-
revalidate = undefined;
|
|
43
|
-
}
|
|
44
|
-
return fetch(req, {
|
|
45
|
-
...init,
|
|
46
|
-
cache: noCache ? 'no-cache' : 'force-cache',
|
|
47
|
-
next: {
|
|
48
|
-
revalidate,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ManifestClient } from '@uniformdev/context/api';
|
|
2
|
-
import { getManifestRevalidateInterval } from '../config/helpers';
|
|
3
|
-
import { isDevelopmentEnvironment } from '../utils/draft';
|
|
4
|
-
export const getManifestClient = (options) => {
|
|
5
|
-
const manifestClient = new ManifestClient({
|
|
6
|
-
apiHost: process.env.UNIFORM_API_HOST || process.env.UNIFORM_CLI_BASE_URL,
|
|
7
|
-
apiKey: process.env.UNIFORM_API_KEY,
|
|
8
|
-
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
9
|
-
fetch: (req, init) => {
|
|
10
|
-
let revalidate = options === null || options === void 0 ? void 0 : options.revalidate;
|
|
11
|
-
let noCache = false;
|
|
12
|
-
if (revalidate === -1 || isDevelopmentEnvironment()) {
|
|
13
|
-
noCache = true;
|
|
14
|
-
revalidate = undefined;
|
|
15
|
-
}
|
|
16
|
-
return fetch(req, {
|
|
17
|
-
...init,
|
|
18
|
-
cache: noCache ? 'no-cache' : 'force-cache',
|
|
19
|
-
next: {
|
|
20
|
-
revalidate,
|
|
21
|
-
tags: ['manifest'],
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
return manifestClient;
|
|
27
|
-
};
|
|
28
|
-
export const getManifestFromApi = (options) => {
|
|
29
|
-
const manifestClient = getManifestClient({
|
|
30
|
-
revalidate: getManifestRevalidateInterval(options),
|
|
31
|
-
});
|
|
32
|
-
return manifestClient.get();
|
|
33
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ProjectMapClient } from '@uniformdev/project-map';
|
|
2
|
-
export const getProjectMapClient = (options) => {
|
|
3
|
-
const manifestClient = new ProjectMapClient({
|
|
4
|
-
apiHost: process.env.UNIFORM_API_HOST || process.env.UNIFORM_CLI_BASE_URL,
|
|
5
|
-
apiKey: process.env.UNIFORM_API_KEY,
|
|
6
|
-
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
7
|
-
fetch: (req, init) => {
|
|
8
|
-
return fetch(req, {
|
|
9
|
-
...init,
|
|
10
|
-
next: {
|
|
11
|
-
revalidate: options === null || options === void 0 ? void 0 : options.revalidate,
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
return manifestClient;
|
|
17
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { CANVAS_EDITOR_STATE, RouteClient } from '@uniformdev/canvas';
|
|
2
|
-
import { isDevelopmentEnvironment } from '../utils/draft';
|
|
3
|
-
import { buildPathTag } from '../utils/tag';
|
|
4
|
-
export const getRouteClient = (options) => {
|
|
5
|
-
const client = new RouteClient({
|
|
6
|
-
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
7
|
-
apiKey: process.env.UNIFORM_API_KEY,
|
|
8
|
-
edgeApiHost: process.env.UNIFORM_EDGE_API_HOST,
|
|
9
|
-
fetch: (req, init) => {
|
|
10
|
-
let requestedUrl;
|
|
11
|
-
if (typeof req === 'string') {
|
|
12
|
-
requestedUrl = new URL(req);
|
|
13
|
-
}
|
|
14
|
-
else if (req instanceof URL) {
|
|
15
|
-
requestedUrl = req;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
requestedUrl = new URL(req.url);
|
|
19
|
-
}
|
|
20
|
-
const tags = [];
|
|
21
|
-
let state;
|
|
22
|
-
if (requestedUrl) {
|
|
23
|
-
// this is here so this code breaks if parameters change here
|
|
24
|
-
const pathKey = 'path';
|
|
25
|
-
const stateKey = 'state';
|
|
26
|
-
const path = requestedUrl.searchParams.get(pathKey);
|
|
27
|
-
state = parseInt(requestedUrl.searchParams.get(stateKey) || '', 10);
|
|
28
|
-
if (path) {
|
|
29
|
-
// at this point, we do not know if this path is dynamic or not
|
|
30
|
-
// so apply each segment as a tag so we can clear any segment, ie:
|
|
31
|
-
// /authors/alex would add /authors and /authors/alex as tags
|
|
32
|
-
const pieces = path.split('/');
|
|
33
|
-
for (let i = 0; i < pieces.length; i++) {
|
|
34
|
-
const segmentPieces = pieces.slice(0, i + 1);
|
|
35
|
-
const segment = segmentPieces.join('/');
|
|
36
|
-
tags.push(buildPathTag(segment));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
let revalidate;
|
|
41
|
-
let noCache = false;
|
|
42
|
-
if (options === null || options === void 0 ? void 0 : options.revalidate) {
|
|
43
|
-
revalidate = options.revalidate;
|
|
44
|
-
}
|
|
45
|
-
if (revalidate === -1 || isDevelopmentEnvironment()) {
|
|
46
|
-
noCache = true;
|
|
47
|
-
revalidate = undefined;
|
|
48
|
-
}
|
|
49
|
-
const extraHeaders = {};
|
|
50
|
-
if (state === CANVAS_EDITOR_STATE) {
|
|
51
|
-
extraHeaders['x-bypass-cache'] = 'true';
|
|
52
|
-
}
|
|
53
|
-
return fetch(req, {
|
|
54
|
-
...init,
|
|
55
|
-
cache: noCache ? 'no-cache' : 'force-cache',
|
|
56
|
-
next: {
|
|
57
|
-
revalidate,
|
|
58
|
-
tags: tags.length ? tags : undefined,
|
|
59
|
-
},
|
|
60
|
-
headers: {
|
|
61
|
-
...((init === null || init === void 0 ? void 0 : init.headers) || {}),
|
|
62
|
-
...extraHeaders,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
return client;
|
|
68
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CANVAS_LOCALIZATION_TYPE } from '@uniformdev/canvas';
|
|
3
|
-
const wrapperStyles = {
|
|
4
|
-
display: 'flex',
|
|
5
|
-
flexDirection: 'column',
|
|
6
|
-
gap: '0.5rem',
|
|
7
|
-
borderLeft: '4px solid #e42535',
|
|
8
|
-
padding: '16px',
|
|
9
|
-
fontSize: '16px',
|
|
10
|
-
borderRadius: '0 8px 8px 0',
|
|
11
|
-
margin: '8px',
|
|
12
|
-
backgroundColor: 'rgba(255, 255, 255, 0.45)',
|
|
13
|
-
color: '#1d3557',
|
|
14
|
-
};
|
|
15
|
-
export function DefaultNotImplementedComponent(props) {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
-
const componentType = (_a = props.component) === null || _a === void 0 ? void 0 : _a.type;
|
|
18
|
-
if (!componentType) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
if (componentType === CANVAS_LOCALIZATION_TYPE) {
|
|
22
|
-
return (_jsx("div", { style: wrapperStyles, children: _jsxs("p", { children: ["Seems like localization is not enabled in your application. Please read our documentation on how to", ' ', _jsx("a", { href: "https://docs.uniform.app/guides/composition/localization#activate-front-end", target: "_blank", style: { fontWeight: 'bolder', textDecoration: 'underline' }, rel: "noreferrer", children: "enable localization in your front-end application." })] }) }));
|
|
23
|
-
}
|
|
24
|
-
const proposedFileName = `${componentType[0].toUpperCase()}${componentType.substring(1)}`;
|
|
25
|
-
const probableProps = Object.keys((_b = props.component.parameters) !== null && _b !== void 0 ? _b : {});
|
|
26
|
-
const probableSlots = Object.keys((_c = props.component.slots) !== null && _c !== void 0 ? _c : {});
|
|
27
|
-
return (_jsxs("div", { style: wrapperStyles, children: [_jsx("h2", { style: { fontSize: '1.2rem' }, children: "Unknown Component" }), _jsxs("p", { children: ["Received request from Uniform to render a component with the public ID: ", _jsx("code", { children: componentType }), "."] }), _jsxs("p", { children: [_jsx("code", { children: "<UniformComposition />" }), " does not have ", _jsx("code", { children: componentType }), " mapped to a React component yet."] }), _jsx("p", { children: "To teach your app how to render this component:" }), ' ', _jsxs("ul", { style: {
|
|
28
|
-
listStyleType: 'disc',
|
|
29
|
-
marginLeft: '1rem',
|
|
30
|
-
display: 'flex',
|
|
31
|
-
flexDirection: 'column',
|
|
32
|
-
gap: '0.5rem',
|
|
33
|
-
}, children: [_jsxs("li", { children: ["Create a React component and register it with Uniform, for example", _jsx("pre", { children: `function ${proposedFileName}(${probableProps.length > 0 ? `{ ${probableProps.join(', ')} }` : ''}) {
|
|
34
|
-
return (
|
|
35
|
-
<div>
|
|
36
|
-
${proposedFileName}!
|
|
37
|
-
${probableSlots.length > 0
|
|
38
|
-
? probableSlots.map((slot) => `<UniformSlot name="${slot}" />`).join('\n ')
|
|
39
|
-
: ''}
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
registerUniformComponent({ type: "${componentType}", component: ${proposedFileName} })` }), _jsxs("details", { children: [_jsx("summary", { style: { cursor: 'pointer' }, children: "Props that your React component will receive" }), _jsx("pre", { children: JSON.stringify(props, null, 2) })] })] }), _jsxs("li", { children: ["Import the component into the file where ", _jsx("code", { children: "<UniformComposition />" }), " is defined, for example ", _jsx("pre", { children: `import "../components/${proposedFileName}.tsx"` })] })] }), ' ', _jsxs("p", { children: ["Need more help?", ' ', _jsx("a", { href: "https://docs.uniform.app/docs/guides/composition/rendering", target: "_blank", rel: "noreferrer", style: { textDecoration: 'underline' }, children: "Check out the documentation." })] })] }));
|
|
45
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import Script from 'next/script';
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
|
-
import { useUniformContext } from '../hooks/useUniformContext';
|
|
6
|
-
const isGtagConfigured = () => {
|
|
7
|
-
return typeof window !== 'undefined' && typeof window.gtag === 'function';
|
|
8
|
-
};
|
|
9
|
-
export const GoogleTagManagerAnalytics = (props) => {
|
|
10
|
-
const { seenComponents } = useUniformContext();
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (!(seenComponents === null || seenComponents === void 0 ? void 0 : seenComponents.length)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (!isGtagConfigured()) {
|
|
16
|
-
// eslint-disable-next-line no-console
|
|
17
|
-
console.warn('Google Tag Manager is not configured. Please add the gtag script to your site.');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
seenComponents.forEach((component) => {
|
|
21
|
-
var _a, _b, _c, _d, _e;
|
|
22
|
-
if (component.type === 'personalization') {
|
|
23
|
-
(_b = (_a = window).gtag) === null || _b === void 0 ? void 0 : _b.call(_a, 'event', component.id, {
|
|
24
|
-
event_category: 'Uniform Personalization',
|
|
25
|
-
event_label: component.variants.join(', '),
|
|
26
|
-
is_control_group: component.control ? 1 : 0,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else if (component.type === 'test') {
|
|
30
|
-
(_d = (_c = window).gtag) === null || _d === void 0 ? void 0 : _d.call(_c, 'event', component.id, {
|
|
31
|
-
event_category: 'Uniform AB Testing',
|
|
32
|
-
event_label: (_e = component.variant) !== null && _e !== void 0 ? _e : 'No Variant',
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}, [seenComponents]);
|
|
37
|
-
return (_jsx(_Fragment, { children: Boolean(props === null || props === void 0 ? void 0 : props.measurementId) && (_jsxs(_Fragment, { children: [_jsx(Script, { src: `https://www.googletagmanager.com/gtag/js?id=${props.measurementId}`, strategy: "afterInteractive" }), _jsx(Script, { id: "google-analytics", strategy: "afterInteractive", children: `
|
|
38
|
-
window.dataLayer = window.dataLayer || [];
|
|
39
|
-
function gtag(){window.dataLayer.push(arguments);}
|
|
40
|
-
gtag('js', new Date());
|
|
41
|
-
|
|
42
|
-
gtag('config', '${props.measurementId}');
|
|
43
|
-
` })] })) }));
|
|
44
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type ComponentInstance, type RootComponentInstance, RouteGetResponseComposition } from '@uniformdev/canvas';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiResponse'> & {
|
|
4
|
-
composition: RootComponentInstance;
|
|
5
|
-
path: string;
|
|
6
|
-
state?: number;
|
|
7
|
-
searchParams: {
|
|
8
|
-
[key: string]: string | undefined;
|
|
9
|
-
} | undefined;
|
|
10
|
-
cookieValue: string | undefined;
|
|
11
|
-
isDraftMode: boolean;
|
|
12
|
-
isContextualEditing: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type ComponentProps<TProps = unknown> = TProps & {
|
|
15
|
-
component: ComponentInstance;
|
|
16
|
-
context: CompositionContext;
|
|
17
|
-
};
|
|
18
|
-
export type UniformComponentProps<TRenderProps = unknown> = {
|
|
19
|
-
data: ComponentInstance;
|
|
20
|
-
context: CompositionContext;
|
|
21
|
-
children?: ReactNode | ((props: ComponentProps<TRenderProps>) => JSX.Element);
|
|
22
|
-
};
|
|
23
|
-
export declare function UniformComponent({ data, children, context }: UniformComponentProps): import("react").FunctionComponentElement<{
|
|
24
|
-
children?: ReactNode;
|
|
25
|
-
}>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from 'react';
|
|
2
|
-
import { componentStoreResolver } from '../register/componentStoreResolver';
|
|
3
|
-
import { resolveChildren } from '../resolve/resolveChildren';
|
|
4
|
-
export function UniformComponent({ data, children, context }) {
|
|
5
|
-
const resolvedChildren = resolveChildren({
|
|
6
|
-
children,
|
|
7
|
-
data,
|
|
8
|
-
context,
|
|
9
|
-
hasParentLayout: false,
|
|
10
|
-
resolveRenderer: componentStoreResolver,
|
|
11
|
-
});
|
|
12
|
-
const childrenToRender = [resolvedChildren];
|
|
13
|
-
return createElement(Fragment, {}, childrenToRender);
|
|
14
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ContextState } from '@uniformdev/context';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export type SuspenseOptions = {
|
|
4
|
-
mode: 'off';
|
|
5
|
-
} | {
|
|
6
|
-
mode: 'fallback';
|
|
7
|
-
fallback: React.ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export type UniformCompositionProps = {
|
|
10
|
-
/**
|
|
11
|
-
* The params object from Next.js router. Used to resolve a composition.
|
|
12
|
-
*/
|
|
13
|
-
params: {
|
|
14
|
-
slug: string | string[];
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* The searchParams object from Next.js router. Used for signal evaluation.
|
|
18
|
-
*/
|
|
19
|
-
searchParams?: {
|
|
20
|
-
[key: string]: string | undefined;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Behavior of root Suspense component.
|
|
24
|
-
*/
|
|
25
|
-
suspense?: {
|
|
26
|
-
mode: 'off';
|
|
27
|
-
} | {
|
|
28
|
-
mode: 'fallback';
|
|
29
|
-
fallback: ReactNode;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Update state that should be added to the call to update before composition evaluation
|
|
33
|
-
*/
|
|
34
|
-
update?: Partial<ContextState>;
|
|
35
|
-
/**
|
|
36
|
-
* The children of the UniformComposition component.
|
|
37
|
-
*/
|
|
38
|
-
children?: ReactNode;
|
|
39
|
-
};
|
|
40
|
-
export declare const UniformComposition: ({ suspense, ...props }: UniformCompositionProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense } from 'react';
|
|
3
|
-
import { isDraftModeEnabled, isIncontextEditingEnabled } from '../utils/draft';
|
|
4
|
-
import { resolveComposition } from './retrieveRoute';
|
|
5
|
-
import { UniformComponent } from './UniformComponent';
|
|
6
|
-
import { UniformProvider } from './UniformContext';
|
|
7
|
-
import { UniformScript } from './UniformScript';
|
|
8
|
-
export const UniformComposition = ({ suspense = {
|
|
9
|
-
mode: 'off',
|
|
10
|
-
}, ...props }) => (_jsx(ConditionalWrapper, { options: suspense, children: _jsx(UniformCompositionInner, { ...props }) }));
|
|
11
|
-
const ConditionalWrapper = ({ children, options }) => {
|
|
12
|
-
if (options.mode === 'off') {
|
|
13
|
-
return _jsx(_Fragment, { children: children });
|
|
14
|
-
}
|
|
15
|
-
return _jsx(Suspense, { fallback: options.fallback, children: children });
|
|
16
|
-
};
|
|
17
|
-
const UniformCompositionInner = async ({ params, searchParams, update, children, }) => {
|
|
18
|
-
const { composition: evaluatedComposition, cookieValue, path, searchParams: evaluatedSearchParams, seenComponents, isCanvasEditing, ...rest } = await resolveComposition({
|
|
19
|
-
params,
|
|
20
|
-
searchParams,
|
|
21
|
-
update,
|
|
22
|
-
});
|
|
23
|
-
const context = {
|
|
24
|
-
composition: evaluatedComposition,
|
|
25
|
-
path,
|
|
26
|
-
searchParams,
|
|
27
|
-
cookieValue,
|
|
28
|
-
isDraftMode: isDraftModeEnabled({ searchParams }),
|
|
29
|
-
isContextualEditing: isIncontextEditingEnabled({
|
|
30
|
-
searchParams,
|
|
31
|
-
}),
|
|
32
|
-
...rest,
|
|
33
|
-
};
|
|
34
|
-
return (_jsxs(UniformProvider, { cookieValue: cookieValue, seenComponents: seenComponents, children: [_jsx(UniformScript, { enabled: isCanvasEditing }), _jsx(UniformComponent, { data: evaluatedComposition, context: context }), Boolean(children) && children] }));
|
|
35
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { SeenUniformComponent } from '../models';
|
|
3
|
-
export type UniformContextProps = {
|
|
4
|
-
cookieValue: string | undefined;
|
|
5
|
-
seenComponents: SeenUniformComponent[] | undefined;
|
|
6
|
-
};
|
|
7
|
-
export declare const UniformContext: import("react").Context<UniformContextProps>;
|
|
8
|
-
export declare const UniformProvider: ({ children, cookieValue, seenComponents, }: PropsWithChildren<UniformContextProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useEffect } from 'react';
|
|
4
|
-
import { removeUniformCookie, setUniformCookie } from '../cookie';
|
|
5
|
-
export const UniformContext = createContext({
|
|
6
|
-
cookieValue: undefined,
|
|
7
|
-
seenComponents: undefined,
|
|
8
|
-
});
|
|
9
|
-
export const UniformProvider = ({ children, cookieValue, seenComponents, }) => {
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (cookieValue) {
|
|
12
|
-
setUniformCookie(cookieValue);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
removeUniformCookie();
|
|
16
|
-
}
|
|
17
|
-
}, [cookieValue]);
|
|
18
|
-
return (_jsx(UniformContext.Provider, { value: { cookieValue, seenComponents }, children: children }));
|
|
19
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ComponentInstance } from '@uniformdev/canvas';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { RenderRichTextComponentResolver } from './types';
|
|
4
|
-
export type UniformRichTextProps = {
|
|
5
|
-
/**
|
|
6
|
-
* The name of the HTML tag to render.
|
|
7
|
-
* @default "div"
|
|
8
|
-
*/
|
|
9
|
-
as?: React.ElementType;
|
|
10
|
-
/** The ID of the parameter. */
|
|
11
|
-
parameterId: string;
|
|
12
|
-
/**
|
|
13
|
-
* A function which can provide a custom react component
|
|
14
|
-
* for rendering a rich text node
|
|
15
|
-
*/
|
|
16
|
-
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
17
|
-
/** The component instance. */
|
|
18
|
-
component: ComponentInstance;
|
|
19
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
20
|
-
/**
|
|
21
|
-
* Adds rendering support for Uniform Rich Text parameters
|
|
22
|
-
*/
|
|
23
|
-
export declare const UniformRichText: React.ForwardRefExoticComponent<{
|
|
24
|
-
/**
|
|
25
|
-
* The name of the HTML tag to render.
|
|
26
|
-
* @default "div"
|
|
27
|
-
*/
|
|
28
|
-
as?: React.ElementType<any> | undefined;
|
|
29
|
-
/** The ID of the parameter. */
|
|
30
|
-
parameterId: string;
|
|
31
|
-
/**
|
|
32
|
-
* A function which can provide a custom react component
|
|
33
|
-
* for rendering a rich text node
|
|
34
|
-
*/
|
|
35
|
-
resolveRichTextRenderer?: RenderRichTextComponentResolver | undefined;
|
|
36
|
-
/** The component instance. */
|
|
37
|
-
component: ComponentInstance;
|
|
38
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<unknown>>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isRichTextValue, isRichTextValueConsideredEmpty, } from '@uniformdev/richtext';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { UniformRichTextNode } from './UniformRichTextNode';
|
|
5
|
-
/**
|
|
6
|
-
* Adds rendering support for Uniform Rich Text parameters
|
|
7
|
-
*/
|
|
8
|
-
export const UniformRichText = React.forwardRef(function UniformRichText({ parameterId, component, resolveRichTextRenderer, as: Tag = 'div', ...props }, ref) {
|
|
9
|
-
var _a;
|
|
10
|
-
const parameter = (_a = component === null || component === void 0 ? void 0 : component.parameters) === null || _a === void 0 ? void 0 : _a[parameterId];
|
|
11
|
-
const value = parameter === null || parameter === void 0 ? void 0 : parameter.value;
|
|
12
|
-
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
13
|
-
return null;
|
|
14
|
-
return Tag === null ? (_jsx(UniformRichTextNode, { node: value.root, resolveRichTextRenderer: resolveRichTextRenderer })) : (_jsx(Tag, { ref: ref, ...props, children: _jsx(UniformRichTextNode, { node: value.root, resolveRichTextRenderer: resolveRichTextRenderer }) }));
|
|
15
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RichTextNode } from '@uniformdev/richtext';
|
|
2
|
-
import { RenderRichTextComponentResolver } from './types';
|
|
3
|
-
export type UniformRichTextNodeProps = {
|
|
4
|
-
node: RichTextNode;
|
|
5
|
-
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Render a single RichText node
|
|
9
|
-
*/
|
|
10
|
-
export declare function UniformRichTextNode({ node, ...props }: UniformRichTextNodeProps): import("react/jsx-runtime").JSX.Element | null;
|