@kubuild/core 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -0
- package/dist/document/artboards.d.ts +113 -0
- package/dist/document/artboards.d.ts.map +1 -0
- package/dist/document/command-tree-utils.d.ts.map +1 -0
- package/dist/{commands.d.ts → document/commands.d.ts} +75 -2
- package/dist/document/commands.d.ts.map +1 -0
- package/dist/{document-utils.d.ts → document/document-utils.d.ts} +1 -3
- package/dist/document/document-utils.d.ts.map +1 -0
- package/dist/{history.d.ts → document/history.d.ts} +46 -0
- package/dist/document/history.d.ts.map +1 -0
- package/dist/document/index.d.ts +6 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/index.cjs +3755 -1660
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3666 -1605
- package/dist/index.js.map +1 -1
- package/dist/{exporter.d.ts → io/exporter.d.ts} +3 -3
- package/dist/io/exporter.d.ts.map +1 -0
- package/dist/{importer.d.ts → io/importer.d.ts} +2 -2
- package/dist/io/importer.d.ts.map +1 -0
- package/dist/io/index.d.ts +7 -0
- package/dist/io/index.d.ts.map +1 -0
- package/dist/io/load-project.d.ts +42 -0
- package/dist/io/load-project.d.ts.map +1 -0
- package/dist/io/migration.d.ts.map +1 -0
- package/dist/io/round-trip-comparator.d.ts.map +1 -0
- package/dist/io/template-utils.d.ts.map +1 -0
- package/dist/{binding-resolver.d.ts → runtime/binding-resolver.d.ts} +1 -1
- package/dist/runtime/binding-resolver.d.ts.map +1 -0
- package/dist/runtime/conditional-resolver.d.ts +45 -0
- package/dist/runtime/conditional-resolver.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/interpolator.d.ts +50 -0
- package/dist/runtime/interpolator.d.ts.map +1 -0
- package/dist/runtime/pipeline-executor.d.ts +136 -0
- package/dist/runtime/pipeline-executor.d.ts.map +1 -0
- package/dist/runtime/state-store.d.ts +128 -0
- package/dist/runtime/state-store.d.ts.map +1 -0
- package/dist/{variable-catalog.d.ts → runtime/variable-catalog.d.ts} +1 -1
- package/dist/runtime/variable-catalog.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{interfaces.d.ts → types/interfaces.d.ts} +29 -2
- package/dist/types/interfaces.d.ts.map +1 -0
- package/dist/validation/index.d.ts +5 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/project-validator.d.ts +38 -0
- package/dist/validation/project-validator.d.ts.map +1 -0
- package/dist/validation/security.d.ts.map +1 -0
- package/dist/validation/validation-engine.d.ts +39 -0
- package/dist/validation/validation-engine.d.ts.map +1 -0
- package/dist/validation/validator.d.ts.map +1 -0
- package/package.json +4 -3
- package/dist/binding-resolver.d.ts.map +0 -1
- package/dist/command-tree-utils.d.ts.map +0 -1
- package/dist/commands.d.ts.map +0 -1
- package/dist/document-utils.d.ts.map +0 -1
- package/dist/exporter.d.ts.map +0 -1
- package/dist/history.d.ts.map +0 -1
- package/dist/importer.d.ts.map +0 -1
- package/dist/interfaces.d.ts.map +0 -1
- package/dist/migration.d.ts.map +0 -1
- package/dist/round-trip-comparator.d.ts.map +0 -1
- package/dist/security.d.ts.map +0 -1
- package/dist/template-utils.d.ts.map +0 -1
- package/dist/validator.d.ts.map +0 -1
- package/dist/variable-catalog.d.ts.map +0 -1
- /package/dist/{command-tree-utils.d.ts → document/command-tree-utils.d.ts} +0 -0
- /package/dist/{migration.d.ts → io/migration.d.ts} +0 -0
- /package/dist/{round-trip-comparator.d.ts → io/round-trip-comparator.d.ts} +0 -0
- /package/dist/{template-utils.d.ts → io/template-utils.d.ts} +0 -0
- /package/dist/{security.d.ts → validation/security.d.ts} +0 -0
- /package/dist/{validator.d.ts → validation/validator.d.ts} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# @kubuild/core
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@kubuild/core)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
Framework-agnostic engine for **KUBUILD**: document tree utilities, command engine, history stack (undo/redo), Action Pipeline Executor, Runtime State Store, Validation Engine, template interpolation, migration, and export/import.
|
|
8
|
+
|
|
9
|
+
Core contains **zero UI/DOM dependencies** and runs seamlessly in Node.js, Cloudflare Workers, Electron, and the browser.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📦 Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Using pnpm (recommended)
|
|
17
|
+
pnpm add @kubuild/core @kubuild/schema
|
|
18
|
+
|
|
19
|
+
# Using npm
|
|
20
|
+
npm install @kubuild/core @kubuild/schema
|
|
21
|
+
|
|
22
|
+
# Using yarn
|
|
23
|
+
yarn add @kubuild/core @kubuild/schema
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## ✨ Features
|
|
29
|
+
|
|
30
|
+
- **Document Tree Manipulation**: Safe operations for finding, inserting, moving, cloning, and removing nodes (`findNodeById`, `insertNode`, `removeNode`, `moveNode`).
|
|
31
|
+
- **Command Engine & History**: Transactional command pattern with an undo/redo stack (`CommandEngine`, `InsertNodeCommand`, `UpdateNodePropsCommand`, `UpdateNodeStylesCommand`).
|
|
32
|
+
- **Action Pipeline Executor**: Comprehensive runner for executing multi-step action flows (`ActionPipelineExecutor`), evaluating success/error branches and conditional expressions.
|
|
33
|
+
- **Runtime State Store**: Lightweight reactive store (`RuntimeStateStore`) for managing form values, execution logs, response data, and runtime variables.
|
|
34
|
+
- **Validation Engine**: Built-in validators for form fields and models (required, email, regex, min/max length, custom rules).
|
|
35
|
+
- **Template Interpolation**: Powerful variable interpolation supporting syntax like `{{form.name}}`, `{{user.id}}`, or `{{response.data}}`.
|
|
36
|
+
- **Portable Export & Import**: Pack page documents and assets into portable `.stora` archives (compressed zip via `fflate`) and unpack them back into memory.
|
|
37
|
+
- **Security Defense**: Strict XSS prevention, safe URL sanitization, and style value validation.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🚀 Quick Usage
|
|
42
|
+
|
|
43
|
+
### Command Engine & Undo/Redo
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { CommandEngine, InsertNodeCommand } from '@kubuild/core';
|
|
47
|
+
import type { PageDocument, Node } from '@kubuild/schema';
|
|
48
|
+
|
|
49
|
+
const engine = new CommandEngine(initialPageDocument);
|
|
50
|
+
|
|
51
|
+
// Execute a command to insert a new node
|
|
52
|
+
const buttonNode: Node = {
|
|
53
|
+
id: 'btn-1',
|
|
54
|
+
type: 'button',
|
|
55
|
+
props: { label: 'Click Me' },
|
|
56
|
+
styles: { backgroundColor: '#3b82f6', color: '#ffffff' }
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
engine.execute(new InsertNodeCommand(engine.getDocument(), 'root-1', buttonNode));
|
|
60
|
+
|
|
61
|
+
// Undo the insertion
|
|
62
|
+
engine.undo();
|
|
63
|
+
|
|
64
|
+
// Redo the insertion
|
|
65
|
+
engine.redo();
|
|
66
|
+
|
|
67
|
+
const currentDoc: PageDocument = engine.getDocument();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Action Pipeline Execution & Interpolation
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import {
|
|
74
|
+
ActionPipelineExecutor,
|
|
75
|
+
RuntimeStateStore,
|
|
76
|
+
interpolateTemplate
|
|
77
|
+
} from '@kubuild/core';
|
|
78
|
+
import type { ActionPipeline } from '@kubuild/schema';
|
|
79
|
+
|
|
80
|
+
// 1. Initialize State Store
|
|
81
|
+
const stateStore = new RuntimeStateStore({
|
|
82
|
+
form: { email: 'user@example.com', name: 'Alex' },
|
|
83
|
+
user: { role: 'admin' }
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// 2. Interpolate template string
|
|
87
|
+
const greeting = interpolateTemplate('Hello {{form.name}}! Role: {{user.role}}', stateStore.getState());
|
|
88
|
+
console.log(greeting); // "Hello Alex! Role: admin"
|
|
89
|
+
|
|
90
|
+
// 3. Execute Pipeline
|
|
91
|
+
const executor = new ActionPipelineExecutor({
|
|
92
|
+
stateStore,
|
|
93
|
+
runners: {
|
|
94
|
+
async apiRequest(step, context) {
|
|
95
|
+
const response = await fetch(step.config.url, { method: step.config.method });
|
|
96
|
+
return await response.json();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const result = await executor.execute(pipelineDefinition);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Exporting & Importing `.stora` Files
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { exportStoraArchive, importStoraArchive } from '@kubuild/core';
|
|
108
|
+
|
|
109
|
+
// Export document to binary .stora buffer (zip)
|
|
110
|
+
const storaBuffer: Uint8Array = await exportStoraArchive(pageDocument, {
|
|
111
|
+
includeAssets: true
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Import .stora buffer back into validated PageDocument
|
|
115
|
+
const importedDocument = await importStoraArchive(storaBuffer);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 📄 License
|
|
121
|
+
|
|
122
|
+
MIT © [KUBUILD](https://github.com/kustora/kubuild)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Artboard, Node, PageDocument, ProjectDocument } from '@kubuild/schema';
|
|
2
|
+
export type ArtboardChangeType = 'ARTBOARD_ADDED' | 'ARTBOARD_REMOVED' | 'ARTBOARD_RENAMED' | 'ACTIVE_ARTBOARD_CHANGED' | 'NODE_EXTRACTED_TO_ARTBOARD';
|
|
3
|
+
export interface ArtboardChangeEvent {
|
|
4
|
+
type: ArtboardChangeType;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
artboardId: string;
|
|
7
|
+
/** Source artboard, for operations that move content between artboards. */
|
|
8
|
+
sourceArtboardId?: string;
|
|
9
|
+
nodeId?: string;
|
|
10
|
+
payload?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Mirrors CommandResult from commands.ts, but at the project (multi-artboard) level.
|
|
14
|
+
* Node-level commands keep returning CommandResult and keep operating on a single
|
|
15
|
+
* PageDocument, unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export interface ProjectCommandResult {
|
|
18
|
+
project: ProjectDocument;
|
|
19
|
+
event: ArtboardChangeEvent;
|
|
20
|
+
}
|
|
21
|
+
export interface AddArtboardParams {
|
|
22
|
+
artboard: Artboard;
|
|
23
|
+
index?: number;
|
|
24
|
+
/** Make the newly added artboard active (default: true). */
|
|
25
|
+
activate?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface RemoveArtboardParams {
|
|
28
|
+
artboardId: string;
|
|
29
|
+
}
|
|
30
|
+
export interface RenameArtboardParams {
|
|
31
|
+
artboardId: string;
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SetActiveArtboardParams {
|
|
35
|
+
artboardId: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ExtractNodeToArtboardParams {
|
|
38
|
+
/** Artboard currently holding the node. */
|
|
39
|
+
artboardId: string;
|
|
40
|
+
/** Node whose subtree becomes the new artboard's content. */
|
|
41
|
+
nodeId: string;
|
|
42
|
+
/** Optional explicit name for the new artboard (defaults to the node type). */
|
|
43
|
+
name?: string;
|
|
44
|
+
/** Optional explicit id for the new artboard. */
|
|
45
|
+
newArtboardId?: string;
|
|
46
|
+
/** Make the new artboard active (default: false — authors usually keep editing the page). */
|
|
47
|
+
activate?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Collect every node id used anywhere in the project (across all artboards).
|
|
51
|
+
* Node ids must be unique project-wide so that content can move between artboards
|
|
52
|
+
* without silently colliding.
|
|
53
|
+
*/
|
|
54
|
+
export declare function collectProjectNodeIds(project: ProjectDocument): Set<string>;
|
|
55
|
+
export declare function findArtboardById(project: ProjectDocument, artboardId: string): Artboard | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the component artboard an `open_modal` / `close_modal` action targets.
|
|
58
|
+
* ModalManager keys off plain strings, so a trigger in one artboard can address
|
|
59
|
+
* content in another with no additional wiring.
|
|
60
|
+
*/
|
|
61
|
+
export declare function findArtboardByTriggerId(project: ProjectDocument, triggerId: string): Artboard | undefined;
|
|
62
|
+
export declare function getActiveArtboard(project: ProjectDocument): Artboard | undefined;
|
|
63
|
+
export declare function getPageArtboards(project: ProjectDocument): Artboard[];
|
|
64
|
+
export declare function getComponentArtboards(project: ProjectDocument): Artboard[];
|
|
65
|
+
export interface CreateArtboardOptions {
|
|
66
|
+
id?: string;
|
|
67
|
+
slug?: string;
|
|
68
|
+
triggerId?: string;
|
|
69
|
+
viewport?: Artboard['viewport'];
|
|
70
|
+
width?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build a page artboard around a fresh blank document.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createPageArtboard(name?: string, options?: CreateArtboardOptions): Artboard;
|
|
76
|
+
/**
|
|
77
|
+
* Wrap an existing node as the sole child of a synthetic `page` root and return it as a
|
|
78
|
+
* component artboard. The synthetic root exists so each artboard's `document` stays a
|
|
79
|
+
* fully valid PageDocument, meaning no existing command, validator, or history code
|
|
80
|
+
* needs to know that component artboards exist at all.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createComponentArtboard(node: Node, options?: CreateArtboardOptions & {
|
|
83
|
+
name?: string;
|
|
84
|
+
rootId?: string;
|
|
85
|
+
}): Artboard;
|
|
86
|
+
/**
|
|
87
|
+
* Create a project containing a single blank page artboard.
|
|
88
|
+
*/
|
|
89
|
+
export declare function createBlankProject(title?: string): ProjectDocument;
|
|
90
|
+
export declare function addArtboard(project: ProjectDocument, params: AddArtboardParams): ProjectCommandResult;
|
|
91
|
+
export declare function removeArtboard(project: ProjectDocument, params: RemoveArtboardParams): ProjectCommandResult;
|
|
92
|
+
export declare function renameArtboard(project: ProjectDocument, params: RenameArtboardParams): ProjectCommandResult;
|
|
93
|
+
export declare function setActiveArtboard(project: ProjectDocument, params: SetActiveArtboardParams): ProjectCommandResult;
|
|
94
|
+
/**
|
|
95
|
+
* Detach a node's subtree into its own component artboard, leaving an
|
|
96
|
+
* `artboard-reference` stub at the original position.
|
|
97
|
+
*
|
|
98
|
+
* The stub matters: selection, move/delete, copy/paste, the Layers panel, and history
|
|
99
|
+
* diffing all walk nodes that are physically present in the tree, so a bare deletion would
|
|
100
|
+
* leave the page with no visible, selectable anchor for "this surface opens artboard X"
|
|
101
|
+
* and would strand the trigger's id with nothing pointing back at it.
|
|
102
|
+
*
|
|
103
|
+
* Undo scoping caveat (Phase 1): the editor's history is per-document, so this operation —
|
|
104
|
+
* which spans two artboards — is applied as one atomic project-level step rather than being
|
|
105
|
+
* finely undoable inside each artboard's own stack.
|
|
106
|
+
*/
|
|
107
|
+
export declare function extractNodeToArtboard(project: ProjectDocument, params: ExtractNodeToArtboardParams): ProjectCommandResult;
|
|
108
|
+
/**
|
|
109
|
+
* Replace one artboard's document wholesale. Used by the editor when committing the
|
|
110
|
+
* single active PageDocument it holds back into the project.
|
|
111
|
+
*/
|
|
112
|
+
export declare function updateArtboardDocument(project: ProjectDocument, artboardId: string, document: PageDocument): ProjectDocument;
|
|
113
|
+
//# sourceMappingURL=artboards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artboards.d.ts","sourceRoot":"","sources":["../../src/document/artboards.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,IAAI,EACJ,YAAY,EACZ,eAAe,EAMhB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,kBA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;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc3E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,CAgBrE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAgB5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAExD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAenF;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,IAAI,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EACvC,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACxB,mBAAmB,CAyBrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PageDocument, Node, ResponsiveStyles, StyleDefinition, AnimationConfig } from '@kubuild/schema';
|
|
2
|
-
export type DocumentChangeType = 'NODE_INSERTED' | 'NODE_MOVED' | 'PROPS_UPDATED' | 'STYLE_UPDATED' | 'ANIMATION_UPDATED' | 'NODE_REMOVED' | 'NODE_DUPLICATED';
|
|
1
|
+
import { PageDocument, Node, ResponsiveStyles, StyleDefinition, AnimationConfig, ActionPipeline, FormConfig } from '@kubuild/schema';
|
|
2
|
+
export type DocumentChangeType = 'NODE_INSERTED' | 'NODE_MOVED' | 'PROPS_UPDATED' | 'STYLE_UPDATED' | 'ANIMATION_UPDATED' | 'ACTIONS_UPDATED' | 'FORM_CONFIG_UPDATED' | 'NODE_REMOVED' | 'NODE_DUPLICATED' | 'NODE_WRAPPED' | 'NODE_UNGROUPED' | 'NODE_REPLACED';
|
|
3
3
|
export interface DocumentChangeEvent {
|
|
4
4
|
type: DocumentChangeType;
|
|
5
5
|
timestamp: string;
|
|
@@ -61,6 +61,28 @@ export interface DuplicateNodeParams {
|
|
|
61
61
|
index?: number;
|
|
62
62
|
idGenerator?: (oldId: string) => string;
|
|
63
63
|
}
|
|
64
|
+
export interface WrapNodeIntoFrameParams {
|
|
65
|
+
/** Single node ID to wrap into a frame. */
|
|
66
|
+
nodeId?: string;
|
|
67
|
+
/** Multiple node IDs to wrap into a frame. */
|
|
68
|
+
nodeIds?: string[] | string;
|
|
69
|
+
/** Optional custom ID for the created flex frame container. */
|
|
70
|
+
frameId?: string;
|
|
71
|
+
/** Optional custom props for the flex frame container. */
|
|
72
|
+
frameProps?: Record<string, unknown>;
|
|
73
|
+
/** Optional custom responsive styles for the flex frame container. */
|
|
74
|
+
frameStyles?: ResponsiveStyles;
|
|
75
|
+
}
|
|
76
|
+
export interface UngroupNodeFrameParams {
|
|
77
|
+
/** Node ID of the flex container to unwrap. */
|
|
78
|
+
nodeId: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ReplaceNodeParams {
|
|
81
|
+
/** ID of the existing node to replace. */
|
|
82
|
+
nodeId: string;
|
|
83
|
+
/** Full replacement node — its `id` must match `nodeId` (identity is never silently changed). */
|
|
84
|
+
node: Node;
|
|
85
|
+
}
|
|
64
86
|
/**
|
|
65
87
|
* 1. Insert a node into a target parent node.
|
|
66
88
|
* Returns a new PageDocument and a NODE_INSERTED event.
|
|
@@ -111,4 +133,55 @@ export interface UpdateAnimationParams {
|
|
|
111
133
|
* Returns a new PageDocument and an ANIMATION_UPDATED event.
|
|
112
134
|
*/
|
|
113
135
|
export declare function updateAnimation(document: PageDocument, params: UpdateAnimationParams): CommandResult;
|
|
136
|
+
export interface UpdateActionsParams {
|
|
137
|
+
nodeId: string;
|
|
138
|
+
actions: ActionPipeline[] | null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 8. Update the action pipelines of an existing node.
|
|
142
|
+
* Returns a new PageDocument and an ACTIONS_UPDATED event.
|
|
143
|
+
*/
|
|
144
|
+
export declare function updateActions(document: PageDocument, params: UpdateActionsParams): CommandResult;
|
|
145
|
+
export interface UpdateFormConfigParams {
|
|
146
|
+
nodeId: string;
|
|
147
|
+
formConfig: Partial<FormConfig> | null;
|
|
148
|
+
/**
|
|
149
|
+
* If true (default), shallow merges new formConfig properties with existing config.
|
|
150
|
+
* If false, replaces the formConfig with the provided object.
|
|
151
|
+
* If formConfig is null, removes the form configuration from the node.
|
|
152
|
+
*/
|
|
153
|
+
merge?: boolean;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 9. Update the form configuration of an existing node.
|
|
157
|
+
* Returns a new PageDocument and a FORM_CONFIG_UPDATED event.
|
|
158
|
+
*/
|
|
159
|
+
export declare function updateFormConfig(document: PageDocument, params: UpdateFormConfigParams): CommandResult;
|
|
160
|
+
/**
|
|
161
|
+
* 10. Wrap specified node(s) into a new flex container node at the same position in the parent.
|
|
162
|
+
* Preserves sibling ordering and returns a new PageDocument and a NODE_WRAPPED event.
|
|
163
|
+
* Full undo/redo compatibility with DocumentHistoryManager. (STORA-105)
|
|
164
|
+
*/
|
|
165
|
+
export declare function wrapNodeIntoFrame(document: PageDocument, params: WrapNodeIntoFrameParams): CommandResult;
|
|
166
|
+
/**
|
|
167
|
+
* 11. Unwrap a flex frame container, moving all of its children to its parent at its position,
|
|
168
|
+
* and removing the container.
|
|
169
|
+
* Returns a new PageDocument and a NODE_UNGROUPED event.
|
|
170
|
+
* Full undo/redo compatibility with DocumentHistoryManager. (STORA-106)
|
|
171
|
+
*/
|
|
172
|
+
export declare function ungroupNodeFrame(document: PageDocument, params: UngroupNodeFrameParams): CommandResult;
|
|
173
|
+
/**
|
|
174
|
+
* 12. Replace an existing node's entire subtree (props, styles, children, animation,
|
|
175
|
+
* actions, formConfig) in place, preserving its position in the parent.
|
|
176
|
+
*
|
|
177
|
+
* Used by AI "enhance" flows (STORA-514) when a validated candidate node differs
|
|
178
|
+
* structurally from the original (e.g. AI regenerated nested children) — a change
|
|
179
|
+
* `updateProps`/`updateStyle` alone can't express since they only ever touch one
|
|
180
|
+
* property bag at a time. The replacement node's `id` must match `nodeId`; this command
|
|
181
|
+
* never lets identity (id) drift, the same guarantee `@kubuild/ai`'s
|
|
182
|
+
* `normalizeAndValidateRefactoredNode` already enforces upstream on `type`/`id`.
|
|
183
|
+
*
|
|
184
|
+
* Returns a new PageDocument and a NODE_REPLACED event.
|
|
185
|
+
*/
|
|
186
|
+
export declare function replaceNode(document: PageDocument, params: ReplaceNodeParams): CommandResult;
|
|
114
187
|
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/document/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,gBAAgB,EAChB,eAAe,EAGf,eAAe,EAEf,cAAc,EAEd,UAAU,EAEX,MAAM,iBAAiB,CAAC;AASzB,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,YAAY,GACZ,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,iBAAiB,GACjB,qBAAqB,GACrB,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,eAAe,CAAC;AAEpB,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,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G,IAAI,CAAC;IAC3C;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,qBAAqB,GAC5B,aAAa,CAmCf;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,mBAAmB,GAC1B,aAAa,CA+Bf;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,sBAAsB,GAC7B,aAAa,CAsCf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,uBAAuB,GAC9B,aAAa,CAyGf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,sBAAsB,GAC7B,aAAa,CAkDf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,iBAAiB,GACxB,aAAa,CAuDf"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { PageDocument, Node } from '@kubuild/schema';
|
|
2
|
-
import type { ComponentRegistryLike } from '
|
|
3
|
-
export { validateDocument } from './validator';
|
|
4
|
-
export type { DocumentValidationResult, DocumentValidationError, DocumentValidationErrorCode, ValidationOptions, ComponentDefinitionLike, ComponentRegistryLike, } from './validator';
|
|
2
|
+
import type { ComponentRegistryLike } from '../validation/validator';
|
|
5
3
|
export declare function createBlankDocument(title?: string): PageDocument;
|
|
6
4
|
export declare function findNodeById(rootNode: Node, targetId: string): Node | null;
|
|
7
5
|
export interface CollectedAssetReference {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-utils.d.ts","sourceRoot":"","sources":["../../src/document/document-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAe,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,wBAAgB,mBAAmB,CAAC,KAAK,SAAkB,GAAG,YAAY,CAsBzE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAQ1E;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QACT,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,IAAI,GAAG,uBAAuB,EAAE,CAkDhF;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,IAAI,EACd,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,gBAAgB,CA8BlB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,IAAI,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAClD,MAAM,CA+CR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAClD,YAAY,CAKd;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,IAAI,EACd,QAAQ,CAAC,EAAE,qBAAqB,EAChC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAClC,wBAAwB,EAAE,CA6C5B"}
|
|
@@ -30,6 +30,8 @@ export declare class HistoryEngine<T = PageDocument> {
|
|
|
30
30
|
private current;
|
|
31
31
|
private future;
|
|
32
32
|
private readonly maxHistory;
|
|
33
|
+
private transactionDepth;
|
|
34
|
+
private transactionAnchor;
|
|
33
35
|
constructor(initialState: T, options?: HistoryOptions);
|
|
34
36
|
/**
|
|
35
37
|
* Get the current active state (returns an immutable clone).
|
|
@@ -58,8 +60,40 @@ export declare class HistoryEngine<T = PageDocument> {
|
|
|
58
60
|
/**
|
|
59
61
|
* Push a new state.
|
|
60
62
|
* Clears the redo stack and shifts oldest past entries if maxHistory is exceeded.
|
|
63
|
+
*
|
|
64
|
+
* STORA-510: while a transaction is active (see `beginTransaction`), pushes update
|
|
65
|
+
* `current` in place without creating an individual undo entry — the whole group
|
|
66
|
+
* collapses into one entry when `endTransaction()` is called.
|
|
61
67
|
*/
|
|
62
68
|
push(nextState: T, event?: DocumentChangeEvent): void;
|
|
69
|
+
/**
|
|
70
|
+
* Begin a grouped-history transaction (STORA-510).
|
|
71
|
+
*
|
|
72
|
+
* Every `push()` made between `beginTransaction()` and the matching outermost
|
|
73
|
+
* `endTransaction()` updates the live state immediately (so `present`/`getState()`
|
|
74
|
+
* always reflect the latest change), but no individual undo entry is recorded until
|
|
75
|
+
* the transaction ends. This is how a multi-step action (e.g. one `streamPage`
|
|
76
|
+
* generation session inserting several sections) collapses into a single undo step.
|
|
77
|
+
*
|
|
78
|
+
* Transactions may be nested; only the outermost `beginTransaction`/`endTransaction`
|
|
79
|
+
* pair has any effect, so a batching caller can safely wrap calls that themselves
|
|
80
|
+
* might also start their own (nested) transaction.
|
|
81
|
+
*/
|
|
82
|
+
beginTransaction(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Ends the current transaction (see `beginTransaction`). Once the outermost
|
|
85
|
+
* transaction ends, the state as it was immediately before `beginTransaction()` is
|
|
86
|
+
* pushed as a single past entry (exactly as one `push()` would) and the redo stack
|
|
87
|
+
* is cleared — unless nothing actually changed during the transaction, in which case
|
|
88
|
+
* this is a no-op and no empty undo entry is created.
|
|
89
|
+
*
|
|
90
|
+
* Calling `endTransaction()` without a matching `beginTransaction()` is a no-op.
|
|
91
|
+
*/
|
|
92
|
+
endTransaction(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Whether a grouped-history transaction is currently active.
|
|
95
|
+
*/
|
|
96
|
+
get inTransaction(): boolean;
|
|
63
97
|
/**
|
|
64
98
|
* Undo to the previous state.
|
|
65
99
|
* Returns the restored state, or undefined if undo is not possible.
|
|
@@ -100,6 +134,18 @@ export declare class DocumentHistoryManager {
|
|
|
100
134
|
execute(executor: (currentDoc: PageDocument) => CommandResult): CommandResult;
|
|
101
135
|
undo(): PageDocument | undefined;
|
|
102
136
|
redo(): PageDocument | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Begin a grouped-history transaction (STORA-510) — see `HistoryEngine.beginTransaction`.
|
|
139
|
+
* Every `execute()` call made until the matching `endTransaction()` updates
|
|
140
|
+
* `document` immediately but is collapsed into a single undo entry.
|
|
141
|
+
*/
|
|
142
|
+
beginTransaction(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Ends a grouped-history transaction started with `beginTransaction()` — see
|
|
145
|
+
* `HistoryEngine.endTransaction`.
|
|
146
|
+
*/
|
|
147
|
+
endTransaction(): void;
|
|
148
|
+
get inTransaction(): boolean;
|
|
103
149
|
reset(newDocument: PageDocument): void;
|
|
104
150
|
clear(): void;
|
|
105
151
|
getState(): HistoryState<PageDocument>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/document/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhE,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,aAAa,CAAC,CAAC,GAAG,YAAY;IACzC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CA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