@uniformdev/canvas-next-rsc 19.79.1-alpha.11 → 19.80.1-alpha.126
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 +64 -0
- package/dist/UniformComposition-38e22896.d.ts +61 -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 +161 -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 +2 -2
- package/dist/component.d.ts +2 -2
- package/dist/components/DefaultNotImplementedComponent.d.ts +2 -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 +25 -0
- package/dist/components/UniformComponent.js +14 -0
- package/dist/components/UniformComposition.d.ts +40 -0
- package/dist/components/UniformComposition.js +35 -0
- package/dist/components/UniformContext.d.ts +8 -0
- package/dist/components/UniformContext.js +19 -0
- package/dist/components/UniformRichText.d.ts +38 -0
- package/dist/components/UniformRichText.js +15 -0
- package/dist/components/UniformRichTextNode.d.ts +10 -0
- package/dist/components/UniformRichTextNode.js +49 -0
- package/dist/components/UniformScript.d.ts +3 -0
- package/dist/components/UniformScript.js +49 -0
- package/dist/components/UniformSlot.d.ts +40 -0
- package/dist/components/UniformSlot.js +38 -0
- package/dist/components/UniformText.d.ts +6 -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 +14 -0
- package/dist/components/convertComponentToProps.js +22 -0
- package/dist/components/evaluateComposition.d.ts +22 -0
- package/dist/components/evaluateComposition.js +183 -0
- package/dist/components/getEnrichmentTags.d.ts +3 -0
- package/dist/components/getEnrichmentTags.js +13 -0
- package/dist/components/getUniformContext.d.ts +6 -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 +15 -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 +141 -0
- package/dist/components/retrieveRoute.js +146 -0
- package/dist/components/types.d.ts +11 -0
- package/dist/components/types.js +1 -0
- package/dist/config/helpers.d.ts +17 -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/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 +19 -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.d.mts +1 -1
- package/dist/handler.d.ts +1 -1
- 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 +3 -3
- package/dist/index.d.ts +3 -3
- 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 +2 -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 +9 -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 +6 -0
- package/dist/register/registerUniformComponent.js +8 -0
- package/dist/resolve/resolveChildren.d.ts +10 -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 +6 -0
- package/dist/utils/apply.js +124 -0
- package/dist/utils/comp.d.ts +16 -0
- package/dist/utils/comp.js +65 -0
- package/dist/utils/diff.d.ts +44 -0
- package/dist/utils/diff.js +144 -0
- package/dist/utils/draft.d.ts +12 -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 +13 -13
|
@@ -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
|
+
};
|
package/dist/handler.d.mts
CHANGED
|
@@ -9,4 +9,4 @@ declare const createPreviewOPTIONSRouteHandler: () => () => Promise<Response>;
|
|
|
9
9
|
|
|
10
10
|
declare const createPreviewPOSTRouteHandler: () => (request: Request) => Promise<Response>;
|
|
11
11
|
|
|
12
|
-
export { CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|
|
12
|
+
export { type CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|
package/dist/handler.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ declare const createPreviewOPTIONSRouteHandler: () => () => Promise<Response>;
|
|
|
9
9
|
|
|
10
10
|
declare const createPreviewPOSTRouteHandler: () => (request: Request) => Promise<Response>;
|
|
11
11
|
|
|
12
|
-
export { CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|
|
12
|
+
export { type CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|
|
@@ -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.d.mts
CHANGED
|
@@ -5,8 +5,8 @@ import { ManifestClient } from '@uniformdev/context/api';
|
|
|
5
5
|
import { ProjectMapClient, ProjectMapNode } from '@uniformdev/project-map';
|
|
6
6
|
import { ContextState, ContextOptions } from '@uniformdev/context';
|
|
7
7
|
import React__default, { PropsWithChildren } from 'react';
|
|
8
|
-
import { U as UniformCompositionProps } from './UniformComposition-
|
|
9
|
-
export { a as UniformComposition, r as resolveComposition } from './UniformComposition-
|
|
8
|
+
import { U as UniformCompositionProps } from './UniformComposition-0pvEHduc.mjs';
|
|
9
|
+
export { a as UniformComposition, r as resolveComposition } from './UniformComposition-0pvEHduc.mjs';
|
|
10
10
|
import { ClientContextComponent } from '@uniformdev/canvas-next-rsc-client';
|
|
11
11
|
|
|
12
12
|
type GetCanvasClientOptions = {
|
|
@@ -250,4 +250,4 @@ type RetrieveRouteOptions = PageParameters & {
|
|
|
250
250
|
};
|
|
251
251
|
declare const retrieveRoute: ({ params, searchParams, skipPrefetch, }: RetrieveRouteOptions) => Promise<ResolvedRouteGetResponse>;
|
|
252
252
|
|
|
253
|
-
export { ContextUpdateTransfer, ContextUpdateTransferProps, CreateServerUniformContextProps, CreateStaticParamsOptions, GetCanvasClientOptions, GetManifestClientOptions, GetProjectMapClientOptions, GetRouteClientOptions, UniformCompositionProps, UniformContext, UniformContextProps, UniformPlayground, UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveRoute };
|
|
253
|
+
export { ContextUpdateTransfer, type ContextUpdateTransferProps, type CreateServerUniformContextProps, type CreateStaticParamsOptions, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, UniformCompositionProps, UniformContext, type UniformContextProps, UniformPlayground, type UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveRoute };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { ManifestClient } from '@uniformdev/context/api';
|
|
|
5
5
|
import { ProjectMapClient, ProjectMapNode } from '@uniformdev/project-map';
|
|
6
6
|
import { ContextState, ContextOptions } from '@uniformdev/context';
|
|
7
7
|
import React__default, { PropsWithChildren } from 'react';
|
|
8
|
-
import { U as UniformCompositionProps } from './UniformComposition-
|
|
9
|
-
export { a as UniformComposition, r as resolveComposition } from './UniformComposition-
|
|
8
|
+
import { U as UniformCompositionProps } from './UniformComposition-0pvEHduc.js';
|
|
9
|
+
export { a as UniformComposition, r as resolveComposition } from './UniformComposition-0pvEHduc.js';
|
|
10
10
|
import { ClientContextComponent } from '@uniformdev/canvas-next-rsc-client';
|
|
11
11
|
|
|
12
12
|
type GetCanvasClientOptions = {
|
|
@@ -250,4 +250,4 @@ type RetrieveRouteOptions = PageParameters & {
|
|
|
250
250
|
};
|
|
251
251
|
declare const retrieveRoute: ({ params, searchParams, skipPrefetch, }: RetrieveRouteOptions) => Promise<ResolvedRouteGetResponse>;
|
|
252
252
|
|
|
253
|
-
export { ContextUpdateTransfer, ContextUpdateTransferProps, CreateServerUniformContextProps, CreateStaticParamsOptions, GetCanvasClientOptions, GetManifestClientOptions, GetProjectMapClientOptions, GetRouteClientOptions, UniformCompositionProps, UniformContext, UniformContextProps, UniformPlayground, UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveRoute };
|
|
253
|
+
export { ContextUpdateTransfer, type ContextUpdateTransferProps, type CreateServerUniformContextProps, type CreateStaticParamsOptions, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, UniformCompositionProps, UniformContext, type UniformContextProps, UniformPlayground, type UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveRoute };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentInstance, ComponentParameter } from '@uniformdev/canvas';
|
|
2
|
+
export interface TestComponent {
|
|
3
|
+
slots?: {
|
|
4
|
+
test?: ComponentInstance[];
|
|
5
|
+
};
|
|
6
|
+
parameters: {
|
|
7
|
+
test?: ComponentParameter<string | undefined>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PersonalizeComponent {
|
|
11
|
+
slots?: {
|
|
12
|
+
pz?: ComponentInstance[];
|
|
13
|
+
};
|
|
14
|
+
parameters: {
|
|
15
|
+
trackingEventName?: ComponentParameter<string>;
|
|
16
|
+
count?: ComponentParameter<string | number>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export type SeenUniformComponent = SeenPersonalizationComponent | SeenTestComponent;
|
|
20
|
+
export interface SeenPersonalizationComponent {
|
|
21
|
+
id: string;
|
|
22
|
+
type: 'personalization';
|
|
23
|
+
variants: string[];
|
|
24
|
+
control: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface SeenTestComponent {
|
|
27
|
+
id: string;
|
|
28
|
+
type: 'test';
|
|
29
|
+
variant: string | undefined;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const componentStore: import("./createComponentStore").ComponentStore;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps } from '../components/UniformComponent';
|
|
3
|
+
export declare const NOT_IMPLEMENTED_COMPONENT = "__not_implemented__";
|
|
4
|
+
export declare const createComponentStore: () => ComponentStore;
|
|
5
|
+
export type ComponentStore = {
|
|
6
|
+
register: (options: {
|
|
7
|
+
type: string;
|
|
8
|
+
variantId?: string;
|
|
9
|
+
component: React.ComponentType<ComponentProps<any>>;
|
|
10
|
+
}) => void;
|
|
11
|
+
get: (type: string, variantId?: string) => React.ComponentType<ComponentProps<any>> | undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getTypeWithVariant } from './getTypeWithVariant';
|
|
2
|
+
export const NOT_IMPLEMENTED_COMPONENT = '__not_implemented__';
|
|
3
|
+
export const createComponentStore = () => {
|
|
4
|
+
const components = new Map();
|
|
5
|
+
return {
|
|
6
|
+
register: ({ type, component, variantId }) => {
|
|
7
|
+
components.set(getTypeWithVariant(type, variantId), component);
|
|
8
|
+
},
|
|
9
|
+
get: (type, variantId) => {
|
|
10
|
+
return components.get(getTypeWithVariant(type, variantId));
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ComponentInstance } from '@uniformdev/canvas';
|
|
3
|
+
import { ComponentProps } from '../components/UniformComponent';
|
|
4
|
+
import { ComponentStore } from './createComponentStore';
|
|
5
|
+
type RenderComponentResolver = (component: ComponentInstance) => React.ComponentType<ComponentProps<any>> | null;
|
|
6
|
+
export declare const createComponentStoreResolver: (options: {
|
|
7
|
+
store: ComponentStore;
|
|
8
|
+
}) => RenderComponentResolver;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DefaultNotImplementedComponent } from '../components/DefaultNotImplementedComponent';
|
|
2
|
+
import { getTypeWithVariant } from './getTypeWithVariant';
|
|
3
|
+
export const createComponentStoreResolver = ({ store }) => {
|
|
4
|
+
return (component) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const resolved = (_a = store.get(getTypeWithVariant(component.type, component.variant))) !== null && _a !== void 0 ? _a : store.get(getTypeWithVariant(component.type));
|
|
7
|
+
return resolved || DefaultNotImplementedComponent;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTypeWithVariant: (type: string, variantId?: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getTypeWithVariant = (type, variantId) => `${type}${variantId ? `__${variantId}` : ''}`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RenderComponentResolver } from '@uniformdev/canvas-react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { CompositionContext, UniformComponentProps } from '../components/UniformComponent';
|
|
4
|
+
export declare function resolveChildren<TRenderProps = unknown>({ children, data, context, hasParentLayout, resolveRenderer, }: {
|
|
5
|
+
children: UniformComponentProps<TRenderProps>['children'];
|
|
6
|
+
data: Required<UniformComponentProps<TRenderProps>>['data'];
|
|
7
|
+
context: CompositionContext;
|
|
8
|
+
hasParentLayout: boolean;
|
|
9
|
+
resolveRenderer: RenderComponentResolver;
|
|
10
|
+
}): ReactNode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { convertComponentToProps } from '../components/convertComponentToProps';
|
|
4
|
+
import { UniformSlot } from '../components/UniformSlot';
|
|
5
|
+
export function resolveChildren({ children, data, context, hasParentLayout, resolveRenderer, }) {
|
|
6
|
+
// attempt to resolve the top level component if we're at the root and children were not provided
|
|
7
|
+
if (!children && !hasParentLayout) {
|
|
8
|
+
const topLevelComponent = resolveRenderer({ type: data.type });
|
|
9
|
+
if (topLevelComponent) {
|
|
10
|
+
children = createElement(topLevelComponent, convertComponentToProps({ component: data, context }));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
children = Object.keys(data.slots || {}).map((slotName) => (_jsx(UniformSlot, { name: slotName, data: data, context: context }, slotName)));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const renderChildren = typeof children === 'function'
|
|
17
|
+
? children(convertComponentToProps({ component: data, context }))
|
|
18
|
+
: children;
|
|
19
|
+
return renderChildren;
|
|
20
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const TYPE_SEP = '~';
|
|
2
|
+
const PAIR_SEP = '!';
|
|
3
|
+
const KV_SEP = '-';
|
|
4
|
+
// the cookie format is thus:
|
|
5
|
+
// <ab-test-data>~<session-scores>~<visitor-scores>
|
|
6
|
+
// where each type is subdivided into key-value pairs:
|
|
7
|
+
// <k>-<v>!<k>-<v>!...
|
|
8
|
+
// score data is further encoded into base64, so the scores themselves are compressed
|
|
9
|
+
// example:
|
|
10
|
+
// mytest-var1!mytest2-var2~ses1-x!ses2-1~vis1-fa~vis2-10
|
|
11
|
+
// means:
|
|
12
|
+
// mytest test: var1 variant
|
|
13
|
+
// mytest2 test: var2 variant
|
|
14
|
+
// ses1 session signal: bton(x) score
|
|
15
|
+
// ses2 session signal: bton(1) score
|
|
16
|
+
// vis1 visitor signal: bton(fa) score
|
|
17
|
+
// vis2 visitor signal: bton(10) score;
|
|
18
|
+
export function parseScoreCookie(cookieValue) {
|
|
19
|
+
if (!cookieValue)
|
|
20
|
+
return;
|
|
21
|
+
const types = cookieValue.split(TYPE_SEP);
|
|
22
|
+
if (types.length > 3)
|
|
23
|
+
return;
|
|
24
|
+
const [abTestData, sessionScores, visitorScores] = types;
|
|
25
|
+
return {
|
|
26
|
+
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
|
27
|
+
consent: true,
|
|
28
|
+
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
|
29
|
+
scores: decodeCookieType(parseCookieType(visitorScores)),
|
|
30
|
+
tests: parseCookieType(abTestData),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function parseCookieType(type) {
|
|
34
|
+
if (!type) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
const pairs = type.split(PAIR_SEP).map((pair) => pair.split(KV_SEP));
|
|
38
|
+
return pairs.reduce((acc, cur) => {
|
|
39
|
+
if (cur.length < 2)
|
|
40
|
+
return acc;
|
|
41
|
+
// join handles the case when there is a pair separator in the value,
|
|
42
|
+
// i.e. testname-testid-with-hyphens
|
|
43
|
+
acc[cur[0]] = cur.slice(1).join('-');
|
|
44
|
+
return acc;
|
|
45
|
+
}, {});
|
|
46
|
+
}
|
|
47
|
+
function decodeCookieType(type) {
|
|
48
|
+
return Object.entries(type).reduce((acc, [key, value]) => {
|
|
49
|
+
acc[key] = bton(value);
|
|
50
|
+
return acc;
|
|
51
|
+
}, {});
|
|
52
|
+
}
|
|
53
|
+
export function serializeCookie(data) {
|
|
54
|
+
return [
|
|
55
|
+
serializeCookieType(data.tests),
|
|
56
|
+
serializeCookieType(encodeCookieType(data.sessionScores)),
|
|
57
|
+
serializeCookieType(encodeCookieType(data.scores)),
|
|
58
|
+
].join(TYPE_SEP);
|
|
59
|
+
}
|
|
60
|
+
function encodeCookieType(type) {
|
|
61
|
+
return Object.entries(type).reduce((acc, [key, value]) => {
|
|
62
|
+
acc[key] = ntob(value);
|
|
63
|
+
return acc;
|
|
64
|
+
}, {});
|
|
65
|
+
}
|
|
66
|
+
function serializeCookieType(type) {
|
|
67
|
+
return Object.entries(type)
|
|
68
|
+
.map((kv) => kv.join(KV_SEP))
|
|
69
|
+
.join(PAIR_SEP);
|
|
70
|
+
}
|
|
71
|
+
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
72
|
+
// binary to string lookup table
|
|
73
|
+
const b2s = alphabet.split('');
|
|
74
|
+
// string to binary lookup table
|
|
75
|
+
// 123 == 'z'.charCodeAt(0) + 1
|
|
76
|
+
const s2b = new Array(123);
|
|
77
|
+
for (let i = 0; i < alphabet.length; i++) {
|
|
78
|
+
s2b[alphabet.charCodeAt(i)] = i;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Converts a number to a base64 string of its representation.
|
|
82
|
+
* Compresses the number if it is to be transferred in a string representation.
|
|
83
|
+
*/
|
|
84
|
+
const ntob = (number) => {
|
|
85
|
+
if (number < 0)
|
|
86
|
+
return `-${ntob(-number)}`;
|
|
87
|
+
let lo = number >>> 0;
|
|
88
|
+
let hi = (number / 4294967296) >>> 0;
|
|
89
|
+
let right = '';
|
|
90
|
+
while (hi > 0) {
|
|
91
|
+
right = b2s[0x3f & lo] + right;
|
|
92
|
+
lo >>>= 6;
|
|
93
|
+
lo |= (0x3f & hi) << 26;
|
|
94
|
+
hi >>>= 6;
|
|
95
|
+
}
|
|
96
|
+
let left = '';
|
|
97
|
+
do {
|
|
98
|
+
left = b2s[0x3f & lo] + left;
|
|
99
|
+
lo >>>= 6;
|
|
100
|
+
} while (lo > 0);
|
|
101
|
+
return left + right;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Converts a base64 string to an equivalent number _represented as a string in base64_.
|
|
105
|
+
* Decompresses a number from the compressed base64 string.
|
|
106
|
+
*/
|
|
107
|
+
const bton = (base64) => {
|
|
108
|
+
let number = 0;
|
|
109
|
+
const sign = base64.charAt(0) === '-' ? 1 : 0;
|
|
110
|
+
for (let i = sign; i < base64.length; i++) {
|
|
111
|
+
number = number * 64 + s2b[base64.charCodeAt(i)];
|
|
112
|
+
}
|
|
113
|
+
return sign ? -number : number;
|
|
114
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|