@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,82 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import { ResolvedRouteGetResponse, ComponentInstance } from '@uniformdev/canvas';
|
|
4
|
+
import { PageParameters, ComponentProps, CompositionContext, AppDirectoryServerContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
5
|
+
|
|
6
|
+
type UniformStaticCompositionProps = {
|
|
7
|
+
/**
|
|
8
|
+
* How to render the composition.
|
|
9
|
+
*/
|
|
10
|
+
mode: 'static';
|
|
11
|
+
};
|
|
12
|
+
type UniformServerCompositionProps = {
|
|
13
|
+
/**
|
|
14
|
+
* How to render the composition.
|
|
15
|
+
*/
|
|
16
|
+
mode: 'server';
|
|
17
|
+
/**
|
|
18
|
+
* The Context instance to use for server-side rendering.
|
|
19
|
+
*/
|
|
20
|
+
serverContext?: AppDirectoryServerContext;
|
|
21
|
+
};
|
|
22
|
+
type UniformCompositionProps = PageParameters & {
|
|
23
|
+
/**
|
|
24
|
+
* The route data to render.
|
|
25
|
+
*/
|
|
26
|
+
route: ResolvedRouteGetResponse | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Function to map composition components to React components.
|
|
29
|
+
*/
|
|
30
|
+
resolveComponent: ResolveComponentFunction;
|
|
31
|
+
/**
|
|
32
|
+
* Function to map empty placeholders to React components.
|
|
33
|
+
*/
|
|
34
|
+
resolveEmptyPlaceholder?: ResolveEmptyPlaceholderFunction;
|
|
35
|
+
} & (UniformStaticCompositionProps | UniformServerCompositionProps);
|
|
36
|
+
declare const UniformComposition: React.FC<UniformCompositionProps>;
|
|
37
|
+
type ResolveComponentFunction = (options: {
|
|
38
|
+
component: ComponentInstance;
|
|
39
|
+
}) => ResolveComponentResult;
|
|
40
|
+
type ResolveEmptyPlaceholderFunction = (options: ResolveEmptyPlaceholderOptions) => ResolveEmptyPlaceholderResult;
|
|
41
|
+
type ResolveEmptyPlaceholderOptions = {
|
|
42
|
+
parentComponent: ComponentInstance | undefined;
|
|
43
|
+
component: ComponentInstance;
|
|
44
|
+
slotName: string;
|
|
45
|
+
slotIndex: number;
|
|
46
|
+
};
|
|
47
|
+
type ResolveComponentResult = {
|
|
48
|
+
component: ComponentType<ComponentProps<any, any>> | null;
|
|
49
|
+
includeContext?: boolean;
|
|
50
|
+
suspense?: {
|
|
51
|
+
fallback: ComponentType<any> | undefined;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
type ResolveEmptyPlaceholderResult = {
|
|
55
|
+
component: ComponentType<ComponentProps<any, any>> | null;
|
|
56
|
+
};
|
|
57
|
+
declare const resolveComposition: (props: Omit<ResolveComponentsOptions, "slotName" | "slotIndex" | "target"> & {
|
|
58
|
+
composition: ComponentInstance;
|
|
59
|
+
compositionContext: CompositionContext;
|
|
60
|
+
}) => React$1.FunctionComponentElement<{
|
|
61
|
+
children?: ReactNode | undefined;
|
|
62
|
+
}> | null;
|
|
63
|
+
type ResolveComponentsOptions = {
|
|
64
|
+
serverContext?: AppDirectoryServerContext;
|
|
65
|
+
target: {
|
|
66
|
+
type: 'root';
|
|
67
|
+
composition: ComponentInstance;
|
|
68
|
+
} | {
|
|
69
|
+
type: 'slot';
|
|
70
|
+
components: ComponentInstance[];
|
|
71
|
+
parent: ComponentInstance;
|
|
72
|
+
root: ComponentInstance;
|
|
73
|
+
};
|
|
74
|
+
slotName: string | undefined;
|
|
75
|
+
slotIndex: number | undefined;
|
|
76
|
+
resolveComponent: ResolveComponentFunction;
|
|
77
|
+
resolveEmptyPlaceholder: ResolveEmptyPlaceholderFunction | undefined;
|
|
78
|
+
compositionContext: CompositionContext;
|
|
79
|
+
mode: UniformCompositionProps['mode'];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { type ResolveComponentFunction as R, type UniformCompositionProps as U, type ResolveComponentResult as a, UniformComposition as b, resolveComposition as r };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import { ResolvedRouteGetResponse, ComponentInstance } from '@uniformdev/canvas';
|
|
4
|
+
import { PageParameters, ComponentProps, CompositionContext, AppDirectoryServerContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
5
|
+
|
|
6
|
+
type UniformStaticCompositionProps = {
|
|
7
|
+
/**
|
|
8
|
+
* How to render the composition.
|
|
9
|
+
*/
|
|
10
|
+
mode: 'static';
|
|
11
|
+
};
|
|
12
|
+
type UniformServerCompositionProps = {
|
|
13
|
+
/**
|
|
14
|
+
* How to render the composition.
|
|
15
|
+
*/
|
|
16
|
+
mode: 'server';
|
|
17
|
+
/**
|
|
18
|
+
* The Context instance to use for server-side rendering.
|
|
19
|
+
*/
|
|
20
|
+
serverContext?: AppDirectoryServerContext;
|
|
21
|
+
};
|
|
22
|
+
type UniformCompositionProps = PageParameters & {
|
|
23
|
+
/**
|
|
24
|
+
* The route data to render.
|
|
25
|
+
*/
|
|
26
|
+
route: ResolvedRouteGetResponse | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Function to map composition components to React components.
|
|
29
|
+
*/
|
|
30
|
+
resolveComponent: ResolveComponentFunction;
|
|
31
|
+
/**
|
|
32
|
+
* Function to map empty placeholders to React components.
|
|
33
|
+
*/
|
|
34
|
+
resolveEmptyPlaceholder?: ResolveEmptyPlaceholderFunction;
|
|
35
|
+
} & (UniformStaticCompositionProps | UniformServerCompositionProps);
|
|
36
|
+
declare const UniformComposition: React.FC<UniformCompositionProps>;
|
|
37
|
+
type ResolveComponentFunction = (options: {
|
|
38
|
+
component: ComponentInstance;
|
|
39
|
+
}) => ResolveComponentResult;
|
|
40
|
+
type ResolveEmptyPlaceholderFunction = (options: ResolveEmptyPlaceholderOptions) => ResolveEmptyPlaceholderResult;
|
|
41
|
+
type ResolveEmptyPlaceholderOptions = {
|
|
42
|
+
parentComponent: ComponentInstance | undefined;
|
|
43
|
+
component: ComponentInstance;
|
|
44
|
+
slotName: string;
|
|
45
|
+
slotIndex: number;
|
|
46
|
+
};
|
|
47
|
+
type ResolveComponentResult = {
|
|
48
|
+
component: ComponentType<ComponentProps<any, any>> | null;
|
|
49
|
+
includeContext?: boolean;
|
|
50
|
+
suspense?: {
|
|
51
|
+
fallback: ComponentType<any> | undefined;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
type ResolveEmptyPlaceholderResult = {
|
|
55
|
+
component: ComponentType<ComponentProps<any, any>> | null;
|
|
56
|
+
};
|
|
57
|
+
declare const resolveComposition: (props: Omit<ResolveComponentsOptions, "slotName" | "slotIndex" | "target"> & {
|
|
58
|
+
composition: ComponentInstance;
|
|
59
|
+
compositionContext: CompositionContext;
|
|
60
|
+
}) => React$1.FunctionComponentElement<{
|
|
61
|
+
children?: ReactNode | undefined;
|
|
62
|
+
}> | null;
|
|
63
|
+
type ResolveComponentsOptions = {
|
|
64
|
+
serverContext?: AppDirectoryServerContext;
|
|
65
|
+
target: {
|
|
66
|
+
type: 'root';
|
|
67
|
+
composition: ComponentInstance;
|
|
68
|
+
} | {
|
|
69
|
+
type: 'slot';
|
|
70
|
+
components: ComponentInstance[];
|
|
71
|
+
parent: ComponentInstance;
|
|
72
|
+
root: ComponentInstance;
|
|
73
|
+
};
|
|
74
|
+
slotName: string | undefined;
|
|
75
|
+
slotIndex: number | undefined;
|
|
76
|
+
resolveComponent: ResolveComponentFunction;
|
|
77
|
+
resolveEmptyPlaceholder: ResolveEmptyPlaceholderFunction | undefined;
|
|
78
|
+
compositionContext: CompositionContext;
|
|
79
|
+
mode: UniformCompositionProps['mode'];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { type ResolveComponentFunction as R, type UniformCompositionProps as U, type ResolveComponentResult as a, UniformComposition as b, resolveComposition as r };
|
|
@@ -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
|
+
};
|