@vectojs/core 1.14.0 → 1.15.0

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/index.mjs CHANGED
@@ -1,9 +1,3 @@
1
- import {
2
- LayoutEngine,
3
- LayoutResultBuffer,
4
- computeLineSegments,
5
- createCanvasMeasurer
6
- } from "./chunk-X7I465AQ.mjs";
7
1
  import {
8
2
  CanvasRenderer,
9
3
  SVGRenderer,
@@ -15,25 +9,11 @@ import {
15
9
  sanitizeUrl
16
10
  } from "./chunk-L5BCKFQE.mjs";
17
11
  import {
18
- Easing,
19
12
  Entity,
20
- MSDFFont,
21
13
  MSDFTextEntity,
22
14
  SVGEntity,
23
- SpringDriver,
24
- SpringPhysics,
25
- TweenDriver,
26
- VectoJSEvent,
27
- clearCssLineBoxMetrics,
28
- cssLineBoxBaseline,
29
- isTweenConfig,
30
- prepareContentGrid
31
- } from "./chunk-XIEQHSBB.mjs";
32
- import {
33
- ArabicShaper,
34
- BidiResolver,
35
- LayoutWorkerManager
36
- } from "./chunk-IESDTEJ4.mjs";
15
+ VectoJSEvent
16
+ } from "./chunk-64UFEHOJ.mjs";
37
17
 
38
18
  // src/tree/ComputeParticleEntity.ts
39
19
  var PARTICLE_STRIDE_FLOATS = 8;
@@ -330,6 +310,7 @@ var ComputeParticleEntity = class extends Entity {
330
310
  };
331
311
 
332
312
  // src/tree/Scene.ts
313
+ import { clearCssLineBoxMetrics, cssLineBoxBaseline } from "@vectojs/text";
333
314
  var INTERACTIVE_A11Y_ROLES = /* @__PURE__ */ new Set([
334
315
  "button",
335
316
  "switch",
@@ -2838,6 +2819,10 @@ var Scene = class _Scene {
2838
2819
  };
2839
2820
 
2840
2821
  // src/components/TextEntity.ts
2822
+ import {
2823
+ LayoutEngine,
2824
+ createCanvasMeasurer
2825
+ } from "@vectojs/layout";
2841
2826
  var sharedMeasurer;
2842
2827
  function defaultMeasurer() {
2843
2828
  if (sharedMeasurer === void 0) sharedMeasurer = createCanvasMeasurer("sans-serif");
@@ -3459,99 +3444,11 @@ var Group = class extends Entity {
3459
3444
  }
3460
3445
  };
3461
3446
 
3462
- // src/math/SpatialHashGrid.ts
3463
- var SpatialHashGrid = class {
3464
- cellSize;
3465
- grid = /* @__PURE__ */ new Map();
3466
- entityCells = /* @__PURE__ */ new Map();
3467
- constructor(cellSize = 64) {
3468
- this.cellSize = cellSize;
3469
- }
3470
- hash(cx, cy) {
3471
- const x = cx < 0 ? -2 * cx - 1 : 2 * cx;
3472
- const y = cy < 0 ? -2 * cy - 1 : 2 * cy;
3473
- return (x + y) * (x + y + 1) / 2 + y;
3474
- }
3475
- cellsForAABB(x, y, w, h) {
3476
- const minCx = Math.floor(x / this.cellSize);
3477
- const minCy = Math.floor(y / this.cellSize);
3478
- const maxCx = Math.floor((x + w) / this.cellSize);
3479
- const maxCy = Math.floor((y + h) / this.cellSize);
3480
- const keys = [];
3481
- for (let cx = minCx; cx <= maxCx; cx++) {
3482
- for (let cy = minCy; cy <= maxCy; cy++) {
3483
- keys.push(this.hash(cx, cy));
3484
- }
3485
- }
3486
- return keys;
3487
- }
3488
- /**
3489
- * Insert or update an entity's axis-aligned bounding box in the grid.
3490
- *
3491
- * If the entity is already registered its old cell memberships are removed
3492
- * before the new ones are computed, so this method is safe to call every
3493
- * frame.
3494
- *
3495
- * @param id - Unique string identifier for the entity.
3496
- * @param x - Left edge of the AABB in world space.
3497
- * @param y - Top edge of the AABB in world space.
3498
- * @param w - Width of the AABB.
3499
- * @param h - Height of the AABB.
3500
- */
3501
- insert(id, x, y, w, h) {
3502
- this.remove(id);
3503
- const keys = this.cellsForAABB(x, y, w, h);
3504
- this.entityCells.set(id, keys);
3505
- for (const key of keys) {
3506
- if (!this.grid.has(key)) this.grid.set(key, /* @__PURE__ */ new Set());
3507
- this.grid.get(key).add(id);
3508
- }
3509
- }
3510
- /**
3511
- * Remove an entity from all grid cells it currently occupies.
3512
- *
3513
- * Silently does nothing if the entity is not registered.
3514
- *
3515
- * @param id - Unique string identifier of the entity to remove.
3516
- */
3517
- remove(id) {
3518
- const keys = this.entityCells.get(id);
3519
- if (!keys) return;
3520
- for (const key of keys) {
3521
- this.grid.get(key)?.delete(id);
3522
- }
3523
- this.entityCells.delete(id);
3524
- }
3525
- /**
3526
- * Return all entity IDs whose grid cells overlap the given AABB.
3527
- *
3528
- * Time complexity: O(k) where k is the number of cells the query AABB spans
3529
- * plus the number of results — O(1) average for small, similarly-sized entities.
3530
- *
3531
- * @param x - Left edge of the query AABB.
3532
- * @param y - Top edge of the query AABB.
3533
- * @param w - Width of the query AABB.
3534
- * @param h - Height of the query AABB.
3535
- * @returns A `Set` of entity ID strings whose cells intersect the query region.
3536
- */
3537
- query(x, y, w, h) {
3538
- const result = /* @__PURE__ */ new Set();
3539
- for (const key of this.cellsForAABB(x, y, w, h)) {
3540
- const cell = this.grid.get(key);
3541
- if (cell) for (const id of cell) result.add(id);
3542
- }
3543
- return result;
3544
- }
3545
- /**
3546
- * Clear all cells and entity registrations, resetting the grid to an empty state.
3547
- *
3548
- * Call once per frame before re-inserting all dynamic entities.
3549
- */
3550
- clear() {
3551
- this.grid.clear();
3552
- this.entityCells.clear();
3553
- }
3554
- };
3447
+ // src/index.ts
3448
+ export * from "@vectojs/layout";
3449
+ export * from "@vectojs/text";
3450
+ export * from "@vectojs/math";
3451
+ export * from "@vectojs/animation";
3555
3452
 
3556
3453
  // src/tree/DOMPortalEntity.ts
3557
3454
  var DOMPortalEntity = class extends Entity {
@@ -3657,20 +3554,13 @@ var DOMPortalEntity = class extends Entity {
3657
3554
  Scene.registerWebGLPointRendererCreator(createWebGLPointRenderer);
3658
3555
  Scene.registerWebGPUParticleSystemManager(WebGPUParticleSystemManager);
3659
3556
  export {
3660
- ArabicShaper,
3661
- BidiResolver,
3662
3557
  CanvasRenderer,
3663
3558
  Circle,
3664
3559
  ComputeParticleEntity,
3665
3560
  DOMPortalEntity,
3666
- Easing,
3667
3561
  Entity,
3668
3562
  GridTextEntity,
3669
3563
  Group,
3670
- LayoutEngine,
3671
- LayoutResultBuffer,
3672
- LayoutWorkerManager,
3673
- MSDFFont,
3674
3564
  MSDFTextEntity,
3675
3565
  PARTICLE_OFFSET_LIFE,
3676
3566
  PARTICLE_OFFSET_ORIGIN_X,
@@ -3686,25 +3576,15 @@ export {
3686
3576
  SVGEntity,
3687
3577
  SVGRenderer,
3688
3578
  Scene,
3689
- SpatialHashGrid,
3690
3579
  SplineEntity,
3691
- SpringDriver,
3692
- SpringPhysics,
3693
3580
  TextEntity,
3694
3581
  TextRasterCache,
3695
- TweenDriver,
3696
3582
  VectoJSEvent,
3697
3583
  WebGPUParticleSystemManager,
3698
- clearCssLineBoxMetrics,
3699
- computeLineSegments,
3700
- createCanvasMeasurer,
3701
3584
  createWebGLPointRenderer,
3702
- cssLineBoxBaseline,
3703
3585
  isSafeUrl,
3704
- isTweenConfig,
3705
3586
  loadSpline,
3706
3587
  parseColorToRGBA,
3707
3588
  polySegmentToBezier,
3708
- prepareContentGrid,
3709
3589
  sanitizeUrl
3710
3590
  };
@@ -1,3 +1 @@
1
- export * from './LayoutEngine';
2
- export * from './LayoutWorkerManager';
3
- export * from './measure';
1
+ export * from '@vectojs/layout';
package/dist/layout.js CHANGED
@@ -1,16 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
- var _chunkBA5HUUDFjs = require('./chunk-BA5HUUDF.js');
7
-
8
-
9
- var _chunk4AR425ARjs = require('./chunk-4AR425AR.js');
10
-
11
-
12
-
13
-
14
-
15
-
16
- exports.LayoutEngine = _chunkBA5HUUDFjs.LayoutEngine; exports.LayoutResultBuffer = _chunkBA5HUUDFjs.LayoutResultBuffer; exports.LayoutWorkerManager = _chunk4AR425ARjs.LayoutWorkerManager; exports.computeLineSegments = _chunkBA5HUUDFjs.computeLineSegments; exports.createCanvasMeasurer = _chunkBA5HUUDFjs.createCanvasMeasurer;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }// src/layout/index.ts
2
+ var _layout = require('@vectojs/layout'); _createStarExport(_layout);
package/dist/layout.mjs CHANGED
@@ -1,16 +1,2 @@
1
- import {
2
- LayoutEngine,
3
- LayoutResultBuffer,
4
- computeLineSegments,
5
- createCanvasMeasurer
6
- } from "./chunk-X7I465AQ.mjs";
7
- import {
8
- LayoutWorkerManager
9
- } from "./chunk-IESDTEJ4.mjs";
10
- export {
11
- LayoutEngine,
12
- LayoutResultBuffer,
13
- LayoutWorkerManager,
14
- computeLineSegments,
15
- createCanvasMeasurer
16
- };
1
+ // src/layout/index.ts
2
+ export * from "@vectojs/layout";
@@ -1,5 +1,5 @@
1
1
  import { Entity, type ContentProjection } from '../tree/Entity';
2
- import { MSDFFont } from './MSDFFont';
2
+ import { MSDFFont } from '@vectojs/text';
3
3
  export interface MSDFTextEntityOptions {
4
4
  font: MSDFFont;
5
5
  texture: TexImageSource;
@@ -1,7 +1,3 @@
1
- export * from './ArabicShaper';
2
- export * from './BidiResolver';
3
- export * from './PreparedContentGrid';
4
- export * from './MSDFFont';
1
+ export * from '@vectojs/text';
5
2
  export * from './MSDFTextEntity';
6
3
  export * from './SVGEntity';
7
- export * from './Typography';
package/dist/text.js CHANGED
@@ -1,22 +1,11 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }
2
2
 
3
3
 
4
+ var _chunkJ6NHSFIEjs = require('./chunk-J6NHSFIE.js');
4
5
 
6
+ // src/text/index.ts
7
+ var _text = require('@vectojs/text'); _createStarExport(_text);
5
8
 
6
9
 
7
10
 
8
- var _chunk2Z23LTH3js = require('./chunk-2Z23LTH3.js');
9
-
10
-
11
-
12
- var _chunk4AR425ARjs = require('./chunk-4AR425AR.js');
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
- exports.ArabicShaper = _chunk4AR425ARjs.ArabicShaper; exports.BidiResolver = _chunk4AR425ARjs.BidiResolver; exports.MSDFFont = _chunk2Z23LTH3js.MSDFFont; exports.MSDFTextEntity = _chunk2Z23LTH3js.MSDFTextEntity; exports.SVGEntity = _chunk2Z23LTH3js.SVGEntity; exports.clearCssLineBoxMetrics = _chunk2Z23LTH3js.clearCssLineBoxMetrics; exports.cssLineBoxBaseline = _chunk2Z23LTH3js.cssLineBoxBaseline; exports.prepareContentGrid = _chunk2Z23LTH3js.prepareContentGrid;
11
+ exports.MSDFTextEntity = _chunkJ6NHSFIEjs.MSDFTextEntity; exports.SVGEntity = _chunkJ6NHSFIEjs.SVGEntity;
package/dist/text.mjs CHANGED
@@ -1,22 +1,11 @@
1
1
  import {
2
- MSDFFont,
3
2
  MSDFTextEntity,
4
- SVGEntity,
5
- clearCssLineBoxMetrics,
6
- cssLineBoxBaseline,
7
- prepareContentGrid
8
- } from "./chunk-XIEQHSBB.mjs";
9
- import {
10
- ArabicShaper,
11
- BidiResolver
12
- } from "./chunk-IESDTEJ4.mjs";
3
+ SVGEntity
4
+ } from "./chunk-64UFEHOJ.mjs";
5
+
6
+ // src/text/index.ts
7
+ export * from "@vectojs/text";
13
8
  export {
14
- ArabicShaper,
15
- BidiResolver,
16
- MSDFFont,
17
9
  MSDFTextEntity,
18
- SVGEntity,
19
- clearCssLineBoxMetrics,
20
- cssLineBoxBaseline,
21
- prepareContentGrid
10
+ SVGEntity
22
11
  };
@@ -1,5 +1,5 @@
1
- import { type MotionConfig, type TweenConfig, type SpringConfig } from '../animation/drivers';
2
- import type { PreparedContentGrid } from '../text/PreparedContentGrid';
1
+ import { type MotionConfig, type TweenConfig, type SpringConfig } from '@vectojs/animation';
2
+ import type { PreparedContentGrid } from '@vectojs/text';
3
3
  /** A numeric transform/visual property that participates in the animation system. */
4
4
  export type AnimatableProp = 'x' | 'y' | 'scaleX' | 'scaleY' | 'rotation' | 'opacity';
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectojs/core",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -53,16 +53,18 @@
53
53
  "THIRD_PARTY_NOTICES.md"
54
54
  ],
55
55
  "scripts": {
56
- "benchmark:grid": "vitest bench benchmark/PreparedContentGrid.bench.ts --run",
57
- "build": "node scripts/build-worker.js && tsup && tsc -p tsconfig.build.json",
56
+ "build": "(cd ../math && bun run build) && (cd ../text && bun run build) && (cd ../layout && bun run build) && (cd ../animation && bun run build) && tsup && tsc -p tsconfig.build.json",
58
57
  "test": "vitest run",
59
58
  "test:e2e": "bun e2e/hidpi.e2e.ts && bun e2e/text-projection.e2e.ts"
60
59
  },
61
- "dependencies": {},
60
+ "dependencies": {
61
+ "@vectojs/animation": "^0.1.0",
62
+ "@vectojs/layout": "^0.1.0",
63
+ "@vectojs/math": "^0.1.0",
64
+ "@vectojs/text": "^0.1.0"
65
+ },
62
66
  "devDependencies": {
63
67
  "@vitest/coverage-v8": "^4.1.10",
64
- "bidi-js": "^1.0.3",
65
- "esbuild": "^0.28.1",
66
68
  "jsdom": "^29.1.1",
67
69
  "tsup": "^8.3.5",
68
70
  "vitest": "^4.1.10",
@@ -1,48 +0,0 @@
1
- import { type EasingFn, type EasingName } from './easing';
2
- export interface SpringConfig {
3
- stiffness?: number;
4
- damping?: number;
5
- mass?: number;
6
- }
7
- export interface TweenConfig {
8
- duration: number;
9
- easing?: EasingName | EasingFn;
10
- delay?: number;
11
- }
12
- /** A motion config. Presence of `duration` selects a tween; otherwise a spring. */
13
- export type MotionConfig = 'spring' | SpringConfig | TweenConfig;
14
- export declare function isTweenConfig(c: MotionConfig): c is TweenConfig;
15
- /** Backs one animating property. Ticked in ms; writes `value`. */
16
- export interface PropertyDriver {
17
- value: number;
18
- /** The current destination — applied exactly when the animation completes, so a
19
- * finished spring lands on target rather than within its rest epsilon. */
20
- readonly target: number;
21
- /** Change the destination. Spring keeps velocity; tween restarts from current value. */
22
- retarget(to: number): void;
23
- tick(dtMs: number): void;
24
- isDone(): boolean;
25
- }
26
- export declare class TweenDriver implements PropertyDriver {
27
- value: number;
28
- private from;
29
- private to;
30
- private elapsed;
31
- private readonly duration;
32
- private readonly delay;
33
- private readonly ease;
34
- constructor(from: number, to: number, cfg: TweenConfig);
35
- get target(): number;
36
- retarget(to: number): void;
37
- tick(dtMs: number): void;
38
- isDone(): boolean;
39
- }
40
- export declare class SpringDriver implements PropertyDriver {
41
- private spring;
42
- constructor(from: number, to: number, cfg: SpringConfig);
43
- get value(): number;
44
- get target(): number;
45
- retarget(to: number): void;
46
- tick(dtMs: number): void;
47
- isDone(): boolean;
48
- }
@@ -1,16 +0,0 @@
1
- /** An easing function: maps normalized time t in [0,1] to eased progress. */
2
- export type EasingFn = (t: number) => number;
3
- /** Curated easing set. Add sparingly — every entry must map f(0)=0, f(1)=1. */
4
- export declare const Easing: {
5
- linear: (t: number) => number;
6
- easeInQuad: (t: number) => number;
7
- easeOutQuad: (t: number) => number;
8
- easeInOutQuad: (t: number) => number;
9
- easeInCubic: (t: number) => number;
10
- easeOutCubic: (t: number) => number;
11
- easeInOutCubic: (t: number) => number;
12
- easeOutBack: (t: number) => number;
13
- easeInOutBack: (t: number) => number;
14
- };
15
- /** Name of a built-in easing curve. */
16
- export type EasingName = keyof typeof Easing;