@vectojs/core 1.7.0 → 1.8.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/README.md +14 -1
- package/THIRD_PARTY_NOTICES.md +24 -0
- package/dist/chunk-4AR425AR.js +1121 -0
- package/dist/{chunk-ZBKKRYDH.js → chunk-BA5HUUDF.js} +8 -8
- package/dist/{chunk-DFNK6OV6.js → chunk-FIQAIF55.js} +206 -4
- package/dist/chunk-IESDTEJ4.mjs +1121 -0
- package/dist/{chunk-3CODWSF3.mjs → chunk-RQ2ETTBN.mjs} +204 -2
- package/dist/{chunk-V7GUWG5C.mjs → chunk-X7I465AQ.mjs} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +829 -130
- package/dist/index.mjs +706 -7
- package/dist/layout.js +3 -3
- package/dist/layout.mjs +2 -2
- package/dist/text/BidiResolver.d.ts +0 -1
- package/dist/text/PreparedContentGrid.d.ts +60 -0
- package/dist/text/index.d.ts +1 -0
- package/dist/text.js +5 -3
- package/dist/text.mjs +6 -4
- package/dist/tree/Entity.d.ts +21 -0
- package/dist/tree/Scene.d.ts +29 -0
- package/package.json +5 -2
- package/dist/chunk-CTZQOM5Z.js +0 -418
- package/dist/chunk-STWPTWO4.mjs +0 -418
package/dist/layout.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkBA5HUUDFjs = require('./chunk-BA5HUUDF.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk4AR425ARjs = require('./chunk-4AR425AR.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
exports.LayoutEngine =
|
|
16
|
+
exports.LayoutEngine = _chunkBA5HUUDFjs.LayoutEngine; exports.LayoutResultBuffer = _chunkBA5HUUDFjs.LayoutResultBuffer; exports.LayoutWorkerManager = _chunk4AR425ARjs.LayoutWorkerManager; exports.computeLineSegments = _chunkBA5HUUDFjs.computeLineSegments; exports.createCanvasMeasurer = _chunkBA5HUUDFjs.createCanvasMeasurer;
|
package/dist/layout.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
LayoutResultBuffer,
|
|
4
4
|
computeLineSegments,
|
|
5
5
|
createCanvasMeasurer
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X7I465AQ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
LayoutWorkerManager
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IESDTEJ4.mjs";
|
|
10
10
|
export {
|
|
11
11
|
LayoutEngine,
|
|
12
12
|
LayoutResultBuffer,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface PreparedContentGridCell {
|
|
2
|
+
/** UTF-16 source start, matching DOM Range offsets. */
|
|
3
|
+
readonly sourceStart: number;
|
|
4
|
+
/** UTF-16 source end, matching DOM Range offsets. */
|
|
5
|
+
readonly sourceEnd: number;
|
|
6
|
+
/** Legal UTF-16 caret offsets relative to `sourceStart`. */
|
|
7
|
+
readonly sourceCaretOffsets: readonly number[];
|
|
8
|
+
/** Contextually shaped glyph text used by the canvas painter. */
|
|
9
|
+
readonly glyph: string;
|
|
10
|
+
/** Visual x coordinate inside the line. */
|
|
11
|
+
readonly x: number;
|
|
12
|
+
/** Grid advance in local CSS pixels. */
|
|
13
|
+
readonly advance: number;
|
|
14
|
+
/** Resolved bidi embedding level. */
|
|
15
|
+
readonly level: number;
|
|
16
|
+
}
|
|
17
|
+
export interface PreparedContentGridLine {
|
|
18
|
+
/** Start of this logical line in {@link PreparedContentGrid.source}. */
|
|
19
|
+
readonly sourceStart: number;
|
|
20
|
+
/** End of visible line content, excluding the hard break. */
|
|
21
|
+
readonly sourceEnd: number;
|
|
22
|
+
/** Start of the next line, thereby owning the intervening hard break. */
|
|
23
|
+
readonly nextSourceStart: number;
|
|
24
|
+
/** Total visual grid width in local CSS pixels. */
|
|
25
|
+
readonly width: number;
|
|
26
|
+
/** Cells stay in logical source order; their x coordinates encode visual order. */
|
|
27
|
+
readonly cells: readonly PreparedContentGridCell[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Immutable source-aware geometry shared by canvas grid text and its semantic
|
|
31
|
+
* DOM projection. It deliberately remains independent of syntax highlighting.
|
|
32
|
+
*/
|
|
33
|
+
export interface PreparedContentGrid {
|
|
34
|
+
readonly kind: 'content-grid';
|
|
35
|
+
readonly revision: number;
|
|
36
|
+
readonly source: string;
|
|
37
|
+
readonly font: string;
|
|
38
|
+
readonly cellWidth: number;
|
|
39
|
+
readonly lineHeight: number;
|
|
40
|
+
readonly baseline: number;
|
|
41
|
+
readonly tabSize: number;
|
|
42
|
+
readonly lines: readonly PreparedContentGridLine[];
|
|
43
|
+
}
|
|
44
|
+
export interface PrepareContentGridOptions {
|
|
45
|
+
/** CSS font shorthand shared by canvas and the projected DOM. */
|
|
46
|
+
font: string;
|
|
47
|
+
/** Width of one grid column in local CSS pixels. */
|
|
48
|
+
cellWidth: number;
|
|
49
|
+
/** Visual line advance in local CSS pixels. */
|
|
50
|
+
lineHeight: number;
|
|
51
|
+
/** Canvas baseline relative to each line's top. */
|
|
52
|
+
baseline: number;
|
|
53
|
+
/** Number of columns between tab stops. Defaults to 4. */
|
|
54
|
+
tabSize?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Compile logical source into one retained grid plan. Canvas paint and native
|
|
58
|
+
* text projection must consume this same object rather than re-segmenting it.
|
|
59
|
+
*/
|
|
60
|
+
export declare function prepareContentGrid(source: string, options: PrepareContentGridOptions): PreparedContentGrid;
|
package/dist/text/index.d.ts
CHANGED
package/dist/text.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunkDFNK6OV6js = require('./chunk-DFNK6OV6.js');
|
|
8
7
|
|
|
8
|
+
var _chunkFIQAIF55js = require('./chunk-FIQAIF55.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var _chunkCTZQOM5Zjs = require('./chunk-CTZQOM5Z.js');
|
|
12
11
|
|
|
12
|
+
var _chunk4AR425ARjs = require('./chunk-4AR425AR.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -17,4 +17,6 @@ var _chunkCTZQOM5Zjs = require('./chunk-CTZQOM5Z.js');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.ArabicShaper = _chunk4AR425ARjs.ArabicShaper; exports.BidiResolver = _chunk4AR425ARjs.BidiResolver; exports.MSDFFont = _chunkFIQAIF55js.MSDFFont; exports.MSDFTextEntity = _chunkFIQAIF55js.MSDFTextEntity; exports.SVGEntity = _chunkFIQAIF55js.SVGEntity; exports.clearCssLineBoxMetrics = _chunkFIQAIF55js.clearCssLineBoxMetrics; exports.cssLineBoxBaseline = _chunkFIQAIF55js.cssLineBoxBaseline; exports.prepareContentGrid = _chunkFIQAIF55js.prepareContentGrid;
|
package/dist/text.mjs
CHANGED
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
MSDFTextEntity,
|
|
4
4
|
SVGEntity,
|
|
5
5
|
clearCssLineBoxMetrics,
|
|
6
|
-
cssLineBoxBaseline
|
|
7
|
-
|
|
6
|
+
cssLineBoxBaseline,
|
|
7
|
+
prepareContentGrid
|
|
8
|
+
} from "./chunk-RQ2ETTBN.mjs";
|
|
8
9
|
import {
|
|
9
10
|
ArabicShaper,
|
|
10
11
|
BidiResolver
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IESDTEJ4.mjs";
|
|
12
13
|
export {
|
|
13
14
|
ArabicShaper,
|
|
14
15
|
BidiResolver,
|
|
@@ -16,5 +17,6 @@ export {
|
|
|
16
17
|
MSDFTextEntity,
|
|
17
18
|
SVGEntity,
|
|
18
19
|
clearCssLineBoxMetrics,
|
|
19
|
-
cssLineBoxBaseline
|
|
20
|
+
cssLineBoxBaseline,
|
|
21
|
+
prepareContentGrid
|
|
20
22
|
};
|
package/dist/tree/Entity.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type MotionConfig, type TweenConfig, type SpringConfig } from '../animation/drivers';
|
|
2
|
+
import type { PreparedContentGrid } from '../text/PreparedContentGrid';
|
|
2
3
|
/** A numeric transform/visual property that participates in the animation system. */
|
|
3
4
|
export type AnimatableProp = 'x' | 'y' | 'scaleX' | 'scaleY' | 'rotation' | 'opacity';
|
|
4
5
|
/**
|
|
@@ -111,6 +112,20 @@ export interface ContentProjection {
|
|
|
111
112
|
baseline?: number;
|
|
112
113
|
/** Explicit visual lines for mixed-style or internally inset text. */
|
|
113
114
|
lines?: ContentProjectionLine[];
|
|
115
|
+
/**
|
|
116
|
+
* Set to `'none'` for grid-drawn monospace content (code blocks, editors):
|
|
117
|
+
* the Scene disables OpenType ligatures and kerning on the projected DOM
|
|
118
|
+
* text so its selection geometry matches canvas text drawn cell-by-cell.
|
|
119
|
+
* Firefox otherwise ligates sequences like `ffi` in the DOM copy and the
|
|
120
|
+
* highlight drifts off the drawn glyphs.
|
|
121
|
+
*/
|
|
122
|
+
ligatures?: 'normal' | 'none';
|
|
123
|
+
/**
|
|
124
|
+
* Retained source-aware grid geometry for code-like content. Canvas paint
|
|
125
|
+
* and semantic projection share this plan so grapheme, tab, wide-character,
|
|
126
|
+
* shaping, and bidi boundaries cannot drift between the two surfaces.
|
|
127
|
+
*/
|
|
128
|
+
grid?: PreparedContentGrid;
|
|
114
129
|
}
|
|
115
130
|
/** Typography for a native input projected by the accessibility layer. */
|
|
116
131
|
export interface TextInputStyle {
|
|
@@ -138,6 +153,12 @@ export interface A11yAttributes {
|
|
|
138
153
|
label?: string;
|
|
139
154
|
/** Explicit keyboard tab order for projected non-native interaction regions. */
|
|
140
155
|
tabIndex?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Whether the semantic shadow element participates in pointer hit testing.
|
|
158
|
+
* Use `'none'` for structural containers whose selectable or interactive
|
|
159
|
+
* descendants own the pointer surface. Defaults to `'auto'`.
|
|
160
|
+
*/
|
|
161
|
+
pointerEvents?: 'auto' | 'none';
|
|
141
162
|
/** Destination URL; only meaningful for `tag: 'a'`. */
|
|
142
163
|
href?: string;
|
|
143
164
|
/** Link target; only meaningful for `tag: 'a'`. Defaults to current window. */
|
package/dist/tree/Scene.d.ts
CHANGED
|
@@ -157,7 +157,25 @@ export declare class Scene {
|
|
|
157
157
|
private a11yElements;
|
|
158
158
|
/** DOM nodes mirroring static text content, keyed by entity id. */
|
|
159
159
|
private contentElements;
|
|
160
|
+
/** Pending cold font-calibration frame per projected grid entity. */
|
|
161
|
+
private contentGridCalibrationFrames;
|
|
162
|
+
/** Detached, untransformed font probes used by the cold calibration pass. */
|
|
163
|
+
private contentGridCalibrationProbes;
|
|
164
|
+
/** Invalidates grid font calibration after browser font availability changes. */
|
|
165
|
+
private contentFontEpoch;
|
|
166
|
+
/** Cached Canvas-to-client scale for the current font/viewport epoch. */
|
|
167
|
+
private contentMetricScaleEpoch;
|
|
168
|
+
private contentMetricScaleX;
|
|
160
169
|
private contentProjectionEnabled;
|
|
170
|
+
/**
|
|
171
|
+
* True while a text-selection drag that started on a projection's blank
|
|
172
|
+
* region (no text node under the press) is being driven manually — the
|
|
173
|
+
* browser has no native anchor for it, so mousemove extends the Selection
|
|
174
|
+
* from the position we resolved ourselves.
|
|
175
|
+
*/
|
|
176
|
+
private blankRegionSelectionDrag;
|
|
177
|
+
private contentSelectionAnchor;
|
|
178
|
+
private contentSelectionEndListener;
|
|
161
179
|
private frameHadAnimation;
|
|
162
180
|
private frameHadInteractive;
|
|
163
181
|
private resizeHandler;
|
|
@@ -199,6 +217,8 @@ export declare class Scene {
|
|
|
199
217
|
private hasWarnedZeroSize;
|
|
200
218
|
private fontLoadHandler;
|
|
201
219
|
constructor(canvas: HTMLCanvasElement, options?: SceneOptions);
|
|
220
|
+
private endContentSelectionDrag;
|
|
221
|
+
private releaseContentSelectionForRebuild;
|
|
202
222
|
/**
|
|
203
223
|
* Expose the underlying {@link IRenderer} for advanced direct-draw operations.
|
|
204
224
|
*
|
|
@@ -218,6 +238,7 @@ export declare class Scene {
|
|
|
218
238
|
* @example scene.add(new CircleEntity());
|
|
219
239
|
*/
|
|
220
240
|
add(entity: Entity): this;
|
|
241
|
+
private clearContentGridState;
|
|
221
242
|
private removeA11yRecursively;
|
|
222
243
|
/**
|
|
223
244
|
* Remove a top-level entity from the scene graph and clean up its
|
|
@@ -297,6 +318,14 @@ export declare class Scene {
|
|
|
297
318
|
* visible to the browser's text machinery anyway.
|
|
298
319
|
*/
|
|
299
320
|
private syncContentProjection;
|
|
321
|
+
/**
|
|
322
|
+
* Materialize a prepared grid in logical source order while positioning each
|
|
323
|
+
* carrier from the shared canvas geometry. Browser font measurement happens
|
|
324
|
+
* later in one cold read/write batch, never inside projection synchronization.
|
|
325
|
+
*/
|
|
326
|
+
private syncContentGridProjection;
|
|
327
|
+
private getContentMetricScaleX;
|
|
328
|
+
private scheduleContentGridCalibration;
|
|
300
329
|
private enforceA11yDomOrder;
|
|
301
330
|
/** Keep DOM/WebGL overlay layers aligned with the canvas's CSS box. */
|
|
302
331
|
private syncOverlayGeometry;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectojs/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -49,9 +49,11 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"files": [
|
|
52
|
-
"dist"
|
|
52
|
+
"dist",
|
|
53
|
+
"THIRD_PARTY_NOTICES.md"
|
|
53
54
|
],
|
|
54
55
|
"scripts": {
|
|
56
|
+
"benchmark:grid": "vitest bench benchmark/PreparedContentGrid.bench.ts --run",
|
|
55
57
|
"build": "node scripts/build-worker.js && tsup && tsc -p tsconfig.build.json",
|
|
56
58
|
"test": "vitest run",
|
|
57
59
|
"test:e2e": "bun e2e/hidpi.e2e.ts && bun e2e/text-projection.e2e.ts"
|
|
@@ -59,6 +61,7 @@
|
|
|
59
61
|
"dependencies": {},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@vitest/coverage-v8": "^4.1.10",
|
|
64
|
+
"bidi-js": "^1.0.3",
|
|
62
65
|
"esbuild": "^0.28.1",
|
|
63
66
|
"jsdom": "^29.1.1",
|
|
64
67
|
"tsup": "^8.3.5",
|