@neta-art/cohub-cli 10.17.1 → 10.19.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.
Files changed (77) hide show
  1. package/README.md +6 -0
  2. package/dist/board-export-resources.d.ts +2 -0
  3. package/dist/board-export-resources.js +1 -0
  4. package/dist/board-export.d.ts +11 -2
  5. package/dist/board-export.js +181 -62
  6. package/dist/board-gpu/index.d.ts +32 -0
  7. package/dist/board-gpu/index.js +188 -0
  8. package/dist/board-gpu/page.js +70384 -0
  9. package/dist/board-gpu/protocol.d.ts +38 -0
  10. package/dist/board-gpu/protocol.js +1 -0
  11. package/dist/board-kernel/{getPo2TextureFromSource.js → FilterPipe.js} +251 -1
  12. package/dist/board-kernel/browserAll.js +1 -1
  13. package/dist/board-kernel/init.js +1 -251
  14. package/dist/board-kernel/webworkerAll.js +1 -1
  15. package/dist/board-kernel.d.ts +3 -3
  16. package/dist/board-kernel.js +6501 -414
  17. package/dist/board-media-export.d.ts +16 -0
  18. package/dist/board-media-export.js +147 -0
  19. package/dist/board-media.d.ts +2 -1
  20. package/dist/board-media.js +23 -0
  21. package/dist/board-simulate.d.ts +4 -0
  22. package/dist/board-simulate.js +34 -4
  23. package/dist/client.d.ts +1 -0
  24. package/dist/client.js +4 -1
  25. package/dist/commands/apps.js +25 -3
  26. package/dist/commands/boards/authoring.js +45 -3
  27. package/dist/commands/boards/examples.js +21 -5
  28. package/dist/commands/boards.js +10 -2
  29. package/dist/commands/space-displays.d.ts +1 -1
  30. package/dist/commands/space-displays.js +356 -85
  31. package/dist/commands/spaces.js +11 -2
  32. package/dist/host/runtime.d.ts +12 -2
  33. package/dist/host/runtime.js +155 -10
  34. package/dist/host/serve.js +49 -11
  35. package/dist/host/workspaces.d.ts +2 -0
  36. package/dist/host/workspaces.js +18 -0
  37. package/dist/index.js +1 -0
  38. package/dist/output.d.ts +1 -0
  39. package/dist/output.js +3 -0
  40. package/dist/runtime/cli-path.d.ts +5 -0
  41. package/dist/runtime/cli-path.js +27 -0
  42. package/dist/runtime/connection.d.ts +22 -4
  43. package/dist/runtime/connection.js +13 -3
  44. package/dist/runtime/harnesses/claude-approval.d.ts +31 -0
  45. package/dist/runtime/harnesses/claude-approval.js +119 -0
  46. package/dist/runtime/harnesses/claude.js +42 -3
  47. package/dist/runtime/harnesses/codex-approval.d.ts +25 -0
  48. package/dist/runtime/harnesses/codex-approval.js +69 -0
  49. package/dist/runtime/harnesses/codex.js +36 -5
  50. package/dist/runtime/harnesses/index.js +12 -3
  51. package/dist/runtime/harnesses/stream-json.d.ts +16 -2
  52. package/dist/runtime/harnesses/stream-json.js +26 -6
  53. package/dist/runtime/harnesses/types.d.ts +3 -1
  54. package/dist/runtime/instance.d.ts +1 -0
  55. package/dist/runtime/instance.js +1 -0
  56. package/dist/runtime/launch.js +2 -4
  57. package/dist/runtime/local-workspace.d.ts +15 -0
  58. package/dist/runtime/local-workspace.js +52 -0
  59. package/dist/runtime/model-catalog.js +7 -4
  60. package/dist/runtime/native/approvals.d.ts +18 -0
  61. package/dist/runtime/native/approvals.js +54 -0
  62. package/dist/runtime/native/codex-link.d.ts +7 -0
  63. package/dist/runtime/native/codex-link.js +40 -5
  64. package/dist/runtime/native/daemon.d.ts +5 -1
  65. package/dist/runtime/native/daemon.js +6 -1
  66. package/dist/runtime/native/execution.d.ts +2 -0
  67. package/dist/runtime/preferences.d.ts +7 -0
  68. package/dist/runtime/preferences.js +22 -0
  69. package/dist/runtime/presentation.d.ts +3 -0
  70. package/dist/runtime/presentation.js +2 -1
  71. package/dist/runtime/supervisor.js +92 -9
  72. package/dist/safe-remote-image.d.ts +4 -0
  73. package/dist/safe-remote-image.js +8 -0
  74. package/dist/space-files/transfer.js +3 -2
  75. package/dist/space-files/upload.d.ts +5 -2
  76. package/dist/space-files/upload.js +41 -1
  77. package/package.json +2 -2
@@ -0,0 +1,38 @@
1
+ import type { BoardDocument } from "@neta-art/cohub";
2
+ import type { BoardScriptParameter, BoardShader } from "@neta-art/cohub/board";
3
+ import type { BoardExportRegion, BoardThemeId } from "@neta-art/cohub/board";
4
+ import type { BoardExportWarning } from "@neta-art/cohub/board/export";
5
+ export type BoardGpuInit = {
6
+ document: BoardDocument;
7
+ animation: string | null;
8
+ theme: BoardThemeId;
9
+ };
10
+ export type BoardGpuFrame = {
11
+ time: number | null;
12
+ region: BoardExportRegion;
13
+ camera?: {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ scale: number;
18
+ padding?: number;
19
+ background: "paper" | "transparent";
20
+ format: "png" | "jpeg" | "webp";
21
+ quality?: number;
22
+ withImages: boolean;
23
+ imageMemory: number;
24
+ assetKeys?: Record<string, string>;
25
+ };
26
+ export type BoardGpuResult = {
27
+ data: string;
28
+ width: number;
29
+ height: number;
30
+ scale: number;
31
+ itemCount: number;
32
+ warnings: BoardExportWarning[];
33
+ };
34
+ export type BoardGpuShader = {
35
+ id: string;
36
+ shader: BoardShader;
37
+ parameters?: Record<string, BoardScriptParameter>;
38
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -13116,6 +13116,24 @@ var CanvasPoolClass = class {
13116
13116
  const CanvasPool = new CanvasPoolClass();
13117
13117
  GlobalResourceRegistry.register(CanvasPool);
13118
13118
  //#endregion
13119
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/scene/container/bounds/getRenderableBounds.mjs
13120
+ const tempProjectionMatrix = new Matrix();
13121
+ function getGlobalRenderableBounds(renderables, bounds) {
13122
+ bounds.clear();
13123
+ const actualMatrix = bounds.matrix;
13124
+ for (let i = 0; i < renderables.length; i++) {
13125
+ const renderable = renderables[i];
13126
+ if (renderable.globalDisplayStatus < 7) continue;
13127
+ const renderGroup = renderable.renderGroup ?? renderable.parentRenderGroup;
13128
+ if (renderGroup?.isCachedAsTexture) bounds.matrix = tempProjectionMatrix.copyFrom(renderGroup.textureOffsetInverseTransform).append(renderable.worldTransform);
13129
+ else if (renderGroup?._parentCacheAsTextureRenderGroup) bounds.matrix = tempProjectionMatrix.copyFrom(renderGroup._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(renderable.groupTransform);
13130
+ else bounds.matrix = renderable.worldTransform;
13131
+ bounds.addBounds(renderable.bounds);
13132
+ }
13133
+ bounds.matrix = actualMatrix;
13134
+ return bounds;
13135
+ }
13136
+ //#endregion
13119
13137
  //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/scene/text/utils/getPo2TextureFromSource.mjs
13120
13138
  const tempBounds = new Bounds();
13121
13139
  function getPo2TextureFromSource(image, width, height, resolution, autoGenerateMipmaps = false) {
@@ -13135,4 +13153,236 @@ function getPo2TextureFromSource(image, width, height, resolution, autoGenerateM
13135
13153
  return texture;
13136
13154
  }
13137
13155
  //#endregion
13138
- export { groupD8 as $, bgr2rgb as A, Bounds as B, Sprite as C, TexturePool as D, RenderGroup as E, removeItems as F, TextureStyle as G, Texture as H, BigPool as I, deprecation as J, definedProps as K, GlobalResourceRegistry as L, multiplyHexColors as M, getGlobalBounds as N, InstructionSet as O, FilterEffect as P, Rectangle as Q, warn as R, DOMAdapter as S, Container as T, TextureMatrix as U, updateQuadBounds as V, TextureSource as W, v8_3_4 as X, v8_0_0 as Y, uid as Z, Cache as _, Geometry as a, extensions as at, ImageSource as b, Filter as c, RendererType as d, Matrix as et, BindGroup as f, getTestContext as g, GlProgram as h, canUseNewCanvasBlendModes as i, ExtensionType as it, multiplyColors as j, getLocalBounds as k, State as l, GpuProgram as m, CanvasPool as n, eventemitter3_default as nt, Buffer$1 as o, __commonJSMin as ot, UniformGroup as p, nextPow2 as q, canvasUtils as r, ObservablePoint as rt, BufferUsage as s, __toESM as st, getPo2TextureFromSource as t, Point as tt, Shader as u, Ticker as v, ViewContainer as w, CanvasSource as x, UPDATE_PRIORITY as y, Color as z };
13156
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/CanvasFilterSystem.mjs
13157
+ function isCanvasFilterCapable(filter) {
13158
+ return typeof filter.getCanvasFilterString === "function";
13159
+ }
13160
+ var CanvasFilterFrame = class {
13161
+ constructor() {
13162
+ this.skip = false;
13163
+ this.useClip = false;
13164
+ this.filters = null;
13165
+ this.container = null;
13166
+ this.bounds = new Bounds();
13167
+ this.cssFilterString = "";
13168
+ }
13169
+ };
13170
+ var CanvasFilterSystem = class {
13171
+ /**
13172
+ * @param renderer - The Canvas renderer
13173
+ * @param renderer.canvasContext
13174
+ * @param renderer.canvasContext.activeContext
13175
+ * @param renderer.canvasContext.activeResolution
13176
+ */
13177
+ constructor(renderer) {
13178
+ this._filterStack = [];
13179
+ this._filterStackIndex = 0;
13180
+ this._savedStates = [];
13181
+ this._alphaMultiplier = 1;
13182
+ this._warnedFilterTypes = /* @__PURE__ */ new Set();
13183
+ this.renderer = renderer;
13184
+ }
13185
+ /**
13186
+ * Push a filter instruction onto the stack.
13187
+ * Called when entering a filtered container.
13188
+ * @param instruction - The filter instruction from FilterPipe
13189
+ */
13190
+ push(instruction) {
13191
+ const filterFrame = this._pushFilterFrame();
13192
+ const filters = instruction.filterEffect.filters;
13193
+ filterFrame.skip = false;
13194
+ filterFrame.useClip = false;
13195
+ filterFrame.filters = filters;
13196
+ filterFrame.container = instruction.container;
13197
+ filterFrame.cssFilterString = "";
13198
+ if (filters.every((filter) => !filter.enabled)) {
13199
+ filterFrame.skip = true;
13200
+ return;
13201
+ }
13202
+ const cssFilters = [];
13203
+ for (const filter of filters) {
13204
+ if (!filter.enabled) continue;
13205
+ if (!isCanvasFilterCapable(filter)) {
13206
+ this._warnUnsupportedFilter(filter);
13207
+ continue;
13208
+ }
13209
+ const cssString = filter.getCanvasFilterString();
13210
+ if (cssString === null) {
13211
+ this._warnUnsupportedFilter(filter);
13212
+ continue;
13213
+ }
13214
+ if (cssString) cssFilters.push(cssString);
13215
+ }
13216
+ if (cssFilters.length === 0 && true) {
13217
+ filterFrame.skip = true;
13218
+ return;
13219
+ }
13220
+ filterFrame.cssFilterString = cssFilters.join(" ");
13221
+ this._calculateFilterArea(instruction, filterFrame.bounds);
13222
+ filterFrame.useClip = !!instruction.filterEffect.filterArea;
13223
+ const context = this.renderer.canvasContext.activeContext;
13224
+ const previousFilter = context.filter || "none";
13225
+ this._savedStates.push({
13226
+ filter: previousFilter,
13227
+ alphaMultiplier: this._alphaMultiplier
13228
+ });
13229
+ if (filterFrame.useClip && Number.isFinite(filterFrame.bounds.width) && Number.isFinite(filterFrame.bounds.height) && filterFrame.bounds.width > 0 && filterFrame.bounds.height > 0) {
13230
+ const resolution = this.renderer.canvasContext.activeResolution || 1;
13231
+ context.save();
13232
+ context.setTransform(1, 0, 0, 1, 0, 0);
13233
+ context.beginPath();
13234
+ context.rect(filterFrame.bounds.x * resolution, filterFrame.bounds.y * resolution, filterFrame.bounds.width * resolution, filterFrame.bounds.height * resolution);
13235
+ context.clip();
13236
+ } else filterFrame.useClip = false;
13237
+ if (filterFrame.cssFilterString) context.filter = previousFilter !== "none" ? `${previousFilter} ${filterFrame.cssFilterString}` : filterFrame.cssFilterString;
13238
+ }
13239
+ /** Pop a filter from the stack. Called when exiting a filtered container. */
13240
+ pop() {
13241
+ const filterFrame = this._popFilterFrame();
13242
+ if (filterFrame.skip) return;
13243
+ const savedState = this._savedStates.pop();
13244
+ if (!savedState) return;
13245
+ const context = this.renderer.canvasContext.activeContext;
13246
+ if (filterFrame.useClip) context.restore();
13247
+ else context.filter = savedState.filter;
13248
+ this._alphaMultiplier = savedState.alphaMultiplier;
13249
+ }
13250
+ /**
13251
+ * Applies supported filters to a texture and returns a new texture.
13252
+ * Unsupported filters are skipped with a warn-once message.
13253
+ * @param params - The parameters for applying filters.
13254
+ * @param params.texture
13255
+ * @param params.filters
13256
+ * @returns The resulting texture after filters are applied.
13257
+ */
13258
+ generateFilteredTexture({ texture, filters }) {
13259
+ if (!filters?.length || filters.every((filter) => !filter.enabled)) return texture;
13260
+ const cssFilters = [];
13261
+ for (const filter of filters) {
13262
+ if (!filter.enabled) continue;
13263
+ if (!isCanvasFilterCapable(filter)) {
13264
+ this._warnUnsupportedFilter(filter);
13265
+ continue;
13266
+ }
13267
+ const cssString = filter.getCanvasFilterString();
13268
+ if (cssString === null) {
13269
+ this._warnUnsupportedFilter(filter);
13270
+ continue;
13271
+ }
13272
+ if (cssString) cssFilters.push(cssString);
13273
+ }
13274
+ if (cssFilters.length === 0 && true) return texture;
13275
+ const source = canvasUtils.getCanvasSource(texture);
13276
+ if (!source) return texture;
13277
+ const frame = texture.frame;
13278
+ const resolution = texture.source._resolution ?? texture.source.resolution ?? 1;
13279
+ const width = frame.width;
13280
+ const height = frame.height;
13281
+ const { canvas, context } = CanvasPool.getOptimalCanvasAndContext(width, height, resolution);
13282
+ context.setTransform(1, 0, 0, 1, 0, 0);
13283
+ context.clearRect(0, 0, canvas.width, canvas.height);
13284
+ if (cssFilters.length) context.filter = cssFilters.join(" ");
13285
+ const sx = frame.x * resolution;
13286
+ const sy = frame.y * resolution;
13287
+ const sw = width * resolution;
13288
+ const sh = height * resolution;
13289
+ context.drawImage(source, sx, sy, sw, sh, 0, 0, sw, sh);
13290
+ context.filter = "none";
13291
+ context.globalAlpha = 1;
13292
+ return getPo2TextureFromSource(canvas, width, height, resolution);
13293
+ }
13294
+ /**
13295
+ * Calculate the filter area bounds.
13296
+ * @param instruction - Filter instruction
13297
+ * @param bounds - Bounds object to populate
13298
+ */
13299
+ _calculateFilterArea(instruction, bounds) {
13300
+ if (instruction.renderables) getGlobalRenderableBounds(instruction.renderables, bounds);
13301
+ else if (instruction.filterEffect.filterArea) {
13302
+ bounds.clear();
13303
+ bounds.addRect(instruction.filterEffect.filterArea);
13304
+ bounds.applyMatrix(instruction.container.worldTransform);
13305
+ } else instruction.container.getFastGlobalBounds(true, bounds);
13306
+ if (instruction.container) {
13307
+ const filterFrameTransform = (instruction.container.renderGroup || instruction.container.parentRenderGroup)?.cacheToLocalTransform;
13308
+ if (filterFrameTransform) bounds.applyMatrix(filterFrameTransform);
13309
+ }
13310
+ }
13311
+ _warnUnsupportedFilter(filter) {
13312
+ const filterName = filter?.constructor?.name || "Filter";
13313
+ if (this._warnedFilterTypes.has(filterName)) return;
13314
+ this._warnedFilterTypes.add(filterName);
13315
+ console.warn(`CanvasRenderer: filter "${filterName}" is not supported in Canvas2D and will be skipped.`);
13316
+ }
13317
+ get alphaMultiplier() {
13318
+ return this._alphaMultiplier;
13319
+ }
13320
+ _pushFilterFrame() {
13321
+ let filterFrame = this._filterStack[this._filterStackIndex];
13322
+ if (!filterFrame) filterFrame = this._filterStack[this._filterStackIndex] = new CanvasFilterFrame();
13323
+ this._filterStackIndex++;
13324
+ return filterFrame;
13325
+ }
13326
+ _popFilterFrame() {
13327
+ if (this._filterStackIndex <= 0) return this._filterStack[0];
13328
+ this._filterStackIndex--;
13329
+ return this._filterStack[this._filterStackIndex];
13330
+ }
13331
+ /** Destroys the system */
13332
+ destroy() {
13333
+ this._filterStack = null;
13334
+ this._savedStates = null;
13335
+ this._warnedFilterTypes = null;
13336
+ this._alphaMultiplier = 1;
13337
+ }
13338
+ };
13339
+ /** @ignore */
13340
+ CanvasFilterSystem.extension = {
13341
+ type: [ExtensionType.CanvasSystem],
13342
+ name: "filter"
13343
+ };
13344
+ //#endregion
13345
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/defaults/defaultFilter.vert.mjs
13346
+ var vertex = "in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n";
13347
+ //#endregion
13348
+ //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/FilterPipe.mjs
13349
+ var FilterPipe = class {
13350
+ constructor(renderer) {
13351
+ this._renderer = renderer;
13352
+ }
13353
+ push(filterEffect, container, instructionSet) {
13354
+ this._renderer.renderPipes.batch.break(instructionSet);
13355
+ instructionSet.add({
13356
+ renderPipeId: "filter",
13357
+ canBundle: false,
13358
+ action: "pushFilter",
13359
+ container,
13360
+ filterEffect
13361
+ });
13362
+ }
13363
+ pop(_filterEffect, _container, instructionSet) {
13364
+ this._renderer.renderPipes.batch.break(instructionSet);
13365
+ instructionSet.add({
13366
+ renderPipeId: "filter",
13367
+ action: "popFilter",
13368
+ canBundle: false
13369
+ });
13370
+ }
13371
+ execute(instruction) {
13372
+ if (instruction.action === "pushFilter") this._renderer.filter.push(instruction);
13373
+ else if (instruction.action === "popFilter") this._renderer.filter.pop();
13374
+ }
13375
+ destroy() {
13376
+ this._renderer = null;
13377
+ }
13378
+ };
13379
+ FilterPipe.extension = {
13380
+ type: [
13381
+ ExtensionType.WebGLPipes,
13382
+ ExtensionType.WebGPUPipes,
13383
+ ExtensionType.CanvasPipes
13384
+ ],
13385
+ name: "filter"
13386
+ };
13387
+ //#endregion
13388
+ export { nextPow2 as $, Container as A, FilterEffect as B, Ticker as C, DOMAdapter as D, CanvasSource as E, getLocalBounds as F, Color as G, BigPool as H, bgr2rgb as I, Texture as J, Bounds as K, multiplyColors as L, RenderGroup as M, TexturePool as N, Sprite as O, InstructionSet as P, definedProps as Q, multiplyHexColors as R, Cache as S, ImageSource as T, GlobalResourceRegistry as U, removeItems as V, warn as W, TextureSource as X, TextureMatrix as Y, TextureStyle as Z, UniformGroup as _, getGlobalRenderableBounds as a, groupD8 as at, GlProgram as b, canUseNewCanvasBlendModes as c, eventemitter3_default as ct, BufferUsage as d, extensions as dt, deprecation as et, Filter as f, __commonJSMin as ft, BindGroup as g, RendererType as h, getPo2TextureFromSource as i, Rectangle as it, assignWithIgnore as j, ViewContainer as k, Geometry as l, ObservablePoint as lt, Shader as m, vertex as n, v8_3_4 as nt, CanvasPool as o, Matrix as ot, State as p, __toESM as pt, updateQuadBounds as q, CanvasFilterSystem as r, uid as rt, canvasUtils as s, Point as st, FilterPipe as t, v8_0_0 as tt, Buffer$1 as u, ExtensionType as ut, GpuProgram as v, UPDATE_PRIORITY as w, getTestContext as x, getAttributeInfoFromFormat as y, getGlobalBounds as z };
@@ -1,4 +1,4 @@
1
- import { F as removeItems, R as warn, T as Container, at as extensions, it as ExtensionType, nt as eventemitter3_default, ot as __commonJSMin, st as __toESM, tt as Point, v as Ticker, y as UPDATE_PRIORITY } from "./getPo2TextureFromSource.js";
1
+ import { A as Container, C as Ticker, V as removeItems, W as warn, ct as eventemitter3_default, dt as extensions, ft as __commonJSMin, pt as __toESM, st as Point, ut as ExtensionType, w as UPDATE_PRIORITY } from "./FilterPipe.js";
2
2
  import "./init.js";
3
3
  //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/dom/CanvasObserver.mjs
4
4
  var CanvasObserver = class {
@@ -1,214 +1,4 @@
1
- import { B as Bounds, D as TexturePool, H as Texture, R as warn, a as Geometry, at as extensions, c as Filter, d as RendererType, et as Matrix, f as BindGroup, h as GlProgram, it as ExtensionType, m as GpuProgram, n as CanvasPool, p as UniformGroup, r as canvasUtils, t as getPo2TextureFromSource } from "./getPo2TextureFromSource.js";
2
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/scene/container/bounds/getRenderableBounds.mjs
3
- const tempProjectionMatrix = new Matrix();
4
- function getGlobalRenderableBounds(renderables, bounds) {
5
- bounds.clear();
6
- const actualMatrix = bounds.matrix;
7
- for (let i = 0; i < renderables.length; i++) {
8
- const renderable = renderables[i];
9
- if (renderable.globalDisplayStatus < 7) continue;
10
- const renderGroup = renderable.renderGroup ?? renderable.parentRenderGroup;
11
- if (renderGroup?.isCachedAsTexture) bounds.matrix = tempProjectionMatrix.copyFrom(renderGroup.textureOffsetInverseTransform).append(renderable.worldTransform);
12
- else if (renderGroup?._parentCacheAsTextureRenderGroup) bounds.matrix = tempProjectionMatrix.copyFrom(renderGroup._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(renderable.groupTransform);
13
- else bounds.matrix = renderable.worldTransform;
14
- bounds.addBounds(renderable.bounds);
15
- }
16
- bounds.matrix = actualMatrix;
17
- return bounds;
18
- }
19
- //#endregion
20
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/CanvasFilterSystem.mjs
21
- function isCanvasFilterCapable(filter) {
22
- return typeof filter.getCanvasFilterString === "function";
23
- }
24
- var CanvasFilterFrame = class {
25
- constructor() {
26
- this.skip = false;
27
- this.useClip = false;
28
- this.filters = null;
29
- this.container = null;
30
- this.bounds = new Bounds();
31
- this.cssFilterString = "";
32
- }
33
- };
34
- var CanvasFilterSystem = class {
35
- /**
36
- * @param renderer - The Canvas renderer
37
- * @param renderer.canvasContext
38
- * @param renderer.canvasContext.activeContext
39
- * @param renderer.canvasContext.activeResolution
40
- */
41
- constructor(renderer) {
42
- this._filterStack = [];
43
- this._filterStackIndex = 0;
44
- this._savedStates = [];
45
- this._alphaMultiplier = 1;
46
- this._warnedFilterTypes = /* @__PURE__ */ new Set();
47
- this.renderer = renderer;
48
- }
49
- /**
50
- * Push a filter instruction onto the stack.
51
- * Called when entering a filtered container.
52
- * @param instruction - The filter instruction from FilterPipe
53
- */
54
- push(instruction) {
55
- const filterFrame = this._pushFilterFrame();
56
- const filters = instruction.filterEffect.filters;
57
- filterFrame.skip = false;
58
- filterFrame.useClip = false;
59
- filterFrame.filters = filters;
60
- filterFrame.container = instruction.container;
61
- filterFrame.cssFilterString = "";
62
- if (filters.every((filter) => !filter.enabled)) {
63
- filterFrame.skip = true;
64
- return;
65
- }
66
- const cssFilters = [];
67
- for (const filter of filters) {
68
- if (!filter.enabled) continue;
69
- if (!isCanvasFilterCapable(filter)) {
70
- this._warnUnsupportedFilter(filter);
71
- continue;
72
- }
73
- const cssString = filter.getCanvasFilterString();
74
- if (cssString === null) {
75
- this._warnUnsupportedFilter(filter);
76
- continue;
77
- }
78
- if (cssString) cssFilters.push(cssString);
79
- }
80
- if (cssFilters.length === 0 && true) {
81
- filterFrame.skip = true;
82
- return;
83
- }
84
- filterFrame.cssFilterString = cssFilters.join(" ");
85
- this._calculateFilterArea(instruction, filterFrame.bounds);
86
- filterFrame.useClip = !!instruction.filterEffect.filterArea;
87
- const context = this.renderer.canvasContext.activeContext;
88
- const previousFilter = context.filter || "none";
89
- this._savedStates.push({
90
- filter: previousFilter,
91
- alphaMultiplier: this._alphaMultiplier
92
- });
93
- if (filterFrame.useClip && Number.isFinite(filterFrame.bounds.width) && Number.isFinite(filterFrame.bounds.height) && filterFrame.bounds.width > 0 && filterFrame.bounds.height > 0) {
94
- const resolution = this.renderer.canvasContext.activeResolution || 1;
95
- context.save();
96
- context.setTransform(1, 0, 0, 1, 0, 0);
97
- context.beginPath();
98
- context.rect(filterFrame.bounds.x * resolution, filterFrame.bounds.y * resolution, filterFrame.bounds.width * resolution, filterFrame.bounds.height * resolution);
99
- context.clip();
100
- } else filterFrame.useClip = false;
101
- if (filterFrame.cssFilterString) context.filter = previousFilter !== "none" ? `${previousFilter} ${filterFrame.cssFilterString}` : filterFrame.cssFilterString;
102
- }
103
- /** Pop a filter from the stack. Called when exiting a filtered container. */
104
- pop() {
105
- const filterFrame = this._popFilterFrame();
106
- if (filterFrame.skip) return;
107
- const savedState = this._savedStates.pop();
108
- if (!savedState) return;
109
- const context = this.renderer.canvasContext.activeContext;
110
- if (filterFrame.useClip) context.restore();
111
- else context.filter = savedState.filter;
112
- this._alphaMultiplier = savedState.alphaMultiplier;
113
- }
114
- /**
115
- * Applies supported filters to a texture and returns a new texture.
116
- * Unsupported filters are skipped with a warn-once message.
117
- * @param params - The parameters for applying filters.
118
- * @param params.texture
119
- * @param params.filters
120
- * @returns The resulting texture after filters are applied.
121
- */
122
- generateFilteredTexture({ texture, filters }) {
123
- if (!filters?.length || filters.every((filter) => !filter.enabled)) return texture;
124
- const cssFilters = [];
125
- for (const filter of filters) {
126
- if (!filter.enabled) continue;
127
- if (!isCanvasFilterCapable(filter)) {
128
- this._warnUnsupportedFilter(filter);
129
- continue;
130
- }
131
- const cssString = filter.getCanvasFilterString();
132
- if (cssString === null) {
133
- this._warnUnsupportedFilter(filter);
134
- continue;
135
- }
136
- if (cssString) cssFilters.push(cssString);
137
- }
138
- if (cssFilters.length === 0 && true) return texture;
139
- const source = canvasUtils.getCanvasSource(texture);
140
- if (!source) return texture;
141
- const frame = texture.frame;
142
- const resolution = texture.source._resolution ?? texture.source.resolution ?? 1;
143
- const width = frame.width;
144
- const height = frame.height;
145
- const { canvas, context } = CanvasPool.getOptimalCanvasAndContext(width, height, resolution);
146
- context.setTransform(1, 0, 0, 1, 0, 0);
147
- context.clearRect(0, 0, canvas.width, canvas.height);
148
- if (cssFilters.length) context.filter = cssFilters.join(" ");
149
- const sx = frame.x * resolution;
150
- const sy = frame.y * resolution;
151
- const sw = width * resolution;
152
- const sh = height * resolution;
153
- context.drawImage(source, sx, sy, sw, sh, 0, 0, sw, sh);
154
- context.filter = "none";
155
- context.globalAlpha = 1;
156
- return getPo2TextureFromSource(canvas, width, height, resolution);
157
- }
158
- /**
159
- * Calculate the filter area bounds.
160
- * @param instruction - Filter instruction
161
- * @param bounds - Bounds object to populate
162
- */
163
- _calculateFilterArea(instruction, bounds) {
164
- if (instruction.renderables) getGlobalRenderableBounds(instruction.renderables, bounds);
165
- else if (instruction.filterEffect.filterArea) {
166
- bounds.clear();
167
- bounds.addRect(instruction.filterEffect.filterArea);
168
- bounds.applyMatrix(instruction.container.worldTransform);
169
- } else instruction.container.getFastGlobalBounds(true, bounds);
170
- if (instruction.container) {
171
- const filterFrameTransform = (instruction.container.renderGroup || instruction.container.parentRenderGroup)?.cacheToLocalTransform;
172
- if (filterFrameTransform) bounds.applyMatrix(filterFrameTransform);
173
- }
174
- }
175
- _warnUnsupportedFilter(filter) {
176
- const filterName = filter?.constructor?.name || "Filter";
177
- if (this._warnedFilterTypes.has(filterName)) return;
178
- this._warnedFilterTypes.add(filterName);
179
- console.warn(`CanvasRenderer: filter "${filterName}" is not supported in Canvas2D and will be skipped.`);
180
- }
181
- get alphaMultiplier() {
182
- return this._alphaMultiplier;
183
- }
184
- _pushFilterFrame() {
185
- let filterFrame = this._filterStack[this._filterStackIndex];
186
- if (!filterFrame) filterFrame = this._filterStack[this._filterStackIndex] = new CanvasFilterFrame();
187
- this._filterStackIndex++;
188
- return filterFrame;
189
- }
190
- _popFilterFrame() {
191
- if (this._filterStackIndex <= 0) return this._filterStack[0];
192
- this._filterStackIndex--;
193
- return this._filterStack[this._filterStackIndex];
194
- }
195
- /** Destroys the system */
196
- destroy() {
197
- this._filterStack = null;
198
- this._savedStates = null;
199
- this._warnedFilterTypes = null;
200
- this._alphaMultiplier = 1;
201
- }
202
- };
203
- /** @ignore */
204
- CanvasFilterSystem.extension = {
205
- type: [ExtensionType.CanvasSystem],
206
- name: "filter"
207
- };
208
- //#endregion
209
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/defaults/defaultFilter.vert.mjs
210
- var vertex = "in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n";
211
- //#endregion
1
+ import { J as Texture, K as Bounds, N as TexturePool, W as warn, _ as UniformGroup, a as getGlobalRenderableBounds, b as GlProgram, dt as extensions, f as Filter, g as BindGroup, h as RendererType, l as Geometry, n as vertex, ot as Matrix, r as CanvasFilterSystem, t as FilterPipe, ut as ExtensionType, v as GpuProgram } from "./FilterPipe.js";
212
2
  //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/defaults/passthrough/passthrough.frag.mjs
213
3
  var fragment = "in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n";
214
4
  //#endregion
@@ -241,46 +31,6 @@ var PassthroughFilter = class extends Filter {
241
31
  }
242
32
  };
243
33
  //#endregion
244
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/FilterPipe.mjs
245
- var FilterPipe = class {
246
- constructor(renderer) {
247
- this._renderer = renderer;
248
- }
249
- push(filterEffect, container, instructionSet) {
250
- this._renderer.renderPipes.batch.break(instructionSet);
251
- instructionSet.add({
252
- renderPipeId: "filter",
253
- canBundle: false,
254
- action: "pushFilter",
255
- container,
256
- filterEffect
257
- });
258
- }
259
- pop(_filterEffect, _container, instructionSet) {
260
- this._renderer.renderPipes.batch.break(instructionSet);
261
- instructionSet.add({
262
- renderPipeId: "filter",
263
- action: "popFilter",
264
- canBundle: false
265
- });
266
- }
267
- execute(instruction) {
268
- if (instruction.action === "pushFilter") this._renderer.filter.push(instruction);
269
- else if (instruction.action === "popFilter") this._renderer.filter.pop();
270
- }
271
- destroy() {
272
- this._renderer = null;
273
- }
274
- };
275
- FilterPipe.extension = {
276
- type: [
277
- ExtensionType.WebGLPipes,
278
- ExtensionType.WebGPUPipes,
279
- ExtensionType.CanvasPipes
280
- ],
281
- name: "filter"
282
- };
283
- //#endregion
284
34
  //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/FilterSystem.mjs
285
35
  const quadGeometry = new Geometry({
286
36
  attributes: { aPosition: {
@@ -1,3 +1,3 @@
1
- import "./getPo2TextureFromSource.js";
1
+ import "./FilterPipe.js";
2
2
  import "./init.js";
3
3
  export {};
@@ -1,5 +1,5 @@
1
- export { BOARD_SCRIPT_DRAWING_EXAMPLE, hasBoardScripts, boardAssetKey, boardAssetKeySource, boardDocumentAt, boardFrameRegions, boardRegionStep, createBoardAnimationSampler, boardSequence, boardSequencePatch, boardPathTrack, boardTextureEdge, boardTexturePixels, buildBoardScene, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "@neta-art/cohub/board";
2
- export { prepareBoardExport } from "@neta-art/cohub/board/export";
3
- export { boardRenderTheme, createBoardRenderSampler, inspectBoardScene, inspectBoardItems, measureBoardText } from "@neta-art/cohub/board/render";
1
+ export { BOARD_SCRIPT_DRAWING_EXAMPLE, BOARD_SCRIPT_RAIN_EXAMPLE, hasBoardScripts, boardAssetKey, boardAssetKeySource, boardMediaRate, boardMediaSpans, boardTimedMedia, boardScriptAttachments, boardShaderParameters, boardFrameRegions, boardRegionStep, createBoardAnimationSampler, boardSequence, boardSequencePatch, boardPathTrack, boardPlacePatch, boardTextureEdge, boardTexturePixels, buildBoardScene, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "@neta-art/cohub/board";
2
+ export { describeBoardExportWarning, prepareBoardExport } from "@neta-art/cohub/board/export";
3
+ export { boardRenderTheme, checkBoardShader, createBoardRenderSampler, inspectBoardScene, inspectBoardItems, measureBoardText } from "@neta-art/cohub/board/render";
4
4
  export { createNodeBoardRenderer, createNodeBoardScriptHost, exportBoardImageBytes } from "@neta-art/cohub/board/export/node";
5
5
  export { createBoardScriptHarness } from "@neta-art/cohub/board/testing";