@retikz/core 0.2.0-alpha.7 → 0.2.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/dist/es/arrows/index.d.ts +13 -0
  2. package/dist/es/arrows/index.d.ts.map +1 -0
  3. package/dist/es/arrows/index.js +118 -0
  4. package/dist/es/arrows/types.d.ts +43 -0
  5. package/dist/es/arrows/types.d.ts.map +1 -0
  6. package/dist/es/compile/clip.d.ts +17 -0
  7. package/dist/es/compile/clip.d.ts.map +1 -0
  8. package/dist/es/compile/clip.js +84 -0
  9. package/dist/es/compile/compile.d.ts +26 -1
  10. package/dist/es/compile/compile.d.ts.map +1 -1
  11. package/dist/es/compile/compile.js +60 -7
  12. package/dist/es/compile/marker-prim.d.ts +22 -0
  13. package/dist/es/compile/marker-prim.d.ts.map +1 -0
  14. package/dist/es/compile/marker-prim.js +63 -0
  15. package/dist/es/compile/node.d.ts +2 -1
  16. package/dist/es/compile/node.d.ts.map +1 -1
  17. package/dist/es/compile/node.js +3 -3
  18. package/dist/es/compile/paint.d.ts +6 -1
  19. package/dist/es/compile/paint.d.ts.map +1 -1
  20. package/dist/es/compile/paint.js +60 -3
  21. package/dist/es/compile/path/anchor.d.ts.map +1 -1
  22. package/dist/es/compile/path/anchor.js +12 -0
  23. package/dist/es/compile/path/index.d.ts +15 -0
  24. package/dist/es/compile/path/index.d.ts.map +1 -1
  25. package/dist/es/compile/path/index.js +268 -12
  26. package/dist/es/compile/path/relative.d.ts.map +1 -1
  27. package/dist/es/compile/path/relative.js +8 -0
  28. package/dist/es/compile/path/shrink.d.ts +19 -6
  29. package/dist/es/compile/path/shrink.d.ts.map +1 -1
  30. package/dist/es/compile/path/shrink.js +147 -25
  31. package/dist/es/compile/position.d.ts +8 -2
  32. package/dist/es/compile/position.d.ts.map +1 -1
  33. package/dist/es/compile/position.js +7 -1
  34. package/dist/es/geometry/bend.d.ts +7 -0
  35. package/dist/es/geometry/bend.d.ts.map +1 -1
  36. package/dist/es/geometry/bend.js +26 -1
  37. package/dist/es/index.d.ts +16 -4
  38. package/dist/es/index.d.ts.map +1 -1
  39. package/dist/es/index.js +13 -7
  40. package/dist/es/ir/clip.d.ts +72 -0
  41. package/dist/es/ir/clip.d.ts.map +1 -0
  42. package/dist/es/ir/clip.js +37 -0
  43. package/dist/es/ir/coordinate.d.ts +3 -3
  44. package/dist/es/ir/coordinate.d.ts.map +1 -1
  45. package/dist/es/ir/coordinate.js +4 -2
  46. package/dist/es/ir/index.d.ts +2 -0
  47. package/dist/es/ir/index.d.ts.map +1 -1
  48. package/dist/es/ir/json.d.ts +22 -0
  49. package/dist/es/ir/json.d.ts.map +1 -0
  50. package/dist/es/ir/json.js +25 -0
  51. package/dist/es/ir/node.d.ts +10 -10
  52. package/dist/es/ir/node.d.ts.map +1 -1
  53. package/dist/es/ir/node.js +4 -2
  54. package/dist/es/ir/paint.d.ts +25 -3
  55. package/dist/es/ir/paint.d.ts.map +1 -1
  56. package/dist/es/ir/paint.js +12 -6
  57. package/dist/es/ir/path/arrow.d.ts +40 -60
  58. package/dist/es/ir/path/arrow.d.ts.map +1 -1
  59. package/dist/es/ir/path/arrow.js +5 -5
  60. package/dist/es/ir/path/path.d.ts +553 -164
  61. package/dist/es/ir/path/path.d.ts.map +1 -1
  62. package/dist/es/ir/path/path.js +21 -1
  63. package/dist/es/ir/path/step.d.ts +483 -128
  64. package/dist/es/ir/path/step.d.ts.map +1 -1
  65. package/dist/es/ir/path/step.js +18 -5
  66. package/dist/es/ir/path/target.d.ts +1 -1
  67. package/dist/es/ir/path/target.d.ts.map +1 -1
  68. package/dist/es/ir/path/target.js +4 -2
  69. package/dist/es/ir/position/between-position.d.ts +26 -0
  70. package/dist/es/ir/position/between-position.d.ts.map +1 -0
  71. package/dist/es/ir/position/between-position.js +21 -0
  72. package/dist/es/ir/position/index.d.ts +1 -0
  73. package/dist/es/ir/position/index.d.ts.map +1 -1
  74. package/dist/es/ir/scene.d.ts +51 -0
  75. package/dist/es/ir/scene.d.ts.map +1 -1
  76. package/dist/es/ir/scene.js +14 -2
  77. package/dist/es/ir/scope.d.ts +999 -380
  78. package/dist/es/ir/scope.d.ts.map +1 -1
  79. package/dist/es/ir/scope.js +2 -0
  80. package/dist/es/pathGenerators/define.d.ts +16 -0
  81. package/dist/es/pathGenerators/define.d.ts.map +1 -0
  82. package/dist/es/pathGenerators/define.js +23 -0
  83. package/dist/es/pathGenerators/index.d.ts +9 -0
  84. package/dist/es/pathGenerators/index.d.ts.map +1 -0
  85. package/dist/es/pathGenerators/types.d.ts +45 -0
  86. package/dist/es/pathGenerators/types.d.ts.map +1 -0
  87. package/dist/es/patterns/index.d.ts +10 -0
  88. package/dist/es/patterns/index.d.ts.map +1 -0
  89. package/dist/es/patterns/index.js +83 -0
  90. package/dist/es/patterns/types.d.ts +38 -0
  91. package/dist/es/patterns/types.d.ts.map +1 -0
  92. package/dist/es/primitive/clip.d.ts +18 -0
  93. package/dist/es/primitive/clip.d.ts.map +1 -0
  94. package/dist/es/primitive/group.d.ts +6 -0
  95. package/dist/es/primitive/group.d.ts.map +1 -1
  96. package/dist/es/primitive/index.d.ts +2 -0
  97. package/dist/es/primitive/index.d.ts.map +1 -1
  98. package/dist/es/primitive/marker.d.ts +160 -0
  99. package/dist/es/primitive/marker.d.ts.map +1 -0
  100. package/dist/es/primitive/paint.d.ts +32 -4
  101. package/dist/es/primitive/paint.d.ts.map +1 -1
  102. package/dist/es/primitive/path.d.ts +22 -18
  103. package/dist/es/primitive/path.d.ts.map +1 -1
  104. package/dist/es/primitive/scene.d.ts +2 -1
  105. package/dist/es/primitive/scene.d.ts.map +1 -1
  106. package/dist/lib/arrows/index.cjs +118 -0
  107. package/dist/lib/arrows/index.d.ts +13 -0
  108. package/dist/lib/arrows/index.d.ts.map +1 -0
  109. package/dist/lib/arrows/types.d.ts +43 -0
  110. package/dist/lib/arrows/types.d.ts.map +1 -0
  111. package/dist/lib/compile/clip.cjs +84 -0
  112. package/dist/lib/compile/clip.d.ts +17 -0
  113. package/dist/lib/compile/clip.d.ts.map +1 -0
  114. package/dist/lib/compile/compile.cjs +62 -9
  115. package/dist/lib/compile/compile.d.ts +26 -1
  116. package/dist/lib/compile/compile.d.ts.map +1 -1
  117. package/dist/lib/compile/marker-prim.cjs +63 -0
  118. package/dist/lib/compile/marker-prim.d.ts +22 -0
  119. package/dist/lib/compile/marker-prim.d.ts.map +1 -0
  120. package/dist/lib/compile/node.cjs +3 -3
  121. package/dist/lib/compile/node.d.ts +2 -1
  122. package/dist/lib/compile/node.d.ts.map +1 -1
  123. package/dist/lib/compile/paint.cjs +60 -3
  124. package/dist/lib/compile/paint.d.ts +6 -1
  125. package/dist/lib/compile/paint.d.ts.map +1 -1
  126. package/dist/lib/compile/path/anchor.cjs +12 -0
  127. package/dist/lib/compile/path/anchor.d.ts.map +1 -1
  128. package/dist/lib/compile/path/index.cjs +266 -10
  129. package/dist/lib/compile/path/index.d.ts +15 -0
  130. package/dist/lib/compile/path/index.d.ts.map +1 -1
  131. package/dist/lib/compile/path/relative.cjs +8 -0
  132. package/dist/lib/compile/path/relative.d.ts.map +1 -1
  133. package/dist/lib/compile/path/shrink.cjs +147 -25
  134. package/dist/lib/compile/path/shrink.d.ts +19 -6
  135. package/dist/lib/compile/path/shrink.d.ts.map +1 -1
  136. package/dist/lib/compile/position.cjs +7 -1
  137. package/dist/lib/compile/position.d.ts +8 -2
  138. package/dist/lib/compile/position.d.ts.map +1 -1
  139. package/dist/lib/geometry/bend.cjs +26 -0
  140. package/dist/lib/geometry/bend.d.ts +7 -0
  141. package/dist/lib/geometry/bend.d.ts.map +1 -1
  142. package/dist/lib/index.cjs +20 -3
  143. package/dist/lib/index.d.ts +16 -4
  144. package/dist/lib/index.d.ts.map +1 -1
  145. package/dist/lib/ir/clip.cjs +37 -0
  146. package/dist/lib/ir/clip.d.ts +72 -0
  147. package/dist/lib/ir/clip.d.ts.map +1 -0
  148. package/dist/lib/ir/coordinate.cjs +4 -2
  149. package/dist/lib/ir/coordinate.d.ts +3 -3
  150. package/dist/lib/ir/coordinate.d.ts.map +1 -1
  151. package/dist/lib/ir/index.d.ts +2 -0
  152. package/dist/lib/ir/index.d.ts.map +1 -1
  153. package/dist/lib/ir/json.cjs +26 -0
  154. package/dist/lib/ir/json.d.ts +22 -0
  155. package/dist/lib/ir/json.d.ts.map +1 -0
  156. package/dist/lib/ir/node.cjs +4 -2
  157. package/dist/lib/ir/node.d.ts +10 -10
  158. package/dist/lib/ir/node.d.ts.map +1 -1
  159. package/dist/lib/ir/paint.cjs +12 -5
  160. package/dist/lib/ir/paint.d.ts +25 -3
  161. package/dist/lib/ir/paint.d.ts.map +1 -1
  162. package/dist/lib/ir/path/arrow.cjs +5 -5
  163. package/dist/lib/ir/path/arrow.d.ts +40 -60
  164. package/dist/lib/ir/path/arrow.d.ts.map +1 -1
  165. package/dist/lib/ir/path/path.cjs +20 -0
  166. package/dist/lib/ir/path/path.d.ts +553 -164
  167. package/dist/lib/ir/path/path.d.ts.map +1 -1
  168. package/dist/lib/ir/path/step.cjs +18 -4
  169. package/dist/lib/ir/path/step.d.ts +483 -128
  170. package/dist/lib/ir/path/step.d.ts.map +1 -1
  171. package/dist/lib/ir/path/target.cjs +4 -2
  172. package/dist/lib/ir/path/target.d.ts +1 -1
  173. package/dist/lib/ir/path/target.d.ts.map +1 -1
  174. package/dist/lib/ir/position/between-position.cjs +22 -0
  175. package/dist/lib/ir/position/between-position.d.ts +26 -0
  176. package/dist/lib/ir/position/between-position.d.ts.map +1 -0
  177. package/dist/lib/ir/position/index.d.ts +1 -0
  178. package/dist/lib/ir/position/index.d.ts.map +1 -1
  179. package/dist/lib/ir/scene.cjs +14 -1
  180. package/dist/lib/ir/scene.d.ts +51 -0
  181. package/dist/lib/ir/scene.d.ts.map +1 -1
  182. package/dist/lib/ir/scope.cjs +2 -0
  183. package/dist/lib/ir/scope.d.ts +999 -380
  184. package/dist/lib/ir/scope.d.ts.map +1 -1
  185. package/dist/lib/pathGenerators/define.cjs +23 -0
  186. package/dist/lib/pathGenerators/define.d.ts +16 -0
  187. package/dist/lib/pathGenerators/define.d.ts.map +1 -0
  188. package/dist/lib/pathGenerators/index.d.ts +9 -0
  189. package/dist/lib/pathGenerators/index.d.ts.map +1 -0
  190. package/dist/lib/pathGenerators/types.d.ts +45 -0
  191. package/dist/lib/pathGenerators/types.d.ts.map +1 -0
  192. package/dist/lib/patterns/index.cjs +83 -0
  193. package/dist/lib/patterns/index.d.ts +10 -0
  194. package/dist/lib/patterns/index.d.ts.map +1 -0
  195. package/dist/lib/patterns/types.d.ts +38 -0
  196. package/dist/lib/patterns/types.d.ts.map +1 -0
  197. package/dist/lib/primitive/clip.d.ts +18 -0
  198. package/dist/lib/primitive/clip.d.ts.map +1 -0
  199. package/dist/lib/primitive/group.d.ts +6 -0
  200. package/dist/lib/primitive/group.d.ts.map +1 -1
  201. package/dist/lib/primitive/index.d.ts +2 -0
  202. package/dist/lib/primitive/index.d.ts.map +1 -1
  203. package/dist/lib/primitive/marker.d.ts +160 -0
  204. package/dist/lib/primitive/marker.d.ts.map +1 -0
  205. package/dist/lib/primitive/paint.d.ts +32 -4
  206. package/dist/lib/primitive/paint.d.ts.map +1 -1
  207. package/dist/lib/primitive/path.d.ts +22 -18
  208. package/dist/lib/primitive/path.d.ts.map +1 -1
  209. package/dist/lib/primitive/scene.d.ts +2 -1
  210. package/dist/lib/primitive/scene.d.ts.map +1 -1
  211. package/package.json +1 -1
  212. package/dist/es/compile/path/arrow-geometry.d.ts +0 -22
  213. package/dist/es/compile/path/arrow-geometry.d.ts.map +0 -1
  214. package/dist/es/compile/path/arrow-geometry.js +0 -40
  215. package/dist/lib/compile/path/arrow-geometry.cjs +0 -41
  216. package/dist/lib/compile/path/arrow-geometry.d.ts +0 -22
  217. package/dist/lib/compile/path/arrow-geometry.d.ts.map +0 -1
@@ -1,8 +1,10 @@
1
1
  import { PaintResolver } from '../paint';
2
2
  import { IRPath, IRPosition } from '../../ir';
3
3
  import { ScenePrimitive, Transform } from '../../primitive';
4
+ import { PathGeneratorDefinition } from '../../pathGenerators';
4
5
  import { NameStack } from '../name-stack';
5
6
  import { TextMeasurer } from '../text-metrics';
7
+ import { EffectiveArrows } from './shrink';
6
8
  /** emitPathPrimitive 可选 warn 钩子 */
7
9
  export type EmitPathWarnHook = {
8
10
  /** 警告收集器(由 compileToScene 传入) */
@@ -21,6 +23,19 @@ export type EmitPathWarnHook = {
21
23
  scopeChain?: ReadonlyArray<Transform>;
22
24
  /** fill 解析器(PaintSpec → resourceRef + 登记资源);缺省时纯色透传、PaintSpec 退化为无填充 */
23
25
  resolveFill?: PaintResolver;
26
+ /**
27
+ * 有效 arrow 表(内置 7 + 注入);缺省 = 仅内置 7
28
+ * @description compileToScene 合并 `{ ...BUILTIN_ARROWS, ...options.arrows }` 传入;
29
+ * endpointArrows 据此查表算 shrink / 调 def.emit;未注册名编译期 throw
30
+ */
31
+ effectiveArrows?: EffectiveArrows;
32
+ /**
33
+ * 有效 path generator 表(注入即全部,core 无内置);缺省 = 空表
34
+ * @description compileToScene 传 `options.pathGenerators ?? {}`;generator step 据此查表(未注册名
35
+ * 编译期 throw,错误列出可用名)→ 双 parse 护栏 → targetParams resolve → 调 generate splice 命令。
36
+ * 解析逻辑由后续实现落地(此处仅声明 hook 入口)。
37
+ */
38
+ effectivePathGenerators?: Record<string, PathGeneratorDefinition>;
24
39
  };
25
40
  /**
26
41
  * IR Path → PathPrim
@@ -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,EACN,UAAU,EAGX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAEV,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,e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AAe,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,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,IA0tBrE,CAAC"}
@@ -32,6 +32,14 @@ var normalizeRelativeTargets = (steps, nameStack, scopeChain = []) => {
32
32
  out.push(step);
33
33
  continue;
34
34
  }
35
+ if (step.kind === "generator") {
36
+ out.push(step);
37
+ if (step.to !== void 0) {
38
+ const pos = require_anchor.refPointOfTarget(step.to, nameStack, scopeChain);
39
+ if (pos) prevEnd = pos;
40
+ }
41
+ continue;
42
+ }
35
43
  const original = step.to;
36
44
  let resolvedTo = original;
37
45
  let updatePrevEnd = true;
@@ -1 +1 @@
1
- {"version":3,"file":"relative.d.ts","sourceRoot":"","sources":["../../../../src/compile/path/relative.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAY,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI/C;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,aAAa,CAAC,MAAM,CAAC,EAC5B,WAAW,SAAS,EACpB,aAAY,aAAa,CAAC,SAAS,CAAM,KACxC,KAAK,CAAC,MAAM,CA6Ed,CAAC"}
1
+ {"version":3,"file":"relative.d.ts","sourceRoot":"","sources":["../../../../src/compile/path/relative.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAY,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI/C;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,aAAa,CAAC,MAAM,CAAC,EAC5B,WAAW,SAAS,EACpB,aAAY,aAAa,CAAC,SAAS,CAAM,KACxC,KAAK,CAAC,MAAM,CAuFd,CAAC"}
@@ -1,12 +1,21 @@
1
1
  const require_arrow = require("../../ir/path/arrow.cjs");
2
+ const require_marker_prim = require("../marker-prim.cjs");
2
3
  const require_anchor = require("./anchor.cjs");
3
- const require_arrow_geometry = require("./arrow-geometry.cjs");
4
4
  //#region src/compile/path/shrink.ts
5
+ /** 默认 baseSize(marker 局部基准边长,viewBox `0 0 baseSize baseSize`) */
6
+ var ARROW_GEOMETRY_BASE_SIZE = 10;
7
+ /** 查 effective 表取 def;未注册名编译期 throw(消息含字母序可用名列表) */
8
+ var lookupArrowDef = (shape, effective) => {
9
+ if (Object.prototype.hasOwnProperty.call(effective, shape)) return effective[shape];
10
+ const available = Object.keys(effective).sort().join(", ");
11
+ throw new Error(`Unknown arrow shape '${shape}'; available: ${available}`);
12
+ };
5
13
  /**
6
- * 端点级 spec:顶层默认 ⊕ end-side override(逐字段 merge)
7
- * @description 缺省字段继承顶层(不是"完全替换");空心 shape 上 fill 字段被丢(silent no-op
14
+ * 端点级视觉输入:顶层默认 ⊕ end-side override(逐字段 merge)
15
+ * @description 缺省字段继承顶层(不是"完全替换");空心 def 上 fill 字段被丢(silent no-op)。
16
+ * 产 compile-internal 中间体,供 shrink + emit 消费。
8
17
  */
9
- var resolveArrowEndSpec = (topLevel, endSide) => {
18
+ var resolveArrowVisual = (topLevel, endSide, effective) => {
10
19
  const baseShape = endSide?.shape ?? topLevel.shape ?? require_arrow.DEFAULT_ARROW_SHAPE;
11
20
  const out = { shape: baseShape };
12
21
  const scale = endSide?.scale ?? topLevel.scale;
@@ -21,35 +30,148 @@ var resolveArrowEndSpec = (topLevel, endSide) => {
21
30
  if (opacity !== void 0) out.opacity = opacity;
22
31
  const lineWidth = endSide?.lineWidth ?? topLevel.lineWidth;
23
32
  if (lineWidth !== void 0) out.lineWidth = lineWidth;
24
- if (!require_arrow_geometry.isHollowArrowShape(baseShape)) {
33
+ if (!lookupArrowDef(baseShape, effective).hollow) {
25
34
  const fill = endSide?.fill ?? topLevel.fill;
26
35
  if (fill !== void 0) out.fill = fill;
27
36
  }
28
37
  return out;
29
38
  };
30
- /** IR path-level `arrow` + `arrowDetail` → PathPrim 起末端点箭头规格 */
31
- var endpointArrows = (arrow, detail) => {
32
- if (!arrow || arrow === "none") return {};
33
- const top = detail ?? {};
34
- const startSpec = resolveArrowEndSpec(top, top.start);
35
- const endSpec = resolveArrowEndSpec(top, top.end);
36
- switch (arrow) {
37
- case "->": return { arrowEnd: endSpec };
38
- case "<-": return { arrowStart: startSpec };
39
- case "<->": return {
40
- arrowStart: startSpec,
41
- arrowEnd: endSpec
42
- };
39
+ /**
40
+ * 校验 def 几何字段有限(baseSize 还须 > 0)
41
+ * @description 第三方 / LLM 写出的 def 可能漏字段或塞 NaN / Infinity / 0 baseSize;这些数会经 shrink 公式
42
+ * 污染 path 本体坐标(非仅 marker),故在此抛清晰错(含 shape 名,便于自修),不放任 NaN 静默流出。
43
+ */
44
+ var assertFiniteGeometry = (shape, def) => {
45
+ if (!Number.isFinite(def.lineContactX)) throw new Error(`Arrow '${shape}' has a non-finite lineContactX (${String(def.lineContactX)}); it must be a finite number.`);
46
+ if (def.baseSize !== void 0 && (!Number.isFinite(def.baseSize) || def.baseSize <= 0)) throw new Error(`Arrow '${shape}' has an invalid baseSize (${String(def.baseSize)}); it must be a finite number greater than 0.`);
47
+ if (def.tipX !== void 0 && !Number.isFinite(def.tipX)) throw new Error(`Arrow '${shape}' has a non-finite tipX (${String(def.tipX)}); it must be a finite number.`);
48
+ };
49
+ /**
50
+ * 调 def.emit 收集 marker 并跑窄子集 + JSON-safe 校验
51
+ * @description emit 缺失 / 非函数 / 抛错 / 返回非 iterable 都包成含 shape 名的清晰错(便于第三方 / LLM 自修),
52
+ * 不泄漏内部变量名;产物逐个过共享 `validateMarkerPrimitives`(窄子集 + 深度无函数检查,与 pattern motif 同套)。
53
+ */
54
+ var callEmit = (shape, def, ctx) => {
55
+ if (typeof def.emit !== "function") throw new Error(`Arrow '${shape}' is missing an emit function (ArrowDefinition.emit is required).`);
56
+ let marker;
57
+ try {
58
+ marker = [...def.emit(ctx)];
59
+ } catch (e) {
60
+ throw new Error(`Arrow '${shape}' emit failed: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
43
61
  }
62
+ require_marker_prim.validateMarkerPrimitives(`Arrow '${shape}'`, marker);
63
+ return marker;
64
+ };
65
+ /** 据 def + 视觉输入解析端点几何(baseSize / tipX / contactX / resolved length·width) */
66
+ var resolveGeometry = (visual, effective) => {
67
+ const def = lookupArrowDef(visual.shape, effective);
68
+ assertFiniteGeometry(visual.shape, def);
69
+ const baseSize = def.baseSize ?? ARROW_GEOMETRY_BASE_SIZE;
70
+ const tipX = def.tipX ?? baseSize;
71
+ const lineWidth = visual.lineWidth ?? 1.5;
72
+ const contactX = def.hollow ? def.lineContactX - lineWidth / 2 : def.lineContactX;
73
+ const scale = visual.scale ?? 1;
74
+ const resolvedLength = (visual.length ?? def.defaultLength ?? 6) * scale;
75
+ const resolvedWidth = (visual.width ?? def.defaultWidth ?? 6) * scale;
76
+ if (!Number.isFinite(resolvedLength) || !Number.isFinite(resolvedWidth)) throw new Error(`Arrow '${visual.shape}' resolved length/width is non-finite (length × scale overflowed); use smaller length / scale values.`);
77
+ return {
78
+ def,
79
+ baseSize,
80
+ tipX,
81
+ contactX,
82
+ lineWidth,
83
+ resolvedLength,
84
+ resolvedWidth
85
+ };
44
86
  };
45
87
  /**
46
88
  * 端点级 shrink(strokeWidth 倍):line 末端朝起点缩这么多,让箭头尖端落回原 target
47
89
  * @description 不分实心 / 空心:路径端点接在箭头尾部或凹口,箭头尖端仍贴原 target。低 opacity 下不会再透出 line。
48
90
  */
49
- var computeShrink = (spec) => {
50
- const geometry = require_arrow_geometry.resolveArrowShapeGeometry(spec);
51
- const length = (spec.length ?? geometry.defaultLength) * (spec.scale ?? 1);
52
- return (geometry.tipX - geometry.lineContactX) * length / geometry.baseSize;
91
+ var computeShrink = (geometry) => (geometry.tipX - geometry.contactX) * geometry.resolvedLength / geometry.baseSize;
92
+ /**
93
+ * def + 解析后视觉输入构 `ArrowEmitContext`
94
+ * @description hollow def:fill 丢(neutral)、stroke = color override ?? contextStroke、lineWidth 启用;
95
+ * solid def:fill = fill ?? color ?? contextStroke、stroke = color ?? contextStroke。
96
+ */
97
+ var buildEmitContext = (visual, geometry, round) => {
98
+ const contextStroke = { kind: "contextStroke" };
99
+ return {
100
+ stroke: visual.color ?? contextStroke,
101
+ fill: geometry.def.hollow ? contextStroke : visual.fill ?? visual.color ?? contextStroke,
102
+ lineWidth: geometry.lineWidth,
103
+ round
104
+ };
105
+ };
106
+ /**
107
+ * 把视觉中间体物化成最终 `ArrowEndSpec`(已解析 marker 描述)
108
+ * @description 构 `ArrowEmitContext` → 调 `def.emit` 收集 `MarkerPrimitive[]`,并算 baseSize /
109
+ * refX(hollow 减 lineWidth/2)/ markerWidth = 解析 length / markerHeight = 解析 width / opacity 透传。
110
+ */
111
+ var materializeArrowEndSpec = (visual, geometry, round) => {
112
+ const ctx = buildEmitContext(visual, geometry, round);
113
+ const marker = callEmit(visual.shape, geometry.def, ctx);
114
+ const out = {
115
+ shape: visual.shape,
116
+ baseSize: geometry.baseSize,
117
+ refX: geometry.contactX,
118
+ markerWidth: geometry.resolvedLength,
119
+ markerHeight: geometry.resolvedWidth,
120
+ marker
121
+ };
122
+ if (visual.opacity !== void 0) out.opacity = visual.opacity;
123
+ return out;
124
+ };
125
+ /**
126
+ * IR path-level `arrow` + `arrowDetail` → PathPrim 起末端点已解析 marker 描述
127
+ * @description merge 视觉输入 → 查 effective 表 + 解析几何 → 算 shrink → 调 def.emit 物化最终 `ArrowEndSpec`。
128
+ * 返回同时带 compile-internal 的 shrink 量(端点收缩在 compile 落,与 emit 落点无关)。
129
+ * 未注册 shape 名在此 throw(lookupArrowDef)。
130
+ */
131
+ var endpointArrows = (arrow, detail, effective, round) => {
132
+ if (!arrow || arrow === "none") return {
133
+ shrinkStart: 0,
134
+ shrinkEnd: 0
135
+ };
136
+ const top = detail ?? {};
137
+ const wantStart = arrow === "<-" || arrow === "<->";
138
+ const wantEnd = arrow === "->" || arrow === "<->";
139
+ const result = {
140
+ shrinkStart: 0,
141
+ shrinkEnd: 0
142
+ };
143
+ if (wantStart) {
144
+ const visual = resolveArrowVisual(top, top.start, effective);
145
+ const geometry = resolveGeometry(visual, effective);
146
+ result.arrowStart = materializeArrowEndSpec(visual, geometry, round);
147
+ result.shrinkStart = computeShrink(geometry);
148
+ }
149
+ if (wantEnd) {
150
+ const visual = resolveArrowVisual(top, top.end, effective);
151
+ const geometry = resolveGeometry(visual, effective);
152
+ result.arrowEnd = materializeArrowEndSpec(visual, geometry, round);
153
+ result.shrinkEnd = computeShrink(geometry);
154
+ }
155
+ return result;
156
+ };
157
+ /**
158
+ * 解析一个中段标记 `IRArrowMark` 为已物化的 marker 描述(`ArrowEndSpec`)
159
+ * @description 复用端点箭头同一管线:mark 自身视觉子集字段(shape / scale / length / width / color /
160
+ * fill / opacity / lineWidth)即 `ResolvedArrowVisual`(空心 def 上 fill 字段被丢)→ 查 effective 表
161
+ * 解析几何 → 调 def.emit 物化局部 baseSize 几何 + wrapper 参数。方向由调用方按路径切线决定,本函数不含定向。
162
+ * 未注册 shape 名在此 throw(lookupArrowDef)。
163
+ */
164
+ var resolveMarkArrowSpec = (mark, effective, round) => {
165
+ const baseShape = mark.shape ?? require_arrow.DEFAULT_ARROW_SHAPE;
166
+ const visual = { shape: baseShape };
167
+ if (mark.scale !== void 0) visual.scale = mark.scale;
168
+ if (mark.length !== void 0) visual.length = mark.length;
169
+ if (mark.width !== void 0) visual.width = mark.width;
170
+ if (mark.color !== void 0) visual.color = mark.color;
171
+ if (mark.opacity !== void 0) visual.opacity = mark.opacity;
172
+ if (mark.lineWidth !== void 0) visual.lineWidth = mark.lineWidth;
173
+ if (!lookupArrowDef(baseShape, effective).hollow && mark.fill !== void 0) visual.fill = mark.fill;
174
+ return materializeArrowEndSpec(visual, resolveGeometry(visual, effective), round);
53
175
  };
54
176
  /** 取一个 PathCommand 末端 endpoint(move/line/quad/cubic → to;arc/ellipseArc → polar(end);close 无端点) */
55
177
  var endpointOf = (cmd) => {
@@ -92,7 +214,7 @@ var setEndpoint = (commands, idx, newPt, round) => {
92
214
  * @description 让 line 端点接在 hollow arrow 尾部外缘、不贯穿 back outline;shrink=0 的实心 shape 跳过。in-place 改写 commands 数组
93
215
  */
94
216
  var applyArrowShrinks = (commands, shrinkStart, shrinkEnd, strokeWidth, round) => {
95
- if (shrinkStart > 0) {
217
+ if (shrinkStart !== 0) {
96
218
  const firstIdx = commands.findIndex((o) => o.kind === "move");
97
219
  if (firstIdx >= 0) {
98
220
  const cur = commands[firstIdx];
@@ -103,7 +225,7 @@ var applyArrowShrinks = (commands, shrinkStart, shrinkEnd, strokeWidth, round) =
103
225
  }
104
226
  }
105
227
  }
106
- if (shrinkEnd > 0) {
228
+ if (shrinkEnd !== 0) {
107
229
  let lastIdx = -1;
108
230
  for (let i = commands.length - 1; i >= 0; i--) if (commands[i].kind !== "close") {
109
231
  lastIdx = i;
@@ -125,5 +247,5 @@ var applyArrowShrinks = (commands, shrinkStart, shrinkEnd, strokeWidth, round) =
125
247
  };
126
248
  //#endregion
127
249
  exports.applyArrowShrinks = applyArrowShrinks;
128
- exports.computeShrink = computeShrink;
129
250
  exports.endpointArrows = endpointArrows;
251
+ exports.resolveMarkArrowSpec = resolveMarkArrowSpec;
@@ -1,15 +1,28 @@
1
- import { IRArrowDetail } from '../../ir';
1
+ import { IRArrowDetail, IRArrowMark } from '../../ir';
2
+ import { ArrowDefinition } from '../../arrows';
2
3
  import { ArrowEndSpec, PathCommand } from '../../primitive';
3
- /** IR path-level `arrow` + `arrowDetail` PathPrim 起末端点箭头规格 */
4
- export declare const endpointArrows: (arrow: "none" | "->" | "<-" | "<->" | undefined, detail: IRArrowDetail | undefined) => {
4
+ /** 有效 arrow 表:内置 7 + 注入(同名注入覆盖内置) */
5
+ export type EffectiveArrows = Record<string, ArrowDefinition>;
6
+ /**
7
+ * IR path-level `arrow` + `arrowDetail` → PathPrim 起末端点已解析 marker 描述
8
+ * @description merge 视觉输入 → 查 effective 表 + 解析几何 → 算 shrink → 调 def.emit 物化最终 `ArrowEndSpec`。
9
+ * 返回同时带 compile-internal 的 shrink 量(端点收缩在 compile 落,与 emit 落点无关)。
10
+ * 未注册 shape 名在此 throw(lookupArrowDef)。
11
+ */
12
+ export declare const endpointArrows: (arrow: "none" | "->" | "<-" | "<->" | undefined, detail: IRArrowDetail | undefined, effective: EffectiveArrows, round: (n: number) => number) => {
5
13
  arrowStart?: ArrowEndSpec;
6
14
  arrowEnd?: ArrowEndSpec;
15
+ shrinkStart: number;
16
+ shrinkEnd: number;
7
17
  };
8
18
  /**
9
- * 端点级 shrink(strokeWidth 倍):line 末端朝起点缩这么多,让箭头尖端落回原 target
10
- * @description 不分实心 / 空心:路径端点接在箭头尾部或凹口,箭头尖端仍贴原 target。低 opacity 下不会再透出 line。
19
+ * 解析一个中段标记 `IRArrowMark` 为已物化的 marker 描述(`ArrowEndSpec`)
20
+ * @description 复用端点箭头同一管线:mark 自身视觉子集字段(shape / scale / length / width / color /
21
+ * fill / opacity / lineWidth)即 `ResolvedArrowVisual`(空心 def 上 fill 字段被丢)→ 查 effective 表
22
+ * 解析几何 → 调 def.emit 物化局部 baseSize 几何 + wrapper 参数。方向由调用方按路径切线决定,本函数不含定向。
23
+ * 未注册 shape 名在此 throw(lookupArrowDef)。
11
24
  */
12
- export declare const computeShrink: (spec: ArrowEndSpec) => number;
25
+ export declare const resolveMarkArrowSpec: (mark: IRArrowMark, effective: EffectiveArrows, round: (n: number) => number) => ArrowEndSpec;
13
26
  /**
14
27
  * 按 shape + spec(length / scale / lineWidth)把首/末段端点向内缩短
15
28
  * @description 让 line 端点接在 hollow arrow 尾部外缘、不贯穿 back outline;shrink=0 的实心 shape 跳过。in-place 改写 commands 数组
@@ -1 +1 @@
1
- {"version":3,"file":"shrink.d.ts","sourceRoot":"","sources":["../../../../src/compile/path/shrink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAA0C,MAAM,UAAU,CAAC;AAC3G,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAmCjE,gEAAgE;AAChE,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,EAC/C,QAAQ,aAAa,GAAG,SAAS,KAChC;IAAE,UAAU,CAAC,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,EAAE,YAAY,CAAA;CAatD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,YAAY,KAAG,MAIlD,CAAC;AAiDF;;;GAG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,MAAM,KAAK,MAAM,KAC3B,IA4CF,CAAC"}
@@ -35,7 +35,7 @@ var DIRECTION_VECTOR = {
35
35
  * - 节点 id lookup 走 NameStack.lookup 进行 inside-out 搜索(内层 frame 可见外层 frame);
36
36
  * nodeDistance 为容器 prop 注入默认距离,AtPosition 自带 distance 优先
37
37
  */
38
- var resolvePosition = (pos, nameStack, nodeDistance = DEFAULT_NODE_DISTANCE, scopeChain = []) => {
38
+ var resolvePosition = (pos, nameStack, nodeDistance = DEFAULT_NODE_DISTANCE, scopeChain = [], resolveBetweenGlobal) => {
39
39
  if (typeof pos === "string") {
40
40
  const node = nameStack.lookup(pos);
41
41
  if (!node) return null;
@@ -57,6 +57,12 @@ var resolvePosition = (pos, nameStack, nodeDistance = DEFAULT_NODE_DISTANCE, sco
57
57
  if (!base) return null;
58
58
  return [base[0] + pos.offset[0], base[1] + pos.offset[1]];
59
59
  }
60
+ if ("between" in pos) {
61
+ if (!resolveBetweenGlobal) return null;
62
+ const global = resolveBetweenGlobal(pos, nameStack, scopeChain);
63
+ if (!global) return null;
64
+ return scopeChain.length === 0 ? global : require_scope.inverseTransformChain(global, scopeChain);
65
+ }
60
66
  let origin;
61
67
  if (!pos.origin) origin = [0, 0];
62
68
  else {
@@ -1,6 +1,12 @@
1
- import { IRAtPosition, IROffsetPosition, IRPosition, PolarPosition } from '../ir';
1
+ import { IRAtPosition, IRBetweenPosition, IROffsetPosition, IRPosition, PolarPosition } from '../ir';
2
2
  import { Transform } from '../primitive';
3
3
  import { NameStack } from './name-stack';
4
+ /**
5
+ * between 端点 → 世界坐标解析器(依赖注入,避免 position.ts ↔ compile/path/anchor.ts 循环)
6
+ * @description 实参由 compile 层注入(= `refPointOfTarget`,处理 NodeTarget anchor / Cartesian / Polar /
7
+ * Offset / 嵌套 between,返回世界坐标)。resolvePosition 收到 between 时调它取世界中点再反投影回局部。
8
+ */
9
+ export type ResolveBetweenGlobal = (between: IRBetweenPosition, nameStack: NameStack, scopeChain: ReadonlyArray<Transform>) => IRPosition | null;
4
10
  /**
5
11
  * IR 各种位置形态(笛卡尔/极坐标/相对定位/偏移定位/节点 id)→ 笛卡尔位置
6
12
  * @description
@@ -20,5 +26,5 @@ import { NameStack } from './name-stack';
20
26
  * - 节点 id lookup 走 NameStack.lookup 进行 inside-out 搜索(内层 frame 可见外层 frame);
21
27
  * nodeDistance 为容器 prop 注入默认距离,AtPosition 自带 distance 优先
22
28
  */
23
- export declare const resolvePosition: (pos: IRPosition | PolarPosition | IRAtPosition | IROffsetPosition | string, nameStack: NameStack, nodeDistance?: number, scopeChain?: ReadonlyArray<Transform>) => IRPosition | null;
29
+ export declare const resolvePosition: (pos: IRPosition | PolarPosition | IRAtPosition | IROffsetPosition | IRBetweenPosition | string, nameStack: NameStack, nodeDistance?: number, scopeChain?: ReadonlyArray<Transform>, resolveBetweenGlobal?: ResolveBetweenGlobal) => IRPosition | null;
24
30
  //# sourceMappingURL=position.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/compile/position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAqB9C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,gBAAgB,GAAG,MAAM,EAC1E,WAAW,SAAS,EACpB,eAAc,MAA8B,EAC5C,aAAY,aAAa,CAAC,SAAS,CAAM,KACxC,UAAU,GAAG,IAyCf,CAAC"}
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/compile/position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACvH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,KACjC,UAAU,GAAG,IAAI,CAAC;AAoBvB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,MAAM,EAC9F,WAAW,SAAS,EACpB,eAAc,MAA8B,EAC5C,aAAY,aAAa,CAAC,SAAS,CAAM,EACzC,uBAAuB,oBAAoB,KAC1C,UAAU,GAAG,IAiDf,CAAC"}
@@ -14,5 +14,31 @@ var bendControlPoints = (from, to, direction, bendAngle) => {
14
14
  const ctlOffset = 4 / 3 * (chord * Math.tan(bendAngle * Math.PI / 180 / 2));
15
15
  return [[from[0] + dx / 3 + ctlOffset * nx, from[1] + dy / 3 + ctlOffset * ny], [from[0] + 2 * dx / 3 + ctlOffset * nx, from[1] + 2 * dy / 3 + ctlOffset * ny]];
16
16
  };
17
+ /** 默认 looseness(looseness 缺省时) */
18
+ var DEFAULT_LOOSENESS = 1;
19
+ /** self-loop(from==to)默认环大小(user units,受 looseness 缩放) */
20
+ var DEFAULT_LOOP_SIZE = 1;
21
+ /** 直边 cubic 控制点距离系数(chord 的几分之一) */
22
+ var OUTIN_DISTANCE_FACTOR = 1 / 3;
23
+ /** 角度(度)转单位方向向量(0°=+x,90°=+y screen-down,与 IR 角度约定一致) */
24
+ var dirOf = (angleDeg) => {
25
+ const rad = angleDeg * Math.PI / 180;
26
+ return [Math.cos(rad), Math.sin(rad)];
27
+ };
28
+ /**
29
+ * out/in 角 + looseness 拟合 from→to 的非对称 cubic(含 self-loop 退化)
30
+ * @description 标准 TikZ:control1 = from + d·dir(outAngle),control2 = to + d·dir(inAngle);
31
+ * d = looseness × distance,distance = chord × 系数(chord>0)或默认环大小(self-loop,from==to chord=0)。
32
+ * self-loop 时两控制点沿 out/in 两个不同方向各自从端点撑开,画出环(bend 对称弯在 chord=0 时退化为点,故 out/in 是自环唯一手段)。
33
+ */
34
+ var outInControlPoints = (from, to, outAngle, inAngle, looseness) => {
35
+ const k = looseness ?? DEFAULT_LOOSENESS;
36
+ const chord = Math.hypot(to[0] - from[0], to[1] - from[1]);
37
+ const d = k * (chord === 0 ? DEFAULT_LOOP_SIZE : chord * OUTIN_DISTANCE_FACTOR);
38
+ const outDir = dirOf(outAngle);
39
+ const inDir = dirOf(inAngle);
40
+ return [[from[0] + d * outDir[0], from[1] + d * outDir[1]], [to[0] + d * inDir[0], to[1] + d * inDir[1]]];
41
+ };
17
42
  //#endregion
18
43
  exports.bendControlPoints = bendControlPoints;
44
+ exports.outInControlPoints = outInControlPoints;
@@ -4,4 +4,11 @@ import { Position } from './point';
4
4
  * @description apex offset = chord × tan(bendAngle/2);控制点取 chord 1/3 与 2/3 处沿法向偏移,让 cubic 在 t=0.5 穿过 apex 故 ctlOffset = 4/3 × apexOffset。法向(screen y-down):visual-left=(dy,-dx)/|chord|,visual-right=(-dy,dx)/|chord|。chord=0 时两控制点都返回 from
5
5
  */
6
6
  export declare const bendControlPoints: (from: Position, to: Position, direction: "left" | "right", bendAngle: number) => [Position, Position];
7
+ /**
8
+ * out/in 角 + looseness 拟合 from→to 的非对称 cubic(含 self-loop 退化)
9
+ * @description 标准 TikZ:control1 = from + d·dir(outAngle),control2 = to + d·dir(inAngle);
10
+ * d = looseness × distance,distance = chord × 系数(chord>0)或默认环大小(self-loop,from==to chord=0)。
11
+ * self-loop 时两控制点沿 out/in 两个不同方向各自从端点撑开,画出环(bend 对称弯在 chord=0 时退化为点,故 out/in 是自环唯一手段)。
12
+ */
13
+ export declare const outInControlPoints: (from: Position, to: Position, outAngle: number, inAngle: number, looseness?: number) => [Position, Position];
7
14
  //# sourceMappingURL=bend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bend.d.ts","sourceRoot":"","sources":["../../../src/geometry/bend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,WAAW,MAAM,GAAG,OAAO,EAC3B,WAAW,MAAM,KAChB,CAAC,QAAQ,EAAE,QAAQ,CAgBrB,CAAC"}
1
+ {"version":3,"file":"bend.d.ts","sourceRoot":"","sources":["../../../src/geometry/bend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,WAAW,MAAM,GAAG,OAAO,EAC3B,WAAW,MAAM,KAChB,CAAC,QAAQ,EAAE,QAAQ,CAgBrB,CAAC;AAiBF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,UAAU,MAAM,EAChB,SAAS,MAAM,EACf,YAAY,MAAM,KACjB,CAAC,QAAQ,EAAE,QAAQ,CAUrB,CAAC"}
@@ -3,13 +3,16 @@ const require_position = require("./ir/position/position.cjs");
3
3
  const require_polar_position = require("./ir/position/polar-position.cjs");
4
4
  const require_at_position = require("./ir/position/at-position.cjs");
5
5
  const require_offset_position = require("./ir/position/offset-position.cjs");
6
+ const require__transform = require("./geometry/_transform.cjs");
7
+ const require_rect = require("./geometry/rect.cjs");
8
+ const require_target = require("./ir/path/target.cjs");
9
+ const require_between_position = require("./ir/position/between-position.cjs");
6
10
  const require_font = require("./ir/font.cjs");
11
+ const require_json = require("./ir/json.cjs");
7
12
  const require_paint = require("./ir/paint.cjs");
13
+ const require_clip = require("./ir/clip.cjs");
8
14
  const require_text = require("./ir/text.cjs");
9
15
  const require_arrow = require("./ir/path/arrow.cjs");
10
- const require__transform = require("./geometry/_transform.cjs");
11
- const require_rect = require("./geometry/rect.cjs");
12
- const require_target = require("./ir/path/target.cjs");
13
16
  const require_step = require("./ir/path/step.cjs");
14
17
  const require_path = require("./ir/path/path.cjs");
15
18
  const require_node = require("./ir/node.cjs");
@@ -21,6 +24,8 @@ const require_circle = require("./geometry/circle.cjs");
21
24
  const require_ellipse = require("./geometry/ellipse.cjs");
22
25
  const require_diamond = require("./geometry/diamond.cjs");
23
26
  const require_index = require("./shapes/index.cjs");
27
+ const require_index$1 = require("./arrows/index.cjs");
28
+ const require_index$2 = require("./patterns/index.cjs");
24
29
  const require_text_metrics = require("./compile/text-metrics.cjs");
25
30
  const require_layout = require("./compile/layout.cjs");
26
31
  const require_compile = require("./compile/compile.cjs");
@@ -29,21 +34,27 @@ const require_parseTargetSugar = require("./parsers/parseTargetSugar.cjs");
29
34
  const require_parseWay = require("./parsers/parseWay.cjs");
30
35
  const require_polar = require("./geometry/polar.cjs");
31
36
  const require_point = require("./geometry/point.cjs");
37
+ const require_define = require("./pathGenerators/define.cjs");
32
38
  exports.ARROW_MARKER_DEFAULT_SIZE = require_arrow.ARROW_MARKER_DEFAULT_SIZE;
33
39
  exports.ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH = require_arrow.ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH;
34
40
  exports.ARROW_SHAPES = require_arrow.ARROW_SHAPES;
35
41
  exports.AT_DIRECTIONS = require_at_position.AT_DIRECTIONS;
42
+ exports.AbsoluteTargetSchema = require_between_position.AbsoluteTargetSchema;
36
43
  exports.AnchorRefSchema = require_target.AnchorRefSchema;
37
44
  exports.ArcStepSchema = require_step.ArcStepSchema;
38
45
  exports.ArrowDefaultSchema = require_scope.ArrowDefaultSchema;
39
46
  exports.ArrowDetailSchema = require_arrow.ArrowDetailSchema;
40
47
  exports.ArrowEndDetailSchema = require_arrow.ArrowEndDetailSchema;
41
48
  exports.AtPositionSchema = require_at_position.AtPositionSchema;
49
+ exports.BUILTIN_ARROWS = require_index$1.BUILTIN_ARROWS;
50
+ exports.BUILTIN_PATTERNS = require_index$2.BUILTIN_PATTERNS;
42
51
  exports.BUILTIN_SHAPES = require_index.BUILTIN_SHAPES;
43
52
  exports.BendStepSchema = require_step.BendStepSchema;
53
+ exports.BetweenPositionSchema = require_between_position.BetweenPositionSchema;
44
54
  exports.CURRENT_IR_VERSION = require_scene.CURRENT_IR_VERSION;
45
55
  exports.ChildSchema = require_scene.ChildSchema;
46
56
  exports.CirclePathStepSchema = require_step.CirclePathStepSchema;
57
+ exports.ClipSpecSchema = require_clip.ClipSpecSchema;
47
58
  exports.ControlPointSchema = require_step.ControlPointSchema;
48
59
  exports.CoordinateSchema = require_coordinate.CoordinateSchema;
49
60
  exports.CubicStepSchema = require_step.CubicStepSchema;
@@ -54,8 +65,11 @@ exports.DrawWay = require_parseWay.DrawWay;
54
65
  exports.EllipsePathStepSchema = require_step.EllipsePathStepSchema;
55
66
  exports.FoldStepSchema = require_step.FoldStepSchema;
56
67
  exports.FontSchema = require_font.FontSchema;
68
+ exports.GeneratorStepSchema = require_step.GeneratorStepSchema;
57
69
  exports.GradientStopSchema = require_paint.GradientStopSchema;
58
70
  exports.HOLLOW_ARROW_SHAPES = require_arrow.HOLLOW_ARROW_SHAPES;
71
+ exports.JsonObjectSchema = require_json.JsonObjectSchema;
72
+ exports.JsonValueSchema = require_json.JsonValueSchema;
59
73
  exports.LabelDefaultSchema = require_scope.LabelDefaultSchema;
60
74
  exports.LineSpecSchema = require_text.LineSpecSchema;
61
75
  exports.LineStepSchema = require_step.LineStepSchema;
@@ -67,6 +81,7 @@ exports.NodeLabelSchema = require_node.NodeLabelSchema;
67
81
  exports.NodeSchema = require_node.NodeSchema;
68
82
  exports.NodeTargetSchema = require_target.NodeTargetSchema;
69
83
  exports.OffsetPositionSchema = require_offset_position.OffsetPositionSchema;
84
+ exports.PATTERN_SHAPES = require_paint.PATTERN_SHAPES;
70
85
  exports.PaintSpecSchema = require_paint.PaintSpecSchema;
71
86
  exports.PathDefaultSchema = require_scope.PathDefaultSchema;
72
87
  exports.PathSchema = require_path.PathSchema;
@@ -83,9 +98,11 @@ exports.StepSchema = require_step.StepSchema;
83
98
  exports.TargetSchema = require_target.TargetSchema;
84
99
  exports.TextBlockSchema = require_text.TextBlockSchema;
85
100
  exports.TransformSchema = require_transform.TransformSchema;
101
+ exports.ViewBoxSchema = require_scene.ViewBoxSchema;
86
102
  exports.circle = require_circle.circle;
87
103
  exports.compileToScene = require_compile.compileToScene;
88
104
  exports.computeLayout = require_layout.computeLayout;
105
+ exports.definePathGenerator = require_define.definePathGenerator;
89
106
  exports.diamond = require_diamond.diamond;
90
107
  exports.ellipse = require_ellipse.ellipse;
91
108
  exports.fallbackMeasurer = require_text_metrics.fallbackMeasurer;
@@ -2,14 +2,20 @@
2
2
  * @retikz/core 公开 API
3
3
  * @description 任何 framework adapter(@retikz/react、@retikz/vue、@retikz/canvas、@retikz/ssr)只能 import 本文件导出内容,不准走子路径。本包零 React/零 DOM 依赖
4
4
  */
5
- export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, AnchorRefSchema, NodeTargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, RectangleStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ScopeSchema, NodeDefaultSchema, PathDefaultSchema, LabelDefaultSchema, ArrowDefaultSchema, TransformSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, PaintSpecSchema, GradientStopSchema, } from './ir';
6
- export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRAnchorRef, IRNodeTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRRectangleStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRScope, IRNodeDefault, IRPathDefault, IRLabelDefault, IRArrowDefault, StyleChannel, IRTransform, IRTranslateTransform, IRPolarTranslateTransform, IRAtTranslateTransform, IROffsetTranslateTransform, IRRotateTransform, IRScaleTransform, IRChild, IR, ArrowShape, IRArrowDetail, IRArrowEndDetail, NodeShape, BuiltinShapeName, NodeTextAlign, IRPaintSpec, IRGradientStop, } 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, } from './ir';
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, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ScopeSchema, NodeDefaultSchema, PathDefaultSchema, LabelDefaultSchema, ArrowDefaultSchema, TransformSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, PaintSpecSchema, GradientStopSchema, JsonValueSchema, JsonObjectSchema, ClipSpecSchema, ViewBoxSchema, } from './ir';
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, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRScope, 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, } from './ir';
8
8
  export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, PathCommand,
9
9
  /** 7 个 named PathCommand 分支(便于 wrapper / Pick<>) */
10
10
  MovePathCommand, LinePathCommand, QuadPathCommand, CubicPathCommand, ArcPathCommand, EllipseArcPathCommand, ClosePathCommand, ArrowEndSpec, GroupPrim, Transform,
11
11
  /** 3 个 named Transform 分支 */
12
- TranslateTransform, RotateTransform, ScaleTransform, Layout, Scene, PaintValue, SceneResource, } from './primitive';
12
+ TranslateTransform, RotateTransform, ScaleTransform, Layout, Scene, PaintValue, SceneResource, PaintResource,
13
+ /** 裁剪资源(renderer-agnostic,adapter 物化 `<clipPath>`) */
14
+ ClipResource, ClipShape,
15
+ /** 已解析 pattern tile(emit-in-compile 产物,进 Scene 资源,纯数据无函数) */
16
+ ResolvedPatternTile,
17
+ /** marker 窄子集(ArrowDefinition.emit 产物,renderer-agnostic) */
18
+ MarkerPrimitive, MarkerPathPrim, MarkerEllipsePrim, MarkerRectPrim, MarkerGroupPrim, MarkerPathCommand, MarkerFill, } from './primitive';
13
19
  export type { FontSpec, TextMetrics, TextMeasurer, CompileOptions, CompileWarning, } from './compile';
14
20
  export { computeLayout, fallbackMeasurer, compileToScene } from './compile';
15
21
  export type { WayItem, WayDSL, WayCycle, WayVia, WayRelativeItem, WayLabel, WayLabelOp, } from './parsers';
@@ -18,5 +24,11 @@ export type { Position, Rect, RectAnchor, Circle, Ellipse, Diamond, PolarPositio
18
24
  export { point, rect, circle, ellipse, diamond, RECT_ANCHORS, polar } from './geometry';
19
25
  export type { ShapeDefinition, ShapeStyle } from './shapes';
20
26
  export { BUILTIN_SHAPES, worldToLocal, localToWorld } from './shapes';
27
+ export type { ArrowDefinition, ArrowEmitContext } from './arrows';
28
+ export { BUILTIN_ARROWS } from './arrows';
29
+ export type { PatternDefinition, PatternEmitContext } from './patterns';
30
+ export { BUILTIN_PATTERNS } from './patterns';
31
+ export type { PathGeneratorDefinition, PathGeneratorContext } from './pathGenerators';
32
+ export { definePathGenerator } from './pathGenerators';
21
33
  export type { ValueOf, AssertEqual } from './types';
22
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,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,MAAM,SAAS,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,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,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,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,MAAM,EACN,OAAO,EACP,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd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ACN,eAAe,EACf,QAAQ,EACR,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjF,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACP,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxF,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGtE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,37 @@
1
+ let zod = require("zod");
2
+ //#region src/ir/clip.ts
3
+ /**
4
+ * 裁剪区规格(4 种结构化形状之一)
5
+ * @description renderer-agnostic 的纯数值裁剪区:`rect` 取景窗 / `circle` 圆形遮罩 / `ellipse` 椭圆遮罩 /
6
+ * `polygon` 任意直边区域。坐标为所在 scope 的局部坐标系(与 scope children 同帧)。
7
+ * 尺寸字段 `.positive().finite()`、坐标 `.finite()` 守 Scene JSON 可序列化(NaN/Infinity round-trip 失真)。
8
+ * 不含 SVG path 迷你语言(任意贝塞尔裁剪推迟)。
9
+ */
10
+ var ClipSpecSchema = zod.z.discriminatedUnion("kind", [
11
+ zod.z.object({
12
+ kind: zod.z.literal("rect"),
13
+ x: zod.z.number().finite().describe("Rect left-top x in scope-local coords"),
14
+ y: zod.z.number().finite().describe("Rect left-top y in scope-local coords"),
15
+ width: zod.z.number().finite().positive().describe("Rect width (> 0)"),
16
+ height: zod.z.number().finite().positive().describe("Rect height (> 0)")
17
+ }).describe("Rectangular clip region"),
18
+ zod.z.object({
19
+ kind: zod.z.literal("circle"),
20
+ cx: zod.z.number().finite().describe("Circle center x"),
21
+ cy: zod.z.number().finite().describe("Circle center y"),
22
+ r: zod.z.number().finite().positive().describe("Circle radius (> 0)")
23
+ }).describe("Circular clip region"),
24
+ zod.z.object({
25
+ kind: zod.z.literal("ellipse"),
26
+ cx: zod.z.number().finite().describe("Ellipse center x"),
27
+ cy: zod.z.number().finite().describe("Ellipse center y"),
28
+ rx: zod.z.number().finite().positive().describe("Ellipse x radius (> 0)"),
29
+ ry: zod.z.number().finite().positive().describe("Ellipse y radius (> 0)")
30
+ }).describe("Elliptical clip region"),
31
+ zod.z.object({
32
+ kind: zod.z.literal("polygon"),
33
+ points: zod.z.array(zod.z.tuple([zod.z.number().finite(), zod.z.number().finite()])).min(3).describe("Polygon vertices [x, y][]; at least 3 points, each finite")
34
+ }).describe("Polygon clip region (arbitrary straight-edge area)")
35
+ ]).describe("Clip region: one of rect / circle / ellipse / polygon, in scope-local coordinates. Used by `Scope.clip`; compiled into a renderer-agnostic ClipResource and referenced via the group `clipRef`.");
36
+ //#endregion
37
+ exports.ClipSpecSchema = ClipSpecSchema;