@retikz/core 0.3.0-alpha.4 → 0.3.0-alpha.5
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/dist/es/compile/compile.d.ts +1 -1
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +35 -3
- package/dist/es/compile/node.d.ts +3 -1
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +3 -0
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +2 -0
- package/dist/es/index.d.ts +4 -1
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +3 -1
- package/dist/es/ir/animation.d.ts +218 -0
- package/dist/es/ir/animation.d.ts.map +1 -0
- package/dist/es/ir/animation.js +118 -0
- package/dist/es/ir/index.d.ts +1 -0
- package/dist/es/ir/index.d.ts.map +1 -1
- package/dist/es/ir/node.d.ts +176 -20
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +2 -0
- package/dist/es/ir/path/arrow.d.ts +24 -24
- package/dist/es/ir/path/path.d.ts +212 -56
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +2 -0
- package/dist/es/ir/scene.d.ts +156 -0
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/ir/scene.js +3 -1
- package/dist/es/ir/scope.d.ts +834 -196
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +6 -2
- package/dist/es/presets/animation.d.ts +123 -0
- package/dist/es/presets/animation.d.ts.map +1 -0
- package/dist/es/presets/animation.js +272 -0
- package/dist/es/presets/index.d.ts +3 -0
- package/dist/es/presets/index.d.ts.map +1 -0
- package/dist/es/primitive/ellipse.d.ts +3 -0
- package/dist/es/primitive/ellipse.d.ts.map +1 -1
- package/dist/es/primitive/group.d.ts +3 -0
- package/dist/es/primitive/group.d.ts.map +1 -1
- package/dist/es/primitive/path.d.ts +3 -0
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +3 -0
- package/dist/es/primitive/rect.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +3 -0
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/es/primitive/text.d.ts +3 -0
- package/dist/es/primitive/text.d.ts.map +1 -1
- package/dist/lib/compile/compile.cjs +35 -3
- package/dist/lib/compile/compile.d.ts +1 -1
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +3 -0
- package/dist/lib/compile/node.d.ts +3 -1
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +2 -0
- package/dist/lib/compile/path/index.d.ts.map +1 -1
- package/dist/lib/index.cjs +27 -0
- package/dist/lib/index.d.ts +4 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/animation.cjs +127 -0
- package/dist/lib/ir/animation.d.ts +218 -0
- package/dist/lib/ir/animation.d.ts.map +1 -0
- package/dist/lib/ir/index.d.ts +1 -0
- package/dist/lib/ir/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +2 -0
- package/dist/lib/ir/node.d.ts +176 -20
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.d.ts +24 -24
- package/dist/lib/ir/path/path.cjs +2 -0
- package/dist/lib/ir/path/path.d.ts +212 -56
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/scene.cjs +3 -1
- package/dist/lib/ir/scene.d.ts +156 -0
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +6 -2
- package/dist/lib/ir/scope.d.ts +834 -196
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/presets/animation.cjs +286 -0
- package/dist/lib/presets/animation.d.ts +123 -0
- package/dist/lib/presets/animation.d.ts.map +1 -0
- package/dist/lib/presets/index.d.ts +3 -0
- package/dist/lib/presets/index.d.ts.map +1 -0
- package/dist/lib/primitive/ellipse.d.ts +3 -0
- package/dist/lib/primitive/ellipse.d.ts.map +1 -1
- package/dist/lib/primitive/group.d.ts +3 -0
- package/dist/lib/primitive/group.d.ts.map +1 -1
- package/dist/lib/primitive/path.d.ts +3 -0
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +3 -0
- package/dist/lib/primitive/rect.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +3 -0
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/dist/lib/primitive/text.d.ts +3 -0
- package/dist/lib/primitive/text.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ export type CompileWarning = {
|
|
|
12
12
|
* 警告类型代码(机器可读)
|
|
13
13
|
* @description 用户可按 code 分支处理;未来 alpha 加新 code 不破坏调用方
|
|
14
14
|
*/
|
|
15
|
-
code: 'UNRESOLVED_NODE_REFERENCE' | 'PATH_TOO_SHORT' | 'ANCHOR_RESOLUTION_FAILED' | 'OFFSET_BASE_UNRESOLVED' | 'POLAR_ORIGIN_UNRESOLVED' | 'AT_TARGET_UNRESOLVED' | 'RELATIVE_INITIAL_NO_PREV_END' | 'BBOX_EXTREME_INPUT' | 'DUPLICATE_NODE_ID' | 'SHAPE_OVERRIDES_BUILTIN' | 'ARROW_OVERRIDES_BUILTIN' | 'PATTERN_OVERRIDES_BUILTIN' | 'COMPOSITE_NOT_REGISTERED' | (string & {});
|
|
15
|
+
code: 'UNRESOLVED_NODE_REFERENCE' | 'PATH_TOO_SHORT' | 'ANCHOR_RESOLUTION_FAILED' | 'OFFSET_BASE_UNRESOLVED' | 'POLAR_ORIGIN_UNRESOLVED' | 'AT_TARGET_UNRESOLVED' | 'RELATIVE_INITIAL_NO_PREV_END' | 'BBOX_EXTREME_INPUT' | 'DUPLICATE_NODE_ID' | 'SHAPE_OVERRIDES_BUILTIN' | 'ARROW_OVERRIDES_BUILTIN' | 'PATTERN_OVERRIDES_BUILTIN' | 'COMPOSITE_NOT_REGISTERED' | 'ANIMATION_INVALID_PROPERTY' | (string & {});
|
|
16
16
|
/** 人类可读消息(英文) */
|
|
17
17
|
message: string;
|
|
18
18
|
/** IR locator 路径(jq-like,如 `'children[3].path.children[1].to'`) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAA0D,MAAM,OAAO,CAAC;AACxF,OAAO,KAAK,EAAa,KAAK,EAA6B,MAAM,cAAc,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAwBzD,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AA6CrE,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,IAAI,EACA,2BAA2B,GAC3B,gBAAgB,GAChB,0BAA0B,GAC1B,wBAAwB,GACxB,yBAAyB,GACzB,sBAAsB,GACtB,8BAA8B,GAC9B,oBAAoB,GACpB,mBAAmB,GACnB,yBAAyB,GACzB,yBAAyB,GACzB,2BAA2B,GAC3B,0BAA0B,GAC1B,4BAA4B,GAC5B,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAClB,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG;IAC3B,oCAAoC;IACpC,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7C;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACzD;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACxC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAsLF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KA6WrE,CAAC"}
|
|
@@ -95,6 +95,26 @@ var defaultWarnDispatcher = (warning) => {
|
|
|
95
95
|
if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
|
|
96
96
|
console.warn(`[retikz] ${warning.code} at ${warning.path}: ${warning.message}`);
|
|
97
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* 校验 animation tracks 的 viewBox⇔根 约束(schema 上下文无关、分不清元素 vs 根,故在此 compile 层做)
|
|
100
|
+
* @description `viewBox`(镜头)只在 scene 根合法、元素级非法;scene 根只接受 `viewBox`。违例 track → `warn(ANIMATION_INVALID_PROPERTY)` + drop(不丢图、不影响其余 track)。全空返回 undefined(不 stamp 空数组)。
|
|
101
|
+
*/
|
|
102
|
+
var filterAnimations = (tracks, context, onWarn, irPath) => {
|
|
103
|
+
if (tracks === void 0) return void 0;
|
|
104
|
+
const kept = tracks.filter((track, index) => {
|
|
105
|
+
const isViewBox = track.property === "viewBox";
|
|
106
|
+
if (!(context === "root" ? isViewBox : !isViewBox)) {
|
|
107
|
+
onWarn({
|
|
108
|
+
code: "ANIMATION_INVALID_PROPERTY",
|
|
109
|
+
message: context === "root" ? `Scene-root animation must use the "viewBox" property (camera); got "${track.property}". Track dropped.` : `Animation property "viewBox" is camera-only (scene root), not valid on an element. Track dropped.`,
|
|
110
|
+
path: `${irPath}.animations[${index}]`
|
|
111
|
+
});
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
return kept.length > 0 ? kept : void 0;
|
|
117
|
+
};
|
|
98
118
|
var makePathPlaceholder = () => ({ type: "path-placeholder" });
|
|
99
119
|
/** 把内部 sink 收窄回公开 ScenePrimitive[]:占位已全部回填(compileToScene 末端 placeholderBalance 无条件校验兜底) */
|
|
100
120
|
var sealSink = (sink) => sink;
|
|
@@ -253,7 +273,11 @@ var compileToScene = (ir, options = {}) => {
|
|
|
253
273
|
const child = children[i];
|
|
254
274
|
if ("namespace" in child) throw new Error(`Unexpected composite node '${child.namespace}.${child.type}' reached compile; composites must be lowered via lowerComposites first.`);
|
|
255
275
|
if (child.type === "node") {
|
|
256
|
-
const
|
|
276
|
+
const effectiveNode = resolveNodeStyle(child, styleStack);
|
|
277
|
+
const layout = layoutNode({
|
|
278
|
+
...effectiveNode,
|
|
279
|
+
animations: filterAnimations(effectiveNode.animations, "element", onWarn, `${locatorPrefix}children[${i}].node`)
|
|
280
|
+
}, measureText, nameStack, nodeDistance, chain, resolveLabelDefault(styleStack), effectiveShapes, refPointOfTarget);
|
|
257
281
|
const globalLayout = chain.length === 0 ? layout : projectLayoutToGlobal(layout, chain);
|
|
258
282
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
259
283
|
for (const prim of emitNodePrimitives(layout, round, paint.resolve)) {
|
|
@@ -317,13 +341,19 @@ var compileToScene = (ir, options = {}) => {
|
|
|
317
341
|
};
|
|
318
342
|
if (child.id !== void 0) group.id = child.id;
|
|
319
343
|
if (child.meta !== void 0) group.meta = child.meta;
|
|
344
|
+
const scopeAnimations = filterAnimations(child.animations, "element", onWarn, `${locatorPrefix}children[${i}].scope`);
|
|
345
|
+
if (scopeAnimations !== void 0) group.animations = scopeAnimations;
|
|
320
346
|
if (hasOwnTransforms) group.transforms = [...ownTransforms];
|
|
321
347
|
if (child.clip !== void 0) group.clipRef = clip.resolve(child.clip);
|
|
322
348
|
sink.push(group);
|
|
323
349
|
if (child.zIndex !== void 0) zIndexOf.set(group, child.zIndex);
|
|
324
350
|
} else {
|
|
351
|
+
const effectivePath = resolveEffectivePath(child, styleStack);
|
|
325
352
|
const pending = {
|
|
326
|
-
path:
|
|
353
|
+
path: {
|
|
354
|
+
...effectivePath,
|
|
355
|
+
animations: filterAnimations(effectivePath.animations, "element", onWarn, `${locatorPrefix}children[${i}].path`)
|
|
356
|
+
},
|
|
327
357
|
irPath: `${locatorPrefix}children[${i}].path`,
|
|
328
358
|
scopeChain: chain,
|
|
329
359
|
zIndex: child.zIndex
|
|
@@ -349,10 +379,12 @@ var compileToScene = (ir, options = {}) => {
|
|
|
349
379
|
throw new Error(`internal: ${placeholderBalance} unresolved path placeholder(s) leaked into Scene output${detail}`);
|
|
350
380
|
}
|
|
351
381
|
const resources = [...paint.resources(), ...clip.resources()];
|
|
382
|
+
const rootAnimations = filterAnimations(loweredIr.animations, "root", onWarn, "scene");
|
|
352
383
|
return {
|
|
353
384
|
primitives: stableSortByZIndex(sealSink(primitives)),
|
|
354
385
|
layout: loweredIr.viewBox !== void 0 ? viewBoxToLayout(loweredIr.viewBox, round) : assertFiniteLayout(computeLayout(allPoints, layoutPadding, round)),
|
|
355
|
-
...resources.length > 0 ? { resources } : {}
|
|
386
|
+
...resources.length > 0 ? { resources } : {},
|
|
387
|
+
...rootAnimations !== void 0 ? { animations: rootAnimations } : {}
|
|
356
388
|
};
|
|
357
389
|
};
|
|
358
390
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Position } from '../geometry/point';
|
|
2
2
|
import { Rect } from '../geometry/rect';
|
|
3
|
-
import { AtDirection, IRBoundary, IRJsonObject, IRLabelDefault, IRNode, IRPaintSpec } from '../ir';
|
|
3
|
+
import { AtDirection, IRAnimationTrack, IRBoundary, IRJsonObject, IRLabelDefault, IRNode, IRPaintSpec } from '../ir';
|
|
4
4
|
import { PaintResolver } from './paint';
|
|
5
5
|
import { ScenePrimitive, TextLine, Transform } from '../primitive';
|
|
6
6
|
import { ShapeDefinition } from '../shapes';
|
|
@@ -77,6 +77,8 @@ export type NodeLayout = {
|
|
|
77
77
|
boundary?: IRBoundary;
|
|
78
78
|
/** provenance 元数据(来自 IR `node.meta`);emit 时原样 stamp 到 node 的 top-level 图元,renderer 忽略 */
|
|
79
79
|
meta?: IRJsonObject;
|
|
80
|
+
/** 时间轴动画 tracks(来自 IR `node.animations`);emit 时原样 stamp 到 node 的 top-level 图元,renderer 播放 / 降级 */
|
|
81
|
+
animations?: Array<IRAnimationTrack>;
|
|
80
82
|
/** 构建本 layout 的 shape 注册表引用——借用连接面(borrowed boundary)查表用 */
|
|
81
83
|
shapes: Record<string, ShapeDefinition>;
|
|
82
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/compile/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,kBAAk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EF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,aAAa,YAAY,EACzB,WAAW,SAAS,EACpB,eAAe,MAAM,EACrB,aAAY,aAAa,CAAC,SAAS,CAAM,EACzC,eAAe,cAAc,EAC7B,SAAQ,MAAM,CAAC,MAAM,EAAE,eAAe,CAAkB,EACxD,uBAAuB,oBAAoB,KAC1C,UAiNF,CAAC;AAcF;;;;GAIG;AACH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,UAAU,KAAG,KAAK,CAAC,QAAQ,CA6BpE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,UAAU,EAClB,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAC5B,aAAa,aAAa,KACzB,KAAK,CAAC,cAAc,CAqItB,CAAC"}
|
package/dist/es/compile/node.js
CHANGED
|
@@ -406,6 +406,7 @@ var layoutNode = (node, measureText, nameStack, nodeDistance, scopeChain = [], l
|
|
|
406
406
|
labels,
|
|
407
407
|
boundary: node.boundary,
|
|
408
408
|
meta: node.meta,
|
|
409
|
+
animations: node.animations,
|
|
409
410
|
shapes
|
|
410
411
|
};
|
|
411
412
|
};
|
|
@@ -546,6 +547,7 @@ var emitNodePrimitives = (layout, round, resolveFill) => {
|
|
|
546
547
|
if (!(layout.rotateDeg !== 0 || layout.lines !== void 0)) {
|
|
547
548
|
if (layout.id !== void 0) for (const prim of shapePrims) prim.id = layout.id;
|
|
548
549
|
if (layout.meta !== void 0) for (const prim of shapePrims) prim.meta = layout.meta;
|
|
550
|
+
if (layout.animations !== void 0) for (const prim of shapePrims) prim.animations = layout.animations;
|
|
549
551
|
return inner;
|
|
550
552
|
}
|
|
551
553
|
const group = {
|
|
@@ -554,6 +556,7 @@ var emitNodePrimitives = (layout, round, resolveFill) => {
|
|
|
554
556
|
};
|
|
555
557
|
if (layout.id !== void 0) group.id = layout.id;
|
|
556
558
|
if (layout.meta !== void 0) group.meta = layout.meta;
|
|
559
|
+
if (layout.animations !== void 0) group.animations = layout.animations;
|
|
557
560
|
if (layout.rotateDeg !== 0) group.transforms = [{
|
|
558
561
|
kind: "rotate",
|
|
559
562
|
degrees: round(layout.rotateDeg),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/compile/path/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAY9C,OAAO,KAAK,EACV,MAAM,EAEN,UAAU,EAGX,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAIV,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,iBAAiB,CAAC;AAKtE,OAAO,EAAE,KAAK,eAAe,EAA2D,MAAM,UAAU,CAAC;AA8FzG,mCAAmC;AACnC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iCAAiC;IACjC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,IAAI,CAAC;IACX,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACtC,wEAAwE;IACxE,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACnE,CAAC;AA0EF;;;GAGG;AACH,eAAO,MA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AE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACnE,CAAC;AA0EF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,WAAW,SAAS,EACpB,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAC5B,cAAa,YAA+B,EAC5C,WAAU,gBAAqB,KAC9B;IAAE,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAAE,GAAG,IAsvBrE,CAAC"}
|
|
@@ -648,6 +648,7 @@ var emitPathPrimitive = (path, nameStack, round, measureText = fallbackMeasurer,
|
|
|
648
648
|
};
|
|
649
649
|
if (path.id !== void 0) group.id = path.id;
|
|
650
650
|
if (path.meta !== void 0) group.meta = path.meta;
|
|
651
|
+
if (path.animations !== void 0) group.animations = path.animations;
|
|
651
652
|
const transformedPoints = points.map((p) => applyTransformChain(p, transforms));
|
|
652
653
|
if (!transformedPoints.every(isFinitePoint)) throw new Error("Path rotate / scale produced a non-finite coordinate (scale too large); use a smaller scale.");
|
|
653
654
|
return {
|
|
@@ -658,6 +659,7 @@ var emitPathPrimitive = (path, nameStack, round, measureText = fallbackMeasurer,
|
|
|
658
659
|
}
|
|
659
660
|
if (path.id !== void 0) primitive.id = path.id;
|
|
660
661
|
if (path.meta !== void 0) primitive.meta = path.meta;
|
|
662
|
+
if (path.animations !== void 0) primitive.animations = path.animations;
|
|
661
663
|
return {
|
|
662
664
|
primitives: bodyPrims,
|
|
663
665
|
points
|
package/dist/es/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, AnchorRefSchema, NodeTargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, AbsoluteTargetSchema, BetweenPositionSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, RectangleStepSchema, GeneratorStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, ShapeRefSchema, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ScopeSchema, CompositeBaseSchema, NodeDefaultSchema, PathDefaultSchema, LabelDefaultSchema, ArrowDefaultSchema, TransformSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, PaintSpecSchema, GradientStopSchema, JsonValueSchema, JsonObjectSchema, ClipSpecSchema, ViewBoxSchema, } from './ir';
|
|
6
6
|
export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRAnchorRef, IRNodeTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRAbsoluteTarget, IRBetweenPosition, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRRectangleStep, IRGeneratorStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRShapeRef, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRScope, IRComposite, IRNodeDefault, IRPathDefault, IRLabelDefault, IRArrowDefault, StyleChannel, IRTransform, IRTranslateTransform, IRPolarTranslateTransform, IRAtTranslateTransform, IROffsetTranslateTransform, IRRotateTransform, IRScaleTransform, IRChild, IR, ArrowShape, BuiltinArrowName, ArrowShapeName, IRArrowDetail, IRArrowEndDetail, NodeShape, BuiltinShapeName, NodeTextAlign, PatternShapeName, BuiltinPatternName, IRPaintSpec, IRGradientStop, JsonValue, IRJsonObject, IRClipSpec, IRViewBox, } from './ir';
|
|
7
|
-
export { ARROW_SHAPES, DEFAULT_ARROW_SHAPE, HOLLOW_ARROW_SHAPES, ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, NODE_SHAPES, NODE_TEXT_ALIGNS, PATTERN_SHAPES, Boundary, BoundarySchema, } from './ir';
|
|
7
|
+
export { ARROW_SHAPES, DEFAULT_ARROW_SHAPE, HOLLOW_ARROW_SHAPES, ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, NODE_SHAPES, NODE_TEXT_ALIGNS, PATTERN_SHAPES, Boundary, BoundarySchema, AnimationProperty, AnimationEasing, AnimationDirection, AnimationFill, AnimationTrigger, AnimationTrackSchema, KeyframeSchema, TriggerSchema, EasingSchema, OriginSchema, } from './ir';
|
|
8
8
|
export type { BoundaryKeyword, IRBoundary } from './ir';
|
|
9
|
+
export type { BuiltinAnimationProperty, AnimationPropertyRef, AnimationEasingName, AnimationDirectionName, AnimationFillName, AnimationTriggerName, IRAnimationTrack, IRKeyframe, IRAnimationTrigger, IRAnimationOrigin, } from './ir';
|
|
9
10
|
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, PathCommand,
|
|
10
11
|
/** 7 个 named PathCommand 分支(便于 wrapper / Pick<>) */
|
|
11
12
|
MovePathCommand, LinePathCommand, QuadPathCommand, CubicPathCommand, ArcPathCommand, EllipseArcPathCommand, ClosePathCommand, ArrowEndSpec, GroupPrim, Transform,
|
|
@@ -21,6 +22,8 @@ export type { FontSpec, TextMetrics, TextMeasurer, CompileOptions, CompileWarnin
|
|
|
21
22
|
export { computeLayout, fallbackMeasurer, compileToScene } from './compile';
|
|
22
23
|
export type { WayItem, WayDSL, WayCycle, WayVia, WayRelativeItem, WayLabel, WayLabelOp, } from './parsers';
|
|
23
24
|
export { parseWay, DrawWay, parseTargetSugar, parseNodeTarget } from './parsers';
|
|
25
|
+
export { fadeIn, drawOn, scaleIn, grow, growUp, slideIn, colorShift, cameraTo, pulse, spin, loop, flash, blink, wiggle, stagger, } from './presets';
|
|
26
|
+
export type { AnimationPresetOptions, ScaleInOptions, GrowUpOptions, SlideInOptions, ColorShiftOptions, CameraToOptions, PulseOptions, SpinOptions, LoopOptions, FlashOptions, BlinkOptions, WiggleOptions, } from './presets';
|
|
24
27
|
export type { Position, Rect, RectAnchor, Circle, Ellipse, Diamond, PolarPosition, } from './geometry';
|
|
25
28
|
export { point, rect, circle, ellipse, diamond, RECT_ANCHORS, polar } from './geometry';
|
|
26
29
|
export type { ShapeDefinition, ShapeDefinitionInput, ShapeStyle } from './shapes';
|
package/dist/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,cAAc,EACd,WAAW,EACX,MAAM,EACN,MAAM,EACN,WAAW,EACX,UAAU,EACV,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,MAAM,EACN,OAAO,EACP,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,EAAE,EACF,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,MAAM,CAAC;AACd,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,sCAAsC,EACtC,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qB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AAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/es/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Boundary, BoundarySchema } from "./ir/boundary.js";
|
|
|
8
8
|
import { AnchorRefSchema, NodeTargetSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, TargetSchema } from "./ir/path/target.js";
|
|
9
9
|
import { AbsoluteTargetSchema, BetweenPositionSchema } from "./ir/position/between-position.js";
|
|
10
10
|
import { FontSchema } from "./ir/font.js";
|
|
11
|
+
import { AnimationDirection, AnimationEasing, AnimationFill, AnimationProperty, AnimationTrackSchema, AnimationTrigger, EasingSchema, KeyframeSchema, OriginSchema, TriggerSchema } from "./ir/animation.js";
|
|
11
12
|
import { GradientStopSchema, PATTERN_SHAPES, PaintSpecSchema } from "./ir/paint.js";
|
|
12
13
|
import { ClipSpecSchema } from "./ir/clip.js";
|
|
13
14
|
import { LineSpecSchema, TextBlockSchema } from "./ir/text.js";
|
|
@@ -33,10 +34,11 @@ import { compileToScene } from "./compile/compile.js";
|
|
|
33
34
|
import { parseNodeTarget } from "./parsers/parseNodeTarget.js";
|
|
34
35
|
import { parseTargetSugar } from "./parsers/parseTargetSugar.js";
|
|
35
36
|
import { DrawWay, parseWay } from "./parsers/parseWay.js";
|
|
37
|
+
import { blink, cameraTo, colorShift, drawOn, fadeIn, flash, grow, growUp, loop, pulse, scaleIn, slideIn, spin, stagger, wiggle } from "./presets/animation.js";
|
|
36
38
|
import { polar } from "./geometry/polar.js";
|
|
37
39
|
import { point } from "./geometry/point.js";
|
|
38
40
|
import { circle } from "./geometry/circle.js";
|
|
39
41
|
import { diamond } from "./geometry/diamond.js";
|
|
40
42
|
import { definePathGenerator } from "./pathGenerators/define.js";
|
|
41
43
|
import { defineComposite } from "./composites/types.js";
|
|
42
|
-
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, AT_DIRECTIONS, AbsoluteTargetSchema, AnchorRefSchema, ArcStepSchema, ArrowDefaultSchema, ArrowDetailSchema, ArrowEndDetailSchema, AtPositionSchema, BUILTIN_ARROWS, BUILTIN_PATTERNS, BUILTIN_SHAPES, BendStepSchema, BetweenPositionSchema, Boundary, BoundarySchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ClipSpecSchema, CompositeBaseSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DEFAULT_ARROW_SHAPE, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, GeneratorStepSchema, GradientStopSchema, HOLLOW_ARROW_SHAPES, JsonObjectSchema, JsonValueSchema, LabelDefaultSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeDefaultSchema, NodeLabelSchema, NodeSchema, NodeTargetSchema, OffsetPositionSchema, PATTERN_SHAPES, PaintSpecSchema, PathDefaultSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RectangleStepSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, SceneSchema, ScopeSchema, ShapeRefSchema, StepLabelSchema, StepSchema, TargetSchema, TextBlockSchema, TransformSchema, ViewBoxSchema, circle, compileToScene, computeLayout, defineComposite, definePathGenerator, defineShape, diamond, ellipse, fallbackMeasurer, localToWorld, parseNodeTarget, parseTargetSugar, parseWay, point, polar, rect, worldToLocal };
|
|
44
|
+
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, AT_DIRECTIONS, AbsoluteTargetSchema, AnchorRefSchema, AnimationDirection, AnimationEasing, AnimationFill, AnimationProperty, AnimationTrackSchema, AnimationTrigger, ArcStepSchema, ArrowDefaultSchema, ArrowDetailSchema, ArrowEndDetailSchema, AtPositionSchema, BUILTIN_ARROWS, BUILTIN_PATTERNS, BUILTIN_SHAPES, BendStepSchema, BetweenPositionSchema, Boundary, BoundarySchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ClipSpecSchema, CompositeBaseSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DEFAULT_ARROW_SHAPE, DrawWay, EasingSchema, EllipsePathStepSchema, FoldStepSchema, FontSchema, GeneratorStepSchema, GradientStopSchema, HOLLOW_ARROW_SHAPES, JsonObjectSchema, JsonValueSchema, KeyframeSchema, LabelDefaultSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeDefaultSchema, NodeLabelSchema, NodeSchema, NodeTargetSchema, OffsetPositionSchema, OriginSchema, PATTERN_SHAPES, PaintSpecSchema, PathDefaultSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RectangleStepSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, SceneSchema, ScopeSchema, ShapeRefSchema, StepLabelSchema, StepSchema, TargetSchema, TextBlockSchema, TransformSchema, TriggerSchema, ViewBoxSchema, blink, cameraTo, circle, colorShift, compileToScene, computeLayout, defineComposite, definePathGenerator, defineShape, diamond, drawOn, ellipse, fadeIn, fallbackMeasurer, flash, grow, growUp, localToWorld, loop, parseNodeTarget, parseTargetSugar, parseWay, point, polar, pulse, rect, scaleIn, slideIn, spin, stagger, wiggle, worldToLocal };
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ValueOf } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* 可动画属性通道(renderer 无关;DrawWay 风格 const + 派生类型,裸字面量 'opacity' 仍第一形态)
|
|
5
|
+
* @description `viewBox` 仅在 scene 根合法(镜头),元素级 viewBox track 由 compile / render 拒;
|
|
6
|
+
* `pathDraw` 是 0..1 路径画出进度;`scaleX` / `scaleY` 是非均匀缩放(柱状图从基线长出等),`scale` 是均匀缩放;
|
|
7
|
+
* transform 通道(scale / scaleX / scaleY / rotate)的支点见 track 级 `origin`,缺省几何中心。
|
|
8
|
+
* 各后端按通道翻译:SVG WAAPI/CSS、Canvas rAF 几何 lerp。
|
|
9
|
+
*/
|
|
10
|
+
export declare const AnimationProperty: {
|
|
11
|
+
readonly Opacity: "opacity";
|
|
12
|
+
readonly Fill: "fill";
|
|
13
|
+
readonly Stroke: "stroke";
|
|
14
|
+
readonly StrokeWidth: "strokeWidth";
|
|
15
|
+
readonly TranslateX: "translateX";
|
|
16
|
+
readonly TranslateY: "translateY";
|
|
17
|
+
readonly Rotate: "rotate";
|
|
18
|
+
readonly Scale: "scale";
|
|
19
|
+
readonly ScaleX: "scaleX";
|
|
20
|
+
readonly ScaleY: "scaleY";
|
|
21
|
+
readonly PathDraw: "pathDraw";
|
|
22
|
+
readonly ViewBox: "viewBox";
|
|
23
|
+
};
|
|
24
|
+
/** 内置可动画属性通道名联合 */
|
|
25
|
+
export type BuiltinAnimationProperty = ValueOf<typeof AnimationProperty>;
|
|
26
|
+
/** 属性名:内置 ∪ 任意自定义字符串(`& {}` 保内置自动补全,同 NodeShape 范式);自定义通道由后续 renderer 注册的插值器解释 */
|
|
27
|
+
export type AnimationPropertyRef = BuiltinAnimationProperty | (string & {});
|
|
28
|
+
/** 缓动具名预设(与 CSS 同名);track / keyframe 亦可改用 cubic-bezier 四元组 */
|
|
29
|
+
export declare const AnimationEasing: {
|
|
30
|
+
readonly Linear: "linear";
|
|
31
|
+
readonly Ease: "ease";
|
|
32
|
+
readonly EaseIn: "ease-in";
|
|
33
|
+
readonly EaseOut: "ease-out";
|
|
34
|
+
readonly EaseInOut: "ease-in-out";
|
|
35
|
+
};
|
|
36
|
+
/** 缓动预设名联合 */
|
|
37
|
+
export type AnimationEasingName = ValueOf<typeof AnimationEasing>;
|
|
38
|
+
/** 每次迭代的播放方向(抄 WAAPI / CSS animation-direction) */
|
|
39
|
+
export declare const AnimationDirection: {
|
|
40
|
+
readonly Normal: "normal";
|
|
41
|
+
readonly Reverse: "reverse";
|
|
42
|
+
readonly Alternate: "alternate";
|
|
43
|
+
readonly AlternateReverse: "alternate-reverse";
|
|
44
|
+
};
|
|
45
|
+
/** 播放方向名联合 */
|
|
46
|
+
export type AnimationDirectionName = ValueOf<typeof AnimationDirection>;
|
|
47
|
+
/** 活动区间外取值(抄 WAAPI / CSS animation-fill-mode) */
|
|
48
|
+
export declare const AnimationFill: {
|
|
49
|
+
readonly None: "none";
|
|
50
|
+
readonly Forwards: "forwards";
|
|
51
|
+
readonly Backwards: "backwards";
|
|
52
|
+
readonly Both: "both";
|
|
53
|
+
};
|
|
54
|
+
/** 填充模式名联合 */
|
|
55
|
+
export type AnimationFillName = ValueOf<typeof AnimationFill>;
|
|
56
|
+
export declare const EasingSchema: z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>;
|
|
57
|
+
export declare const KeyframeSchema: z.ZodObject<{
|
|
58
|
+
at: z.ZodNumber;
|
|
59
|
+
value: z.ZodType<import('./json').JsonValue, z.ZodTypeDef, import('./json').JsonValue>;
|
|
60
|
+
easing: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
value: import('./json').JsonValue;
|
|
63
|
+
at: number;
|
|
64
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
value: import('./json').JsonValue;
|
|
67
|
+
at: number;
|
|
68
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
/** 播放触发器关键字(runtime 落地;DrawWay 风格 const + 派生类型,与其它 Animation 枚举单一真源一致) */
|
|
71
|
+
export declare const AnimationTrigger: {
|
|
72
|
+
readonly Load: "load";
|
|
73
|
+
readonly Visible: "visible";
|
|
74
|
+
readonly Manual: "manual";
|
|
75
|
+
};
|
|
76
|
+
/** 触发器关键字联合(不含 { onEvent } 对象形态) */
|
|
77
|
+
export type AnimationTriggerName = ValueOf<typeof AnimationTrigger>;
|
|
78
|
+
export declare const TriggerSchema: z.ZodUnion<[z.ZodNativeEnum<{
|
|
79
|
+
readonly Load: "load";
|
|
80
|
+
readonly Visible: "visible";
|
|
81
|
+
readonly Manual: "manual";
|
|
82
|
+
}>, z.ZodObject<{
|
|
83
|
+
onEvent: z.ZodString;
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
onEvent: string;
|
|
86
|
+
}, {
|
|
87
|
+
onEvent: string;
|
|
88
|
+
}>]>;
|
|
89
|
+
export declare const OriginSchema: z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
90
|
+
export declare const AnimationTrackSchema: z.ZodEffects<z.ZodObject<{
|
|
91
|
+
property: z.ZodString;
|
|
92
|
+
keyframes: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
93
|
+
at: z.ZodNumber;
|
|
94
|
+
value: z.ZodType<import('./json').JsonValue, z.ZodTypeDef, import('./json').JsonValue>;
|
|
95
|
+
easing: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
value: import('./json').JsonValue;
|
|
98
|
+
at: number;
|
|
99
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
value: import('./json').JsonValue;
|
|
102
|
+
at: number;
|
|
103
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
104
|
+
}>, "many">, {
|
|
105
|
+
value: import('./json').JsonValue;
|
|
106
|
+
at: number;
|
|
107
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
108
|
+
}[], {
|
|
109
|
+
value: import('./json').JsonValue;
|
|
110
|
+
at: number;
|
|
111
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
112
|
+
}[]>;
|
|
113
|
+
duration: z.ZodNumber;
|
|
114
|
+
delay: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
easing: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>>;
|
|
116
|
+
iterations: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodLiteral<"infinite">]>>;
|
|
117
|
+
direction: z.ZodOptional<z.ZodNativeEnum<{
|
|
118
|
+
readonly Normal: "normal";
|
|
119
|
+
readonly Reverse: "reverse";
|
|
120
|
+
readonly Alternate: "alternate";
|
|
121
|
+
readonly AlternateReverse: "alternate-reverse";
|
|
122
|
+
}>>;
|
|
123
|
+
fill: z.ZodOptional<z.ZodNativeEnum<{
|
|
124
|
+
readonly None: "none";
|
|
125
|
+
readonly Forwards: "forwards";
|
|
126
|
+
readonly Backwards: "backwards";
|
|
127
|
+
readonly Both: "both";
|
|
128
|
+
}>>;
|
|
129
|
+
trigger: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<{
|
|
130
|
+
readonly Load: "load";
|
|
131
|
+
readonly Visible: "visible";
|
|
132
|
+
readonly Manual: "manual";
|
|
133
|
+
}>, z.ZodObject<{
|
|
134
|
+
onEvent: z.ZodString;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
onEvent: string;
|
|
137
|
+
}, {
|
|
138
|
+
onEvent: string;
|
|
139
|
+
}>]>>;
|
|
140
|
+
origin: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>>;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
property: string;
|
|
143
|
+
keyframes: {
|
|
144
|
+
value: import('./json').JsonValue;
|
|
145
|
+
at: number;
|
|
146
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
147
|
+
}[];
|
|
148
|
+
duration: number;
|
|
149
|
+
fill?: "none" | "forwards" | "backwards" | "both" | undefined;
|
|
150
|
+
origin?: string | [number, number] | undefined;
|
|
151
|
+
direction?: "reverse" | "normal" | "alternate" | "alternate-reverse" | undefined;
|
|
152
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
153
|
+
delay?: number | undefined;
|
|
154
|
+
iterations?: number | "infinite" | undefined;
|
|
155
|
+
trigger?: "load" | "visible" | "manual" | {
|
|
156
|
+
onEvent: string;
|
|
157
|
+
} | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
property: string;
|
|
160
|
+
keyframes: {
|
|
161
|
+
value: import('./json').JsonValue;
|
|
162
|
+
at: number;
|
|
163
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
164
|
+
}[];
|
|
165
|
+
duration: number;
|
|
166
|
+
fill?: "none" | "forwards" | "backwards" | "both" | undefined;
|
|
167
|
+
origin?: string | [number, number] | undefined;
|
|
168
|
+
direction?: "reverse" | "normal" | "alternate" | "alternate-reverse" | undefined;
|
|
169
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
170
|
+
delay?: number | undefined;
|
|
171
|
+
iterations?: number | "infinite" | undefined;
|
|
172
|
+
trigger?: "load" | "visible" | "manual" | {
|
|
173
|
+
onEvent: string;
|
|
174
|
+
} | undefined;
|
|
175
|
+
}>, {
|
|
176
|
+
property: string;
|
|
177
|
+
keyframes: {
|
|
178
|
+
value: import('./json').JsonValue;
|
|
179
|
+
at: number;
|
|
180
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
181
|
+
}[];
|
|
182
|
+
duration: number;
|
|
183
|
+
fill?: "none" | "forwards" | "backwards" | "both" | undefined;
|
|
184
|
+
origin?: string | [number, number] | undefined;
|
|
185
|
+
direction?: "reverse" | "normal" | "alternate" | "alternate-reverse" | undefined;
|
|
186
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
187
|
+
delay?: number | undefined;
|
|
188
|
+
iterations?: number | "infinite" | undefined;
|
|
189
|
+
trigger?: "load" | "visible" | "manual" | {
|
|
190
|
+
onEvent: string;
|
|
191
|
+
} | undefined;
|
|
192
|
+
}, {
|
|
193
|
+
property: string;
|
|
194
|
+
keyframes: {
|
|
195
|
+
value: import('./json').JsonValue;
|
|
196
|
+
at: number;
|
|
197
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
198
|
+
}[];
|
|
199
|
+
duration: number;
|
|
200
|
+
fill?: "none" | "forwards" | "backwards" | "both" | undefined;
|
|
201
|
+
origin?: string | [number, number] | undefined;
|
|
202
|
+
direction?: "reverse" | "normal" | "alternate" | "alternate-reverse" | undefined;
|
|
203
|
+
easing?: string | [number, number, number, number] | undefined;
|
|
204
|
+
delay?: number | undefined;
|
|
205
|
+
iterations?: number | "infinite" | undefined;
|
|
206
|
+
trigger?: "load" | "visible" | "manual" | {
|
|
207
|
+
onEvent: string;
|
|
208
|
+
} | undefined;
|
|
209
|
+
}>;
|
|
210
|
+
/** 时间轴动画 track(renderer 无关、JSON 可序列化、无函数;keyframe 给绝对展示值、末帧 = 元素 base 终态) */
|
|
211
|
+
export type IRAnimationTrack = z.infer<typeof AnimationTrackSchema>;
|
|
212
|
+
/** 单个动画关键帧 */
|
|
213
|
+
export type IRKeyframe = z.infer<typeof KeyframeSchema>;
|
|
214
|
+
/** transform 支点(命名 anchor ∪ 局部坐标点;scale / scaleX / scaleY / rotate 用,缺省几何中心) */
|
|
215
|
+
export type IRAnimationOrigin = z.infer<typeof OriginSchema>;
|
|
216
|
+
/** 动画播放触发器(load / visible / manual / { onEvent }) */
|
|
217
|
+
export type IRAnimationTrigger = z.infer<typeof TriggerSchema>;
|
|
218
|
+
//# sourceMappingURL=animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmF9B,CAAC;AAEJ,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACpE,cAAc;AACd,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,gFAAgF;AAChF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC7D,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { JsonValueSchema } from "./json.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/ir/animation.ts
|
|
4
|
+
/**
|
|
5
|
+
* 可动画属性通道(renderer 无关;DrawWay 风格 const + 派生类型,裸字面量 'opacity' 仍第一形态)
|
|
6
|
+
* @description `viewBox` 仅在 scene 根合法(镜头),元素级 viewBox track 由 compile / render 拒;
|
|
7
|
+
* `pathDraw` 是 0..1 路径画出进度;`scaleX` / `scaleY` 是非均匀缩放(柱状图从基线长出等),`scale` 是均匀缩放;
|
|
8
|
+
* transform 通道(scale / scaleX / scaleY / rotate)的支点见 track 级 `origin`,缺省几何中心。
|
|
9
|
+
* 各后端按通道翻译:SVG WAAPI/CSS、Canvas rAF 几何 lerp。
|
|
10
|
+
*/
|
|
11
|
+
var AnimationProperty = {
|
|
12
|
+
Opacity: "opacity",
|
|
13
|
+
Fill: "fill",
|
|
14
|
+
Stroke: "stroke",
|
|
15
|
+
StrokeWidth: "strokeWidth",
|
|
16
|
+
TranslateX: "translateX",
|
|
17
|
+
TranslateY: "translateY",
|
|
18
|
+
Rotate: "rotate",
|
|
19
|
+
Scale: "scale",
|
|
20
|
+
ScaleX: "scaleX",
|
|
21
|
+
ScaleY: "scaleY",
|
|
22
|
+
PathDraw: "pathDraw",
|
|
23
|
+
ViewBox: "viewBox"
|
|
24
|
+
};
|
|
25
|
+
/** 缓动具名预设(与 CSS 同名);track / keyframe 亦可改用 cubic-bezier 四元组 */
|
|
26
|
+
var AnimationEasing = {
|
|
27
|
+
Linear: "linear",
|
|
28
|
+
Ease: "ease",
|
|
29
|
+
EaseIn: "ease-in",
|
|
30
|
+
EaseOut: "ease-out",
|
|
31
|
+
EaseInOut: "ease-in-out"
|
|
32
|
+
};
|
|
33
|
+
/** 每次迭代的播放方向(抄 WAAPI / CSS animation-direction) */
|
|
34
|
+
var AnimationDirection = {
|
|
35
|
+
Normal: "normal",
|
|
36
|
+
Reverse: "reverse",
|
|
37
|
+
Alternate: "alternate",
|
|
38
|
+
AlternateReverse: "alternate-reverse"
|
|
39
|
+
};
|
|
40
|
+
/** 活动区间外取值(抄 WAAPI / CSS animation-fill-mode) */
|
|
41
|
+
var AnimationFill = {
|
|
42
|
+
None: "none",
|
|
43
|
+
Forwards: "forwards",
|
|
44
|
+
Backwards: "backwards",
|
|
45
|
+
Both: "both"
|
|
46
|
+
};
|
|
47
|
+
var EasingSchema = z.union([z.string().min(1), z.tuple([
|
|
48
|
+
z.number().finite(),
|
|
49
|
+
z.number().finite(),
|
|
50
|
+
z.number().finite(),
|
|
51
|
+
z.number().finite()
|
|
52
|
+
])]).describe("Easing: a named preset (built-in linear / ease / ease-in / ease-out / ease-in-out, or a custom name resolved by a renderer-registered easing) or a cubic-bezier control-point tuple [x1, y1, x2, y2]. Defaults to linear when omitted.");
|
|
53
|
+
var KeyframeSchema = z.object({
|
|
54
|
+
at: z.number().min(0).max(1).describe("Normalized keyframe time in [0, 1] (WAAPI offset, decoupled from duration). Keyframes within a track must be sorted ascending by `at`."),
|
|
55
|
+
value: JsonValueSchema.describe("Keyframe value (any JSON value). For built-in properties it is narrowed by the track-level refinement: a finite number (opacity / scale / rotate / translateX|Y / strokeWidth / pathDraw 0..1), a color string (fill / stroke, interpolated in oklch), or a 4-number array [x, y, w, h] (viewBox). Custom (non-built-in) properties accept any JSON value, interpreted by a renderer-registered interpolator."),
|
|
56
|
+
easing: EasingSchema.optional().describe("Per-segment easing from this keyframe to the next; overrides the track-level easing.")
|
|
57
|
+
}).describe("A single animation keyframe: a value at a normalized time, with optional per-segment easing.");
|
|
58
|
+
/** 播放触发器关键字(runtime 落地;DrawWay 风格 const + 派生类型,与其它 Animation 枚举单一真源一致) */
|
|
59
|
+
var AnimationTrigger = {
|
|
60
|
+
Load: "load",
|
|
61
|
+
Visible: "visible",
|
|
62
|
+
Manual: "manual"
|
|
63
|
+
};
|
|
64
|
+
var TriggerSchema = z.union([z.nativeEnum(AnimationTrigger), z.object({ onEvent: z.string().min(1).describe("Event name (e.g. \"click\") the runtime binds to start playback; the handler function never enters the IR.") })]).describe("When playback starts: \"load\" (on render, SSR-friendly) / \"visible\" (runtime IntersectionObserver) / \"manual\" (runtime API) / { onEvent } (bridge to hydration; only the event name is stored, never a callback). Defaults to \"load\".");
|
|
65
|
+
var OriginSchema = z.union([z.string().min(1).describe("Named transform pivot reusing the node anchor vocabulary (center / north / south / east / west / north-east / ... / south-west), resolved against the element boundary by the renderer."), z.tuple([z.number().finite(), z.number().finite()]).describe("Explicit pivot in the element local coordinate space [x, y].")]).describe("Transform pivot for scale / scaleX / scaleY / rotate channels: a named anchor or an explicit local-space point. Ignored by non-transform channels. Defaults to the element geometric center.");
|
|
66
|
+
var AnimationTrackSchema = z.object({
|
|
67
|
+
property: z.string().min(1).describe("Renderer-agnostic animated channel. Built-in: opacity / fill / stroke / strokeWidth / translateX / translateY / rotate / scale (uniform) / scaleX / scaleY (non-uniform) / pathDraw (0..1 reveal) / viewBox (scene-root camera only). Any other string is a custom channel that passes through to a renderer-registered interpolator. `viewBox` is valid only at the scene root (enforced at compile)."),
|
|
68
|
+
keyframes: z.array(KeyframeSchema).min(1).refine((frames) => frames.every((frame, index) => index === 0 || frame.at >= frames[index - 1].at), { message: "keyframes must be sorted ascending by `at`" }).describe("Ordered keyframes (at least one), sorted ascending by `at` within [0, 1]. Each keyframe gives the absolute display value at that time (NOT a delta on top of the base). By convention the final keyframe equals the element base (settled) state, so ignoring the animation renders the complete base figure."),
|
|
69
|
+
duration: z.number().finite().positive().describe("One-iteration duration in milliseconds (> 0)."),
|
|
70
|
+
delay: z.number().finite().nonnegative().optional().describe("Delay before the first iteration, in milliseconds (>= 0). Group-level stagger is compiled by sugar into per-track delays."),
|
|
71
|
+
easing: EasingSchema.optional().describe("Track-level easing applied to each segment that lacks its own keyframe easing. Defaults to linear."),
|
|
72
|
+
iterations: z.union([z.number().finite().positive(), z.literal("infinite")]).optional().describe("Total play count (WAAPI iterations): a positive number (may be fractional) or \"infinite\". Omitted = 1 = play once."),
|
|
73
|
+
direction: z.nativeEnum(AnimationDirection).optional().describe("Per-iteration playback direction (WAAPI / CSS animation-direction). Defaults to \"normal\"."),
|
|
74
|
+
fill: z.nativeEnum(AnimationFill).optional().describe("Value held outside the active interval (WAAPI / CSS fill-mode). Defaults to \"forwards\" so the element settles at its base (end) state, matching the static-settled invariant."),
|
|
75
|
+
trigger: TriggerSchema.optional().describe("Playback trigger; defaults to \"load\"."),
|
|
76
|
+
origin: OriginSchema.optional().describe("Transform pivot for scale / scaleX / scaleY / rotate channels; ignored by other channels. Defaults to the element geometric center.")
|
|
77
|
+
}).superRefine((track, ctx) => {
|
|
78
|
+
const numeric = new Set([
|
|
79
|
+
AnimationProperty.Opacity,
|
|
80
|
+
AnimationProperty.StrokeWidth,
|
|
81
|
+
AnimationProperty.TranslateX,
|
|
82
|
+
AnimationProperty.TranslateY,
|
|
83
|
+
AnimationProperty.Rotate,
|
|
84
|
+
AnimationProperty.Scale,
|
|
85
|
+
AnimationProperty.ScaleX,
|
|
86
|
+
AnimationProperty.ScaleY,
|
|
87
|
+
AnimationProperty.PathDraw
|
|
88
|
+
]);
|
|
89
|
+
track.keyframes.forEach((frame, index) => {
|
|
90
|
+
const value = frame.value;
|
|
91
|
+
const path = [
|
|
92
|
+
"keyframes",
|
|
93
|
+
index,
|
|
94
|
+
"value"
|
|
95
|
+
];
|
|
96
|
+
if (track.property === AnimationProperty.ViewBox) {
|
|
97
|
+
if (!Array.isArray(value) || value.length !== 4) ctx.addIssue({
|
|
98
|
+
code: z.ZodIssueCode.custom,
|
|
99
|
+
path,
|
|
100
|
+
message: "viewBox keyframe value must be a 4-number array [x, y, w, h]"
|
|
101
|
+
});
|
|
102
|
+
} else if (track.property === AnimationProperty.Fill || track.property === AnimationProperty.Stroke) {
|
|
103
|
+
if (typeof value !== "string") ctx.addIssue({
|
|
104
|
+
code: z.ZodIssueCode.custom,
|
|
105
|
+
path,
|
|
106
|
+
message: `${track.property} keyframe value must be a color string`
|
|
107
|
+
});
|
|
108
|
+
} else if (numeric.has(track.property)) {
|
|
109
|
+
if (typeof value !== "number") ctx.addIssue({
|
|
110
|
+
code: z.ZodIssueCode.custom,
|
|
111
|
+
path,
|
|
112
|
+
message: `${track.property} keyframe value must be a number`
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}).describe("A declarative timeline animation track on a single renderer-agnostic property: keyframes over normalized time plus WAAPI-style timing options. The `property` is open (built-in channels or a custom name resolved by a renderer-registered interpolator). Fully JSON-serializable (no functions); playback control and callbacks live in the runtime, not the IR. Renderers that cannot animate render the static settled state and emit a diagnosable warning.");
|
|
117
|
+
//#endregion
|
|
118
|
+
export { AnimationDirection, AnimationEasing, AnimationFill, AnimationProperty, AnimationTrackSchema, AnimationTrigger, EasingSchema, KeyframeSchema, OriginSchema, TriggerSchema };
|
package/dist/es/ir/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|