@retikz/core 0.2.0-alpha.9 → 0.2.0-beta.1

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.
@@ -6,7 +6,7 @@ import { ArrowDefinition } from './types';
6
6
  * 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
7
7
  * openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
8
8
  * framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
9
- * emit 几何在局部 baseSize=10 坐标系,等价历史 SVG。
9
+ * emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
10
10
  */
11
11
  export declare const BUILTIN_ARROWS: Record<BuiltinArrowName, ArrowDefinition>;
12
12
  export type { ArrowDefinition, ArrowEmitContext } from './types';
@@ -39,7 +39,7 @@ var hollowPath = (ctx, points, strokeLinejoin) => ({
39
39
  * 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
40
40
  * openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
41
41
  * framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
42
- * emit 几何在局部 baseSize=10 坐标系,等价历史 SVG。
42
+ * emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
43
43
  */
44
44
  var BUILTIN_ARROWS = {
45
45
  normal: {
@@ -1,5 +1,10 @@
1
1
  /** 默认输出精度:保留 2 位小数 */
2
2
  export declare const DEFAULT_PRECISION = 2;
3
- /** 按指定小数位精度四舍五入;precision = 0 表示取整 */
3
+ /**
4
+ * 按指定小数位精度四舍五入;precision = 0 表示取整
5
+ * @description 末端把 `-0` 归一为 `+0`——`Math.round` 对负的亚精度值(如 `-0.001`)产 `-0`,
6
+ * 而 `JSON.stringify(-0) === '0'` 会让 Scene round-trip 在 `Object.is` 层失真(`-0 !== 0` 于 Object.is)。
7
+ * 归一让序列化往返稳定;数值上 `-0 === 0`,渲染 / 计算无影响。
8
+ */
4
9
  export declare const makeRound: (precision: number) => (n: number) => number;
5
10
  //# sourceMappingURL=precision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/compile/precision.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,sCAAsC;AACtC,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,MAEjC,GAAG,MAAM,WAClB,CAAC"}
1
+ {"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/compile/precision.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,MAEjC,GAAG,MAAM,WAIlB,CAAC"}
@@ -1,8 +1,16 @@
1
1
  //#region src/compile/precision.ts
2
- /** 按指定小数位精度四舍五入;precision = 0 表示取整 */
2
+ /**
3
+ * 按指定小数位精度四舍五入;precision = 0 表示取整
4
+ * @description 末端把 `-0` 归一为 `+0`——`Math.round` 对负的亚精度值(如 `-0.001`)产 `-0`,
5
+ * 而 `JSON.stringify(-0) === '0'` 会让 Scene round-trip 在 `Object.is` 层失真(`-0 !== 0` 于 Object.is)。
6
+ * 归一让序列化往返稳定;数值上 `-0 === 0`,渲染 / 计算无影响。
7
+ */
3
8
  var makeRound = (precision) => {
4
9
  const factor = 10 ** precision;
5
- return (n) => Math.round(n * factor) / factor;
10
+ return (n) => {
11
+ const r = Math.round(n * factor) / factor;
12
+ return r === 0 ? 0 : r;
13
+ };
6
14
  };
7
15
  //#endregion
8
16
  export { makeRound };
@@ -3,7 +3,7 @@ import { PatternDefinition } from './types';
3
3
  /**
4
4
  * 内置 3 pattern 注册项;与 `CompileOptions.patterns` 合并时被同名注入覆盖
5
5
  * @description `defaultSize` 统一 8(user units);motif 几何(lines 横线 / grid 横竖 / dots 圆点)
6
- * 在局部 tile 坐标系产出,等价历史 SVG。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
6
+ * 在局部 tile 坐标系产出(renderer-agnostic)。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
7
7
  */
8
8
  export declare const BUILTIN_PATTERNS: Record<BuiltinPatternName, PatternDefinition>;
9
9
  export type { PatternDefinition, PatternEmitContext } from './types';
@@ -19,7 +19,7 @@ var withBackground = (ctx, motif) => ctx.background === void 0 ? [...motif] : [{
19
19
  /**
20
20
  * 内置 3 pattern 注册项;与 `CompileOptions.patterns` 合并时被同名注入覆盖
21
21
  * @description `defaultSize` 统一 8(user units);motif 几何(lines 横线 / grid 横竖 / dots 圆点)
22
- * 在局部 tile 坐标系产出,等价历史 SVG。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
22
+ * 在局部 tile 坐标系产出(renderer-agnostic)。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
23
23
  */
24
24
  var BUILTIN_PATTERNS = {
25
25
  lines: {
@@ -39,7 +39,7 @@ var hollowPath = (ctx, points, strokeLinejoin) => ({
39
39
  * 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
40
40
  * openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
41
41
  * framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
42
- * emit 几何在局部 baseSize=10 坐标系,等价历史 SVG。
42
+ * emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
43
43
  */
44
44
  var BUILTIN_ARROWS = {
45
45
  normal: {
@@ -6,7 +6,7 @@ import { ArrowDefinition } from './types';
6
6
  * 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
7
7
  * openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
8
8
  * framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
9
- * emit 几何在局部 baseSize=10 坐标系,等价历史 SVG。
9
+ * emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
10
10
  */
11
11
  export declare const BUILTIN_ARROWS: Record<BuiltinArrowName, ArrowDefinition>;
12
12
  export type { ArrowDefinition, ArrowEmitContext } from './types';
@@ -1,8 +1,16 @@
1
1
  //#region src/compile/precision.ts
2
- /** 按指定小数位精度四舍五入;precision = 0 表示取整 */
2
+ /**
3
+ * 按指定小数位精度四舍五入;precision = 0 表示取整
4
+ * @description 末端把 `-0` 归一为 `+0`——`Math.round` 对负的亚精度值(如 `-0.001`)产 `-0`,
5
+ * 而 `JSON.stringify(-0) === '0'` 会让 Scene round-trip 在 `Object.is` 层失真(`-0 !== 0` 于 Object.is)。
6
+ * 归一让序列化往返稳定;数值上 `-0 === 0`,渲染 / 计算无影响。
7
+ */
3
8
  var makeRound = (precision) => {
4
9
  const factor = 10 ** precision;
5
- return (n) => Math.round(n * factor) / factor;
10
+ return (n) => {
11
+ const r = Math.round(n * factor) / factor;
12
+ return r === 0 ? 0 : r;
13
+ };
6
14
  };
7
15
  //#endregion
8
16
  exports.makeRound = makeRound;
@@ -1,5 +1,10 @@
1
1
  /** 默认输出精度:保留 2 位小数 */
2
2
  export declare const DEFAULT_PRECISION = 2;
3
- /** 按指定小数位精度四舍五入;precision = 0 表示取整 */
3
+ /**
4
+ * 按指定小数位精度四舍五入;precision = 0 表示取整
5
+ * @description 末端把 `-0` 归一为 `+0`——`Math.round` 对负的亚精度值(如 `-0.001`)产 `-0`,
6
+ * 而 `JSON.stringify(-0) === '0'` 会让 Scene round-trip 在 `Object.is` 层失真(`-0 !== 0` 于 Object.is)。
7
+ * 归一让序列化往返稳定;数值上 `-0 === 0`,渲染 / 计算无影响。
8
+ */
4
9
  export declare const makeRound: (precision: number) => (n: number) => number;
5
10
  //# sourceMappingURL=precision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/compile/precision.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,sCAAsC;AACtC,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,MAEjC,GAAG,MAAM,WAClB,CAAC"}
1
+ {"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/compile/precision.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,MAEjC,GAAG,MAAM,WAIlB,CAAC"}
@@ -19,7 +19,7 @@ var withBackground = (ctx, motif) => ctx.background === void 0 ? [...motif] : [{
19
19
  /**
20
20
  * 内置 3 pattern 注册项;与 `CompileOptions.patterns` 合并时被同名注入覆盖
21
21
  * @description `defaultSize` 统一 8(user units);motif 几何(lines 横线 / grid 横竖 / dots 圆点)
22
- * 在局部 tile 坐标系产出,等价历史 SVG。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
22
+ * 在局部 tile 坐标系产出(renderer-agnostic)。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
23
23
  */
24
24
  var BUILTIN_PATTERNS = {
25
25
  lines: {
@@ -3,7 +3,7 @@ import { PatternDefinition } from './types';
3
3
  /**
4
4
  * 内置 3 pattern 注册项;与 `CompileOptions.patterns` 合并时被同名注入覆盖
5
5
  * @description `defaultSize` 统一 8(user units);motif 几何(lines 横线 / grid 横竖 / dots 圆点)
6
- * 在局部 tile 坐标系产出,等价历史 SVG。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
6
+ * 在局部 tile 坐标系产出(renderer-agnostic)。`ctx.background` 给定时各 motif 首位铺一张满 tile 背景 rect。
7
7
  */
8
8
  export declare const BUILTIN_PATTERNS: Record<BuiltinPatternName, PatternDefinition>;
9
9
  export type { PatternDefinition, PatternEmitContext } from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retikz/core",
3
- "version": "0.2.0-alpha.9",
3
+ "version": "0.2.0-beta.1",
4
4
  "description": "retikz v0.1 core: framework-agnostic IR, scene compiler, and pure parsers.",
5
5
  "type": "module",
6
6
  "author": "Pionpill",