@open-pencil/scene-graph 0.17.0-beta.5 → 0.17.0-beta.6

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 (151) hide show
  1. package/dist/comments/schema.d.ts.map +1 -1
  2. package/dist/comments/schema.js +1 -0
  3. package/dist/comments/schema.js.map +1 -1
  4. package/dist/comments/threads.d.ts +2 -0
  5. package/dist/comments/threads.d.ts.map +1 -1
  6. package/dist/comments/threads.js +11 -5
  7. package/dist/comments/threads.js.map +1 -1
  8. package/dist/components/properties.d.ts.map +1 -1
  9. package/dist/components/properties.js +1 -1
  10. package/dist/components/properties.js.map +1 -1
  11. package/dist/constants.d.ts +12 -2
  12. package/dist/constants.d.ts.map +1 -1
  13. package/dist/constants.js +42 -1
  14. package/dist/constants.js.map +1 -1
  15. package/dist/copy.d.ts.map +1 -1
  16. package/dist/copy.js +2 -0
  17. package/dist/copy.js.map +1 -1
  18. package/dist/css/grid.d.ts.map +1 -1
  19. package/dist/css/grid.js +27 -3
  20. package/dist/css/grid.js.map +1 -1
  21. package/dist/css/index.d.ts +3 -3
  22. package/dist/css/index.js +3 -3
  23. package/dist/css/layout.d.ts +13 -1
  24. package/dist/css/layout.d.ts.map +1 -1
  25. package/dist/css/layout.js +26 -1
  26. package/dist/css/layout.js.map +1 -1
  27. package/dist/css/values.d.ts +18 -1
  28. package/dist/css/values.d.ts.map +1 -1
  29. package/dist/css/values.js +39 -1
  30. package/dist/css/values.js.map +1 -1
  31. package/dist/geometry.d.ts +6 -6
  32. package/dist/geometry.d.ts.map +1 -1
  33. package/dist/geometry.js +4 -20
  34. package/dist/geometry.js.map +1 -1
  35. package/dist/graph.d.ts +5 -2
  36. package/dist/graph.d.ts.map +1 -1
  37. package/dist/graph.js +16 -6
  38. package/dist/graph.js.map +1 -1
  39. package/dist/icons/glyph.d.ts.map +1 -1
  40. package/dist/icons/glyph.js +1 -1
  41. package/dist/icons/glyph.js.map +1 -1
  42. package/dist/ids.js +1 -1
  43. package/dist/ids.js.map +1 -1
  44. package/dist/index.d.ts +2 -2
  45. package/dist/instances/index.d.ts +6 -1
  46. package/dist/instances/index.d.ts.map +1 -1
  47. package/dist/instances/index.js +20 -8
  48. package/dist/instances/index.js.map +1 -1
  49. package/dist/instances/swap.js +1 -1
  50. package/dist/instances/swap.js.map +1 -1
  51. package/dist/instances/sync.js +25 -1
  52. package/dist/instances/sync.js.map +1 -1
  53. package/dist/layout/index.d.ts +2 -1
  54. package/dist/layout/index.js +2 -1
  55. package/dist/layout/strokes.d.ts +10 -0
  56. package/dist/layout/strokes.d.ts.map +1 -0
  57. package/dist/layout/strokes.js +30 -0
  58. package/dist/layout/strokes.js.map +1 -0
  59. package/dist/node-defaults.d.ts.map +1 -1
  60. package/dist/node-defaults.js +49 -37
  61. package/dist/node-defaults.js.map +1 -1
  62. package/dist/outline/flatten.d.ts.map +1 -1
  63. package/dist/outline/flatten.js +2 -2
  64. package/dist/outline/flatten.js.map +1 -1
  65. package/dist/parse-path.d.ts +4 -1
  66. package/dist/parse-path.d.ts.map +1 -1
  67. package/dist/parse-path.js +15 -1
  68. package/dist/parse-path.js.map +1 -1
  69. package/dist/paths/index.d.ts +2 -2
  70. package/dist/paths/index.js +2 -2
  71. package/dist/paths/network.d.ts +26 -6
  72. package/dist/paths/network.d.ts.map +1 -1
  73. package/dist/paths/network.js +79 -13
  74. package/dist/paths/network.js.map +1 -1
  75. package/dist/paths/smooth-corners.d.ts.map +1 -1
  76. package/dist/paths/smooth-corners.js +1 -1
  77. package/dist/paths/smooth-corners.js.map +1 -1
  78. package/dist/primitives/index.d.ts +1 -7
  79. package/dist/primitives/index.d.ts.map +1 -1
  80. package/dist/shaders/model.d.ts.map +1 -1
  81. package/dist/shaders/model.js +1 -1
  82. package/dist/shaders/model.js.map +1 -1
  83. package/dist/shared-styles.d.ts.map +1 -1
  84. package/dist/shared-styles.js +2 -9
  85. package/dist/shared-styles.js.map +1 -1
  86. package/dist/strokes.d.ts +39 -0
  87. package/dist/strokes.d.ts.map +1 -0
  88. package/dist/strokes.js +104 -0
  89. package/dist/strokes.js.map +1 -0
  90. package/dist/text/index.d.ts +2 -1
  91. package/dist/text/index.js +2 -1
  92. package/dist/text/runs.d.ts +29 -0
  93. package/dist/text/runs.d.ts.map +1 -0
  94. package/dist/text/runs.js +72 -0
  95. package/dist/text/runs.js.map +1 -0
  96. package/dist/transfer/dependencies.d.ts.map +1 -1
  97. package/dist/transfer/dependencies.js +1 -1
  98. package/dist/transfer/dependencies.js.map +1 -1
  99. package/dist/types.d.ts +35 -2
  100. package/dist/types.d.ts.map +1 -1
  101. package/dist/types.js.map +1 -1
  102. package/dist/variables/resolution.d.ts.map +1 -1
  103. package/dist/variables/resolution.js +1 -1
  104. package/dist/variables/resolution.js.map +1 -1
  105. package/dist/vector-network.d.ts.map +1 -1
  106. package/dist/vector-network.js +2 -4
  107. package/dist/vector-network.js.map +1 -1
  108. package/package.json +10 -13
  109. package/src/comments/schema.ts +1 -0
  110. package/src/comments/threads.ts +13 -5
  111. package/src/components/properties.ts +2 -1
  112. package/src/constants.ts +25 -1
  113. package/src/copy.ts +2 -0
  114. package/src/css/grid.ts +31 -3
  115. package/src/css/index.ts +13 -2
  116. package/src/css/layout.ts +36 -0
  117. package/src/css/values.ts +49 -0
  118. package/src/geometry.ts +9 -27
  119. package/src/graph.ts +13 -6
  120. package/src/icons/glyph.ts +2 -1
  121. package/src/ids.ts +1 -1
  122. package/src/instances/index.ts +24 -9
  123. package/src/instances/swap.ts +2 -1
  124. package/src/instances/sync.ts +41 -0
  125. package/src/layout/index.ts +1 -0
  126. package/src/layout/strokes.ts +23 -0
  127. package/src/node-defaults.ts +48 -33
  128. package/src/outline/flatten.ts +2 -1
  129. package/src/parse-path.ts +14 -0
  130. package/src/paths/network.ts +90 -13
  131. package/src/paths/smooth-corners.ts +2 -1
  132. package/src/primitives/index.ts +0 -5
  133. package/src/shaders/model.ts +2 -1
  134. package/src/shared-styles.ts +3 -4
  135. package/src/strokes.ts +121 -0
  136. package/src/text/index.ts +1 -0
  137. package/src/text/runs.ts +80 -0
  138. package/src/transfer/dependencies.ts +2 -1
  139. package/src/types.ts +37 -0
  140. package/src/variables/resolution.ts +2 -1
  141. package/src/vector-network.ts +2 -4
  142. package/dist/arrays.d.ts +0 -17
  143. package/dist/arrays.d.ts.map +0 -1
  144. package/dist/arrays.js +0 -38
  145. package/dist/arrays.js.map +0 -1
  146. package/dist/random.d.ts +0 -7
  147. package/dist/random.d.ts.map +0 -1
  148. package/dist/random.js +0 -25
  149. package/dist/random.js.map +0 -1
  150. package/src/arrays.ts +0 -37
  151. package/src/random.ts +0 -28
@@ -1,5 +1,7 @@
1
1
  import { isEqual } from 'es-toolkit/predicate'
2
2
 
3
+ import { isRecord } from '@open-pencil/std/records'
4
+
3
5
  import { cloneVectorNetwork, copyVectorRegion } from './copy'
4
6
  import type { Mat3 } from './matrix'
5
7
  import type { VectorPathWindingRule } from './parse-path'
@@ -306,10 +308,6 @@ function isInteger(value: unknown): value is number {
306
308
  return typeof value === 'number' && Number.isInteger(value)
307
309
  }
308
310
 
309
- function isRecord(value: unknown): value is Record<string, unknown> {
310
- return typeof value === 'object' && value !== null
311
- }
312
-
313
311
  export type NormalizableVectorNetwork = Omit<VectorNetwork, 'regions'> & {
314
312
  regions?: VectorNetwork['regions']
315
313
  }
package/dist/arrays.d.ts DELETED
@@ -1,17 +0,0 @@
1
- //#region src/arrays.d.ts
2
- /**
3
- * Helpers for lists of any length. Spreading an array into a call's arguments, as in
4
- * `push(...items)` or `Math.max(...values)`, throws once it holds more than about 120,000 items in
5
- * Chrome; these take any number (`@open-pencil/data/no-spread-arguments`).
6
- */
7
- /** Appends every item of `items` to `target`, in order. */
8
- declare function appendAll<T>(target: T[], items: Iterable<T>): void;
9
- /** Inserts every item of `items` into `target` before `index`, in order, as `splice` would. */
10
- declare function insertAll<T>(target: T[], index: number, items: Iterable<T>): void;
11
- /** The largest of `values`, or `-Infinity` when there are none, as `Math.max` gives. */
12
- declare function maxOf(values: Iterable<number>): number;
13
- /** The smallest of `values`, or `Infinity` when there are none, as `Math.min` gives. */
14
- declare function minOf(values: Iterable<number>): number;
15
- //#endregion
16
- export { appendAll, insertAll, maxOf, minOf };
17
- //# sourceMappingURL=arrays.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arrays.d.ts","names":[],"sources":["../src/arrays.ts"],"mappings":";;;;;;;iBAOgB,UAAU,GAAG,QAAQ,KAAK,OAAO,SAAS;;iBAK1C,UAAU,GAAG,QAAQ,KAAK,eAAe,OAAO,SAAS;;iBAOzD,MAAM,QAAQ;;iBAUd,MAAM,QAAQ"}
package/dist/arrays.js DELETED
@@ -1,38 +0,0 @@
1
- //#region src/arrays.ts
2
- /**
3
- * Helpers for lists of any length. Spreading an array into a call's arguments, as in
4
- * `push(...items)` or `Math.max(...values)`, throws once it holds more than about 120,000 items in
5
- * Chrome; these take any number (`@open-pencil/data/no-spread-arguments`).
6
- */
7
- /** Appends every item of `items` to `target`, in order. */
8
- function appendAll(target, items) {
9
- for (const item of items) target.push(item);
10
- }
11
- /** Inserts every item of `items` into `target` before `index`, in order, as `splice` would. */
12
- function insertAll(target, index, items) {
13
- const tail = target.splice(index);
14
- appendAll(target, items);
15
- appendAll(target, tail);
16
- }
17
- /** The largest of `values`, or `-Infinity` when there are none, as `Math.max` gives. */
18
- function maxOf(values) {
19
- let largest = -Infinity;
20
- for (const value of values) {
21
- if (Number.isNaN(value)) return NaN;
22
- if (value > largest) largest = value;
23
- }
24
- return largest;
25
- }
26
- /** The smallest of `values`, or `Infinity` when there are none, as `Math.min` gives. */
27
- function minOf(values) {
28
- let smallest = Infinity;
29
- for (const value of values) {
30
- if (Number.isNaN(value)) return NaN;
31
- if (value < smallest) smallest = value;
32
- }
33
- return smallest;
34
- }
35
- //#endregion
36
- export { appendAll, insertAll, maxOf, minOf };
37
-
38
- //# sourceMappingURL=arrays.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arrays.js","names":[],"sources":["../src/arrays.ts"],"sourcesContent":["/**\n * Helpers for lists of any length. Spreading an array into a call's arguments, as in\n * `push(...items)` or `Math.max(...values)`, throws once it holds more than about 120,000 items in\n * Chrome; these take any number (`@open-pencil/data/no-spread-arguments`).\n */\n\n/** Appends every item of `items` to `target`, in order. */\nexport function appendAll<T>(target: T[], items: Iterable<T>): void {\n for (const item of items) target.push(item)\n}\n\n/** Inserts every item of `items` into `target` before `index`, in order, as `splice` would. */\nexport function insertAll<T>(target: T[], index: number, items: Iterable<T>): void {\n const tail = target.splice(index)\n appendAll(target, items)\n appendAll(target, tail)\n}\n\n/** The largest of `values`, or `-Infinity` when there are none, as `Math.max` gives. */\nexport function maxOf(values: Iterable<number>): number {\n let largest = -Infinity\n for (const value of values) {\n if (Number.isNaN(value)) return Number.NaN\n if (value > largest) largest = value\n }\n return largest\n}\n\n/** The smallest of `values`, or `Infinity` when there are none, as `Math.min` gives. */\nexport function minOf(values: Iterable<number>): number {\n let smallest = Infinity\n for (const value of values) {\n if (Number.isNaN(value)) return Number.NaN\n if (value < smallest) smallest = value\n }\n return smallest\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,UAAa,QAAa,OAA0B;CAClE,KAAK,MAAM,QAAQ,OAAO,OAAO,KAAK,IAAI;AAC5C;;AAGA,SAAgB,UAAa,QAAa,OAAe,OAA0B;CACjF,MAAM,OAAO,OAAO,OAAO,KAAK;CAChC,UAAU,QAAQ,KAAK;CACvB,UAAU,QAAQ,IAAI;AACxB;;AAGA,SAAgB,MAAM,QAAkC;CACtD,IAAI,UAAU;CACd,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,OAAO,MAAM,KAAK,GAAG,OAAO;EAChC,IAAI,QAAQ,SAAS,UAAU;CACjC;CACA,OAAO;AACT;;AAGA,SAAgB,MAAM,QAAkC;CACtD,IAAI,WAAW;CACf,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,OAAO,MAAM,KAAK,GAAG,OAAO;EAChC,IAAI,QAAQ,UAAU,WAAW;CACnC;CACA,OAAO;AACT"}
package/dist/random.d.ts DELETED
@@ -1,7 +0,0 @@
1
- //#region src/random.d.ts
2
- declare function randomHex(bytes?: number): string;
3
- declare function randomInt(): number;
4
- declare function randomIndex(length: number): number;
5
- //#endregion
6
- export { randomHex, randomIndex, randomInt };
7
- //# sourceMappingURL=random.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random.d.ts","names":[],"sources":["../src/random.ts"],"mappings":";iBAAgB,UAAU;iBAUV;iBAIA,YAAY"}
package/dist/random.js DELETED
@@ -1,25 +0,0 @@
1
- //#region src/random.ts
2
- function randomHex(bytes = 16) {
3
- if (!Number.isInteger(bytes) || bytes < 0) throw new RangeError("bytes must be a non-negative integer");
4
- const buf = crypto.getRandomValues(new Uint8Array(bytes));
5
- let hex = "";
6
- for (const b of buf) hex += b.toString(16).padStart(2, "0");
7
- return hex;
8
- }
9
- function randomInt() {
10
- return crypto.getRandomValues(/* @__PURE__ */ new Int32Array(1))[0];
11
- }
12
- function randomIndex(length) {
13
- if (!Number.isInteger(length) || length <= 0) throw new RangeError("length must be a positive integer");
14
- const max = 4294967296;
15
- const limit = max - max % length;
16
- const buffer = /* @__PURE__ */ new Uint32Array(1);
17
- do
18
- crypto.getRandomValues(buffer);
19
- while (buffer[0] >= limit);
20
- return buffer[0] % length;
21
- }
22
- //#endregion
23
- export { randomHex, randomIndex, randomInt };
24
-
25
- //# sourceMappingURL=random.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random.js","names":[],"sources":["../src/random.ts"],"sourcesContent":["export function randomHex(bytes = 16): string {\n if (!Number.isInteger(bytes) || bytes < 0) {\n throw new RangeError('bytes must be a non-negative integer')\n }\n const buf = crypto.getRandomValues(new Uint8Array(bytes))\n let hex = ''\n for (const b of buf) hex += b.toString(16).padStart(2, '0')\n return hex\n}\n\nexport function randomInt(): number {\n return crypto.getRandomValues(new Int32Array(1))[0]\n}\n\nexport function randomIndex(length: number): number {\n if (!Number.isInteger(length) || length <= 0) {\n throw new RangeError('length must be a positive integer')\n }\n const max = 0x1_0000_0000\n const limit = max - (max % length)\n const buffer = new Uint32Array(1)\n\n do {\n crypto.getRandomValues(buffer)\n } while (buffer[0] >= limit)\n\n return buffer[0] % length\n}\n"],"mappings":";AAAA,SAAgB,UAAU,QAAQ,IAAY;CAC5C,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,GACtC,MAAM,IAAI,WAAW,sCAAsC;CAE7D,MAAM,MAAM,OAAO,gBAAgB,IAAI,WAAW,KAAK,CAAC;CACxD,IAAI,MAAM;CACV,KAAK,MAAM,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;CAC1D,OAAO;AACT;AAEA,SAAgB,YAAoB;CAClC,OAAO,OAAO,gCAAgB,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AACnD;AAEA,SAAgB,YAAY,QAAwB;CAClD,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,UAAU,GACzC,MAAM,IAAI,WAAW,mCAAmC;CAE1D,MAAM,MAAM;CACZ,MAAM,QAAQ,MAAO,MAAM;CAC3B,MAAM,yBAAS,IAAI,YAAY,CAAC;CAEhC;EACE,OAAO,gBAAgB,MAAM;QACtB,OAAO,MAAM;CAEtB,OAAO,OAAO,KAAK;AACrB"}
package/src/arrays.ts DELETED
@@ -1,37 +0,0 @@
1
- /**
2
- * Helpers for lists of any length. Spreading an array into a call's arguments, as in
3
- * `push(...items)` or `Math.max(...values)`, throws once it holds more than about 120,000 items in
4
- * Chrome; these take any number (`@open-pencil/data/no-spread-arguments`).
5
- */
6
-
7
- /** Appends every item of `items` to `target`, in order. */
8
- export function appendAll<T>(target: T[], items: Iterable<T>): void {
9
- for (const item of items) target.push(item)
10
- }
11
-
12
- /** Inserts every item of `items` into `target` before `index`, in order, as `splice` would. */
13
- export function insertAll<T>(target: T[], index: number, items: Iterable<T>): void {
14
- const tail = target.splice(index)
15
- appendAll(target, items)
16
- appendAll(target, tail)
17
- }
18
-
19
- /** The largest of `values`, or `-Infinity` when there are none, as `Math.max` gives. */
20
- export function maxOf(values: Iterable<number>): number {
21
- let largest = -Infinity
22
- for (const value of values) {
23
- if (Number.isNaN(value)) return Number.NaN
24
- if (value > largest) largest = value
25
- }
26
- return largest
27
- }
28
-
29
- /** The smallest of `values`, or `Infinity` when there are none, as `Math.min` gives. */
30
- export function minOf(values: Iterable<number>): number {
31
- let smallest = Infinity
32
- for (const value of values) {
33
- if (Number.isNaN(value)) return Number.NaN
34
- if (value < smallest) smallest = value
35
- }
36
- return smallest
37
- }
package/src/random.ts DELETED
@@ -1,28 +0,0 @@
1
- export function randomHex(bytes = 16): string {
2
- if (!Number.isInteger(bytes) || bytes < 0) {
3
- throw new RangeError('bytes must be a non-negative integer')
4
- }
5
- const buf = crypto.getRandomValues(new Uint8Array(bytes))
6
- let hex = ''
7
- for (const b of buf) hex += b.toString(16).padStart(2, '0')
8
- return hex
9
- }
10
-
11
- export function randomInt(): number {
12
- return crypto.getRandomValues(new Int32Array(1))[0]
13
- }
14
-
15
- export function randomIndex(length: number): number {
16
- if (!Number.isInteger(length) || length <= 0) {
17
- throw new RangeError('length must be a positive integer')
18
- }
19
- const max = 0x1_0000_0000
20
- const limit = max - (max % length)
21
- const buffer = new Uint32Array(1)
22
-
23
- do {
24
- crypto.getRandomValues(buffer)
25
- } while (buffer[0] >= limit)
26
-
27
- return buffer[0] % length
28
- }