@makeswift/runtime 0.28.10-canary.6 → 0.28.10-canary.7
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/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/controls/rich-text/control.js.map +1 -1
- package/dist/cjs/runtimes/react/server/render-context.js +1 -6
- package/dist/cjs/runtimes/react/server/render-context.js.map +1 -1
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/controls/rich-text/control.js.map +1 -1
- package/dist/esm/runtimes/react/server/render-context.js +1 -6
- package/dist/esm/runtimes/react/server/render-context.js.map +1 -1
- package/dist/types/runtimes/react/server/render-context.d.ts +2 -1
- package/dist/types/runtimes/react/server/render-context.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@ class MakeswiftGraphQLApiClient {
|
|
|
27
27
|
graphqlClient;
|
|
28
28
|
constructor({ endpoint }) {
|
|
29
29
|
this.graphqlClient = new import_client.GraphQLClient(endpoint, {
|
|
30
|
-
"makeswift-runtime-version": "0.28.10-canary.
|
|
30
|
+
"makeswift-runtime-version": "0.28.10-canary.7"
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async getUnversionedResources({
|
|
@@ -185,7 +185,7 @@ class MakeswiftRestAPIClient {
|
|
|
185
185
|
const requestHeaders = new Headers({
|
|
186
186
|
"x-api-key": this.apiKey,
|
|
187
187
|
"makeswift-site-api-key": this.apiKey,
|
|
188
|
-
"makeswift-runtime-version": "0.28.10-canary.
|
|
188
|
+
"makeswift-runtime-version": "0.28.10-canary.7"
|
|
189
189
|
});
|
|
190
190
|
if (siteVersion?.token) {
|
|
191
191
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
28
28
|
return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
29
29
|
}
|
|
30
30
|
return import_request_response.ApiResponse.json({
|
|
31
|
-
version: "0.28.10-canary.
|
|
31
|
+
version: "0.28.10-canary.7",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controls/rich-text/control.ts"],"sourcesContent":["import { Editor } from 'slate'\n\nimport { BuilderEditMode } from '../../state/modules/builder-edit-mode'\n\nimport {\n ControlInstance,\n richTextDAOToDTO,\n type BoxDisplayModel,\n type RichTextValue,\n} from '@makeswift/controls'\n\ntype ChangeBuilderEditModeMessage = {\n type: typeof RichTextControl.CHANGE_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype InitializeEditorMessage = {\n type: typeof RichTextControl.INITIALIZE_EDITOR\n value: RichTextValue\n}\n\ntype ChangeEditorValueMessage = {\n type: typeof RichTextControl.CHANGE_EDITOR_VALUE\n value: RichTextValue\n}\n\ntype FocusMessage = {\n type: typeof RichTextControl.FOCUS\n}\n\ntype BlurMessage = {\n type: typeof RichTextControl.BLUR\n}\n\ntype UndoMessage = {\n type: typeof RichTextControl.UNDO\n}\n\ntype RedoMessage = {\n type: typeof RichTextControl.REDO\n}\n\ntype BoxModelChangeMessage = {\n type: typeof RichTextControl.CHANGE_BOX_MODEL\n payload: { boxModel: BoxDisplayModel | null }\n}\n\ntype Message =\n | ChangeBuilderEditModeMessage\n | InitializeEditorMessage\n | ChangeEditorValueMessage\n | FocusMessage\n | BlurMessage\n | UndoMessage\n | RedoMessage\n | BoxModelChangeMessage\n\nexport class RichTextControl extends ControlInstance<Message> {\n static readonly CHANGE_BUILDER_EDIT_MODE = 'CHANGE_BUILDER_EDIT_MODE'\n static readonly INITIALIZE_EDITOR = 'INITIALIZE_EDITOR'\n static readonly CHANGE_EDITOR_VALUE = 'CHANGE_EDITOR_VALUE'\n static readonly FOCUS = 'FOCUS'\n static readonly BLUR = 'BLUR'\n static readonly UNDO = 'UNDO'\n static readonly REDO = 'REDO'\n static readonly CHANGE_BOX_MODEL = 'CHANGE_BOX_MODEL'\n\n private editor: Editor | null = null\n\n recv = (message: Message): void => {\n if (!this.editor) return\n\n switch (message.type) {\n case RichTextControl.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.payload.editMode) {\n case BuilderEditMode.BUILD:\n case BuilderEditMode.INTERACT:\n this.editor.deselectAndBlur()\n }\n break\n }\n\n case RichTextControl.FOCUS: {\n this.editor.focusAndSelectAll()\n break\n }\n }\n }\n\n subscribe(_listener: () => void): () => void {\n // No mutable state, nothing to subscribe to\n return () => {}\n }\n\n isCompositeProp(): boolean {\n return false\n }\n\n children(): ControlInstance[] {\n return []\n }\n\n child(_key: string): ControlInstance | undefined {\n return undefined\n }\n\n resolvesToRenderableNode(): boolean {\n return true\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.sendMessage({\n type: RichTextControl.INITIALIZE_EDITOR,\n value: richTextDAOToDTO(editor.children, editor.selection),\n })\n\n const _onChange = editor.onChange\n this.editor.onChange = options => {\n _onChange(options)\n\n // if onChange is local then it will include an operation(s)\n // that is the only case in which we want to push updates\n // this
|
|
1
|
+
{"version":3,"sources":["../../../../src/controls/rich-text/control.ts"],"sourcesContent":["import { Editor } from 'slate'\n\nimport { BuilderEditMode } from '../../state/modules/builder-edit-mode'\n\nimport {\n ControlInstance,\n richTextDAOToDTO,\n type BoxDisplayModel,\n type RichTextValue,\n} from '@makeswift/controls'\n\ntype ChangeBuilderEditModeMessage = {\n type: typeof RichTextControl.CHANGE_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype InitializeEditorMessage = {\n type: typeof RichTextControl.INITIALIZE_EDITOR\n value: RichTextValue\n}\n\ntype ChangeEditorValueMessage = {\n type: typeof RichTextControl.CHANGE_EDITOR_VALUE\n value: RichTextValue\n}\n\ntype FocusMessage = {\n type: typeof RichTextControl.FOCUS\n}\n\ntype BlurMessage = {\n type: typeof RichTextControl.BLUR\n}\n\ntype UndoMessage = {\n type: typeof RichTextControl.UNDO\n}\n\ntype RedoMessage = {\n type: typeof RichTextControl.REDO\n}\n\ntype BoxModelChangeMessage = {\n type: typeof RichTextControl.CHANGE_BOX_MODEL\n payload: { boxModel: BoxDisplayModel | null }\n}\n\ntype Message =\n | ChangeBuilderEditModeMessage\n | InitializeEditorMessage\n | ChangeEditorValueMessage\n | FocusMessage\n | BlurMessage\n | UndoMessage\n | RedoMessage\n | BoxModelChangeMessage\n\nexport class RichTextControl extends ControlInstance<Message> {\n static readonly CHANGE_BUILDER_EDIT_MODE = 'CHANGE_BUILDER_EDIT_MODE'\n static readonly INITIALIZE_EDITOR = 'INITIALIZE_EDITOR'\n static readonly CHANGE_EDITOR_VALUE = 'CHANGE_EDITOR_VALUE'\n static readonly FOCUS = 'FOCUS'\n static readonly BLUR = 'BLUR'\n static readonly UNDO = 'UNDO'\n static readonly REDO = 'REDO'\n static readonly CHANGE_BOX_MODEL = 'CHANGE_BOX_MODEL'\n\n private editor: Editor | null = null\n\n recv = (message: Message): void => {\n if (!this.editor) return\n\n switch (message.type) {\n case RichTextControl.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.payload.editMode) {\n case BuilderEditMode.BUILD:\n case BuilderEditMode.INTERACT:\n this.editor.deselectAndBlur()\n }\n break\n }\n\n case RichTextControl.FOCUS: {\n this.editor.focusAndSelectAll()\n break\n }\n }\n }\n\n subscribe(_listener: () => void): () => void {\n // No mutable state, nothing to subscribe to\n return () => {}\n }\n\n isCompositeProp(): boolean {\n return false\n }\n\n children(): ControlInstance[] {\n return []\n }\n\n child(_key: string): ControlInstance | undefined {\n return undefined\n }\n\n resolvesToRenderableNode(): boolean {\n return true\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.sendMessage({\n type: RichTextControl.INITIALIZE_EDITOR,\n value: richTextDAOToDTO(editor.children, editor.selection),\n })\n\n const _onChange = editor.onChange\n this.editor.onChange = options => {\n _onChange(options)\n\n // if onChange is local then it will include an operation(s)\n // that is the only case in which we want to push updates\n // this prevents infinite loops that can occur when collaborating\n if (options?.operation != null) {\n this.sendMessage({\n type: RichTextControl.CHANGE_EDITOR_VALUE,\n value: richTextDAOToDTO(editor.children, editor.selection),\n })\n }\n }\n }\n\n focus() {\n this.sendMessage({ type: RichTextControl.FOCUS })\n }\n\n blur() {\n this.sendMessage({ type: RichTextControl.BLUR })\n }\n\n undo() {\n this.sendMessage({ type: RichTextControl.UNDO })\n }\n\n redo() {\n this.sendMessage({ type: RichTextControl.REDO })\n }\n\n changeBoxModel(boxModel: BoxDisplayModel | null): void {\n this.sendMessage({\n type: RichTextControl.CHANGE_BOX_MODEL,\n payload: { boxModel },\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,+BAAgC;AAEhC,sBAKO;AAgDA,MAAM,wBAAwB,gCAAyB;AAAA,EAC5D,OAAgB,2BAA2B;AAAA,EAC3C,OAAgB,oBAAoB;AAAA,EACpC,OAAgB,sBAAsB;AAAA,EACtC,OAAgB,QAAQ;AAAA,EACxB,OAAgB,OAAO;AAAA,EACvB,OAAgB,OAAO;AAAA,EACvB,OAAgB,OAAO;AAAA,EACvB,OAAgB,mBAAmB;AAAA,EAE3B,SAAwB;AAAA,EAEhC,OAAO,CAAC,YAA2B;AACjC,QAAI,CAAC,KAAK;AAAQ;AAElB,YAAQ,QAAQ,MAAM;AAAA,MACpB,KAAK,gBAAgB,0BAA0B;AAC7C,gBAAQ,QAAQ,QAAQ,UAAU;AAAA,UAChC,KAAK,yCAAgB;AAAA,UACrB,KAAK,yCAAgB;AACnB,iBAAK,OAAO,gBAAgB;AAAA,QAChC;AACA;AAAA,MACF;AAAA,MAEA,KAAK,gBAAgB,OAAO;AA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35
35
|
throw Error("Makeswift render context was not set.");
|
|
36
36
|
return context;
|
|
37
37
|
};
|
|
38
|
-
const getStore = ({
|
|
39
|
-
if (runtime.requestKey == null) {
|
|
40
|
-
throw Error("Expected a runtime instance that is bound to a specific request key");
|
|
41
|
-
}
|
|
42
|
-
return runtime.getOrCreateStore({ siteVersion, locale });
|
|
43
|
-
};
|
|
38
|
+
const getStore = ({ store }) => store;
|
|
44
39
|
const RenderContext = ({
|
|
45
40
|
context,
|
|
46
41
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"sourcesContent":["import { cache, type PropsWithChildren } from 'react'\n\nimport { ReactRuntime } from '../../react/react-runtime'\nimport { type Store } from '../../../state/store'\n\nimport { type SiteVersion } from '../../../api/site-version'\nimport { MakeswiftClient } from '../../../client'\n\n/**\n * Request-scoped dependencies used to render Makeswift server elements.\n *\n * Framework integrations create a context for each request and install it with\n * `RenderContext` or `setRenderContext` so nested renderers can access it without\n * threading it through every component. The runtime must be request-bound;\n * together with `siteVersion` and `locale`, it selects the store and API resource\n * cache used during rendering.\n */\nexport type ServerRenderContext = {\n request: Request\n runtime: ReactRuntime\n client: MakeswiftClient\n siteVersion: SiteVersion | null\n locale: string | undefined\n}\n\nconst requestContext = cache((): { current?: ServerRenderContext } => ({}))\n\nexport const setRenderContext = (context: ServerRenderContext) => {\n requestContext().current = context\n}\n\nexport const getRenderContext = (): ServerRenderContext => {\n const context = requestContext().current\n if (!context) throw Error('Makeswift render context was not set.')\n return context\n}\n\nexport const getStore = ({
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"sourcesContent":["import { cache, type PropsWithChildren } from 'react'\n\nimport { ReactRuntime } from '../../react/react-runtime'\nimport { type Store } from '../../../state/store'\n\nimport { type SiteVersion } from '../../../api/site-version'\nimport { MakeswiftClient } from '../../../client'\n\n/**\n * Request-scoped dependencies used to render Makeswift server elements.\n *\n * Framework integrations create a context for each request and install it with\n * `RenderContext` or `setRenderContext` so nested renderers can access it without\n * threading it through every component. The runtime must be request-bound;\n * together with `siteVersion` and `locale`, it selects the store and API resource\n * cache used during rendering.\n */\nexport type ServerRenderContext = {\n request: Request\n runtime: ReactRuntime\n client: MakeswiftClient\n siteVersion: SiteVersion | null\n locale: string | undefined\n store: Store\n}\n\nconst requestContext = cache((): { current?: ServerRenderContext } => ({}))\n\nexport const setRenderContext = (context: ServerRenderContext) => {\n requestContext().current = context\n}\n\nexport const getRenderContext = (): ServerRenderContext => {\n const context = requestContext().current\n if (!context) throw Error('Makeswift render context was not set.')\n return context\n}\n\nexport const getStore = ({ store }: ServerRenderContext): Store => store\n\nexport const RenderContext = ({\n context,\n children,\n}: PropsWithChildren<{ context: ServerRenderContext }>) => {\n setRenderContext(context)\n return children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8C;AA0B9C,MAAM,qBAAiB,oBAAM,OAA0C,CAAC,EAAE;AAEnE,MAAM,mBAAmB,CAAC,YAAiC;AAChE,iBAAe,EAAE,UAAU;AAC7B;AAEO,MAAM,mBAAmB,MAA2B;AACzD,QAAM,UAAU,eAAe,EAAE;AACjC,MAAI,CAAC;AAAS,UAAM,MAAM,uCAAuC;AACjE,SAAO;AACT;AAEO,MAAM,WAAW,CAAC,EAAE,MAAM,MAAkC;AAE5D,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAA2D;AACzD,mBAAiB,OAAO;AACxB,SAAO;AACT;","names":[]}
|
|
@@ -4,7 +4,7 @@ class MakeswiftGraphQLApiClient {
|
|
|
4
4
|
graphqlClient;
|
|
5
5
|
constructor({ endpoint }) {
|
|
6
6
|
this.graphqlClient = new GraphQLClient(endpoint, {
|
|
7
|
-
"makeswift-runtime-version": "0.28.10-canary.
|
|
7
|
+
"makeswift-runtime-version": "0.28.10-canary.7"
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
async getUnversionedResources({
|
|
@@ -150,7 +150,7 @@ class MakeswiftRestAPIClient {
|
|
|
150
150
|
const requestHeaders = new Headers({
|
|
151
151
|
"x-api-key": this.apiKey,
|
|
152
152
|
"makeswift-site-api-key": this.apiKey,
|
|
153
|
-
"makeswift-runtime-version": "0.28.10-canary.
|
|
153
|
+
"makeswift-runtime-version": "0.28.10-canary.7"
|
|
154
154
|
});
|
|
155
155
|
if (siteVersion?.token) {
|
|
156
156
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
8
8
|
return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.28.10-canary.
|
|
11
|
+
version: "0.28.10-canary.7",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controls/rich-text/control.ts"],"sourcesContent":["import { Editor } from 'slate'\n\nimport { BuilderEditMode } from '../../state/modules/builder-edit-mode'\n\nimport {\n ControlInstance,\n richTextDAOToDTO,\n type BoxDisplayModel,\n type RichTextValue,\n} from '@makeswift/controls'\n\ntype ChangeBuilderEditModeMessage = {\n type: typeof RichTextControl.CHANGE_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype InitializeEditorMessage = {\n type: typeof RichTextControl.INITIALIZE_EDITOR\n value: RichTextValue\n}\n\ntype ChangeEditorValueMessage = {\n type: typeof RichTextControl.CHANGE_EDITOR_VALUE\n value: RichTextValue\n}\n\ntype FocusMessage = {\n type: typeof RichTextControl.FOCUS\n}\n\ntype BlurMessage = {\n type: typeof RichTextControl.BLUR\n}\n\ntype UndoMessage = {\n type: typeof RichTextControl.UNDO\n}\n\ntype RedoMessage = {\n type: typeof RichTextControl.REDO\n}\n\ntype BoxModelChangeMessage = {\n type: typeof RichTextControl.CHANGE_BOX_MODEL\n payload: { boxModel: BoxDisplayModel | null }\n}\n\ntype Message =\n | ChangeBuilderEditModeMessage\n | InitializeEditorMessage\n | ChangeEditorValueMessage\n | FocusMessage\n | BlurMessage\n | UndoMessage\n | RedoMessage\n | BoxModelChangeMessage\n\nexport class RichTextControl extends ControlInstance<Message> {\n static readonly CHANGE_BUILDER_EDIT_MODE = 'CHANGE_BUILDER_EDIT_MODE'\n static readonly INITIALIZE_EDITOR = 'INITIALIZE_EDITOR'\n static readonly CHANGE_EDITOR_VALUE = 'CHANGE_EDITOR_VALUE'\n static readonly FOCUS = 'FOCUS'\n static readonly BLUR = 'BLUR'\n static readonly UNDO = 'UNDO'\n static readonly REDO = 'REDO'\n static readonly CHANGE_BOX_MODEL = 'CHANGE_BOX_MODEL'\n\n private editor: Editor | null = null\n\n recv = (message: Message): void => {\n if (!this.editor) return\n\n switch (message.type) {\n case RichTextControl.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.payload.editMode) {\n case BuilderEditMode.BUILD:\n case BuilderEditMode.INTERACT:\n this.editor.deselectAndBlur()\n }\n break\n }\n\n case RichTextControl.FOCUS: {\n this.editor.focusAndSelectAll()\n break\n }\n }\n }\n\n subscribe(_listener: () => void): () => void {\n // No mutable state, nothing to subscribe to\n return () => {}\n }\n\n isCompositeProp(): boolean {\n return false\n }\n\n children(): ControlInstance[] {\n return []\n }\n\n child(_key: string): ControlInstance | undefined {\n return undefined\n }\n\n resolvesToRenderableNode(): boolean {\n return true\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.sendMessage({\n type: RichTextControl.INITIALIZE_EDITOR,\n value: richTextDAOToDTO(editor.children, editor.selection),\n })\n\n const _onChange = editor.onChange\n this.editor.onChange = options => {\n _onChange(options)\n\n // if onChange is local then it will include an operation(s)\n // that is the only case in which we want to push updates\n // this
|
|
1
|
+
{"version":3,"sources":["../../../../src/controls/rich-text/control.ts"],"sourcesContent":["import { Editor } from 'slate'\n\nimport { BuilderEditMode } from '../../state/modules/builder-edit-mode'\n\nimport {\n ControlInstance,\n richTextDAOToDTO,\n type BoxDisplayModel,\n type RichTextValue,\n} from '@makeswift/controls'\n\ntype ChangeBuilderEditModeMessage = {\n type: typeof RichTextControl.CHANGE_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype InitializeEditorMessage = {\n type: typeof RichTextControl.INITIALIZE_EDITOR\n value: RichTextValue\n}\n\ntype ChangeEditorValueMessage = {\n type: typeof RichTextControl.CHANGE_EDITOR_VALUE\n value: RichTextValue\n}\n\ntype FocusMessage = {\n type: typeof RichTextControl.FOCUS\n}\n\ntype BlurMessage = {\n type: typeof RichTextControl.BLUR\n}\n\ntype UndoMessage = {\n type: typeof RichTextControl.UNDO\n}\n\ntype RedoMessage = {\n type: typeof RichTextControl.REDO\n}\n\ntype BoxModelChangeMessage = {\n type: typeof RichTextControl.CHANGE_BOX_MODEL\n payload: { boxModel: BoxDisplayModel | null }\n}\n\ntype Message =\n | ChangeBuilderEditModeMessage\n | InitializeEditorMessage\n | ChangeEditorValueMessage\n | FocusMessage\n | BlurMessage\n | UndoMessage\n | RedoMessage\n | BoxModelChangeMessage\n\nexport class RichTextControl extends ControlInstance<Message> {\n static readonly CHANGE_BUILDER_EDIT_MODE = 'CHANGE_BUILDER_EDIT_MODE'\n static readonly INITIALIZE_EDITOR = 'INITIALIZE_EDITOR'\n static readonly CHANGE_EDITOR_VALUE = 'CHANGE_EDITOR_VALUE'\n static readonly FOCUS = 'FOCUS'\n static readonly BLUR = 'BLUR'\n static readonly UNDO = 'UNDO'\n static readonly REDO = 'REDO'\n static readonly CHANGE_BOX_MODEL = 'CHANGE_BOX_MODEL'\n\n private editor: Editor | null = null\n\n recv = (message: Message): void => {\n if (!this.editor) return\n\n switch (message.type) {\n case RichTextControl.CHANGE_BUILDER_EDIT_MODE: {\n switch (message.payload.editMode) {\n case BuilderEditMode.BUILD:\n case BuilderEditMode.INTERACT:\n this.editor.deselectAndBlur()\n }\n break\n }\n\n case RichTextControl.FOCUS: {\n this.editor.focusAndSelectAll()\n break\n }\n }\n }\n\n subscribe(_listener: () => void): () => void {\n // No mutable state, nothing to subscribe to\n return () => {}\n }\n\n isCompositeProp(): boolean {\n return false\n }\n\n children(): ControlInstance[] {\n return []\n }\n\n child(_key: string): ControlInstance | undefined {\n return undefined\n }\n\n resolvesToRenderableNode(): boolean {\n return true\n }\n\n setSlateEditor(editor: Editor) {\n this.editor = editor\n\n this.sendMessage({\n type: RichTextControl.INITIALIZE_EDITOR,\n value: richTextDAOToDTO(editor.children, editor.selection),\n })\n\n const _onChange = editor.onChange\n this.editor.onChange = options => {\n _onChange(options)\n\n // if onChange is local then it will include an operation(s)\n // that is the only case in which we want to push updates\n // this prevents infinite loops that can occur when collaborating\n if (options?.operation != null) {\n this.sendMessage({\n type: RichTextControl.CHANGE_EDITOR_VALUE,\n value: richTextDAOToDTO(editor.children, editor.selection),\n })\n }\n }\n }\n\n focus() {\n this.sendMessage({ type: RichTextControl.FOCUS })\n }\n\n blur() {\n this.sendMessage({ type: RichTextControl.BLUR })\n }\n\n undo() {\n this.sendMessage({ type: RichTextControl.UNDO })\n }\n\n redo() {\n this.sendMessage({ type: RichTextControl.REDO })\n }\n\n changeBoxModel(boxModel: BoxDisplayModel | null): void {\n this.sendMessage({\n type: RichTextControl.CHANGE_BOX_MODEL,\n payload: { boxModel },\n })\n }\n}\n"],"mappings":"AAEA,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAgDA,MAAM,wBAAwB,gBAAyB;AAAA,EAC5D,OAAgB,2BAA2B;AAAA,EAC3C,OAAgB,oBAAoB;AAAA,EACpC,OAAgB,sBAAsB;AAAA,EACtC,OAAgB,QAAQ;AAAA,EACxB,OAAgB,OAAO;AAAA,EACvB,OAAgB,OAAO;AAAA,EACvB,OAAgB,OAAO;AAAA,EACvB,OA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AEA,OAAO;AACL,SAAK,YAAY,EAAE,MAAM,gBAAgB,KAAK,CAAC;AAAA,EACjD;AAAA,EAEA,OAAO;AACL,SAAK,YAAY,EAAE,MAAM,gBAAgB,KAAK,CAAC;AAAA,EACjD;AAAA,EAEA,eAAe,UAAwC;AACrD,SAAK,YAAY;AAAA,MACf,MAAM,gBAAgB;AAAA,MACtB,SAAS,EAAE,SAAS;AAAA,IACtB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -9,12 +9,7 @@ const getRenderContext = () => {
|
|
|
9
9
|
throw Error("Makeswift render context was not set.");
|
|
10
10
|
return context;
|
|
11
11
|
};
|
|
12
|
-
const getStore = ({
|
|
13
|
-
if (runtime.requestKey == null) {
|
|
14
|
-
throw Error("Expected a runtime instance that is bound to a specific request key");
|
|
15
|
-
}
|
|
16
|
-
return runtime.getOrCreateStore({ siteVersion, locale });
|
|
17
|
-
};
|
|
12
|
+
const getStore = ({ store }) => store;
|
|
18
13
|
const RenderContext = ({
|
|
19
14
|
context,
|
|
20
15
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"sourcesContent":["import { cache, type PropsWithChildren } from 'react'\n\nimport { ReactRuntime } from '../../react/react-runtime'\nimport { type Store } from '../../../state/store'\n\nimport { type SiteVersion } from '../../../api/site-version'\nimport { MakeswiftClient } from '../../../client'\n\n/**\n * Request-scoped dependencies used to render Makeswift server elements.\n *\n * Framework integrations create a context for each request and install it with\n * `RenderContext` or `setRenderContext` so nested renderers can access it without\n * threading it through every component. The runtime must be request-bound;\n * together with `siteVersion` and `locale`, it selects the store and API resource\n * cache used during rendering.\n */\nexport type ServerRenderContext = {\n request: Request\n runtime: ReactRuntime\n client: MakeswiftClient\n siteVersion: SiteVersion | null\n locale: string | undefined\n}\n\nconst requestContext = cache((): { current?: ServerRenderContext } => ({}))\n\nexport const setRenderContext = (context: ServerRenderContext) => {\n requestContext().current = context\n}\n\nexport const getRenderContext = (): ServerRenderContext => {\n const context = requestContext().current\n if (!context) throw Error('Makeswift render context was not set.')\n return context\n}\n\nexport const getStore = ({
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"sourcesContent":["import { cache, type PropsWithChildren } from 'react'\n\nimport { ReactRuntime } from '../../react/react-runtime'\nimport { type Store } from '../../../state/store'\n\nimport { type SiteVersion } from '../../../api/site-version'\nimport { MakeswiftClient } from '../../../client'\n\n/**\n * Request-scoped dependencies used to render Makeswift server elements.\n *\n * Framework integrations create a context for each request and install it with\n * `RenderContext` or `setRenderContext` so nested renderers can access it without\n * threading it through every component. The runtime must be request-bound;\n * together with `siteVersion` and `locale`, it selects the store and API resource\n * cache used during rendering.\n */\nexport type ServerRenderContext = {\n request: Request\n runtime: ReactRuntime\n client: MakeswiftClient\n siteVersion: SiteVersion | null\n locale: string | undefined\n store: Store\n}\n\nconst requestContext = cache((): { current?: ServerRenderContext } => ({}))\n\nexport const setRenderContext = (context: ServerRenderContext) => {\n requestContext().current = context\n}\n\nexport const getRenderContext = (): ServerRenderContext => {\n const context = requestContext().current\n if (!context) throw Error('Makeswift render context was not set.')\n return context\n}\n\nexport const getStore = ({ store }: ServerRenderContext): Store => store\n\nexport const RenderContext = ({\n context,\n children,\n}: PropsWithChildren<{ context: ServerRenderContext }>) => {\n setRenderContext(context)\n return children\n}\n"],"mappings":"AAAA,SAAS,aAAqC;AA0B9C,MAAM,iBAAiB,MAAM,OAA0C,CAAC,EAAE;AAEnE,MAAM,mBAAmB,CAAC,YAAiC;AAChE,iBAAe,EAAE,UAAU;AAC7B;AAEO,MAAM,mBAAmB,MAA2B;AACzD,QAAM,UAAU,eAAe,EAAE;AACjC,MAAI,CAAC;AAAS,UAAM,MAAM,uCAAuC;AACjE,SAAO;AACT;AAEO,MAAM,WAAW,CAAC,EAAE,MAAM,MAAkC;AAE5D,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAA2D;AACzD,mBAAiB,OAAO;AACxB,SAAO;AACT;","names":[]}
|
|
@@ -18,10 +18,11 @@ export type ServerRenderContext = {
|
|
|
18
18
|
client: MakeswiftClient;
|
|
19
19
|
siteVersion: SiteVersion | null;
|
|
20
20
|
locale: string | undefined;
|
|
21
|
+
store: Store;
|
|
21
22
|
};
|
|
22
23
|
export declare const setRenderContext: (context: ServerRenderContext) => void;
|
|
23
24
|
export declare const getRenderContext: () => ServerRenderContext;
|
|
24
|
-
export declare const getStore: ({
|
|
25
|
+
export declare const getStore: ({ store }: ServerRenderContext) => Store;
|
|
25
26
|
export declare const RenderContext: ({ context, children, }: PropsWithChildren<{
|
|
26
27
|
context: ServerRenderContext;
|
|
27
28
|
}>) => import("react").ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-context.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,YAAY,CAAA;IACrB,MAAM,EAAE,eAAe,CAAA;IACvB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAA;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"render-context.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,YAAY,CAAA;IACrB,MAAM,EAAE,eAAe,CAAA;IACvB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAA;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAID,eAAO,MAAM,gBAAgB,GAAI,SAAS,mBAAmB,SAE5D,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,mBAInC,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,WAAW,mBAAmB,KAAG,KAAc,CAAA;AAExE,eAAO,MAAM,aAAa,GAAI,wBAG3B,iBAAiB,CAAC;IAAE,OAAO,EAAE,mBAAmB,CAAA;CAAE,CAAC,8BAGrD,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makeswift/runtime",
|
|
3
|
-
"version": "0.28.10-canary.
|
|
3
|
+
"version": "0.28.10-canary.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "makeswift/makeswift",
|
|
@@ -244,8 +244,8 @@
|
|
|
244
244
|
"use-sync-external-store": "^1.5.0",
|
|
245
245
|
"uuid": "^9.0.0",
|
|
246
246
|
"zod": "^3.21.4",
|
|
247
|
-
"@makeswift/next-plugin": "0.6.1",
|
|
248
247
|
"@makeswift/controls": "0.1.22-canary.0",
|
|
248
|
+
"@makeswift/next-plugin": "0.6.1",
|
|
249
249
|
"@makeswift/prop-controllers": "0.4.16-canary.0"
|
|
250
250
|
},
|
|
251
251
|
"devDependencies": {
|