@contember/react-client 1.2.0-alpha.0 → 1.2.0-alpha.10
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/development/ContemberClient.js +38 -5
- package/dist/development/ContemberClient.js.map +1 -1
- package/dist/development/auth/SessionTokenContext.js +5 -1
- package/dist/development/auth/SessionTokenContext.js.map +1 -1
- package/dist/development/auth/useSessionToken.js +4 -2
- package/dist/development/auth/useSessionToken.js.map +1 -1
- package/dist/development/components/RichTextRenderer/ElementRenderer.js +6 -2
- package/dist/development/components/RichTextRenderer/ElementRenderer.js.map +1 -1
- package/dist/development/components/RichTextRenderer/LeafRenderer.js +6 -2
- package/dist/development/components/RichTextRenderer/LeafRenderer.js.map +1 -1
- package/dist/development/components/RichTextRenderer/RenderElementFallback.js +94 -21
- package/dist/development/components/RichTextRenderer/RenderElementFallback.js.map +1 -1
- package/dist/development/components/RichTextRenderer/RenderLeafFallback.js +47 -11
- package/dist/development/components/RichTextRenderer/RenderLeafFallback.js.map +1 -1
- package/dist/development/components/RichTextRenderer/RichTextRenderer.js +20 -5
- package/dist/development/components/RichTextRenderer/RichTextRenderer.js.map +1 -1
- package/dist/development/components/RichTextRenderer/renderChildren.js +17 -5
- package/dist/development/components/RichTextRenderer/renderChildren.js.map +1 -1
- package/dist/development/index.js +2 -1
- package/dist/development/upload/fileUploadReducer.js +2 -2
- package/dist/development/upload/fileUploadReducer.js.map +1 -1
- package/dist/production/ContemberClient.js +13 -4
- package/dist/production/ContemberClient.js.map +1 -1
- package/dist/production/auth/SessionTokenContext.js +5 -1
- package/dist/production/auth/SessionTokenContext.js.map +1 -1
- package/dist/production/auth/useSessionToken.js +4 -2
- package/dist/production/auth/useSessionToken.js.map +1 -1
- package/dist/production/components/RichTextRenderer/RichTextRenderer.js.map +1 -1
- package/dist/production/index.js +2 -1
- package/dist/production/upload/fileUploadReducer.js +2 -2
- package/dist/production/upload/fileUploadReducer.js.map +1 -1
- package/dist/types/ContemberClient.d.ts +3 -0
- package/dist/types/ContemberClient.d.ts.map +1 -1
- package/dist/types/auth/SessionTokenContext.d.ts +6 -1
- package/dist/types/auth/SessionTokenContext.d.ts.map +1 -1
- package/dist/types/auth/useSessionToken.d.ts +1 -0
- package/dist/types/auth/useSessionToken.d.ts.map +1 -1
- package/dist/types/components/RichTextRenderer/RichTextRenderer.d.ts +3 -0
- package/dist/types/components/RichTextRenderer/RichTextRenderer.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/ContemberClient.tsx +28 -13
- package/src/auth/SessionTokenContext.ts +11 -1
- package/src/auth/useSessionToken.ts +2 -1
- package/src/components/RichTextRenderer/RichTextRenderer.tsx +3 -0
- package/src/tsconfig.json +2 -1
- package/src/upload/fileUploadReducer.ts +10 -10
- package/dist/development/utils/assertNever.js +0 -7
- package/dist/development/utils/assertNever.js.map +0 -1
- package/dist/production/utils/assertNever.js +0 -7
- package/dist/production/utils/assertNever.js.map +0 -1
- package/dist/types/utils/assertNever.d.ts +0 -2
- package/dist/types/utils/assertNever.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -2
- package/dist/types/utils/index.d.ts.map +0 -1
- package/src/utils/assertNever.ts +0 -3
- package/src/utils/index.ts +0 -1
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { ElementRenderer } from "./ElementRenderer.js";
|
|
3
3
|
import { LeafRenderer } from "./LeafRenderer.js";
|
|
4
4
|
const renderChildren = (children, options) => {
|
|
5
5
|
if (!Array.isArray(children)) {
|
|
6
6
|
children = [children];
|
|
7
7
|
}
|
|
8
|
-
return /* @__PURE__ */
|
|
8
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: children.map((child, i) => {
|
|
9
9
|
if ("text" in child) {
|
|
10
|
-
return /* @__PURE__ */
|
|
10
|
+
return /* @__PURE__ */ jsxDEV(LeafRenderer, { leaf: child, renderLeaf: options.renderLeaf }, i, false, {
|
|
11
|
+
fileName: "/__w/interface/interface/packages/react-client/src/components/RichTextRenderer/renderChildren.tsx",
|
|
12
|
+
lineNumber: 37,
|
|
13
|
+
columnNumber: 13
|
|
14
|
+
}, globalThis);
|
|
11
15
|
}
|
|
12
16
|
if ("children" in child) {
|
|
13
|
-
return /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ jsxDEV(ElementRenderer, { element: child, options, children: renderChildren(child.children, options) }, i, false, {
|
|
18
|
+
fileName: "/__w/interface/interface/packages/react-client/src/components/RichTextRenderer/renderChildren.tsx",
|
|
19
|
+
lineNumber: 41,
|
|
20
|
+
columnNumber: 7
|
|
21
|
+
}, globalThis);
|
|
14
22
|
}
|
|
15
23
|
return null;
|
|
16
|
-
}) }
|
|
24
|
+
}) }, void 0, false, {
|
|
25
|
+
fileName: "/__w/interface/interface/packages/react-client/src/components/RichTextRenderer/renderChildren.tsx",
|
|
26
|
+
lineNumber: 34,
|
|
27
|
+
columnNumber: 3
|
|
28
|
+
}, globalThis);
|
|
17
29
|
};
|
|
18
30
|
export {
|
|
19
31
|
renderChildren
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderChildren.js","sources":["../../../../src/components/RichTextRenderer/renderChildren.tsx"],"sourcesContent":["import type { ReactElement } from 'react'\nimport type { BuiltinElements } from './BuiltinElements'\nimport type { BuiltinLeaves } from './BuiltinLeaves'\nimport { ElementRenderer, RenderElement } from './ElementRenderer'\nimport { LeafRenderer, RenderLeaf } from './LeafRenderer'\nimport type { RichTextElement } from './RichTextElement'\nimport type { RichTextLeaf } from './RichTextLeaf'\n\nexport interface RenderChildrenOptions<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n> {\n\trenderElement?: RenderElement<CustomElements, CustomLeaves>\n\trenderLeaf?: RenderLeaf<CustomLeaves>\n\tattributeNamePrefix?: string\n}\n\nexport const renderChildren = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n>(\n\tchildren:\n\t\t| CustomElements\n\t\t| BuiltinElements<CustomElements, CustomLeaves>\n\t\t| CustomLeaves\n\t\t| BuiltinLeaves\n\t\t| Array<CustomElements | BuiltinElements<CustomElements, CustomLeaves> | CustomLeaves | BuiltinLeaves>,\n\toptions: RenderChildrenOptions<CustomElements, CustomLeaves>,\n): ReactElement => {\n\tif (!Array.isArray(children)) {\n\t\tchildren = [children]\n\t}\n\treturn (\n\t\t<>\n\t\t\t{children.map((child, i) => {\n\t\t\t\tif ('text' in child) {\n\t\t\t\t\treturn <LeafRenderer<CustomLeaves> key={i} leaf={child} renderLeaf={options.renderLeaf} />\n\t\t\t\t}\n\t\t\t\tif ('children' in child) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ElementRenderer<CustomElements, CustomLeaves> key={i} element={child} options={options}>\n\t\t\t\t\t\t\t{renderChildren<CustomElements, CustomLeaves>(child.children as typeof children, options)}\n\t\t\t\t\t\t</ElementRenderer>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn null // Throw?\n\t\t\t})}\n\t\t</>\n\t)\n}\n"],"names":[],"mappings":";;;AAiBa,MAAA,iBAAiB,CAI7B,UAMA,YACkB;AAClB,MAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG;AAC7B,eAAW,CAAC,QAAQ;AAAA,EACrB;AACA,SAEG,
|
|
1
|
+
{"version":3,"file":"renderChildren.js","sources":["../../../../src/components/RichTextRenderer/renderChildren.tsx"],"sourcesContent":["import type { ReactElement } from 'react'\nimport type { BuiltinElements } from './BuiltinElements'\nimport type { BuiltinLeaves } from './BuiltinLeaves'\nimport { ElementRenderer, RenderElement } from './ElementRenderer'\nimport { LeafRenderer, RenderLeaf } from './LeafRenderer'\nimport type { RichTextElement } from './RichTextElement'\nimport type { RichTextLeaf } from './RichTextLeaf'\n\nexport interface RenderChildrenOptions<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n> {\n\trenderElement?: RenderElement<CustomElements, CustomLeaves>\n\trenderLeaf?: RenderLeaf<CustomLeaves>\n\tattributeNamePrefix?: string\n}\n\nexport const renderChildren = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n>(\n\tchildren:\n\t\t| CustomElements\n\t\t| BuiltinElements<CustomElements, CustomLeaves>\n\t\t| CustomLeaves\n\t\t| BuiltinLeaves\n\t\t| Array<CustomElements | BuiltinElements<CustomElements, CustomLeaves> | CustomLeaves | BuiltinLeaves>,\n\toptions: RenderChildrenOptions<CustomElements, CustomLeaves>,\n): ReactElement => {\n\tif (!Array.isArray(children)) {\n\t\tchildren = [children]\n\t}\n\treturn (\n\t\t<>\n\t\t\t{children.map((child, i) => {\n\t\t\t\tif ('text' in child) {\n\t\t\t\t\treturn <LeafRenderer<CustomLeaves> key={i} leaf={child} renderLeaf={options.renderLeaf} />\n\t\t\t\t}\n\t\t\t\tif ('children' in child) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ElementRenderer<CustomElements, CustomLeaves> key={i} element={child} options={options}>\n\t\t\t\t\t\t\t{renderChildren<CustomElements, CustomLeaves>(child.children as typeof children, options)}\n\t\t\t\t\t\t</ElementRenderer>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn null // Throw?\n\t\t\t})}\n\t\t</>\n\t)\n}\n"],"names":["this"],"mappings":";;;AAiBa,MAAA,iBAAiB,CAI7B,UAMA,YACkB;AAClB,MAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG;AAC7B,eAAW,CAAC,QAAQ;AAAA,EACrB;AACA,SAEG,uBAAA,UAAA,EAAA,UAAA,SAAS,IAAI,CAAC,OAAO,MAAM;AAC3B,QAAI,UAAU,OAAO;AACpB,oCAAQ,cAAmC,EAAA,MAAM,OAAO,YAAY,QAAQ,cAApC,GAAjC,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAiF,GAAAA,UAAA;AAAA,IACzF;AACA,QAAI,cAAc,OAAO;AAEvB,aAAA,uBAAC,iBAAsD,EAAA,SAAS,OAAO,SACrE,yBAA6C,MAAM,UAA6B,OAAO,EAAA,GADrC,GAApD,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAEA,GAAAA,UAAA;AAAA,IAEF;AACO,WAAA;AAAA,EAAA,CACP,EAbF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAcA,GAAAA,UAAA;AAEF;"}
|
|
@@ -6,7 +6,7 @@ import { apiRequestReducer } from "./apiRequest/apiRequestReducer.js";
|
|
|
6
6
|
import { useApiRequest } from "./apiRequest/useApiRequest.js";
|
|
7
7
|
import { SessionTokenContext } from "./auth/SessionTokenContext.js";
|
|
8
8
|
import { SetSessionTokenContext } from "./auth/SetSessionTokenContext.js";
|
|
9
|
-
import { useSessionToken } from "./auth/useSessionToken.js";
|
|
9
|
+
import { useSessionToken, useSessionTokenWithMeta } from "./auth/useSessionToken.js";
|
|
10
10
|
import { useSetSessionToken } from "./auth/useSetSessionToken.js";
|
|
11
11
|
import { RichTextRenderer } from "./components/RichTextRenderer/RichTextRenderer.js";
|
|
12
12
|
import { RichTextRendererError } from "./components/RichTextRenderer/RichTextRendererError.js";
|
|
@@ -50,6 +50,7 @@ export {
|
|
|
50
50
|
useLoginToken,
|
|
51
51
|
useProjectSlug,
|
|
52
52
|
useSessionToken,
|
|
53
|
+
useSessionTokenWithMeta,
|
|
53
54
|
useSetSessionToken,
|
|
54
55
|
useStageSlug,
|
|
55
56
|
useSystemApiRequest,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileUploadError } from "@contember/client";
|
|
2
|
+
import { assertNever } from "@contember/utilities";
|
|
2
3
|
import { toFileId } from "./toFileId.js";
|
|
3
|
-
import { assertNever } from "../utils/assertNever.js";
|
|
4
4
|
const initializeFileUploadState = () => ({
|
|
5
5
|
fileIdByFile: /* @__PURE__ */ new WeakMap(),
|
|
6
6
|
state: /* @__PURE__ */ new Map()
|
|
@@ -136,7 +136,7 @@ const fileUploadReducer = (previousState, action) => {
|
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
138
|
default:
|
|
139
|
-
assertNever();
|
|
139
|
+
assertNever(action);
|
|
140
140
|
}
|
|
141
141
|
if (newState === void 0) {
|
|
142
142
|
return previousState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileUploadReducer.js","sources":["../../../src/upload/fileUploadReducer.ts"],"sourcesContent":["import { FileUploadError } from '@contember/client'\nimport { assertNever } from '
|
|
1
|
+
{"version":3,"file":"fileUploadReducer.js","sources":["../../../src/upload/fileUploadReducer.ts"],"sourcesContent":["import { FileUploadError } from '@contember/client'\nimport { assertNever } from '@contember/utilities'\nimport type { FileId } from './FileId'\nimport type { FileUploadAction } from './FileUploadAction'\nimport type { FileUploadMultiTemporalState } from './FileUploadMultiTemporalState'\nimport { toFileId } from './toFileId'\n\nexport const initializeFileUploadState = <Result = unknown, Metadata = undefined>(): FileUploadMultiTemporalState<Result, Metadata> => ({\n\tfileIdByFile: new WeakMap<File, FileId>(),\n\tstate: new Map(),\n})\n\nexport const fileUploadReducer = <Result = unknown, Metadata = undefined>(\n\tpreviousState: FileUploadMultiTemporalState<Result, Metadata>,\n\taction: FileUploadAction<Result, Metadata>,\n): FileUploadMultiTemporalState<Result, Metadata> => {\n\tlet newState: undefined | FileUploadMultiTemporalState<Result, Metadata>['state'] = undefined\n\n\tswitch (action.type) {\n\t\tcase 'initialize': {\n\t\t\tfor (const [fileId, metadata] of action.files) {\n\t\t\t\t// Deliberately allowing starting a new upload with the same id\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'initializing',\n\t\t\t\t\tabortController: metadata.abortController,\n\t\t\t\t\tpreviewUrl: metadata.previewUrl,\n\t\t\t\t\tfile: metadata.file,\n\t\t\t\t})\n\t\t\t\t// Deliberately mutating\n\t\t\t\tpreviousState.fileIdByFile.set(metadata.file, fileId)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'startUploading': {\n\t\t\tfor (const [fileOrId, metadata] of action.files) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst fileState = (newState ?? previousState.state).get(fileId)\n\n\t\t\t\tif (fileState === undefined || fileState.readyState !== 'initializing') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'uploading',\n\t\t\t\t\tabortController: fileState.abortController,\n\t\t\t\t\tfile: fileState.file,\n\t\t\t\t\tmetadata: metadata.metadata!, // If the user didn't supply the metadata, then that's on them.\n\t\t\t\t\tpreviewUrl: fileState.previewUrl,\n\t\t\t\t\tprogress: undefined,\n\t\t\t\t\tuploader: metadata.uploader,\n\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'finishSuccessfully': {\n\t\t\tfor (const [fileOrId, result] of action.result) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst previousFileState = (newState ?? previousState.state).get(fileId)\n\t\t\t\tif (previousFileState === undefined || previousFileState.readyState !== 'uploading') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'success',\n\t\t\t\t\tfile: previousFileState.file,\n\t\t\t\t\tmetadata: previousFileState.metadata,\n\t\t\t\t\tpreviewUrl: previousFileState.previewUrl,\n\t\t\t\t\tresult,\n\t\t\t\t\tuploader: previousFileState.uploader,\n\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'finishWithError': {\n\t\t\tfor (const errorSpec of action.error) {\n\t\t\t\tlet fileOrId: File | FileId\n\t\t\t\tlet rawError: unknown\n\n\t\t\t\tif (Array.isArray(errorSpec)) {\n\t\t\t\t\t[fileOrId, rawError] = errorSpec\n\t\t\t\t} else {\n\t\t\t\t\tfileOrId = errorSpec\n\t\t\t\t\trawError = undefined\n\t\t\t\t}\n\n\t\t\t\tconst errors: FileUploadError[] = []\n\n\t\t\t\tif (rawError instanceof FileUploadError) {\n\t\t\t\t\terrors.push(rawError)\n\t\t\t\t} else if (Array.isArray(rawError)) {\n\t\t\t\t\tfor (const error of rawError) {\n\t\t\t\t\t\tif (error instanceof FileUploadError) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst previousFileState = (newState ?? previousState.state).get(fileId)\n\t\t\t\tif (\n\t\t\t\t\tpreviousFileState === undefined ||\n\t\t\t\t\t(previousFileState.readyState !== 'initializing' && previousFileState.readyState !== 'uploading')\n\t\t\t\t) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst uploader = previousFileState.readyState === 'uploading' ? previousFileState.uploader : undefined\n\t\t\t\tconst metadata = previousFileState.readyState === 'uploading' ? previousFileState.metadata : undefined\n\t\t\t\t\t; (newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\t\treadyState: 'error',\n\t\t\t\t\t\terrors: errors.length ? errors : undefined,\n\t\t\t\t\t\trawError,\n\t\t\t\t\t\tfile: previousFileState.file,\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\tpreviewUrl: previousFileState.previewUrl,\n\t\t\t\t\t\tuploader,\n\t\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'purge': {\n\t\t\tfor (const fileOrId of action.files) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst fileState = (newState ?? previousState.state).get(fileId)\n\n\t\t\t\tif (fileState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tURL.revokeObjectURL(fileState.previewUrl)\n\t\t\t\tif (fileState.readyState === 'initializing' || fileState.readyState === 'uploading') {\n\t\t\t\t\tfileState.abortController.abort() // This is a bit naughty… We shouldn't do this from here.\n\t\t\t\t}\n\t\t\t\t(newState ??= new Map(previousState.state)).delete(fileId)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'updateUploadProgress': {\n\t\t\tfor (const [fileOrId, { progress }] of action.progress) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst previousFileState = (newState ?? previousState.state).get(fileId)\n\t\t\t\tif (progress === undefined || previousFileState === undefined || previousFileState.readyState !== 'uploading') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst roundedProgress = Math.floor(progress) // throttling\n\t\t\t\tif (roundedProgress === previousFileState.progress) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'uploading',\n\t\t\t\t\tfile: previousFileState.file,\n\t\t\t\t\tuploader: previousFileState.uploader,\n\t\t\t\t\tabortController: previousFileState.abortController,\n\t\t\t\t\tpreviewUrl: previousFileState.previewUrl,\n\t\t\t\t\tmetadata: previousFileState.metadata,\n\t\t\t\t\tprogress: roundedProgress,\n\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tdefault:\n\t\t\tassertNever(action)\n\t}\n\tif (newState === undefined) {\n\t\treturn previousState\n\t}\n\treturn { ...previousState, state: newState }\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,4BAA4B,OAA+F;AAAA,EACvI,kCAAkB,QAAsB;AAAA,EACxC,2BAAW,IAAI;AAChB;AAEa,MAAA,oBAAoB,CAChC,eACA,WACoD;AACpD,MAAI,WAAgF;AAEpF,UAAQ,OAAO,MAAM;AAAA,IACpB,KAAK,cAAc;AAClB,iBAAW,CAAC,QAAQ,QAAQ,KAAK,OAAO,OAA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BAAU,gBAAgB;QAC3B;AACA,SAAC,wBAAa,IAAI,IAAI,cAAc,KAAK,IAAG,OAAO,MAAM;AAAA,MAC1D;AACA;AAAA,IACD;AAAA,IACA,KAAK,wBAAwB;AAC5B,iBAAW,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,UAAU;AACjD,cAAA,SAAS,SAAS,eAAe,QAAQ;AAC/C,cAAM,qBAAqB,YAAY,cAAc,OAAO,IAAI,MAAM;AACtE,YAAI,aAAa,UAAa,sBAAsB,UAAa,kBAAkB,eAAe,aAAa;AAC9G;AAAA,QACD;AACM,cAAA,kBAAkB,KAAK,MAAM,QAAQ;AACvC,YAAA,oBAAoB,kBAAkB,UAAU;AACnD;AAAA,QACD;AACA,SAAC,wBAAa,IAAI,IAAI,cAAc,KAAK,IAAG,IAAI,QAAQ;AAAA,UACvD,YAAY;AAAA,UACZ,MAAM,kBAAkB;AAAA,UACxB,UAAU,kBAAkB;AAAA,UAC5B,iBAAiB,kBAAkB;AAAA,UACnC,YAAY,kBAAkB;AAAA,UAC9B,UAAU,kBAAkB;AAAA,UAC5B,UAAU;AAAA,QAAA,CACV;AAAA,MACF;AACA;AAAA,IACD;AAAA,IACA;AACC,kBAAY,MAAM;AAAA,EACpB;AACA,MAAI,aAAa,QAAW;AACpB,WAAA;AAAA,EACR;AACA,SAAO,EAAE,GAAG,eAAe,OAAO,SAAS;AAC5C;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useState, useCallback } from "react";
|
|
2
|
+
import { memo, useMemo, useState, useCallback } from "react";
|
|
3
3
|
import { ApiBaseUrlContext } from "./config/ApiBaseUrlContext.js";
|
|
4
4
|
import { LoginTokenContext } from "./config/LoginTokenContext.js";
|
|
5
5
|
import { SetSessionTokenContext } from "./auth/SetSessionTokenContext.js";
|
|
@@ -15,7 +15,16 @@ const ContemberClient = memo(function ContemberClient2({
|
|
|
15
15
|
sessionToken,
|
|
16
16
|
stage
|
|
17
17
|
}) {
|
|
18
|
-
const [
|
|
18
|
+
const [localStorageSessionToken, setLocalStorageSessionToken] = useLocalStorageSessionToken();
|
|
19
|
+
const sessionTokenContextValue = useMemo(() => ({
|
|
20
|
+
propsToken: sessionToken,
|
|
21
|
+
token: localStorageSessionToken ?? sessionToken,
|
|
22
|
+
source: localStorageSessionToken ? "localstorage" : sessionToken ? "props" : void 0
|
|
23
|
+
}), [localStorageSessionToken, sessionToken]);
|
|
24
|
+
return /* @__PURE__ */ jsx(ApiBaseUrlContext.Provider, { value: apiBaseUrl, children: /* @__PURE__ */ jsx(LoginTokenContext.Provider, { value: loginToken, children: /* @__PURE__ */ jsx(SetSessionTokenContext.Provider, { value: setLocalStorageSessionToken, children: /* @__PURE__ */ jsx(SessionTokenContext.Provider, { value: sessionTokenContextValue, children: /* @__PURE__ */ jsx(ProjectSlugContext.Provider, { value: project, children: /* @__PURE__ */ jsx(StageSlugContext.Provider, { value: stage, children }) }) }) }) }) });
|
|
25
|
+
});
|
|
26
|
+
const useLocalStorageSessionToken = () => {
|
|
27
|
+
const [sessionTokenInner, setSessionTokenInner] = useState(() => localStorage.getItem(sessionTokenKey) ?? void 0);
|
|
19
28
|
const setSessionToken = useCallback((token) => {
|
|
20
29
|
if (token !== void 0) {
|
|
21
30
|
localStorage.setItem(sessionTokenKey, token);
|
|
@@ -24,8 +33,8 @@ const ContemberClient = memo(function ContemberClient2({
|
|
|
24
33
|
}
|
|
25
34
|
setSessionTokenInner(token);
|
|
26
35
|
}, []);
|
|
27
|
-
return
|
|
28
|
-
}
|
|
36
|
+
return [sessionTokenInner, setSessionToken];
|
|
37
|
+
};
|
|
29
38
|
export {
|
|
30
39
|
ContemberClient
|
|
31
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContemberClient.js","sources":["../../src/ContemberClient.tsx"],"sourcesContent":["import { memo, useCallback,
|
|
1
|
+
{"version":3,"file":"ContemberClient.js","sources":["../../src/ContemberClient.tsx"],"sourcesContent":["import { memo, useCallback, useMemo, useState } from 'react'\nimport { SessionTokenContext, SessionTokenContextValue, SetSessionTokenContext } from './auth'\nimport { ApiBaseUrlContext, LoginTokenContext } from './config'\nimport { ProjectSlugContext, StageSlugContext } from './project'\n\nexport interface ContemberClientProps {\n\tapiBaseUrl: string\n\tsessionToken?: string\n\tloginToken?: string\n\tproject?: string\n\tstage?: string\n}\n\nconst sessionTokenKey = 'contember_session_token'\n\n/**\n * @group Entrypoints\n */\nexport const ContemberClient = memo<ContemberClientProps & { children: React.ReactNode }>(function ContemberClient({\n\tapiBaseUrl,\n\tchildren,\n\tloginToken,\n\tproject,\n\tsessionToken,\n\tstage,\n}) {\n\tconst [localStorageSessionToken, setLocalStorageSessionToken] = useLocalStorageSessionToken()\n\n\tconst sessionTokenContextValue = useMemo((): SessionTokenContextValue => ({\n\t\tpropsToken: sessionToken,\n\t\ttoken: localStorageSessionToken ?? sessionToken,\n\t\tsource: localStorageSessionToken ? 'localstorage' : (sessionToken ? 'props' : undefined),\n\t}), [localStorageSessionToken, sessionToken])\n\n\treturn (\n\t\t<ApiBaseUrlContext.Provider value={apiBaseUrl}>\n\t\t\t<LoginTokenContext.Provider value={loginToken}>\n\t\t\t\t<SetSessionTokenContext.Provider value={setLocalStorageSessionToken}>\n\t\t\t\t\t<SessionTokenContext.Provider value={sessionTokenContextValue}>\n\t\t\t\t\t\t<ProjectSlugContext.Provider value={project}>\n\t\t\t\t\t\t\t<StageSlugContext.Provider value={stage}>{children}</StageSlugContext.Provider>\n\t\t\t\t\t\t</ProjectSlugContext.Provider>\n\t\t\t\t\t</SessionTokenContext.Provider>\n\t\t\t\t</SetSessionTokenContext.Provider>\n\t\t\t</LoginTokenContext.Provider>\n\t\t</ApiBaseUrlContext.Provider>\n\t)\n})\n\nconst useLocalStorageSessionToken = (): [value: string | undefined, set: (token: string | undefined) => void] => {\n\tconst [sessionTokenInner, setSessionTokenInner] = useState(() => localStorage.getItem(sessionTokenKey) ?? undefined)\n\n\tconst setSessionToken = useCallback((token: string | undefined) => {\n\t\tif (token !== undefined) {\n\t\t\tlocalStorage.setItem(sessionTokenKey, token)\n\t\t} else {\n\t\t\tlocalStorage.removeItem(sessionTokenKey)\n\t\t}\n\t\tsetSessionTokenInner(token)\n\t}, [])\n\n\treturn [sessionTokenInner, setSessionToken]\n}\n"],"names":["ContemberClient"],"mappings":";;;;;;;;AAaA,MAAM,kBAAkB;AAKX,MAAA,kBAAkB,KAA2D,SAASA,iBAAgB;AAAA,EAClH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAG;AACF,QAAM,CAAC,0BAA0B,2BAA2B,IAAI,4BAA4B;AAEtF,QAAA,2BAA2B,QAAQ,OAAiC;AAAA,IACzE,YAAY;AAAA,IACZ,OAAO,4BAA4B;AAAA,IACnC,QAAQ,2BAA2B,iBAAkB,eAAe,UAAU;AAAA,EAC3E,IAAA,CAAC,0BAA0B,YAAY,CAAC;AAE5C,6BACE,kBAAkB,UAAlB,EAA2B,OAAO,YAClC,8BAAC,kBAAkB,UAAlB,EAA2B,OAAO,YAClC,UAAC,oBAAA,uBAAuB,UAAvB,EAAgC,OAAO,6BACvC,UAAC,oBAAA,oBAAoB,UAApB,EAA6B,OAAO,0BACpC,UAAA,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACnC,UAAA,oBAAC,iBAAiB,UAAjB,EAA0B,OAAO,OAAQ,SAAS,CAAA,GACpD,EACD,CAAA,EACD,CAAA,GACD,EACD,CAAA;AAEF,CAAC;AAED,MAAM,8BAA8B,MAA6E;AAC1G,QAAA,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,MAAM,aAAa,QAAQ,eAAe,KAAK,MAAS;AAE7G,QAAA,kBAAkB,YAAY,CAAC,UAA8B;AAClE,QAAI,UAAU,QAAW;AACX,mBAAA,QAAQ,iBAAiB,KAAK;AAAA,IAAA,OACrC;AACN,mBAAa,WAAW,eAAe;AAAA,IACxC;AACA,yBAAqB,KAAK;AAAA,EAC3B,GAAG,CAAE,CAAA;AAEE,SAAA,CAAC,mBAAmB,eAAe;AAC3C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionTokenContext.js","sources":["../../../src/auth/SessionTokenContext.ts"],"sourcesContent":["import { createContext } from 'react'\n\nexport const SessionTokenContext = createContext<
|
|
1
|
+
{"version":3,"file":"SessionTokenContext.js","sources":["../../../src/auth/SessionTokenContext.ts"],"sourcesContent":["import { createContext } from 'react'\n\nexport interface SessionTokenContextValue {\n\tpropsToken: string | undefined\n\tsource: 'props' | 'localstorage' | undefined\n\ttoken: string | undefined\n}\n\nexport const SessionTokenContext = createContext<SessionTokenContextValue>({\n\tpropsToken: undefined,\n\tsource: undefined,\n\ttoken: undefined,\n})\n"],"names":[],"mappings":";AAQO,MAAM,sBAAsB,cAAwC;AAAA,EAC1E,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,OAAO;AACR,CAAC;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { SessionTokenContext } from "./SessionTokenContext.js";
|
|
3
|
-
const useSessionToken = () => useContext(SessionTokenContext);
|
|
3
|
+
const useSessionToken = () => useContext(SessionTokenContext).token;
|
|
4
|
+
const useSessionTokenWithMeta = () => useContext(SessionTokenContext);
|
|
4
5
|
export {
|
|
5
|
-
useSessionToken
|
|
6
|
+
useSessionToken,
|
|
7
|
+
useSessionTokenWithMeta
|
|
6
8
|
};
|
|
7
9
|
//# sourceMappingURL=useSessionToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSessionToken.js","sources":["../../../src/auth/useSessionToken.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { SessionTokenContext } from './SessionTokenContext'\n\nexport const useSessionToken = () => useContext(SessionTokenContext)\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useSessionToken.js","sources":["../../../src/auth/useSessionToken.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { SessionTokenContext } from './SessionTokenContext'\n\nexport const useSessionToken = () => useContext(SessionTokenContext).token\nexport const useSessionTokenWithMeta = () => useContext(SessionTokenContext)\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAkB,MAAM,WAAW,mBAAmB,EAAE;AACxD,MAAA,0BAA0B,MAAM,WAAW,mBAAmB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextRenderer.js","sources":["../../../../src/components/RichTextRenderer/RichTextRenderer.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode, useMemo } from 'react'\nimport { defaultDeserialize } from './defaultDeserialize'\nimport type { RenderElement } from './ElementRenderer'\nimport type { RenderLeaf } from './LeafRenderer'\nimport type { NormalizedRichTextBlock } from './NormalizedRichTextBlock'\nimport type { ReferenceRenderer } from './ReferenceRenderer'\nimport { renderChildren } from './renderChildren'\nimport type { RichTextBlock } from './RichTextBlock'\nimport type { RichTextElement } from './RichTextElement'\nimport type { RichTextLeaf } from './RichTextLeaf'\nimport type { RichTextReference } from './RichTextReference'\nimport { RichTextRendererError } from './RichTextRendererError'\nimport { RichTextRenderMetadataContext } from './RichTextRenderMetadataContext'\nimport type { RootEditorNode } from './RootEditorNode'\n\nexport interface RichTextRendererFieldProps {\n\tsource: string | null\n}\n\nexport interface RichTextRendererBlockProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n> {\n\tblocks: RichTextBlock[]\n\treferenceRenderers?: Record<string, ReferenceRenderer<any, CustomElements, CustomLeaves>>\n\tsourceField?: string\n\treferencesField?: string\n\treferenceDiscriminationField?: string\n}\n\nexport type RichTextRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n> = {\n\tdeserialize?: (source: string) => RootEditorNode<CustomElements, CustomLeaves>\n\trenderElement?: RenderElement<CustomElements, CustomLeaves>\n\trenderLeaf?: RenderLeaf<CustomLeaves>\n\tattributeNamePrefix?: string\n\trenderBlock?: ComponentType<{ block: unknown, children?: ReactNode }>\n} & (RichTextRendererFieldProps | RichTextRendererBlockProps<CustomElements, CustomLeaves>)\n\nexport const RichTextRenderer = memo(function RichTextRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n>({\n\tdeserialize = defaultDeserialize,\n\trenderElement,\n\trenderLeaf,\n\trenderBlock = ({ children }) => <>{children}</>,\n\tattributeNamePrefix,\n\t...sourceProps\n}: RichTextRendererProps<CustomElements, CustomLeaves>) {\n\tconst normalizedSource = useMemo<NormalizedRichTextBlock<CustomElements, CustomLeaves>[]>(() => {\n\t\tif ('source' in sourceProps && !('blocks' in sourceProps)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tcontent: sourceProps.source\n\t\t\t\t\t\t? deserialize(sourceProps.source)\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tformatVersion: 0,\n\t\t\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\t },\n\t\t\t\t\tid: undefined,\n\t\t\t\t\treferencesField: undefined,\n\t\t\t\t\treferenceDiscriminationField: undefined,\n\t\t\t\t\treferenceRenderers: {},\n\t\t\t\t\treferences: undefined,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\tif (!('source' in sourceProps)) {\n\t\t\tconst sourceField = sourceProps.sourceField ?? 'source'\n\t\t\tconst referencesField = sourceProps.referencesField ?? 'references'\n\t\t\tconst referenceDiscriminationField = sourceProps.referenceDiscriminationField ?? 'type'\n\n\t\t\treturn sourceProps.blocks.map(block => {\n\t\t\t\tif (!(sourceField in block)) {\n\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t`Found a block without a '${sourceField}' field. ` +\n\t\t\t\t\t\t\t(sourceProps.sourceField === undefined\n\t\t\t\t\t\t\t\t? `The 'sourceField' prop has not been supplied, and so '${sourceField}' was used as a default.`\n\t\t\t\t\t\t\t\t: `That is what the 'sourceField' prop has been set to, and so either this is a typo, ` +\n\t\t\t\t\t\t\t\t `or the data supplied is invalid.`),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst source = block[sourceField]\n\t\t\t\tif (typeof source !== 'string') {\n\t\t\t\t\tthrow new RichTextRendererError(`Found a block whose source is not a string.`)\n\t\t\t\t}\n\n\t\t\t\tif (sourceProps.referencesField !== undefined && !(referencesField in block)) {\n\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t`The 'referencesField' prop is set to '${referencesField}' but a block without such field ` +\n\t\t\t\t\t\t\t`has been encountered. Unless this is just a typo, ` +\n\t\t\t\t\t\t\t`if you do not wish to use references, avoid supplying the 'referencesField' prop.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst references = block[referencesField]\n\n\t\t\t\tlet normalizedReferences: Map<string, RichTextReference> | undefined = undefined\n\t\t\t\tif (references) {\n\t\t\t\t\tif (typeof Object(references)[Symbol.iterator] !== 'function') {\n\t\t\t\t\t\tthrow new RichTextRendererError(`The set of references must be an iterable!`)\n\t\t\t\t\t}\n\n\t\t\t\t\tnormalizedReferences = new Map()\n\t\t\t\t\tfor (const reference of references as Iterable<RichTextReference>) {\n\t\t\t\t\t\tif (!('id' in reference)) {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(`Found a reference without an id field.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!(referenceDiscriminationField in reference)) {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t\t\t`Found a reference without a '${referenceDiscriminationField}' field. ` +\n\t\t\t\t\t\t\t\t\t(sourceProps.referenceDiscriminationField === undefined\n\t\t\t\t\t\t\t\t\t\t? `The 'referenceDiscriminationField' prop has not been supplied, ` +\n\t\t\t\t\t\t\t\t\t\t `and so '${referenceDiscriminationField}' was used as a default.`\n\t\t\t\t\t\t\t\t\t\t: `That is what the 'referenceDiscriminationField' prop has been set to, ` +\n\t\t\t\t\t\t\t\t\t\t `and so either this is a typo, or the data supplied is invalid.`),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnormalizedReferences.set(reference.id, reference)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tid: typeof block.id === 'string' ? block.id : undefined,\n\t\t\t\t\tcontent: deserialize(source),\n\t\t\t\t\treferenceDiscriminationField,\n\t\t\t\t\treferenceRenderers: sourceProps.referenceRenderers ?? {},\n\t\t\t\t\treferencesField,\n\t\t\t\t\treferences: normalizedReferences,\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tthrow new RichTextRendererError(`RichTextRenderer: invalid data supplied.`)\n\t}, [deserialize, sourceProps])\n\n\treturn (\n\t\t<>\n\t\t\t{normalizedSource.map((block, i) => (\n\t\t\t\t<RichTextRenderMetadataContext.Provider\n\t\t\t\t\tkey={block.id ?? i}\n\t\t\t\t\tvalue={{\n\t\t\t\t\t\tformatVersion: block.content.formatVersion,\n\t\t\t\t\t\treferenceRenderers: block.referenceRenderers,\n\t\t\t\t\t\treferencesField: block.referencesField,\n\t\t\t\t\t\treferenceDiscriminationField: block.referenceDiscriminationField,\n\t\t\t\t\t\treferences: block.references,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{createElement(\n\t\t\t\t\t\trenderBlock, {\n\t\t\t\t\t\t\tblock,\n\t\t\t\t\t\t}, renderChildren(block.content.children, {\n\t\t\t\t\t\t\trenderLeaf,\n\t\t\t\t\t\t\trenderElement,\n\t\t\t\t\t\t\tattributeNamePrefix,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)}\n\t\t\t\t</RichTextRenderMetadataContext.Provider>\n\t\t\t))}\n\t\t</>\n\t)\n}) as <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = never>(\n\tprops: RichTextRendererProps<CustomElements, CustomLeaves>,\n) => ReactElement\n"],"names":["RichTextRenderer"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"RichTextRenderer.js","sources":["../../../../src/components/RichTextRenderer/RichTextRenderer.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode, useMemo } from 'react'\nimport { defaultDeserialize } from './defaultDeserialize'\nimport type { RenderElement } from './ElementRenderer'\nimport type { RenderLeaf } from './LeafRenderer'\nimport type { NormalizedRichTextBlock } from './NormalizedRichTextBlock'\nimport type { ReferenceRenderer } from './ReferenceRenderer'\nimport { renderChildren } from './renderChildren'\nimport type { RichTextBlock } from './RichTextBlock'\nimport type { RichTextElement } from './RichTextElement'\nimport type { RichTextLeaf } from './RichTextLeaf'\nimport type { RichTextReference } from './RichTextReference'\nimport { RichTextRendererError } from './RichTextRendererError'\nimport { RichTextRenderMetadataContext } from './RichTextRenderMetadataContext'\nimport type { RootEditorNode } from './RootEditorNode'\n\nexport interface RichTextRendererFieldProps {\n\tsource: string | null\n}\n\nexport interface RichTextRendererBlockProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n> {\n\tblocks: RichTextBlock[]\n\treferenceRenderers?: Record<string, ReferenceRenderer<any, CustomElements, CustomLeaves>>\n\tsourceField?: string\n\treferencesField?: string\n\treferenceDiscriminationField?: string\n}\n\nexport type RichTextRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n> = {\n\tdeserialize?: (source: string) => RootEditorNode<CustomElements, CustomLeaves>\n\trenderElement?: RenderElement<CustomElements, CustomLeaves>\n\trenderLeaf?: RenderLeaf<CustomLeaves>\n\tattributeNamePrefix?: string\n\trenderBlock?: ComponentType<{ block: unknown, children?: ReactNode }>\n} & (RichTextRendererFieldProps | RichTextRendererBlockProps<CustomElements, CustomLeaves>)\n\n/**\n * @group Content rendering\n */\nexport const RichTextRenderer = memo(function RichTextRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = never,\n>({\n\tdeserialize = defaultDeserialize,\n\trenderElement,\n\trenderLeaf,\n\trenderBlock = ({ children }) => <>{children}</>,\n\tattributeNamePrefix,\n\t...sourceProps\n}: RichTextRendererProps<CustomElements, CustomLeaves>) {\n\tconst normalizedSource = useMemo<NormalizedRichTextBlock<CustomElements, CustomLeaves>[]>(() => {\n\t\tif ('source' in sourceProps && !('blocks' in sourceProps)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tcontent: sourceProps.source\n\t\t\t\t\t\t? deserialize(sourceProps.source)\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tformatVersion: 0,\n\t\t\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\t },\n\t\t\t\t\tid: undefined,\n\t\t\t\t\treferencesField: undefined,\n\t\t\t\t\treferenceDiscriminationField: undefined,\n\t\t\t\t\treferenceRenderers: {},\n\t\t\t\t\treferences: undefined,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\tif (!('source' in sourceProps)) {\n\t\t\tconst sourceField = sourceProps.sourceField ?? 'source'\n\t\t\tconst referencesField = sourceProps.referencesField ?? 'references'\n\t\t\tconst referenceDiscriminationField = sourceProps.referenceDiscriminationField ?? 'type'\n\n\t\t\treturn sourceProps.blocks.map(block => {\n\t\t\t\tif (!(sourceField in block)) {\n\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t`Found a block without a '${sourceField}' field. ` +\n\t\t\t\t\t\t\t(sourceProps.sourceField === undefined\n\t\t\t\t\t\t\t\t? `The 'sourceField' prop has not been supplied, and so '${sourceField}' was used as a default.`\n\t\t\t\t\t\t\t\t: `That is what the 'sourceField' prop has been set to, and so either this is a typo, ` +\n\t\t\t\t\t\t\t\t `or the data supplied is invalid.`),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst source = block[sourceField]\n\t\t\t\tif (typeof source !== 'string') {\n\t\t\t\t\tthrow new RichTextRendererError(`Found a block whose source is not a string.`)\n\t\t\t\t}\n\n\t\t\t\tif (sourceProps.referencesField !== undefined && !(referencesField in block)) {\n\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t`The 'referencesField' prop is set to '${referencesField}' but a block without such field ` +\n\t\t\t\t\t\t\t`has been encountered. Unless this is just a typo, ` +\n\t\t\t\t\t\t\t`if you do not wish to use references, avoid supplying the 'referencesField' prop.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst references = block[referencesField]\n\n\t\t\t\tlet normalizedReferences: Map<string, RichTextReference> | undefined = undefined\n\t\t\t\tif (references) {\n\t\t\t\t\tif (typeof Object(references)[Symbol.iterator] !== 'function') {\n\t\t\t\t\t\tthrow new RichTextRendererError(`The set of references must be an iterable!`)\n\t\t\t\t\t}\n\n\t\t\t\t\tnormalizedReferences = new Map()\n\t\t\t\t\tfor (const reference of references as Iterable<RichTextReference>) {\n\t\t\t\t\t\tif (!('id' in reference)) {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(`Found a reference without an id field.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!(referenceDiscriminationField in reference)) {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t\t\t`Found a reference without a '${referenceDiscriminationField}' field. ` +\n\t\t\t\t\t\t\t\t\t(sourceProps.referenceDiscriminationField === undefined\n\t\t\t\t\t\t\t\t\t\t? `The 'referenceDiscriminationField' prop has not been supplied, ` +\n\t\t\t\t\t\t\t\t\t\t `and so '${referenceDiscriminationField}' was used as a default.`\n\t\t\t\t\t\t\t\t\t\t: `That is what the 'referenceDiscriminationField' prop has been set to, ` +\n\t\t\t\t\t\t\t\t\t\t `and so either this is a typo, or the data supplied is invalid.`),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnormalizedReferences.set(reference.id, reference)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tid: typeof block.id === 'string' ? block.id : undefined,\n\t\t\t\t\tcontent: deserialize(source),\n\t\t\t\t\treferenceDiscriminationField,\n\t\t\t\t\treferenceRenderers: sourceProps.referenceRenderers ?? {},\n\t\t\t\t\treferencesField,\n\t\t\t\t\treferences: normalizedReferences,\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tthrow new RichTextRendererError(`RichTextRenderer: invalid data supplied.`)\n\t}, [deserialize, sourceProps])\n\n\treturn (\n\t\t<>\n\t\t\t{normalizedSource.map((block, i) => (\n\t\t\t\t<RichTextRenderMetadataContext.Provider\n\t\t\t\t\tkey={block.id ?? i}\n\t\t\t\t\tvalue={{\n\t\t\t\t\t\tformatVersion: block.content.formatVersion,\n\t\t\t\t\t\treferenceRenderers: block.referenceRenderers,\n\t\t\t\t\t\treferencesField: block.referencesField,\n\t\t\t\t\t\treferenceDiscriminationField: block.referenceDiscriminationField,\n\t\t\t\t\t\treferences: block.references,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{createElement(\n\t\t\t\t\t\trenderBlock, {\n\t\t\t\t\t\t\tblock,\n\t\t\t\t\t\t}, renderChildren(block.content.children, {\n\t\t\t\t\t\t\trenderLeaf,\n\t\t\t\t\t\t\trenderElement,\n\t\t\t\t\t\t\tattributeNamePrefix,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)}\n\t\t\t\t</RichTextRenderMetadataContext.Provider>\n\t\t\t))}\n\t\t</>\n\t)\n}) as <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = never>(\n\tprops: RichTextRendererProps<CustomElements, CustomLeaves>,\n) => ReactElement\n"],"names":["RichTextRenderer"],"mappings":";;;;;;AA4Ca,MAAA,mBAAmB,KAAK,SAASA,kBAG5C;AAAA,EACD,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,cAAc,CAAC,EAAE,SAAS,sCAAS,UAAS;AAAA,EAC5C;AAAA,EACA,GAAG;AACJ,GAAwD;AACjD,QAAA,mBAAmB,QAAiE,MAAM;AAC/F,QAAI,YAAY,eAAe,EAAE,YAAY,cAAc;AACnD,aAAA;AAAA,QACN;AAAA,UACC,SAAS,YAAY,SA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AS;AAAA,UACjD;AAAA,QACD;AACO,eAAA;AAAA,UACN,IAAI,OAAO,MAAM,OAAO,WAAW,MAAM,KAAK;AAAA,UAC9C,SAAS,YAAY,MAAM;AAAA,UAC3B;AAAA,UACA,oBAAoB,YAAY,sBAAsB,CAAC;AAAA,UACvD;AAAA,UACA,YAAY;AAAA,QAAA;AAAA,MACb,CACA;AAAA,IACF;AACM,UAAA,IAAI,sBAAsB,0CAA0C;AAAA,EAAA,GACxE,CAAC,aAAa,WAAW,CAAC;AAE7B,SAEG,oBAAA,UAAA,EAAA,UAAA,iBAAiB,IAAI,CAAC,OAAO,MAC7B;AAAA,IAAC,8BAA8B;AAAA,IAA9B;AAAA,MAEA,OAAO;AAAA,QACN,eAAe,MAAM,QAAQ;AAAA,QAC7B,oBAAoB,MAAM;AAAA,QAC1B,iBAAiB,MAAM;AAAA,QACvB,8BAA8B,MAAM;AAAA,QACpC,YAAY,MAAM;AAAA,MACnB;AAAA,MAEC,UAAA;AAAA,QACA;AAAA,QAAa;AAAA,UACZ;AAAA,QACD;AAAA,QAAG,eAAe,MAAM,QAAQ,UAAU;AAAA,UACzC;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACA;AAAA,MACF;AAAA,IAAA;AAAA,IAjBK,MAAM,MAAM;AAAA,EAmBlB,CAAA,EACF,CAAA;AAEF,CAAC;"}
|
package/dist/production/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { apiRequestReducer } from "./apiRequest/apiRequestReducer.js";
|
|
|
6
6
|
import { useApiRequest } from "./apiRequest/useApiRequest.js";
|
|
7
7
|
import { SessionTokenContext } from "./auth/SessionTokenContext.js";
|
|
8
8
|
import { SetSessionTokenContext } from "./auth/SetSessionTokenContext.js";
|
|
9
|
-
import { useSessionToken } from "./auth/useSessionToken.js";
|
|
9
|
+
import { useSessionToken, useSessionTokenWithMeta } from "./auth/useSessionToken.js";
|
|
10
10
|
import { useSetSessionToken } from "./auth/useSetSessionToken.js";
|
|
11
11
|
import { RichTextRenderer } from "./components/RichTextRenderer/RichTextRenderer.js";
|
|
12
12
|
import { RichTextRendererError } from "./components/RichTextRenderer/RichTextRendererError.js";
|
|
@@ -50,6 +50,7 @@ export {
|
|
|
50
50
|
useLoginToken,
|
|
51
51
|
useProjectSlug,
|
|
52
52
|
useSessionToken,
|
|
53
|
+
useSessionTokenWithMeta,
|
|
53
54
|
useSetSessionToken,
|
|
54
55
|
useStageSlug,
|
|
55
56
|
useSystemApiRequest,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileUploadError } from "@contember/client";
|
|
2
|
+
import { assertNever } from "@contember/utilities";
|
|
2
3
|
import { toFileId } from "./toFileId.js";
|
|
3
|
-
import { assertNever } from "../utils/assertNever.js";
|
|
4
4
|
const initializeFileUploadState = () => ({
|
|
5
5
|
fileIdByFile: /* @__PURE__ */ new WeakMap(),
|
|
6
6
|
state: /* @__PURE__ */ new Map()
|
|
@@ -136,7 +136,7 @@ const fileUploadReducer = (previousState, action) => {
|
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
138
|
default:
|
|
139
|
-
assertNever();
|
|
139
|
+
assertNever(action);
|
|
140
140
|
}
|
|
141
141
|
if (newState === void 0) {
|
|
142
142
|
return previousState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileUploadReducer.js","sources":["../../../src/upload/fileUploadReducer.ts"],"sourcesContent":["import { FileUploadError } from '@contember/client'\nimport { assertNever } from '
|
|
1
|
+
{"version":3,"file":"fileUploadReducer.js","sources":["../../../src/upload/fileUploadReducer.ts"],"sourcesContent":["import { FileUploadError } from '@contember/client'\nimport { assertNever } from '@contember/utilities'\nimport type { FileId } from './FileId'\nimport type { FileUploadAction } from './FileUploadAction'\nimport type { FileUploadMultiTemporalState } from './FileUploadMultiTemporalState'\nimport { toFileId } from './toFileId'\n\nexport const initializeFileUploadState = <Result = unknown, Metadata = undefined>(): FileUploadMultiTemporalState<Result, Metadata> => ({\n\tfileIdByFile: new WeakMap<File, FileId>(),\n\tstate: new Map(),\n})\n\nexport const fileUploadReducer = <Result = unknown, Metadata = undefined>(\n\tpreviousState: FileUploadMultiTemporalState<Result, Metadata>,\n\taction: FileUploadAction<Result, Metadata>,\n): FileUploadMultiTemporalState<Result, Metadata> => {\n\tlet newState: undefined | FileUploadMultiTemporalState<Result, Metadata>['state'] = undefined\n\n\tswitch (action.type) {\n\t\tcase 'initialize': {\n\t\t\tfor (const [fileId, metadata] of action.files) {\n\t\t\t\t// Deliberately allowing starting a new upload with the same id\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'initializing',\n\t\t\t\t\tabortController: metadata.abortController,\n\t\t\t\t\tpreviewUrl: metadata.previewUrl,\n\t\t\t\t\tfile: metadata.file,\n\t\t\t\t})\n\t\t\t\t// Deliberately mutating\n\t\t\t\tpreviousState.fileIdByFile.set(metadata.file, fileId)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'startUploading': {\n\t\t\tfor (const [fileOrId, metadata] of action.files) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst fileState = (newState ?? previousState.state).get(fileId)\n\n\t\t\t\tif (fileState === undefined || fileState.readyState !== 'initializing') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'uploading',\n\t\t\t\t\tabortController: fileState.abortController,\n\t\t\t\t\tfile: fileState.file,\n\t\t\t\t\tmetadata: metadata.metadata!, // If the user didn't supply the metadata, then that's on them.\n\t\t\t\t\tpreviewUrl: fileState.previewUrl,\n\t\t\t\t\tprogress: undefined,\n\t\t\t\t\tuploader: metadata.uploader,\n\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'finishSuccessfully': {\n\t\t\tfor (const [fileOrId, result] of action.result) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst previousFileState = (newState ?? previousState.state).get(fileId)\n\t\t\t\tif (previousFileState === undefined || previousFileState.readyState !== 'uploading') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'success',\n\t\t\t\t\tfile: previousFileState.file,\n\t\t\t\t\tmetadata: previousFileState.metadata,\n\t\t\t\t\tpreviewUrl: previousFileState.previewUrl,\n\t\t\t\t\tresult,\n\t\t\t\t\tuploader: previousFileState.uploader,\n\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'finishWithError': {\n\t\t\tfor (const errorSpec of action.error) {\n\t\t\t\tlet fileOrId: File | FileId\n\t\t\t\tlet rawError: unknown\n\n\t\t\t\tif (Array.isArray(errorSpec)) {\n\t\t\t\t\t[fileOrId, rawError] = errorSpec\n\t\t\t\t} else {\n\t\t\t\t\tfileOrId = errorSpec\n\t\t\t\t\trawError = undefined\n\t\t\t\t}\n\n\t\t\t\tconst errors: FileUploadError[] = []\n\n\t\t\t\tif (rawError instanceof FileUploadError) {\n\t\t\t\t\terrors.push(rawError)\n\t\t\t\t} else if (Array.isArray(rawError)) {\n\t\t\t\t\tfor (const error of rawError) {\n\t\t\t\t\t\tif (error instanceof FileUploadError) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst previousFileState = (newState ?? previousState.state).get(fileId)\n\t\t\t\tif (\n\t\t\t\t\tpreviousFileState === undefined ||\n\t\t\t\t\t(previousFileState.readyState !== 'initializing' && previousFileState.readyState !== 'uploading')\n\t\t\t\t) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst uploader = previousFileState.readyState === 'uploading' ? previousFileState.uploader : undefined\n\t\t\t\tconst metadata = previousFileState.readyState === 'uploading' ? previousFileState.metadata : undefined\n\t\t\t\t\t; (newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\t\treadyState: 'error',\n\t\t\t\t\t\terrors: errors.length ? errors : undefined,\n\t\t\t\t\t\trawError,\n\t\t\t\t\t\tfile: previousFileState.file,\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\tpreviewUrl: previousFileState.previewUrl,\n\t\t\t\t\t\tuploader,\n\t\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'purge': {\n\t\t\tfor (const fileOrId of action.files) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst fileState = (newState ?? previousState.state).get(fileId)\n\n\t\t\t\tif (fileState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tURL.revokeObjectURL(fileState.previewUrl)\n\t\t\t\tif (fileState.readyState === 'initializing' || fileState.readyState === 'uploading') {\n\t\t\t\t\tfileState.abortController.abort() // This is a bit naughty… We shouldn't do this from here.\n\t\t\t\t}\n\t\t\t\t(newState ??= new Map(previousState.state)).delete(fileId)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase 'updateUploadProgress': {\n\t\t\tfor (const [fileOrId, { progress }] of action.progress) {\n\t\t\t\tconst fileId = toFileId(previousState, fileOrId)\n\t\t\t\tconst previousFileState = (newState ?? previousState.state).get(fileId)\n\t\t\t\tif (progress === undefined || previousFileState === undefined || previousFileState.readyState !== 'uploading') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst roundedProgress = Math.floor(progress) // throttling\n\t\t\t\tif (roundedProgress === previousFileState.progress) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t(newState ??= new Map(previousState.state)).set(fileId, {\n\t\t\t\t\treadyState: 'uploading',\n\t\t\t\t\tfile: previousFileState.file,\n\t\t\t\t\tuploader: previousFileState.uploader,\n\t\t\t\t\tabortController: previousFileState.abortController,\n\t\t\t\t\tpreviewUrl: previousFileState.previewUrl,\n\t\t\t\t\tmetadata: previousFileState.metadata,\n\t\t\t\t\tprogress: roundedProgress,\n\t\t\t\t})\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tdefault:\n\t\t\tassertNever(action)\n\t}\n\tif (newState === undefined) {\n\t\treturn previousState\n\t}\n\treturn { ...previousState, state: newState }\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,4BAA4B,OAA+F;AAAA,EACvI,kCAAkB,QAAsB;AAAA,EACxC,2BAAW,IAAI;AAChB;AAEa,MAAA,oBAAoB,CAChC,eACA,WACoD;AACpD,MAAI,WAAgF;AAEpF,UAAQ,OAAO,MAAM;AAAA,IACpB,KAAK,cAAc;AAClB,iBAAW,CAAC,QAAQ,QAAQ,KAAK,OAAO,OAAO;AAE9C,SAAC,wBAAa,IAAI,IAAI,cAAc,KAAK,IAAG,IAAI,QAAQ;AAAA,UACvD,YAAY;AAAA,UACZ,iBAAiB,SAAS;AAAA,UAC1B,YAAY,SAAS;AAAA,UACrB,MAAM,SAAS;AAAA,QAAA,CACf;AAED,sBAAc,aAAa,IAAI,SAAS,MAAM,MAAM;AAAA,MACrD;AACA;AAAA,IACD;AAAA,IACA,KAAK,kBAAkB;AACtB,iBAAW,CAAC,UAAU,QAAQ,KAAK,OAAO,OAAO;AAC1C,cAAA,SAAS,SAAS,eAAe,QAAQ;AAC/C,cAAM,aAAa,YAAY,cAAc,OAAO,IAAI,MAAM;AAE9D,YAAI,cAAc,UAAa,UAAU,eAAe,gBAAgB;AACvE;AAAA,QACD;AAEA,SAAC,wBAAa,IAAI,IAAI,cAAc,KAAK,IAAG,IAAI,QAAQ;AAAA,UACvD,YAAY;AAAA,UACZ,iBAAiB,UAAU;AAAA,UAC3B,MAAM,UAAU;AAAA,UAChB,UAAU,SAAS;AAAA;AAAA,UACnB,YAAY,UAAU;AAAA,UACtB,UAAU;AAAA,UACV,UAAU,SAAS;AAAA,QAAA,CACnB;AAAA,MACF;AACA;AAAA,IACD;AAAA,IACA,KAAK,sBAAsB;AAC1B,iBA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AAa,QAAW;AACpB,WAAA;AAAA,EACR;AACA,SAAO,EAAE,GAAG,eAAe,OAAO,SAAS;AAC5C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContemberClient.d.ts","sourceRoot":"","sources":["../../src/ContemberClient.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAID,eAAO,MAAM,eAAe;cAA2C,MAAM,SAAS;
|
|
1
|
+
{"version":3,"file":"ContemberClient.d.ts","sourceRoot":"","sources":["../../src/ContemberClient.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAID;;GAEG;AACH,eAAO,MAAM,eAAe;cAA2C,MAAM,SAAS;EA6BpF,CAAA"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface SessionTokenContextValue {
|
|
2
|
+
propsToken: string | undefined;
|
|
3
|
+
source: 'props' | 'localstorage' | undefined;
|
|
4
|
+
token: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare const SessionTokenContext: import("react").Context<SessionTokenContextValue>;
|
|
2
7
|
//# sourceMappingURL=SessionTokenContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionTokenContext.d.ts","sourceRoot":"","sources":["../../../src/auth/SessionTokenContext.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"SessionTokenContext.d.ts","sourceRoot":"","sources":["../../../src/auth/SessionTokenContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,wBAAwB;IACxC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAAA;IAC5C,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CACzB;AAED,eAAO,MAAM,mBAAmB,mDAI9B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSessionToken.d.ts","sourceRoot":"","sources":["../../../src/auth/useSessionToken.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"useSessionToken.d.ts","sourceRoot":"","sources":["../../../src/auth/useSessionToken.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,0BAA8C,CAAA;AAC1E,eAAO,MAAM,uBAAuB,gEAAwC,CAAA"}
|
|
@@ -26,5 +26,8 @@ export type RichTextRendererProps<CustomElements extends RichTextElement = never
|
|
|
26
26
|
children?: ReactNode;
|
|
27
27
|
}>;
|
|
28
28
|
} & (RichTextRendererFieldProps | RichTextRendererBlockProps<CustomElements, CustomLeaves>);
|
|
29
|
+
/**
|
|
30
|
+
* @group Content rendering
|
|
31
|
+
*/
|
|
29
32
|
export declare const RichTextRenderer: <CustomElements extends RichTextElement<never, never> = never, CustomLeaves extends RichTextLeaf = never>(props: RichTextRendererProps<CustomElements, CustomLeaves>) => ReactElement;
|
|
30
33
|
//# sourceMappingURL=RichTextRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextRenderer/RichTextRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuB,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAA;AAE5F,OAAO,KAAK,EAAE,aAAa,EAAE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