@uniformdev/canvas-next-rsc 19.173.1-alpha.17 → 19.173.2-alpha.258
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.ts +56 -43
- 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-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/component.d.mts +23 -5
- package/dist/component.d.ts +23 -5
- package/dist/component.js +94 -37
- package/dist/component.mjs +93 -35
- 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/config.js +11 -17
- package/dist/config.mjs +11 -14
- 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/handler.js +14 -10
- package/dist/handler.mjs +3 -16
- 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.d.mts +38 -38
- package/dist/index.d.ts +38 -38
- package/dist/index.esm.js +57 -37
- package/dist/index.js +85 -62
- package/dist/index.mjs +57 -37
- 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 +21 -21
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ComponentInstance, ResolvedRouteGetResponse } from '@uniformdev/canvas';
|
|
2
|
+
import {
|
|
3
|
+
AppDirectoryServerContext,
|
|
4
|
+
ComponentProps,
|
|
5
|
+
CompositionContext,
|
|
6
|
+
PageParameters,
|
|
7
|
+
} from '@uniformdev/canvas-next-rsc-shared';
|
|
8
|
+
import * as React$1 from 'react';
|
|
9
|
+
import { ComponentType, ReactNode } from 'react';
|
|
10
|
+
|
|
11
|
+
type UniformStaticCompositionProps = {
|
|
12
|
+
/**
|
|
13
|
+
* How to render the composition.
|
|
14
|
+
*/
|
|
15
|
+
mode: 'static';
|
|
16
|
+
};
|
|
17
|
+
type UniformServerCompositionProps = {
|
|
18
|
+
/**
|
|
19
|
+
* How to render the composition.
|
|
20
|
+
*/
|
|
21
|
+
mode: 'server';
|
|
22
|
+
/**
|
|
23
|
+
* The Context instance to use for server-side rendering.
|
|
24
|
+
*/
|
|
25
|
+
serverContext?: AppDirectoryServerContext;
|
|
26
|
+
};
|
|
27
|
+
type UniformCompositionProps = PageParameters & {
|
|
28
|
+
/**
|
|
29
|
+
* The route data to render.
|
|
30
|
+
*/
|
|
31
|
+
route: ResolvedRouteGetResponse | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Function to map composition components to React components.
|
|
34
|
+
*/
|
|
35
|
+
resolveComponent: ResolveComponentFunction;
|
|
36
|
+
} & (UniformStaticCompositionProps | UniformServerCompositionProps);
|
|
37
|
+
declare const UniformComposition: React.FC<UniformCompositionProps>;
|
|
38
|
+
type ResolveComponentFunction = (options: { component: ComponentInstance }) => ResolveComponentResult;
|
|
39
|
+
type ResolveComponentResult = {
|
|
40
|
+
component: ComponentType<ComponentProps<any, any>> | null;
|
|
41
|
+
includeContext?: boolean;
|
|
42
|
+
};
|
|
43
|
+
declare const resolveComposition: (
|
|
44
|
+
props: Omit<ResolveComponentsOptions, 'slotName' | 'slotIndex' | 'target'> & {
|
|
45
|
+
composition: ComponentInstance;
|
|
46
|
+
compositionContext: CompositionContext;
|
|
47
|
+
}
|
|
48
|
+
) => React$1.FunctionComponentElement<{
|
|
49
|
+
children?: ReactNode;
|
|
50
|
+
}> | null;
|
|
51
|
+
type ResolveComponentsOptions = {
|
|
52
|
+
serverContext?: AppDirectoryServerContext;
|
|
53
|
+
target:
|
|
54
|
+
| {
|
|
55
|
+
type: 'root';
|
|
56
|
+
composition: ComponentInstance;
|
|
57
|
+
}
|
|
58
|
+
| {
|
|
59
|
+
type: 'slot';
|
|
60
|
+
components: ComponentInstance[];
|
|
61
|
+
parent: ComponentInstance;
|
|
62
|
+
root: ComponentInstance;
|
|
63
|
+
};
|
|
64
|
+
slotName: string | undefined;
|
|
65
|
+
slotIndex: number | undefined;
|
|
66
|
+
resolveComponent: ResolveComponentFunction;
|
|
67
|
+
compositionContext: CompositionContext;
|
|
68
|
+
mode: UniformCompositionProps['mode'];
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
UniformComposition as a,
|
|
73
|
+
ResolveComponentResult as b,
|
|
74
|
+
ResolveComponentFunction as R,
|
|
75
|
+
resolveComposition as r,
|
|
76
|
+
UniformCompositionProps as U,
|
|
77
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { ManifestClient } from '@uniformdev/context/api';
|
|
2
|
+
export type GetManifestClientOptions = {
|
|
3
|
+
revalidate?: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const getManifestClient: (options?: GetManifestClientOptions) => ManifestClient;
|
|
6
|
+
export declare const getManifestFromApi: (options: {
|
|
7
|
+
searchParams:
|
|
8
|
+
| {
|
|
9
|
+
[key: string]: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
| undefined;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
project: {
|
|
14
|
+
id?: string | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
ui_version?: number | undefined;
|
|
17
|
+
pz?:
|
|
18
|
+
| {
|
|
19
|
+
sig?:
|
|
20
|
+
| {
|
|
21
|
+
[key: string]: {
|
|
22
|
+
str: number;
|
|
23
|
+
cap: number;
|
|
24
|
+
dur: 'p' | 's' | 't';
|
|
25
|
+
crit: {
|
|
26
|
+
type: 'G';
|
|
27
|
+
op?: '&' | '|' | undefined;
|
|
28
|
+
clauses: (
|
|
29
|
+
| {
|
|
30
|
+
type: 'G';
|
|
31
|
+
op?: '&' | '|' | undefined;
|
|
32
|
+
clauses: (
|
|
33
|
+
| any
|
|
34
|
+
| {
|
|
35
|
+
type: 'CK';
|
|
36
|
+
cookieName: string;
|
|
37
|
+
match:
|
|
38
|
+
| {
|
|
39
|
+
rhs: string;
|
|
40
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
41
|
+
cs?: boolean | undefined;
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
op: '*' | '!*';
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
type: 'QS';
|
|
49
|
+
queryName: string;
|
|
50
|
+
match:
|
|
51
|
+
| {
|
|
52
|
+
rhs: string;
|
|
53
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
54
|
+
cs?: boolean | undefined;
|
|
55
|
+
}
|
|
56
|
+
| {
|
|
57
|
+
op: '*' | '!*';
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
type: 'QK';
|
|
62
|
+
key: string;
|
|
63
|
+
match:
|
|
64
|
+
| {
|
|
65
|
+
rhs: string;
|
|
66
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
67
|
+
cs?: boolean | undefined;
|
|
68
|
+
}
|
|
69
|
+
| {
|
|
70
|
+
op: '*' | '!*';
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
type: 'EVT';
|
|
75
|
+
event:
|
|
76
|
+
| {
|
|
77
|
+
rhs: string;
|
|
78
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
79
|
+
cs?: boolean | undefined;
|
|
80
|
+
}
|
|
81
|
+
| {
|
|
82
|
+
op: '*' | '!*';
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
| {
|
|
86
|
+
type: 'PV';
|
|
87
|
+
path:
|
|
88
|
+
| {
|
|
89
|
+
rhs: string;
|
|
90
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
91
|
+
cs?: boolean | undefined;
|
|
92
|
+
}
|
|
93
|
+
| {
|
|
94
|
+
op: '*' | '!*';
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
| {
|
|
98
|
+
type: 'PVC';
|
|
99
|
+
match: {
|
|
100
|
+
rhs: number;
|
|
101
|
+
op: '=' | '!=' | '<' | '>';
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
)[];
|
|
105
|
+
}
|
|
106
|
+
| {
|
|
107
|
+
type: 'CK';
|
|
108
|
+
cookieName: string;
|
|
109
|
+
match:
|
|
110
|
+
| {
|
|
111
|
+
rhs: string;
|
|
112
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
113
|
+
cs?: boolean | undefined;
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
op: '*' | '!*';
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
| {
|
|
120
|
+
type: 'QS';
|
|
121
|
+
queryName: string;
|
|
122
|
+
match:
|
|
123
|
+
| {
|
|
124
|
+
rhs: string;
|
|
125
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
126
|
+
cs?: boolean | undefined;
|
|
127
|
+
}
|
|
128
|
+
| {
|
|
129
|
+
op: '*' | '!*';
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
| {
|
|
133
|
+
type: 'QK';
|
|
134
|
+
key: string;
|
|
135
|
+
match:
|
|
136
|
+
| {
|
|
137
|
+
rhs: string;
|
|
138
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
139
|
+
cs?: boolean | undefined;
|
|
140
|
+
}
|
|
141
|
+
| {
|
|
142
|
+
op: '*' | '!*';
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
| {
|
|
146
|
+
type: 'EVT';
|
|
147
|
+
event:
|
|
148
|
+
| {
|
|
149
|
+
rhs: string;
|
|
150
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
151
|
+
cs?: boolean | undefined;
|
|
152
|
+
}
|
|
153
|
+
| {
|
|
154
|
+
op: '*' | '!*';
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
| {
|
|
158
|
+
type: 'PV';
|
|
159
|
+
path:
|
|
160
|
+
| {
|
|
161
|
+
rhs: string;
|
|
162
|
+
op: '~' | '=' | '//' | '!=' | '!~' | '!//';
|
|
163
|
+
cs?: boolean | undefined;
|
|
164
|
+
}
|
|
165
|
+
| {
|
|
166
|
+
op: '*' | '!*';
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
| {
|
|
170
|
+
type: 'PVC';
|
|
171
|
+
match: {
|
|
172
|
+
rhs: number;
|
|
173
|
+
op: '=' | '!=' | '<' | '>';
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
)[];
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
| undefined;
|
|
181
|
+
enr?:
|
|
182
|
+
| {
|
|
183
|
+
[key: string]: {
|
|
184
|
+
cap: number;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
| undefined;
|
|
188
|
+
agg?:
|
|
189
|
+
| {
|
|
190
|
+
[key: string]: {
|
|
191
|
+
inputs: {
|
|
192
|
+
dim: string;
|
|
193
|
+
sign?: '-' | '+' | 'c' | undefined;
|
|
194
|
+
}[];
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
| undefined;
|
|
198
|
+
control?: number | undefined;
|
|
199
|
+
}
|
|
200
|
+
| undefined;
|
|
201
|
+
test?:
|
|
202
|
+
| {
|
|
203
|
+
[key: string]: {
|
|
204
|
+
wv?: string | undefined;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
| undefined;
|
|
208
|
+
};
|
|
209
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
};
|
package/dist/component.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentProps, CompositionContext, SlotDefinition } from '@uniformdev/canvas-next-rsc-shared';
|
|
2
2
|
export { ComponentProps, CompositionContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
3
3
|
import React__default, { PropsWithChildren, ReactNode, Key } from 'react';
|
|
4
|
-
export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-
|
|
4
|
+
export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-Dw55RFP6.mjs';
|
|
5
5
|
import { ComponentInstance } from '@uniformdev/canvas';
|
|
6
6
|
import { RichTextNode } from '@uniformdev/richtext';
|
|
7
7
|
import { PureUniformTextProps } from '@uniformdev/canvas-react/core';
|
|
@@ -34,7 +34,16 @@ type UniformRichTextProps = {
|
|
|
34
34
|
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
35
35
|
/** The component instance. */
|
|
36
36
|
component: ComponentInstance;
|
|
37
|
-
|
|
37
|
+
context?: Pick<CompositionContext, 'isContextualEditing'>;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
40
|
+
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
41
|
+
* @default undefined
|
|
42
|
+
*/
|
|
43
|
+
placeholder?: string | ((parameter: {
|
|
44
|
+
id: string;
|
|
45
|
+
}) => string | undefined);
|
|
46
|
+
} & Omit<React__default.HTMLAttributes<HTMLDivElement>, 'children' | 'placeholder'>;
|
|
38
47
|
/**
|
|
39
48
|
* Adds rendering support for Uniform Rich Text parameters
|
|
40
49
|
*/
|
|
@@ -43,17 +52,26 @@ declare const UniformRichText: React__default.ForwardRefExoticComponent<{
|
|
|
43
52
|
* The name of the HTML tag to render.
|
|
44
53
|
* @default "div"
|
|
45
54
|
*/
|
|
46
|
-
as?: React__default.ElementType
|
|
55
|
+
as?: React__default.ElementType;
|
|
47
56
|
/** The ID of the parameter. */
|
|
48
57
|
parameterId: string;
|
|
49
58
|
/**
|
|
50
59
|
* A function which can provide a custom react component
|
|
51
60
|
* for rendering a rich text node
|
|
52
61
|
*/
|
|
53
|
-
resolveRichTextRenderer?: RenderRichTextComponentResolver
|
|
62
|
+
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
54
63
|
/** The component instance. */
|
|
55
64
|
component: ComponentInstance;
|
|
56
|
-
|
|
65
|
+
context?: Pick<CompositionContext, "isContextualEditing">;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
68
|
+
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
69
|
+
* @default undefined
|
|
70
|
+
*/
|
|
71
|
+
placeholder?: string | ((parameter: {
|
|
72
|
+
id: string;
|
|
73
|
+
}) => string | undefined);
|
|
74
|
+
} & Omit<React__default.HTMLAttributes<HTMLDivElement>, "placeholder" | "children"> & React__default.RefAttributes<unknown>>;
|
|
57
75
|
|
|
58
76
|
type UniformRichTextNodeProps = {
|
|
59
77
|
node: RichTextNode;
|
package/dist/component.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentProps, CompositionContext, SlotDefinition } from '@uniformdev/canvas-next-rsc-shared';
|
|
2
2
|
export { ComponentProps, CompositionContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
3
3
|
import React__default, { PropsWithChildren, ReactNode, Key } from 'react';
|
|
4
|
-
export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-
|
|
4
|
+
export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-Dw55RFP6.js';
|
|
5
5
|
import { ComponentInstance } from '@uniformdev/canvas';
|
|
6
6
|
import { RichTextNode } from '@uniformdev/richtext';
|
|
7
7
|
import { PureUniformTextProps } from '@uniformdev/canvas-react/core';
|
|
@@ -34,7 +34,16 @@ type UniformRichTextProps = {
|
|
|
34
34
|
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
35
35
|
/** The component instance. */
|
|
36
36
|
component: ComponentInstance;
|
|
37
|
-
|
|
37
|
+
context?: Pick<CompositionContext, 'isContextualEditing'>;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
40
|
+
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
41
|
+
* @default undefined
|
|
42
|
+
*/
|
|
43
|
+
placeholder?: string | ((parameter: {
|
|
44
|
+
id: string;
|
|
45
|
+
}) => string | undefined);
|
|
46
|
+
} & Omit<React__default.HTMLAttributes<HTMLDivElement>, 'children' | 'placeholder'>;
|
|
38
47
|
/**
|
|
39
48
|
* Adds rendering support for Uniform Rich Text parameters
|
|
40
49
|
*/
|
|
@@ -43,17 +52,26 @@ declare const UniformRichText: React__default.ForwardRefExoticComponent<{
|
|
|
43
52
|
* The name of the HTML tag to render.
|
|
44
53
|
* @default "div"
|
|
45
54
|
*/
|
|
46
|
-
as?: React__default.ElementType
|
|
55
|
+
as?: React__default.ElementType;
|
|
47
56
|
/** The ID of the parameter. */
|
|
48
57
|
parameterId: string;
|
|
49
58
|
/**
|
|
50
59
|
* A function which can provide a custom react component
|
|
51
60
|
* for rendering a rich text node
|
|
52
61
|
*/
|
|
53
|
-
resolveRichTextRenderer?: RenderRichTextComponentResolver
|
|
62
|
+
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
54
63
|
/** The component instance. */
|
|
55
64
|
component: ComponentInstance;
|
|
56
|
-
|
|
65
|
+
context?: Pick<CompositionContext, "isContextualEditing">;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
68
|
+
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
69
|
+
* @default undefined
|
|
70
|
+
*/
|
|
71
|
+
placeholder?: string | ((parameter: {
|
|
72
|
+
id: string;
|
|
73
|
+
}) => string | undefined);
|
|
74
|
+
} & Omit<React__default.HTMLAttributes<HTMLDivElement>, "placeholder" | "children"> & React__default.RefAttributes<unknown>>;
|
|
57
75
|
|
|
58
76
|
type UniformRichTextNodeProps = {
|
|
59
77
|
node: RichTextNode;
|