@weasel-js/core 1.3.0 → 1.4.0-pre.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/CHANGELOG.md +303 -0
- package/dist/{DrawCommand-BnZyQaDc.d.ts → DrawCommand-b-z1bCT-.d.ts} +1 -1
- package/dist/{chunk-3FB44DBC.js → chunk-BLJNRMKB.js} +3 -3
- package/dist/{chunk-3FB44DBC.js.map → chunk-BLJNRMKB.js.map} +1 -1
- package/dist/{chunk-3ZV53ZW2.js → chunk-H6E6KPTU.js} +19 -2
- package/dist/chunk-H6E6KPTU.js.map +1 -0
- package/dist/{chunk-N3T7D6AS.js → chunk-IMFXEINV.js} +455 -172
- package/dist/chunk-IMFXEINV.js.map +1 -0
- package/dist/{chunk-F74NVEHT.js → chunk-SBFC6J3C.js} +14 -3
- package/dist/chunk-SBFC6J3C.js.map +1 -0
- package/dist/{chunk-AQS4JGRA.js → chunk-Y5KS66G7.js} +3 -3
- package/dist/{chunk-AQS4JGRA.js.map → chunk-Y5KS66G7.js.map} +1 -1
- package/dist/index.d.ts +215 -165
- package/dist/index.js +5 -5
- package/dist/insert.js +1 -1
- package/dist/move.js +2 -2
- package/dist/{registry-BU1_3L_C.d.ts → registry-sBLZYWI1.d.ts} +167 -13
- package/dist/renderer.d.ts +6 -413
- package/dist/renderer.js +5 -5
- package/dist/resize.js +2 -2
- package/dist/routing.d.ts +2 -2
- package/dist/routing.js +1 -1
- package/dist/stroke-B_BxktoE.d.ts +626 -0
- package/package.json +8 -8
- package/dist/chunk-3ZV53ZW2.js.map +0 -1
- package/dist/chunk-F74NVEHT.js.map +0 -1
- package/dist/chunk-N3T7D6AS.js.map +0 -1
- package/dist/stroke-5pBwOm9s.d.ts +0 -190
package/dist/renderer.d.ts
CHANGED
|
@@ -1,204 +1,12 @@
|
|
|
1
|
-
import { M as Mesh
|
|
2
|
-
export { a as ShaderCompileError, b as SpriteSheet, c as StrokeOptions, V as ViewLike, f as frameRect, t as tessellateStroke, v as viewToMat3 } from './stroke-
|
|
3
|
-
|
|
4
|
-
export { TextureHandle } from '@weasel-js/paint';
|
|
5
|
-
import { M as Mat3, S as ShaderProgramHandle, D as DrawCommand } from './DrawCommand-BnZyQaDc.js';
|
|
6
|
-
export { G as GroupDrawCommand, I as ImageDrawCommand, P as PathDrawCommand, a as ShaderDrawCommand, b as ShaderUniform, c as SolidPaint, T as TextDrawCommand, m as mat3, r as registerProgram } from './DrawCommand-BnZyQaDc.js';
|
|
1
|
+
import { M as Mesh } from './stroke-B_BxktoE.js';
|
|
2
|
+
export { I as IDENTITY_COLOR_MATRIX, a as ImageMinification, R as RenderTarget, S as ShaderCompileError, b as SpriteSheet, c as StrokeOptions, V as ViewLike, W as WeaselRenderer, d as WeaselRendererOptions, e as buildGradientRamp, f as frameRect, t as tessellateStroke, v as viewToMat3 } from './stroke-B_BxktoE.js';
|
|
3
|
+
export { D as DrawCommand, G as GroupDrawCommand, I as ImageDrawCommand, M as Mat3, P as PathDrawCommand, S as ShaderDrawCommand, a as ShaderProgramHandle, b as ShaderUniform, c as SolidPaint, T as TextDrawCommand, m as mat3, r as registerProgram } from './DrawCommand-b-z1bCT-.js';
|
|
7
4
|
import { P as Path } from './path-JEV2c5If.js';
|
|
8
5
|
export { canQueryLocalFonts, enableLocalFontOutlines, hasFontOutlines, isCanvasFont, listFontOutlines, outlineStatus, registerCanvasFont, registerFont, registerFontOutlines, subscribeGlyphReady, unregisterCanvasFont, unregisterFontOutlines } from '@weasel-js/font';
|
|
6
|
+
import { TextureHandle } from '@weasel-js/paint';
|
|
7
|
+
export { TextureHandle } from '@weasel-js/paint';
|
|
9
8
|
import '@weasel-js/text';
|
|
10
9
|
|
|
11
|
-
interface GLMeshHandle {
|
|
12
|
-
readonly vao: WebGLVertexArrayObject;
|
|
13
|
-
readonly indexCount: number;
|
|
14
|
-
readonly requiresStencil: boolean;
|
|
15
|
-
readonly anchorA?: Uint32Array;
|
|
16
|
-
readonly anchorB?: Uint32Array;
|
|
17
|
-
readonly anchorT?: Float32Array;
|
|
18
|
-
}
|
|
19
|
-
/** Resources to release when a Mesh is reclaimed by GC. */
|
|
20
|
-
interface MeshResources {
|
|
21
|
-
vao: WebGLVertexArrayObject;
|
|
22
|
-
vbo: WebGLBuffer;
|
|
23
|
-
ibo: WebGLBuffer;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Caches GL-side buffers + VAO per `Mesh` identity. Upload happens lazily
|
|
27
|
-
* on first `handleFor(mesh)` call.
|
|
28
|
-
*
|
|
29
|
-
* **GC-aware cleanup (deferred-delete queue):** when a Mesh becomes
|
|
30
|
-
* unreachable, the WeakMap entry is dropped automatically — but the
|
|
31
|
-
* underlying GL resources (VAO, VBO, IBO) would leak forever without an
|
|
32
|
-
* explicit `gl.delete*` call. We register each Mesh with a
|
|
33
|
-
* `FinalizationRegistry`; when the Mesh is reclaimed, the finalizer pushes
|
|
34
|
-
* the resources onto an internal queue. The renderer drains this queue at
|
|
35
|
-
* the start of each `render()` call (via `drainPendingDeletes()`), when GL
|
|
36
|
-
* is in a known state — no VAO bound, no draw mid-flight. Deleting from the
|
|
37
|
-
* finalizer directly was racy (it could fire between two `gl.bindVertexArray`
|
|
38
|
-
* calls inside `dispatch()`, sometimes corrupting the next draw); deferring
|
|
39
|
-
* the actual delete to a known-safe point keeps the use-after-free risk to
|
|
40
|
-
* zero.
|
|
41
|
-
*
|
|
42
|
-
* Caveats:
|
|
43
|
-
* - Finalizer timing is non-deterministic; resources may live for a frame
|
|
44
|
-
* or two beyond their Mesh, but they will be reclaimed.
|
|
45
|
-
* - If the GL context is lost between finalizer and drain, the drain
|
|
46
|
-
* no-ops safely (`gl.isContextLost()` makes deletes no-ops, and
|
|
47
|
-
* `gl.deleteBuffer(null)` is allowed).
|
|
48
|
-
*
|
|
49
|
-
* The cache is GL-context-bound; if the context is lost and re-created, the
|
|
50
|
-
* renderer should construct a new GLMeshCache. (Context loss handling lives
|
|
51
|
-
* in `WeaselRenderer`.)
|
|
52
|
-
*/
|
|
53
|
-
declare class GLMeshCache {
|
|
54
|
-
private readonly gl;
|
|
55
|
-
private readonly aPositionLoc;
|
|
56
|
-
private readonly map;
|
|
57
|
-
/** Meshes this context has drawn at least once; see `uploadRecurring`. */
|
|
58
|
-
private readonly seen;
|
|
59
|
-
private readonly finalizer;
|
|
60
|
-
private readonly pendingDeletes;
|
|
61
|
-
/** Transient resources allocated this frame; freed at end of render(). */
|
|
62
|
-
private readonly transientThisFrame;
|
|
63
|
-
constructor(gl: WebGL2RenderingContext, aPositionLoc: number);
|
|
64
|
-
handleFor(mesh: Mesh): GLMeshHandle;
|
|
65
|
-
/**
|
|
66
|
-
* Upload a Mesh that the caller knows is single-use (e.g. the per-frame
|
|
67
|
-
* stroke ribbon from `tessellateStroke`). Returns a handle backed by fresh
|
|
68
|
-
* GL resources that the renderer will free deterministically at the end
|
|
69
|
-
* of the current frame via `freeTransient()`. Bypasses the WeakMap cache
|
|
70
|
-
* and the FinalizationRegistry, so transient meshes never wait on GC.
|
|
71
|
-
*/
|
|
72
|
-
uploadTransient(mesh: Mesh): GLMeshHandle;
|
|
73
|
-
/**
|
|
74
|
-
* Upload a Mesh that may or may not recur across frames. Its first sight in
|
|
75
|
-
* *this* context takes `uploadTransient`; every later one takes the
|
|
76
|
-
* persistent handle. One transient upload to find out is cheaper than
|
|
77
|
-
* stranding a persistent VAO on a mesh that never returns, whose release
|
|
78
|
-
* would wait on GC. The transient upload does not populate the persistent
|
|
79
|
-
* map, so steady-state reuse begins on the third frame.
|
|
80
|
-
*/
|
|
81
|
-
uploadRecurring(mesh: Mesh): GLMeshHandle;
|
|
82
|
-
/**
|
|
83
|
-
* Free all transient resources allocated since the last call. Called by
|
|
84
|
-
* the renderer at the end of each `render()`. Safe under context loss.
|
|
85
|
-
*/
|
|
86
|
-
freeTransient(): void;
|
|
87
|
-
/** @internal — for tests asserting the transient-list size. */
|
|
88
|
-
_transientCount(): number;
|
|
89
|
-
/**
|
|
90
|
-
* Free GL resources whose Mesh has been GC'd since the last drain.
|
|
91
|
-
* Called by the renderer at the top of each `render()`, before any draws.
|
|
92
|
-
*/
|
|
93
|
-
drainPendingDeletes(): void;
|
|
94
|
-
/** @internal — for tests asserting the queue size. */
|
|
95
|
-
_pendingDeleteCount(): number;
|
|
96
|
-
/** @internal — for tests that need to simulate the finalizer firing. */
|
|
97
|
-
_enqueueDeleteForTest(resources: MeshResources): void;
|
|
98
|
-
private upload;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* GL texture upload + cache for MSDF font atlases (and future images).
|
|
103
|
-
*
|
|
104
|
-
* Textures are keyed by a string id (the font family name or image id).
|
|
105
|
-
* Pixels are uploaded once per id; a later upload of the same id reuses the
|
|
106
|
-
* texture and only re-applies its wrap mode when that changed.
|
|
107
|
-
* The cache is GL-context-bound; discard and create a new one on context loss.
|
|
108
|
-
*
|
|
109
|
-
* Atlas format: RGBA UNSIGNED_BYTE, linear filtering, no mipmaps.
|
|
110
|
-
* Mipmap generation is deliberately skipped — MSDF works correctly with
|
|
111
|
-
* linear filtering, and mipmap resampling corrupts the multi-channel SDF signal.
|
|
112
|
-
*/
|
|
113
|
-
type TexSource = HTMLImageElement | ImageBitmap | ImageData | HTMLCanvasElement;
|
|
114
|
-
/** How a texture samples outside `0..1`. Pattern tiles need `'repeat'`;
|
|
115
|
-
* everything else clamps. WebGL2 allows `REPEAT` on NPOT textures, so a
|
|
116
|
-
* tile of any size tiles correctly. */
|
|
117
|
-
type TextureWrap = 'clamp' | 'repeat';
|
|
118
|
-
declare class GLTextureCache {
|
|
119
|
-
private readonly gl;
|
|
120
|
-
private readonly map;
|
|
121
|
-
private readonly wraps;
|
|
122
|
-
constructor(gl: WebGL2RenderingContext);
|
|
123
|
-
has(id: string): boolean;
|
|
124
|
-
/** Uploads the pixels once per id. `wrap` is re-applied whenever it differs
|
|
125
|
-
* from what the id was last uploaded under: the same registered image can
|
|
126
|
-
* be a clamped shader texture in one draw and a repeating pattern tile in
|
|
127
|
-
* the next, and first-upload-wins gave the second one the first one's mode. */
|
|
128
|
-
upload(id: string, source: TexSource, wrap?: TextureWrap): string;
|
|
129
|
-
private applyWrap;
|
|
130
|
-
/** Create a single-channel R8 texture from raw bytes (full upload).
|
|
131
|
-
* No-op if `id` already exists. Same LINEAR/CLAMP params as `upload`;
|
|
132
|
-
* UNPACK_ALIGNMENT dropped to 1 for non-4-aligned row widths. */
|
|
133
|
-
uploadR8(id: string, width: number, height: number, data: Uint8Array): void;
|
|
134
|
-
/** Patch a rect of an existing R8 texture with tightly-packed w×h bytes. */
|
|
135
|
-
subImageR8(id: string, x: number, y: number, w: number, h: number, data: Uint8Array): void;
|
|
136
|
-
bind(id: string, unit: number): void;
|
|
137
|
-
/**
|
|
138
|
-
* Delete every uploaded GL texture and clear the map. Called by
|
|
139
|
-
* `WeaselRenderer.dispose()`. The cache is unusable but refillable
|
|
140
|
-
* afterward — a subsequent `upload()` for a previously-seen id re-creates
|
|
141
|
-
* the texture rather than restoring the deleted one.
|
|
142
|
-
*/
|
|
143
|
-
free(): void;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* CPU gradient-ramp builder + GL 1×256 RGBA texture cache.
|
|
148
|
-
*
|
|
149
|
-
* Each unique stop list is uploaded once. Key = JSON.stringify(stops).
|
|
150
|
-
* The cache is GL-context-bound; discard and recreate on context loss.
|
|
151
|
-
*
|
|
152
|
-
* Output convention §2: texels are stored as straight RGBA. The fragment
|
|
153
|
-
* shader applies premultiplication before writing outColor.
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
/** Bake gradient stops into a 256-entry RGBA lookup strip, which the shader
|
|
157
|
-
* samples instead of evaluating stops per fragment. */
|
|
158
|
-
declare function buildGradientRamp(stops: GradStop[]): Uint8ClampedArray;
|
|
159
|
-
declare class GradientRampCache {
|
|
160
|
-
private readonly gl;
|
|
161
|
-
private readonly map;
|
|
162
|
-
private totalQueries;
|
|
163
|
-
private cacheHits;
|
|
164
|
-
constructor(gl: WebGL2RenderingContext);
|
|
165
|
-
upload(stops: GradStop[]): string;
|
|
166
|
-
bind(key: string, unit: number): void;
|
|
167
|
-
hitRate(): number;
|
|
168
|
-
resetStats(): void;
|
|
169
|
-
/**
|
|
170
|
-
* Delete every uploaded GL ramp texture and clear the map. Called by
|
|
171
|
-
* `WeaselRenderer.dispose()`. Only the GL textures are owned resources —
|
|
172
|
-
* `buildGradientRamp`'s CPU-side `Uint8ClampedArray` is transient per
|
|
173
|
-
* `upload()` call and already gone by the time a ramp is cached. The
|
|
174
|
-
* cache is unusable but refillable afterward (stats are left as-is; call
|
|
175
|
-
* `resetStats()` separately if desired).
|
|
176
|
-
*/
|
|
177
|
-
free(): void;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** Row-major 4×5 color matrix identity. */
|
|
181
|
-
declare const IDENTITY_COLOR_MATRIX: Float32Array<ArrayBuffer>;
|
|
182
|
-
interface GroupFrame {
|
|
183
|
-
transform?: Mat3;
|
|
184
|
-
alpha?: number;
|
|
185
|
-
/** Row-major 4×5 color matrix (20 floats). Absent leaves the stack unchanged. */
|
|
186
|
-
colorMatrix?: Float32Array | number[];
|
|
187
|
-
}
|
|
188
|
-
declare class GroupState {
|
|
189
|
-
private transformStack;
|
|
190
|
-
private alphaStack;
|
|
191
|
-
private colorMatrixStack;
|
|
192
|
-
get transform(): Mat3;
|
|
193
|
-
get alpha(): number;
|
|
194
|
-
get colorMatrix(): Float32Array;
|
|
195
|
-
push(frame: GroupFrame): void;
|
|
196
|
-
/** Drop every pushed frame, leaving the root. A frame that throws part-way
|
|
197
|
-
* down the tree never pops, and the next frame would draw under leftovers. */
|
|
198
|
-
reset(): void;
|
|
199
|
-
pop(): void;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
10
|
/**
|
|
203
11
|
* registerTexture — accepts an image source, assigns an opaque id, stores in
|
|
204
12
|
* a module-level registry. Actual GL upload happens lazily at draw time in
|
|
@@ -221,221 +29,6 @@ declare class GroupState {
|
|
|
221
29
|
*/
|
|
222
30
|
declare function registerTexture(image: HTMLImageElement | ImageBitmap): TextureHandle;
|
|
223
31
|
|
|
224
|
-
/**
|
|
225
|
-
* Growable vertex staging for consecutive solid-fill geometry.
|
|
226
|
-
*
|
|
227
|
-
* Geometry only: `draw.ts` owns when a run starts, what breaks it, and the
|
|
228
|
-
* uniforms the flush draws under. Colors ride the vertices (the batch program
|
|
229
|
-
* is `pathFillVColor` with `u_color` left at white) because shapes in a run
|
|
230
|
-
* differ in color and a merged draw has one set of uniforms — and so does the
|
|
231
|
-
* model transform, applied here rather than uploaded, so that shapes under
|
|
232
|
-
* different transforms still share a draw.
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
declare class SolidBatch {
|
|
236
|
-
private readonly gl;
|
|
237
|
-
private readonly aPos;
|
|
238
|
-
private readonly aColor;
|
|
239
|
-
/** Cycled per flush, and created on first use so a renderer that flushes
|
|
240
|
-
* rarely allocates as few slots as it flushes. */
|
|
241
|
-
private readonly ring;
|
|
242
|
-
private next;
|
|
243
|
-
/** The same, for flushes past a slot's capacity; these sets grow to fit. */
|
|
244
|
-
private readonly largeRing;
|
|
245
|
-
private nextLarge;
|
|
246
|
-
private verts;
|
|
247
|
-
private idx;
|
|
248
|
-
private nVerts;
|
|
249
|
-
private nIdx;
|
|
250
|
-
/** Whether the staged run is rects alone, so its indices are the canonical
|
|
251
|
-
* quad pattern and a slot already holding that pattern needs no upload. */
|
|
252
|
-
private pureRects;
|
|
253
|
-
constructor(gl: WebGL2RenderingContext, prog: ShaderProgram);
|
|
254
|
-
get length(): number;
|
|
255
|
-
/** Whether staging `vertices` more would put the run past the per-flush cap. */
|
|
256
|
-
wouldOverflow(vertices: number): boolean;
|
|
257
|
-
/**
|
|
258
|
-
* Append one rect's four corners through `m`, all carrying `rgba` (straight
|
|
259
|
-
* alpha). An affine maps a rect to a parallelogram, so two triangles still
|
|
260
|
-
* cover it and the batch draws at `u_model` identity.
|
|
261
|
-
*/
|
|
262
|
-
pushRect(x: number, y: number, w: number, h: number, m: Mat3, r: number, g: number, b: number, a: number): void;
|
|
263
|
-
/**
|
|
264
|
-
* Append a tessellated mesh through `m`, all vertices carrying `rgba`. The
|
|
265
|
-
* mesh's own indices are rebased onto the staged vertices, which is why the
|
|
266
|
-
* index buffer is uploaded per flush rather than written once.
|
|
267
|
-
*/
|
|
268
|
-
pushMesh(mesh: Mesh, m: Mat3, r: number, g: number, b: number, a: number): void;
|
|
269
|
-
/** Upload the staged geometry into the next set of buffers and bind its VAO.
|
|
270
|
-
* Returns the index count for the caller's `drawElements`. */
|
|
271
|
-
uploadAndBind(): number;
|
|
272
|
-
reset(): void;
|
|
273
|
-
dispose(): void;
|
|
274
|
-
/** Grow the CPU arrays so `vertices` / `indices` more fit. */
|
|
275
|
-
private reserve;
|
|
276
|
-
private nextRingSlot;
|
|
277
|
-
private nextLargeSlot;
|
|
278
|
-
private createSet;
|
|
279
|
-
private deleteSet;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/** How to construct a `WeaselRenderer`: the GL context or canvas to draw
|
|
283
|
-
* into, the output size, and the quality knobs that separate screen
|
|
284
|
-
* rendering from print. */
|
|
285
|
-
interface WeaselRendererOptions {
|
|
286
|
-
gl?: WebGL2RenderingContext;
|
|
287
|
-
canvas?: HTMLCanvasElement;
|
|
288
|
-
width: number;
|
|
289
|
-
height: number;
|
|
290
|
-
dpr: number;
|
|
291
|
-
/** MIN_FILTER strategy for image/pattern textures (`GLImageCache`).
|
|
292
|
-
* Default `'linear'` — the existing screen behavior. The headless
|
|
293
|
-
* `renderSceneToPixels` path passes `'mipmap'` for print-quality
|
|
294
|
-
* minification. Explicitly passing `'linear'` is always valid. */
|
|
295
|
-
imageMinification?: ImageMinification;
|
|
296
|
-
/** Flatness tolerance for curve tessellation, in WORLD units (see
|
|
297
|
-
* `TessellateOptions.flattenTolerance`). When set, path fills are
|
|
298
|
-
* tessellated fresh at this tolerance per frame (transient pool) instead
|
|
299
|
-
* of served from the Path-identity mesh cache — the cache key does not
|
|
300
|
-
* include tolerance. Default: unset — the existing cached behavior at
|
|
301
|
-
* `DEFAULT_FLATTEN_TOLERANCE`. The headless path derives this from the
|
|
302
|
-
* requested output scale; screen callers normally leave it unset. */
|
|
303
|
-
flattenTolerance?: number;
|
|
304
|
-
/** Per-render synchronous bake budget for dynamic canvas-SDF glyphs.
|
|
305
|
-
* Default DEFAULT_BAKE_BUDGET (16). The headless renderSceneToPixels
|
|
306
|
-
* path passes Infinity so print never defers a glyph. */
|
|
307
|
-
bakeBudget?: number;
|
|
308
|
-
/** On-screen glyph size, in CSS pixels, at or above which text renders from
|
|
309
|
-
* tessellated font outlines instead of a distance field — see
|
|
310
|
-
* `OUTLINE_MIN_SCREEN_PX`. Only faces registered with
|
|
311
|
-
* `registerFontOutlines` are affected; everything else keeps its SDF tier
|
|
312
|
-
* whatever this says. Pass `Infinity` to disable the tier outright, or 0
|
|
313
|
-
* to use outlines wherever they exist (what the headless path does, since
|
|
314
|
-
* print has no reason to sample a field it could evaluate exactly). */
|
|
315
|
-
textOutlineMinScreenSize?: number;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* The WebGL2 renderer: takes a list of draw commands and paints them.
|
|
319
|
-
*
|
|
320
|
-
* It knows nothing about the scene — commands are the whole interface, which
|
|
321
|
-
* is what lets layers, HUD widgets and overlays all draw through the same
|
|
322
|
-
* pipeline. GPU resources (meshes, textures, gradient ramps) are cached across
|
|
323
|
-
* frames and keyed by identity, so re-issuing the same command is cheap.
|
|
324
|
-
*/
|
|
325
|
-
declare class WeaselRenderer {
|
|
326
|
-
private readonly gl;
|
|
327
|
-
private pathFill;
|
|
328
|
-
private pathFillVColor;
|
|
329
|
-
private textSdf;
|
|
330
|
-
private textSdfR8;
|
|
331
|
-
private imageFill;
|
|
332
|
-
private gradFill;
|
|
333
|
-
private patternFill;
|
|
334
|
-
private meshCache;
|
|
335
|
-
private textureCache;
|
|
336
|
-
private imageCache;
|
|
337
|
-
private gradRampCache;
|
|
338
|
-
private programRegistry;
|
|
339
|
-
private quadVbo;
|
|
340
|
-
private quadIbo;
|
|
341
|
-
private solidBatch;
|
|
342
|
-
private readonly groupState;
|
|
343
|
-
private widthCss;
|
|
344
|
-
private heightCss;
|
|
345
|
-
private dpr;
|
|
346
|
-
private canvas;
|
|
347
|
-
private readonly imageMinification;
|
|
348
|
-
private readonly flattenTolerance?;
|
|
349
|
-
private readonly bakeBudget;
|
|
350
|
-
private readonly textOutlineMinScreenSize;
|
|
351
|
-
private contextLost;
|
|
352
|
-
private boundOnLost;
|
|
353
|
-
private boundOnRestored;
|
|
354
|
-
/** True after `dispose()`. A disposed renderer ignores further `render()`
|
|
355
|
-
* calls and `registerProgram()` calls. */
|
|
356
|
-
private disposed;
|
|
357
|
-
constructor(opts: WeaselRendererOptions);
|
|
358
|
-
private uploadQuadGeometry;
|
|
359
|
-
/**
|
|
360
|
-
* Compile a consumer-registered shader program against this renderer's GL context.
|
|
361
|
-
*
|
|
362
|
-
* Call once per renderer after the module-level `registerProgram()`.
|
|
363
|
-
* Throws `ShaderCompileError` if compilation fails.
|
|
364
|
-
*
|
|
365
|
-
* In dev mode, calling again with the same handle replaces the compiled program.
|
|
366
|
-
*
|
|
367
|
-
* @experimental
|
|
368
|
-
*/
|
|
369
|
-
registerProgram(handle: ShaderProgramHandle): void;
|
|
370
|
-
/**
|
|
371
|
-
* The compiled program for `id`, compiling it against this context on first
|
|
372
|
-
* use. Unlike {@link registerProgram} this neither throws on a missing
|
|
373
|
-
* source nor on a compile failure: a paint kind asking for a program it
|
|
374
|
-
* never registered must decline the paint, not take down the frame.
|
|
375
|
-
*/
|
|
376
|
-
private ensureProgram;
|
|
377
|
-
private applyViewport;
|
|
378
|
-
isContextLost(): boolean;
|
|
379
|
-
private onContextLost;
|
|
380
|
-
private onContextRestored;
|
|
381
|
-
/** Free the GL resources this renderer itself owns and detach context-loss
|
|
382
|
-
* listeners when a canvas was supplied. Idempotent.
|
|
383
|
-
*
|
|
384
|
-
* Scope: built-in shader programs, any consumer-registered programs, the
|
|
385
|
-
* shared quad/rect geometry, any in-flight transient meshes, and the
|
|
386
|
-
* enumerable Map-keyed caches (`GLTextureCache` atlas/image textures,
|
|
387
|
-
* `GradientRampCache` ramp textures) ARE freed.
|
|
388
|
-
*
|
|
389
|
-
* NOT freed: `GLImageCache` (bitmap/pattern textures) and `GLMeshCache`'s
|
|
390
|
-
* persistent per-Path mesh cache are keyed by `WeakMap`, not enumerable,
|
|
391
|
-
* and are only reclaimed when the GL context itself goes away (cf.
|
|
392
|
-
* `GLImageCache`'s own "deferred to v2" note). On a caller-owned
|
|
393
|
-
* long-lived context — the headless render-to-pixels path hands the same
|
|
394
|
-
* `gl` to many short-lived renderers — the image/pattern textures and
|
|
395
|
-
* persistent Path meshes each renderer uploads DO accumulate across
|
|
396
|
-
* renderer instances until the caller recycles the context.
|
|
397
|
-
*
|
|
398
|
-
* Also: a Mesh that gets GC'd after `dispose()` still lands in
|
|
399
|
-
* `GLMeshCache`'s `pendingDeletes` queue via its `FinalizationRegistry`,
|
|
400
|
-
* but nothing drains that queue post-dispose (only `render()` does) —
|
|
401
|
-
* those GL resources leak until the context goes away too.
|
|
402
|
-
*
|
|
403
|
-
* A disposed renderer ignores further `render()` and `registerProgram()`
|
|
404
|
-
* calls. */
|
|
405
|
-
dispose(): void;
|
|
406
|
-
/**
|
|
407
|
-
* Draw one frame.
|
|
408
|
-
*
|
|
409
|
-
* `viewMatrix` is the frame's world→screen transform. It is only consulted
|
|
410
|
-
* by `units: 'world'` gradients, which fall back to screen space without
|
|
411
|
-
* it — every other command carries its own transform in the stream, so
|
|
412
|
-
* callers with no view concept can keep calling `render(commands)`.
|
|
413
|
-
*/
|
|
414
|
-
render(commands: DrawCommand[], viewMatrix?: Mat3): void;
|
|
415
|
-
resize(dims: {
|
|
416
|
-
width: number;
|
|
417
|
-
height: number;
|
|
418
|
-
dpr: number;
|
|
419
|
-
}): void;
|
|
420
|
-
/** @internal */ _gl(): WebGL2RenderingContext;
|
|
421
|
-
/** @internal */ _pathFill(): ShaderProgram;
|
|
422
|
-
/** @internal */ _pathFillVColor(): ShaderProgram;
|
|
423
|
-
/** @internal */ _solidBatch(): SolidBatch;
|
|
424
|
-
/** @internal */ _textSdf(): ShaderProgram;
|
|
425
|
-
/** @internal */ _textSdfR8(): ShaderProgram;
|
|
426
|
-
/** @internal */ _imageFill(): ShaderProgram;
|
|
427
|
-
/** @internal */ _gradFill(): ShaderProgram;
|
|
428
|
-
/** @internal */ _patternFill(): ShaderProgram;
|
|
429
|
-
/** @internal */ _meshCache(): GLMeshCache;
|
|
430
|
-
/** @internal */ _textureCache(): GLTextureCache;
|
|
431
|
-
/** @internal */ _imageCache(): GLImageCache;
|
|
432
|
-
/** @internal */ _gradRampCache(): GradientRampCache;
|
|
433
|
-
/** @internal */ _groupState(): GroupState;
|
|
434
|
-
/** @internal */ _widthCss(): number;
|
|
435
|
-
/** @internal */ _heightCss(): number;
|
|
436
|
-
/** @internal */ _dpr(): number;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
32
|
/** Options for `tessellate`. A smaller tolerance means more triangles and
|
|
440
33
|
* smoother curves; it is in path-local units, so callers rendering at a
|
|
441
34
|
* larger scale should tighten it. */
|
|
@@ -462,4 +55,4 @@ declare function tessellate(path: Path, opts?: TessellateOptions): Mesh;
|
|
|
462
55
|
*/
|
|
463
56
|
declare const OUTLINE_MIN_SCREEN_PX = 48;
|
|
464
57
|
|
|
465
|
-
export {
|
|
58
|
+
export { Mesh, OUTLINE_MIN_SCREEN_PX, type TessellateOptions, registerTexture, tessellate };
|
package/dist/renderer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { IDENTITY_COLOR_MATRIX, OUTLINE_MIN_SCREEN_PX, ShaderCompileError, WeaselRenderer, buildGradientRamp, canQueryLocalFonts, enableLocalFontOutlines, frameRect, hasFontOutlines, isCanvasFont, listFontOutlines, mat3, outlineStatus, registerCanvasFont, registerFont, registerFontOutlines, registerProgram, subscribeGlyphReady, tessellate, tessellateStroke, unregisterCanvasFont, unregisterFontOutlines, viewToMat3 } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-
|
|
1
|
+
export { IDENTITY_COLOR_MATRIX, OUTLINE_MIN_SCREEN_PX, ShaderCompileError, WeaselRenderer, buildGradientRamp, canQueryLocalFonts, enableLocalFontOutlines, frameRect, hasFontOutlines, isCanvasFont, listFontOutlines, mat3, outlineStatus, registerCanvasFont, registerFont, registerFontOutlines, registerProgram, subscribeGlyphReady, tessellate, tessellateStroke, unregisterCanvasFont, unregisterFontOutlines, viewToMat3 } from './chunk-IMFXEINV.js';
|
|
2
|
+
import './chunk-H6E6KPTU.js';
|
|
3
|
+
import './chunk-Y5KS66G7.js';
|
|
4
|
+
import './chunk-BLJNRMKB.js';
|
|
5
|
+
import './chunk-SBFC6J3C.js';
|
|
6
6
|
import './chunk-67KE7SDP.js';
|
|
7
7
|
import './chunk-MXFSHJOM.js';
|
|
8
8
|
import './chunk-ZB7UYJVG.js';
|
package/dist/resize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CORNER_ANCHORS, DEFAULT_RESIZE_BEHAVIORS, clampMinSize, cornerPoint, cornerResizeHandles, fixedCornerOf, hitCornerHandle, lockAspectWithModifier, pointSnapToGrid, snapToGrid, snapToGuides } from './chunk-
|
|
2
|
-
export { RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR } from './chunk-
|
|
1
|
+
export { CORNER_ANCHORS, DEFAULT_RESIZE_BEHAVIORS, clampMinSize, cornerPoint, cornerResizeHandles, fixedCornerOf, hitCornerHandle, lockAspectWithModifier, pointSnapToGrid, snapToGrid, snapToGuides } from './chunk-BLJNRMKB.js';
|
|
2
|
+
export { RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR } from './chunk-SBFC6J3C.js';
|
|
3
3
|
//# sourceMappingURL=resize.js.map
|
|
4
4
|
//# sourceMappingURL=resize.js.map
|
package/dist/routing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParsedModifiers, GestureName, GestureSpec } from '@weasel-js/gestures';
|
|
2
2
|
export { ChannelRef, DescribeRouteOptions, GESTURE_DESCRIPTORS, GestureArgSpec, GestureDescriptor, GestureName, ModRequirement, ModifierKey, ParsedModifiers, ParsedRoute, PhaseAtom, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, RouteDescriptionPart, RouteFieldName, RouteTermLabel, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute } from '@weasel-js/gestures';
|
|
3
|
-
import { T as Tool } from './registry-
|
|
3
|
+
import { T as Tool } from './registry-sBLZYWI1.js';
|
|
4
4
|
import './types-DIQAisSG.js';
|
|
5
5
|
import '@weasel-js/history';
|
|
6
6
|
import './path-JEV2c5If.js';
|
|
@@ -9,7 +9,7 @@ import './types-XBcDEp3Y.js';
|
|
|
9
9
|
import './view-DSQgxBJB.js';
|
|
10
10
|
import '@weasel-js/modes';
|
|
11
11
|
import 'react';
|
|
12
|
-
import './DrawCommand-
|
|
12
|
+
import './DrawCommand-b-z1bCT-.js';
|
|
13
13
|
import '@weasel-js/paint';
|
|
14
14
|
import '@weasel-js/text';
|
|
15
15
|
import './geometry-Dtt_k6Dq.js';
|
package/dist/routing.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { GESTURE_DESCRIPTORS, PREDICATE_TARGET, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, buildRouteRegistry, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, findConflicts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute, routeGestureForSpecKind, routesForSpec } from './chunk-
|
|
1
|
+
export { GESTURE_DESCRIPTORS, PREDICATE_TARGET, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, buildRouteRegistry, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, findConflicts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute, routeGestureForSpecKind, routesForSpec } from './chunk-H6E6KPTU.js';
|
|
2
2
|
//# sourceMappingURL=routing.js.map
|
|
3
3
|
//# sourceMappingURL=routing.js.map
|