@kaskad/component-tree 0.0.1 → 0.0.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 (136) hide show
  1. package/fesm2022/kaskad-component-tree.mjs +2380 -0
  2. package/fesm2022/kaskad-component-tree.mjs.map +1 -0
  3. package/package.json +10 -10
  4. package/types/kaskad-component-tree.d.ts +582 -0
  5. package/esm2022/index.js +0 -12
  6. package/esm2022/index.js.map +0 -1
  7. package/esm2022/kaskad-component-tree.js +0 -5
  8. package/esm2022/kaskad-component-tree.js.map +0 -1
  9. package/esm2022/lib/component-lookup/index.js +0 -68
  10. package/esm2022/lib/component-lookup/index.js.map +0 -1
  11. package/esm2022/lib/component-lookup/traverses/array-traverser.js +0 -18
  12. package/esm2022/lib/component-lookup/traverses/array-traverser.js.map +0 -1
  13. package/esm2022/lib/component-lookup/traverses/component-traverser.js +0 -120
  14. package/esm2022/lib/component-lookup/traverses/component-traverser.js.map +0 -1
  15. package/esm2022/lib/component-lookup/traverses/index.js +0 -29
  16. package/esm2022/lib/component-lookup/traverses/index.js.map +0 -1
  17. package/esm2022/lib/component-lookup/traverses/object-traverser.js +0 -22
  18. package/esm2022/lib/component-lookup/traverses/object-traverser.js.map +0 -1
  19. package/esm2022/lib/component-lookup/types.js +0 -1
  20. package/esm2022/lib/component-lookup/types.js.map +0 -1
  21. package/esm2022/lib/component-tree-api.js +0 -121
  22. package/esm2022/lib/component-tree-api.js.map +0 -1
  23. package/esm2022/lib/computation/computation-frame.js +0 -27
  24. package/esm2022/lib/computation/computation-frame.js.map +0 -1
  25. package/esm2022/lib/computation/computation-stack.js +0 -83
  26. package/esm2022/lib/computation/computation-stack.js.map +0 -1
  27. package/esm2022/lib/computation/index.js +0 -3
  28. package/esm2022/lib/computation/index.js.map +0 -1
  29. package/esm2022/lib/config.js +0 -6
  30. package/esm2022/lib/config.js.map +0 -1
  31. package/esm2022/lib/mobx/component.js +0 -110
  32. package/esm2022/lib/mobx/component.js.map +0 -1
  33. package/esm2022/lib/mobx/create-root-node.js +0 -21
  34. package/esm2022/lib/mobx/create-root-node.js.map +0 -1
  35. package/esm2022/lib/mobx/ref-space.js +0 -25
  36. package/esm2022/lib/mobx/ref-space.js.map +0 -1
  37. package/esm2022/lib/mobx/store.js +0 -827
  38. package/esm2022/lib/mobx/store.js.map +0 -1
  39. package/esm2022/lib/node/create-node-options.js +0 -16
  40. package/esm2022/lib/node/create-node-options.js.map +0 -1
  41. package/esm2022/lib/node/creators/array-creator.js +0 -9
  42. package/esm2022/lib/node/creators/array-creator.js.map +0 -1
  43. package/esm2022/lib/node/creators/command-creator.js +0 -16
  44. package/esm2022/lib/node/creators/command-creator.js.map +0 -1
  45. package/esm2022/lib/node/creators/component-creator.js +0 -58
  46. package/esm2022/lib/node/creators/component-creator.js.map +0 -1
  47. package/esm2022/lib/node/creators/leaf-creator.js +0 -5
  48. package/esm2022/lib/node/creators/leaf-creator.js.map +0 -1
  49. package/esm2022/lib/node/creators/map-creator.js +0 -14
  50. package/esm2022/lib/node/creators/map-creator.js.map +0 -1
  51. package/esm2022/lib/node/creators/object-creator.js +0 -17
  52. package/esm2022/lib/node/creators/object-creator.js.map +0 -1
  53. package/esm2022/lib/node/creators/set-creator.js +0 -13
  54. package/esm2022/lib/node/creators/set-creator.js.map +0 -1
  55. package/esm2022/lib/node/creators/shape-creator.js +0 -15
  56. package/esm2022/lib/node/creators/shape-creator.js.map +0 -1
  57. package/esm2022/lib/node/creators/variant-shape-creator.js +0 -23
  58. package/esm2022/lib/node/creators/variant-shape-creator.js.map +0 -1
  59. package/esm2022/lib/node/guards.js +0 -5
  60. package/esm2022/lib/node/guards.js.map +0 -1
  61. package/esm2022/lib/node/node-creation.js +0 -47
  62. package/esm2022/lib/node/node-creation.js.map +0 -1
  63. package/esm2022/lib/node/node-type.js +0 -1
  64. package/esm2022/lib/node/node-type.js.map +0 -1
  65. package/esm2022/lib/node/node.js +0 -305
  66. package/esm2022/lib/node/node.js.map +0 -1
  67. package/esm2022/lib/parsers/index.js +0 -3
  68. package/esm2022/lib/parsers/index.js.map +0 -1
  69. package/esm2022/lib/parsers/node-selector.types.js +0 -1
  70. package/esm2022/lib/parsers/node-selector.types.js.map +0 -1
  71. package/esm2022/lib/parsers/parse-component-selector.js +0 -43
  72. package/esm2022/lib/parsers/parse-component-selector.js.map +0 -1
  73. package/esm2022/lib/parsers/parse-node-selector.js +0 -263
  74. package/esm2022/lib/parsers/parse-node-selector.js.map +0 -1
  75. package/esm2022/lib/types/command.js +0 -1
  76. package/esm2022/lib/types/command.js.map +0 -1
  77. package/esm2022/lib/types/index.js +0 -5
  78. package/esm2022/lib/types/index.js.map +0 -1
  79. package/esm2022/lib/types/node.guards.js +0 -7
  80. package/esm2022/lib/types/node.guards.js.map +0 -1
  81. package/esm2022/lib/types/schema.js +0 -1
  82. package/esm2022/lib/types/schema.js.map +0 -1
  83. package/esm2022/lib/util/extract-node-value.js +0 -45
  84. package/esm2022/lib/util/extract-node-value.js.map +0 -1
  85. package/esm2022/lib/util/format-source.js +0 -7
  86. package/esm2022/lib/util/format-source.js.map +0 -1
  87. package/esm2022/lib/util/get-component.js +0 -8
  88. package/esm2022/lib/util/get-component.js.map +0 -1
  89. package/esm2022/lib/util/id-generator.js +0 -10
  90. package/esm2022/lib/util/id-generator.js.map +0 -1
  91. package/esm2022/lib/util/traverse-node.js +0 -50
  92. package/esm2022/lib/util/traverse-node.js.map +0 -1
  93. package/index.d.ts +0 -11
  94. package/kaskad-component-tree.d.ts +0 -5
  95. package/lib/component-lookup/index.d.ts +0 -8
  96. package/lib/component-lookup/traverses/array-traverser.d.ts +0 -3
  97. package/lib/component-lookup/traverses/component-traverser.d.ts +0 -3
  98. package/lib/component-lookup/traverses/index.d.ts +0 -9
  99. package/lib/component-lookup/traverses/object-traverser.d.ts +0 -3
  100. package/lib/component-lookup/types.d.ts +0 -13
  101. package/lib/component-tree-api.d.ts +0 -21
  102. package/lib/computation/computation-frame.d.ts +0 -14
  103. package/lib/computation/computation-stack.d.ts +0 -48
  104. package/lib/computation/index.d.ts +0 -2
  105. package/lib/config.d.ts +0 -4
  106. package/lib/mobx/component.d.ts +0 -45
  107. package/lib/mobx/create-root-node.d.ts +0 -3
  108. package/lib/mobx/ref-space.d.ts +0 -10
  109. package/lib/mobx/store.d.ts +0 -238
  110. package/lib/node/create-node-options.d.ts +0 -12
  111. package/lib/node/creators/array-creator.d.ts +0 -4
  112. package/lib/node/creators/command-creator.d.ts +0 -4
  113. package/lib/node/creators/component-creator.d.ts +0 -4
  114. package/lib/node/creators/leaf-creator.d.ts +0 -4
  115. package/lib/node/creators/map-creator.d.ts +0 -4
  116. package/lib/node/creators/object-creator.d.ts +0 -4
  117. package/lib/node/creators/set-creator.d.ts +0 -4
  118. package/lib/node/creators/shape-creator.d.ts +0 -4
  119. package/lib/node/creators/variant-shape-creator.d.ts +0 -4
  120. package/lib/node/guards.d.ts +0 -3
  121. package/lib/node/node-creation.d.ts +0 -4
  122. package/lib/node/node-type.d.ts +0 -49
  123. package/lib/node/node.d.ts +0 -107
  124. package/lib/parsers/index.d.ts +0 -5
  125. package/lib/parsers/node-selector.types.d.ts +0 -25
  126. package/lib/parsers/parse-component-selector.d.ts +0 -8
  127. package/lib/parsers/parse-node-selector.d.ts +0 -87
  128. package/lib/types/command.d.ts +0 -3
  129. package/lib/types/index.d.ts +0 -4
  130. package/lib/types/node.guards.d.ts +0 -4
  131. package/lib/types/schema.d.ts +0 -13
  132. package/lib/util/extract-node-value.d.ts +0 -3
  133. package/lib/util/format-source.d.ts +0 -1
  134. package/lib/util/get-component.d.ts +0 -4
  135. package/lib/util/id-generator.d.ts +0 -5
  136. package/lib/util/traverse-node.d.ts +0 -26
@@ -1,48 +0,0 @@
1
- import { ComputationSchema } from '@kaskad/types';
2
- import { ComputationFrame } from './computation-frame';
3
- /**
4
- * Manages a stack of computation frames for nested computations.
5
- * For example: formula → formula → template chain.
6
- */
7
- export declare class ComputationStack {
8
- /**
9
- * Maximum allowed stack depth to prevent infinite recursion.
10
- */
11
- static readonly MAX_DEPTH = 10;
12
- private readonly _frames;
13
- constructor();
14
- /**
15
- * Get the topmost computation frame from the stack.
16
- * Returns null if stack is empty.
17
- */
18
- get top(): ComputationFrame | null;
19
- /**
20
- * Returns true if all frames in the stack are activated.
21
- * Empty stack returns true (vacuously).
22
- */
23
- get allActivated(): boolean;
24
- /**
25
- * Get the current stack depth.
26
- */
27
- get depth(): number;
28
- /**
29
- * Check if the stack is empty.
30
- */
31
- get isEmpty(): boolean;
32
- /**
33
- * Push a new computation frame onto the stack.
34
- * Throws if depth limit is exceeded.
35
- */
36
- push(schema: ComputationSchema): ComputationFrame;
37
- /**
38
- * Pop all frames from the given depth onward.
39
- * For example, if depth=2, this removes frames at indices 2, 3, 4, etc.
40
- * Useful when a computation at a specific depth re-evaluates and needs
41
- * to clear its results without affecting parent computations.
42
- */
43
- popFrom(depth: number): void;
44
- /**
45
- * Dispose all frames in the stack.
46
- */
47
- dispose(): void;
48
- }
@@ -1,2 +0,0 @@
1
- export * from './computation-frame';
2
- export * from './computation-stack';
package/lib/config.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { CommandNode } from './node/node';
2
- export declare const componentTreeConfig: {
3
- runCommand: (_node: CommandNode, ..._args: unknown[]) => Promise<unknown>;
4
- };
@@ -1,45 +0,0 @@
1
- import { ComponentId, NodePosition, RefSpaceId, ValueType } from '@kaskad/types';
2
- import { IReactionDisposer } from 'mobx';
3
- import { AbstractNode } from '../node/node';
4
- import { NodeSelector } from '../parsers';
5
- import { NodeChangeHandler } from '../types';
6
- export interface ComponentCreateConfig {
7
- id: ComponentId;
8
- componentType: string;
9
- position: NodePosition;
10
- refSpaceId: RefSpaceId;
11
- props: Map<string, AbstractNode<ValueType>>;
12
- variables: Map<string, AbstractNode<ValueType>>;
13
- onNodeChange: NodeChangeHandler[];
14
- sourceUrl?: string;
15
- }
16
- export declare class TComponent {
17
- readonly id: ComponentId;
18
- readonly position: NodePosition;
19
- readonly refSpaceId: RefSpaceId;
20
- sourceUrl: string | null;
21
- componentType: string;
22
- props: Map<string, AbstractNode<ValueType>>;
23
- variables: Map<string, AbstractNode<ValueType>>;
24
- onNodeChange: NodeChangeHandler[];
25
- handlerDisposers: IReactionDisposer[];
26
- constructor(config: ComponentCreateConfig);
27
- setVariable(variableName: string, node: AbstractNode<ValueType>): void;
28
- /**
29
- * Find a node by selector. Returns null if the node is not found.
30
- * This is an alias for getNode for consistency with ComponentStore's API.
31
- */
32
- findNode(nodeSelector: string): AbstractNode<ValueType> | null;
33
- /**
34
- * Get a node by selector. Throws an error if the node is not found.
35
- * Use findNode() for optional lookups that return null instead of throwing.
36
- *
37
- * Note: Even if the selector contains optional chaining (?.), this method will throw
38
- * if the node is not found. Use findNode() for optional chaining support.
39
- */
40
- getNode(nodeSelector: string): AbstractNode<ValueType>;
41
- findNodeFromParsed(parsed: Omit<NodeSelector, 'componentSelector'>): AbstractNode<ValueType> | null;
42
- getNodeFromParsed(parsed: Omit<NodeSelector, 'componentSelector'>): AbstractNode<ValueType>;
43
- getNodeValue<T>(nodeSelector: string): T | null;
44
- dispose(): void;
45
- }
@@ -1,3 +0,0 @@
1
- import { ComponentId, NodeSchema, RefSpaceId, ValueType } from '@kaskad/types';
2
- import { AbstractNode } from '../node/node';
3
- export declare function createRootNode(refSpaceId: RefSpaceId, schema: NodeSchema, ownerComponentId: ComponentId | null, parentRefSpaceId: RefSpaceId | null, sourceUrl?: string): AbstractNode<ValueType>;
@@ -1,10 +0,0 @@
1
- import { ComponentId, ComponentRef, RefSpaceId } from '@kaskad/types';
2
- export declare class RefSpace {
3
- id: RefSpaceId;
4
- parentRefSpaceId: RefSpaceId | null;
5
- private readonly byRef;
6
- constructor(id: RefSpaceId, parentRefSpaceId?: RefSpaceId | null);
7
- get refs(): Map<string, string>;
8
- addRefs(refs: Record<ComponentRef, ComponentId>): void;
9
- getComponentIdByRef(ref: string): ComponentId | null;
10
- }
@@ -1,238 +0,0 @@
1
- import { ComponentId, NodeSchema, RefSpaceId, ValueType } from '@kaskad/types';
2
- import { AbstractNode, ArrayNode } from '../node/node';
3
- import { TComponent } from './component';
4
- import { RefSpace } from './ref-space';
5
- export declare class ComponentStore {
6
- private static instance;
7
- components: Map<ComponentId, TComponent>;
8
- refSpaces: Map<RefSpaceId, RefSpace>;
9
- componentsToPreload: Set<string>;
10
- private componentsByRefSpace;
11
- static getInstance(): ComponentStore;
12
- static reset(): ComponentStore;
13
- addRefSpace(refSpace: RefSpace): void;
14
- addComponents(components: Record<ComponentId, TComponent>): void;
15
- getRefSpace(refSpaceId: RefSpaceId): RefSpace | null;
16
- getRefSpaceOrThrow(refSpaceId: RefSpaceId): RefSpace;
17
- getComponent(componentId: string): TComponent | null;
18
- getComponentOrThrow(componentId: string): TComponent;
19
- findVariable(componentId: ComponentId, variableName: string): AbstractNode<ValueType> | null;
20
- /**
21
- * Find a single component using a selector relative to another component.
22
- * Throws if multiple components match the selector.
23
- *
24
- * @param relativeTo - The component ID to search relative to
25
- * @param selector - Component selector string (e.g., 'Button', '&myRef', '^parent', ':button', 'Button[disabled=true]')
26
- * @returns The matching component or null if not found
27
- * @throws If the selector matches multiple components
28
- *
29
- * @example
30
- * ```typescript
31
- * const button = store.findComponent(componentId, 'Button');
32
- * const aliased = store.findComponent(componentId, '&myRef');
33
- * const parent = store.findComponent(componentId, '^parent');
34
- * const byType = store.findComponent(componentId, ':button');
35
- * const filtered = store.findComponent(componentId, 'Button[disabled=true]');
36
- * ```
37
- */
38
- findComponent(relativeTo: ComponentId, selector: string): TComponent | null;
39
- /**
40
- * Find all components matching a selector relative to another component.
41
- *
42
- * @param relativeTo - The component ID to search relative to
43
- * @param selector - Component selector string (e.g., 'Button', '&myRef', ':button', 'Button[disabled=true]')
44
- * @returns Array of matching components (empty if none found)
45
- *
46
- * @example
47
- * ```typescript
48
- * const buttons = store.findComponents(componentId, 'Button');
49
- * const allOfType = store.findComponents(componentId, ':button');
50
- * const filtered = store.findComponents(componentId, 'Button[disabled=true]');
51
- * ```
52
- */
53
- findComponents(relativeTo: ComponentId, selector: string): TComponent[];
54
- /**
55
- * Get a node by selector relative to a component.
56
- * Throws an error if the component or node is not found.
57
- * Use findNode() for optional lookups that return null instead of throwing.
58
- *
59
- * Note: Even if the selector contains optional chaining (?.), this method will throw
60
- * if the node is not found. Use findNode() for optional chaining support.
61
- *
62
- * Component selector behavior:
63
- * - `&ref->value` - Throws if component with ref doesn't exist
64
- * - `&ref?->value` - Throws if node not found, but allows missing component (returns null for the whole expression)
65
- *
66
- * @param relativeTo - The component ID to search relative to
67
- * @param selector - Node selector string (e.g., 'prop', '$variable', '^Parent->prop', '&ref?->value')
68
- * @returns The node
69
- * @throws If the component or node is not found (unless using ?-> for component)
70
- *
71
- * @example
72
- * ```typescript
73
- * const node = store.getNode(componentId, 'requiredProp'); // throws if not found
74
- * const optionalNode = store.findNode(componentId, 'user?.profile'); // returns null if not found
75
- * const optionalComponent = store.getNode(componentId, '&optional?->value'); // throws only if value missing, not if component missing
76
- * ```
77
- */
78
- getNode<T extends AbstractNode<ValueType>>(relativeTo: ComponentId, selector: string): T;
79
- /**
80
- * Find a node by selector relative to a component.
81
- * Returns null if the node is not found.
82
- *
83
- * Component selector behavior:
84
- * - `&ref->value` - Throws if component doesn't exist (strict by default)
85
- * - `&ref?->value` - Returns null if component doesn't exist (lenient when explicit)
86
- *
87
- * Use `?->` to explicitly indicate that a missing component is acceptable.
88
- * This makes the code self-documenting and prevents accidental null returns.
89
- *
90
- * @param relativeTo - The component ID to search relative to
91
- * @param selector - Node selector string (e.g., 'prop', '$variable', '^Parent->prop', '&ref?->value')
92
- * @returns The node or null if not found
93
- *
94
- * @example
95
- * ```typescript
96
- * // Strict - throws if component missing
97
- * const node = store.findNode(componentId, '&ref->value');
98
- *
99
- * // Lenient - returns null if component missing
100
- * const optionalNode = store.findNode(componentId, '&ref?->value');
101
- * if (optionalNode) {
102
- * // Use the node
103
- * }
104
- * ```
105
- */
106
- findNode<T extends AbstractNode<ValueType>>(relativeTo: ComponentId, selector: string): T | null;
107
- /**
108
- * Collect node values from multiple components into an array.
109
- * Maps over all components matching the selector and extracts a node value from each.
110
- *
111
- * @param relativeTo - The component ID to search relative to
112
- * @param componentSelector - Selector for finding components (e.g., ':forms.Input', 'Button')
113
- * @param nodeSelector - The node path to extract from each component (e.g., 'value', 'inputKey')
114
- * @returns Array of node values from matched components
115
- *
116
- * @example
117
- * ```typescript
118
- * // Get all input values
119
- * const values = store.collectValuesArray(componentId, ':forms.Input', 'value');
120
- * // Returns: ['value1', 'value2', 'value3']
121
- * ```
122
- */
123
- collectValuesArray<T = unknown[]>(relativeTo: ComponentId, componentSelector: string, nodeSelector: string): T;
124
- /**
125
- * Collect node values from multiple components into a map/object.
126
- * Reduces over all components matching the selector, using one node as the key and another as the value.
127
- *
128
- * @param relativeTo - The component ID to search relative to
129
- * @param componentSelector - Selector for finding components (e.g., ':forms.Input', 'Button')
130
- * @param keyNodeSelector - The node path to use as the object key (e.g., 'inputKey', 'id')
131
- * @param valueNodeSelector - The node path to use as the object value (e.g., 'value', 'label')
132
- * @returns Object/map with keys and values from matched components
133
- *
134
- * @example
135
- * ```typescript
136
- * // Create a map from inputKey to value
137
- * const map = store.collectValuesMap(componentId, ':forms.Input', 'inputKey', 'value');
138
- * // Returns: { key1: 'value1', key2: 'value2' }
139
- * ```
140
- */
141
- collectValuesMap<T = Record<string, unknown>>(relativeTo: ComponentId, componentSelector: string, keyNodeSelector: string, valueNodeSelector: string): T;
142
- /**
143
- * Set a node from a raw schema value.
144
- * The raw schema will be unfolded before being applied.
145
- * Handles structure, computation stack, and nested components.
146
- *
147
- * @param node - The node to update
148
- * @param rawSchema - The raw schema value (will be unfolded into a NodeSchema)
149
- */
150
- setNodeRawSchema(node: AbstractNode<ValueType>, rawSchema: unknown): void;
151
- /**
152
- * Set a node from an already-unfolded schema.
153
- * Use this when you already have a NodeSchema to avoid double-unfolding.
154
- * Handles structure, nested components, and computation stack.
155
- *
156
- * @param node - The node to update
157
- * @param schema - The unfolded NodeSchema to set
158
- */
159
- setNodeSchema(node: AbstractNode<ValueType>, schema: NodeSchema): void;
160
- /**
161
- * Remove an item from an array node.
162
- * Handles cleanup of nested components in the removed item.
163
- *
164
- * @param arrayNode - The array node to remove from
165
- * @param index - The index of the item to remove
166
- */
167
- removeArrayItem(arrayNode: ArrayNode, index: number): void;
168
- /**
169
- * Insert an item into an array node at a specific index.
170
- * Creates a node structure from the raw value and inserts it at the specified position.
171
- * Shifts existing items to the right.
172
- *
173
- * @param arrayNode - The array node to insert into
174
- * @param index - The index at which to insert the item
175
- * @param value - The raw value to insert (will be transformed into a node structure)
176
- */
177
- insertArrayItem(arrayNode: ArrayNode, index: number, value: unknown): void;
178
- /**
179
- * Replace an item in an array node at a specific index.
180
- * Creates a node structure from the raw value and replaces the item at the specified position.
181
- * Properly cleans up nested components in the replaced item.
182
- *
183
- * @param arrayNode - The array node containing the item to replace
184
- * @param index - The index of the item to replace
185
- * @param value - The raw value to set (will be transformed into a node structure)
186
- */
187
- replaceArrayItem(arrayNode: ArrayNode, index: number, value: unknown): void;
188
- /**
189
- * Append an item to the end of an array node.
190
- * Creates a node structure from the raw value and appends it to the array.
191
- *
192
- * @param arrayNode - The array node to append to
193
- * @param value - The raw value to append (will be transformed into a node structure)
194
- */
195
- appendArrayItem(arrayNode: ArrayNode, value: unknown): void;
196
- /**
197
- * Reconcile for-loop children using key-based diffing.
198
- * Instead of destroying all children and recreating them,
199
- * this method compares old vs new keys and only creates/destroys what's necessary.
200
- *
201
- * @param arrayNode - The array node containing for-loop children
202
- * @param newSchemas - The new schemas to reconcile
203
- * @returns Indices of newly added items for activation
204
- */
205
- reconcileForLoopChildren(arrayNode: ArrayNode, newSchemas: unknown[]): number[];
206
- /**
207
- * Apply for-loop reconciliation by building new structure and cleaning up removed components.
208
- */
209
- private applyForLoopReconciliation;
210
- /**
211
- * Update loop variables (including item variable) on components that have been repositioned or whose data changed.
212
- */
213
- private updateLoopVariables;
214
- /**
215
- * Check if schemas have explicit trackBy keys that can be used for diffing.
216
- */
217
- private checkForExplicitKeys;
218
- /**
219
- * Extract keys from existing children (RefSpace components with $trackBy variable)
220
- */
221
- private extractOldKeys;
222
- /**
223
- * Extract keys from new schemas (generated by repeat())
224
- */
225
- private extractNewKeys;
226
- /**
227
- * Find duplicate keys in an array
228
- */
229
- private findDuplicateKeys;
230
- removeComponent(componentId: ComponentId): void;
231
- /**
232
- * Creates a new node for an array item from a raw value.
233
- * Returns the created node and the options used (for registering components/refs).
234
- * @throws If the array node has no parent component
235
- */
236
- private createArrayItemNode;
237
- private collectRefSpacesToRemove;
238
- }
@@ -1,12 +0,0 @@
1
- import { ComponentId, ComponentRef, NodePath, NodePosition, RefSpaceId } from '@kaskad/types';
2
- import { TComponent } from '../mobx/component';
3
- export interface CreateNodeOptions {
4
- readonly refSpaceId: RefSpaceId;
5
- readonly position: NodePosition;
6
- readonly components: Record<ComponentId, TComponent>;
7
- readonly refs: Record<RefSpaceId, Record<ComponentRef, ComponentId>>;
8
- readonly sourceUrl?: string;
9
- }
10
- export declare function withPath(opts: CreateNodeOptions, newPath: NodePath): CreateNodeOptions;
11
- export declare function withPosition(opts: CreateNodeOptions, componentId: ComponentId | null, path: NodePath): CreateNodeOptions;
12
- export declare function appendPath(opts: CreateNodeOptions, ...segments: (string | number)[]): CreateNodeOptions;
@@ -1,4 +0,0 @@
1
- import { ArrayNodeSchema } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { ArrayNode } from '../node';
4
- export declare function createArrayNode(schema: ArrayNodeSchema, opts: CreateNodeOptions): ArrayNode;
@@ -1,4 +0,0 @@
1
- import { CommandNodeSchema } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { CommandNode } from '../node';
4
- export declare function createCommandNode(schema: CommandNodeSchema, opts: CreateNodeOptions): CommandNode;
@@ -1,4 +0,0 @@
1
- import { ComponentNodeSchema, ComponentValueType } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { LeafNode } from '../node';
4
- export declare function createComponentNode(schema: ComponentNodeSchema, opts: CreateNodeOptions): LeafNode<ComponentValueType>;
@@ -1,4 +0,0 @@
1
- import { LeafNodeSchema, ValueType } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { AbstractNode } from '../node';
4
- export declare function createLeafNode(schema: LeafNodeSchema, opts: CreateNodeOptions): AbstractNode<ValueType>;
@@ -1,4 +0,0 @@
1
- import { MapNodeSchema } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { MapNode } from '../node';
4
- export declare function createMapNode(schema: MapNodeSchema, opts: CreateNodeOptions): MapNode;
@@ -1,4 +0,0 @@
1
- import { ObjectNodeSchema } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { ObjectNode } from '../node';
4
- export declare function createObjectNode(schema: ObjectNodeSchema, opts: CreateNodeOptions): ObjectNode;
@@ -1,4 +0,0 @@
1
- import { SetNodeSchema } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { SetNode } from '../node';
4
- export declare function createSetNode(schema: SetNodeSchema, opts: CreateNodeOptions): SetNode;
@@ -1,4 +0,0 @@
1
- import { ShapeNodeSchema } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { ShapeNode } from '../node';
4
- export declare function createShapeNode(schema: ShapeNodeSchema, opts: CreateNodeOptions): ShapeNode;
@@ -1,4 +0,0 @@
1
- import { VariantShapeNodeSchema } from '@kaskad/types';
2
- import { CreateNodeOptions } from '../create-node-options';
3
- import { VariantShapeNode } from '../node';
4
- export declare function createVariantShapeNode(schema: VariantShapeNodeSchema, opts: CreateNodeOptions): VariantShapeNode;
@@ -1,3 +0,0 @@
1
- import { ValueType } from '@kaskad/types';
2
- import { AbstractNode } from './node';
3
- export declare function isNode(value: unknown): value is AbstractNode<ValueType>;
@@ -1,4 +0,0 @@
1
- import { NodeSchema, ValueType } from '@kaskad/types';
2
- import { CreateNodeOptions } from './create-node-options';
3
- import { AbstractNode } from './node';
4
- export declare function createNode<T extends AbstractNode<ValueType> = AbstractNode<ValueType>>(unfolded: NodeSchema, opts: CreateNodeOptions): T;
@@ -1,49 +0,0 @@
1
- import { ComponentId, ValueType } from '@kaskad/types';
2
- import { CommandNodeStructure } from '../types';
3
- import { AbstractNode } from './node';
4
- type NodeType = AbstractNode<ValueType>;
5
- export type NodeStructureMap = {
6
- unknown: unknown;
7
- boolean: boolean;
8
- number: number;
9
- string: string;
10
- array: NodeType[];
11
- map: Record<string, NodeType>;
12
- set: Set<NodeType>;
13
- object: Record<string, NodeType>;
14
- shape: Record<string, NodeType>;
15
- variantShape: {
16
- kind: string;
17
- fields: Record<string, NodeType>;
18
- };
19
- command: CommandNodeStructure;
20
- component: string;
21
- componentSchema: unknown;
22
- };
23
- export type NodeExtractedValueMap = {
24
- unknown: unknown;
25
- boolean: boolean;
26
- number: number;
27
- string: string;
28
- array: unknown[];
29
- map: Record<string, unknown>;
30
- set: Set<unknown>;
31
- object: Record<string, unknown>;
32
- shape: unknown;
33
- variantShape: unknown;
34
- command: unknown;
35
- component: ComponentId;
36
- componentSchema: unknown;
37
- };
38
- export type CommandNodeViewModel = {
39
- execute: (...args: unknown[]) => Promise<unknown>;
40
- executing: boolean;
41
- failed: boolean;
42
- };
43
- export type NodeViewModelMap = NodeExtractedValueMap & {
44
- command: CommandNodeViewModel;
45
- };
46
- export type NodeStructure<T extends ValueType> = NodeStructureMap[T['type']];
47
- export type NodeExtractedValue<T extends ValueType> = NodeExtractedValueMap[T['type']];
48
- export type NodeViewModel<T extends ValueType> = NodeViewModelMap[T['type']];
49
- export {};
@@ -1,107 +0,0 @@
1
- import { ArrayValueType, BindingSchema, CommandValueType, MapValueType, NodePosition, ObjectValueType, SetValueType, ShapeValueType, ValueType, VariantShapeValueType } from '@kaskad/types';
2
- import { IReactionDisposer } from 'mobx';
3
- import { ComputationStack } from '../computation';
4
- import { NodeExtractedValue, NodeStructure, NodeViewModel } from './node-type';
5
- export declare abstract class AbstractNode<T extends ValueType> {
6
- readonly valueType: T;
7
- position: NodePosition;
8
- readonly nodeType: T['type'];
9
- readonly computationStack: ComputationStack;
10
- bindingSchema: BindingSchema | null;
11
- extraBinding?: BindingSchema | null;
12
- disposers: IReactionDisposer[];
13
- protected selfEvaluating: boolean;
14
- protected selfFailed: boolean;
15
- protected selfActivated: boolean;
16
- protected constructor(valueType: T, structure: NodeStructure<T> | null, position: NodePosition);
17
- private _structure;
18
- get structure(): NodeStructure<T> | null;
19
- set structure(value: NodeStructure<T>);
20
- abstract get extractedValue(): NodeExtractedValue<T> | null;
21
- get evaluating(): boolean;
22
- set evaluating(evaluating: boolean);
23
- get failed(): boolean;
24
- set failed(failed: boolean);
25
- get fullyActivated(): boolean;
26
- get computationActivated(): boolean;
27
- get isSelfActivated(): boolean;
28
- get viewModel(): NodeViewModel<T> | null;
29
- protected abstract get childrenEvaluating(): boolean;
30
- protected abstract get childrenFailed(): boolean;
31
- protected abstract get childrenActivated(): boolean;
32
- markActivated(): void;
33
- dispose(): void;
34
- /**
35
- * Find a sub-node by following a path of segments.
36
- * @param path Array of strings/numbers representing the path to traverse
37
- * @returns The found node or null if not found/traversal not possible
38
- */
39
- abstract getNodeByPath(path: (string | number)[]): AbstractNode<ValueType> | null;
40
- protected abstract disposeChildren(): void;
41
- }
42
- export declare class LeafNode<T extends ValueType> extends AbstractNode<T> {
43
- constructor(valueType: T, structure: NodeStructure<T> | null, position: NodePosition);
44
- get extractedValue(): NodeExtractedValue<T> | null;
45
- protected get childrenEvaluating(): boolean;
46
- protected get childrenFailed(): boolean;
47
- protected get childrenActivated(): boolean;
48
- getNodeByPath(path: (string | number)[]): AbstractNode<ValueType> | null;
49
- protected disposeChildren(): void;
50
- }
51
- export declare class CommandNode extends LeafNode<CommandValueType> {
52
- #private;
53
- inFlight: number;
54
- constructor(valueType: CommandValueType, structure: NodeStructure<CommandValueType> | null, position: NodePosition);
55
- get executing(): boolean;
56
- get viewModel(): NodeViewModel<CommandValueType>;
57
- }
58
- export declare class ArrayNode extends AbstractNode<ArrayValueType> {
59
- constructor(valueType: ArrayValueType, structure: NodeStructure<ArrayValueType> | null, position: NodePosition);
60
- get extractedValue(): NodeExtractedValue<ArrayValueType> | null;
61
- protected get childrenEvaluating(): boolean;
62
- protected get childrenFailed(): boolean;
63
- protected get childrenActivated(): boolean;
64
- getNodeByPath(path: (string | number)[]): AbstractNode<ValueType> | null;
65
- protected disposeChildren(): void;
66
- }
67
- export declare abstract class AbstractObjectLikeNode<T extends ValueType> extends AbstractNode<T> {
68
- protected constructor(valueType: T, structure: NodeStructure<T> | null, position: NodePosition);
69
- protected get childrenEvaluating(): boolean;
70
- protected get childrenFailed(): boolean;
71
- protected get childrenActivated(): boolean;
72
- getNodeByPath(path: (string | number)[]): AbstractNode<ValueType> | null;
73
- protected abstract object(): Record<string, AbstractNode<ValueType>> | null;
74
- protected disposeChildren(): void;
75
- protected mapObjectExtracted(): Record<string, unknown> | null;
76
- }
77
- export declare class MapNode extends AbstractObjectLikeNode<MapValueType> {
78
- constructor(valueType: MapValueType, structure: NodeStructure<MapValueType> | null, position: NodePosition);
79
- get extractedValue(): Record<string, unknown> | null;
80
- protected object(): Record<string, AbstractNode<ValueType>> | null;
81
- }
82
- export declare class SetNode extends AbstractNode<SetValueType> {
83
- constructor(valueType: SetValueType, structure: NodeStructure<SetValueType> | null, position: NodePosition);
84
- get extractedValue(): NodeExtractedValue<SetValueType> | null;
85
- protected get childrenEvaluating(): boolean;
86
- protected get childrenFailed(): boolean;
87
- protected get childrenActivated(): boolean;
88
- getNodeByPath(path: (string | number)[]): AbstractNode<ValueType> | null;
89
- protected disposeChildren(): void;
90
- }
91
- export declare class ObjectNode extends AbstractObjectLikeNode<ObjectValueType> {
92
- constructor(valueType: ObjectValueType, structure: NodeStructure<ObjectValueType> | null, position: NodePosition);
93
- get extractedValue(): Record<string, unknown> | null;
94
- protected object(): Record<string, AbstractNode<ValueType>> | null;
95
- }
96
- export declare class ShapeNode extends AbstractObjectLikeNode<ShapeValueType> {
97
- constructor(valueType: ShapeValueType, structure: NodeStructure<ShapeValueType> | null, position: NodePosition);
98
- get extractedValue(): Record<string, unknown> | null;
99
- protected object(): Record<string, AbstractNode<ValueType>> | null;
100
- }
101
- export declare class VariantShapeNode extends AbstractObjectLikeNode<VariantShapeValueType> {
102
- constructor(valueType: VariantShapeValueType, structure: NodeStructure<VariantShapeValueType> | null, position: NodePosition);
103
- get extractedValue(): {
104
- [x: string]: unknown;
105
- } | null;
106
- protected object(): Record<string, AbstractNode<ValueType>> | null;
107
- }
@@ -1,5 +0,0 @@
1
- export { parseNodeSelector } from './parse-node-selector';
2
- export type { PathPart, PathArray } from './parse-node-selector';
3
- export type { NodeSelector, PathSegment } from './node-selector.types';
4
- export { parseComponentSelector } from './parse-component-selector';
5
- export type { SelectorSegment, SelectorSegmentModifier } from './parse-component-selector';
@@ -1,25 +0,0 @@
1
- import { SelectorSegment } from './parse-component-selector';
2
- export interface ComponentSelectorInfo {
3
- /**
4
- * Component selector segments (e.g., &ref, :Type, ^Parent with conditions).
5
- */
6
- selector: SelectorSegment[];
7
- /**
8
- * If true, uses ?-> instead of ->,
9
- * meaning it should return null instead of throwing if the component is not found.
10
- */
11
- optional: boolean;
12
- }
13
- export interface NodeSelector {
14
- kind: 'property' | 'variable';
15
- head: string;
16
- tail: PathSegment[];
17
- /**
18
- * If present, the selector references another component.
19
- */
20
- component?: ComponentSelectorInfo;
21
- }
22
- export interface PathSegment {
23
- key: string | number;
24
- optional: boolean;
25
- }
@@ -1,8 +0,0 @@
1
- export type SelectorSegmentModifier = null | ':' | '^' | '&';
2
- export interface SelectorSegment {
3
- qualifier: string;
4
- modifier: SelectorSegmentModifier;
5
- conditions: string[][];
6
- index?: number;
7
- }
8
- export declare function parseComponentSelector(selector: string): SelectorSegment[];