@kubuild/core 0.0.1 → 0.1.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/LICENSE +21 -0
- package/dist/commands.d.ts +17 -2
- package/dist/commands.d.ts.map +1 -1
- package/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kustora
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/commands.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PageDocument, Node, ResponsiveStyles, StyleDefinition } from '@kubuild/schema';
|
|
2
|
-
export type DocumentChangeType = 'NODE_INSERTED' | 'NODE_MOVED' | 'PROPS_UPDATED' | 'STYLE_UPDATED' | 'NODE_REMOVED' | 'NODE_DUPLICATED';
|
|
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';
|
|
3
3
|
export interface DocumentChangeEvent {
|
|
4
4
|
type: DocumentChangeType;
|
|
5
5
|
timestamp: string;
|
|
@@ -96,4 +96,19 @@ export declare function removeNode(document: PageDocument, params: RemoveNodePar
|
|
|
96
96
|
* Returns a new PageDocument and a NODE_DUPLICATED event.
|
|
97
97
|
*/
|
|
98
98
|
export declare function duplicateNode(document: PageDocument, params: DuplicateNodeParams): CommandResult;
|
|
99
|
+
export interface UpdateAnimationParams {
|
|
100
|
+
nodeId: string;
|
|
101
|
+
animation: Partial<AnimationConfig> | null;
|
|
102
|
+
/**
|
|
103
|
+
* If true (default), shallow merges new animation properties with existing animation config.
|
|
104
|
+
* If false, replaces the animation config with the provided object.
|
|
105
|
+
* If animation is null, removes the animation configuration from the node.
|
|
106
|
+
*/
|
|
107
|
+
merge?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 7. Update the animation configuration of an existing node.
|
|
111
|
+
* Returns a new PageDocument and an ANIMATION_UPDATED event.
|
|
112
|
+
*/
|
|
113
|
+
export declare function updateAnimation(document: PageDocument, params: UpdateAnimationParams): CommandResult;
|
|
99
114
|
//# sourceMappingURL=commands.d.ts.map
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"m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S,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,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"}
|
package/dist/index.cjs
CHANGED
|
@@ -80,6 +80,7 @@ __export(index_exports, {
|
|
|
80
80
|
sanitizeUrl: () => sanitizeUrl,
|
|
81
81
|
saveDraftAsTemplate: () => saveDraftAsTemplate,
|
|
82
82
|
sha256Sync: () => sha256Sync,
|
|
83
|
+
updateAnimation: () => updateAnimation,
|
|
83
84
|
updateProps: () => updateProps,
|
|
84
85
|
updateStyle: () => updateStyle,
|
|
85
86
|
validateDocument: () => validateDocument,
|
|
@@ -1364,6 +1365,36 @@ function duplicateNode(document, params) {
|
|
|
1364
1365
|
}
|
|
1365
1366
|
};
|
|
1366
1367
|
}
|
|
1368
|
+
function updateAnimation(document, params) {
|
|
1369
|
+
const { nodeId, animation, merge = true } = params;
|
|
1370
|
+
const newDoc = deepClone(document);
|
|
1371
|
+
const loc = findNodeLocation(newDoc.document, nodeId);
|
|
1372
|
+
if (!loc) {
|
|
1373
|
+
throw new Error(`Cannot update animation: Node with ID "${nodeId}" not found in document.`);
|
|
1374
|
+
}
|
|
1375
|
+
const targetNode = loc.node;
|
|
1376
|
+
const previousAnimation = targetNode.animation ? deepClone(targetNode.animation) : void 0;
|
|
1377
|
+
if (animation === null) {
|
|
1378
|
+
delete targetNode.animation;
|
|
1379
|
+
} else {
|
|
1380
|
+
const currentAnimation = targetNode.animation ? deepClone(targetNode.animation) : {};
|
|
1381
|
+
const candidate = merge ? { ...currentAnimation, ...deepClone(animation) } : deepClone(animation);
|
|
1382
|
+
targetNode.animation = import_schema4.AnimationConfigSchema.parse(candidate);
|
|
1383
|
+
}
|
|
1384
|
+
return {
|
|
1385
|
+
document: newDoc,
|
|
1386
|
+
event: {
|
|
1387
|
+
type: "ANIMATION_UPDATED",
|
|
1388
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1389
|
+
nodeId,
|
|
1390
|
+
parentId: loc.parent ? loc.parent.id : void 0,
|
|
1391
|
+
payload: {
|
|
1392
|
+
animation: targetNode.animation,
|
|
1393
|
+
previousAnimation
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1367
1398
|
|
|
1368
1399
|
// src/history.ts
|
|
1369
1400
|
var DEFAULT_MAX_HISTORY = 50;
|
|
@@ -3677,6 +3708,7 @@ function areNodeIdsCompletelyDistinct(docA, docB) {
|
|
|
3677
3708
|
sanitizeUrl,
|
|
3678
3709
|
saveDraftAsTemplate,
|
|
3679
3710
|
sha256Sync,
|
|
3711
|
+
updateAnimation,
|
|
3680
3712
|
updateProps,
|
|
3681
3713
|
updateStyle,
|
|
3682
3714
|
validateDocument,
|