@nova-lab/core 1.2.1-dev.258 → 1.2.2-dev.272

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 (30) hide show
  1. package/README.md +55 -0
  2. package/dist/2d/effects.js +165 -404
  3. package/dist/2d/lighting.d.ts +2 -0
  4. package/dist/2d/lighting.js +483 -227
  5. package/dist/2d/lottie.js +1 -1
  6. package/dist/2d/meshes.js +2 -2
  7. package/dist/2d/render-textures.js +3 -537
  8. package/dist/2d.js +3 -3
  9. package/dist/{NovaNode-CBZ-Ol-W.js → NovaNode-CshmSV9Y.js} +21 -21
  10. package/dist/{NovaRenderCommandWriter-CWQRa42y.js → NovaRenderCommandWriter-DeHyKjke.js} +272 -251
  11. package/dist/NovaRenderTexture-Desjl5-m.js +539 -0
  12. package/dist/{NovaTextSelectionService-Bdi0AqZ5.js → NovaTextSelectionService-CWJKn7TW.js} +3658 -3216
  13. package/dist/{NovaWebGLProgram-BO250QNF.js → NovaWebGLProgram-ytnblA5d.js} +28 -25
  14. package/dist/core.js +3 -3
  15. package/dist/model/lighting/LightingFields2D.d.ts +35 -0
  16. package/dist/model/lighting/LightingRenderer2D.d.ts +11 -18
  17. package/dist/model/lighting/LightingScene2D.d.ts +43 -0
  18. package/dist/model/lighting/NovaLighting2D.d.ts +18 -33
  19. package/dist/model/lighting/NovaLightingEffect2D.d.ts +46 -0
  20. package/dist/model/lighting/lighting-effect.d.ts +24 -0
  21. package/dist/model/lighting/lighting-shaders.d.ts +2 -2
  22. package/dist/model/lighting/lighting.types.d.ts +5 -1
  23. package/dist/model/render/backends/webgl/NovaWebGLCompositionPass.d.ts +2 -1
  24. package/dist/model/render/backends/webgl/NovaWebGLFrameRenderer.d.ts +29 -3
  25. package/dist/model/render/backends/webgl/NovaWebGLPathClipPass.d.ts +3 -2
  26. package/dist/model/render/backends/webgl/NovaWebGLProgram.d.ts +1 -1
  27. package/dist/model/render/graph/nova-render-dirty-items.d.ts +12 -0
  28. package/dist/model/runtime/cursor/NovaCursorManager.d.ts +7 -0
  29. package/dist/shader-effect-CHXZBHrO.js +247 -0
  30. package/package.json +2 -2
package/dist/2d/lottie.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { mat3 as H } from "gl-matrix";
2
2
  import { t as le } from "../nova-color-parser-BCN_rFRN.js";
3
- import { N as C } from "../NovaNode-CBZ-Ol-W.js";
3
+ import { N as C } from "../NovaNode-CshmSV9Y.js";
4
4
  class ye extends Error {
5
5
  constructor(c, a, i) {
6
6
  super(`[Nova Lottie] ${c}${a === null ? "" : ` (layer ${a})`}: ${i}`), this.jsonPath = c, this.layer = a, this.feature = i, this.name = "NovaLottiePreparationError";
package/dist/2d/meshes.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i as I } from "../nova-render-texture-image-identity-DQ09XFKs.js";
2
2
  import { g as M, r as P, s as Y } from "../nova-mesh-registry-B7Xz5mhU.js";
3
- import { N as X } from "../NovaWebGLProgram-BO250QNF.js";
4
- import { N as G } from "../NovaNode-CBZ-Ol-W.js";
3
+ import { N as X } from "../NovaWebGLProgram-ytnblA5d.js";
4
+ import { N as G } from "../NovaNode-CshmSV9Y.js";
5
5
  const D = /* @__PURE__ */ new WeakMap(), L = 65536, $ = 393216;
6
6
  function H(e) {
7
7
  if (!e || !Number.isSafeInteger(e.positions?.length) || e.positions.length < 6 || e.positions.length % 2 || e.positions.length > L * 2)
@@ -1,539 +1,5 @@
1
- import { t as q, u as z, v as I } from "../NovaRenderCommandWriter-CWQRa42y.js";
2
- import { g as M, E as P, n as D } from "../nova-color-parser-BCN_rFRN.js";
3
- import { s as L } from "../nova-mesh-registry-B7Xz5mhU.js";
4
- import { N as S, w as N, b as A } from "../NovaNode-CBZ-Ol-W.js";
5
- import { o as k } from "../NovaAssetRegistry-p2QlCwvT.js";
6
- class O {
7
- constructor(e, t, r, n, s) {
8
- this.node = e, this._app = t, this.origin = r, this._changed = n, this._trackReads = s, this.assertOwner(), this._syncAncestors();
9
- }
10
- _ancestors = [];
11
- _listeners = [];
12
- _reads = [];
13
- _closed = !1;
14
- assertOwner() {
15
- if (this.node.nova !== this._app)
16
- throw new Error("[Nova] Node capture source belongs to another app");
17
- if (this.node.runtime.disposed || this.node.lifecycleState === "destroyed")
18
- throw new Error("[Nova] Node capture source is destroyed");
19
- let e = this.node;
20
- for (; e && e !== this.node.surface; )
21
- e = e.parent instanceof S ? e.parent : null;
22
- if (!e || !this._app.surfaces.includes(this.node.surface))
23
- throw new Error("[Nova] Node capture source is detached from its app surface");
24
- }
25
- _syncAncestors() {
26
- const e = [];
27
- let t = this.node.parent;
28
- for (; t instanceof S; )
29
- e.push(t), t = t.parent;
30
- if (this._listeners.length && e.length === this._ancestors.length && e.every((n, s) => n === this._ancestors[s]))
31
- return;
32
- for (const n of this._listeners.splice(0))
33
- n();
34
- this._ancestors = e;
35
- const r = () => {
36
- this._closed || (this._syncAncestors(), this._changed());
37
- };
38
- this._listeners.push(N(this.node, !0, r));
39
- for (const n of e)
40
- this._listeners.push(N(n, !1, r)), this._listeners.push(N(n, "bounds", () => {
41
- const s = n.getComposition();
42
- !this._closed && !s?.bounds && (s || n.getMask() || n.getEffects().length) && this._changed();
43
- }));
44
- }
45
- record(e, t, r) {
46
- this.assertOwner();
47
- const n = /* @__PURE__ */ new Map(), s = this.node.surface.captureSubtreeWithContext(this.node, e, t, r, (d, h) => {
48
- let c = n.get(d);
49
- c || (c = /* @__PURE__ */ new Set(), n.set(d, c));
50
- for (const u of h.values())
51
- for (const i of u)
52
- c.add(i);
53
- });
54
- if (this._closed || this._app.raph.core.disposed)
55
- throw new Error("[Nova] Node capture owner destroyed during capture");
56
- const o = [];
57
- try {
58
- if (this._trackReads)
59
- for (const [d, h] of n)
60
- for (const c of h) {
61
- const u = d.runtime.path(c.endsWith(".*") ? c.slice(0, -2) : c);
62
- o.push(d.surface.watch(u, A.Flush, this._changed, { initial: "none" }));
63
- }
64
- } catch (d) {
65
- for (const h of o)
66
- h();
67
- throw d;
68
- }
69
- for (const d of this._reads)
70
- d();
71
- return this._reads = o, s;
72
- }
73
- destroy() {
74
- this._closed = !0;
75
- for (const e of [...this._listeners, ...this._reads])
76
- e();
77
- this._listeners = [], this._reads = [], this._ancestors = [];
78
- }
79
- }
80
- let $ = 0;
81
- class H {
82
- constructor(e) {
83
- this._host = e;
84
- }
85
- _owner = ++$;
86
- _states = /* @__PURE__ */ new Map();
87
- _next = 0;
88
- _lease;
89
- _pendingSourceChanges;
90
- _capturing = !1;
91
- _lost = !1;
92
- _destroying = !1;
93
- get hasWork() {
94
- if (this._lost)
95
- return !1;
96
- for (const e of this._states.values())
97
- if (e.dirty || this._every(e))
98
- return !0;
99
- return !1;
100
- }
101
- _read(e, t) {
102
- this._host.alive() && this._host.read(e.image.id, t);
103
- }
104
- _publish(e, t = !1) {
105
- const r = /* @__PURE__ */ new Set(), n = [], s = (o) => {
106
- if (r.has(o))
107
- return;
108
- r.add(o);
109
- const d = this._host.available(), h = {
110
- size: `${o.width}:${o.height}`,
111
- ready: o.status === "ready" && d,
112
- status: o.status === "ready" && !d ? "unready" : o.status,
113
- error: o.error,
114
- revision: o.revision
115
- }, c = o.published, u = {};
116
- (!c || c.size !== h.size) && (u.size = h.size), (!c || c.ready !== h.ready) && (u.ready = h.ready), (!c || c.status !== h.status) && (u.status = h.status), (!c || c.error !== h.error) && (u.error = h.error), (!c || c.revision !== h.revision) && (u.revision = h.revision), o.published = o.status === "destroyed" ? void 0 : h, n.push({ id: o.image.id, values: u, destroyed: o.status === "destroyed" });
117
- for (const i of o.dependents)
118
- i.status === "error" || i.status === "destroyed" || i.mode === "once" && i.revision > 0 && !i.dirty || (i.invalidation++, i.status = o.status === "error" ? "error" : "unready", i.error = o.status === "error" ? new Error(`[Nova] Render texture dependency failed: ${o.image.id}`) : void 0, i.dirty = o.status !== "error", i.waiting = !1, s(i));
119
- };
120
- s(e);
121
- for (let o = 0; o < n.length; o++) {
122
- const d = n[o], h = this._pendingSourceChanges?.get(d.id);
123
- h && (n[o] = { ...d, values: { ...h.values, ...d.values } }), t ? (this._pendingSourceChanges ??= /* @__PURE__ */ new Map()).set(d.id, n[o]) : this._pendingSourceChanges?.delete(d.id);
124
- }
125
- t || this._host.changed(n);
126
- }
127
- // Source changes keep logical readiness synchronous, but user kernel observers
128
- // run only at the existing flush boundary, after ordinary node cleanup.
129
- _flushSourceChanges() {
130
- if (!this._pendingSourceChanges?.size)
131
- return;
132
- const e = [...this._pendingSourceChanges.values()];
133
- this._pendingSourceChanges.clear();
134
- const t = [];
135
- for (const r of e)
136
- try {
137
- this._host.changed([r]);
138
- } catch (n) {
139
- if (t.push(n), this._host.alive() && [...this._states.values()].some((s) => s.image.id === r.id)) {
140
- const s = this._pendingSourceChanges.get(r.id);
141
- this._pendingSourceChanges.set(r.id, { ...r, ...s, values: { ...r.values, ...s?.values } });
142
- }
143
- }
144
- if (t.length)
145
- throw new AggregateError(t, "[Nova] Source capture metadata observers failed");
146
- }
147
- assertNotCapturing() {
148
- if (this._capturing)
149
- throw new Error("[Nova] App resize during render texture capture");
150
- }
151
- _every(e) {
152
- return e.mode === "every-frame" && e.status !== "error" && e.status !== "destroyed" && !e.waiting;
153
- }
154
- beforeFrame() {
155
- for (const e of this._states.values())
156
- if (this._every(e))
157
- return !0;
158
- return !1;
159
- }
160
- _syncLease() {
161
- const e = !this._destroying && !this._lost && this._host.alive() && this._host.available() && this.beforeFrame();
162
- e && !this._lease ? this._lease = this._host.acquireLoop() : !e && this._lease && (this._lease.release(), this._lease = void 0);
163
- }
164
- _assertMutable(e) {
165
- if (this._capturing)
166
- throw new Error("[Nova] Render texture mutation during capture");
167
- if (!this._host.alive() || this._destroying || e?.status === "destroyed")
168
- throw new Error("[Nova] Render texture is destroyed");
169
- }
170
- _size(e, t, r) {
171
- if (![e, t, r].every((d) => Number.isFinite(d) && d > 0))
172
- throw new RangeError("[Nova] Render texture dimensions and DPR must be positive finite numbers");
173
- const n = Math.max(1, Math.ceil(e * r)), s = Math.max(1, Math.ceil(t * r)), o = n * s * 4;
174
- if (!Number.isSafeInteger(o) || !Number.isFinite(n / r) || !Number.isFinite(s / r))
175
- throw new RangeError("[Nova] Render texture RGBA8 estimate is too large");
176
- return { width: n / r, height: s / r, pixelWidth: n, pixelHeight: s, bytes: o };
177
- }
178
- _dpr(e) {
179
- return e === "app" ? this._host.dpr() : e;
180
- }
181
- _charge(e) {
182
- let t = 0;
183
- for (const r of this._states.values())
184
- r !== e && (t += Math.max(r.reserved, r.allocated));
185
- return t;
186
- }
187
- validateBudget(e) {
188
- if (this._capturing)
189
- throw new Error("[Nova] Renderer configuration during RTT capture");
190
- if (!Number.isSafeInteger(e) || e < 0 || this._charge() > e)
191
- throw new RangeError("[Nova] cache.maxRenderTextureBackingBytes is below live RTT admission");
192
- }
193
- _admit(e, t) {
194
- const r = this._host.budget();
195
- if (!Number.isSafeInteger(r) || r < 0 || this._charge(t) + Math.max(e, t?.allocated ?? 0) > r)
196
- throw new RangeError("[Nova] Render texture backing budget exceeded");
197
- }
198
- create(e, t) {
199
- this._assertMutable();
200
- const r = e.update ?? "once";
201
- if (!["once", "on-dirty", "every-frame"].includes(r) || typeof e.capture != "function")
202
- throw new TypeError("[Nova] Invalid render texture update/capture");
203
- const n = e.dpr ?? "app", s = this._dpr(n), o = this._size(e.width, e.height, s);
204
- this._admit(o.bytes);
205
- const d = Object.freeze([...e.dependencies ?? []]);
206
- for (const p of d) {
207
- if (!k(p) || !["image", "icon", "fill"].includes(p.kind))
208
- throw new TypeError("[Nova] Render texture dependencies must be registered image refs");
209
- if (!this._host.assets._resolveRenderTexture(p, !1) && !this._host.assets.resolveRecord(p))
210
- throw new Error("[Nova] Render texture dependency is not registered");
211
- }
212
- const h = `texture-${++this._next}`, c = `nova.rtt.${this._owner}.${h}`, u = Object.freeze({ __novaAssetRef: !0, namespace: `nova.rtt.${this._owner}`, kind: "image", name: h, id: c }), i = {
213
- targetId: `nova:owned-rtt:${this._owner}:${h}`,
214
- image: u,
215
- dependents: /* @__PURE__ */ new Set(),
216
- dependencies: d,
217
- draw: e.capture,
218
- requestedWidth: e.width,
219
- requestedHeight: e.height,
220
- width: o.width,
221
- height: o.height,
222
- pixelWidth: o.pixelWidth,
223
- pixelHeight: o.pixelHeight,
224
- dprPolicy: n,
225
- dpr: s,
226
- mode: r,
227
- status: "unready",
228
- error: void 0,
229
- dirty: !0,
230
- waiting: !1,
231
- generation: 0,
232
- revision: 0,
233
- reserved: o.bytes,
234
- allocated: 0,
235
- allocatedDpr: 0,
236
- allocatedPixelWidth: 0,
237
- allocatedPixelHeight: 0,
238
- dependencyKeys: [],
239
- invalidation: 0
240
- };
241
- t && (i.source = new O(t.options.source, t.app, Object.freeze({ ...t.options.origin }), () => this._sourceChanged(i), r === "on-dirty")), i.unregister = this._host.assets._registerRenderTextureImage(u, () => ({
242
- kind: "render-target",
243
- targetId: i.targetId,
244
- width: i.width,
245
- height: i.height,
246
- dpr: i.dpr,
247
- pixelWidth: i.pixelWidth,
248
- pixelHeight: i.pixelHeight,
249
- generation: i.generation,
250
- revision: i.revision,
251
- error: i.error,
252
- ready: i.status === "ready" && this._host.available()
253
- })), this._states.set(u, i);
254
- for (const p of d)
255
- this._states.get(p)?.dependents.add(i);
256
- this._host.pin(i.targetId);
257
- const l = new WeakRef(this), g = () => {
258
- const p = l.deref();
259
- if (!p)
260
- throw new Error("[Nova] Render texture owner is destroyed");
261
- return p;
262
- }, w = Object.freeze({
263
- image: u,
264
- get width() {
265
- return l.deref()?._read(i, "size"), i.width;
266
- },
267
- get height() {
268
- return l.deref()?._read(i, "size"), i.height;
269
- },
270
- get ready() {
271
- return l.deref()?._read(i, "ready"), i.status === "ready" && (l.deref()?._host.available() ?? !1);
272
- },
273
- get revision() {
274
- return l.deref()?._read(i, "revision"), i.revision;
275
- },
276
- get status() {
277
- return l.deref()?._read(i, "status"), i.status === "ready" && !(l.deref()?._host.available() ?? !1) ? "unready" : i.status;
278
- },
279
- get error() {
280
- return l.deref()?._read(i, "error"), i.error;
281
- },
282
- capture() {
283
- g()._request(i);
284
- },
285
- resize(p) {
286
- g()._resize(i, p);
287
- },
288
- destroy() {
289
- i.status !== "destroyed" && g()._destroy(i);
290
- }
291
- });
292
- return this._publish(i), this._syncLease(), this._host.requestFlush(), w;
293
- }
294
- _sourceChanged(e) {
295
- e.status === "destroyed" || e.status === "error" || e.mode === "once" && e.status === "ready" || (e.invalidation++, e.status = "unready", e.dirty = !0, this._publish(e, !0), this._host.requestFlush());
296
- }
297
- _request(e) {
298
- this._assertMutable(e);
299
- const t = this._dpr(e.dprPolicy), r = this._size(e.requestedWidth, e.requestedHeight, t);
300
- this._admit(r.bytes, e), e.dpr = t, e.width = r.width, e.height = r.height, e.pixelWidth = r.pixelWidth, e.pixelHeight = r.pixelHeight, e.reserved = r.bytes, e.invalidation++, e.status = "unready", e.error = void 0, e.waiting = !1, e.dirty = !0, this._publish(e), this._syncLease(), this._host.requestFlush();
301
- }
302
- _resize(e, t) {
303
- this._assertMutable(e);
304
- const r = t.dpr ?? e.dprPolicy, n = this._dpr(r), s = this._size(t.width, t.height, n);
305
- this._admit(s.bytes, e), !(e.status === "ready" && e.requestedWidth === t.width && e.requestedHeight === t.height && e.dprPolicy === r && e.dpr === n) && (e.requestedWidth = t.width, e.requestedHeight = t.height, e.width = s.width, e.height = s.height, e.pixelWidth = s.pixelWidth, e.pixelHeight = s.pixelHeight, e.dprPolicy = r, e.dpr = n, e.reserved = s.bytes, e.invalidation++, e.status = "unready", e.error = void 0, e.waiting = !1, e.dirty = !0, this._publish(e), this._syncLease(), this._host.requestFlush());
306
- }
307
- _releaseBacking(e) {
308
- this._host.release(e.targetId), e.allocated = 0;
309
- }
310
- _error(e, t) {
311
- e.invalidation++, e.status = "error", e.error = t instanceof Error ? t : new Error(String(t)), e.dirty = !1, e.waiting = !1, this._publish(e);
312
- }
313
- dprChanged() {
314
- for (const e of this._states.values())
315
- if (!(e.dprPolicy !== "app" || e.dpr === this._host.dpr())) {
316
- e.invalidation++, e.dpr = this._host.dpr(), e.status = "unready";
317
- try {
318
- const t = this._size(e.requestedWidth, e.requestedHeight, e.dpr);
319
- e.width = t.width, e.height = t.height, e.pixelWidth = t.pixelWidth, e.pixelHeight = t.pixelHeight, this._admit(t.bytes, e), e.reserved = t.bytes, e.error = void 0, e.dirty = !0, e.waiting = !1, this._publish(e);
320
- } catch (t) {
321
- this._error(e, t);
322
- }
323
- }
324
- this._syncLease(), this.hasWork && this._host.requestFlush();
325
- }
326
- lost() {
327
- this._lost = !0;
328
- for (const e of this._states.values())
329
- e.invalidation++, e.allocated = 0, e.status !== "error" && (e.status = "unready", e.dirty = !0), this._publish(e);
330
- this._syncLease();
331
- }
332
- restored() {
333
- this._lost = !1;
334
- for (const e of this._states.values())
335
- e.invalidation++, e.allocated = 0, e.generation++, e.status !== "error" && (e.status = "unready", e.dirty = !0, e.waiting = !1), this._publish(e);
336
- this.dprChanged(), this._syncLease(), this.hasWork && this._host.requestFlush();
337
- }
338
- assetsChanged(e) {
339
- for (const t of this._states.values())
340
- t.status !== "error" && (t.mode !== "once" || t.revision === 0 || t.waiting || t.dirty) && t.dependencies.some((r) => e.includes(r.id)) && (t.invalidation++, t.status = "unready", t.dirty = !0, t.waiting = !1, this._publish(t));
341
- this._syncLease(), this.hasWork && this._host.requestFlush();
342
- }
343
- _order() {
344
- const e = [], t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = (s) => {
345
- if (t.has(s))
346
- throw new Error("[Nova] Render texture dependency cycle");
347
- if (!r.has(s)) {
348
- t.add(s);
349
- for (const o of s.dependencies)
350
- if (this._host.assets._resolveRenderTexture(o, !1)) {
351
- const h = this._states.get(o);
352
- if (!h)
353
- throw new Error("[Nova] Foreign render texture dependency");
354
- n(h);
355
- }
356
- t.delete(s), r.add(s), e.push(s);
357
- }
358
- };
359
- for (const s of this._states.values())
360
- n(s);
361
- return e;
362
- }
363
- flush() {
364
- if (!(this._lost || !this._host.available())) {
365
- if (this._capturing)
366
- throw new Error("[Nova] Recursive render texture flush");
367
- this._capturing = !0;
368
- try {
369
- this._flushSourceChanges();
370
- for (const e of this._order()) {
371
- if (!this._host.alive() || this._destroying)
372
- return;
373
- if (e.status === "error" || !e.dirty && !e.waiting && !this._every(e) && e.mode !== "on-dirty")
374
- continue;
375
- let t;
376
- try {
377
- t = e.dependencies.map((s) => this._host.assets._imageDependency(s));
378
- } catch (s) {
379
- throw this._error(e, s), s;
380
- }
381
- const r = t.map((s) => s.key), n = r.some((s, o) => s !== e.dependencyKeys[o]);
382
- if (!(e.source && e.waitingForSource && !e.dirty && !this._every(e)) && (e.dirty || this._every(e) || e.mode === "on-dirty" && n || e.waiting && t.every((s) => s.ready))) {
383
- if (e.status = "unready", t.some((s) => !s.ready)) {
384
- if (e.dirty = !1, e.waiting = !0, this._publish(e), t.some((s) => !s.ready && !s.pending)) {
385
- const s = new Error("[Nova] Image dependency failed");
386
- throw this._error(e, s), s;
387
- }
388
- continue;
389
- }
390
- try {
391
- const s = e.pixelWidth * e.pixelHeight * 4;
392
- this._admit(s, e);
393
- const o = new q(e.image.id, { x: 0, y: 0, width: e.width, height: e.height, dpr: e.dpr }, this._host.rendererType), d = new z(o), h = e.invalidation, c = e.source?.origin, u = new I(this._host.canvas, this._host.schema, d, c ? { capture: { namespace: e.targetId, x: c.x, y: c.y } } : void 0), i = d.markState(), l = e.source ? e.source.record(u, { x: c.x, y: c.y, width: e.width, height: e.height }, e.dpr) : e.draw(u, Object.freeze({ width: e.width, height: e.height, dpr: e.dpr }));
394
- if (e.source && l === !1) {
395
- e.waitingForSource = !0, e.status = "unready", e.waiting = !0, e.dirty = !1, this._publish(e);
396
- continue;
397
- }
398
- if (e.waitingForSource = !1, l && typeof l == "object" && "then" in l)
399
- throw new TypeError("[Nova] Render texture capture must be synchronous");
400
- if (!this._host.alive())
401
- throw new Error("[Nova] Render texture owner destroyed during capture");
402
- if (d.markState().transformDepth !== i.transformDepth || !d.hasNeutralRenderState)
403
- throw new Error("[Nova] Unbalanced render texture capture state");
404
- d.restoreState(i);
405
- const g = o.build();
406
- for (const a of g.commands)
407
- if (a.type === "beginRenderTarget" || a.type === "drawRenderTarget" || a.type === "endRenderTarget")
408
- throw new Error("[Nova] Capture uses declared image dependencies, not raw nested target ids");
409
- const w = new Set(e.dependencies.map((a) => a.id));
410
- for (const a of j(g)) {
411
- if (this._host.assets._resolveRenderTexture(a, !1)?.targetId === e.targetId)
412
- throw new Error("[Nova] Active render texture feedback");
413
- const v = typeof a == "string" ? a : k(a) ? a.id : void 0;
414
- if (v !== void 0 && !w.has(v))
415
- throw new Error(`[Nova] Undeclared image dependency: ${v}`);
416
- }
417
- if (e.dependencies.map((a) => this._host.assets._imageDependency(a)).some((a, y) => !a.ready || a.key !== r[y]) || g.viewport.width !== e.width || g.viewport.height !== e.height || g.viewport.dpr !== e.dpr)
418
- throw new Error("[Nova] Render texture inputs changed during capture; retry explicitly");
419
- let m;
420
- const T = [...g.commands].flatMap((a) => (a.meshBatch && (m ??= []).push(a.meshBatch), a.composition?.effects ?? [])), R = () => {
421
- !this._destroying && this._host.alive() && e.mode === "on-dirty" && e.status !== "error" && e.status !== "destroyed" && (e.invalidation++, e.status = "unready", e.dirty = !0, this._publish(e), this._host.requestFlush());
422
- };
423
- let x = M(T, R);
424
- if (m) {
425
- const a = x;
426
- let y;
427
- try {
428
- y = L(m, R);
429
- } catch (v) {
430
- throw a?.(), v;
431
- }
432
- x = () => {
433
- a?.(), y();
434
- };
435
- }
436
- e.unsubscribeEffects?.(), e.unsubscribeEffects = x;
437
- const f = Object.freeze({ id: e.targetId, width: e.width, height: e.height, dpr: e.dpr, pixelWidth: e.pixelWidth, pixelHeight: e.pixelHeight, kind: "texture" }), B = e.invalidation, E = e.generation, W = !e.allocated || e.allocatedDpr !== f.dpr || e.allocatedPixelWidth !== f.pixelWidth || e.allocatedPixelHeight !== f.pixelHeight;
438
- if (W && e.allocated && this._releaseBacking(e), e.allocated = f.pixelWidth * f.pixelHeight * 4, e.allocatedDpr = f.dpr, e.allocatedPixelWidth = f.pixelWidth, e.allocatedPixelHeight = f.pixelHeight, this._host.draw(g, f), !this._host.alive() || this._destroying)
439
- return;
440
- if (!this._host.available())
441
- throw new Error("[Nova] Context lost during render texture capture");
442
- const b = e.dependencies.map((a) => this._host.assets._imageDependency(a)), C = e.width === f.width && e.height === f.height && e.dpr === f.dpr && e.pixelWidth === f.pixelWidth && e.pixelHeight === f.pixelHeight, F = (!e.source || h === e.invalidation) && e.invalidation === B && e.generation === E && C && b.every((a, y) => a.ready && a.key === r[y]);
443
- if (W && e.generation === E && e.generation++, e.dependencyKeys = r, e.revision++, F)
444
- e.status = "ready", e.dirty = !1, e.waiting = !1, e.error = void 0;
445
- else if (!e.error) {
446
- if (b.some((a) => !a.ready && !a.pending))
447
- throw new Error("[Nova] Image dependency failed during capture");
448
- e.status = "unready", e.waiting = b.some((a) => !a.ready), e.dirty = !e.waiting;
449
- }
450
- this._publish(e), e.dirty && this._host.requestFlush();
451
- } catch (s) {
452
- if (!this._states.has(e.image) || (this._host.available() ? this._error(e, s) : (this._lost = !0, e.invalidation++, e.status = "unready", e.dirty = !0, e.error = void 0, this._publish(e)), !this._host.alive() || !this._states.has(e.image)))
453
- throw s;
454
- try {
455
- this._releaseBacking(e);
456
- } catch {
457
- }
458
- throw s;
459
- }
460
- }
461
- }
462
- } finally {
463
- this._capturing = !1, this._syncLease();
464
- }
465
- }
466
- }
467
- _finishDestroy(e) {
468
- e.unregister?.(), e.unregister = void 0, e.unsubscribeEffects?.(), e.unsubscribeEffects = void 0;
469
- for (const t of e.dependencies)
470
- this._states.get(t)?.dependents.delete(e);
471
- e.dependencies = [], e.draw = void 0, e.source?.destroy(), e.source = void 0, e.dependents.clear(), e.reserved = 0, e.allocated = 0, e.status = "destroyed", e.error = void 0, e.dirty = !1, e.waiting = !1, this._states.delete(e.image), this._host.unpin(e.targetId), this._publish(e);
472
- }
473
- _destroy(e) {
474
- if (e.status !== "destroyed") {
475
- if (this._destroying || this._assertMutable(e), e.dependents.size)
476
- throw new Error("[Nova] Render texture is pinned by a declared dependency");
477
- try {
478
- this._releaseBacking(e);
479
- } catch (t) {
480
- throw this._error(e, t), this._syncLease(), t;
481
- }
482
- try {
483
- this._finishDestroy(e);
484
- } finally {
485
- this._syncLease();
486
- }
487
- }
488
- }
489
- destroy() {
490
- this._destroying = !0, this._syncLease();
491
- const e = [];
492
- for (const t of this._order().reverse())
493
- try {
494
- this._destroy(t);
495
- } catch (r) {
496
- e.push(r);
497
- }
498
- if (e.length)
499
- throw new AggregateError(e, "[Nova] Render texture cleanup failed");
500
- }
501
- backendDestroyed() {
502
- for (const e of [...this._states.values()].reverse())
503
- this._finishDestroy(e);
504
- this._syncLease();
505
- }
506
- }
507
- function J(_, e) {
508
- return _._useRenderTextures((t) => new H(t)).create(e);
509
- }
510
- function Q(_, e) {
511
- if (!e.origin || !Number.isFinite(e.origin.x) || !Number.isFinite(e.origin.y))
512
- throw new TypeError("[Nova] Node capture origin must contain finite world coordinates");
513
- return _._useRenderTextures((t) => new H(t)).create({ ...e, capture() {
514
- } }, { app: _, options: e });
515
- }
516
- function* j(_) {
517
- const e = function* (t) {
518
- t && (t.type === "icon" && (yield t.icon), t.type === "nine-slice-image" && (yield t.image), t.styles?.background && typeof t.styles.background != "string" && (yield t.styles.background));
519
- };
520
- for (const t of _.items)
521
- yield* e(t.schemaItem);
522
- for (const t of _.commands) {
523
- for (const r of t.composition?.effects ?? P)
524
- yield* D(r);
525
- for (const r of t.schemaItems ?? [])
526
- yield* e(r);
527
- if (t.composition?.mask && (yield t.composition.mask.image), t.iconBatch)
528
- for (let r = 0; r < t.iconBatch.count; r++)
529
- yield t.iconBatch.icons[r];
530
- if (t.stripeBatch)
531
- for (let r = 0; r < t.stripeBatch.count; r++)
532
- yield t.stripeBatch.fills[r];
533
- t.meshBatch && (yield t.meshBatch.image), t.particleBatch?.texture && (yield t.particleBatch.texture);
534
- }
535
- }
1
+ import { c as a, a as t } from "../NovaRenderTexture-Desjl5-m.js";
536
2
  export {
537
- Q as createNodeRenderTexture,
538
- J as createRenderTexture
3
+ a as createNodeRenderTexture,
4
+ t as createRenderTexture
539
5
  };
package/dist/2d.js CHANGED
@@ -1,6 +1,6 @@
1
- import { D as o, a as s, N as t, b as r, R as n, S as N, c as v, d as i, e as c, f as d, g as l, h as p, i as S, j as m, k as R, m as u, n as C, r as A, l as T, o as h, p as E, q as g, s as P, t as y, u as f, v as M } from "./NovaNode-CBZ-Ol-W.js";
2
- import { A as b, C as _, a as x, E as D, G as O, N as B, b as V, c as G, d as L, e as k, f as F, g as H, h as j, i as z, j as q, k as K, l as Y, m as U, n as W, o as w, p as J, q as Q, r as X, s as Z, t as $, u as aa, v as ea, w as oa, x as sa, y as ta, z as ra, B as na, D as Na, F as va, H as ia, I as ca, J as da, J as la, K as pa, L as Sa, M as ma, O as Ra, P as ua, Q as Ca, R as Aa, S as Ta, T as ha, U as Ea, V as ga, W as Pa, X as ya, Y as fa, Z as Ma, _ as Ia, $ as ba, a0 as _a, a1 as xa, a2 as Da, a3 as Oa, a4 as Ba, a5 as Va, a6 as Ga, a7 as La, a8 as ka, a9 as Fa, aa as Ha, ab as ja, ac as za, ad as qa, ae as Ka, af as Ya, ag as Ua, ah as Wa, ai as wa, aj as Ja, ak as Qa, al as Xa, am as Za, an as $a, ao as ae, ap as ee, aq as oe, ar as se, as as te, at as re, au as ne, av as Ne, aw as ve, ax as ie, ay as ce, az as de, aA as le, aB as pe, aC as Se, aD as me, aE as Re, aF as ue, aG as Ce, aH as Ae, aI as Te, aJ as he, aK as Ee, aL as ge, aM as Pe, aN as ye, aO as fe, aP as Me, aQ as Ie, aR as be, aS as _e, aT as xe, aU as De, aV as Oe, aW as Be, aX as Ve, aY as Ge, aZ as Le, a_ as ke, a$ as Fe, b0 as He, b1 as je, b2 as ze, b3 as qe, b4 as Ke, b5 as Ye, b6 as Ue, b7 as We, b8 as we } from "./NovaTextSelectionService-Bdi0AqZ5.js";
3
- import { N as Qe, R as Xe, c as Ze, a as $e, b as ao, d as eo, e as oo, f as so, g as to, h as ro, i as no, j as No, k as vo, l as io, m as co, n as lo, o as po, r as So, p as mo, s as Ro, q as uo } from "./NovaRenderCommandWriter-CWQRa42y.js";
1
+ import { D as o, a as s, N as t, b as r, R as n, S as N, c as v, d as i, e as c, f as d, g as l, h as p, i as S, j as m, k as R, m as u, n as C, r as A, l as T, o as h, p as E, q as g, s as P, t as y, u as f, v as M } from "./NovaNode-CshmSV9Y.js";
2
+ import { A as b, C as _, a as x, E as D, G as O, N as B, b as V, c as G, d as L, e as k, f as F, g as H, h as j, i as z, j as q, k as K, l as Y, m as U, n as W, o as w, p as J, q as Q, r as X, s as Z, t as $, u as aa, v as ea, w as oa, x as sa, y as ta, z as ra, B as na, D as Na, F as va, H as ia, I as ca, J as da, J as la, K as pa, L as Sa, M as ma, O as Ra, P as ua, Q as Ca, R as Aa, S as Ta, T as ha, U as Ea, V as ga, W as Pa, X as ya, Y as fa, Z as Ma, _ as Ia, $ as ba, a0 as _a, a1 as xa, a2 as Da, a3 as Oa, a4 as Ba, a5 as Va, a6 as Ga, a7 as La, a8 as ka, a9 as Fa, aa as Ha, ab as ja, ac as za, ad as qa, ae as Ka, af as Ya, ag as Ua, ah as Wa, ai as wa, aj as Ja, ak as Qa, al as Xa, am as Za, an as $a, ao as ae, ap as ee, aq as oe, ar as se, as as te, at as re, au as ne, av as Ne, aw as ve, ax as ie, ay as ce, az as de, aA as le, aB as pe, aC as Se, aD as me, aE as Re, aF as ue, aG as Ce, aH as Ae, aI as Te, aJ as he, aK as Ee, aL as ge, aM as Pe, aN as ye, aO as fe, aP as Me, aQ as Ie, aR as be, aS as _e, aT as xe, aU as De, aV as Oe, aW as Be, aX as Ve, aY as Ge, aZ as Le, a_ as ke, a$ as Fe, b0 as He, b1 as je, b2 as ze, b3 as qe, b4 as Ke, b5 as Ye, b6 as Ue, b7 as We, b8 as we } from "./NovaTextSelectionService-CWJKn7TW.js";
3
+ import { N as Qe, R as Xe, c as Ze, a as $e, b as ao, d as eo, e as oo, f as so, g as to, h as ro, i as no, j as No, k as vo, l as io, m as co, n as lo, o as po, r as So, p as mo, s as Ro, q as uo } from "./NovaRenderCommandWriter-DeHyKjke.js";
4
4
  import { b as Ao, a as To, c as ho, d as Eo, e as go, p as Po, f as yo, s as fo, t as Mo, u as Io } from "./nova-color-parser-BCN_rFRN.js";
5
5
  import { N as _o, a as xo, c as Do, b as Oo, d as Bo, e as Vo, f as Go, g as Lo, h as ko, i as Fo, j as Ho, k as jo, l as zo, m as qo, n as Ko, o as Yo, r as Uo } from "./NovaAssetRegistry-p2QlCwvT.js";
6
6
  import { RaphSchedulerType as wo } from "@raphy-js/raph/runtime";