@kaskad/component-tree 0.0.1

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 (134) hide show
  1. package/README.md +7 -0
  2. package/esm2022/index.js +12 -0
  3. package/esm2022/index.js.map +1 -0
  4. package/esm2022/kaskad-component-tree.js +5 -0
  5. package/esm2022/kaskad-component-tree.js.map +1 -0
  6. package/esm2022/lib/component-lookup/index.js +68 -0
  7. package/esm2022/lib/component-lookup/index.js.map +1 -0
  8. package/esm2022/lib/component-lookup/traverses/array-traverser.js +18 -0
  9. package/esm2022/lib/component-lookup/traverses/array-traverser.js.map +1 -0
  10. package/esm2022/lib/component-lookup/traverses/component-traverser.js +120 -0
  11. package/esm2022/lib/component-lookup/traverses/component-traverser.js.map +1 -0
  12. package/esm2022/lib/component-lookup/traverses/index.js +29 -0
  13. package/esm2022/lib/component-lookup/traverses/index.js.map +1 -0
  14. package/esm2022/lib/component-lookup/traverses/object-traverser.js +22 -0
  15. package/esm2022/lib/component-lookup/traverses/object-traverser.js.map +1 -0
  16. package/esm2022/lib/component-lookup/types.js +1 -0
  17. package/esm2022/lib/component-lookup/types.js.map +1 -0
  18. package/esm2022/lib/component-tree-api.js +121 -0
  19. package/esm2022/lib/component-tree-api.js.map +1 -0
  20. package/esm2022/lib/computation/computation-frame.js +27 -0
  21. package/esm2022/lib/computation/computation-frame.js.map +1 -0
  22. package/esm2022/lib/computation/computation-stack.js +83 -0
  23. package/esm2022/lib/computation/computation-stack.js.map +1 -0
  24. package/esm2022/lib/computation/index.js +3 -0
  25. package/esm2022/lib/computation/index.js.map +1 -0
  26. package/esm2022/lib/config.js +6 -0
  27. package/esm2022/lib/config.js.map +1 -0
  28. package/esm2022/lib/mobx/component.js +110 -0
  29. package/esm2022/lib/mobx/component.js.map +1 -0
  30. package/esm2022/lib/mobx/create-root-node.js +21 -0
  31. package/esm2022/lib/mobx/create-root-node.js.map +1 -0
  32. package/esm2022/lib/mobx/ref-space.js +25 -0
  33. package/esm2022/lib/mobx/ref-space.js.map +1 -0
  34. package/esm2022/lib/mobx/store.js +827 -0
  35. package/esm2022/lib/mobx/store.js.map +1 -0
  36. package/esm2022/lib/node/create-node-options.js +16 -0
  37. package/esm2022/lib/node/create-node-options.js.map +1 -0
  38. package/esm2022/lib/node/creators/array-creator.js +9 -0
  39. package/esm2022/lib/node/creators/array-creator.js.map +1 -0
  40. package/esm2022/lib/node/creators/command-creator.js +16 -0
  41. package/esm2022/lib/node/creators/command-creator.js.map +1 -0
  42. package/esm2022/lib/node/creators/component-creator.js +58 -0
  43. package/esm2022/lib/node/creators/component-creator.js.map +1 -0
  44. package/esm2022/lib/node/creators/leaf-creator.js +5 -0
  45. package/esm2022/lib/node/creators/leaf-creator.js.map +1 -0
  46. package/esm2022/lib/node/creators/map-creator.js +14 -0
  47. package/esm2022/lib/node/creators/map-creator.js.map +1 -0
  48. package/esm2022/lib/node/creators/object-creator.js +17 -0
  49. package/esm2022/lib/node/creators/object-creator.js.map +1 -0
  50. package/esm2022/lib/node/creators/set-creator.js +13 -0
  51. package/esm2022/lib/node/creators/set-creator.js.map +1 -0
  52. package/esm2022/lib/node/creators/shape-creator.js +15 -0
  53. package/esm2022/lib/node/creators/shape-creator.js.map +1 -0
  54. package/esm2022/lib/node/creators/variant-shape-creator.js +23 -0
  55. package/esm2022/lib/node/creators/variant-shape-creator.js.map +1 -0
  56. package/esm2022/lib/node/guards.js +5 -0
  57. package/esm2022/lib/node/guards.js.map +1 -0
  58. package/esm2022/lib/node/node-creation.js +47 -0
  59. package/esm2022/lib/node/node-creation.js.map +1 -0
  60. package/esm2022/lib/node/node-type.js +1 -0
  61. package/esm2022/lib/node/node-type.js.map +1 -0
  62. package/esm2022/lib/node/node.js +305 -0
  63. package/esm2022/lib/node/node.js.map +1 -0
  64. package/esm2022/lib/parsers/index.js +3 -0
  65. package/esm2022/lib/parsers/index.js.map +1 -0
  66. package/esm2022/lib/parsers/node-selector.types.js +1 -0
  67. package/esm2022/lib/parsers/node-selector.types.js.map +1 -0
  68. package/esm2022/lib/parsers/parse-component-selector.js +43 -0
  69. package/esm2022/lib/parsers/parse-component-selector.js.map +1 -0
  70. package/esm2022/lib/parsers/parse-node-selector.js +263 -0
  71. package/esm2022/lib/parsers/parse-node-selector.js.map +1 -0
  72. package/esm2022/lib/types/command.js +1 -0
  73. package/esm2022/lib/types/command.js.map +1 -0
  74. package/esm2022/lib/types/index.js +5 -0
  75. package/esm2022/lib/types/index.js.map +1 -0
  76. package/esm2022/lib/types/node.guards.js +7 -0
  77. package/esm2022/lib/types/node.guards.js.map +1 -0
  78. package/esm2022/lib/types/schema.js +1 -0
  79. package/esm2022/lib/types/schema.js.map +1 -0
  80. package/esm2022/lib/util/extract-node-value.js +45 -0
  81. package/esm2022/lib/util/extract-node-value.js.map +1 -0
  82. package/esm2022/lib/util/format-source.js +7 -0
  83. package/esm2022/lib/util/format-source.js.map +1 -0
  84. package/esm2022/lib/util/get-component.js +8 -0
  85. package/esm2022/lib/util/get-component.js.map +1 -0
  86. package/esm2022/lib/util/id-generator.js +10 -0
  87. package/esm2022/lib/util/id-generator.js.map +1 -0
  88. package/esm2022/lib/util/traverse-node.js +50 -0
  89. package/esm2022/lib/util/traverse-node.js.map +1 -0
  90. package/index.d.ts +11 -0
  91. package/kaskad-component-tree.d.ts +5 -0
  92. package/lib/component-lookup/index.d.ts +8 -0
  93. package/lib/component-lookup/traverses/array-traverser.d.ts +3 -0
  94. package/lib/component-lookup/traverses/component-traverser.d.ts +3 -0
  95. package/lib/component-lookup/traverses/index.d.ts +9 -0
  96. package/lib/component-lookup/traverses/object-traverser.d.ts +3 -0
  97. package/lib/component-lookup/types.d.ts +13 -0
  98. package/lib/component-tree-api.d.ts +21 -0
  99. package/lib/computation/computation-frame.d.ts +14 -0
  100. package/lib/computation/computation-stack.d.ts +48 -0
  101. package/lib/computation/index.d.ts +2 -0
  102. package/lib/config.d.ts +4 -0
  103. package/lib/mobx/component.d.ts +45 -0
  104. package/lib/mobx/create-root-node.d.ts +3 -0
  105. package/lib/mobx/ref-space.d.ts +10 -0
  106. package/lib/mobx/store.d.ts +238 -0
  107. package/lib/node/create-node-options.d.ts +12 -0
  108. package/lib/node/creators/array-creator.d.ts +4 -0
  109. package/lib/node/creators/command-creator.d.ts +4 -0
  110. package/lib/node/creators/component-creator.d.ts +4 -0
  111. package/lib/node/creators/leaf-creator.d.ts +4 -0
  112. package/lib/node/creators/map-creator.d.ts +4 -0
  113. package/lib/node/creators/object-creator.d.ts +4 -0
  114. package/lib/node/creators/set-creator.d.ts +4 -0
  115. package/lib/node/creators/shape-creator.d.ts +4 -0
  116. package/lib/node/creators/variant-shape-creator.d.ts +4 -0
  117. package/lib/node/guards.d.ts +3 -0
  118. package/lib/node/node-creation.d.ts +4 -0
  119. package/lib/node/node-type.d.ts +49 -0
  120. package/lib/node/node.d.ts +107 -0
  121. package/lib/parsers/index.d.ts +5 -0
  122. package/lib/parsers/node-selector.types.d.ts +25 -0
  123. package/lib/parsers/parse-component-selector.d.ts +8 -0
  124. package/lib/parsers/parse-node-selector.d.ts +87 -0
  125. package/lib/types/command.d.ts +3 -0
  126. package/lib/types/index.d.ts +4 -0
  127. package/lib/types/node.guards.d.ts +4 -0
  128. package/lib/types/schema.d.ts +13 -0
  129. package/lib/util/extract-node-value.d.ts +3 -0
  130. package/lib/util/format-source.d.ts +1 -0
  131. package/lib/util/get-component.d.ts +4 -0
  132. package/lib/util/id-generator.d.ts +5 -0
  133. package/lib/util/traverse-node.d.ts +26 -0
  134. package/package.json +26 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../../../libs/component-tree/src/lib/mobx/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAA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EAAE,CAAC,EAAE,CAAC;oBAClC,UAAU,GAAG,KAAK,CAAC;oBACnB,MAAM;gBACR,CAAC;YACH,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import { log } from '@kaskad/config';\nimport { unfoldNodeSchema } from '@kaskad/schema';\nimport { ComponentId, ComponentRef, NodeSchema, RefSpaceId, ValueType } from '@kaskad/types';\nimport { configure, observable, runInAction, untracked } from 'mobx';\n\nimport { findComponent, findComponents, parseComponentSelector } from '../component-lookup';\nimport { CreateNodeOptions } from '../node/create-node-options';\nimport { AbstractNode, ArrayNode } from '../node/node';\nimport { createNode } from '../node/node-creation';\nimport { parseNodeSelector } from '../parsers';\nimport { extractComponentsIds } from '../util/extract-node-value';\nimport { formatSource } from '../util/format-source';\nimport { getComponent } from '../util/get-component';\nimport { componentIdGenerator } from '../util/id-generator';\nimport { traverseNode } from '../util/traverse-node';\nimport { TComponent } from './component';\nimport { RefSpace } from './ref-space';\n\nconfigure({\n enforceActions: 'always',\n});\n\nexport class ComponentStore {\n private static instance: ComponentStore;\n\n components: Map<ComponentId, TComponent> = new Map();\n refSpaces: Map<RefSpaceId, RefSpace> = observable.map({}, { deep: false, name: 'ref-spaces-map' });\n\n componentsToPreload: Set<string> = new Set();\n\n // Index for O(m) RefSpace cleanup during component removal\n private componentsByRefSpace: Map<RefSpaceId, Set<ComponentId>> = new Map();\n\n static getInstance(): ComponentStore {\n if (!ComponentStore.instance) {\n ComponentStore.instance = new ComponentStore();\n }\n return ComponentStore.instance;\n }\n\n // tests purposes only\n static reset() {\n const store = ComponentStore.getInstance();\n runInAction(() => {\n // Remove all root components (components without parents)\n // This will cascade and remove all child components and RefSpaces\n const rootComponents = Array.from(store.components.values()).filter((c) => !c.position.componentId);\n\n for (const component of rootComponents) {\n store.removeComponent(component.id);\n }\n\n // Clear any remaining orphaned data (shouldn't be any, but just to be safe)\n store.components.clear();\n store.refSpaces.clear();\n store.componentsToPreload.clear();\n store.componentsByRefSpace.clear();\n\n componentIdGenerator.reset();\n });\n\n return store;\n }\n\n addRefSpace(refSpace: RefSpace): void {\n runInAction(() => {\n this.refSpaces.set(refSpace.id, refSpace);\n });\n }\n\n addComponents(components: Record<ComponentId, TComponent>) {\n runInAction(() => {\n for (const id in components) {\n const component = components[id];\n this.components.set(id, component);\n\n // Maintain componentsByRefSpace index\n if (!this.componentsByRefSpace.has(component.refSpaceId)) {\n this.componentsByRefSpace.set(component.refSpaceId, new Set());\n }\n this.componentsByRefSpace.get(component.refSpaceId)?.add(id);\n }\n });\n }\n\n getRefSpace(refSpaceId: RefSpaceId): RefSpace | null {\n return this.refSpaces.get(refSpaceId) ?? null;\n }\n\n getRefSpaceOrThrow(refSpaceId: RefSpaceId): RefSpace {\n const refSpace = this.getRefSpace(refSpaceId);\n if (!refSpace) {\n throw new Error(`RefSpace with id \"${refSpaceId}\" is not found.`);\n }\n\n return refSpace;\n }\n\n getComponent(componentId: string): TComponent | null {\n return this.components.get(componentId) || null;\n }\n\n getComponentOrThrow(componentId: string): TComponent {\n const component = this.getComponent(componentId);\n if (!component) {\n throw new Error(`Component with id \"${componentId}\" is not found.`);\n }\n\n return component;\n }\n\n findVariable(componentId: ComponentId, variableName: string): AbstractNode<ValueType> | null {\n const component = this.getComponentOrThrow(componentId);\n\n const node = component.variables.get(variableName);\n if (node) {\n return node;\n }\n\n const parentComponentId = component.position.componentId;\n if (!parentComponentId) {\n return null;\n }\n\n return this.findVariable(parentComponentId, variableName);\n }\n\n /**\n * Find a single component using a selector relative to another component.\n * Throws if multiple components match the selector.\n *\n * @param relativeTo - The component ID to search relative to\n * @param selector - Component selector string (e.g., 'Button', '&myRef', '^parent', ':button', 'Button[disabled=true]')\n * @returns The matching component or null if not found\n * @throws If the selector matches multiple components\n *\n * @example\n * ```typescript\n * const button = store.findComponent(componentId, 'Button');\n * const aliased = store.findComponent(componentId, '&myRef');\n * const parent = store.findComponent(componentId, '^parent');\n * const byType = store.findComponent(componentId, ':button');\n * const filtered = store.findComponent(componentId, 'Button[disabled=true]');\n * ```\n */\n findComponent(relativeTo: ComponentId, selector: string): TComponent | null {\n const parsed = parseComponentSelector(selector);\n return findComponent(relativeTo, parsed);\n }\n\n /**\n * Find all components matching a selector relative to another component.\n *\n * @param relativeTo - The component ID to search relative to\n * @param selector - Component selector string (e.g., 'Button', '&myRef', ':button', 'Button[disabled=true]')\n * @returns Array of matching components (empty if none found)\n *\n * @example\n * ```typescript\n * const buttons = store.findComponents(componentId, 'Button');\n * const allOfType = store.findComponents(componentId, ':button');\n * const filtered = store.findComponents(componentId, 'Button[disabled=true]');\n * ```\n */\n findComponents(relativeTo: ComponentId, selector: string): TComponent[] {\n const parsed = parseComponentSelector(selector);\n return findComponents(relativeTo, parsed);\n }\n\n /**\n * Get a node by selector relative to a component.\n * Throws an error if the component or node is not found.\n * Use findNode() for optional lookups that return null instead of throwing.\n *\n * Note: Even if the selector contains optional chaining (?.), this method will throw\n * if the node is not found. Use findNode() for optional chaining support.\n *\n * Component selector behavior:\n * - `&ref->value` - Throws if component with ref doesn't exist\n * - `&ref?->value` - Throws if node not found, but allows missing component (returns null for the whole expression)\n *\n * @param relativeTo - The component ID to search relative to\n * @param selector - Node selector string (e.g., 'prop', '$variable', '^Parent->prop', '&ref?->value')\n * @returns The node\n * @throws If the component or node is not found (unless using ?-> for component)\n *\n * @example\n * ```typescript\n * const node = store.getNode(componentId, 'requiredProp'); // throws if not found\n * const optionalNode = store.findNode(componentId, 'user?.profile'); // returns null if not found\n * const optionalComponent = store.getNode(componentId, '&optional?->value'); // throws only if value missing, not if component missing\n * ```\n */\n getNode<T extends AbstractNode<ValueType>>(relativeTo: ComponentId, selector: string): T {\n const parsed = parseNodeSelector(selector);\n\n // Look up the component\n let component: TComponent | null;\n\n if (parsed.component) {\n component = findComponent(relativeTo, parsed.component.selector);\n\n // If component not found and not using optional selector, throw error\n if (!component && !parsed.component.optional) {\n const src = formatSource(this.getComponent(relativeTo)?.sourceUrl);\n throw new Error(`${src} Component not found for selector '${selector}' relative to '${relativeTo}'`);\n }\n } else {\n component = this.getComponentOrThrow(relativeTo);\n }\n\n // If component is null (only possible with component.optional), throw\n if (!component) {\n const src = formatSource(this.getComponent(relativeTo)?.sourceUrl);\n throw new Error(`${src} Component not found for selector '${selector}' relative to '${relativeTo}'`);\n }\n\n const src = formatSource(component.sourceUrl);\n\n // If it's a variable path, use RefSpace chain lookup\n if (parsed.kind === 'variable') {\n const node = this.findVariable(component.id, parsed.head);\n if (!node) {\n throw new Error(\n `${src} Variable '${parsed.head}' does not exist in component '${component.id}' or its parent RefSpaces`,\n );\n }\n\n const result = traverseNode(node, parsed.tail) as T | null;\n if (!result) {\n throw new Error(`${src} Node not found for selector '${selector}' in component '${component.id}'`);\n }\n return result;\n }\n\n // For property paths, use strict lookup that throws on missing nodes\n const node = component.getNodeFromParsed(parsed) as T | null;\n if (!node) {\n throw new Error(`${src} Node not found for selector '${selector}' in component '${component.id}'`);\n }\n\n return node;\n }\n\n /**\n * Find a node by selector relative to a component.\n * Returns null if the node is not found.\n *\n * Component selector behavior:\n * - `&ref->value` - Throws if component doesn't exist (strict by default)\n * - `&ref?->value` - Returns null if component doesn't exist (lenient when explicit)\n *\n * Use `?->` to explicitly indicate that a missing component is acceptable.\n * This makes the code self-documenting and prevents accidental null returns.\n *\n * @param relativeTo - The component ID to search relative to\n * @param selector - Node selector string (e.g., 'prop', '$variable', '^Parent->prop', '&ref?->value')\n * @returns The node or null if not found\n *\n * @example\n * ```typescript\n * // Strict - throws if component missing\n * const node = store.findNode(componentId, '&ref->value');\n *\n * // Lenient - returns null if component missing\n * const optionalNode = store.findNode(componentId, '&ref?->value');\n * if (optionalNode) {\n * // Use the node\n * }\n * ```\n */\n findNode<T extends AbstractNode<ValueType>>(relativeTo: ComponentId, selector: string): T | null {\n const parsed = parseNodeSelector(selector);\n\n // If a component selector is specified, look up the component\n let component = parsed.component\n ? findComponent(relativeTo, parsed.component.selector)\n : this.getComponent(relativeTo);\n\n // If component not found and not using optional selector, throw error\n if (!component && parsed.component && !parsed.component.optional) {\n const src = formatSource(this.getComponent(relativeTo)?.sourceUrl);\n throw new Error(`${src} Component not found for selector '${selector}' relative to '${relativeTo}'`);\n }\n\n if (!component) {\n return null;\n }\n\n // If looking up a variable in a sys.Facade component (without explicit component selector),\n // start search from the facade's parent. This ensures variables are resolved from the facade's\n // context, not from within the facade itself. This only applies when using the implicit\n // relativeTo component, not when explicitly selecting a Facade (e.g., ':sys.Facade->$var')\n if (parsed.kind === 'variable' && !parsed.component && component.componentType === 'sys.Facade') {\n const parentComponentId = component.position.componentId;\n if (parentComponentId) {\n const parentComponent = this.getComponent(parentComponentId);\n // If parent exists, use it for variable lookup; otherwise fall back to the Facade itself\n if (parentComponent) {\n component = parentComponent;\n }\n }\n }\n\n const src = formatSource(component.sourceUrl);\n\n // If it's a variable path, use RefSpace chain lookup\n if (parsed.kind === 'variable') {\n const node = this.findVariable(component.id, parsed.head);\n if (!node) {\n // Variable itself doesn't exist - this is likely a typo, so throw\n throw new Error(`${src} Variable \"${parsed.head}\" not found in component \"${component.id}\"`);\n }\n\n // Variable exists, traverse the path (may return null if path is missing)\n return traverseNode(node, parsed.tail) as T;\n }\n\n // For property paths, throw if property doesn't exist but allow null paths\n const node = component.props.get(parsed.head);\n if (!node) {\n throw new Error(\n `${src} Property \"${parsed.head}\" not found in component \"${component.id}\" (type: ${component.componentType}). ` +\n `Available properties: [${Array.from(component.props.keys()).join(', ')}]`,\n );\n }\n\n // Property exists, traverse the path (may return null if path is missing)\n return traverseNode(node, parsed.tail) as T;\n }\n\n /**\n * Collect node values from multiple components into an array.\n * Maps over all components matching the selector and extracts a node value from each.\n *\n * @param relativeTo - The component ID to search relative to\n * @param componentSelector - Selector for finding components (e.g., ':forms.Input', 'Button')\n * @param nodeSelector - The node path to extract from each component (e.g., 'value', 'inputKey')\n * @returns Array of node values from matched components\n *\n * @example\n * ```typescript\n * // Get all input values\n * const values = store.collectValuesArray(componentId, ':forms.Input', 'value');\n * // Returns: ['value1', 'value2', 'value3']\n * ```\n */\n collectValuesArray<T = unknown[]>(relativeTo: ComponentId, componentSelector: string, nodeSelector: string): T {\n const components = this.findComponents(relativeTo, componentSelector);\n return components.map((component) => component.getNodeValue(nodeSelector)) as T;\n }\n\n /**\n * Collect node values from multiple components into a map/object.\n * Reduces over all components matching the selector, using one node as the key and another as the value.\n *\n * @param relativeTo - The component ID to search relative to\n * @param componentSelector - Selector for finding components (e.g., ':forms.Input', 'Button')\n * @param keyNodeSelector - The node path to use as the object key (e.g., 'inputKey', 'id')\n * @param valueNodeSelector - The node path to use as the object value (e.g., 'value', 'label')\n * @returns Object/map with keys and values from matched components\n *\n * @example\n * ```typescript\n * // Create a map from inputKey to value\n * const map = store.collectValuesMap(componentId, ':forms.Input', 'inputKey', 'value');\n * // Returns: { key1: 'value1', key2: 'value2' }\n * ```\n */\n collectValuesMap<T = Record<string, unknown>>(\n relativeTo: ComponentId,\n componentSelector: string,\n keyNodeSelector: string,\n valueNodeSelector: string,\n ): T {\n const components = this.findComponents(relativeTo, componentSelector);\n return components.reduce<Record<string, unknown>>((acc, component) => {\n const key = component.getNodeValue(keyNodeSelector);\n const value = component.getNodeValue(valueNodeSelector);\n\n // skip if the key is not defined\n if (key) {\n acc[key as string] = value;\n }\n return acc;\n }, {}) as T;\n }\n\n /**\n * Set a node from a raw schema value.\n * The raw schema will be unfolded before being applied.\n * Handles structure, computation stack, and nested components.\n *\n * @param node - The node to update\n * @param rawSchema - The raw schema value (will be unfolded into a NodeSchema)\n */\n setNodeRawSchema(node: AbstractNode<ValueType>, rawSchema: unknown): void {\n try {\n const unfolded = unfoldNodeSchema(rawSchema, node.valueType);\n this.setNodeSchema(node, unfolded);\n } catch (e) {\n const component = getComponent(node);\n const src = formatSource(component.sourceUrl, node.position.path);\n throw new Error(`${src} ${(e as Error).message}`, { cause: e });\n }\n }\n\n /**\n * Set a node from an already-unfolded schema.\n * Use this when you already have a NodeSchema to avoid double-unfolding.\n * Handles structure, nested components, and computation stack.\n *\n * @param node - The node to update\n * @param schema - The unfolded NodeSchema to set\n */\n setNodeSchema(node: AbstractNode<ValueType>, schema: NodeSchema): void {\n const component = getComponent(node);\n const refSpace = this.getRefSpaceOrThrow(component.refSpaceId);\n\n const opts: CreateNodeOptions = {\n refSpaceId: refSpace.id,\n position: { componentId: component.id, path: node.position.path },\n components: {},\n refs: {},\n sourceUrl: component.sourceUrl ?? undefined,\n };\n\n const tmpNode = createNode(schema, opts);\n\n runInAction(() => {\n // Handle component removal for component-type nodes\n // Only remove components that are in the old structure but NOT in the new structure\n // This is important for component[] types where existing component IDs may be reused\n const oldComponents = extractComponentsIds(node);\n const newComponents = new Set(extractComponentsIds(tmpNode));\n\n for (const id of oldComponents) {\n if (!newComponents.has(id)) {\n this.removeComponent(id);\n }\n }\n\n // Set new structure and register new components/refs\n node.structure = tmpNode.structure;\n\n // Add refs for all RefSpaces (parent RefSpace and any nested RefSpaces created)\n for (const refSpaceId in opts.refs) {\n const targetRefSpace = this.getRefSpace(refSpaceId);\n if (targetRefSpace) {\n const refs = (opts.refs[refSpaceId] as unknown as Record<ComponentRef, ComponentId> | undefined) ?? {};\n targetRefSpace.addRefs(refs);\n }\n }\n\n this.addComponents(opts.components);\n });\n\n // Push computation frame onto stack (after runAction, before activation)\n if (schema.computation) {\n const resultFrame = tmpNode.computationStack.top;\n if (resultFrame) {\n node.computationStack.push(resultFrame.schema);\n }\n }\n }\n\n /**\n * Remove an item from an array node.\n * Handles cleanup of nested components in the removed item.\n *\n * @param arrayNode - The array node to remove from\n * @param index - The index of the item to remove\n */\n removeArrayItem(arrayNode: ArrayNode, index: number): void {\n runInAction(() => {\n const value = arrayNode.structure || [];\n const removedItem = value[index];\n\n // Clean up components in the removed item\n if (removedItem) {\n const oldComponents = extractComponentsIds(removedItem);\n for (const id of oldComponents) {\n this.removeComponent(id);\n }\n }\n\n arrayNode.structure = [...value.slice(0, index), ...value.slice(index + 1)];\n });\n }\n\n /**\n * Insert an item into an array node at a specific index.\n * Creates a node structure from the raw value and inserts it at the specified position.\n * Shifts existing items to the right.\n *\n * @param arrayNode - The array node to insert into\n * @param index - The index at which to insert the item\n * @param value - The raw value to insert (will be transformed into a node structure)\n */\n insertArrayItem(arrayNode: ArrayNode, index: number, value: unknown): void {\n const { itemNode, opts, refSpace } = this.createArrayItemNode(arrayNode, index, value);\n\n runInAction(() => {\n const currentValue = arrayNode.structure || [];\n arrayNode.structure = [...currentValue.slice(0, index), itemNode, ...currentValue.slice(index)];\n const refs = (opts.refs[refSpace.id] as unknown as Record<ComponentRef, ComponentId> | undefined) ?? {};\n refSpace.addRefs(refs);\n this.addComponents(opts.components);\n });\n }\n\n /**\n * Replace an item in an array node at a specific index.\n * Creates a node structure from the raw value and replaces the item at the specified position.\n * Properly cleans up nested components in the replaced item.\n *\n * @param arrayNode - The array node containing the item to replace\n * @param index - The index of the item to replace\n * @param value - The raw value to set (will be transformed into a node structure)\n */\n replaceArrayItem(arrayNode: ArrayNode, index: number, value: unknown): void {\n const { itemNode, opts, refSpace } = this.createArrayItemNode(arrayNode, index, value);\n\n runInAction(() => {\n const currentValue = arrayNode.structure || [];\n const replacedItem = currentValue[index];\n\n // Clean up components in the replaced item\n if (replacedItem) {\n const oldComponents = extractComponentsIds(replacedItem);\n for (const id of oldComponents) {\n this.removeComponent(id);\n }\n }\n\n arrayNode.structure = [...currentValue.slice(0, index), itemNode, ...currentValue.slice(index + 1)];\n const refs = (opts.refs[refSpace.id] as unknown as Record<ComponentRef, ComponentId> | undefined) ?? {};\n refSpace.addRefs(refs);\n this.addComponents(opts.components);\n });\n }\n\n /**\n * Append an item to the end of an array node.\n * Creates a node structure from the raw value and appends it to the array.\n *\n * @param arrayNode - The array node to append to\n * @param value - The raw value to append (will be transformed into a node structure)\n */\n appendArrayItem(arrayNode: ArrayNode, value: unknown): void {\n // Calculate the index for the new item\n const currentLength = arrayNode.structure?.length ?? 0;\n const { itemNode, opts, refSpace } = this.createArrayItemNode(arrayNode, currentLength, value);\n\n runInAction(() => {\n arrayNode.structure = [...(arrayNode.structure ?? []), itemNode];\n const refs = (opts.refs[refSpace.id] as unknown as Record<ComponentRef, ComponentId> | undefined) ?? {};\n refSpace.addRefs(refs);\n this.addComponents(opts.components);\n });\n }\n\n /**\n * Reconcile for-loop children using key-based diffing.\n * Instead of destroying all children and recreating them,\n * this method compares old vs new keys and only creates/destroys what's necessary.\n *\n * @param arrayNode - The array node containing for-loop children\n * @param newSchemas - The new schemas to reconcile\n * @returns Indices of newly added items for activation\n */\n reconcileForLoopChildren(arrayNode: ArrayNode, newSchemas: unknown[]): number[] {\n const oldChildren = arrayNode.structure || [];\n\n // Handle null/undefined newSchemas\n if (!newSchemas) {\n this.setNodeRawSchema(arrayNode, []);\n return [];\n }\n\n // If there are no old children, just set the new schemas\n if (oldChildren.length === 0) {\n this.setNodeRawSchema(arrayNode, newSchemas);\n return newSchemas.map((_, index) => index);\n }\n\n // If there are no new schemas, just set empty array (will remove all)\n if (newSchemas.length === 0) {\n this.setNodeRawSchema(arrayNode, []);\n return [];\n }\n\n // Check if explicit keys are provided (trackBy syntax)\n const hasExplicitKeys = this.checkForExplicitKeys(newSchemas);\n if (!hasExplicitKeys) {\n // No explicit keys - fall back to full replacement\n this.setNodeRawSchema(arrayNode, newSchemas);\n return newSchemas.map((_, index) => index);\n }\n\n // Extract keys from old children and new schemas\n const oldKeyMap = this.extractOldKeys(oldChildren);\n const newKeys = this.extractNewKeys(newSchemas);\n\n // Check for duplicate keys in new schemas\n const duplicateKeys = this.findDuplicateKeys(newKeys);\n if (duplicateKeys.size > 0) {\n log.warn(\n `Duplicate keys detected in for-loop: ${Array.from(duplicateKeys).join(', ')}. ` +\n 'This may cause unexpected behavior. Falling back to full replacement.',\n );\n this.setNodeRawSchema(arrayNode, newSchemas);\n return newSchemas.map((_, index) => index);\n }\n\n // Build sets for diffing\n const oldKeySet = new Set(oldKeyMap.keys());\n const newKeySet = new Set(newKeys);\n\n // Determine what to add, remove, and keep\n const toRemove: string[] = [];\n const toKeepSet = new Set<string>();\n\n for (const key of oldKeySet) {\n if (newKeySet.has(key)) {\n toKeepSet.add(key);\n } else {\n toRemove.push(key);\n }\n }\n\n const toAdd: number[] = [];\n newKeys.forEach((key, index) => {\n if (!oldKeySet.has(key)) {\n toAdd.push(index);\n }\n });\n\n // Perform the actual reconciliation\n this.applyForLoopReconciliation(arrayNode, {\n oldKeyMap,\n newKeys,\n newSchemas,\n toRemove,\n toKeep: Array.from(toKeepSet),\n });\n\n // Update loop variables (index, first, last, and item variables) for repositioned components\n this.updateLoopVariables(arrayNode, newKeys, newSchemas, oldKeyMap);\n\n return toAdd;\n }\n\n /**\n * Apply for-loop reconciliation by building new structure and cleaning up removed components.\n */\n private applyForLoopReconciliation(\n arrayNode: ArrayNode,\n reconcileInfo: {\n oldKeyMap: Map<string, { index: number; componentId: ComponentId }>;\n newKeys: string[];\n newSchemas: unknown[];\n toRemove: string[];\n toKeep: string[];\n },\n ): void {\n const { oldKeyMap, newKeys, newSchemas, toRemove, toKeep } = reconcileInfo;\n const toKeepSet = new Set(toKeep);\n\n const component = getComponent(arrayNode);\n const refSpace = this.getRefSpaceOrThrow(component.refSpaceId);\n\n // Build the new structure array, reusing kept nodes and creating new ones\n const newStructure: AbstractNode<ValueType>[] = [];\n const newComponents: Record<ComponentId, TComponent> = {};\n const newRefs: Record<ComponentRef, ComponentId> = {};\n\n // Build new structure in order of new keys\n // Use untracked to avoid MobX reactivity issues when reading structure\n const oldStructure = untracked(() => arrayNode.structure);\n for (let i = 0; i < newKeys.length; i++) {\n const key = newKeys[i];\n const oldEntry = oldKeyMap.get(key);\n\n if (oldEntry && toKeepSet.has(key) && oldStructure && oldStructure[oldEntry.index]) {\n // Reuse existing node\n newStructure.push(oldStructure[oldEntry.index]);\n } else {\n // Create new node\n const schema = newSchemas[i];\n const itemPath = [...arrayNode.position.path, i];\n\n const opts: CreateNodeOptions = {\n refSpaceId: refSpace.id,\n position: { componentId: component.id, path: itemPath },\n components: {},\n refs: {},\n sourceUrl: component.sourceUrl ?? undefined,\n };\n\n const itemNode = createNode(unfoldNodeSchema(schema, arrayNode.valueType.item), opts);\n newStructure.push(itemNode);\n\n // Collect new components and refs\n Object.assign(newComponents, opts.components);\n const itemRefs = (opts.refs[refSpace.id] as unknown as Record<ComponentRef, ComponentId> | undefined) ?? {};\n Object.assign(newRefs, itemRefs);\n }\n }\n\n runInAction(() => {\n // Remove components that are no longer needed\n for (const key of toRemove) {\n const entry = oldKeyMap.get(key);\n if (entry) {\n this.removeComponent(entry.componentId);\n }\n }\n\n // Update the structure\n arrayNode.structure = newStructure;\n\n // Register new refs and components\n refSpace.addRefs(newRefs);\n this.addComponents(newComponents);\n });\n }\n\n /**\n * Update loop variables (including item variable) on components that have been repositioned or whose data changed.\n */\n private updateLoopVariables(\n node: ArrayNode,\n newKeys: string[],\n newSchemas: unknown[],\n oldKeyMap: Map<string, { index: number; componentId: ComponentId }>,\n ): void {\n const structure = node.structure || [];\n const totalItems = newKeys.length;\n\n runInAction(() => {\n newKeys.forEach((key, newIndex) => {\n const oldEntry = oldKeyMap.get(key);\n if (!oldEntry) return; // Skip newly added items\n\n const child = structure[newIndex];\n if (!child) return;\n\n const componentId = child.structure as ComponentId | null;\n if (!componentId) return;\n\n const component = this.getComponent(componentId);\n if (!component) return;\n\n // Update $index variable if it exists and the index changed\n // Variables are stored without the $ prefix (e.g., 'index' not '$index')\n const indexNode = component.variables.get('index');\n if (indexNode && oldEntry.index !== newIndex) {\n indexNode.structure = newIndex;\n }\n\n // Update $first variable if it exists\n const firstNode = component.variables.get('first');\n if (firstNode) {\n const wasFirst = oldEntry.index === 0;\n const isFirst = newIndex === 0;\n if (wasFirst !== isFirst) {\n firstNode.structure = isFirst;\n }\n }\n\n // Update $last variable if it exists\n const lastNode = component.variables.get('last');\n if (lastNode) {\n lastNode.structure = newIndex === totalItems - 1;\n }\n\n // Update item variables from new schema\n const newSchema = newSchemas[newIndex] as Record<string, unknown>;\n for (const [schemaKey, schemaValue] of Object.entries(newSchema)) {\n if (!schemaKey.startsWith('$')) continue;\n\n const varName = schemaKey.slice(1); // Remove '$' prefix\n\n // Skip loop control variables (already handled above)\n if (varName === 'index' || varName === 'first' || varName === 'last' || varName === 'trackBy') {\n continue;\n }\n\n const varNode = component.variables.get(varName);\n if (!varNode) continue;\n\n const varDef = schemaValue as { _value?: unknown } | undefined;\n if (!varDef || !('_value' in varDef)) continue;\n\n // Update item variable using setNodeRawSchema for proper object handling\n this.setNodeRawSchema(varNode, varDef._value);\n }\n });\n });\n }\n\n /**\n * Check if schemas have explicit trackBy keys that can be used for diffing.\n */\n private checkForExplicitKeys(schemas: unknown[]): boolean {\n if (schemas.length === 0) return false;\n\n const firstSchema = schemas[0] as Record<string, unknown> | undefined;\n if (!firstSchema) return false;\n\n const forKeySchema = firstSchema['$trackBy'] as { _value: unknown } | undefined;\n\n if (forKeySchema && '_value' in forKeySchema) {\n const value = forKeySchema._value;\n if (typeof value === 'number') {\n return false;\n }\n if (typeof value === 'string') {\n const indexPattern = /^\\d+(?::\\d+)*$/;\n return !indexPattern.test(value);\n }\n return true;\n }\n\n return false;\n }\n\n /**\n * Extract keys from existing children (RefSpace components with $trackBy variable)\n */\n private extractOldKeys(\n children: AbstractNode<ValueType>[],\n ): Map<string, { index: number; componentId: ComponentId }> {\n const keyMap = new Map<string, { index: number; componentId: ComponentId }>();\n\n children.forEach((child, index) => {\n const componentId = child.structure as ComponentId | null;\n if (!componentId) return;\n\n const component = this.getComponent(componentId);\n if (!component || component.componentType !== 'sys.RefSpace') return;\n\n const keyNode = component.variables.get('trackBy');\n const key = keyNode ? keyNode.extractedValue : component.id;\n keyMap.set(String(key), { index, componentId });\n });\n\n return keyMap;\n }\n\n /**\n * Extract keys from new schemas (generated by repeat())\n */\n private extractNewKeys(schemas: unknown[]): string[] {\n return schemas.map((schema, index) => {\n const forKeyValue = (schema as Record<string, unknown>)['$trackBy'] as { _value: unknown } | undefined;\n\n if (forKeyValue && '_value' in forKeyValue) {\n return String(forKeyValue._value);\n }\n\n return String(index);\n });\n }\n\n /**\n * Find duplicate keys in an array\n */\n private findDuplicateKeys(keys: string[]): Set<string> {\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n\n for (const key of keys) {\n if (seen.has(key)) {\n duplicates.add(key);\n }\n seen.add(key);\n }\n\n return duplicates;\n }\n\n removeComponent(componentId: ComponentId): void {\n const component = this.components.get(componentId);\n if (!component) return;\n\n runInAction(() => {\n // Collect all nested child component IDs (depth-first traversal)\n const allChildIds: ComponentId[] = [];\n for (const [, propNode] of component.props) {\n extractComponentsIds(propNode, allChildIds);\n }\n for (const [, varNode] of component.variables) {\n extractComponentsIds(varNode, allChildIds);\n }\n\n // Deduplicate while preserving order (later items are deeper in tree)\n const childIds = [...new Set(allChildIds)];\n const allIds = new Set([componentId, ...childIds]);\n\n const spacesToRemove = this.collectRefSpacesToRemove(allIds);\n\n // Dispose components in leaf-first order (reverse of depth-first)\n for (let i = childIds.length - 1; i >= 0; i--) {\n this.components.get(childIds[i])?.dispose();\n }\n component.dispose();\n\n // Finally, delete all components and RefSpaces from registries\n for (const id of allIds) {\n // Remove from componentsByRefSpace index\n const comp = this.components.get(id);\n if (comp) {\n this.componentsByRefSpace.get(comp.refSpaceId)?.delete(id);\n }\n this.components.delete(id);\n }\n for (const refSpaceId of spacesToRemove) {\n this.refSpaces.delete(refSpaceId);\n // Clean up empty index entries\n this.componentsByRefSpace.delete(refSpaceId);\n }\n });\n }\n\n /**\n * Creates a new node for an array item from a raw value.\n * Returns the created node and the options used (for registering components/refs).\n * @throws If the array node has no parent component\n */\n private createArrayItemNode(\n arrayNode: ArrayNode,\n index: number,\n value: unknown,\n ): { itemNode: AbstractNode<ValueType>; opts: CreateNodeOptions; refSpace: RefSpace } {\n const component = getComponent(arrayNode);\n const refSpace = this.getRefSpaceOrThrow(component.refSpaceId);\n\n const itemPath = [...arrayNode.position.path, index];\n\n const opts: CreateNodeOptions = {\n refSpaceId: refSpace.id,\n position: { componentId: component.position.componentId, path: itemPath },\n components: {},\n refs: {},\n sourceUrl: component.sourceUrl ?? undefined,\n };\n\n const itemNode = createNode(unfoldNodeSchema(value, arrayNode.valueType.item), opts);\n\n return { itemNode, opts, refSpace };\n }\n\n private collectRefSpacesToRemove(componentIdsToDelete: Set<ComponentId>): Set<RefSpaceId> {\n // Collect unique RefSpace IDs that components belong to (candidates for removal)\n const candidateSpaceIds = new Set<RefSpaceId>();\n for (const componentId of componentIdsToDelete) {\n const refSpaceId = this.components.get(componentId)?.refSpaceId;\n if (refSpaceId) {\n candidateSpaceIds.add(refSpaceId);\n }\n }\n\n // Filter to only RefSpaces that have no remaining components after deletion\n const refSpaceIdsToDelete = new Set<RefSpaceId>();\n for (const refSpaceId of candidateSpaceIds) {\n const componentsInSpace = this.componentsByRefSpace.get(refSpaceId);\n if (!componentsInSpace) continue;\n\n // Check if ALL components in this RefSpace are being deleted\n let allDeleted = true;\n for (const id of componentsInSpace) {\n if (!componentIdsToDelete.has(id)) {\n allDeleted = false;\n break;\n }\n }\n\n if (allDeleted) {\n refSpaceIdsToDelete.add(refSpaceId);\n }\n }\n\n return refSpaceIdsToDelete;\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ export function withPath(opts, newPath) {
2
+ return {
3
+ ...opts,
4
+ position: { componentId: opts.position.componentId, path: newPath },
5
+ };
6
+ }
7
+ export function withPosition(opts, componentId, path) {
8
+ return {
9
+ ...opts,
10
+ position: { componentId, path },
11
+ };
12
+ }
13
+ export function appendPath(opts, ...segments) {
14
+ return withPath(opts, [...opts.position.path, ...segments]);
15
+ }
16
+ //# sourceMappingURL=create-node-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-node-options.js","sourceRoot":"","sources":["../../../../../../libs/component-tree/src/lib/node/create-node-options.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,QAAQ,CAAC,IAAuB,EAAE,OAAiB;IACjE,OAAO;QACL,GAAG,IAAI;QACP,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE;KACpE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,IAAuB,EACvB,WAA+B,EAC/B,IAAc;IAEd,OAAO;QACL,GAAG,IAAI;QACP,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAuB,EAAE,GAAG,QAA6B;IAClF,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import { ComponentId, ComponentRef, NodePath, NodePosition, RefSpaceId } from '@kaskad/types';\n\nimport { TComponent } from '../mobx/component';\n\nexport interface CreateNodeOptions {\n readonly refSpaceId: RefSpaceId;\n readonly position: NodePosition;\n readonly components: Record<ComponentId, TComponent>;\n readonly refs: Record<RefSpaceId, Record<ComponentRef, ComponentId>>;\n readonly sourceUrl?: string;\n}\n\nexport function withPath(opts: CreateNodeOptions, newPath: NodePath): CreateNodeOptions {\n return {\n ...opts,\n position: { componentId: opts.position.componentId, path: newPath },\n };\n}\n\nexport function withPosition(\n opts: CreateNodeOptions,\n componentId: ComponentId | null,\n path: NodePath,\n): CreateNodeOptions {\n return {\n ...opts,\n position: { componentId, path },\n };\n}\n\nexport function appendPath(opts: CreateNodeOptions, ...segments: (string | number)[]): CreateNodeOptions {\n return withPath(opts, [...opts.position.path, ...segments]);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { appendPath } from '../create-node-options';
2
+ import { ArrayNode } from '../node';
3
+ import { createNode } from '../node-creation';
4
+ export function createArrayNode(schema, opts) {
5
+ // TODO: set empty array on unfolding ?
6
+ const value = (schema.value || []).map((item, index) => createNode(item, appendPath(opts, index)));
7
+ return new ArrayNode(schema.valueType, value, opts.position);
8
+ }
9
+ //# sourceMappingURL=array-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/array-creator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAqB,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,eAAe,CAAC,MAAuB,EAAE,IAAuB;IAC9E,uCAAuC;IACvC,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnG,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import { ArrayNodeSchema } from '@kaskad/types';\n\nimport { appendPath, CreateNodeOptions } from '../create-node-options';\nimport { ArrayNode } from '../node';\nimport { createNode } from '../node-creation';\n\nexport function createArrayNode(schema: ArrayNodeSchema, opts: CreateNodeOptions): ArrayNode {\n // TODO: set empty array on unfolding ?\n const value = (schema.value || []).map((item, index) => createNode(item, appendPath(opts, index)));\n\n return new ArrayNode(schema.valueType, value, opts.position);\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { isObject } from '@kaskad/schema';
2
+ import { CommandNode } from '../node';
3
+ export function createCommandNode(schema, opts) {
4
+ if (!opts.position.componentId) {
5
+ throw new Error(`componentId is required for command.`);
6
+ }
7
+ if (!isObject(schema.value)) {
8
+ return new CommandNode(schema.valueType, null, opts.position);
9
+ }
10
+ const structure = { ...schema.value }; // Clone the value to avoid mutation
11
+ if (!structure.owner) {
12
+ structure.owner = opts.position.componentId;
13
+ }
14
+ return new CommandNode(schema.valueType, structure, opts.position);
15
+ }
16
+ //# sourceMappingURL=command-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/command-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,UAAU,iBAAiB,CAAC,MAAyB,EAAE,IAAuB;IAClF,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,oCAAoC;IAE3E,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrB,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC9C,CAAC;IAED,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,SAAiC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC7F,CAAC","sourcesContent":["import { isObject } from '@kaskad/schema';\nimport { CommandNodeSchema } from '@kaskad/types';\n\nimport { CommandNodeStructure } from '../../types';\nimport { CreateNodeOptions } from '../create-node-options';\nimport { CommandNode } from '../node';\n\nexport function createCommandNode(schema: CommandNodeSchema, opts: CreateNodeOptions): CommandNode {\n if (!opts.position.componentId) {\n throw new Error(`componentId is required for command.`);\n }\n\n if (!isObject(schema.value)) {\n return new CommandNode(schema.valueType, null, opts.position);\n }\n\n const structure = { ...schema.value }; // Clone the value to avoid mutation\n\n if (!structure.owner) {\n structure.owner = opts.position.componentId;\n }\n\n return new CommandNode(schema.valueType, structure as CommandNodeStructure, opts.position);\n}\n"]}
@@ -0,0 +1,58 @@
1
+ import { TComponent } from '../../mobx/component';
2
+ import { RefSpace } from '../../mobx/ref-space';
3
+ import { ComponentStore } from '../../mobx/store';
4
+ import { componentIdGenerator } from '../../util/id-generator';
5
+ import { withPosition } from '../create-node-options';
6
+ import { LeafNode } from '../node';
7
+ import { createNode } from '../node-creation';
8
+ export function createComponentNode(schema, opts) {
9
+ const componentSchema = schema.value;
10
+ if (!componentSchema || typeof componentSchema === 'string') {
11
+ return new LeafNode(schema.valueType, componentSchema, opts.position);
12
+ }
13
+ if (componentSchema.ref && opts.refs[opts.refSpaceId]?.[componentSchema.ref]) {
14
+ throw new Error(`Duplicated ref "${componentSchema.ref}".`);
15
+ }
16
+ const id = componentIdGenerator.generateId();
17
+ const isFacade = componentSchema.componentType === 'sys.Facade';
18
+ const isRefSpace = componentSchema.componentType === 'sys.RefSpace';
19
+ const needsContentSpace = isFacade || isRefSpace;
20
+ const contentSpaceId = isFacade ? `${id}-template` : isRefSpace ? `${id}-instance` : opts.refSpaceId;
21
+ const props = new Map();
22
+ for (const [key, propSchema] of componentSchema.props.entries()) {
23
+ // 'content' prop uses isolated RefSpace
24
+ const propOpts = needsContentSpace && key === 'content' ? { ...opts, refSpaceId: contentSpaceId } : opts;
25
+ props.set(key, createNode(propSchema, withPosition(propOpts, id, [key])));
26
+ }
27
+ const variables = new Map();
28
+ for (const [key, variableSchema] of componentSchema.variables.entries()) {
29
+ variables.set(key, createNode(variableSchema, withPosition(opts, id, [key])));
30
+ }
31
+ const onNodeChange = componentSchema.onNodeChange.map((handler) => ({
32
+ ...handler,
33
+ command: createNode(handler.command, withPosition(opts, id, [handler.selector])),
34
+ }));
35
+ opts.components[id] = new TComponent({
36
+ id,
37
+ componentType: componentSchema.componentType,
38
+ props,
39
+ variables,
40
+ onNodeChange,
41
+ position: opts.position,
42
+ refSpaceId: isFacade ? opts.refSpaceId : contentSpaceId,
43
+ sourceUrl: opts.sourceUrl,
44
+ });
45
+ if (componentSchema.ref) {
46
+ opts.refs[opts.refSpaceId] ??= {};
47
+ opts.refs[opts.refSpaceId][componentSchema.ref] = id;
48
+ }
49
+ if (needsContentSpace) {
50
+ const refSpace = new RefSpace(contentSpaceId, opts.refSpaceId);
51
+ ComponentStore.getInstance().addRefSpace(refSpace);
52
+ if (opts.refs[contentSpaceId]) {
53
+ refSpace.addRefs(opts.refs[contentSpaceId]);
54
+ }
55
+ }
56
+ return new LeafNode({ type: 'component' }, id, opts.position);
57
+ }
58
+ //# sourceMappingURL=component-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/component-creator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAqB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAA6B,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,mBAAmB,CACjC,MAA2B,EAC3B,IAAuB;IAEvB,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;IAErC,IAAI,CAAC,eAAe,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC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C;QAC/D,cAAc,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAEnD,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YAC9B,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO,IAAI,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { ComponentNodeSchema, ComponentValueType, ValueType } from '@kaskad/types';\n\nimport { TComponent } from '../../mobx/component';\nimport { RefSpace } from '../../mobx/ref-space';\nimport { ComponentStore } from '../../mobx/store';\nimport { NodeChangeHandler } from '../../types';\nimport { componentIdGenerator } from '../../util/id-generator';\nimport { CreateNodeOptions, withPosition } from '../create-node-options';\nimport { AbstractNode, CommandNode, LeafNode } from '../node';\nimport { createNode } from '../node-creation';\n\nexport function createComponentNode(\n schema: ComponentNodeSchema,\n opts: CreateNodeOptions,\n): LeafNode<ComponentValueType> {\n const componentSchema = schema.value;\n\n if (!componentSchema || typeof componentSchema === 'string') {\n return new LeafNode(schema.valueType, componentSchema, opts.position);\n }\n\n if (componentSchema.ref && opts.refs[opts.refSpaceId]?.[componentSchema.ref]) {\n throw new Error(`Duplicated ref \"${componentSchema.ref}\".`);\n }\n\n const id = componentIdGenerator.generateId();\n\n const isFacade = componentSchema.componentType === 'sys.Facade';\n const isRefSpace = componentSchema.componentType === 'sys.RefSpace';\n const needsContentSpace = isFacade || isRefSpace;\n const contentSpaceId = isFacade ? `${id}-template` : isRefSpace ? `${id}-instance` : opts.refSpaceId;\n\n const props = new Map<string, AbstractNode<ValueType>>();\n for (const [key, propSchema] of componentSchema.props.entries()) {\n // 'content' prop uses isolated RefSpace\n const propOpts = needsContentSpace && key === 'content' ? { ...opts, refSpaceId: contentSpaceId } : opts;\n props.set(key, createNode(propSchema, withPosition(propOpts, id, [key])));\n }\n\n const variables = new Map<string, AbstractNode<ValueType>>();\n for (const [key, variableSchema] of componentSchema.variables.entries()) {\n variables.set(key, createNode(variableSchema, withPosition(opts, id, [key])));\n }\n\n const onNodeChange = componentSchema.onNodeChange.map((handler) => ({\n ...handler,\n command: createNode(handler.command, withPosition(opts, id, [handler.selector])) as CommandNode,\n })) as NodeChangeHandler[];\n\n opts.components[id] = new TComponent({\n id,\n componentType: componentSchema.componentType,\n props,\n variables,\n onNodeChange,\n position: opts.position,\n refSpaceId: isFacade ? opts.refSpaceId : contentSpaceId,\n sourceUrl: opts.sourceUrl,\n });\n\n if (componentSchema.ref) {\n opts.refs[opts.refSpaceId] ??= {};\n opts.refs[opts.refSpaceId][componentSchema.ref] = id;\n }\n\n if (needsContentSpace) {\n const refSpace = new RefSpace(contentSpaceId, opts.refSpaceId);\n ComponentStore.getInstance().addRefSpace(refSpace);\n\n if (opts.refs[contentSpaceId]) {\n refSpace.addRefs(opts.refs[contentSpaceId]);\n }\n }\n\n return new LeafNode({ type: 'component' }, id, opts.position);\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { LeafNode } from '../node';
2
+ export function createLeafNode(schema, opts) {
3
+ return new LeafNode(schema.valueType, schema.value, opts.position);
4
+ }
5
+ //# sourceMappingURL=leaf-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaf-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/leaf-creator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,UAAU,cAAc,CAAC,MAAsB,EAAE,IAAuB;IAC5E,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAA4B,CAAC;AAChG,CAAC","sourcesContent":["import { LeafNodeSchema, ValueType } from '@kaskad/types';\n\nimport { CreateNodeOptions } from '../create-node-options';\nimport { AbstractNode, LeafNode } from '../node';\n\nexport function createLeafNode(schema: LeafNodeSchema, opts: CreateNodeOptions) {\n return new LeafNode(schema.valueType, schema.value, opts.position) as AbstractNode<ValueType>;\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { appendPath } from '../create-node-options';
2
+ import { MapNode } from '../node';
3
+ import { createNode } from '../node-creation';
4
+ export function createMapNode(schema, opts) {
5
+ if (!schema.value) {
6
+ return new MapNode(schema.valueType, null, opts.position);
7
+ }
8
+ const children = {};
9
+ for (const key in schema.value) {
10
+ children[key] = createNode(schema.value[key], appendPath(opts, key));
11
+ }
12
+ return new MapNode(schema.valueType, children, opts.position);
13
+ }
14
+ //# sourceMappingURL=map-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/map-creator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAqB,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAgB,OAAO,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,aAAa,CAAC,MAAqB,EAAE,IAAuB;IAC1E,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,QAAQ,GAA4C,EAAE,CAAC;IAC7D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/B,QAAQ,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { MapNodeSchema, ValueType } from '@kaskad/types';\n\nimport { appendPath, CreateNodeOptions } from '../create-node-options';\nimport { AbstractNode, MapNode } from '../node';\nimport { createNode } from '../node-creation';\n\nexport function createMapNode(schema: MapNodeSchema, opts: CreateNodeOptions): MapNode {\n if (!schema.value) {\n return new MapNode(schema.valueType, null, opts.position);\n }\n\n const children: Record<string, AbstractNode<ValueType>> = {};\n for (const key in schema.value) {\n children[key] = createNode(schema.value[key], appendPath(opts, key));\n }\n\n return new MapNode(schema.valueType, children, opts.position);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { appendPath } from '../create-node-options';
2
+ import { ObjectNode } from '../node';
3
+ import { createNode } from '../node-creation';
4
+ export function createObjectNode(schema, opts) {
5
+ if (!schema.value) {
6
+ return new ObjectNode(schema.valueType, null, opts.position);
7
+ }
8
+ if (!Object.keys(schema.valueType).length) {
9
+ return new ObjectNode(schema.valueType, null, opts.position);
10
+ }
11
+ const fields = {};
12
+ for (const key in schema.value) {
13
+ fields[key] = createNode(schema.value[key], appendPath(opts, key));
14
+ }
15
+ return new ObjectNode(schema.valueType, fields, opts.position);
16
+ }
17
+ //# sourceMappingURL=object-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/object-creator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAqB,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAgB,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,gBAAgB,CAAC,MAAwB,EAAE,IAAuB;IAChF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1C,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { ObjectNodeSchema, ValueType } from '@kaskad/types';\n\nimport { appendPath, CreateNodeOptions } from '../create-node-options';\nimport { AbstractNode, ObjectNode } from '../node';\nimport { createNode } from '../node-creation';\n\nexport function createObjectNode(schema: ObjectNodeSchema, opts: CreateNodeOptions): ObjectNode {\n if (!schema.value) {\n return new ObjectNode(schema.valueType, null, opts.position);\n }\n\n if (!Object.keys(schema.valueType).length) {\n return new ObjectNode(schema.valueType, null, opts.position);\n }\n\n const fields: Record<string, AbstractNode<ValueType>> = {};\n for (const key in schema.value) {\n fields[key] = createNode(schema.value[key], appendPath(opts, key));\n }\n\n return new ObjectNode(schema.valueType, fields, opts.position);\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { appendPath } from '../create-node-options';
2
+ import { SetNode } from '../node';
3
+ import { createNode } from '../node-creation';
4
+ export function createSetNode(schema, opts) {
5
+ if (!schema.value) {
6
+ return new SetNode(schema.valueType, null, opts.position);
7
+ }
8
+ // Convert array to Set of nodes
9
+ const items = schema.value.map((item, index) => createNode(item, appendPath(opts, index)));
10
+ const value = new Set(items);
11
+ return new SetNode(schema.valueType, value, opts.position);
12
+ }
13
+ //# sourceMappingURL=set-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/set-creator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAqB,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,aAAa,CAAC,MAAqB,EAAE,IAAuB;IAC1E,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,gCAAgC;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3F,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAE7B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { SetNodeSchema } from '@kaskad/types';\n\nimport { appendPath, CreateNodeOptions } from '../create-node-options';\nimport { SetNode } from '../node';\nimport { createNode } from '../node-creation';\n\nexport function createSetNode(schema: SetNodeSchema, opts: CreateNodeOptions): SetNode {\n if (!schema.value) {\n return new SetNode(schema.valueType, null, opts.position);\n }\n\n // Convert array to Set of nodes\n const items = schema.value.map((item, index) => createNode(item, appendPath(opts, index)));\n const value = new Set(items);\n\n return new SetNode(schema.valueType, value, opts.position);\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { isObject } from '@kaskad/schema';
2
+ import { appendPath } from '../create-node-options';
3
+ import { ShapeNode } from '../node';
4
+ import { createNode } from '../node-creation';
5
+ export function createShapeNode(schema, opts) {
6
+ if (!isObject(schema.value)) {
7
+ return new ShapeNode(schema.valueType, null, opts.position);
8
+ }
9
+ const fields = {};
10
+ for (const key in schema.value) {
11
+ fields[key] = createNode(schema.value[key], appendPath(opts, key));
12
+ }
13
+ return new ShapeNode(schema.valueType, fields, opts.position);
14
+ }
15
+ //# sourceMappingURL=shape-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/shape-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAqB,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAgB,SAAS,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,eAAe,CAAC,MAAuB,EAAE,IAAuB;IAC9E,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { isObject } from '@kaskad/schema';\nimport { ShapeNodeSchema, ValueType } from '@kaskad/types';\n\nimport { appendPath, CreateNodeOptions } from '../create-node-options';\nimport { AbstractNode, ShapeNode } from '../node';\nimport { createNode } from '../node-creation';\n\nexport function createShapeNode(schema: ShapeNodeSchema, opts: CreateNodeOptions): ShapeNode {\n if (!isObject(schema.value)) {\n return new ShapeNode(schema.valueType, null, opts.position);\n }\n\n const fields: Record<string, AbstractNode<ValueType>> = {};\n for (const key in schema.value) {\n fields[key] = createNode(schema.value[key], appendPath(opts, key));\n }\n\n return new ShapeNode(schema.valueType, fields, opts.position);\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { appendPath } from '../create-node-options';
2
+ import { VariantShapeNode } from '../node';
3
+ import { createNode } from '../node-creation';
4
+ export function createVariantShapeNode(schema, opts) {
5
+ if (!schema.value) {
6
+ return new VariantShapeNode(schema.valueType, null, opts.position);
7
+ }
8
+ const value = splitValue(schema.value, schema.valueType);
9
+ const fields = {};
10
+ for (const key in value.fields) {
11
+ fields[key] = createNode(value.fields[key], appendPath(opts, key));
12
+ }
13
+ return new VariantShapeNode(schema.valueType, { kind: value.kind, fields }, opts.position);
14
+ }
15
+ function splitValue(value, valueType) {
16
+ const kindKey = `${valueType.shapeType}Type`;
17
+ const { [kindKey]: kind, ...fields } = value;
18
+ if (!kind) {
19
+ throw new Error(`Missing kind field ${kindKey}`);
20
+ }
21
+ return { kind, fields };
22
+ }
23
+ //# sourceMappingURL=variant-shape-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant-shape-creator.js","sourceRoot":"","sources":["../../../../../../../libs/component-tree/src/lib/node/creators/variant-shape-creator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAqB,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAgB,gBAA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skad/types';\n\nimport { appendPath, CreateNodeOptions } from '../create-node-options';\nimport { AbstractNode, VariantShapeNode } from '../node';\nimport { createNode } from '../node-creation';\n\ntype SplitValue = { kind: string; fields: Record<string, NodeSchema> };\n\nexport function createVariantShapeNode(schema: VariantShapeNodeSchema, opts: CreateNodeOptions) {\n if (!schema.value) {\n return new VariantShapeNode(schema.valueType, null, opts.position);\n }\n\n const value = splitValue(schema.value, schema.valueType);\n\n const fields: Record<string, AbstractNode<ValueType>> = {};\n for (const key in value.fields) {\n fields[key] = createNode(value.fields[key], appendPath(opts, key));\n }\n\n return new VariantShapeNode(schema.valueType, { kind: value.kind, fields }, opts.position);\n}\n\nfunction splitValue(value: VariantShapeValue, valueType: VariantShapeValueType): SplitValue {\n const kindKey = `${valueType.shapeType}Type`;\n const { [kindKey]: kind, ...fields } = value;\n\n if (!kind) {\n throw new Error(`Missing kind field ${kindKey}`);\n }\n\n return { kind, fields } as SplitValue;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { isObject } from '@kaskad/schema';
2
+ export function isNode(value) {
3
+ return isObject(value) && 'nodeType' in value;
4
+ }
5
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../libs/component-tree/src/lib/node/guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,UAAU,IAAI,KAAK,CAAC;AAChD,CAAC","sourcesContent":["import { isObject } from '@kaskad/schema';\nimport { ValueType } from '@kaskad/types';\n\nimport { AbstractNode } from './node';\n\nexport function isNode(value: unknown): value is AbstractNode<ValueType> {\n return isObject(value) && 'nodeType' in value;\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import { createArrayNode } from './creators/array-creator';
2
+ import { createCommandNode } from './creators/command-creator';
3
+ import { createComponentNode } from './creators/component-creator';
4
+ import { createLeafNode } from './creators/leaf-creator';
5
+ import { createMapNode } from './creators/map-creator';
6
+ import { createObjectNode } from './creators/object-creator';
7
+ import { createSetNode } from './creators/set-creator';
8
+ import { createShapeNode } from './creators/shape-creator';
9
+ import { createVariantShapeNode } from './creators/variant-shape-creator';
10
+ import { AbstractNode } from './node';
11
+ export function createNode(unfolded, opts) {
12
+ if (unfolded instanceof AbstractNode) {
13
+ return unfolded;
14
+ }
15
+ const node = _create(unfolded, opts);
16
+ if (unfolded.computation) {
17
+ node.computationStack.push(unfolded.computation);
18
+ }
19
+ node.bindingSchema = unfolded.binding;
20
+ node.extraBinding = unfolded.extraBinding;
21
+ return node;
22
+ }
23
+ const nodeCreators = {
24
+ component: (node, opts) => createComponentNode(node, opts),
25
+ array: (node, opts) => createArrayNode(node, opts),
26
+ map: (node, opts) => createMapNode(node, opts),
27
+ set: (node, opts) => createSetNode(node, opts),
28
+ object: (node, opts) => createObjectNode(node, opts),
29
+ command: (node, opts) => createCommandNode(node, opts),
30
+ shape: (node, opts) => createShapeNode(node, opts),
31
+ variantShape: (node, opts) => createVariantShapeNode(node, opts),
32
+ // Leaf types
33
+ string: (node, opts) => createLeafNode(node, opts),
34
+ number: (node, opts) => createLeafNode(node, opts),
35
+ boolean: (node, opts) => createLeafNode(node, opts),
36
+ unknown: (node, opts) => createLeafNode(node, opts),
37
+ componentSchema: (node, opts) => createLeafNode(node, opts),
38
+ };
39
+ function _create(node, opts) {
40
+ const creator = nodeCreators[node.valueType.type];
41
+ if (creator) {
42
+ return creator(node, opts);
43
+ }
44
+ // Fallback for any unknown types
45
+ return createLeafNode(node, opts);
46
+ }
47
+ //# sourceMappingURL=node-creation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-creation.js","sourceRoot":"","sources":["../../../../../../libs/component-tree/src/lib/node/node-creation.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,E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CAAC;IAC7B,CAAC;IACD,iCAAiC;IACjC,OAAO,cAAc,CAAC,IAAsB,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import {\n ArrayNodeSchema,\n CommandNodeSchema,\n ComponentNodeSchema,\n LeafNodeSchema,\n MapNodeSchema,\n NodeSchema,\n ObjectNodeSchema,\n SetNodeSchema,\n ShapeNodeSchema,\n ValueType,\n VariantShapeNodeSchema,\n} from '@kaskad/types';\n\nimport { CreateNodeOptions } from './create-node-options';\nimport { createArrayNode } from './creators/array-creator';\nimport { createCommandNode } from './creators/command-creator';\nimport { createComponentNode } from './creators/component-creator';\nimport { createLeafNode } from './creators/leaf-creator';\nimport { createMapNode } from './creators/map-creator';\nimport { createObjectNode } from './creators/object-creator';\nimport { createSetNode } from './creators/set-creator';\nimport { createShapeNode } from './creators/shape-creator';\nimport { createVariantShapeNode } from './creators/variant-shape-creator';\nimport { AbstractNode } from './node';\n\nexport function createNode<T extends AbstractNode<ValueType> = AbstractNode<ValueType>>(\n unfolded: NodeSchema,\n opts: CreateNodeOptions,\n): T {\n if (unfolded instanceof AbstractNode) {\n return unfolded as unknown as T;\n }\n const node = _create(unfolded, opts);\n\n if (unfolded.computation) {\n node.computationStack.push(unfolded.computation);\n }\n\n node.bindingSchema = unfolded.binding;\n node.extraBinding = unfolded.extraBinding;\n return node as T;\n}\n\nconst nodeCreators: Record<string, (node: NodeSchema, opts: CreateNodeOptions) => AbstractNode<ValueType>> = {\n component: (node, opts) => createComponentNode(node as ComponentNodeSchema, opts),\n array: (node, opts) => createArrayNode(node as ArrayNodeSchema, opts),\n map: (node, opts) => createMapNode(node as MapNodeSchema, opts),\n set: (node, opts) => createSetNode(node as SetNodeSchema, opts),\n object: (node, opts) => createObjectNode(node as ObjectNodeSchema, opts),\n command: (node, opts) => createCommandNode(node as CommandNodeSchema, opts),\n shape: (node, opts) => createShapeNode(node as ShapeNodeSchema, opts),\n variantShape: (node, opts) => createVariantShapeNode(node as VariantShapeNodeSchema, opts),\n // Leaf types\n string: (node, opts) => createLeafNode(node as LeafNodeSchema, opts),\n number: (node, opts) => createLeafNode(node as LeafNodeSchema, opts),\n boolean: (node, opts) => createLeafNode(node as LeafNodeSchema, opts),\n unknown: (node, opts) => createLeafNode(node as LeafNodeSchema, opts),\n componentSchema: (node, opts) => createLeafNode(node as LeafNodeSchema, opts),\n};\n\nfunction _create(node: NodeSchema, opts: CreateNodeOptions): AbstractNode<ValueType> {\n const creator = nodeCreators[node.valueType.type];\n if (creator) {\n return creator(node, opts);\n }\n // Fallback for any unknown types\n return createLeafNode(node as LeafNodeSchema, opts);\n}\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=node-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-type.js","sourceRoot":"","sources":["../../../../../../libs/component-tree/src/lib/node/node-type.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentId, ValueType } from '@kaskad/types';\n\nimport { CommandNodeStructure } from '../types';\nimport { AbstractNode } from './node';\n\n// Using AbstractNode<ValueType> instead of TNode\ntype NodeType = AbstractNode<ValueType>;\n\nexport type NodeStructureMap = {\n unknown: unknown;\n boolean: boolean;\n number: number;\n string: string;\n array: NodeType[];\n map: Record<string, NodeType>;\n set: Set<NodeType>;\n object: Record<string, NodeType>;\n shape: Record<string, NodeType>;\n variantShape: { kind: string; fields: Record<string, NodeType> };\n command: CommandNodeStructure;\n component: string;\n componentSchema: unknown;\n};\n\nexport type NodeExtractedValueMap = {\n unknown: unknown;\n boolean: boolean;\n number: number;\n string: string;\n array: unknown[];\n map: Record<string, unknown>;\n set: Set<unknown>;\n object: Record<string, unknown>;\n shape: unknown; // TODO: specify more specific type\n variantShape: unknown; // TODO: specify more specific type\n command: unknown;\n component: ComponentId;\n componentSchema: unknown;\n};\n\nexport type CommandNodeViewModel = {\n execute: (...args: unknown[]) => Promise<unknown>;\n executing: boolean;\n failed: boolean;\n};\n\nexport type NodeViewModelMap = NodeExtractedValueMap & {\n command: CommandNodeViewModel;\n};\n\nexport type NodeStructure<T extends ValueType> = NodeStructureMap[T['type']];\nexport type NodeExtractedValue<T extends ValueType> = NodeExtractedValueMap[T['type']];\nexport type NodeViewModel<T extends ValueType> = NodeViewModelMap[T['type']];\n"]}