@retikz/core 0.2.0-alpha.3 → 0.2.0-alpha.4
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.map +1 -1
- package/dist/es/compile/compile.js +74 -12
- package/dist/es/compile/node.d.ts +4 -0
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +83 -32
- package/dist/es/ir/node.d.ts +31 -2
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +9 -2
- package/dist/es/ir/path/path.d.ts +3 -0
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +1 -0
- package/dist/es/ir/scope.d.ts +36 -4
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +5 -2
- package/dist/lib/compile/compile.cjs +74 -12
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +83 -32
- package/dist/lib/compile/node.d.ts +4 -0
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +9 -2
- package/dist/lib/ir/node.d.ts +31 -2
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +1 -0
- package/dist/lib/ir/path/path.d.ts +3 -0
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +5 -2
- package/dist/lib/ir/scope.d.ts +36 -4
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/es/ir/scope.d.ts
CHANGED
|
@@ -161,6 +161,8 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
161
161
|
weight?: number | "normal" | "bold" | undefined;
|
|
162
162
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
163
163
|
}>>;
|
|
164
|
+
rotate: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["none", "radial", "tangent"]>, z.ZodNumber]>>;
|
|
165
|
+
keepUpright: z.ZodOptional<z.ZodBoolean>;
|
|
164
166
|
}, "strip", z.ZodTypeAny, {
|
|
165
167
|
text: string;
|
|
166
168
|
distance?: number | undefined;
|
|
@@ -173,6 +175,8 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
173
175
|
} | undefined;
|
|
174
176
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
175
177
|
textColor?: string | undefined;
|
|
178
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
179
|
+
keepUpright?: boolean | undefined;
|
|
176
180
|
}, {
|
|
177
181
|
text: string;
|
|
178
182
|
distance?: number | undefined;
|
|
@@ -185,6 +189,8 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
185
189
|
} | undefined;
|
|
186
190
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
187
191
|
textColor?: string | undefined;
|
|
192
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
193
|
+
keepUpright?: boolean | undefined;
|
|
188
194
|
}>, z.ZodArray<z.ZodObject<{
|
|
189
195
|
text: z.ZodString;
|
|
190
196
|
position: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<{
|
|
@@ -216,6 +222,8 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
216
222
|
weight?: number | "normal" | "bold" | undefined;
|
|
217
223
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
218
224
|
}>>;
|
|
225
|
+
rotate: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["none", "radial", "tangent"]>, z.ZodNumber]>>;
|
|
226
|
+
keepUpright: z.ZodOptional<z.ZodBoolean>;
|
|
219
227
|
}, "strip", z.ZodTypeAny, {
|
|
220
228
|
text: string;
|
|
221
229
|
distance?: number | undefined;
|
|
@@ -228,6 +236,8 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
228
236
|
} | undefined;
|
|
229
237
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
230
238
|
textColor?: string | undefined;
|
|
239
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
240
|
+
keepUpright?: boolean | undefined;
|
|
231
241
|
}, {
|
|
232
242
|
text: string;
|
|
233
243
|
distance?: number | undefined;
|
|
@@ -240,8 +250,11 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
240
250
|
} | undefined;
|
|
241
251
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
242
252
|
textColor?: string | undefined;
|
|
253
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
254
|
+
keepUpright?: boolean | undefined;
|
|
243
255
|
}>, "many">]>>;
|
|
244
|
-
|
|
256
|
+
zIndex: z.ZodOptional<z.ZodNumber>;
|
|
257
|
+
}, "type" | "text" | "position" | "label" | "zIndex" | "id">, "strict", z.ZodTypeAny, {
|
|
245
258
|
fill?: string | undefined;
|
|
246
259
|
opacity?: number | undefined;
|
|
247
260
|
font?: {
|
|
@@ -478,6 +491,7 @@ export declare const PathDefaultSchema: z.ZodObject<Omit<{
|
|
|
478
491
|
opacity: z.ZodOptional<z.ZodNumber>;
|
|
479
492
|
fillOpacity: z.ZodOptional<z.ZodNumber>;
|
|
480
493
|
drawOpacity: z.ZodOptional<z.ZodNumber>;
|
|
494
|
+
zIndex: z.ZodOptional<z.ZodNumber>;
|
|
481
495
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
482
496
|
type: z.ZodLiteral<"step">;
|
|
483
497
|
kind: z.ZodLiteral<"move">;
|
|
@@ -1417,7 +1431,7 @@ export declare const PathDefaultSchema: z.ZodObject<Omit<{
|
|
|
1417
1431
|
textColor?: string | undefined;
|
|
1418
1432
|
} | undefined;
|
|
1419
1433
|
}>]>, "many">;
|
|
1420
|
-
}, "type" | "arrow" | "arrowDetail" | "children">, "strict", z.ZodTypeAny, {
|
|
1434
|
+
}, "type" | "arrow" | "arrowDetail" | "zIndex" | "children">, "strict", z.ZodTypeAny, {
|
|
1421
1435
|
fill?: string | undefined;
|
|
1422
1436
|
opacity?: number | undefined;
|
|
1423
1437
|
color?: string | undefined;
|
|
@@ -1674,6 +1688,7 @@ export type IRScope = {
|
|
|
1674
1688
|
labelDefault?: IRLabelDefault;
|
|
1675
1689
|
arrowDefault?: IRArrowDefault;
|
|
1676
1690
|
resetStyle?: boolean | Array<StyleChannel>;
|
|
1691
|
+
zIndex?: number;
|
|
1677
1692
|
children: Array<IRNode | IRPath | IRCoordinate | IRScope>;
|
|
1678
1693
|
};
|
|
1679
1694
|
/**
|
|
@@ -1943,6 +1958,8 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
1943
1958
|
weight?: number | "normal" | "bold" | undefined;
|
|
1944
1959
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
1945
1960
|
}>>;
|
|
1961
|
+
rotate: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["none", "radial", "tangent"]>, z.ZodNumber]>>;
|
|
1962
|
+
keepUpright: z.ZodOptional<z.ZodBoolean>;
|
|
1946
1963
|
}, "strip", z.ZodTypeAny, {
|
|
1947
1964
|
text: string;
|
|
1948
1965
|
distance?: number | undefined;
|
|
@@ -1955,6 +1972,8 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
1955
1972
|
} | undefined;
|
|
1956
1973
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
1957
1974
|
textColor?: string | undefined;
|
|
1975
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
1976
|
+
keepUpright?: boolean | undefined;
|
|
1958
1977
|
}, {
|
|
1959
1978
|
text: string;
|
|
1960
1979
|
distance?: number | undefined;
|
|
@@ -1967,6 +1986,8 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
1967
1986
|
} | undefined;
|
|
1968
1987
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
1969
1988
|
textColor?: string | undefined;
|
|
1989
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
1990
|
+
keepUpright?: boolean | undefined;
|
|
1970
1991
|
}>, z.ZodArray<z.ZodObject<{
|
|
1971
1992
|
text: z.ZodString;
|
|
1972
1993
|
position: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<{
|
|
@@ -1998,6 +2019,8 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
1998
2019
|
weight?: number | "normal" | "bold" | undefined;
|
|
1999
2020
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
2000
2021
|
}>>;
|
|
2022
|
+
rotate: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["none", "radial", "tangent"]>, z.ZodNumber]>>;
|
|
2023
|
+
keepUpright: z.ZodOptional<z.ZodBoolean>;
|
|
2001
2024
|
}, "strip", z.ZodTypeAny, {
|
|
2002
2025
|
text: string;
|
|
2003
2026
|
distance?: number | undefined;
|
|
@@ -2010,6 +2033,8 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
2010
2033
|
} | undefined;
|
|
2011
2034
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
2012
2035
|
textColor?: string | undefined;
|
|
2036
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
2037
|
+
keepUpright?: boolean | undefined;
|
|
2013
2038
|
}, {
|
|
2014
2039
|
text: string;
|
|
2015
2040
|
distance?: number | undefined;
|
|
@@ -2022,8 +2047,11 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
2022
2047
|
} | undefined;
|
|
2023
2048
|
position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
|
|
2024
2049
|
textColor?: string | undefined;
|
|
2050
|
+
rotate?: number | "none" | "radial" | "tangent" | undefined;
|
|
2051
|
+
keepUpright?: boolean | undefined;
|
|
2025
2052
|
}>, "many">]>>;
|
|
2026
|
-
|
|
2053
|
+
zIndex: z.ZodOptional<z.ZodNumber>;
|
|
2054
|
+
}, "type" | "text" | "position" | "label" | "zIndex" | "id">, "strict", z.ZodTypeAny, {
|
|
2027
2055
|
fill?: string | undefined;
|
|
2028
2056
|
opacity?: number | undefined;
|
|
2029
2057
|
font?: {
|
|
@@ -2256,6 +2284,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
2256
2284
|
opacity: z.ZodOptional<z.ZodNumber>;
|
|
2257
2285
|
fillOpacity: z.ZodOptional<z.ZodNumber>;
|
|
2258
2286
|
drawOpacity: z.ZodOptional<z.ZodNumber>;
|
|
2287
|
+
zIndex: z.ZodOptional<z.ZodNumber>;
|
|
2259
2288
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
2260
2289
|
type: z.ZodLiteral<"step">;
|
|
2261
2290
|
kind: z.ZodLiteral<"move">;
|
|
@@ -3195,7 +3224,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
3195
3224
|
textColor?: string | undefined;
|
|
3196
3225
|
} | undefined;
|
|
3197
3226
|
}>]>, "many">;
|
|
3198
|
-
}, "type" | "arrow" | "arrowDetail" | "children">, "strict", z.ZodTypeAny, {
|
|
3227
|
+
}, "type" | "arrow" | "arrowDetail" | "zIndex" | "children">, "strict", z.ZodTypeAny, {
|
|
3199
3228
|
fill?: string | undefined;
|
|
3200
3229
|
opacity?: number | undefined;
|
|
3201
3230
|
color?: string | undefined;
|
|
@@ -3413,6 +3442,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
3413
3442
|
} | undefined;
|
|
3414
3443
|
}>>;
|
|
3415
3444
|
resetStyle: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodArray<z.ZodEnum<["node", "path", "label", "arrow"]>, "many">]>>;
|
|
3445
|
+
zIndex: z.ZodOptional<z.ZodNumber>;
|
|
3416
3446
|
children: z.ZodArray<z.ZodLazy<z.ZodTypeAny>, "many">;
|
|
3417
3447
|
}, "strip", z.ZodTypeAny, {
|
|
3418
3448
|
type: "scope";
|
|
@@ -3424,6 +3454,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
3424
3454
|
strokeWidth?: number | undefined;
|
|
3425
3455
|
fillOpacity?: number | undefined;
|
|
3426
3456
|
drawOpacity?: number | undefined;
|
|
3457
|
+
zIndex?: number | undefined;
|
|
3427
3458
|
id?: string | undefined;
|
|
3428
3459
|
localNamespace?: boolean | undefined;
|
|
3429
3460
|
transforms?: ({
|
|
@@ -3555,6 +3586,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
3555
3586
|
strokeWidth?: number | undefined;
|
|
3556
3587
|
fillOpacity?: number | undefined;
|
|
3557
3588
|
drawOpacity?: number | undefined;
|
|
3589
|
+
zIndex?: number | undefined;
|
|
3558
3590
|
id?: string | undefined;
|
|
3559
3591
|
localNamespace?: boolean | undefined;
|
|
3560
3592
|
transforms?: ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/ir/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,aAAa,CAAC;AAOhE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/ir/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2GrB,CAAC"}
|
package/dist/es/ir/scope.js
CHANGED
|
@@ -15,7 +15,8 @@ var NodeDefaultSchema = NodeSchema.omit({
|
|
|
15
15
|
id: true,
|
|
16
16
|
position: true,
|
|
17
17
|
text: true,
|
|
18
|
-
label: true
|
|
18
|
+
label: true,
|
|
19
|
+
zIndex: true
|
|
19
20
|
}).strict();
|
|
20
21
|
/**
|
|
21
22
|
* every path 默认样式 schema
|
|
@@ -25,7 +26,8 @@ var PathDefaultSchema = PathSchema.omit({
|
|
|
25
26
|
type: true,
|
|
26
27
|
children: true,
|
|
27
28
|
arrow: true,
|
|
28
|
-
arrowDetail: true
|
|
29
|
+
arrowDetail: true,
|
|
30
|
+
zIndex: true
|
|
29
31
|
}).strict();
|
|
30
32
|
/**
|
|
31
33
|
* every label 默认样式 schema(node label 与 step label 共享)
|
|
@@ -80,6 +82,7 @@ var ScopeSchema = z.object({
|
|
|
80
82
|
"label",
|
|
81
83
|
"arrow"
|
|
82
84
|
]))]).optional().describe("Inheritance barrier: drop the outer scope cascade + every-X defaults for the listed channels (or all when true), falling back to the built-in baseline. Only cuts the scope-inheritance axis; labels / arrows still follow their host path / node resolved color (structural relation, not scope inheritance)."),
|
|
85
|
+
zIndex: z.number().int().finite().optional().describe("Explicit stacking order of this scope as a whole among its sibling IR children. Higher draws on top. Applies to the scope group as a single unit in the parent; does NOT affect how children stack inside the scope. Omitted = 0 = source order."),
|
|
83
86
|
children: z.array(z.lazy(() => {
|
|
84
87
|
if (!childSchemaRef) throw new Error("ScopeSchema: ChildSchema not registered yet; ensure scene.ts loaded");
|
|
85
88
|
return childSchemaRef;
|
|
@@ -56,6 +56,18 @@ var defaultWarnDispatcher = (warning) => {
|
|
|
56
56
|
if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
|
|
57
57
|
console.warn(`[retikz] ${warning.code} at ${warning.path}: ${warning.message}`);
|
|
58
58
|
};
|
|
59
|
+
var makePathPlaceholder = () => ({ type: "path-placeholder" });
|
|
60
|
+
/** 把内部 sink 收窄回公开 ScenePrimitive[]:占位已全部回填(compileToScene 末端 placeholderBalance 无条件校验兜底) */
|
|
61
|
+
var sealSink = (sink) => sink;
|
|
62
|
+
/** dev 诊断:递归找出残留占位的 index 路径,供末端无条件校验报错时定位 */
|
|
63
|
+
var collectPlaceholderLocators = (prims, prefix = "primitives") => {
|
|
64
|
+
const locators = [];
|
|
65
|
+
prims.forEach((prim, idx) => {
|
|
66
|
+
if (prim.type === "path-placeholder") locators.push(`${prefix}[${idx}]`);
|
|
67
|
+
else if (prim.type === "group") locators.push(...collectPlaceholderLocators(prim.children, `${prefix}[${idx}].children`));
|
|
68
|
+
});
|
|
69
|
+
return locators;
|
|
70
|
+
};
|
|
59
71
|
/** scope.transforms 解析失败时根据失败成因映射的 warn code */
|
|
60
72
|
var scopeTransformWarnCode = (scope) => {
|
|
61
73
|
for (const t of scope.transforms ?? []) {
|
|
@@ -98,11 +110,32 @@ var compileToScene = (ir, options = {}) => {
|
|
|
98
110
|
});
|
|
99
111
|
}
|
|
100
112
|
const primitives = [];
|
|
113
|
+
/** 已 push 但未回填的占位计数;compileToScene 返回前必须归零(无条件守 Scene 公开契约) */
|
|
114
|
+
let placeholderBalance = 0;
|
|
115
|
+
/**
|
|
116
|
+
* primitive → 显式 zIndex 旁路记录(缺省视为 0);sealSink 后按它稳定排序,不写进 primitive 本体(保 Scene 输出纯净)。
|
|
117
|
+
* key 只会是 real ScenePrimitive——占位 PathPlaceholder 永不进此 Map(占位即将被回填替换)。
|
|
118
|
+
*/
|
|
119
|
+
const zIndexOf = /* @__PURE__ */ new Map();
|
|
120
|
+
/**
|
|
121
|
+
* 按 zIndex 升序原地稳定排序:同 zIndex 保持原 IR 顺序(decorate-sort 带原始下标)。全 0 键 = 恒等。
|
|
122
|
+
* 仅在 sealSink(占位已回填、类型已收窄回 ScenePrimitive)之后调用。
|
|
123
|
+
*/
|
|
124
|
+
const stableSortByZIndex = (arr) => {
|
|
125
|
+
const decorated = arr.map((prim, index) => ({
|
|
126
|
+
prim,
|
|
127
|
+
index,
|
|
128
|
+
z: zIndexOf.get(prim) ?? 0
|
|
129
|
+
}));
|
|
130
|
+
decorated.sort((a, b) => a.z - b.z || a.index - b.index);
|
|
131
|
+
for (let i = 0; i < arr.length; i++) arr[i] = decorated[i].prim;
|
|
132
|
+
return arr;
|
|
133
|
+
};
|
|
101
134
|
const nameStack = new require_name_stack.NameStack({ onDuplicate: (info) => onWarn(formatDuplicateWarning(info)) });
|
|
102
135
|
const allPoints = [];
|
|
103
136
|
/**
|
|
104
137
|
* 解析一批本层收集的 pending paths(lookup-only 阶段)
|
|
105
|
-
* @description path
|
|
138
|
+
* @description 两种落点:有 `slot`(scopeChain 为空)→ 原位 splice 回填该 path 在本层 sink 占的位(按引用定位免索引漂移),保住与同层 node 的 IR 声明序;无 `slot`(scopeChain 非空)→ hoist 到顶层 `primitives`,因端点已是全局坐标、进 transformed GroupPrim 会被 scope.transform 二次 apply。NameStack 切到 pass2 守门:path 解析中误调 register 抛 internal error;解析完切回 pass1 让上层 scope 子树继续 register 子节点。
|
|
106
139
|
* `item.scopeChain` 记录该 path 所属 scope 累积 transform 链——传给 emitPathPrimitive,
|
|
107
140
|
* 让 step.to 内的 polar/at/offset 字面量按"当前 scope 局部度量 + 末端 apply chain"投影回全局。
|
|
108
141
|
*/
|
|
@@ -116,10 +149,18 @@ var compileToScene = (ir, options = {}) => {
|
|
|
116
149
|
irPath: item.irPath,
|
|
117
150
|
scopeChain: item.scopeChain
|
|
118
151
|
});
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
152
|
+
if (item.slot) {
|
|
153
|
+
const idx = item.slot.sink.indexOf(item.slot.placeholder);
|
|
154
|
+
if (idx === -1) throw new Error("internal: path placeholder missing from its sink");
|
|
155
|
+
const real = result?.primitives ?? [];
|
|
156
|
+
item.slot.sink.splice(idx, 1, ...real);
|
|
157
|
+
if (item.zIndex !== void 0) for (const prim of real) zIndexOf.set(prim, item.zIndex);
|
|
158
|
+
placeholderBalance--;
|
|
159
|
+
} else if (result) for (const prim of result.primitives) {
|
|
160
|
+
primitives.push(prim);
|
|
161
|
+
if (item.zIndex !== void 0) zIndexOf.set(prim, item.zIndex);
|
|
122
162
|
}
|
|
163
|
+
if (result) for (const p of result.points) allPoints.push(p);
|
|
123
164
|
}
|
|
124
165
|
} finally {
|
|
125
166
|
nameStack.exitLookupPhase();
|
|
@@ -143,7 +184,10 @@ var compileToScene = (ir, options = {}) => {
|
|
|
143
184
|
const layout = require_node.layoutNode(require_style.resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, require_style.resolveLabelDefault(styleStack), effectiveShapes);
|
|
144
185
|
const globalLayout = chain.length === 0 ? layout : require_scope.projectLayoutToGlobal(layout, chain);
|
|
145
186
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
146
|
-
for (const prim of require_node.emitNodePrimitives(layout, round))
|
|
187
|
+
for (const prim of require_node.emitNodePrimitives(layout, round)) {
|
|
188
|
+
sink.push(prim);
|
|
189
|
+
if (child.zIndex !== void 0) zIndexOf.set(prim, child.zIndex);
|
|
190
|
+
}
|
|
147
191
|
allPoints.push(require_rect.rect.anchor(globalLayout.rect, "north-west"), require_rect.rect.anchor(globalLayout.rect, "north-east"), require_rect.rect.anchor(globalLayout.rect, "south-west"), require_rect.rect.anchor(globalLayout.rect, "south-east"));
|
|
148
192
|
layoutsAccumulator.push(globalLayout);
|
|
149
193
|
} else if (child.type === "coordinate") {
|
|
@@ -196,22 +240,40 @@ var compileToScene = (ir, options = {}) => {
|
|
|
196
240
|
if (innerSink.length === 0 && !hasOwnTransforms && child.id === void 0) continue;
|
|
197
241
|
const group = {
|
|
198
242
|
type: "group",
|
|
199
|
-
children: innerSink
|
|
243
|
+
children: stableSortByZIndex(sealSink(innerSink))
|
|
200
244
|
};
|
|
201
245
|
if (hasOwnTransforms) group.transforms = [...ownTransforms];
|
|
202
246
|
sink.push(group);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
247
|
+
if (child.zIndex !== void 0) zIndexOf.set(group, child.zIndex);
|
|
248
|
+
} else {
|
|
249
|
+
const pending = {
|
|
250
|
+
path: require_style.resolveEffectivePath(child, styleStack),
|
|
251
|
+
irPath: `${locatorPrefix}children[${i}].path`,
|
|
252
|
+
scopeChain: chain,
|
|
253
|
+
zIndex: child.zIndex
|
|
254
|
+
};
|
|
255
|
+
if (chain.length === 0) {
|
|
256
|
+
const placeholder = makePathPlaceholder();
|
|
257
|
+
sink.push(placeholder);
|
|
258
|
+
pending.slot = {
|
|
259
|
+
sink,
|
|
260
|
+
placeholder
|
|
261
|
+
};
|
|
262
|
+
placeholderBalance++;
|
|
263
|
+
}
|
|
264
|
+
pathsAccumulator.push(pending);
|
|
265
|
+
}
|
|
208
266
|
}
|
|
209
267
|
};
|
|
210
268
|
const rootPaths = [];
|
|
211
269
|
processChildren(ir.children, [], primitives, "", [], rootPaths, []);
|
|
212
270
|
resolvePendingPaths(rootPaths);
|
|
271
|
+
if (placeholderBalance !== 0) {
|
|
272
|
+
const detail = typeof process !== "undefined" && process.env.NODE_ENV !== "production" ? ` at ${collectPlaceholderLocators(primitives).join(", ")}` : "";
|
|
273
|
+
throw new Error(`internal: ${placeholderBalance} unresolved path placeholder(s) leaked into Scene output${detail}`);
|
|
274
|
+
}
|
|
213
275
|
return {
|
|
214
|
-
primitives,
|
|
276
|
+
primitives: stableSortByZIndex(sealSink(primitives)),
|
|
215
277
|
layout: require_layout.computeLayout(allPoints, layoutPadding, round)
|
|
216
278
|
};
|
|
217
279
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAwC,MAAM,OAAO,CAAC;AACtE,O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B,MAAM,gBAAgB,CAAC;AA4CrE,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,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;CAC1C,CAAC;AA6FF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KA4RrE,CAAC"}
|
|
@@ -78,19 +78,51 @@ var LABEL_DIRECTION_MAP = {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
|
-
* 算 label
|
|
82
|
-
* @description 8 方向:节点对应 anchor 出发按单位向量 × distance 外推;数字角度:先取 angleBoundary 边界点再沿 (cos,sin) × distance
|
|
81
|
+
* 算 label 中心点(节点局部坐标系,未旋转)
|
|
82
|
+
* @description 8 方向:节点对应 anchor 出发按单位向量 × distance 外推;数字角度:先取 angleBoundary 边界点再沿 (cos,sin) × distance 外推。
|
|
83
|
+
* 两个分支都在 **axis-aligned rect(rotate=0)** 上算——node 自身 rotate 由外层 GroupPrim 统一施加;
|
|
84
|
+
* 若用带 rotate 的 rect,label 位置会被 anchorOf / angleBoundaryOf 旋转一次、再被外层 group 旋转一次(双重旋转)。
|
|
85
|
+
* anchorOf / angleBoundaryOf 本身不改(path anchor `'A.north'` / `'A.30'` 仍需带 rotate 的 rect)。
|
|
83
86
|
*/
|
|
84
87
|
var labelCenter = (layout, label) => {
|
|
88
|
+
const aaLayout = {
|
|
89
|
+
...layout,
|
|
90
|
+
rect: {
|
|
91
|
+
...layout.rect,
|
|
92
|
+
rotate: 0
|
|
93
|
+
}
|
|
94
|
+
};
|
|
85
95
|
if (typeof label.position === "number") {
|
|
86
96
|
const rad = label.position * Math.PI / 180;
|
|
87
|
-
const [bx, by] = angleBoundaryOf(
|
|
97
|
+
const [bx, by] = angleBoundaryOf(aaLayout, label.position);
|
|
88
98
|
return [bx + Math.cos(rad) * label.distance, by + Math.sin(rad) * label.distance];
|
|
89
99
|
}
|
|
90
100
|
const { anchor, vec } = LABEL_DIRECTION_MAP[label.position];
|
|
91
|
-
const [bx, by] = anchorOf(
|
|
101
|
+
const [bx, by] = anchorOf(aaLayout, anchor);
|
|
92
102
|
return [bx + vec[0] * label.distance, by + vec[1] * label.distance];
|
|
93
103
|
};
|
|
104
|
+
/** 角度换算常量(弧度 → 度) */
|
|
105
|
+
var RAD_TO_DEG = 180 / Math.PI;
|
|
106
|
+
/**
|
|
107
|
+
* 算 label 文本自旋角度(度,屏幕 y-down,节点局部系)
|
|
108
|
+
* @description radial = atan2(label中心 − node中心);tangent = radial + 90;number = 原值;none / 缺省 = 0。
|
|
109
|
+
* keepUpright 时把"偏离正立 > 90°"的角度翻 180° 保阅读方向。方向向量在局部坐标算,node 自身 rotate 由外层 group 叠加。
|
|
110
|
+
*/
|
|
111
|
+
var resolveLabelRotateDeg = (label, lx, ly, cx, cy) => {
|
|
112
|
+
const mode = label.rotate;
|
|
113
|
+
if (mode === void 0 || mode === "none") return 0;
|
|
114
|
+
let deg;
|
|
115
|
+
if (typeof mode === "number") deg = mode;
|
|
116
|
+
else {
|
|
117
|
+
const radial = Math.atan2(ly - cy, lx - cx) * RAD_TO_DEG;
|
|
118
|
+
deg = mode === "tangent" ? radial + 90 : radial;
|
|
119
|
+
}
|
|
120
|
+
if (label.keepUpright) {
|
|
121
|
+
const norm = (deg % 360 + 360) % 360;
|
|
122
|
+
if (norm > 90 && norm < 270) deg += 180;
|
|
123
|
+
}
|
|
124
|
+
return deg;
|
|
125
|
+
};
|
|
94
126
|
/**
|
|
95
127
|
* 取节点 shape 在指定角度方向的边界点
|
|
96
128
|
* @description 角度是节点**局部坐标系**下的极角(度数:0°=局部 +x,90°=局部 +y)。layout.rect.rotate 把局部基绕中心旋转,得到世界系下的视觉方向;shape boundaryPoint 内部用 rotate-aware 投影,所以这里把局部 (cos, sin) 经 rect.rotate 旋转后加到中心当作世界系 toward 传入。不应用 margin(同 anchorOf);用于 `'A.30'` 落点
|
|
@@ -177,7 +209,9 @@ var layoutNode = (node, measureText, nameStack, nodeDistance, scopeChain = [], l
|
|
|
177
209
|
fontSize: (labFont?.size ?? labelDefault?.font?.size ?? baseFontSize) * fontScale,
|
|
178
210
|
fontFamily: labFont?.family ?? labelDefault?.font?.family ?? fontFamily,
|
|
179
211
|
fontWeight: labFont?.weight ?? labelDefault?.font?.weight ?? fontWeight,
|
|
180
|
-
fontStyle: labFont?.style ?? labelDefault?.font?.style ?? fontStyle
|
|
212
|
+
fontStyle: labFont?.style ?? labelDefault?.font?.style ?? fontStyle,
|
|
213
|
+
rotate: lab.rotate,
|
|
214
|
+
keepUpright: lab.keepUpright
|
|
181
215
|
};
|
|
182
216
|
});
|
|
183
217
|
return {
|
|
@@ -257,37 +291,54 @@ var emitNodePrimitives = (layout, round) => {
|
|
|
257
291
|
measuredHeight: round(layout.textHeight)
|
|
258
292
|
});
|
|
259
293
|
}
|
|
260
|
-
if (layout.labels)
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
294
|
+
if (layout.labels) {
|
|
295
|
+
const cx = layout.rect.x;
|
|
296
|
+
const cy = layout.rect.y;
|
|
297
|
+
for (const lab of layout.labels) {
|
|
298
|
+
const [lx, ly] = labelCenter(layout, lab);
|
|
299
|
+
const textPrim = {
|
|
300
|
+
type: "text",
|
|
301
|
+
x: round(lx),
|
|
302
|
+
y: round(ly),
|
|
303
|
+
lines: [{ text: lab.text }],
|
|
304
|
+
fontSize: lab.fontSize,
|
|
305
|
+
fontFamily: lab.fontFamily,
|
|
306
|
+
fontWeight: lab.fontWeight,
|
|
307
|
+
fontStyle: lab.fontStyle,
|
|
308
|
+
align: "middle",
|
|
309
|
+
baseline: "middle",
|
|
310
|
+
lineHeight: round(lab.fontSize * DEFAULT_LINE_HEIGHT_FACTOR),
|
|
311
|
+
fill: lab.textColor ?? "currentColor",
|
|
312
|
+
opacity: lab.opacity ?? layout.opacity,
|
|
313
|
+
measuredWidth: 0,
|
|
314
|
+
measuredHeight: round(lab.fontSize)
|
|
315
|
+
};
|
|
316
|
+
const deg = resolveLabelRotateDeg(lab, lx, ly, cx, cy);
|
|
317
|
+
if (deg === 0) inner.push(textPrim);
|
|
318
|
+
else inner.push({
|
|
319
|
+
type: "group",
|
|
320
|
+
transforms: [{
|
|
321
|
+
kind: "rotate",
|
|
322
|
+
degrees: round(deg),
|
|
323
|
+
cx: round(lx),
|
|
324
|
+
cy: round(ly)
|
|
325
|
+
}],
|
|
326
|
+
children: [textPrim]
|
|
327
|
+
});
|
|
328
|
+
}
|
|
279
329
|
}
|
|
280
|
-
if (layout.rotateDeg
|
|
281
|
-
|
|
330
|
+
if (!(layout.rotateDeg !== 0 || layout.lines !== void 0)) return inner;
|
|
331
|
+
const group = {
|
|
282
332
|
type: "group",
|
|
283
|
-
transforms: [{
|
|
284
|
-
kind: "rotate",
|
|
285
|
-
degrees: round(layout.rotateDeg),
|
|
286
|
-
cx: round(layout.rect.x),
|
|
287
|
-
cy: round(layout.rect.y)
|
|
288
|
-
}],
|
|
289
333
|
children: inner
|
|
334
|
+
};
|
|
335
|
+
if (layout.rotateDeg !== 0) group.transforms = [{
|
|
336
|
+
kind: "rotate",
|
|
337
|
+
degrees: round(layout.rotateDeg),
|
|
338
|
+
cx: round(layout.rect.x),
|
|
339
|
+
cy: round(layout.rect.y)
|
|
290
340
|
}];
|
|
341
|
+
return [group];
|
|
291
342
|
};
|
|
292
343
|
//#endregion
|
|
293
344
|
exports.anchorOf = anchorOf;
|
|
@@ -79,6 +79,10 @@ export type NodeLabelLayout = {
|
|
|
79
79
|
fontFamily?: string;
|
|
80
80
|
fontWeight?: string | number;
|
|
81
81
|
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
82
|
+
/** label 文本自旋模式(none / radial / tangent / 数字角度);缺省 = 不旋转 */
|
|
83
|
+
rotate?: 'none' | 'radial' | 'tangent' | number;
|
|
84
|
+
/** 自旋后若文字倒置则翻 180°;缺省 false */
|
|
85
|
+
keepUpright?: boolean;
|
|
82
86
|
};
|
|
83
87
|
/**
|
|
84
88
|
* 取节点 shape 在 toward 方向的附着点(path 端点贴边用)
|
|
@@ -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,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,EAAe,MAAM,OAAO,CAAC;AAC1F,OAAO,KAAK,
|
|
1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F;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,QAAQ,QAAQ,KAAG,QACS,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,UAAU,EAAE,MAAM,MAAM,KAAG,QAM3D,CAAC;AAmEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,UAAU,MAAM,KAAG,QActE,CAAC;AAEF;;;;;;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,KACvD,UA6JF,CAAC;AAcF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,UAAU,EAClB,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAC3B,KAAK,CAAC,cAAc,CAiFtB,CAAC"}
|
package/dist/lib/ir/node.cjs
CHANGED
|
@@ -32,7 +32,13 @@ var NodeLabelSchema = zod.z.object({
|
|
|
32
32
|
distance: zod.z.number().nonnegative().optional().describe("Gap between the node border and the label center, in user units. Default 12."),
|
|
33
33
|
textColor: zod.z.string().optional().describe("Label text color; falls back to currentColor."),
|
|
34
34
|
opacity: zod.z.number().min(0).max(1).optional().describe("Label-only opacity 0..1; multiplied with the node opacity if both are set."),
|
|
35
|
-
font: require_font.FontSchema.optional().describe("Label font overrides; missing fields inherit from the parent node font, then renderer defaults.")
|
|
35
|
+
font: require_font.FontSchema.optional().describe("Label font overrides; missing fields inherit from the parent node font, then renderer defaults."),
|
|
36
|
+
rotate: zod.z.union([zod.z.enum([
|
|
37
|
+
"none",
|
|
38
|
+
"radial",
|
|
39
|
+
"tangent"
|
|
40
|
+
]), zod.z.number()]).optional().describe("Rotate the label text around its own center. `none` (default) = horizontal; `radial` = along the node-center -> label-center direction; `tangent` = radial + 90 deg; a number = explicit degrees (screen y-down: 0 = +x, 90 = +y). Only changes text orientation, not placement."),
|
|
41
|
+
keepUpright: zod.z.boolean().optional().describe("When true, flips the rotated label 180 deg if it would otherwise read upside-down (more than 90 deg from upright). Default false (strict geometric angle).")
|
|
36
42
|
}).describe("Extra text attached around a node border. Multiple labels supported via array form on `Node.label`.");
|
|
37
43
|
var NodeSchema = zod.z.object({
|
|
38
44
|
type: zod.z.literal("node").describe("Discriminator marking this child as a node"),
|
|
@@ -72,7 +78,8 @@ var NodeSchema = zod.z.object({
|
|
|
72
78
|
padding: zod.z.number().nonnegative().optional().describe("Symmetric inner padding (alias for `innerXSep` + `innerYSep`); axis-specific fields take precedence."),
|
|
73
79
|
margin: zod.z.number().nonnegative().optional().describe("Symmetric outer margin (alias for `outerSep`); axis-specific field takes precedence."),
|
|
74
80
|
font: require_font.FontSchema.optional().describe("Font spec for the inner text label (family / size / weight / style); all fields optional, all fall back to renderer defaults."),
|
|
75
|
-
label: zod.z.union([NodeLabelSchema, zod.z.array(NodeLabelSchema)]).optional().describe("Extra label(s) attached around the node border (TikZ `[label=above:foo]`); single object or array form. Compiled into one TextPrim per label, positioned by `position` direction / angle and `distance`.")
|
|
81
|
+
label: zod.z.union([NodeLabelSchema, zod.z.array(NodeLabelSchema)]).optional().describe("Extra label(s) attached around the node border (TikZ `[label=above:foo]`); single object or array form. Compiled into one TextPrim per label, positioned by `position` direction / angle and `distance`."),
|
|
82
|
+
zIndex: zod.z.number().int().finite().optional().describe("Explicit stacking order among sibling IR children. Higher draws on top. Omitted = 0 = source order. Sorting is stable: same zIndex keeps source order. Scoped per group (a node inside a scope only restacks within that scope).")
|
|
76
83
|
}).describe("Node primitive: a positioned, optionally textual shape (rectangle / circle / ellipse / diamond)");
|
|
77
84
|
//#endregion
|
|
78
85
|
exports.NODE_SHAPES = NODE_SHAPES;
|