@makeswift/runtime 0.28.4-canary.0 → 0.28.4-canary.2

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.
Files changed (105) hide show
  1. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  2. package/dist/cjs/builder/serialization.js +78 -0
  3. package/dist/cjs/builder/serialization.js.map +1 -0
  4. package/dist/cjs/client/index.js +3 -3
  5. package/dist/cjs/controls/serialization/base/index.js +76 -0
  6. package/dist/cjs/controls/serialization/base/index.js.map +1 -0
  7. package/dist/cjs/controls/{visitors/message-port-serializer/client-message-port-serialization-visitor.js → serialization/base/visitor.js} +9 -22
  8. package/dist/cjs/controls/serialization/base/visitor.js.map +1 -0
  9. package/dist/cjs/controls/serialization/index.js +55 -0
  10. package/dist/cjs/controls/serialization/index.js.map +1 -0
  11. package/dist/cjs/controls/serialization/message-port/function-serialization.js.map +1 -0
  12. package/dist/cjs/{builder/serialization → controls/serialization/message-port}/index.js +6 -6
  13. package/dist/cjs/controls/serialization/message-port/index.js.map +1 -0
  14. package/dist/cjs/controls/{visitors/message-port-serializer/index.js → serialization/message-port/visitor.js} +25 -13
  15. package/dist/cjs/controls/serialization/message-port/visitor.js.map +1 -0
  16. package/dist/cjs/{builder/serialization/control-serialization.js → prop-controllers/serialization.js} +41 -144
  17. package/dist/cjs/prop-controllers/serialization.js.map +1 -0
  18. package/dist/cjs/state/modules/element-trees.js +45 -19
  19. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  20. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  21. package/dist/esm/builder/serialization.js +59 -0
  22. package/dist/esm/builder/serialization.js.map +1 -0
  23. package/dist/esm/client/index.js +3 -3
  24. package/dist/esm/controls/serialization/base/index.js +74 -0
  25. package/dist/esm/controls/serialization/base/index.js.map +1 -0
  26. package/dist/esm/controls/{visitors/message-port-serializer/client-message-port-serialization-visitor.js → serialization/base/visitor.js} +6 -20
  27. package/dist/esm/controls/serialization/base/visitor.js.map +1 -0
  28. package/dist/esm/controls/serialization/index.js +30 -0
  29. package/dist/esm/controls/serialization/index.js.map +1 -0
  30. package/dist/esm/controls/serialization/message-port/function-serialization.js.map +1 -0
  31. package/dist/esm/controls/serialization/message-port/index.js +3 -0
  32. package/dist/esm/controls/serialization/message-port/index.js.map +1 -0
  33. package/dist/esm/controls/serialization/message-port/visitor.js +24 -0
  34. package/dist/esm/controls/serialization/message-port/visitor.js.map +1 -0
  35. package/dist/esm/{builder/serialization/control-serialization.js → prop-controllers/serialization.js} +11 -136
  36. package/dist/esm/prop-controllers/serialization.js.map +1 -0
  37. package/dist/esm/state/modules/element-trees.js +46 -20
  38. package/dist/esm/state/modules/element-trees.js.map +1 -1
  39. package/dist/types/api-handler/handlers/webhook/types.d.ts +4 -4
  40. package/dist/types/builder/serialization.d.ts +23 -0
  41. package/dist/types/builder/serialization.d.ts.map +1 -0
  42. package/dist/types/builder/serialization.test.d.ts +2 -0
  43. package/dist/types/builder/serialization.test.d.ts.map +1 -0
  44. package/dist/types/client/index.d.ts +4 -4
  45. package/dist/types/controls/serialization/base/index.d.ts +10 -0
  46. package/dist/types/controls/serialization/base/index.d.ts.map +1 -0
  47. package/dist/types/controls/serialization/base/visitor.d.ts +7 -0
  48. package/dist/types/controls/serialization/base/visitor.d.ts.map +1 -0
  49. package/dist/types/controls/serialization/index.d.ts +10 -0
  50. package/dist/types/controls/serialization/index.d.ts.map +1 -0
  51. package/dist/types/controls/{visitors/message-port-serializer → serialization/message-port}/function-serialization.d.ts +1 -1
  52. package/dist/types/controls/serialization/message-port/function-serialization.d.ts.map +1 -0
  53. package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts.map +1 -0
  54. package/dist/types/controls/serialization/message-port/index.d.ts +3 -0
  55. package/dist/types/controls/serialization/message-port/index.d.ts.map +1 -0
  56. package/dist/types/controls/serialization/message-port/visitor.d.ts +7 -0
  57. package/dist/types/controls/serialization/message-port/visitor.d.ts.map +1 -0
  58. package/dist/types/{builder/serialization/control-serialization.d.ts → prop-controllers/serialization.d.ts} +11 -29
  59. package/dist/types/prop-controllers/serialization.d.ts.map +1 -0
  60. package/dist/types/slate/BlockPlugin/index.d.ts +3 -3
  61. package/dist/types/state/modules/__tests__/fixtures/element-trees-demo-component.d.ts +4 -0
  62. package/dist/types/state/modules/__tests__/fixtures/element-trees-demo-component.d.ts.map +1 -1
  63. package/dist/types/state/modules/__tests__/fixtures/element-trees.d.ts +7 -0
  64. package/dist/types/state/modules/__tests__/fixtures/element-trees.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/dist/cjs/builder/serialization/control-serialization.js.map +0 -1
  67. package/dist/cjs/builder/serialization/controls/types.js +0 -17
  68. package/dist/cjs/builder/serialization/controls/types.js.map +0 -1
  69. package/dist/cjs/builder/serialization/function-serialization.js +0 -57
  70. package/dist/cjs/builder/serialization/function-serialization.js.map +0 -1
  71. package/dist/cjs/builder/serialization/index.js.map +0 -1
  72. package/dist/cjs/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js.map +0 -1
  73. package/dist/cjs/controls/visitors/message-port-serializer/function-serialization.js.map +0 -1
  74. package/dist/cjs/controls/visitors/message-port-serializer/index.js.map +0 -1
  75. package/dist/esm/builder/serialization/control-serialization.js.map +0 -1
  76. package/dist/esm/builder/serialization/controls/types.js +0 -1
  77. package/dist/esm/builder/serialization/controls/types.js.map +0 -1
  78. package/dist/esm/builder/serialization/function-serialization.js +0 -31
  79. package/dist/esm/builder/serialization/function-serialization.js.map +0 -1
  80. package/dist/esm/builder/serialization/index.js +0 -3
  81. package/dist/esm/builder/serialization/index.js.map +0 -1
  82. package/dist/esm/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.js.map +0 -1
  83. package/dist/esm/controls/visitors/message-port-serializer/function-serialization.js.map +0 -1
  84. package/dist/esm/controls/visitors/message-port-serializer/index.js +0 -13
  85. package/dist/esm/controls/visitors/message-port-serializer/index.js.map +0 -1
  86. package/dist/types/builder/serialization/control-serialization.d.ts.map +0 -1
  87. package/dist/types/builder/serialization/control-serialization.test.d.ts +0 -2
  88. package/dist/types/builder/serialization/control-serialization.test.d.ts.map +0 -1
  89. package/dist/types/builder/serialization/controls/types.d.ts +0 -10
  90. package/dist/types/builder/serialization/controls/types.d.ts.map +0 -1
  91. package/dist/types/builder/serialization/function-serialization.d.ts +0 -12
  92. package/dist/types/builder/serialization/function-serialization.d.ts.map +0 -1
  93. package/dist/types/builder/serialization/function-serialization.test.d.ts.map +0 -1
  94. package/dist/types/builder/serialization/index.d.ts +0 -4
  95. package/dist/types/builder/serialization/index.d.ts.map +0 -1
  96. package/dist/types/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.d.ts +0 -9
  97. package/dist/types/controls/visitors/message-port-serializer/client-message-port-serialization-visitor.d.ts.map +0 -1
  98. package/dist/types/controls/visitors/message-port-serializer/function-serialization.d.ts.map +0 -1
  99. package/dist/types/controls/visitors/message-port-serializer/function-serialization.test.d.ts +0 -2
  100. package/dist/types/controls/visitors/message-port-serializer/function-serialization.test.d.ts.map +0 -1
  101. package/dist/types/controls/visitors/message-port-serializer/index.d.ts +0 -3
  102. package/dist/types/controls/visitors/message-port-serializer/index.d.ts.map +0 -1
  103. /package/dist/cjs/controls/{visitors/message-port-serializer → serialization/message-port}/function-serialization.js +0 -0
  104. /package/dist/esm/controls/{visitors/message-port-serializer → serialization/message-port}/function-serialization.js +0 -0
  105. /package/dist/types/{builder/serialization → controls/serialization/message-port}/function-serialization.test.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { getIn } from "immutable";
1
+ import { getIn, removeIn, setIn } from "immutable";
2
2
  import { isElementReference } from "@makeswift/controls";
3
3
  import * as Introspection from "../../prop-controllers/introspection";
4
4
  import { isKnownAction } from "../actions";
@@ -180,11 +180,11 @@ function deleteElement({ elements, elementIds }, deletedElement, propName, descr
180
180
  }
181
181
  function applyDelete(elementTree, descriptors, rootElements, path) {
182
182
  const [deleteElementPath, ...parentElementPaths] = getChangedElementsPaths(path);
183
- const [deletedElement, propName] = getElementAndPropName(rootElements.old, deleteElementPath);
183
+ const [deletedElement, propName] = getElementAndPropName(rootElements.before, deleteElementPath);
184
184
  const elements = new Map(elementTree.elements);
185
185
  const elementIds = new Map(elementTree.elementIds);
186
186
  deleteElement({ elements, elementIds }, deletedElement, propName, descriptors);
187
- updateParentElements(elements, parentElementPaths, rootElements.new);
187
+ updateParentElements(elements, parentElementPaths, rootElements.after);
188
188
  return {
189
189
  elements,
190
190
  elementIds
@@ -211,11 +211,11 @@ function insertElement({ elements, elementIds }, insertedElement, propName, desc
211
211
  }
212
212
  function applyInsert(elementTree, descriptors, rootElements, path) {
213
213
  const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path);
214
- const [insertedElement, propName] = getElementAndPropName(rootElements.new, insertedElementPath);
214
+ const [insertedElement, propName] = getElementAndPropName(rootElements.after, insertedElementPath);
215
215
  const elements = new Map(elementTree.elements);
216
216
  const elementIds = new Map(elementTree.elementIds);
217
217
  insertElement({ elements, elementIds }, insertedElement, propName, descriptors);
218
- updateParentElements(elements, parentElementPaths, rootElements.new);
218
+ updateParentElements(elements, parentElementPaths, rootElements.after);
219
219
  return {
220
220
  elements,
221
221
  elementIds
@@ -223,31 +223,57 @@ function applyInsert(elementTree, descriptors, rootElements, path) {
223
223
  }
224
224
  function applyUpdate(elementTree, descriptors, rootElements, path) {
225
225
  const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path);
226
- const [deletedElement, propName] = getElementAndPropName(rootElements.old, updateElementPath);
227
- const [insertedElement, _] = getElementAndPropName(rootElements.new, updateElementPath);
226
+ const [deletedElement, propName] = getElementAndPropName(rootElements.before, updateElementPath);
227
+ const [insertedElement, _] = getElementAndPropName(rootElements.after, updateElementPath);
228
228
  const elements = new Map(elementTree.elements);
229
229
  const elementIds = new Map(elementTree.elementIds);
230
230
  deleteElement({ elements, elementIds }, deletedElement, propName, descriptors);
231
231
  insertElement({ elements, elementIds }, insertedElement, propName, descriptors);
232
- updateParentElements(elements, parentElementPaths, rootElements.new);
232
+ updateParentElements(elements, parentElementPaths, rootElements.after);
233
233
  return {
234
234
  elements,
235
235
  elementIds
236
236
  };
237
237
  }
238
+ function applyOpComponent(root, component) {
239
+ let applied = root;
240
+ if ("ld" in component || "od" in component) {
241
+ applied = removeIn(applied, component.p);
242
+ }
243
+ if ("li" in component) {
244
+ applied = setIn(applied, component.p, component.li);
245
+ }
246
+ if ("oi" in component) {
247
+ applied = setIn(applied, component.p, component.oi);
248
+ }
249
+ return applied;
250
+ }
251
+ function selectTreeTransform(op) {
252
+ const hasDelete = "ld" in op || "od" in op;
253
+ const hasInsert = "li" in op || "oi" in op;
254
+ if (hasDelete && hasInsert)
255
+ return applyUpdate;
256
+ if (hasDelete)
257
+ return applyDelete;
258
+ if (hasInsert)
259
+ return applyInsert;
260
+ return (elementTree) => elementTree;
261
+ }
238
262
  function applyChanges(elementTree, descriptors, rootElements, operation) {
239
- return operation.reduce((tree, op) => {
240
- const hasDelete = "ld" in op || "od" in op;
241
- const hasInsert = "li" in op || "oi" in op;
242
- if (hasDelete && hasInsert) {
243
- return applyUpdate(tree, descriptors, rootElements, op.p);
244
- }
245
- if (hasDelete)
246
- return applyDelete(tree, descriptors, rootElements, op.p);
247
- if (hasInsert)
248
- return applyInsert(tree, descriptors, rootElements, op.p);
249
- return tree;
250
- }, elementTree);
263
+ const result = operation.reduce(
264
+ (acc, op) => {
265
+ const rootBefore = acc.rootBefore;
266
+ const rootAfter = operation.length > 1 ? applyOpComponent(rootBefore, op) : rootElements.new;
267
+ const roots = { before: rootBefore, after: rootAfter };
268
+ const applyChange = selectTreeTransform(op);
269
+ return {
270
+ elementTree: applyChange(acc.elementTree, descriptors, roots, op.p),
271
+ rootBefore: rootAfter
272
+ };
273
+ },
274
+ { elementTree, rootBefore: rootElements.old }
275
+ );
276
+ return result.elementTree;
251
277
  }
252
278
  export {
253
279
  buildElementTree,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controllers'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction hasChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n if (isElementReference(element)) return false\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return false\n\n const children = Introspection.getElementChildren(propDescriptor, element.props[propName])\n return children.length > 0\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n deletedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(deletedElement, propName, descriptors)) {\n for (const element of traverseElementTree(deletedElement, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n } else {\n elements.delete(deletedElement.key)\n elementIds.delete(deletedElement.key)\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [deleteElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.old, deleteElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.new, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.old, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.new, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n updateParentElements(elements, parentElementPaths, rootElements.new)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n return operation.reduce((tree, op) => {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n if (hasDelete && hasInsert) {\n return applyUpdate(tree, descriptors, rootElements, op.p)\n }\n\n if (hasDelete) return applyDelete(tree, descriptors, rootElements, op.p)\n if (hasInsert) return applyInsert(tree, descriptors, rootElements, op.p)\n return tree\n }, elementTree)\n}\n"],"mappings":"AACA,SAAS,aAAa;AAEtB,SAAyC,0BAA0B;AAEnE,YAAY,mBAAmB;AAE/B,SAA0C,qBAAqB;AAE/D,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAErC,SAAS,sBAAqC;AAUvC,SAAS,gBACd,WACA,aACO;AACP,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,MAAI,aAAa,QAAQ,eAAe;AAAM,WAAO;AAErD,aAAW,CAAC,aAAa,QAAQ,KAAK,WAAW;AAC/C,UAAM,IAAI,aAAa,iBAAiB,eAAe,QAAQ,GAAG,WAAW,CAAC;AAAA,EAChF;AAEA,SAAO;AACT;AAEA,S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B;AAC5F,QAAM,CAAC,iBAAiB,CAAC,IAAI,sBAAsB,aAAa,KAAK,iBAAiB;AAEtF,QAAM,WAAW,IAAI,IAAI,YAAY,QAAQ;AAC7C,QAAM,aAAa,IAAI,IAAI,YAAY,UAAU;AAEjD,gBAAc,EAAE,UAAU,WAAW,GAAG,gBAAgB,UAAU,WAAW;AAC7E,gBAAc,EAAE,UAAU,WAAW,GAAG,iBAAiB,UAAU,WAAW;AAE9E,uBAAqB,UAAU,oBAAoB,aAAa,GAAG;AAEnE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,aACP,aACA,aACA,cACA,WACa;AACb,SAAO,UAAU,OAAO,CAAC,MAAM,OAAO;AACpC,UAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,UAAM,YAAY,QAAQ,MAAM,QAAQ;AACxC,QAAI,aAAa,WAAW;AAC1B,aAAO,YAAY,MAAM,aAAa,cAAc,GAAG,CAAC;AAAA,IAC1D;AAEA,QAAI;AAAW,aAAO,YAAY,MAAM,aAAa,cAAc,GAAG,CAAC;AACvE,QAAI;AAAW,aAAO,YAAY,MAAM,aAAa,cAAc,GAAG,CAAC;AACvE,WAAO;AAAA,EACT,GAAG,WAAW;AAChB;","names":["i"]}
1
+ {"version":3,"sources":["../../../../src/state/modules/element-trees.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { getIn, removeIn, setIn } from 'immutable'\n\nimport { type Element, type ElementData, isElementReference } from '@makeswift/controls'\n\nimport * as Introspection from '../../prop-controllers/introspection'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\n\nimport { getRootElement, type Document } from './read-only-documents'\nimport { type DescriptorsByComponentType } from './prop-controllers'\n\nexport type ElementTree = {\n elements: Map<string, Element>\n elementIds: Map<string, string>\n}\n\nexport type State = Map<string, ElementTree>\n\nexport function getInitialState(\n documents?: Map<string, Document>,\n descriptors?: DescriptorsByComponentType,\n): State {\n const state = new Map<string, ElementTree>()\n if (documents == null || descriptors == null) return state\n\n for (const [documentKey, document] of documents) {\n state.set(documentKey, buildElementTree(getRootElement(document), descriptors))\n }\n\n return state\n}\n\nfunction getElementTree(state: State, documentKey: string): ElementTree | null {\n return state.get(documentKey) ?? null\n}\n\nexport function getElements(state: State, documentKey: string): Map<string, Element> {\n return getElementTree(state, documentKey)?.elements ?? new Map()\n}\n\nexport function getElementIds(state: State, documentKey: string): Map<string, string> {\n return getElementTree(state, documentKey)?.elementIds ?? new Map()\n}\n\nexport function getElement(state: State, documentKey: string, elementKey: string): Element | null {\n return getElements(state, documentKey).get(elementKey) ?? null\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return getElementIds(state, documentKey).get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {\n const { document, descriptors } = action.payload\n return new Map(state).set(\n document.key,\n buildElementTree(getRootElement(document), descriptors),\n )\n }\n\n case ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.documentKey)\n return deleted ? nextState : state\n }\n\n case ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {\n const { oldDocument, newDocument, descriptors, operation } = action.payload\n const documentKey = oldDocument.key\n console.assert(\n documentKey === newDocument.key,\n `Mismatching document keys ${documentKey} !== ${newDocument.key}`,\n )\n\n const elementTree = state.get(documentKey)\n if (elementTree == null) return state\n\n const updatedElementTree = applyChanges(\n elementTree,\n descriptors,\n {\n old: getRootElement(oldDocument),\n new: getRootElement(newDocument),\n },\n operation,\n )\n\n return new Map(state).set(documentKey, updatedElementTree)\n }\n\n default:\n return state\n }\n}\n\nexport function* traverseElementTree(\n element: Element,\n descriptors: DescriptorsByComponentType,\n): Generator<Element> {\n yield element\n if (isElementReference(element)) return\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return\n\n for (const [propKey, descriptor] of Object.entries(elementDescriptors)) {\n const children = Introspection.getElementChildren(descriptor, element.props[propKey])\n for (const child of children) {\n yield* traverseElementTree(child, descriptors)\n }\n }\n}\n\nfunction getElementIdProp(\n element: ElementData,\n descriptors: DescriptorsByComponentType,\n): string | null {\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) return null\n\n for (const [propName, descriptor] of Object.entries(elementDescriptors)) {\n const elementId = Introspection.getElementId(descriptor, element.props[propName])\n if (elementId != null) return elementId\n }\n\n return null\n}\n\nexport function buildElementTree(\n rootElement: Element,\n descriptors: DescriptorsByComponentType,\n): ElementTree {\n const elements = new Map<string, Element>()\n const elementIds = new Map<string, string>()\n\n for (const element of traverseElementTree(rootElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n\n return {\n elements,\n elementIds,\n }\n}\n\ntype OperationPath = Operation[number]['p']\n\n// performance-sensitive function, intentionally not using `elementData` schema here\nfunction isElement(item: unknown): item is Element {\n return (\n typeof item === 'object' &&\n item != null &&\n 'key' in item &&\n 'type' in item &&\n typeof item.key === 'string' &&\n typeof item.type === 'string'\n )\n}\n\ntype ElementOperationPath = { elementPath: OperationPath; propName: string | null }\n\nfunction getElementOperationPath(path: OperationPath): ElementOperationPath {\n if (path.length === 0) {\n return { elementPath: [], propName: null }\n }\n\n const i = path.findLastIndex(\n (fragment, i) =>\n typeof fragment === 'number' && (i === path.length - 1 || path[i + 1] === 'props'),\n )\n\n if ((i === -1 && path[0] !== 'props') || path.length - i < 3) {\n console.error('Operation path does not point to an element property', { path })\n return { elementPath: [], propName: null }\n }\n\n return { elementPath: path.slice(0, i + 1), propName: `${path.slice(i + 1).at(1)}` }\n}\n\nexport function getChangedElementsPaths(\n path: OperationPath,\n): [ElementOperationPath, ...ElementOperationPath[]] {\n let elementOp = getElementOperationPath(path)\n const result: [ElementOperationPath, ...ElementOperationPath[]] = [elementOp]\n while (elementOp.elementPath.length > 0) {\n elementOp = getElementOperationPath(elementOp.elementPath.slice(0, -1))\n result.push(elementOp)\n }\n\n return result\n}\n\nfunction getElementByPath(rootElement: Element, elementPath: OperationPath): Element | null {\n const item = getIn(rootElement, elementPath)\n if (!isElement(item)) {\n console.error('Expected an element, got', item, {\n rootElement,\n elementPath,\n })\n\n return null\n }\n\n return item\n}\n\nfunction getElementAndPropName(\n rootElement: Element,\n { elementPath, propName }: ElementOperationPath,\n): [Element, string | null] {\n const element = getElementByPath(rootElement, elementPath)\n return element != null ? [element, propName] : [rootElement, null]\n}\n\nfunction updateParentElements(\n elements: ElementTree['elements'],\n elementPaths: ElementOperationPath[],\n rootElement: Element,\n): void {\n elementPaths.forEach(({ elementPath }) => {\n const element = getElementByPath(rootElement, elementPath)\n if (element != null) elements.set(element.key, element)\n })\n}\n\nfunction hasChildren(\n element: Element,\n propName: string,\n descriptors: DescriptorsByComponentType,\n): boolean {\n if (isElementReference(element)) return false\n\n const propDescriptor = descriptors.get(element.type)?.[propName]\n if (propDescriptor == null) return false\n\n const children = Introspection.getElementChildren(propDescriptor, element.props[propName])\n return children.length > 0\n}\n\nfunction deleteElement(\n { elements, elementIds }: ElementTree,\n deletedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(deletedElement, propName, descriptors)) {\n for (const element of traverseElementTree(deletedElement, descriptors)) {\n elements.delete(element.key)\n elementIds.delete(element.key)\n }\n } else {\n elements.delete(deletedElement.key)\n elementIds.delete(deletedElement.key)\n }\n}\n\nfunction applyDelete(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [deleteElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.before, deleteElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction insertElement(\n { elements, elementIds }: ElementTree,\n insertedElement: Element,\n propName: string | null,\n descriptors: DescriptorsByComponentType,\n) {\n if (propName == null || hasChildren(insertedElement, propName, descriptors)) {\n for (const element of traverseElementTree(insertedElement, descriptors)) {\n elements.set(element.key, element)\n if (!isElementReference(element)) {\n const elementId = getElementIdProp(element, descriptors)\n if (elementId != null) elementIds.set(element.key, elementId)\n }\n }\n } else {\n elements.set(insertedElement.key, insertedElement)\n if (!isElementReference(insertedElement)) {\n const elementId = getElementIdProp(insertedElement, descriptors)\n if (elementId != null) elementIds.set(insertedElement.key, elementId)\n }\n }\n}\n\nfunction applyInsert(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [insertedElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [insertedElement, propName] = getElementAndPropName(rootElements.after, insertedElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyUpdate(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { before: Element; after: Element },\n path: OperationPath,\n): ElementTree {\n const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path)\n const [deletedElement, propName] = getElementAndPropName(rootElements.before, updateElementPath)\n const [insertedElement, _] = getElementAndPropName(rootElements.after, updateElementPath)\n\n const elements = new Map(elementTree.elements)\n const elementIds = new Map(elementTree.elementIds)\n\n deleteElement({ elements, elementIds }, deletedElement, propName, descriptors)\n insertElement({ elements, elementIds }, insertedElement, propName, descriptors)\n\n // Use the \"after\" state to efficiently update all of parent subtrees in the state\n updateParentElements(elements, parentElementPaths, rootElements.after)\n\n return {\n elements,\n elementIds,\n }\n}\n\nfunction applyOpComponent(root: Element, component: Operation[number]): Element {\n let applied: Element = root\n\n if ('ld' in component || 'od' in component) {\n applied = removeIn(applied, component.p)\n }\n\n if ('li' in component) {\n applied = setIn(applied, component.p, component.li)\n }\n\n if ('oi' in component) {\n applied = setIn(applied, component.p, component.oi)\n }\n\n return applied\n}\n\nfunction selectTreeTransform(op: Operation[number]): typeof applyUpdate {\n const hasDelete = 'ld' in op || 'od' in op\n const hasInsert = 'li' in op || 'oi' in op\n\n if (hasDelete && hasInsert) return applyUpdate\n if (hasDelete) return applyDelete\n if (hasInsert) return applyInsert\n\n return elementTree => elementTree\n}\n\nfunction applyChanges(\n elementTree: ElementTree,\n descriptors: DescriptorsByComponentType,\n rootElements: { old: Element; new: Element },\n operation: Operation,\n): ElementTree {\n // Updates the element tree \"cache\" based on the provided operation, which can\n // be composed of 1-n component ops. We apply each component op sequentially\n // to the 'old' root element to determine the changed elements and update the\n // cache accordingly at each intermediate step.\n const result = operation.reduce(\n (acc, op) => {\n const rootBefore = acc.rootBefore\n\n // If there's only one component op, we can skip the application of the op\n // and assume that the result will be the 'new' root element provided to\n // us by the builder.\n const rootAfter = operation.length > 1 ? applyOpComponent(rootBefore, op) : rootElements.new\n\n const roots = { before: rootBefore, after: rootAfter }\n const applyChange = selectTreeTransform(op)\n\n return {\n elementTree: applyChange(acc.elementTree, descriptors, roots, op.p),\n rootBefore: rootAfter,\n }\n },\n { elementTree, rootBefore: rootElements.old },\n )\n\n return result.elementTree\n}\n"],"mappings":"AACA,SAAS,OAAO,UAAU,aAAa;AAEvC,SAAyC,0BAA0B;AAEnE,YAAY,mBAAmB;AAE/B,SAA0C,qBAAqB;AA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P,aACA,aACA,cACA,WACa;AAKb,QAAM,SAAS,UAAU;AAAA,IACvB,CAAC,KAAK,OAAO;AACX,YAAM,aAAa,IAAI;AAKvB,YAAM,YAAY,UAAU,SAAS,IAAI,iBAAiB,YAAY,EAAE,IAAI,aAAa;AAEzF,YAAM,QAAQ,EAAE,QAAQ,YAAY,OAAO,UAAU;AACrD,YAAM,cAAc,oBAAoB,EAAE;AAE1C,aAAO;AAAA,QACL,aAAa,YAAY,IAAI,aAAa,aAAa,OAAO,GAAG,CAAC;AAAA,QAClE,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IACA,EAAE,aAAa,YAAY,aAAa,IAAI;AAAA,EAC9C;AAEA,SAAO,OAAO;AAChB;","names":["i"]}
@@ -304,7 +304,6 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
304
304
  unstable_defaultLocale?: unknown;
305
305
  }>;
306
306
  }, "strip", z.ZodTypeAny, {
307
- type: "site.published";
308
307
  data: {
309
308
  at: number;
310
309
  siteId: string;
@@ -381,8 +380,8 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
381
380
  }, z.ZodTypeAny, "passthrough"> | null | undefined;
382
381
  unstable_defaultLocale?: string | null | undefined;
383
382
  };
384
- }, {
385
383
  type: "site.published";
384
+ }, {
386
385
  data: {
387
386
  at: number;
388
387
  siteId: string;
@@ -393,6 +392,7 @@ export declare const sitePublishedWebhookPayloadSchema: z.ZodObject<{
393
392
  unstable_diff?: unknown;
394
393
  unstable_defaultLocale?: unknown;
395
394
  };
395
+ type: "site.published";
396
396
  }>;
397
397
  export type SitePublishedWebhookPayload = z.infer<typeof sitePublishedWebhookPayloadSchema>;
398
398
  export type SitePublishedWebhookPayloadData = z.infer<typeof sitePublishedWebhookPayloadSchema>['data'];
@@ -697,7 +697,6 @@ declare const webhookPayloadSchema: z.ZodObject<{
697
697
  unstable_defaultLocale?: unknown;
698
698
  }>;
699
699
  }, "strip", z.ZodTypeAny, {
700
- type: "site.published";
701
700
  data: {
702
701
  at: number;
703
702
  siteId: string;
@@ -774,8 +773,8 @@ declare const webhookPayloadSchema: z.ZodObject<{
774
773
  }, z.ZodTypeAny, "passthrough"> | null | undefined;
775
774
  unstable_defaultLocale?: string | null | undefined;
776
775
  };
777
- }, {
778
776
  type: "site.published";
777
+ }, {
779
778
  data: {
780
779
  at: number;
781
780
  siteId: string;
@@ -786,6 +785,7 @@ declare const webhookPayloadSchema: z.ZodObject<{
786
785
  unstable_diff?: unknown;
787
786
  unstable_defaultLocale?: unknown;
788
787
  };
788
+ type: "site.published";
789
789
  }>;
790
790
  export type WebhookPayloadSchema = z.infer<typeof webhookPayloadSchema>;
791
791
  type WebhookSuccessBody = {
@@ -0,0 +1,23 @@
1
+ import { type Data, ControlDefinition as UnifiedControlDefinition, type SerializedRecord, DeserializationPlugin } from '@makeswift/controls';
2
+ import { type SerializedLegacyControl, type DeserializedLegacyControl } from '../prop-controllers/serialization';
3
+ import { type Descriptor } from '../prop-controllers/descriptors';
4
+ import { type DeserializedFunction, type SerializedFunction } from '../controls/serialization/message-port';
5
+ import { type DeserializeControlRecordsOptions } from '../controls/serialization';
6
+ export * from '../prop-controllers/serialization';
7
+ export type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord;
8
+ export type DeserializedControl<T extends Data = Data> = DeserializedLegacyControl<T> | UnifiedControlDefinition;
9
+ export declare function serializeControl<T extends Data>(control: Descriptor<T>): [SerializedControl<T>, Transferable[]];
10
+ export type DeserializeControlOptions = {
11
+ plugins?: DeserializationPlugin<any>[];
12
+ };
13
+ export declare function deserializeControl<T extends Data>(serializedControl: SerializedControl<T>, options?: DeserializeControlOptions): DeserializedControl<T>;
14
+ export declare function serializeControls(controls: Record<string, Descriptor>): [Record<string, SerializedControl>, Transferable[]];
15
+ export declare function deserializeControls(serializedControls: Record<string, unknown>, { onError, plugins }?: DeserializeControlRecordsOptions): Record<string, DeserializedControl>;
16
+ type AnyFunction = (...args: any[]) => any;
17
+ export type Serialize<T> = T extends AnyFunction ? SerializedFunction<T> : T extends Record<string, unknown> ? {
18
+ [K in keyof T]: Serialize<T[K]>;
19
+ } : T;
20
+ export type Deserialize<T> = T extends SerializedFunction<infer U> ? DeserializedFunction<U> : T extends Record<string, unknown> ? {
21
+ [K in keyof T]: Deserialize<T[K]>;
22
+ } : T;
23
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/builder/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,iBAAiB,IAAI,wBAAwB,EAC7C,KAAK,gBAAgB,EACrB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAG/B,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,iCAAiC,CAAA;AAGrF,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAGxB,MAAM,wCAAwC,CAAA;AAE/C,OAAO,EACL,KAAK,gCAAgC,EAEtC,MAAM,2BAA2B,CAAA;AAElC,cAAc,mCAAmC,CAAA;AAEjD,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IAAI,uBAAuB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAA;AAEpG,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IACjD,yBAAyB,CAAC,CAAC,CAAC,GAC5B,wBAAwB,CAAA;AAE5B,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,IAAI,EAC7C,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAQxC;AAQD,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,CAAC,EAAE,qBAAqB,CAAC,GAAG,CA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@@
1
+ {"version":3,"file":"serialization.test.d.ts","sourceRoot":"","sources":["../../../src/builder/serialization.test.ts"],"names":[],"mappings":""}
@@ -330,7 +330,6 @@ declare const makeswiftComponentDocumentSchema: z.ZodObject<{
330
330
  siteId: z.ZodString;
331
331
  inheritsFromParent: z.ZodBoolean;
332
332
  }, "strip", z.ZodTypeAny, {
333
- id: string;
334
333
  data: ({
335
334
  type: string;
336
335
  key: string;
@@ -396,12 +395,12 @@ declare const makeswiftComponentDocumentSchema: z.ZodObject<{
396
395
  value: string;
397
396
  key: string;
398
397
  } | undefined);
398
+ id: string;
399
399
  name: string | null;
400
400
  locale: string | null;
401
401
  siteId: string;
402
402
  inheritsFromParent: boolean;
403
403
  }, {
404
- id: string;
405
404
  data: ({
406
405
  type: string;
407
406
  key: string;
@@ -467,6 +466,7 @@ declare const makeswiftComponentDocumentSchema: z.ZodObject<{
467
466
  value: string;
468
467
  key: string;
469
468
  } | undefined);
469
+ id: string;
470
470
  name: string | null;
471
471
  locale: string | null;
472
472
  siteId: string;
@@ -478,12 +478,12 @@ declare const makeswiftComponentDocumentFallbackSchema: z.ZodObject<{
478
478
  locale: z.ZodNullable<z.ZodString>;
479
479
  data: z.ZodNull;
480
480
  }, "strip", z.ZodTypeAny, {
481
- id: string;
482
481
  data: null;
482
+ id: string;
483
483
  locale: string | null;
484
484
  }, {
485
- id: string;
486
485
  data: null;
486
+ id: string;
487
487
  locale: string | null;
488
488
  }>;
489
489
  export type MakeswiftComponentDocumentFallback = z.infer<typeof makeswiftComponentDocumentFallbackSchema>;
@@ -0,0 +1,10 @@
1
+ import { ControlDefinition, type SerializedRecord, type DeserializedRecord, DeserializationPlugin } from '@makeswift/controls';
2
+ import { BaseControlSerializationVisitor } from './visitor';
3
+ export { type SerializedRecord, type DeserializedRecord } from '@makeswift/controls';
4
+ export declare function serializeControls(controls: Record<string, ControlDefinition>, visitor: BaseControlSerializationVisitor): Record<string, SerializedRecord>;
5
+ export type DeserializeControlOptions = {
6
+ plugins: DeserializationPlugin<any>[];
7
+ };
8
+ export declare function deserializeControl(serializedControl: SerializedRecord, options: DeserializeControlOptions): ControlDefinition;
9
+ export declare function deserializeUnifiedControlDef(record: DeserializedRecord): ControlDefinition;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAA;AAyB5B,OAAO,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAA;AAE3D,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAEpF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAC3C,OAAO,EAAE,+BAA+B,GACvC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAOlC;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAA;CACtC,CAAA;AAED,wBAAgB,kBAAkB,CAChC,iBAAiB,EAAE,gBAAgB,EACnC,OAAO,EAAE,yBAAyB,GACjC,iBAAiB,CAInB;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,kBAAkB,GAAG,iBAAiB,CAsC1F"}
@@ -0,0 +1,7 @@
1
+ import { SerializedRecord, SerializationPlugin, ControlSerializationVisitor } from '@makeswift/controls';
2
+ import { RichTextV2Definition } from '../../rich-text-v2';
3
+ export declare class BaseControlSerializationVisitor extends ControlSerializationVisitor {
4
+ constructor(plugins: SerializationPlugin<any>[]);
5
+ visitRichTextV2(def: RichTextV2Definition): SerializedRecord;
6
+ }
7
+ //# sourceMappingURL=visitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/base/visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEhB,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEzD,qBAAa,+BAAgC,SAAQ,2BAA2B;gBAClE,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAAE;IAS/C,eAAe,CAAC,GAAG,EAAE,oBAAoB,GAAG,gBAAgB;CAyB7D"}
@@ -0,0 +1,10 @@
1
+ import { type SerializedRecord, type DeserializeControlOptions } from './base';
2
+ export declare function isSerializedRecord(r: unknown): r is SerializedRecord;
3
+ export type DeserializeControlRecordsOptions = {
4
+ onError?: (err: Error, context: {
5
+ key: string;
6
+ serializedControl: unknown;
7
+ }) => void;
8
+ } & Partial<Pick<DeserializeControlOptions, 'plugins'>>;
9
+ export declare function deserializeControlRecords<T>(serializedControls: Record<string, unknown>, deserialize: (serializedControl: SerializedRecord, options?: Partial<DeserializeControlOptions>) => T, { onError, plugins }?: DeserializeControlRecordsOptions): Record<string, T>;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/controls/serialization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,yBAAyB,EAAE,MAAM,QAAQ,CAAA;AAE9E,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,CAEpE;AAED,MAAM,MAAM,gCAAgC,GAAG;IAC7C,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;CACrF,GAAG,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC,CAAA;AAEvD,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,WAAW,EAAE,CACX,iBAAiB,EAAE,gBAAgB,EACnC,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,KACzC,CAAC,EACN,EAAE,OAAO,EAAE,OAAO,EAAE,GAAE,gCAAqC,GAC1D,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CA0BnB"}
@@ -1,4 +1,5 @@
1
1
  import { DeserializationPlugin, type AnyFunction, type SerializedFunctionReturnType, type DeserializedFunction } from '@makeswift/controls';
2
+ export { type DeserializedFunction } from '@makeswift/controls';
2
3
  declare const SerializedFunctionTag: unique symbol;
3
4
  type ResolveCallPromise<T extends AnyFunction> = (value: SerializedFunctionReturnType<T>) => void;
4
5
  type OnMessageHandler<T extends AnyFunction> = MessagePort['onmessage'] & {
@@ -12,5 +13,4 @@ export declare function isSerializedFunction(value: any): value is SerializedFun
12
13
  export declare function serializeFunction<T extends AnyFunction>(func: T): SerializedFunction<T>;
13
14
  export declare function deserializeFunction<T extends AnyFunction>(serializedFunction: SerializedFunction<T>): DeserializedFunction<T>;
14
15
  export declare const functionDeserializationPlugin: DeserializationPlugin<SerializedFunction<AnyFunction>, DeserializedFunction<AnyFunction>>;
15
- export {};
16
16
  //# sourceMappingURL=function-serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-serialization.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/message-port/function-serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,WAAW,EAChB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,CAAC,MAAM,qBAAqB,EAAE,OAAO,MAAM,CAAA;AAElD,KAAK,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,KAAK,EAAE,4BAA4B,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;AAEjG,KAAK,gBAAgB,CAAC,CAAC,SAAS,WAAW,IAAI,WAAW,CAAC,WAAW,CAAC,GAAG;IACxE,OAAO,CAAC,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;CACjD,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI,WAAW,GAAG;IACpE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC9B,QAAQ,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAEzF;AAID,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAYvF;AAqBD,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,WAAW,EACvD,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC,GACxC,oBAAoB,CAAC,CAAC,CAAC,CAkBzB;AAED,eAAO,MAAM,6BAA6B,EAAE,qBAAqB,CAC/D,kBAAkB,CAAC,WAAW,CAAC,EAC/B,oBAAoB,CAAC,WAAW,CAAC,CAIlC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-serialization.test.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/message-port/function-serialization.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './function-serialization';
2
+ export * from './visitor';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/message-port/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,WAAW,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { BaseControlSerializationVisitor } from '../base/visitor';
2
+ export declare class ClientMessagePortSerializationVisitor extends BaseControlSerializationVisitor {
3
+ private transferables;
4
+ constructor();
5
+ getTransferables(): Transferable[];
6
+ }
7
+ //# sourceMappingURL=visitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/message-port/visitor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAA;AAGjE,qBAAa,qCAAsC,SAAQ,+BAA+B;IACxF,OAAO,CAAC,aAAa,CAAqB;;IAe1C,gBAAgB,IAAI,YAAY,EAAE;CAGnC"}
@@ -1,11 +1,9 @@
1
- import { GapData, GapX, GapYDescriptor, GapYPropControllerData, ResponsiveLengthOptions, ResponsiveLengthPropControllerData, ResponsiveIconRadioGroup, ResponsiveNumber, ResponsiveSelect, type Descriptor, type PropDef, type OptionsType } from '@makeswift/prop-controllers';
2
- import { type Data, type Device, ControlDefinition as UnifiedControlDefinition, type SerializedRecord, type RichTextValue as RichTextControlValue, DeserializationPlugin } from '@makeswift/controls';
3
- import { PanelDescriptorType as PanelControlType, Descriptor as ControlDefinition } from '../../prop-controllers/descriptors';
4
- import { DELETED_PROP_CONTROLLER_TYPES, ListDescriptor as ListControl, ListOptions as ListControlConfig, ListValue as ListControlValue, ShapeDescriptor as ShapeControl, ShapeValue as ShapeControlValue, TypeaheadDescriptor as TypeaheadControl, TypeaheadOptions as TypeaheadControlConfig, TypeaheadValue as TypeaheadControlValue, RichTextDescriptor as RichTextControl } from '../../prop-controllers/deleted';
5
- import { DeserializedFunction, SerializedFunction } from './function-serialization';
6
- import { LinkData, DateDescriptor as DateControl, DatePropControllerData, Types as PropControllerTypes, ImageDescriptor as ImageControl, ImageData as ImageControlValue, LinkDescriptor as LinkControl, LinkPropControllerData, ResponsiveLengthDescriptor, NumberOptions, NumberPropControllerData, NumberDescriptor, ResponsiveColorPropControllerData, ResponsiveColorDescriptor, CheckboxPropControllerData, CheckboxDescriptor as CheckboxControl, TextStyleDescriptor as TextStyleControl, TextStylePropControllerData, TextInputDescriptor as TextInputControl } from '@makeswift/prop-controllers';
7
- import { type LegacyDescriptor } from '../../prop-controllers/descriptors';
8
- import { type DeserializedRecord } from '@makeswift/controls';
1
+ import { type Data, type Device, type RichTextValue as RichTextControlValue } from '@makeswift/controls';
2
+ import { type Descriptor, type PropDef, type OptionsType, CheckboxDescriptor as CheckboxControl, CheckboxPropControllerData, DateDescriptor as DateControl, DatePropControllerData, ImageDescriptor as ImageControl, ImageData as ImageControlValue, GapData, GapX, GapYDescriptor, GapYPropControllerData, LinkData, LinkDescriptor as LinkControl, LinkPropControllerData, NumberDescriptor, NumberOptions, NumberPropControllerData, ResponsiveColorDescriptor, ResponsiveColorPropControllerData, ResponsiveIconRadioGroup, ResponsiveLengthDescriptor, ResponsiveLengthOptions, ResponsiveLengthPropControllerData, ResponsiveNumber, ResponsiveSelect, Types as PropControllerTypes, TextStyleDescriptor as TextStyleControl, TextStylePropControllerData, TextInputDescriptor as TextInputControl } from '@makeswift/prop-controllers';
3
+ import { type DeserializedFunction, type SerializedFunction } from '../controls/serialization/message-port/function-serialization';
4
+ import { PanelDescriptorType as PanelControlType } from './descriptors';
5
+ import { DELETED_PROP_CONTROLLER_TYPES, ListDescriptor as ListControl, ListOptions as ListControlConfig, ListValue as ListControlValue, ShapeDescriptor as ShapeControl, ShapeValue as ShapeControlValue, TypeaheadDescriptor as TypeaheadControl, TypeaheadOptions as TypeaheadControlConfig, TypeaheadValue as TypeaheadControlValue, RichTextDescriptor as RichTextControl } from './deleted';
6
+ import { type LegacyDescriptor } from './descriptors';
9
7
  type SerializedShapeControlConfig<T extends Record<string, SerializedPanelControl>> = {
10
8
  type: T;
11
9
  preset?: {
@@ -215,32 +213,16 @@ type DeserializedRichTextControl<_T = RichTextControlValue> = {
215
213
  options: DeserializedConfig<RichTextControlConfig>;
216
214
  };
217
215
  export type SerializedLegacyControl<T extends Data = Data> = Exclude<LegacyDescriptor<T>, ListControl<T extends ListControlValue ? T : ListControlValue> | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any> | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue> | Descriptor<typeof GapX> | GapYDescriptor<T> | Descriptor<typeof ResponsiveNumber> | CheckboxControl<T> | ResponsiveColorDescriptor<T> | NumberDescriptor<T> | Descriptor<typeof ResponsiveIconRadioGroup> | Descriptor<typeof ResponsiveSelect> | ResponsiveLengthDescriptor<T> | DateControl<T> | LinkControl<T> | TextInputControl<T> | TextStyleControl<T> | ImageControl<T> | RichTextControl<T>> | SerializedListControl<T extends ListControlValue ? T : ListControlValue> | SerializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any> | SerializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue> | SerializedControlDef<typeof GapX> | SerializedGapYControl<T> | SerializedControlDef<typeof ResponsiveNumber> | SerializedCheckboxControl<T> | SerializedResponsiveColorControl<T> | SerializedNumberControl<T> | SerializedControlDef<typeof ResponsiveIconRadioGroup> | SerializedControlDef<typeof ResponsiveSelect> | SerializedResponsiveLengthControl<T> | SerializedDateControl<T> | SerializedLinkControl<T> | SerializedTextInputControl<T> | SerializedTextStyleControl<T> | SerializedImageControl<T> | SerializedRichTextControl<T>;
218
- export type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord;
219
- type SerializedPanelControl<T extends Data = Data> = Extract<SerializedControl<T>, {
216
+ type SerializedPanelControl<T extends Data = Data> = Extract<SerializedLegacyControl<T>, {
220
217
  type: PanelControlType;
221
218
  }>;
222
219
  type SerializedPanelControlValueType<T extends SerializedPanelControl> = T extends SerializedPanelControl<infer U> ? U : never;
223
220
  export type DeserializedLegacyControl<T extends Data = Data> = Exclude<LegacyDescriptor<T>, ListControl<T extends ListControlValue ? T : ListControlValue> | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any> | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue> | Descriptor<typeof GapX> | GapYDescriptor<T> | Descriptor<typeof ResponsiveNumber> | CheckboxControl<T> | ResponsiveColorDescriptor<T> | NumberDescriptor<T> | Descriptor<typeof ResponsiveIconRadioGroup> | Descriptor<typeof ResponsiveSelect> | ResponsiveLengthDescriptor<T> | DateControl<T> | LinkControl<T> | TextInputControl<T> | TextStyleControl<T> | ImageControl<T> | RichTextControl<T>> | DeserializedListControl<T extends ListControlValue ? T : ListControlValue> | DeserializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any> | DeserializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue> | DeserializedControlDef<typeof GapX> | DeserializedGapYControl<T> | DeserializedControlDef<typeof ResponsiveNumber> | DeserializedCheckboxControl<T> | DeserializedResponsiveColorControl<T> | DeserializedNumberControl<T> | DeserializedControlDef<typeof ResponsiveIconRadioGroup> | DeserializedControlDef<typeof ResponsiveSelect> | DeserializedResponsiveLengthControl<T> | DeserializedDateControl<T> | DeserializedLinkControl<T> | DeserializedTextInputControl<T> | DeserializedTextStyleControl<T> | DeserializedImageControl<T> | DeserializedRichTextControl<T>;
224
- export type DeserializedControl<T extends Data = Data> = DeserializedLegacyControl<T> | UnifiedControlDefinition;
225
- export type DeserializedPanelControl<T extends Data = Data> = Extract<DeserializedControl<T>, {
221
+ export type DeserializedPanelControl<T extends Data = Data> = Extract<DeserializedLegacyControl<T>, {
226
222
  type: PanelControlType;
227
223
  }>;
228
224
  type DeserializedPanelControlValueType<T extends DeserializedPanelControl> = T extends DeserializedPanelControl<infer U> ? U : never;
229
- export declare function serializeControl<T extends Data>(control: ControlDefinition<T>): [SerializedControl<T>, Transferable[]];
230
- export declare function isSerializedControl(control: unknown): control is SerializedControl;
231
- export declare function deserializeLegacyControl<T extends Data>(serializedControl: SerializedLegacyControl<T>): DeserializedControl<T>;
232
- export type DeserializeControlOptions = {
233
- plugins?: DeserializationPlugin<any>[];
234
- };
235
- export declare function deserializeControl<T extends Data>(serializedControl: SerializedControl<T>, options?: DeserializeControlOptions): DeserializedControl<T>;
236
- export declare function deserializeUnifiedControlDef(record: DeserializedRecord): UnifiedControlDefinition;
237
- export declare function serializeControls(controls: Record<string, ControlDefinition>): [Record<string, SerializedControl>, Transferable[]];
238
- export type DeserializeControlsOptions = {
239
- onError?: (err: Error, context: {
240
- key: string;
241
- serializedControl: unknown;
242
- }) => void;
243
- } & Pick<DeserializeControlOptions, 'plugins'>;
244
- export declare function deserializeControls(serializedControls: Record<string, unknown>, { onError, plugins, }?: DeserializeControlsOptions): Record<string, DeserializedControl>;
225
+ export declare function serializeLegacyControl<T extends Data>(control: LegacyDescriptor<T>): [SerializedLegacyControl<T>, Transferable[]];
226
+ export declare function deserializeLegacyControl<T extends Data>(serializedControl: SerializedLegacyControl<T>): DeserializedLegacyControl<T>;
245
227
  export {};
246
- //# sourceMappingURL=control-serialization.d.ts.map
228
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/prop-controllers/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,aAAa,IAAI,oBAAoB,EAC3C,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,kBAAkB,IAAI,eAAe,EACrC,0BAA0B,EAC1B,cAAc,IAAI,WAAW,EAC7B,sBAAsB,EACtB,eAAe,IAAI,YAAY,EAC/B,SAAS,IAAI,iBAAiB,EAC9B,OAAO,EACP,IAAI,EACJ,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,IAAI,WAAW,EAC7B,sBAAsB,EACtB,gB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AC,CAAC,CAAC,EAC5B;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAC3B,CAAA;AAED,KAAK,iCAAiC,CAAC,CAAC,SAAS,wBAAwB,IACvE,CAAC,SAAS,wBAAwB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEzD,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,IAAI,EACnD,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC3B,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CA2D9C;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,IAAI,EACrD,iBAAiB,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAC5C,yBAAyB,CAAC,CAAC,CAAC,CA2D9B"}
@@ -27,9 +27,9 @@ export declare const ListActions: {
27
27
  export declare function onKeyDown(e: KeyboardEvent, editor: Editor): void;
28
28
  export declare function withBlock(editor: Editor): import("../../slate/types").MakeswiftEditor;
29
29
  export declare function BlockPlugin(): {
30
- control: import("@makeswift/controls").RichTextPluginControl<import("@makeswift/controls").SelectDefinition<import("@makeswift/controls").SelectConfig<"blockquote" | "paragraph" | "heading-one" | "heading-two" | "heading-three" | "heading-four" | "heading-five" | "heading-six" | "ordered-list" | "unordered-list"> & {
31
- readonly defaultValue: "blockquote" | "paragraph" | "heading-one" | "heading-two" | "heading-three" | "heading-four" | "heading-five" | "heading-six" | "ordered-list" | "unordered-list";
32
- }>, "blockquote" | "paragraph" | "heading-one" | "heading-two" | "heading-three" | "heading-four" | "heading-five" | "heading-six" | "ordered-list" | "unordered-list"> | undefined;
30
+ control: import("@makeswift/controls").RichTextPluginControl<import("@makeswift/controls").SelectDefinition<import("@makeswift/controls").SelectConfig<"paragraph" | "heading-one" | "heading-two" | "heading-three" | "heading-four" | "heading-five" | "heading-six" | "blockquote" | "unordered-list" | "ordered-list"> & {
31
+ readonly defaultValue: "paragraph" | "heading-one" | "heading-two" | "heading-three" | "heading-four" | "heading-five" | "heading-six" | "blockquote" | "unordered-list" | "ordered-list";
32
+ }>, "paragraph" | "heading-one" | "heading-two" | "heading-three" | "heading-four" | "heading-five" | "heading-six" | "blockquote" | "unordered-list" | "ordered-list"> | undefined;
33
33
  withPlugin: ((editor: Editor) => Editor) | undefined;
34
34
  onKeyDown: ((event: KeyboardEvent, editor: Editor) => void) | undefined;
35
35
  renderElement: ((renderElement: RenderElement, value: any) => (props: RenderElementProps) => import("react").ReactNode) | undefined;
@@ -4,4 +4,8 @@ export declare function ElementTreesDemo({ left, right }: {
4
4
  left: ReactNode;
5
5
  right: ReactNode;
6
6
  }): import("react/jsx-runtime").JSX.Element;
7
+ export declare const SLOT_DEMO_COMPONENT_TYPE = "SlotDemo";
8
+ export declare function SlotDemo({ children }: {
9
+ children: ReactNode;
10
+ }): import("react/jsx-runtime").JSX.Element;
7
11
  //# sourceMappingURL=element-trees-demo-component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"element-trees-demo-component.d.ts","sourceRoot":"","sources":["../../../../../../src/state/modules/__tests__/fixtures/element-trees-demo-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,eAAO,MAAM,gCAAgC,SAAS,CAAA;AAEtD,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,2CAOtF"}
1
+ {"version":3,"file":"element-trees-demo-component.d.ts","sourceRoot":"","sources":["../../../../../../src/state/modules/__tests__/fixtures/element-trees-demo-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,eAAO,MAAM,gCAAgC,SAAS,CAAA;AAEtD,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,2CAOtF;AAED,eAAO,MAAM,wBAAwB,aAAa,CAAA;AAElD,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAE7D"}
@@ -1,3 +1,5 @@
1
+ import { type Operation } from 'ot-json0';
2
+ import { type ElementData } from '@makeswift/controls';
1
3
  export declare const homePage: {
2
4
  key: string;
3
5
  props: {
@@ -1781,4 +1783,9 @@ export declare const resetElementTree: {
1781
1783
  };
1782
1784
  };
1783
1785
  };
1786
+ export declare const reparentingElementTree: {
1787
+ before: ElementData;
1788
+ after: ElementData;
1789
+ op: Operation;
1790
+ };
1784
1791
  //# sourceMappingURL=element-trees.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"element-trees.d.ts","sourceRoot":"","sources":["../../../../../../src/state/modules/__tests__/fixtures/element-trees.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqR5B,CAAA;AAID,eAAO,MAAM,sBAAsB,EAAE;IACnC,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,WAAW,CAAA;IAClB,EAAE,EAAE,SAAS,CAAA;CAkUd,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/runtime",
3
- "version": "0.28.4-canary.0",
3
+ "version": "0.28.4-canary.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "url": "makeswift/makeswift",