@uniformdev/canvas-next-rsc 20.31.1-alpha.1 → 20.31.1-alpha.185
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-0pvEHduc.d.mts +64 -0
- package/dist/UniformComposition-0pvEHduc.d.ts +77 -0
- package/dist/UniformComposition-38e22896.d.ts +74 -0
- package/dist/UniformComposition-B-Z17dUt.d.mts +67 -0
- package/dist/UniformComposition-B-Z17dUt.d.ts +80 -0
- package/dist/UniformComposition-D4tBQ2U4.d.mts +64 -0
- package/dist/UniformComposition-D4tBQ2U4.d.ts +77 -0
- package/dist/UniformComposition-Dw55RFP6.d.mts +67 -0
- package/dist/UniformComposition-Dw55RFP6.d.ts +67 -0
- package/dist/UniformComposition-IWWzoI_H.d.mts +82 -0
- package/dist/UniformComposition-IWWzoI_H.d.ts +82 -0
- package/dist/UniformComposition-d178d865.d.ts +77 -0
- package/dist/actions/updateContext.d.ts +2 -0
- package/dist/actions/updateContext.js +17 -0
- package/dist/client/canvasClient.d.ts +5 -0
- package/dist/client/canvasClient.js +53 -0
- package/dist/client/manifestClient.d.ts +209 -0
- package/dist/client/manifestClient.js +33 -0
- package/dist/client/projectMapClient.d.ts +5 -0
- package/dist/client/projectMapClient.js +17 -0
- package/dist/client/routeClient.d.ts +5 -0
- package/dist/client/routeClient.js +68 -0
- package/dist/components/DefaultNotImplementedComponent.d.ts +4 -0
- package/dist/components/DefaultNotImplementedComponent.js +45 -0
- package/dist/components/GoogleTagManagerAnalytics.d.ts +3 -0
- package/dist/components/GoogleTagManagerAnalytics.js +44 -0
- package/dist/components/UniformComponent.d.ts +35 -0
- package/dist/components/UniformComponent.js +14 -0
- package/dist/components/UniformComposition.d.ts +47 -0
- package/dist/components/UniformComposition.js +35 -0
- package/dist/components/UniformContext.d.ts +13 -0
- package/dist/components/UniformContext.js +19 -0
- package/dist/components/UniformRichText.d.ts +42 -0
- package/dist/components/UniformRichText.js +15 -0
- package/dist/components/UniformRichTextNode.d.ts +14 -0
- package/dist/components/UniformRichTextNode.js +49 -0
- package/dist/components/UniformScript.d.ts +5 -0
- package/dist/components/UniformScript.js +49 -0
- package/dist/components/UniformSlot.d.ts +48 -0
- package/dist/components/UniformSlot.js +38 -0
- package/dist/components/UniformText.d.ts +10 -0
- package/dist/components/UniformText.js +5 -0
- package/dist/components/__tests__/evaluateComposition.spec.d.ts +1 -0
- package/dist/components/__tests__/evaluateComposition.spec.js +80 -0
- package/dist/components/convertComponentToProps.d.ts +18 -0
- package/dist/components/convertComponentToProps.js +22 -0
- package/dist/components/evaluateComposition.d.ts +32 -0
- package/dist/components/evaluateComposition.js +183 -0
- package/dist/components/getEnrichmentTags.d.ts +5 -0
- package/dist/components/getEnrichmentTags.js +13 -0
- package/dist/components/getUniformContext.d.ts +10 -0
- package/dist/components/getUniformContext.js +17 -0
- package/dist/components/nodes/HeadingRichTextNode.d.ts +2 -0
- package/dist/components/nodes/HeadingRichTextNode.js +6 -0
- package/dist/components/nodes/LinebreakRichTextNode.d.ts +2 -0
- package/dist/components/nodes/LinebreakRichTextNode.js +4 -0
- package/dist/components/nodes/LinkRichTextNode.d.ts +2 -0
- package/dist/components/nodes/LinkRichTextNode.js +6 -0
- package/dist/components/nodes/ListItemRichTextNode.d.ts +2 -0
- package/dist/components/nodes/ListItemRichTextNode.js +5 -0
- package/dist/components/nodes/ListRichTextNode.d.ts +2 -0
- package/dist/components/nodes/ListRichTextNode.js +6 -0
- package/dist/components/nodes/ParagraphRichTextNode.d.ts +2 -0
- package/dist/components/nodes/ParagraphRichTextNode.js +6 -0
- package/dist/components/nodes/TabRichTextNode.d.ts +2 -0
- package/dist/components/nodes/TabRichTextNode.js +4 -0
- package/dist/components/nodes/TextRichTextNode.d.ts +2 -0
- package/dist/components/nodes/TextRichTextNode.js +9 -0
- package/dist/components/renderComponent.d.ts +26 -0
- package/dist/components/renderComponent.js +52 -0
- package/dist/components/resolvePath.d.ts +5 -0
- package/dist/components/resolvePath.js +34 -0
- package/dist/components/retrieveRoute.d.ts +198 -0
- package/dist/components/retrieveRoute.js +146 -0
- package/dist/components/types.d.ts +15 -0
- package/dist/components/types.js +1 -0
- package/dist/config/helpers.d.ts +23 -0
- package/dist/config/helpers.js +34 -0
- package/dist/config/models.d.ts +51 -0
- package/dist/config/models.js +1 -0
- package/dist/config/uniform.server.config.d.ts +3 -0
- package/dist/config/uniform.server.config.js +4 -0
- package/dist/cookie/index.d.ts +12 -0
- package/dist/cookie/index.js +21 -0
- package/dist/handler/createPreviewGETRouteHandler.d.ts +1 -0
- package/dist/handler/createPreviewGETRouteHandler.js +43 -0
- package/dist/handler/createPreviewPOSTRouteHandler.d.ts +1 -0
- package/dist/handler/createPreviewPOSTRouteHandler.js +88 -0
- package/dist/handler/createUniformRouteHandler.d.ts +4 -0
- package/dist/handler/createUniformRouteHandler.js +10 -0
- package/dist/handler/helpers.d.ts +17 -0
- package/dist/handler/helpers.js +148 -0
- package/dist/handler/messages/handleCompositionChanged.d.ts +2 -0
- package/dist/handler/messages/handleCompositionChanged.js +9 -0
- package/dist/handler/messages/handleCompositionDeleted.d.ts +2 -0
- package/dist/handler/messages/handleCompositionDeleted.js +9 -0
- package/dist/handler/messages/handleCompositionPublished.d.ts +2 -0
- package/dist/handler/messages/handleCompositionPublished.js +9 -0
- package/dist/handler/messages/handleManifestPublished.d.ts +2 -0
- package/dist/handler/messages/handleManifestPublished.js +10 -0
- package/dist/handler/messages/handleProjectMapNodeDelete.d.ts +2 -0
- package/dist/handler/messages/handleProjectMapNodeDelete.js +21 -0
- package/dist/handler/messages/handleProjectMapNodeInsert.d.ts +2 -0
- package/dist/handler/messages/handleProjectMapNodeInsert.js +21 -0
- package/dist/handler/messages/handleProjectMapNodeUpdate.d.ts +2 -0
- package/dist/handler/messages/handleProjectMapNodeUpdate.js +22 -0
- package/dist/handler/messages/handleRedirectDelete.d.ts +2 -0
- package/dist/handler/messages/handleRedirectDelete.js +15 -0
- package/dist/handler/messages/handleRedirectInsert.d.ts +2 -0
- package/dist/handler/messages/handleRedirectInsert.js +15 -0
- package/dist/handler/messages/handleRedirectUpdate.d.ts +2 -0
- package/dist/handler/messages/handleRedirectUpdate.js +15 -0
- package/dist/hooks/useForgetMe.d.ts +4 -0
- package/dist/hooks/useForgetMe.js +10 -0
- package/dist/hooks/useToggleConsent.d.ts +7 -0
- package/dist/hooks/useToggleConsent.js +22 -0
- package/dist/hooks/useUniformContext.d.ts +1 -0
- package/dist/hooks/useUniformContext.js +3 -0
- package/dist/index.esm.js +17 -26
- package/dist/index.js +17 -26
- package/dist/index.mjs +17 -26
- package/dist/models/index.d.ts +30 -0
- package/dist/models/index.js +1 -0
- package/dist/register/componentStore.d.ts +1 -0
- package/dist/register/componentStore.js +2 -0
- package/dist/register/componentStoreResolver.d.ts +4 -0
- package/dist/register/componentStoreResolver.js +5 -0
- package/dist/register/createComponentStore.d.ts +12 -0
- package/dist/register/createComponentStore.js +13 -0
- package/dist/register/createComponentStoreResolver.d.ts +12 -0
- package/dist/register/createComponentStoreResolver.js +9 -0
- package/dist/register/getTypeWithVariant.d.ts +1 -0
- package/dist/register/getTypeWithVariant.js +1 -0
- package/dist/register/registerUniformComponent.d.ts +10 -0
- package/dist/register/registerUniformComponent.js +8 -0
- package/dist/resolve/resolveChildren.d.ts +17 -0
- package/dist/resolve/resolveChildren.js +20 -0
- package/dist/score/index.d.ts +3 -0
- package/dist/score/index.js +114 -0
- package/dist/utils/__tests__/apply.spec.d.ts +1 -0
- package/dist/utils/__tests__/apply.spec.js +358 -0
- package/dist/utils/__tests__/diff.spec.d.ts +1 -0
- package/dist/utils/__tests__/diff.spec.js +394 -0
- package/dist/utils/apply.d.ts +10 -0
- package/dist/utils/apply.js +124 -0
- package/dist/utils/comp.d.ts +25 -0
- package/dist/utils/comp.js +65 -0
- package/dist/utils/diff.d.ts +58 -0
- package/dist/utils/diff.js +144 -0
- package/dist/utils/draft.d.ts +20 -0
- package/dist/utils/draft.js +22 -0
- package/dist/utils/tag.d.ts +2 -0
- package/dist/utils/tag.js +7 -0
- package/dist/utils/url.d.ts +1 -0
- package/dist/utils/url.js +10 -0
- package/package.json +14 -14
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const isSvixMessage: (request: Request) => Promise<{
|
|
2
|
+
looksLikeMessage: boolean;
|
|
3
|
+
validation: boolean;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const processCompositionChange: (compositionId: string) => Promise<{
|
|
6
|
+
tags: string[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare const buildProjectMapNodePaths: (path: string) => string[];
|
|
9
|
+
export declare const getPathName: (url: string) => string;
|
|
10
|
+
export declare const processRedirectChange: (sourceUrl: string) => Promise<{
|
|
11
|
+
tags: string[];
|
|
12
|
+
}>;
|
|
13
|
+
export declare const processEdgeConfigChange: ({ source_url }: { source_url: string }) => Promise<void>;
|
|
14
|
+
export type MessageHandlerResponse = {
|
|
15
|
+
tags: string[];
|
|
16
|
+
};
|
|
17
|
+
export type SvixMessageHandler = (body: any) => Promise<MessageHandlerResponse | undefined>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { parseConnectionString } from '@vercel/edge-config';
|
|
2
|
+
import { Webhook } from 'svix';
|
|
3
|
+
import { getProjectMapClient } from '../client/projectMapClient';
|
|
4
|
+
import { getRouteClient } from '../client/routeClient';
|
|
5
|
+
import { getServerConfig } from '../config/helpers';
|
|
6
|
+
import { buildCompositionTag, buildPathTag } from '../utils/tag';
|
|
7
|
+
export const isSvixMessage = async (request) => {
|
|
8
|
+
const requiredHeaders = ['svix-id', 'svix-timestamp', 'svix-signature'];
|
|
9
|
+
const hasAllRequiredHeaders = requiredHeaders.every((header) => request.headers.has(header));
|
|
10
|
+
if (!hasAllRequiredHeaders) {
|
|
11
|
+
return {
|
|
12
|
+
looksLikeMessage: false,
|
|
13
|
+
validation: false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (typeof process.env.UNIFORM_WEBHOOK_SECRET !== 'undefined') {
|
|
17
|
+
// https://docs.svix.com/receiving/verifying-payloads/how
|
|
18
|
+
const payload = await request.clone().text();
|
|
19
|
+
const headers = Object.fromEntries(request.headers.entries());
|
|
20
|
+
const wh = new Webhook(process.env.UNIFORM_WEBHOOK_SECRET);
|
|
21
|
+
try {
|
|
22
|
+
wh.verify(payload, headers);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return {
|
|
26
|
+
looksLikeMessage: true,
|
|
27
|
+
validation: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
looksLikeMessage: true,
|
|
33
|
+
validation: true,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export const processCompositionChange = async (compositionId) => {
|
|
37
|
+
const projectMapClient = getProjectMapClient({
|
|
38
|
+
revalidate: 0,
|
|
39
|
+
});
|
|
40
|
+
const { nodes } = await projectMapClient.getNodes({
|
|
41
|
+
compositionId,
|
|
42
|
+
});
|
|
43
|
+
const tags = [];
|
|
44
|
+
if (nodes) {
|
|
45
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
46
|
+
const node = nodes[i];
|
|
47
|
+
await processEdgeConfigChange({
|
|
48
|
+
source_url: node.path,
|
|
49
|
+
});
|
|
50
|
+
tags.push(...buildProjectMapNodePaths(node.path));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
tags.push(buildCompositionTag(compositionId));
|
|
54
|
+
return {
|
|
55
|
+
tags,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export const buildProjectMapNodePaths = (path) => {
|
|
59
|
+
const tags = [];
|
|
60
|
+
const isDynamic = path.includes(':');
|
|
61
|
+
if (!isDynamic) {
|
|
62
|
+
tags.push(buildPathTag(path));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const pieces = path.split('/');
|
|
66
|
+
const invalidatePieces = [];
|
|
67
|
+
for (let j = 0; j < pieces.length; j++) {
|
|
68
|
+
const piece = pieces[j];
|
|
69
|
+
if (piece.startsWith(':')) {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
invalidatePieces.push(piece);
|
|
73
|
+
}
|
|
74
|
+
const toInvalidate = invalidatePieces.join('/');
|
|
75
|
+
tags.push(buildPathTag(toInvalidate));
|
|
76
|
+
}
|
|
77
|
+
return tags;
|
|
78
|
+
};
|
|
79
|
+
export const getPathName = (url) => {
|
|
80
|
+
try {
|
|
81
|
+
const { pathname } = new URL(url);
|
|
82
|
+
return pathname;
|
|
83
|
+
}
|
|
84
|
+
catch (_a) {
|
|
85
|
+
return url;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export const processRedirectChange = async (sourceUrl) => {
|
|
89
|
+
const tags = [];
|
|
90
|
+
const pathName = getPathName(sourceUrl);
|
|
91
|
+
tags.push(buildPathTag(pathName));
|
|
92
|
+
return {
|
|
93
|
+
tags,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export const processEdgeConfigChange = async ({ source_url }) => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
if (!process.env.UNIFORM_VERCEL_EDGE_CONFIG_TOKEN) {
|
|
99
|
+
// eslint-disable-next-line no-console
|
|
100
|
+
console.warn('UNIFORM_VERCEL_EDGE_CONFIG_TOKEN is not set, skipping edge redirect upsert');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const config = getServerConfig();
|
|
104
|
+
const routeClient = getRouteClient({
|
|
105
|
+
revalidate: -1,
|
|
106
|
+
});
|
|
107
|
+
const route = await routeClient.getRoute({
|
|
108
|
+
path: source_url,
|
|
109
|
+
});
|
|
110
|
+
let valueToStore = undefined;
|
|
111
|
+
const shouldSaveRedirect = route.type === 'redirect' && ((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.edgeRedirects);
|
|
112
|
+
const shouldSaveComposition = route.type === 'composition' && ((_b = config.experimental) === null || _b === void 0 ? void 0 : _b.edgeCompositions);
|
|
113
|
+
if (shouldSaveRedirect || shouldSaveComposition) {
|
|
114
|
+
valueToStore = route;
|
|
115
|
+
}
|
|
116
|
+
const sourcePath = getPathName(source_url);
|
|
117
|
+
const soucrcePathKey = buildPathTag(sourcePath);
|
|
118
|
+
const { id } = parseConnectionString(process.env.EDGE_CONFIG) || {};
|
|
119
|
+
if (!id) {
|
|
120
|
+
// eslint-disable-next-line no-console
|
|
121
|
+
console.warn('EDGE_CONFIG is not set or not a connection string, skipping edge redirect upsert');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const url = new URL(`https://api.vercel.com/v1/edge-config/${id}/items`);
|
|
125
|
+
if (process.env.UNIFORM_VERCEL_EDGE_CONFIG_TEAM_ID) {
|
|
126
|
+
url.searchParams.set('teamId', process.env.UNIFORM_VERCEL_EDGE_CONFIG_TEAM_ID);
|
|
127
|
+
}
|
|
128
|
+
const response = await fetch(url.toString(), {
|
|
129
|
+
method: 'PATCH',
|
|
130
|
+
headers: {
|
|
131
|
+
'Content-Type': 'application/json',
|
|
132
|
+
Authorization: `Bearer ${process.env.UNIFORM_VERCEL_EDGE_CONFIG_TOKEN}`,
|
|
133
|
+
},
|
|
134
|
+
body: JSON.stringify({
|
|
135
|
+
items: [
|
|
136
|
+
{
|
|
137
|
+
operation: valueToStore ? 'upsert' : 'delete',
|
|
138
|
+
key: soucrcePathKey.replace(/\W+/g, ''),
|
|
139
|
+
value: valueToStore !== null && valueToStore !== void 0 ? valueToStore : null,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
}),
|
|
143
|
+
});
|
|
144
|
+
if (!response.ok) {
|
|
145
|
+
// eslint-disable-next-line no-console
|
|
146
|
+
console.warn(`Failed to upsert edge redirect for ${source_url}`, await response.text());
|
|
147
|
+
}
|
|
148
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompositionChangedDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { processCompositionChange } from '../helpers';
|
|
3
|
+
export const handleCompositionChanged = async (body) => {
|
|
4
|
+
const parsed = CompositionChangedDefinition.schema.safeParse(body);
|
|
5
|
+
if (!parsed.success) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return processCompositionChange(parsed.data.id);
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompositionDeletedDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { processCompositionChange } from '../helpers';
|
|
3
|
+
export const handleCompositionDeleted = async (body) => {
|
|
4
|
+
const parsed = CompositionDeletedDefinition.schema.safeParse(body);
|
|
5
|
+
if (!parsed.success) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return processCompositionChange(parsed.data.id);
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompositionPublishedDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { processCompositionChange } from '../helpers';
|
|
3
|
+
export const handleCompositionPublished = async (body) => {
|
|
4
|
+
const parsed = CompositionPublishedDefinition.schema.safeParse(body);
|
|
5
|
+
if (!parsed.success) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return processCompositionChange(parsed.data.id);
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ManifestPublishedDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
export const handleManifestPublished = async (body) => {
|
|
3
|
+
const parsed = ManifestPublishedDefinition.schema.safeParse(body);
|
|
4
|
+
if (!parsed.success) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
tags: ['manifest'],
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ProjectMapNodeDeleteDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { getServerConfig } from '../../config/helpers';
|
|
3
|
+
import { buildProjectMapNodePaths, processEdgeConfigChange } from '../helpers';
|
|
4
|
+
export const handleProjectMapNodeDelete = async (body) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const parsed = ProjectMapNodeDeleteDefinition.schema.safeParse(body);
|
|
7
|
+
if (!parsed.success) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const tags = [];
|
|
11
|
+
tags.push(...buildProjectMapNodePaths(parsed.data.path));
|
|
12
|
+
const config = getServerConfig();
|
|
13
|
+
if ((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.edgeCompositions) {
|
|
14
|
+
await processEdgeConfigChange({
|
|
15
|
+
source_url: parsed.data.path,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
tags,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ProjectMapNodeInsertDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { getServerConfig } from '../../config/helpers';
|
|
3
|
+
import { buildProjectMapNodePaths, processEdgeConfigChange } from '../helpers';
|
|
4
|
+
export const handleProjectMapNodeInsert = async (body) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const parsed = ProjectMapNodeInsertDefinition.schema.safeParse(body);
|
|
7
|
+
if (!parsed.success) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const tags = [];
|
|
11
|
+
tags.push(...buildProjectMapNodePaths(parsed.data.path));
|
|
12
|
+
const config = getServerConfig();
|
|
13
|
+
if ((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.edgeCompositions) {
|
|
14
|
+
await processEdgeConfigChange({
|
|
15
|
+
source_url: parsed.data.path,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
tags,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ProjectMapNodeUpdateDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { getServerConfig } from '../../config/helpers';
|
|
3
|
+
import { buildProjectMapNodePaths, processEdgeConfigChange } from '../helpers';
|
|
4
|
+
export const handleProjectMapNodeUpdate = async (body) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const parsed = ProjectMapNodeUpdateDefinition.schema.safeParse(body);
|
|
7
|
+
if (!parsed.success) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const tags = [];
|
|
11
|
+
tags.push(...buildProjectMapNodePaths(parsed.data.path));
|
|
12
|
+
tags.push(...buildProjectMapNodePaths(parsed.data.previous_path));
|
|
13
|
+
const config = getServerConfig();
|
|
14
|
+
if ((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.edgeCompositions) {
|
|
15
|
+
await processEdgeConfigChange({
|
|
16
|
+
source_url: parsed.data.path,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
tags,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RedirectDeleteDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { getServerConfig } from '../../config/helpers';
|
|
3
|
+
import { processEdgeConfigChange, processRedirectChange } from '../helpers';
|
|
4
|
+
export const handleRedirectDelete = async (body) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const parsed = RedirectDeleteDefinition.schema.safeParse(body);
|
|
7
|
+
if (!parsed.success) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const config = getServerConfig();
|
|
11
|
+
if ((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.edgeRedirects) {
|
|
12
|
+
await processEdgeConfigChange(parsed.data);
|
|
13
|
+
}
|
|
14
|
+
return processRedirectChange(parsed.data.source_url);
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RedirectInsertDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { getServerConfig } from '../../config/helpers';
|
|
3
|
+
import { processEdgeConfigChange, processRedirectChange } from '../helpers';
|
|
4
|
+
export const handleRedirectInsert = async (body) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const parsed = RedirectInsertDefinition.schema.safeParse(body);
|
|
7
|
+
if (!parsed.success) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const config = getServerConfig();
|
|
11
|
+
if ((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.edgeRedirects) {
|
|
12
|
+
await processEdgeConfigChange(parsed.data);
|
|
13
|
+
}
|
|
14
|
+
return processRedirectChange(parsed.data.source_url);
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RedirectUpdateDefinition } from '@uniformdev/webhooks';
|
|
2
|
+
import { getServerConfig } from '../../config/helpers';
|
|
3
|
+
import { processEdgeConfigChange, processRedirectChange } from '../helpers';
|
|
4
|
+
export const handleRedirectUpdate = async (body) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const parsed = RedirectUpdateDefinition.schema.safeParse(body);
|
|
7
|
+
if (!parsed.success) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const config = getServerConfig();
|
|
11
|
+
if ((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.edgeRedirects) {
|
|
12
|
+
await processEdgeConfigChange(parsed.data);
|
|
13
|
+
}
|
|
14
|
+
return processRedirectChange(parsed.data.source_url);
|
|
15
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { removeUniformCookie, setUniformCookie } from '../cookie';
|
|
3
|
+
import { useUniformContext } from './useUniformContext';
|
|
4
|
+
/**
|
|
5
|
+
* Indicates whether or not a user has provided consent, and provides a function to toggle consent.
|
|
6
|
+
*/
|
|
7
|
+
export const useToggleConsent = () => {
|
|
8
|
+
const { cookieValue } = useUniformContext();
|
|
9
|
+
const hasConsent = !!cookieValue;
|
|
10
|
+
return {
|
|
11
|
+
consent: hasConsent,
|
|
12
|
+
toggleConsent: () => {
|
|
13
|
+
if (hasConsent) {
|
|
14
|
+
removeUniformCookie();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
setUniformCookie('~~');
|
|
18
|
+
}
|
|
19
|
+
window.location.reload();
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useUniformContext: () => import('../components/UniformContext').UniformContextProps;
|
package/dist/index.esm.js
CHANGED
|
@@ -29,7 +29,7 @@ var isDraftModeEnabled = async ({
|
|
|
29
29
|
var isIncontextEditingEnabled = ({
|
|
30
30
|
searchParams
|
|
31
31
|
}) => {
|
|
32
|
-
return
|
|
32
|
+
return (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) === "true";
|
|
33
33
|
};
|
|
34
34
|
var determinePreviewMode = ({
|
|
35
35
|
searchParams
|
|
@@ -628,18 +628,11 @@ var ContextUpdateTrigger = ({ path }) => {
|
|
|
628
628
|
// src/components/PersonalizeClientWrapper.tsx
|
|
629
629
|
import { PersonalizeClient } from "@uniformdev/canvas-next-rsc-client";
|
|
630
630
|
import React3 from "react";
|
|
631
|
-
var PersonalizeClientWrapper = (
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
count: props.count,
|
|
637
|
-
slots: props.slots,
|
|
638
|
-
trackingEventName: props.trackingEventName,
|
|
639
|
-
algorithm: props.algorithm,
|
|
640
|
-
indexes: []
|
|
641
|
-
}
|
|
642
|
-
);
|
|
631
|
+
var PersonalizeClientWrapper = ({
|
|
632
|
+
contextInstance,
|
|
633
|
+
...props
|
|
634
|
+
}) => {
|
|
635
|
+
return /* @__PURE__ */ React3.createElement(PersonalizeClient, { ...props, indexes: [] });
|
|
643
636
|
};
|
|
644
637
|
|
|
645
638
|
// src/components/PersonalizeServer.ts
|
|
@@ -678,19 +671,12 @@ var PersonalizeServer = (props) => {
|
|
|
678
671
|
import { PersonalizeClient as PersonalizeClient2 } from "@uniformdev/canvas-next-rsc-client";
|
|
679
672
|
import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
|
|
680
673
|
import React5 from "react";
|
|
681
|
-
var PersonalizeServerHybrid = (
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
count: props.count,
|
|
688
|
-
slots: props.slots,
|
|
689
|
-
trackingEventName: props.trackingEventName,
|
|
690
|
-
algorithm: props.algorithm,
|
|
691
|
-
indexes
|
|
692
|
-
}
|
|
693
|
-
);
|
|
674
|
+
var PersonalizeServerHybrid = ({
|
|
675
|
+
contextInstance,
|
|
676
|
+
...props
|
|
677
|
+
}) => {
|
|
678
|
+
const { indexes } = runPersonalization2({ ...props, contextInstance });
|
|
679
|
+
return /* @__PURE__ */ React5.createElement(PersonalizeClient2, { ...props, indexes });
|
|
694
680
|
};
|
|
695
681
|
|
|
696
682
|
// src/components/TestServer.ts
|
|
@@ -829,6 +815,11 @@ var UniformComposition = async ({
|
|
|
829
815
|
},
|
|
830
816
|
{}
|
|
831
817
|
),
|
|
818
|
+
compositionMetadata: {
|
|
819
|
+
compositionId: route.compositionApiResponse.composition._id,
|
|
820
|
+
matchedRoute: route.matchedRoute,
|
|
821
|
+
dynamicInputs: route.dynamicInputs
|
|
822
|
+
},
|
|
832
823
|
quirks: {
|
|
833
824
|
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
834
825
|
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ var isDraftModeEnabled = async ({
|
|
|
82
82
|
var isIncontextEditingEnabled = ({
|
|
83
83
|
searchParams
|
|
84
84
|
}) => {
|
|
85
|
-
return
|
|
85
|
+
return (searchParams == null ? void 0 : searchParams[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) === "true";
|
|
86
86
|
};
|
|
87
87
|
var determinePreviewMode = ({
|
|
88
88
|
searchParams
|
|
@@ -656,18 +656,11 @@ var ContextUpdateTrigger = ({ path }) => {
|
|
|
656
656
|
// src/components/PersonalizeClientWrapper.tsx
|
|
657
657
|
var import_canvas_next_rsc_client3 = require("@uniformdev/canvas-next-rsc-client");
|
|
658
658
|
var import_react3 = __toESM(require("react"));
|
|
659
|
-
var PersonalizeClientWrapper = (
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
count: props.count,
|
|
665
|
-
slots: props.slots,
|
|
666
|
-
trackingEventName: props.trackingEventName,
|
|
667
|
-
algorithm: props.algorithm,
|
|
668
|
-
indexes: []
|
|
669
|
-
}
|
|
670
|
-
);
|
|
659
|
+
var PersonalizeClientWrapper = ({
|
|
660
|
+
contextInstance,
|
|
661
|
+
...props
|
|
662
|
+
}) => {
|
|
663
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_canvas_next_rsc_client3.PersonalizeClient, { ...props, indexes: [] });
|
|
671
664
|
};
|
|
672
665
|
|
|
673
666
|
// src/components/PersonalizeServer.ts
|
|
@@ -706,19 +699,12 @@ var PersonalizeServer = (props) => {
|
|
|
706
699
|
var import_canvas_next_rsc_client5 = require("@uniformdev/canvas-next-rsc-client");
|
|
707
700
|
var import_canvas_next_rsc_shared4 = require("@uniformdev/canvas-next-rsc-shared");
|
|
708
701
|
var import_react6 = __toESM(require("react"));
|
|
709
|
-
var PersonalizeServerHybrid = (
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
count: props.count,
|
|
716
|
-
slots: props.slots,
|
|
717
|
-
trackingEventName: props.trackingEventName,
|
|
718
|
-
algorithm: props.algorithm,
|
|
719
|
-
indexes
|
|
720
|
-
}
|
|
721
|
-
);
|
|
702
|
+
var PersonalizeServerHybrid = ({
|
|
703
|
+
contextInstance,
|
|
704
|
+
...props
|
|
705
|
+
}) => {
|
|
706
|
+
const { indexes } = (0, import_canvas_next_rsc_shared4.runPersonalization)({ ...props, contextInstance });
|
|
707
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_canvas_next_rsc_client5.PersonalizeClient, { ...props, indexes });
|
|
722
708
|
};
|
|
723
709
|
|
|
724
710
|
// src/components/TestServer.ts
|
|
@@ -852,6 +838,11 @@ var UniformComposition = async ({
|
|
|
852
838
|
},
|
|
853
839
|
{}
|
|
854
840
|
),
|
|
841
|
+
compositionMetadata: {
|
|
842
|
+
compositionId: route.compositionApiResponse.composition._id,
|
|
843
|
+
matchedRoute: route.matchedRoute,
|
|
844
|
+
dynamicInputs: route.dynamicInputs
|
|
845
|
+
},
|
|
855
846
|
quirks: {
|
|
856
847
|
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
857
848
|
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|
package/dist/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ var isDraftModeEnabled = async ({
|
|
|
29
29
|
var isIncontextEditingEnabled = ({
|
|
30
30
|
searchParams
|
|
31
31
|
}) => {
|
|
32
|
-
return
|
|
32
|
+
return (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) === "true";
|
|
33
33
|
};
|
|
34
34
|
var determinePreviewMode = ({
|
|
35
35
|
searchParams
|
|
@@ -628,18 +628,11 @@ var ContextUpdateTrigger = ({ path }) => {
|
|
|
628
628
|
// src/components/PersonalizeClientWrapper.tsx
|
|
629
629
|
import { PersonalizeClient } from "@uniformdev/canvas-next-rsc-client";
|
|
630
630
|
import React3 from "react";
|
|
631
|
-
var PersonalizeClientWrapper = (
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
count: props.count,
|
|
637
|
-
slots: props.slots,
|
|
638
|
-
trackingEventName: props.trackingEventName,
|
|
639
|
-
algorithm: props.algorithm,
|
|
640
|
-
indexes: []
|
|
641
|
-
}
|
|
642
|
-
);
|
|
631
|
+
var PersonalizeClientWrapper = ({
|
|
632
|
+
contextInstance,
|
|
633
|
+
...props
|
|
634
|
+
}) => {
|
|
635
|
+
return /* @__PURE__ */ React3.createElement(PersonalizeClient, { ...props, indexes: [] });
|
|
643
636
|
};
|
|
644
637
|
|
|
645
638
|
// src/components/PersonalizeServer.ts
|
|
@@ -678,19 +671,12 @@ var PersonalizeServer = (props) => {
|
|
|
678
671
|
import { PersonalizeClient as PersonalizeClient2 } from "@uniformdev/canvas-next-rsc-client";
|
|
679
672
|
import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
|
|
680
673
|
import React5 from "react";
|
|
681
|
-
var PersonalizeServerHybrid = (
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
count: props.count,
|
|
688
|
-
slots: props.slots,
|
|
689
|
-
trackingEventName: props.trackingEventName,
|
|
690
|
-
algorithm: props.algorithm,
|
|
691
|
-
indexes
|
|
692
|
-
}
|
|
693
|
-
);
|
|
674
|
+
var PersonalizeServerHybrid = ({
|
|
675
|
+
contextInstance,
|
|
676
|
+
...props
|
|
677
|
+
}) => {
|
|
678
|
+
const { indexes } = runPersonalization2({ ...props, contextInstance });
|
|
679
|
+
return /* @__PURE__ */ React5.createElement(PersonalizeClient2, { ...props, indexes });
|
|
694
680
|
};
|
|
695
681
|
|
|
696
682
|
// src/components/TestServer.ts
|
|
@@ -829,6 +815,11 @@ var UniformComposition = async ({
|
|
|
829
815
|
},
|
|
830
816
|
{}
|
|
831
817
|
),
|
|
818
|
+
compositionMetadata: {
|
|
819
|
+
compositionId: route.compositionApiResponse.composition._id,
|
|
820
|
+
matchedRoute: route.matchedRoute,
|
|
821
|
+
dynamicInputs: route.dynamicInputs
|
|
822
|
+
},
|
|
832
823
|
quirks: {
|
|
833
824
|
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
834
825
|
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|