@open-pencil/scene-graph 0.17.0-beta.5 → 0.17.0-beta.7
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/comments/schema.d.ts.map +1 -1
- package/dist/comments/schema.js +1 -0
- package/dist/comments/schema.js.map +1 -1
- package/dist/comments/threads.d.ts +2 -0
- package/dist/comments/threads.d.ts.map +1 -1
- package/dist/comments/threads.js +11 -5
- package/dist/comments/threads.js.map +1 -1
- package/dist/components/properties.d.ts.map +1 -1
- package/dist/components/properties.js +1 -1
- package/dist/components/properties.js.map +1 -1
- package/dist/constants.d.ts +12 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +42 -1
- package/dist/constants.js.map +1 -1
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +3 -0
- package/dist/copy.js.map +1 -1
- package/dist/css/grid.d.ts.map +1 -1
- package/dist/css/grid.js +27 -3
- package/dist/css/grid.js.map +1 -1
- package/dist/css/index.d.ts +3 -3
- package/dist/css/index.js +3 -3
- package/dist/css/layout.d.ts +13 -1
- package/dist/css/layout.d.ts.map +1 -1
- package/dist/css/layout.js +26 -1
- package/dist/css/layout.js.map +1 -1
- package/dist/css/values.d.ts +18 -1
- package/dist/css/values.d.ts.map +1 -1
- package/dist/css/values.js +39 -1
- package/dist/css/values.js.map +1 -1
- package/dist/geometry.d.ts +6 -6
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +4 -20
- package/dist/geometry.js.map +1 -1
- package/dist/graph.d.ts +5 -2
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +16 -6
- package/dist/graph.js.map +1 -1
- package/dist/icons/glyph.d.ts.map +1 -1
- package/dist/icons/glyph.js +1 -1
- package/dist/icons/glyph.js.map +1 -1
- package/dist/ids.js +1 -1
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/instances/index.d.ts +6 -1
- package/dist/instances/index.d.ts.map +1 -1
- package/dist/instances/index.js +20 -8
- package/dist/instances/index.js.map +1 -1
- package/dist/instances/swap.js +1 -1
- package/dist/instances/swap.js.map +1 -1
- package/dist/instances/sync.js +25 -1
- package/dist/instances/sync.js.map +1 -1
- package/dist/layout/index.d.ts +2 -1
- package/dist/layout/index.js +2 -1
- package/dist/layout/strokes.d.ts +10 -0
- package/dist/layout/strokes.d.ts.map +1 -0
- package/dist/layout/strokes.js +30 -0
- package/dist/layout/strokes.js.map +1 -0
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +49 -37
- package/dist/node-defaults.js.map +1 -1
- package/dist/outline/flatten.d.ts.map +1 -1
- package/dist/outline/flatten.js +2 -2
- package/dist/outline/flatten.js.map +1 -1
- package/dist/parse-path.d.ts +4 -1
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +15 -1
- package/dist/parse-path.js.map +1 -1
- package/dist/paths/index.d.ts +2 -2
- package/dist/paths/index.js +2 -2
- package/dist/paths/network.d.ts +26 -6
- package/dist/paths/network.d.ts.map +1 -1
- package/dist/paths/network.js +79 -13
- package/dist/paths/network.js.map +1 -1
- package/dist/paths/smooth-corners.d.ts.map +1 -1
- package/dist/paths/smooth-corners.js +1 -1
- package/dist/paths/smooth-corners.js.map +1 -1
- package/dist/primitives/index.d.ts +1 -7
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/shaders/model.d.ts.map +1 -1
- package/dist/shaders/model.js +1 -1
- package/dist/shaders/model.js.map +1 -1
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +2 -9
- package/dist/shared-styles.js.map +1 -1
- package/dist/strokes.d.ts +39 -0
- package/dist/strokes.d.ts.map +1 -0
- package/dist/strokes.js +104 -0
- package/dist/strokes.js.map +1 -0
- package/dist/text/index.d.ts +2 -1
- package/dist/text/index.js +2 -1
- package/dist/text/runs.d.ts +29 -0
- package/dist/text/runs.d.ts.map +1 -0
- package/dist/text/runs.js +72 -0
- package/dist/text/runs.js.map +1 -0
- package/dist/transfer/dependencies.d.ts.map +1 -1
- package/dist/transfer/dependencies.js +1 -1
- package/dist/transfer/dependencies.js.map +1 -1
- package/dist/types.d.ts +47 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/variables/resolution.d.ts.map +1 -1
- package/dist/variables/resolution.js +1 -1
- package/dist/variables/resolution.js.map +1 -1
- package/dist/vector-network.d.ts.map +1 -1
- package/dist/vector-network.js +2 -4
- package/dist/vector-network.js.map +1 -1
- package/package.json +10 -13
- package/src/comments/schema.ts +1 -0
- package/src/comments/threads.ts +13 -5
- package/src/components/properties.ts +2 -1
- package/src/constants.ts +25 -1
- package/src/copy.ts +3 -0
- package/src/css/grid.ts +31 -3
- package/src/css/index.ts +13 -2
- package/src/css/layout.ts +36 -0
- package/src/css/values.ts +49 -0
- package/src/geometry.ts +9 -27
- package/src/graph.ts +13 -6
- package/src/icons/glyph.ts +2 -1
- package/src/ids.ts +1 -1
- package/src/instances/index.ts +24 -9
- package/src/instances/swap.ts +2 -1
- package/src/instances/sync.ts +41 -0
- package/src/layout/index.ts +1 -0
- package/src/layout/strokes.ts +23 -0
- package/src/node-defaults.ts +48 -33
- package/src/outline/flatten.ts +2 -1
- package/src/parse-path.ts +14 -0
- package/src/paths/network.ts +90 -13
- package/src/paths/smooth-corners.ts +2 -1
- package/src/primitives/index.ts +0 -5
- package/src/shaders/model.ts +2 -1
- package/src/shared-styles.ts +3 -4
- package/src/strokes.ts +121 -0
- package/src/text/index.ts +1 -0
- package/src/text/runs.ts +80 -0
- package/src/transfer/dependencies.ts +2 -1
- package/src/types.ts +50 -0
- package/src/variables/resolution.ts +2 -1
- package/src/vector-network.ts +2 -4
- package/dist/arrays.d.ts +0 -17
- package/dist/arrays.d.ts.map +0 -1
- package/dist/arrays.js +0 -38
- package/dist/arrays.js.map +0 -1
- package/dist/random.d.ts +0 -7
- package/dist/random.d.ts.map +0 -1
- package/dist/random.js +0 -25
- package/dist/random.js.map +0 -1
- package/src/arrays.ts +0 -37
- package/src/random.ts +0 -28
package/src/types.ts
CHANGED
|
@@ -186,6 +186,17 @@ export interface GradientStop {
|
|
|
186
186
|
|
|
187
187
|
export type GradientTransform = Matrix
|
|
188
188
|
|
|
189
|
+
/** Figma's adjustments of an image paint, each from -1 to 1; 0 leaves the image as it is. */
|
|
190
|
+
export interface ImageFilters {
|
|
191
|
+
exposure?: number
|
|
192
|
+
contrast?: number
|
|
193
|
+
saturation?: number
|
|
194
|
+
temperature?: number
|
|
195
|
+
tint?: number
|
|
196
|
+
highlights?: number
|
|
197
|
+
shadows?: number
|
|
198
|
+
}
|
|
199
|
+
|
|
189
200
|
export interface Fill {
|
|
190
201
|
type: FillType
|
|
191
202
|
color: Color
|
|
@@ -203,6 +214,8 @@ export interface Fill {
|
|
|
203
214
|
imageTransform?: GradientTransform
|
|
204
215
|
/** Clockwise turn of a Fill, Fit or Tile image, in multiples of 90°; a crop holds its own. */
|
|
205
216
|
imageRotation?: number
|
|
217
|
+
/** An image's adjustments, kept and saved; the canvas does not draw them. */
|
|
218
|
+
filters?: ImageFilters
|
|
206
219
|
sourceNodeId?: string
|
|
207
220
|
scale?: number
|
|
208
221
|
spacing?: number
|
|
@@ -287,6 +300,33 @@ export interface ProgressiveBlur {
|
|
|
287
300
|
endOffset: Vector
|
|
288
301
|
}
|
|
289
302
|
|
|
303
|
+
/**
|
|
304
|
+
* A Noise effect's grain, in Figma's plugin terms: `MONOTONE` grains in the effect's colour,
|
|
305
|
+
* `DUOTONE` in it and `secondaryColor`, `MULTITONE` in many colours at `opacity`. `noiseSize` is a
|
|
306
|
+
* grain's size in px, which Figma keeps within 0 to 100, and `density` how much of the layer the
|
|
307
|
+
* grains cover, 0 to 1. `seed` picks the pattern; Figma's plugin API neither shows nor sets it.
|
|
308
|
+
*/
|
|
309
|
+
export interface NoiseEffectParams {
|
|
310
|
+
noiseType: NoiseType
|
|
311
|
+
noiseSize: Vector
|
|
312
|
+
density: number
|
|
313
|
+
secondaryColor?: Color
|
|
314
|
+
opacity?: number
|
|
315
|
+
seed?: number
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* A Texture effect's grain, which roughens the layer's edges: `noiseSize` is the grain's size in
|
|
320
|
+
* px, within 0 to 100 as Figma keeps it, and `clipToShape` keeps the roughened layer inside its
|
|
321
|
+
* own outline. The effect's `radius` is how far the grain moves the edges. `.fig` files name the
|
|
322
|
+
* effect `GRAIN`.
|
|
323
|
+
*/
|
|
324
|
+
export interface TextureEffectParams {
|
|
325
|
+
noiseSize: Vector
|
|
326
|
+
clipToShape: boolean
|
|
327
|
+
seed?: number
|
|
328
|
+
}
|
|
329
|
+
|
|
290
330
|
export interface Effect {
|
|
291
331
|
type:
|
|
292
332
|
| 'DROP_SHADOW'
|
|
@@ -295,6 +335,8 @@ export interface Effect {
|
|
|
295
335
|
| 'BACKGROUND_BLUR'
|
|
296
336
|
| 'FOREGROUND_BLUR'
|
|
297
337
|
| 'GLASS'
|
|
338
|
+
| 'NOISE'
|
|
339
|
+
| 'TEXTURE'
|
|
298
340
|
color: Color
|
|
299
341
|
offset: Vector
|
|
300
342
|
radius: number
|
|
@@ -306,6 +348,10 @@ export interface Effect {
|
|
|
306
348
|
glass?: GlassEffectParams
|
|
307
349
|
/** Set on a layer or background blur that is progressive, and only there. */
|
|
308
350
|
progressive?: ProgressiveBlur
|
|
351
|
+
/** Set on a `NOISE` effect, and only there. */
|
|
352
|
+
noise?: NoiseEffectParams
|
|
353
|
+
/** Set on a `TEXTURE` effect, and only there. */
|
|
354
|
+
texture?: TextureEffectParams
|
|
309
355
|
}
|
|
310
356
|
|
|
311
357
|
export type ConstraintType = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'SCALE'
|
|
@@ -654,6 +700,8 @@ export interface CommentReply {
|
|
|
654
700
|
author: string
|
|
655
701
|
/** The author's collaboration color when they wrote it, for their avatar. */
|
|
656
702
|
authorColor?: Color
|
|
703
|
+
/** The agent that wrote it, for `author` or as itself. */
|
|
704
|
+
agent?: string
|
|
657
705
|
/** Markdown: bold, italic, strikethrough, links and lists. */
|
|
658
706
|
text: string
|
|
659
707
|
createdAt: string
|
|
@@ -678,6 +726,8 @@ export interface CommentThread {
|
|
|
678
726
|
author: string
|
|
679
727
|
/** The author's collaboration color when they wrote it, for their avatar. */
|
|
680
728
|
authorColor?: Color
|
|
729
|
+
/** The agent that wrote it, for `author` or as itself. */
|
|
730
|
+
agent?: string
|
|
681
731
|
/** Markdown: bold, italic, strikethrough, links and lists. */
|
|
682
732
|
text: string
|
|
683
733
|
createdAt: string
|
package/src/vector-network.ts
CHANGED
|
@@ -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
|
package/dist/arrays.d.ts.map
DELETED
|
@@ -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
|
package/dist/arrays.js.map
DELETED
|
@@ -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
|
package/dist/random.d.ts.map
DELETED
|
@@ -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
|
package/dist/random.js.map
DELETED
|
@@ -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
|
-
}
|