@remkoj/optimizely-cms-react 5.1.5 → 6.0.0-pre10
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/components/cms-content/get-content-type.js +8 -17
- package/dist/components/cms-content/get-content-type.js.map +1 -1
- package/dist/components/cms-content/get-content.js +41 -59
- package/dist/components/cms-content/get-content.js.map +1 -1
- package/dist/components/cms-content/resolve-component.js +9 -4
- package/dist/components/cms-content/resolve-component.js.map +1 -1
- package/dist/components/cms-content/rsc.js +3 -5
- package/dist/components/cms-content/rsc.js.map +1 -1
- package/dist/components/cms-content-area/index.js +3 -3
- package/dist/components/cms-content-area/index.js.map +1 -1
- package/dist/components/cms-editable/index.js +7 -5
- package/dist/components/cms-editable/index.js.map +1 -1
- package/dist/components/rich-text/components.d.ts +1 -1
- package/dist/components/rich-text/index.d.ts +2 -1
- package/dist/components/rich-text/index.js +6 -3
- package/dist/components/rich-text/index.js.map +1 -1
- package/dist/components/rsc-components.d.ts +31 -0
- package/dist/components/rsc-components.js +53 -0
- package/dist/components/rsc-components.js.map +1 -0
- package/dist/components/rsc.d.ts +2 -45
- package/dist/components/rsc.js +1 -51
- package/dist/components/rsc.js.map +1 -1
- package/dist/components/type-utils.d.ts +1 -1
- package/dist/components/visual-builder/functions.js +1 -1
- package/dist/components/visual-builder/functions.js.map +1 -1
- package/dist/components/visual-builder/index.js +9 -5
- package/dist/components/visual-builder/index.js.map +1 -1
- package/dist/components/visual-builder/types.d.ts +2 -1
- package/dist/context/client.js +5 -2
- package/dist/context/client.js.map +1 -1
- package/dist/context/rsc.d.ts +1 -1
- package/dist/context/rsc.js +14 -43
- package/dist/context/rsc.js.map +1 -1
- package/dist/context/shared.js +2 -1
- package/dist/context/shared.js.map +1 -1
- package/dist/context/types.d.ts +3 -11
- package/dist/factory/default.js +0 -5
- package/dist/factory/default.js.map +1 -1
- package/dist/factory/types.d.ts +1 -1
- package/dist/rsc.d.ts +1 -0
- package/dist/rsc.js +1 -0
- package/dist/rsc.js.map +1 -1
- package/dist/types.d.ts +5 -3
- package/dist/utilities.d.ts +54 -4
- package/dist/utilities.js +100 -7
- package/dist/utilities.js.map +1 -1
- package/package.json +23 -25
- package/dist/components.d.ts +0 -29
- package/dist/components.js +0 -24
- package/dist/components.js.map +0 -1
package/dist/components/rsc.d.ts
CHANGED
|
@@ -1,53 +1,10 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
|
-
import { type ReactNode, type ComponentType } from 'react';
|
|
3
|
-
import { type PropsWithContext, type PropsWithOptionalContext } from '../context/types.js';
|
|
4
|
-
import { type CmsContentAreaComponent } from './cms-content-area/index.js';
|
|
5
|
-
import { type CmsEditableComponent } from './cms-editable/index.js';
|
|
6
|
-
import { type CmsContentComponent } from './cms-content/rsc.js';
|
|
7
|
-
import { type OptimizelyCompositionComponent } from './visual-builder/index.js';
|
|
8
|
-
import { type RichTextComponent } from './rich-text/index.js';
|
|
9
2
|
export type { BaseStyleDefinition, ElementStyleDefinition, LayoutProps, LayoutPropsSetting, LayoutPropsSettingChoices, LayoutPropsSettingKeys, LayoutPropsSettingValues, NodeStyleDefinition, StyleDefinition, StyleSetting, } from './cms-styles/index.js';
|
|
10
3
|
export { extractSettings, readSetting } from './cms-styles/index.js';
|
|
11
4
|
export * from './cms-styles/index.js';
|
|
12
5
|
export { isNode, isComponentNode, isComponentNodeOfType, isStructureNode, isElementNode, } from './visual-builder/functions.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
type ReactServerComponentType<P = any> = ComponentType<P> | ((props: P) => Promise<ReactNode>);
|
|
17
|
-
/**
|
|
18
|
-
* Wrapper function to turn context dependant components into easy to use
|
|
19
|
-
* server components
|
|
20
|
-
*
|
|
21
|
-
* @param component The component where the `ctx` parameter must be fulfilled
|
|
22
|
-
* @returns The component, without CTX parameter
|
|
23
|
-
*/
|
|
24
|
-
export declare function serverContextAware<P extends PropsWithContext>(component: ReactServerComponentType<P>): ComponentType<PropsWithOptionalContext<Omit<P, 'ctx'>>>;
|
|
25
|
-
/**
|
|
26
|
-
* Client side Optimizely CMS Editable
|
|
27
|
-
*/
|
|
28
|
-
export declare const CmsEditable: CmsEditableComponent;
|
|
29
|
-
/**
|
|
30
|
-
* Client side Optimizely CMS Content, leveraging the CMS Context to load the
|
|
31
|
-
* content type and content data when needed
|
|
32
|
-
*/
|
|
33
|
-
export declare const CmsContent: CmsContentComponent;
|
|
34
|
-
export type { CmsContentComponent, CmsContentProps } from './cms-content/rsc.js';
|
|
35
|
-
/**
|
|
36
|
-
* Client side Optimizely CMS Content Area, leveraging the CMS Context to infer
|
|
37
|
-
* the connection to Optimizely Graph and component dictionary.
|
|
38
|
-
*/
|
|
39
|
-
export declare const CmsContentArea: CmsContentAreaComponent;
|
|
40
|
-
export type { CmsContentAreaClassMapper, CmsContentAreaComponent, CmsContentAreaProps, ContentAreaItemDefinition, } from './cms-content-area/index.js';
|
|
41
|
-
/**
|
|
42
|
-
* Client side Optimizely Composition (e.g. Visual Builder), leveraging the CMS
|
|
43
|
-
* Context to infer the connection to Optimizely Graph and component
|
|
44
|
-
* dictionary.
|
|
45
|
-
*/
|
|
46
|
-
export declare const OptimizelyComposition: OptimizelyCompositionComponent;
|
|
47
|
-
/**
|
|
48
|
-
* Client side renderer for Rich Text
|
|
49
|
-
*/
|
|
50
|
-
export declare const RichText: RichTextComponent;
|
|
6
|
+
export type { CompositionNode, CompositionNodeBase, CompositionComponentNode, CompositionStructureNode, CompositionComponentType, LeafPropsFactory, NodePropsFactory, } from './visual-builder/types.js';
|
|
7
|
+
export { StructureNodeTypes, } from './visual-builder/types.js';
|
|
51
8
|
export type { RichTextComponent, RichTextProps, RichTextNode, StringNode, TypedNode, NodeInput, } from './rich-text/index.js';
|
|
52
9
|
export { DefaultComponents as RichTextComponentDictionary, createHtmlComponent, } from './rich-text/components.js';
|
|
53
10
|
export { isNodeInput, isNonEmptyString, isRichTextNode, isStringNode, isText, isTypedNode, } from './rich-text/utils.js';
|
package/dist/components/rsc.js
CHANGED
|
@@ -1,59 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import 'server-only';
|
|
3
|
-
import { getServerContext } from '../context/rsc.js';
|
|
4
|
-
import { cmsContentAware } from './cms-content/utils.js';
|
|
5
|
-
import { CmsContentArea as BaseContentArea, } from './cms-content-area/index.js'; // Both RSC & Client capable
|
|
6
|
-
import { CmsEditable as BaseEditable, } from './cms-editable/index.js'; // Both RSC & Client capable
|
|
7
|
-
import { CmsContent as BaseCmsContent, } from './cms-content/rsc.js'; // Different components for RSC & Client
|
|
8
|
-
import { OptimizelyComposition as BaseOptimizelyComposition, } from './visual-builder/index.js'; // Both RSC & Client capable
|
|
9
|
-
import { RichText as BaseRichText, } from './rich-text/index.js';
|
|
10
2
|
export { extractSettings, readSetting } from './cms-styles/index.js';
|
|
11
3
|
export * from './cms-styles/index.js';
|
|
12
4
|
// Visual Builder items
|
|
13
5
|
export { isNode, isComponentNode, isComponentNodeOfType, isStructureNode, isElementNode, } from './visual-builder/functions.js';
|
|
14
|
-
|
|
15
|
-
* Wrapper function to turn context dependant components into easy to use
|
|
16
|
-
* server components
|
|
17
|
-
*
|
|
18
|
-
* @param component The component where the `ctx` parameter must be fulfilled
|
|
19
|
-
* @returns The component, without CTX parameter
|
|
20
|
-
*/
|
|
21
|
-
export function serverContextAware(component) {
|
|
22
|
-
const BaseComponent = component;
|
|
23
|
-
const ServerContextInjector = ({ ctx, ...props }) => {
|
|
24
|
-
if (!ctx)
|
|
25
|
-
console.error(`🔴 [ServerContextAware] Context for context aware component ${BaseComponent.displayName ?? BaseComponent.name ?? '[ANONYMOUS]'} is not defined!`);
|
|
26
|
-
const cmpCtx = ctx || getServerContext();
|
|
27
|
-
const componentProps = { ...props, ctx: cmpCtx };
|
|
28
|
-
return _jsx(BaseComponent, { ...componentProps });
|
|
29
|
-
};
|
|
30
|
-
ServerContextInjector.displayName = 'Server Context Injector';
|
|
31
|
-
return ServerContextInjector;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Client side Optimizely CMS Editable
|
|
35
|
-
*/
|
|
36
|
-
export const CmsEditable = serverContextAware(BaseEditable);
|
|
37
|
-
/**
|
|
38
|
-
* Client side Optimizely CMS Content, leveraging the CMS Context to load the
|
|
39
|
-
* content type and content data when needed
|
|
40
|
-
*/
|
|
41
|
-
export const CmsContent = serverContextAware(BaseCmsContent);
|
|
42
|
-
/**
|
|
43
|
-
* Client side Optimizely CMS Content Area, leveraging the CMS Context to infer
|
|
44
|
-
* the connection to Optimizely Graph and component dictionary.
|
|
45
|
-
*/
|
|
46
|
-
export const CmsContentArea = cmsContentAware(serverContextAware(BaseContentArea), CmsContent);
|
|
47
|
-
/**
|
|
48
|
-
* Client side Optimizely Composition (e.g. Visual Builder), leveraging the CMS
|
|
49
|
-
* Context to infer the connection to Optimizely Graph and component
|
|
50
|
-
* dictionary.
|
|
51
|
-
*/
|
|
52
|
-
export const OptimizelyComposition = cmsContentAware(serverContextAware(BaseOptimizelyComposition), CmsContent);
|
|
53
|
-
/**
|
|
54
|
-
* Client side renderer for Rich Text
|
|
55
|
-
*/
|
|
56
|
-
export const RichText = serverContextAware(BaseRichText);
|
|
6
|
+
export { StructureNodeTypes, } from './visual-builder/types.js';
|
|
57
7
|
export { DefaultComponents as RichTextComponentDictionary, createHtmlComponent, } from './rich-text/components.js';
|
|
58
8
|
export { isNodeInput, isNonEmptyString, isRichTextNode, isStringNode, isText, isTypedNode, } from './rich-text/utils.js';
|
|
59
9
|
//# sourceMappingURL=rsc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/components/rsc.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/components/rsc.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAepB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,cAAc,uBAAuB,CAAA;AAErC,uBAAuB;AACvB,OAAO,EACL,MAAM,EACN,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,aAAa,GACd,MAAM,+BAA+B,CAAA;AAYtC,OAAO,EACL,kBAAkB,GACnB,MAAM,2BAA2B,CAAA;AAUlC,OAAO,EACL,iBAAiB,IAAI,2BAA2B,EAChD,mBAAmB,GACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,MAAM,EACN,WAAW,GACZ,MAAM,sBAAsB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GenericContext } from "../rsc.js";
|
|
2
|
-
import type { PropsWithChildren } from "react";
|
|
2
|
+
import type { PropsWithChildren, JSX } from "react";
|
|
3
3
|
/**
|
|
4
4
|
* Define an element as a React Component, React ExoticComponent or string name
|
|
5
5
|
* representing a HTML Element (e.g. "div", "a", etc...), this value can be used
|
|
@@ -78,7 +78,7 @@ export const defaultNodePropsFactory = (node) => {
|
|
|
78
78
|
["Node", "Component", "Content"]
|
|
79
79
|
].filter(x => x);
|
|
80
80
|
const contentLink = { key: node.key ?? '', isInline: true };
|
|
81
|
-
const componentData = { __name: node.name };
|
|
81
|
+
const componentData = { __name: node.name, ...node.component };
|
|
82
82
|
const layoutData = {
|
|
83
83
|
type: node.type,
|
|
84
84
|
layoutType: node.layoutType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/components/visual-builder/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAyB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/components/visual-builder/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM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AAK,CAAC,MAAM,GAAG,CAAC;QAChD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACpD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -10,17 +10,21 @@ export function OptimizelyComposition({ node, leafPropsFactory = defaultPropsFac
|
|
|
10
10
|
const { factory, isDebug } = ctx;
|
|
11
11
|
// Render the element
|
|
12
12
|
if (isComponentNode(node)) {
|
|
13
|
-
if (isDebug)
|
|
14
|
-
|
|
13
|
+
/*if (isDebug)
|
|
14
|
+
console.log(
|
|
15
|
+
`⚪ [VisualBuilder] Rendering element node ${JSON.stringify(node)}`
|
|
16
|
+
)*/
|
|
15
17
|
const [contentLink, contentType, nodeId, fragmentData, layoutProps] = leafPropsFactory(node);
|
|
16
18
|
return (_jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, layoutProps: layoutProps, editorComponentId: nodeId || contentLink.key || undefined, ctx: ctx }));
|
|
17
19
|
}
|
|
18
20
|
// Debug
|
|
19
|
-
if (isDebug)
|
|
20
|
-
|
|
21
|
+
/*if (isDebug)
|
|
22
|
+
console.log(
|
|
23
|
+
`⚪ [VisualBuilder] Rendering structure node ${JSON.stringify(node)}`
|
|
24
|
+
)*/
|
|
21
25
|
// Ensure we've got a factory
|
|
22
26
|
if (!factory)
|
|
23
|
-
throw new Error('🟡 [VisualBuilder] [OptimizelyComposition] The factory must be defined within the
|
|
27
|
+
throw new Error('🟡 [VisualBuilder] [OptimizelyComposition] The factory must be defined within the Context');
|
|
24
28
|
const [contentLink, contentTypes, nodeId, fragmentData, layoutProps] = nodePropsFactory(node);
|
|
25
29
|
const firstExistingType = contentTypes
|
|
26
30
|
.map((ct) => factory.has([...ct].reverse()))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/visual-builder/index.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,gBAAgB,CAAA;AAIvB;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,IAAI,EACJ,gBAAgB,GAAG,mBAAmB,EACtC,gBAAgB,GAAG,uBAAuB,EAC1C,GAAG,EACH,UAAU,EAAE,UAAU,GACS;IAC/B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;IAEhC,qBAAqB;IACrB,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/visual-builder/index.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,gBAAgB,CAAA;AAIvB;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,IAAI,EACJ,gBAAgB,GAAG,mBAAmB,EACtC,gBAAgB,GAAG,uBAAuB,EAC1C,GAAG,EACH,UAAU,EAAE,UAAU,GACS;IAC/B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;IAEhC,qBAAqB;IACrB,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B;;;aAGK;QACL,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,GACjE,gBAAgB,CAAC,IAAI,CAAC,CAAA;QACxB,OAAO,CACL,KAAC,UAAU,IACT,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,MAAM,IAAI,WAAW,CAAC,GAAG,IAAI,SAAS,EACzD,GAAG,EAAE,GAAG,GACR,CACH,CAAA;IACH,CAAC;IAED,QAAQ;IACR;;;SAGK;IAEL,6BAA6B;IAC7B,IAAI,CAA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G,EACR,UAAU,EAAE,UAAU,IALjB,QAAQ,CAMb,CACH,CAAA;QACH,CAAC,CAAC,GACS,CACd,CAAA;AACH,CAAC;AAED,eAAe,qBAAqB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComponentType, type PropsWithChildren } from "react";
|
|
1
|
+
import { type ComponentType, type PropsWithChildren, type JSX } from "react";
|
|
2
2
|
import { type InlineContentLinkWithLocale, type ContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
|
|
3
3
|
import { type ContentType } from "../../types.js";
|
|
4
4
|
import { type PropsWithContext, type PropsWithOptionalContext } from "../../context/types.js";
|
|
@@ -22,6 +22,7 @@ export type CompositionNodeBase = {
|
|
|
22
22
|
export type CompositionStructureNode = CompositionNodeBase & {
|
|
23
23
|
layoutType: "experience" | "section" | "row" | "column";
|
|
24
24
|
nodes?: Array<CompositionNode>;
|
|
25
|
+
component?: Record<string, any>;
|
|
25
26
|
};
|
|
26
27
|
export type CompositionComponentNode<E extends Record<string, any> = Record<string, any>> = CompositionNodeBase & {
|
|
27
28
|
layoutType: "component";
|
package/dist/context/client.js
CHANGED
|
@@ -13,8 +13,11 @@ export var OptimizelyCmsMode;
|
|
|
13
13
|
})(OptimizelyCmsMode || (OptimizelyCmsMode = {}));
|
|
14
14
|
export class ClientContextInstance {
|
|
15
15
|
constructor(cfg, components) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
this.client = isOptiGraphClient(cfg.client)
|
|
17
|
+
? cfg.client
|
|
18
|
+
: isOptiGraphConfig(cfg.client)
|
|
19
|
+
? createClient(cfg.client)
|
|
20
|
+
: createClient();
|
|
18
21
|
this.factory = new DefaultComponentFactory(components);
|
|
19
22
|
this.inEditMode = cfg.inEditMode;
|
|
20
23
|
this.inPreviewMode = cfg.inPreviewMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/context/client.tsx"],"names":[],"mappings":"AAAA,YAAY,CA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ACjB,IAAI,GAAuB,CAAA;IAC3B,IAAI,CAAC;QACH,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,qBAAqB;IACvB,CAAC;IACD,OAAO,GAAG,IAAI,YAAY,CAAA;AAC5B,CAAC"}
|
package/dist/context/rsc.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare class ServerContext implements GenericContext {
|
|
|
48
48
|
* @deprecated Use the context handed down through the CmsContentArea and CmsContent
|
|
49
49
|
* components
|
|
50
50
|
*/
|
|
51
|
-
export declare const getServerContext: () =>
|
|
51
|
+
export declare const getServerContext: () => never;
|
|
52
52
|
/**
|
|
53
53
|
* Update the shared server context from the provided context. This is compatibility
|
|
54
54
|
* method to ensure that the value returned by `getServerContext` can be retrieved and
|
package/dist/context/rsc.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
2
|
import { createClient, isOptiGraphClient, } from '@remkoj/optimizely-graph-client';
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import { DefaultComponentFactory, } from '../factory/index.js';
|
|
5
4
|
import { isDebug, isDevelopment } from '../rsc-utilities.js';
|
|
6
5
|
export * from './types.js';
|
|
@@ -90,20 +89,25 @@ export class ServerContext {
|
|
|
90
89
|
setEditableContentIsExperience(isExperience) {
|
|
91
90
|
this._editableIsExperience = isExperience;
|
|
92
91
|
}
|
|
92
|
+
//private _hasWarned: boolean = false;
|
|
93
93
|
toJSON(key) {
|
|
94
|
-
if (this.isDebugOrDevelopment) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
/*if (this.isDebugOrDevelopment) {
|
|
95
|
+
if (!this._hasWarned || this.isDebug) {
|
|
96
|
+
console.warn(
|
|
97
|
+
'🦺 [ServerContext] Converting Context to JSON, this is typically a side effect of the context being passed between Server & Client components', key
|
|
98
|
+
)
|
|
99
|
+
this._hasWarned = true
|
|
100
|
+
}
|
|
101
|
+
if (this.isDebug)
|
|
102
|
+
console.trace()
|
|
103
|
+
}*/
|
|
100
104
|
return {
|
|
105
|
+
client: this.client?.toJSON(),
|
|
101
106
|
inEditMode: this.inEditMode,
|
|
102
107
|
inPreviewMode: this.inPreviewMode,
|
|
103
108
|
isDebug: this.isDebug,
|
|
104
109
|
isDebugOrDevelopment: this.isDebugOrDevelopment,
|
|
105
110
|
isDevelopment: this.isDevelopment,
|
|
106
|
-
clientConfig: this.client?.toJSON(),
|
|
107
111
|
locale: this.locale,
|
|
108
112
|
};
|
|
109
113
|
}
|
|
@@ -121,9 +125,7 @@ export class ServerContext {
|
|
|
121
125
|
* components
|
|
122
126
|
*/
|
|
123
127
|
export const getServerContext = () => {
|
|
124
|
-
|
|
125
|
-
console.debug('🦺 [ServerContext] getServerContext has been deprecated, this provides an instance of the Server Context that is potentially shared between requests');
|
|
126
|
-
return internalGetServerContext();
|
|
128
|
+
throw new Error('🦺 [ServerContext] getServerContext has been removed, due to potential leakage across requests');
|
|
127
129
|
};
|
|
128
130
|
/**
|
|
129
131
|
* Update the shared server context from the provided context. This is compatibility
|
|
@@ -136,38 +138,7 @@ export const getServerContext = () => {
|
|
|
136
138
|
* @returns The updated shared server context
|
|
137
139
|
*/
|
|
138
140
|
export function updateSharedServerContext(currentCtx) {
|
|
139
|
-
|
|
140
|
-
// Update component factory
|
|
141
|
-
serverCtx.setComponentFactory(currentCtx.factory);
|
|
142
|
-
// Update Optimizely Graph Client
|
|
143
|
-
if (currentCtx.client)
|
|
144
|
-
serverCtx.setOptimizelyGraphClient(currentCtx.client);
|
|
145
|
-
// Update locale
|
|
146
|
-
if (currentCtx.locale)
|
|
147
|
-
serverCtx.setLocale(currentCtx.locale);
|
|
148
|
-
// Update mode
|
|
149
|
-
if (currentCtx.inEditMode)
|
|
150
|
-
serverCtx.setMode('edit');
|
|
151
|
-
else if (currentCtx.inPreviewMode)
|
|
152
|
-
serverCtx.setMode('preview');
|
|
153
|
-
else if (!currentCtx.inEditMode && !currentCtx.inPreviewMode)
|
|
154
|
-
serverCtx.setMode('public');
|
|
155
|
-
// Update editable content
|
|
156
|
-
serverCtx.setEditableContentId(currentCtx.editableContent);
|
|
157
|
-
return serverCtx;
|
|
141
|
+
throw new Error('🦺 [ServerContext] getServerContext has been removed, due to potential leakage across requests');
|
|
158
142
|
}
|
|
159
|
-
const cachePlaceholder = (factory) => {
|
|
160
|
-
if (isDebug() || isDevelopment())
|
|
161
|
-
console.warn('🚧 [React Context] Running client/server react code instead of server context, no cache() available.');
|
|
162
|
-
return factory;
|
|
163
|
-
};
|
|
164
|
-
//@ts-ignore React.cache is only available in the react-server context
|
|
165
|
-
const cache = (React.cache || cachePlaceholder);
|
|
166
|
-
const internalGetServerContext = cache(() => {
|
|
167
|
-
const ctx = new ServerContext({});
|
|
168
|
-
if (ctx.isDebug)
|
|
169
|
-
console.log('🦺 [ServerContext] Created new context');
|
|
170
|
-
return ctx;
|
|
171
|
-
});
|
|
172
143
|
//#endregion
|
|
173
144
|
//# sourceMappingURL=rsc.js.map
|
package/dist/context/rsc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/context/rsc.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EACL,YAAY,EACZ,iBAAiB,GAGlB,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/context/rsc.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EACL,YAAY,EACZ,iBAAiB,GAGlB,MAAM,iCAAiC,CAAA;AAMxC,OAAO,EAGL,uBAAuB,GACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE5D,cAAc,YAAY,CAAA;AAU1B,MAAM,OAAO,aAAa;IAQxB,IAA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+C,CAAC,CAAA;QAClE,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAA;IAC5B,CAAC;IACM,oBAAoB,CAAC,IAAuC;QACjE,IAAI,IAAI,CAAC,OAAO;YACd,OAAO,CAAC,GAAG,CACT,qDAAqD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAC5E,CAAA;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;IACvB,CAAC;IACM,8BAA8B,CAAC,YAAqB;QACzD,IAAI,CAAC,qBAAqB,GAAG,YAAY,CAAA;IAC3C,CAAC;IAED,sCAAsC;IAC/B,MAAM,CAAC,GAAY;QACxB;;;;;;;;;WASG;QAEH,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAA;IACH,CAAC;CACF;AAED,+FAA+F;AAC/F;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACjC,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAA;AACL,CAAC,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CACvC,UAA0B;IAE1B,MAAM,IAAI,KAAK,CACX,gGAAgG,CACjG,CAAA;AACL,CAAC;AACD,YAAY"}
|
package/dist/context/shared.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isOptiGraphConfig } from "@remkoj/optimizely-graph-client";
|
|
1
2
|
export function isTransferrableContext(ctxIn) {
|
|
2
|
-
return typeof (ctxIn) == 'object' && ctxIn != null && ctxIn.factory === undefined;
|
|
3
|
+
return typeof (ctxIn) == 'object' && ctxIn != null && ctxIn.factory === undefined && isOptiGraphConfig(ctxIn.client);
|
|
3
4
|
}
|
|
4
5
|
export function isGenericContext(ctxIn) {
|
|
5
6
|
return typeof (ctxIn) == 'object' && ctxIn != null && typeof ctxIn.factory == 'object' && ctxIn.factory != null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/context/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/context/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,UAAU,sBAAsB,CAAC,KAA0B;IAC/D,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,QAAQ,IAAI,KAAK,IAAI,IAAI,IAAK,KAAwB,CAAC,OAAO,KAAK,SAAS,IAAI,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC1I,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA0B;IACzD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,QAAQ,IAAI,KAAK,IAAI,IAAI,IAAI,OAAQ,KAAwB,CAAC,OAAO,IAAI,QAAQ,IAAK,KAAwB,CAAC,OAAO,IAAI,IAAI,CAAA;AACzJ,CAAC"}
|
package/dist/context/types.d.ts
CHANGED
|
@@ -16,17 +16,9 @@ export interface GenericContext {
|
|
|
16
16
|
/**
|
|
17
17
|
* The context information that can cross the React Server/Client boundary
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
20
|
-
readonly
|
|
21
|
-
|
|
22
|
-
readonly inEditMode: boolean;
|
|
23
|
-
readonly inPreviewMode: boolean;
|
|
24
|
-
readonly isDevelopment: boolean;
|
|
25
|
-
readonly isDebug: boolean;
|
|
26
|
-
readonly isDebugOrDevelopment: boolean;
|
|
27
|
-
readonly editableContent?: ContentLink | null;
|
|
28
|
-
readonly editableContentIsExperience?: boolean;
|
|
29
|
-
}
|
|
19
|
+
export type TransferrableContext = {
|
|
20
|
+
readonly client?: OptimizelyGraphConfig;
|
|
21
|
+
} & Readonly<Omit<GenericContext, 'client' | 'factory'>>;
|
|
30
22
|
export type BaseContext = TransferrableContext | GenericContext;
|
|
31
23
|
export type PropsWithContext<P = {}> = P & {
|
|
32
24
|
ctx: GenericContext;
|
package/dist/factory/default.js
CHANGED
|
@@ -28,21 +28,16 @@ export class DefaultComponentFactory {
|
|
|
28
28
|
}
|
|
29
29
|
register(type, component, useSuspense = false, loader) {
|
|
30
30
|
const registryKey = processComponentTypeHandle(type);
|
|
31
|
-
if (this.dbg)
|
|
32
|
-
console.log(`➕ [DefaultComponentFactory] Registering ${registryKey}`);
|
|
33
31
|
this.registry.set(registryKey, { type, component, useSuspense, loader });
|
|
34
32
|
}
|
|
35
33
|
registerAll(components) {
|
|
36
34
|
components.forEach((c) => {
|
|
37
35
|
const registryKey = processComponentTypeHandle(c.type);
|
|
38
|
-
if (this.dbg)
|
|
39
|
-
console.log(`➕ [DefaultComponentFactory] Registering ${registryKey}`);
|
|
40
36
|
this.registry.set(registryKey, c);
|
|
41
37
|
});
|
|
42
38
|
}
|
|
43
39
|
has(type) {
|
|
44
40
|
const registryKey = processComponentTypeHandle(type);
|
|
45
|
-
//if (this.dbg) console.log(`🔎 [DefaultComponentFactory] Checking for ${ registryKey }`)
|
|
46
41
|
return this.registry.has(registryKey);
|
|
47
42
|
}
|
|
48
43
|
resolve(type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/factory/default.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA;AAElD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAIlC;;;;;OAKG;IACH,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AAC,iCAAiC;aACtF,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,iCAAiC;aAC7E,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,0BAA0B;aAC3E,IAAI,CAAC,YAAY,CAAC,CAAA,CAAC,kCAAkC;IAC1D,MAAM,IAAI,KAAK,CAAC,kCAAkC,OAAO,MAAM,EAAE,CAAC,CAAA;AACpE,CAAC"}
|
package/dist/factory/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentType as ReactComponentType, ExoticComponent as ReactExoticComponent } from "react";
|
|
1
|
+
import type { ComponentType as ReactComponentType, ExoticComponent as ReactExoticComponent, JSX } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Basic Component Type descriptor for the Component Factory
|
|
4
4
|
*/
|
package/dist/rsc.d.ts
CHANGED
package/dist/rsc.js
CHANGED
|
@@ -12,5 +12,6 @@ export * from './context/types.js';
|
|
|
12
12
|
// Export React Server Components
|
|
13
13
|
export * from './context/rsc.js';
|
|
14
14
|
export * from './components/rsc.js';
|
|
15
|
+
export * from './components/rsc-components.js';
|
|
15
16
|
export * from './rsc-utilities.js';
|
|
16
17
|
//# sourceMappingURL=rsc.js.map
|
package/dist/rsc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../src/rsc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,SAAS,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;AAExC,iBAAiB;AACjB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAElC,iCAAiC;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../src/rsc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,SAAS,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;AAExC,iBAAiB;AACjB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAElC,iCAAiC;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oBAAoB,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
|
4
4
|
import type { ContentLinkWithLocale, ContentLink, InlineContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
|
|
5
5
|
import type { GenericContext } from "./context/types.js";
|
|
6
6
|
import type { CmsEditableProps } from "./components/cms-editable/index.js";
|
|
7
|
+
import type { VariationInput } from "@remkoj/optimizely-graph-client/router";
|
|
8
|
+
export type { VariationInput } from "@remkoj/optimizely-graph-client/router";
|
|
7
9
|
export type ContentType = string[];
|
|
8
10
|
export type {
|
|
9
11
|
/**
|
|
@@ -45,12 +47,11 @@ export type CmsComponentProps<T, L extends Record<string, any> = Record<string,
|
|
|
45
47
|
*/
|
|
46
48
|
ctx?: GenericContext;
|
|
47
49
|
}>;
|
|
48
|
-
export type ContentQueryProps<LocaleType = string> = Omit<ContentLink, 'isInline'> & {
|
|
50
|
+
export type ContentQueryProps<LocaleType = string> = Omit<ContentLink, 'isInline' | 'variation'> & {
|
|
49
51
|
locale?: Array<LocaleType> | LocaleType | null;
|
|
50
52
|
path?: string | null;
|
|
51
53
|
domain?: string | null;
|
|
52
|
-
|
|
53
|
-
variant?: string | null;
|
|
54
|
+
variation?: VariationInput | null;
|
|
54
55
|
};
|
|
55
56
|
/**
|
|
56
57
|
* Extract the data type from a GraphQL Query
|
|
@@ -66,6 +67,7 @@ export type GetDataQueryResponseTemplate = {
|
|
|
66
67
|
__typename?: string | null;
|
|
67
68
|
_metadata?: {
|
|
68
69
|
key?: string | null;
|
|
70
|
+
locale?: any | null;
|
|
69
71
|
} | null;
|
|
70
72
|
[key: string]: any;
|
|
71
73
|
} | null;
|
package/dist/utilities.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import type { DocumentNode } from 'graphql';
|
|
3
|
-
import type { ContentLinkWithLocale, ContentLink } from '@remkoj/optimizely-graph-client';
|
|
4
|
-
import type { ContentType, BaseCmsComponent, CmsComponentWithQuery, CmsComponentWithFragment, WithGqlFragment, ContentQueryProps } from './types.js';
|
|
3
|
+
import type { ContentLinkWithLocale, ContentLink, IOptiGraphClient, InlineContentLink } from '@remkoj/optimizely-graph-client';
|
|
4
|
+
import type { ContentType, BaseCmsComponent, CmsComponentWithQuery, CmsComponentWithFragment, WithGqlFragment, ContentQueryProps, CmsComponentProps } from './types.js';
|
|
5
5
|
import type { ComponentFactory, ComponentTypeHandle } from './factory/types.js';
|
|
6
6
|
export * from './components/rich-text/utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Safeguard filter to remove default properties from the CmsComponent, intended
|
|
9
|
+
* to prevent these properties to be passed to client components. It will also
|
|
10
|
+
* remove all properties where the name starts with a `_`.
|
|
11
|
+
*
|
|
12
|
+
* @param toFilter The object to filter the
|
|
13
|
+
* @returns W
|
|
14
|
+
*/
|
|
15
|
+
export declare function filterCmsComponentProps<T extends object>(toFilter: T): Omit<T, keyof CmsComponentProps<any>>;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* @param toTest
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
7
22
|
export declare function isNonEmptyString(toTest: any): toTest is string;
|
|
8
23
|
export declare function isNotNullOrUndefined<T>(toTest?: T | null): toTest is T;
|
|
9
24
|
export declare function isContentType(toTest: any): toTest is ContentType;
|
|
@@ -44,10 +59,36 @@ export declare function resolveComponentType(factory: ComponentFactory, type: Co
|
|
|
44
59
|
export declare function isCmsComponentWithDataQuery<T = DocumentNode>(toTest?: BaseCmsComponent<T>): toTest is CmsComponentWithQuery<T>;
|
|
45
60
|
export declare function isCmsComponentWithFragment<T = DocumentNode>(toTest?: BaseCmsComponent<T>): toTest is CmsComponentWithFragment<T>;
|
|
46
61
|
export declare function validatesFragment<T extends ComponentType<any>>(toTest?: T): toTest is T & Pick<Required<WithGqlFragment<T, any>>, "validateFragment">;
|
|
47
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Take a ContentLink and transform it into the normalized set of request variables used query for content across
|
|
64
|
+
* multiple components.
|
|
65
|
+
*
|
|
66
|
+
* @param contentLink The contentlink to transform
|
|
67
|
+
* @param client If provided, the the configuration of the client is applied to the variables
|
|
68
|
+
* @returns The request variables to use for querying Optimizely Graph
|
|
69
|
+
*/
|
|
70
|
+
export declare function contentLinkToRequestVariables(contentLink: ContentLinkWithLocale, client: IOptiGraphClient): ContentQueryProps;
|
|
71
|
+
/**
|
|
72
|
+
* Normalizes a string|null|undefined input to a non-empty string or undefined. This ensures that a
|
|
73
|
+
* non-empty string is considered insignificant and will not yield an empty result. When provided,
|
|
74
|
+
* the transformer function is applied *after* the non-empty check and the outcome of the transformer
|
|
75
|
+
* is returned.
|
|
76
|
+
*
|
|
77
|
+
* @param inputValue The current value to check
|
|
78
|
+
* @param transformer The transformer to apply to a non-empty string value
|
|
79
|
+
* @returns The output of the transformer when the input is a non-empty string, `undefined` otherwise
|
|
80
|
+
*/
|
|
81
|
+
export declare function ifNonEmptyString<T = string>(inputValue?: string | null, transformer?: (iv: string) => T): T | undefined;
|
|
48
82
|
export declare function toUniqueValues<R extends any>(value: R, index: number, array: Array<R>): value is R;
|
|
49
83
|
export declare function trim<T extends string | null | undefined>(valueToTrim: T): T;
|
|
50
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Extract the identifier needed for the edit HTML properties from the contentLink. This will ensure
|
|
86
|
+
* that inline content links don't output an identifier.
|
|
87
|
+
*
|
|
88
|
+
* @param contentLink
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
export declare function getContentEditId(contentLink?: ContentLink | InlineContentLink | null): string | undefined;
|
|
51
92
|
/**
|
|
52
93
|
* Generate a pseudo-random identifier usable to satisfy the unique key
|
|
53
94
|
* requirement for children within a React node. However this effectively will
|
|
@@ -61,3 +102,12 @@ export declare function getContentEditId(contentLink: ContentLink): string;
|
|
|
61
102
|
* @returns The unique key
|
|
62
103
|
*/
|
|
63
104
|
export declare function getRandomKey(prefix?: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Parse the provided string to determine if it's a valid positive (i.e. larger then 0) number,
|
|
107
|
+
* return the number if it is, `undefined` or the `defaultValue` otherwise.
|
|
108
|
+
*
|
|
109
|
+
* @param value
|
|
110
|
+
* @param defaultValue
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
export declare function tryParsePositiveInt(value: string | undefined | null, defaultValue?: number): number | undefined;
|