@neta-art/cohub-cli 10.20.0 → 10.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/about.d.ts +2 -0
- package/dist/about.js +71 -0
- package/dist/board-export.d.ts +2 -0
- package/dist/board-export.js +37 -9
- package/dist/board-gpu/daemon.js +3 -10
- package/dist/board-gpu/index.js +1 -1
- package/dist/board-gpu/page.js +668 -188
- package/dist/board-gpu/protocol.d.ts +14 -0
- package/dist/board-kernel.d.ts +2 -2
- package/dist/board-kernel.js +832 -188
- package/dist/board-media-export.d.ts +1 -0
- package/dist/board-media-export.js +17 -0
- package/dist/board-profile.d.ts +3 -1
- package/dist/board-profile.js +14 -0
- package/dist/board-simulate.d.ts +9 -2
- package/dist/board-simulate.js +93 -35
- package/dist/build.json +1 -0
- package/dist/commands/boards.js +77 -7
- package/dist/commands/feedback.js +2 -0
- package/dist/commands/version.d.ts +2 -0
- package/dist/commands/version.js +21 -0
- package/dist/host/serve.js +9 -3
- package/dist/index.js +4 -11
- package/dist/runtime/connection.js +2 -0
- package/dist/runtime/harnesses/claude-approval.d.ts +4 -1
- package/dist/runtime/harnesses/claude-approval.js +8 -3
- package/dist/runtime/harnesses/claude.js +20 -11
- package/dist/runtime/presentation.d.ts +1 -0
- package/dist/runtime/presentation.js +1 -0
- package/dist/runtime/supervisor.js +2 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.js +17 -0
- package/package.json +9 -3
package/dist/board-kernel.js
CHANGED
|
@@ -5912,6 +5912,7 @@ const itemEnvelope$1 = {
|
|
|
5912
5912
|
visible: boolean().optional().describe("false hides the item and its children; key it on a timeline to show the item only for a span."),
|
|
5913
5913
|
style: BoardStyleSchema$1.default({}),
|
|
5914
5914
|
locked: boolean().optional(),
|
|
5915
|
+
autoplay: boolean().optional().describe("true shows live content as the Board opens: an app runs, a video loops muted, a 3D model renders. Ignored for other items and for a video whose props.time follows a timeline."),
|
|
5915
5916
|
metadata: record(string(), unknown()).optional()
|
|
5916
5917
|
};
|
|
5917
5918
|
const boxed$1 = (size) => ({
|
|
@@ -7127,6 +7128,7 @@ const NOT_ANIMATABLE = /* @__PURE__ */ new Set([
|
|
|
7127
7128
|
"parent",
|
|
7128
7129
|
"z",
|
|
7129
7130
|
"locked",
|
|
7131
|
+
"autoplay",
|
|
7130
7132
|
"metadata",
|
|
7131
7133
|
"script"
|
|
7132
7134
|
]);
|
|
@@ -7965,6 +7967,159 @@ function isBoardRootScript(document, id) {
|
|
|
7965
7967
|
return Boolean(document.board?.scripts && Object.hasOwn(document.board.scripts, id));
|
|
7966
7968
|
}
|
|
7967
7969
|
//#endregion
|
|
7970
|
+
//#region ../sdk/src/board/model/json.ts
|
|
7971
|
+
function sameJson(a, b) {
|
|
7972
|
+
if (a === b) return true;
|
|
7973
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
7974
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
7975
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
7976
|
+
for (let index = 0; index < a.length; index += 1) if (!sameJson(a[index], b[index])) return false;
|
|
7977
|
+
return true;
|
|
7978
|
+
}
|
|
7979
|
+
const left = a;
|
|
7980
|
+
const right = b;
|
|
7981
|
+
let members = 0;
|
|
7982
|
+
for (const key of Object.keys(left)) {
|
|
7983
|
+
if (left[key] === void 0) continue;
|
|
7984
|
+
members += 1;
|
|
7985
|
+
if (!sameJson(left[key], right[key])) return false;
|
|
7986
|
+
}
|
|
7987
|
+
for (const key of Object.keys(right)) if (right[key] !== void 0) members -= 1;
|
|
7988
|
+
return members === 0;
|
|
7989
|
+
}
|
|
7990
|
+
//#endregion
|
|
7991
|
+
//#region ../sdk/src/board/model/script-scope.ts
|
|
7992
|
+
const childrenByItems = /* @__PURE__ */ new WeakMap();
|
|
7993
|
+
const everyItem = /* @__PURE__ */ new WeakMap();
|
|
7994
|
+
function childIndex(items) {
|
|
7995
|
+
let index = childrenByItems.get(items);
|
|
7996
|
+
if (!index) {
|
|
7997
|
+
index = /* @__PURE__ */ new Map();
|
|
7998
|
+
for (const [id, item] of Object.entries(items)) {
|
|
7999
|
+
if (!item.parent) continue;
|
|
8000
|
+
const siblings = index.get(item.parent);
|
|
8001
|
+
if (siblings) siblings.push(id);
|
|
8002
|
+
else index.set(item.parent, [id]);
|
|
8003
|
+
}
|
|
8004
|
+
childrenByItems.set(items, index);
|
|
8005
|
+
}
|
|
8006
|
+
return index;
|
|
8007
|
+
}
|
|
8008
|
+
function boardScriptOf(document, id) {
|
|
8009
|
+
return isBoardRootScript(document, id) ? document.board?.scripts?.[id] : document.items[id]?.script;
|
|
8010
|
+
}
|
|
8011
|
+
function boardScriptScope(document, id) {
|
|
8012
|
+
if (isBoardRootScript(document, id)) {
|
|
8013
|
+
let all = everyItem.get(document.items);
|
|
8014
|
+
if (!all) {
|
|
8015
|
+
all = new Set(Object.keys(document.items));
|
|
8016
|
+
everyItem.set(document.items, all);
|
|
8017
|
+
}
|
|
8018
|
+
return all;
|
|
8019
|
+
}
|
|
8020
|
+
const item = document.items[id];
|
|
8021
|
+
const scope = /* @__PURE__ */ new Set([id]);
|
|
8022
|
+
for (const target of Object.values(item?.script?.targets ?? {})) if (document.items[target]) scope.add(target);
|
|
8023
|
+
if (item?.type !== "frame") return scope;
|
|
8024
|
+
const children = childIndex(document.items);
|
|
8025
|
+
const visited = /* @__PURE__ */ new Set([id]);
|
|
8026
|
+
const queue = [id];
|
|
8027
|
+
for (let depth = 0; queue.length && depth < 64; depth++) for (const parent of queue.splice(0)) for (const child of children.get(parent) ?? []) {
|
|
8028
|
+
if (visited.has(child)) continue;
|
|
8029
|
+
visited.add(child);
|
|
8030
|
+
scope.add(child);
|
|
8031
|
+
queue.push(child);
|
|
8032
|
+
}
|
|
8033
|
+
return scope;
|
|
8034
|
+
}
|
|
8035
|
+
function diffBoardScriptItems(copy, document, scope, note) {
|
|
8036
|
+
const changes = {};
|
|
8037
|
+
let changed = false;
|
|
8038
|
+
for (const id of scope) {
|
|
8039
|
+
const item = document.items[id];
|
|
8040
|
+
const previous = copy.get(id);
|
|
8041
|
+
if (!item || previous === item) continue;
|
|
8042
|
+
copy.set(id, item);
|
|
8043
|
+
if (previous && sameJson(previous, item)) continue;
|
|
8044
|
+
changes[id] = item;
|
|
8045
|
+
changed = true;
|
|
8046
|
+
note?.(id, previous ? "changed" : "added");
|
|
8047
|
+
}
|
|
8048
|
+
if (copy.size > scope.size) for (const id of copy.keys()) {
|
|
8049
|
+
if (scope.has(id)) continue;
|
|
8050
|
+
copy.delete(id);
|
|
8051
|
+
changes[id] = null;
|
|
8052
|
+
changed = true;
|
|
8053
|
+
note?.(id, "removed");
|
|
8054
|
+
}
|
|
8055
|
+
return changed ? changes : null;
|
|
8056
|
+
}
|
|
8057
|
+
function supersedes(pending, event) {
|
|
8058
|
+
if (pending.type !== event.type) return false;
|
|
8059
|
+
if (event.type === "viewchange" || event.type === "selectionchange") return true;
|
|
8060
|
+
if (event.type === "pointermove") return pending.pointerId === event.pointerId;
|
|
8061
|
+
if (event.type !== "gesture") return false;
|
|
8062
|
+
const a = pending.data;
|
|
8063
|
+
const b = event.data;
|
|
8064
|
+
return a.id === b.id && a.phase === "update" && b.phase === "update";
|
|
8065
|
+
}
|
|
8066
|
+
function boardScriptListens(output, event) {
|
|
8067
|
+
return !output || event.type === "viewchange" || output.listens.includes(event.type);
|
|
8068
|
+
}
|
|
8069
|
+
function queueBoardScriptEvent(queue, event) {
|
|
8070
|
+
let queued = queue.length - 1;
|
|
8071
|
+
while (queued >= 0 && !supersedes(queue[queued], event)) queued--;
|
|
8072
|
+
if (queued >= 0 && (event.type !== "pointermove" || queued === queue.length - 1)) queue.splice(queued, 1);
|
|
8073
|
+
if (queue.length >= 128) return false;
|
|
8074
|
+
queue.push(event);
|
|
8075
|
+
return true;
|
|
8076
|
+
}
|
|
8077
|
+
function boardScriptEmit(document, sender, input) {
|
|
8078
|
+
const message = input;
|
|
8079
|
+
if (!message || typeof message.target !== "string" || typeof message.type !== "string" || !message.type) throw new Error("emit() takes a target id and an event type.");
|
|
8080
|
+
const { target, type } = message;
|
|
8081
|
+
if (!isBoardRootScript(document, target) && !boardScriptScope(document, sender).has(target)) throw new Error(`emit() from ${sender} cannot reach ${target}: it is neither in scope nor a Board script.`);
|
|
8082
|
+
const depth = typeof message.depth === "number" && Number.isSafeInteger(message.depth) && message.depth > 0 ? message.depth : 1;
|
|
8083
|
+
if (depth > 16) throw new Error(`emit(${target}, "${type}") from ${sender} is ${depth} handlers deep, past the limit of 16: handlers keep answering each other. Emit from onFrame() to send it on the next step.`);
|
|
8084
|
+
return {
|
|
8085
|
+
target,
|
|
8086
|
+
event: {
|
|
8087
|
+
type,
|
|
8088
|
+
data: message.data,
|
|
8089
|
+
depth
|
|
8090
|
+
}
|
|
8091
|
+
};
|
|
8092
|
+
}
|
|
8093
|
+
function createBoardScriptOutbox(order) {
|
|
8094
|
+
let queued = [];
|
|
8095
|
+
let seq = 0;
|
|
8096
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
8097
|
+
return {
|
|
8098
|
+
get size() {
|
|
8099
|
+
return queued.length;
|
|
8100
|
+
},
|
|
8101
|
+
push(sender, target, event) {
|
|
8102
|
+
const count = waiting.get(target) ?? 0;
|
|
8103
|
+
if (count >= 128) throw new Error(`emit(${target}, "${event.type}") from ${sender}: ${target} already has 128 events waiting.`);
|
|
8104
|
+
waiting.set(target, count + 1);
|
|
8105
|
+
queued.push({
|
|
8106
|
+
rank: order().get(sender) ?? Number.MAX_SAFE_INTEGER,
|
|
8107
|
+
seq: seq++,
|
|
8108
|
+
target,
|
|
8109
|
+
event
|
|
8110
|
+
});
|
|
8111
|
+
},
|
|
8112
|
+
take() {
|
|
8113
|
+
const batch = queued.sort((a, b) => a.rank - b.rank || a.seq - b.seq);
|
|
8114
|
+
queued = [];
|
|
8115
|
+
waiting.clear();
|
|
8116
|
+
const byTarget = /* @__PURE__ */ new Map();
|
|
8117
|
+
for (const { target, event } of batch) byTarget.set(target, [...byTarget.get(target) ?? [], event]);
|
|
8118
|
+
return byTarget;
|
|
8119
|
+
}
|
|
8120
|
+
};
|
|
8121
|
+
}
|
|
8122
|
+
//#endregion
|
|
7968
8123
|
//#region ../sdk/src/board/model/geometry.ts
|
|
7969
8124
|
function screenPoint(x, y) {
|
|
7970
8125
|
return {
|
|
@@ -8407,100 +8562,13 @@ function visibleWorldRect(viewport, surfaceWidth, surfaceHeight) {
|
|
|
8407
8562
|
};
|
|
8408
8563
|
}
|
|
8409
8564
|
//#endregion
|
|
8410
|
-
//#region ../sdk/src/board/model/json.ts
|
|
8411
|
-
function sameJson(a, b) {
|
|
8412
|
-
if (a === b) return true;
|
|
8413
|
-
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
8414
|
-
if (Array.isArray(a) || Array.isArray(b)) {
|
|
8415
|
-
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
8416
|
-
for (let index = 0; index < a.length; index += 1) if (!sameJson(a[index], b[index])) return false;
|
|
8417
|
-
return true;
|
|
8418
|
-
}
|
|
8419
|
-
const left = a;
|
|
8420
|
-
const right = b;
|
|
8421
|
-
let members = 0;
|
|
8422
|
-
for (const key of Object.keys(left)) {
|
|
8423
|
-
if (left[key] === void 0) continue;
|
|
8424
|
-
members += 1;
|
|
8425
|
-
if (!sameJson(left[key], right[key])) return false;
|
|
8426
|
-
}
|
|
8427
|
-
for (const key of Object.keys(right)) if (right[key] !== void 0) members -= 1;
|
|
8428
|
-
return members === 0;
|
|
8429
|
-
}
|
|
8430
|
-
//#endregion
|
|
8431
|
-
//#region ../sdk/src/board/model/script-scope.ts
|
|
8432
|
-
const childrenByItems = /* @__PURE__ */ new WeakMap();
|
|
8433
|
-
const everyItem = /* @__PURE__ */ new WeakMap();
|
|
8434
|
-
function childIndex(items) {
|
|
8435
|
-
let index = childrenByItems.get(items);
|
|
8436
|
-
if (!index) {
|
|
8437
|
-
index = /* @__PURE__ */ new Map();
|
|
8438
|
-
for (const [id, item] of Object.entries(items)) {
|
|
8439
|
-
if (!item.parent) continue;
|
|
8440
|
-
const siblings = index.get(item.parent);
|
|
8441
|
-
if (siblings) siblings.push(id);
|
|
8442
|
-
else index.set(item.parent, [id]);
|
|
8443
|
-
}
|
|
8444
|
-
childrenByItems.set(items, index);
|
|
8445
|
-
}
|
|
8446
|
-
return index;
|
|
8447
|
-
}
|
|
8448
|
-
function boardScriptOf(document, id) {
|
|
8449
|
-
return isBoardRootScript(document, id) ? document.board?.scripts?.[id] : document.items[id]?.script;
|
|
8450
|
-
}
|
|
8451
|
-
function boardScriptScope(document, id) {
|
|
8452
|
-
if (isBoardRootScript(document, id)) {
|
|
8453
|
-
let all = everyItem.get(document.items);
|
|
8454
|
-
if (!all) {
|
|
8455
|
-
all = new Set(Object.keys(document.items));
|
|
8456
|
-
everyItem.set(document.items, all);
|
|
8457
|
-
}
|
|
8458
|
-
return all;
|
|
8459
|
-
}
|
|
8460
|
-
const item = document.items[id];
|
|
8461
|
-
const scope = /* @__PURE__ */ new Set([id]);
|
|
8462
|
-
for (const target of Object.values(item?.script?.targets ?? {})) if (document.items[target]) scope.add(target);
|
|
8463
|
-
if (item?.type !== "frame") return scope;
|
|
8464
|
-
const children = childIndex(document.items);
|
|
8465
|
-
const visited = /* @__PURE__ */ new Set([id]);
|
|
8466
|
-
const queue = [id];
|
|
8467
|
-
for (let depth = 0; queue.length && depth < 64; depth++) for (const parent of queue.splice(0)) for (const child of children.get(parent) ?? []) {
|
|
8468
|
-
if (visited.has(child)) continue;
|
|
8469
|
-
visited.add(child);
|
|
8470
|
-
scope.add(child);
|
|
8471
|
-
queue.push(child);
|
|
8472
|
-
}
|
|
8473
|
-
return scope;
|
|
8474
|
-
}
|
|
8475
|
-
function diffBoardScriptItems(copy, document, scope, note) {
|
|
8476
|
-
const changes = {};
|
|
8477
|
-
let changed = false;
|
|
8478
|
-
for (const id of scope) {
|
|
8479
|
-
const item = document.items[id];
|
|
8480
|
-
const previous = copy.get(id);
|
|
8481
|
-
if (!item || previous === item) continue;
|
|
8482
|
-
copy.set(id, item);
|
|
8483
|
-
if (previous && sameJson(previous, item)) continue;
|
|
8484
|
-
changes[id] = item;
|
|
8485
|
-
changed = true;
|
|
8486
|
-
note?.(id, previous ? "changed" : "added");
|
|
8487
|
-
}
|
|
8488
|
-
if (copy.size > scope.size) for (const id of copy.keys()) {
|
|
8489
|
-
if (scope.has(id)) continue;
|
|
8490
|
-
copy.delete(id);
|
|
8491
|
-
changes[id] = null;
|
|
8492
|
-
changed = true;
|
|
8493
|
-
note?.(id, "removed");
|
|
8494
|
-
}
|
|
8495
|
-
return changed ? changes : null;
|
|
8496
|
-
}
|
|
8497
|
-
//#endregion
|
|
8498
8565
|
//#region ../sdk/src/board/model/shader.ts
|
|
8499
8566
|
const BOARD_SHADER_LIMITS = {
|
|
8500
|
-
passes:
|
|
8567
|
+
passes: 16,
|
|
8501
8568
|
source: 65536,
|
|
8502
8569
|
sprites: 65536,
|
|
8503
8570
|
stateEdge: 1024,
|
|
8571
|
+
texel: 1024,
|
|
8504
8572
|
uniformSlots: 128
|
|
8505
8573
|
};
|
|
8506
8574
|
const COMPONENTS = {
|
|
@@ -8575,6 +8643,10 @@ function validateBoardShader(shader) {
|
|
|
8575
8643
|
if (!Number.isSafeInteger(pass.sprites) || pass.sprites < 1 || pass.sprites > BOARD_SHADER_LIMITS.sprites) throw new Error(`sprites must be an integer from 1 to ${BOARD_SHADER_LIMITS.sprites}.`);
|
|
8576
8644
|
if (boardShaderPassLayer(value, pass) === "filter") throw new Error("Filter passes draw over the owner's box; they cannot draw sprites.");
|
|
8577
8645
|
}
|
|
8646
|
+
if (pass.texel !== void 0) {
|
|
8647
|
+
if (typeof pass.texel !== "number" || !(pass.texel > 0 && pass.texel <= BOARD_SHADER_LIMITS.texel)) throw new Error(`texel must be a number above 0 and up to ${BOARD_SHADER_LIMITS.texel}.`);
|
|
8648
|
+
if (pass.sprites !== void 0 || boardShaderPassLayer(value, pass) === "filter") throw new Error("texel shades a pass over its box; sprite and filter passes cannot take it.");
|
|
8649
|
+
}
|
|
8578
8650
|
if (pass.name !== void 0) {
|
|
8579
8651
|
if (typeof pass.name !== "string" || !IDENTIFIER.test(pass.name)) throw new Error(`Invalid pass name: ${String(pass.name)}`);
|
|
8580
8652
|
if (names.has(pass.name)) throw new Error(`Pass names must be unique: ${pass.name}`);
|
|
@@ -8619,6 +8691,33 @@ function parseBoardItem(value) {
|
|
|
8619
8691
|
if (!parsed.ok) throw new Error(parsed.diagnostics[0]?.message ?? "Invalid script item.");
|
|
8620
8692
|
return parsed.item;
|
|
8621
8693
|
}
|
|
8694
|
+
function presentItem(base, patch) {
|
|
8695
|
+
return presentTransform(base, patch) ?? parseBoardItem(mergePatch(base, patch));
|
|
8696
|
+
}
|
|
8697
|
+
function presentTransform(base, patch) {
|
|
8698
|
+
const next = { ...base };
|
|
8699
|
+
for (const key in patch) {
|
|
8700
|
+
const value = patch[key];
|
|
8701
|
+
if (key === "position") {
|
|
8702
|
+
if (!value || typeof value !== "object") return null;
|
|
8703
|
+
const { x = base.position.x, y = base.position.y, ...rest } = value;
|
|
8704
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return null;
|
|
8705
|
+
for (const _ in rest) return null;
|
|
8706
|
+
next.position = {
|
|
8707
|
+
x,
|
|
8708
|
+
y
|
|
8709
|
+
};
|
|
8710
|
+
continue;
|
|
8711
|
+
}
|
|
8712
|
+
if (key === "rotation" || key === "z") {
|
|
8713
|
+
if (!Number.isFinite(value)) return null;
|
|
8714
|
+
} else if (key === "opacity") {
|
|
8715
|
+
if (typeof value !== "number" || !(value >= 0 && value <= 1)) return null;
|
|
8716
|
+
} else if (key !== "visible" || typeof value !== "boolean") return null;
|
|
8717
|
+
next[key] = value;
|
|
8718
|
+
}
|
|
8719
|
+
return next;
|
|
8720
|
+
}
|
|
8622
8721
|
const DISPLAY_FIELDS = /* @__PURE__ */ new Set([
|
|
8623
8722
|
"position",
|
|
8624
8723
|
"size",
|
|
@@ -8816,7 +8915,7 @@ function prepareBoardScriptOutput(document, owner, output) {
|
|
|
8816
8915
|
const base = document.items[id];
|
|
8817
8916
|
if (base && scope.has(id)) presented.set(id, {
|
|
8818
8917
|
base,
|
|
8819
|
-
item:
|
|
8918
|
+
item: presentItem(base, patch)
|
|
8820
8919
|
});
|
|
8821
8920
|
}
|
|
8822
8921
|
const prefix = scriptTemporaryPrefix(owner);
|
|
@@ -8848,7 +8947,7 @@ function composeBoardScriptItems(document, scene, outputs, incoming = /* @__PURE
|
|
|
8848
8947
|
if (current.base !== base) {
|
|
8849
8948
|
current = {
|
|
8850
8949
|
base,
|
|
8851
|
-
item:
|
|
8950
|
+
item: presentItem(base, output.patches[id] ?? {})
|
|
8852
8951
|
};
|
|
8853
8952
|
prepared.presented.set(id, current);
|
|
8854
8953
|
}
|
|
@@ -11649,9 +11748,10 @@ function resolveRegion(scene, region) {
|
|
|
11649
11748
|
};
|
|
11650
11749
|
const rect = itemBounds(frame.frame);
|
|
11651
11750
|
return {
|
|
11652
|
-
items: scene.items.filter((item) => item.id
|
|
11751
|
+
items: scene.items.filter((item) => item.id === region.id || visible(item, rect)),
|
|
11653
11752
|
rect,
|
|
11654
|
-
padding: 0
|
|
11753
|
+
padding: 0,
|
|
11754
|
+
page: region.id
|
|
11655
11755
|
};
|
|
11656
11756
|
}
|
|
11657
11757
|
case "rect": {
|
|
@@ -11689,7 +11789,8 @@ function planBoardExport(input) {
|
|
|
11689
11789
|
width: Math.max(1, Math.floor(world.width * scale)),
|
|
11690
11790
|
height: Math.max(1, Math.floor(world.height * scale)),
|
|
11691
11791
|
items: resolved.items,
|
|
11692
|
-
clamped: scale < safeRequest - 1e-6
|
|
11792
|
+
clamped: scale < safeRequest - 1e-6,
|
|
11793
|
+
...resolved.page ? { page: resolved.page } : {}
|
|
11693
11794
|
};
|
|
11694
11795
|
}
|
|
11695
11796
|
//#endregion
|
|
@@ -13153,6 +13254,61 @@ function createBoardRegistry(definitions = []) {
|
|
|
13153
13254
|
}
|
|
13154
13255
|
const defaultBoardRegistry = createBoardRegistry();
|
|
13155
13256
|
//#endregion
|
|
13257
|
+
//#region ../sdk/src/board/model/autoplay.ts
|
|
13258
|
+
const text = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
13259
|
+
function boardAppMetadata(item) {
|
|
13260
|
+
if (item?.type !== "frame" || !item.metadata) return null;
|
|
13261
|
+
const value = item.metadata.cohubApp;
|
|
13262
|
+
if (!value || typeof value !== "object") return null;
|
|
13263
|
+
const app = value;
|
|
13264
|
+
const appId = text(app.appId);
|
|
13265
|
+
const ref = text(app.ref);
|
|
13266
|
+
const url = text(app.url);
|
|
13267
|
+
const name = text(app.name);
|
|
13268
|
+
if (!appId || !ref || !url || !name) return null;
|
|
13269
|
+
const icon = text(app.icon);
|
|
13270
|
+
const cover = text(app.cover);
|
|
13271
|
+
const themeColor = text(app.themeColor);
|
|
13272
|
+
return {
|
|
13273
|
+
appId,
|
|
13274
|
+
ref,
|
|
13275
|
+
url,
|
|
13276
|
+
name,
|
|
13277
|
+
...icon ? { icon } : {},
|
|
13278
|
+
...cover ? { cover } : {},
|
|
13279
|
+
...themeColor ? { themeColor } : {}
|
|
13280
|
+
};
|
|
13281
|
+
}
|
|
13282
|
+
function boardAutoplayKind(item) {
|
|
13283
|
+
if (!item) return null;
|
|
13284
|
+
if (item.type === "video") return item.props.time === void 0 ? "video" : null;
|
|
13285
|
+
if (item.type === "task") return boardAutoplayVideo(item) ? "video" : null;
|
|
13286
|
+
if (isBoardModelItem(item)) return "model";
|
|
13287
|
+
return boardAppMetadata(item) ? "app" : null;
|
|
13288
|
+
}
|
|
13289
|
+
function boardAutoplayVideo(item) {
|
|
13290
|
+
if (item.type === "video") return item.props.time === void 0 ? item.props.src : null;
|
|
13291
|
+
if (item.type !== "task" || item.props.snapshot.status !== "completed") return null;
|
|
13292
|
+
const artifact = featuredTaskArtifact(item.props.snapshot.artifacts);
|
|
13293
|
+
return artifact?.type === "video" ? artifact.url : null;
|
|
13294
|
+
}
|
|
13295
|
+
function boardAutoplayLoops(scene, at) {
|
|
13296
|
+
const loops = [];
|
|
13297
|
+
for (const item of scene.items) {
|
|
13298
|
+
const src = item.autoplay ? boardAutoplayVideo(item) : null;
|
|
13299
|
+
if (src) loops.push({
|
|
13300
|
+
id: item.id,
|
|
13301
|
+
kind: "video",
|
|
13302
|
+
src,
|
|
13303
|
+
time: at,
|
|
13304
|
+
volume: 0,
|
|
13305
|
+
shown: scene.shown(item.id),
|
|
13306
|
+
loop: true
|
|
13307
|
+
});
|
|
13308
|
+
}
|
|
13309
|
+
return loops;
|
|
13310
|
+
}
|
|
13311
|
+
//#endregion
|
|
13156
13312
|
//#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/environment-browser/browserExt.mjs
|
|
13157
13313
|
const browserExt = {
|
|
13158
13314
|
extension: {
|
|
@@ -38312,6 +38468,11 @@ function inspectBoardScene(scene, limit = 100, ids) {
|
|
|
38312
38468
|
code: "effect-follow-unused",
|
|
38313
38469
|
item: item.id
|
|
38314
38470
|
});
|
|
38471
|
+
const unfinished = item.type === "task" && (item.props.snapshot.status === "pending" || item.props.snapshot.status === "running");
|
|
38472
|
+
if (item.autoplay && !unfinished && !boardAutoplayKind(item)) push({
|
|
38473
|
+
code: "autoplay-unused",
|
|
38474
|
+
item: item.id
|
|
38475
|
+
});
|
|
38315
38476
|
}
|
|
38316
38477
|
let glyphBudget = 256;
|
|
38317
38478
|
for (const item of texts) {
|
|
@@ -39311,6 +39472,7 @@ function shaderPasses() {
|
|
|
39311
39472
|
return passes;
|
|
39312
39473
|
}
|
|
39313
39474
|
const TEXELS_PER_DEVIATION = 4;
|
|
39475
|
+
const SAMPLED_TEXELS_PER_DEVIATION = 8;
|
|
39314
39476
|
const MAX_HALVINGS = 5;
|
|
39315
39477
|
function gaussian(filters, input, output, deviation, clear, first) {
|
|
39316
39478
|
const { horizontal, vertical, copy } = shaderPasses();
|
|
@@ -39356,6 +39518,7 @@ var BoardBlurFilter = class extends Filter {
|
|
|
39356
39518
|
this.radius = radius;
|
|
39357
39519
|
this.deviation = radius * zoom;
|
|
39358
39520
|
this.padding = Math.ceil(radius * 3 * zoom);
|
|
39521
|
+
this.resolution = this.deviation > SAMPLED_TEXELS_PER_DEVIATION ? SAMPLED_TEXELS_PER_DEVIATION / this.deviation : "inherit";
|
|
39359
39522
|
this.css = `blur(${radius * zoom}px)`;
|
|
39360
39523
|
}
|
|
39361
39524
|
apply(filters, input, output, clearMode) {
|
|
@@ -39644,6 +39807,27 @@ function syncFrameGroup(entry, item, context) {
|
|
|
39644
39807
|
function syncBoardItemEffects(container, item, context) {
|
|
39645
39808
|
syncBoardEffects(container, item.type === "frame" ? void 0 : item.style, context);
|
|
39646
39809
|
}
|
|
39810
|
+
const shaderClips = /* @__PURE__ */ new WeakMap();
|
|
39811
|
+
function clipFrameShaderLayer(layer, item) {
|
|
39812
|
+
const entry = shaderClips.get(layer);
|
|
39813
|
+
if (!isClippingFrame(item)) {
|
|
39814
|
+
if (!entry) return;
|
|
39815
|
+
layer.mask = null;
|
|
39816
|
+
entry.mask.destroy();
|
|
39817
|
+
shaderClips.delete(layer);
|
|
39818
|
+
return;
|
|
39819
|
+
}
|
|
39820
|
+
const { width, height } = item.frame;
|
|
39821
|
+
const sig = `${width},${height}`;
|
|
39822
|
+
if (entry?.sig === sig) return;
|
|
39823
|
+
const mask = entry?.mask ?? layer.addChild(new Graphics());
|
|
39824
|
+
mask.clear().rect(0, 0, width, height).fill(16777215);
|
|
39825
|
+
layer.mask = mask;
|
|
39826
|
+
shaderClips.set(layer, {
|
|
39827
|
+
mask,
|
|
39828
|
+
sig
|
|
39829
|
+
});
|
|
39830
|
+
}
|
|
39647
39831
|
//#endregion
|
|
39648
39832
|
//#region ../sdk/src/board/render/audio-waveform.ts
|
|
39649
39833
|
const DEFAULT_BARS = 44;
|
|
@@ -40376,10 +40560,12 @@ function sync$13(container, item, context) {
|
|
|
40376
40560
|
const failed = Boolean(key && !texture && context.hasError(key));
|
|
40377
40561
|
const detailed = boardCardDetailed(context.zoom);
|
|
40378
40562
|
const elevation = cardElevation(context, item.id);
|
|
40563
|
+
const covered = context.covered?.(item.id) ?? false;
|
|
40379
40564
|
const sig = [
|
|
40380
40565
|
key ?? "",
|
|
40381
40566
|
texture?.uid ?? "none",
|
|
40382
40567
|
failed,
|
|
40568
|
+
covered,
|
|
40383
40569
|
width,
|
|
40384
40570
|
height,
|
|
40385
40571
|
elevation,
|
|
@@ -40400,7 +40586,11 @@ function sync$13(container, item, context) {
|
|
|
40400
40586
|
elevation
|
|
40401
40587
|
});
|
|
40402
40588
|
if (texture && parts.sprite.texture !== texture) parts.sprite.texture = texture;
|
|
40403
|
-
parts.sprite.visible = Boolean(texture);
|
|
40589
|
+
parts.sprite.visible = Boolean(texture) && !covered;
|
|
40590
|
+
if (covered) {
|
|
40591
|
+
parts.chrome.clear();
|
|
40592
|
+
return;
|
|
40593
|
+
}
|
|
40404
40594
|
if (texture) {
|
|
40405
40595
|
const inset = Math.min(width, height) * INSET_RATIO;
|
|
40406
40596
|
const fitted = containRect(width - inset * 2, height - inset * 2, texture.width, texture.height);
|
|
@@ -40509,6 +40699,7 @@ const PLAY_HIT = {
|
|
|
40509
40699
|
cursor: "pointer"
|
|
40510
40700
|
};
|
|
40511
40701
|
function mediaPlayHit(item, point, context) {
|
|
40702
|
+
if (context.covered?.(item.id) || context.mediaTexture?.(item.id)) return null;
|
|
40512
40703
|
const key = context.assetKey(item);
|
|
40513
40704
|
return boardMediaActionAt(item, point, context.zoom, {
|
|
40514
40705
|
materialized: true,
|
|
@@ -41403,9 +41594,12 @@ function sync$8(container, item, context) {
|
|
|
41403
41594
|
const alpha = (style.stroke ? 1 : .55) * itemAlpha(context, style.stroke);
|
|
41404
41595
|
const radius = style.radius ?? 4;
|
|
41405
41596
|
const strokeWidth = style.strokeWidth ?? 1.5;
|
|
41406
|
-
const
|
|
41597
|
+
const page = context.page === item.id;
|
|
41598
|
+
const decorated = props.decoration !== "none" && (!page || style.fill !== void 0);
|
|
41599
|
+
const outlined = decorated && !page;
|
|
41407
41600
|
const visualSig = [
|
|
41408
41601
|
props.decoration,
|
|
41602
|
+
page,
|
|
41409
41603
|
frame.width,
|
|
41410
41604
|
frame.height,
|
|
41411
41605
|
fill,
|
|
@@ -41426,7 +41620,7 @@ function sync$8(container, item, context) {
|
|
|
41426
41620
|
});
|
|
41427
41621
|
const pattern = dashPattern(style.dash, strokeWidth);
|
|
41428
41622
|
const trim = style.trim ?? 1;
|
|
41429
|
-
if (
|
|
41623
|
+
if (outlined && strokeWidth > 0 && trim > 0) {
|
|
41430
41624
|
if (pattern || trim < 1) tracePolyline(parts.box, trimPolyline(roundRectPoints(frame.width, frame.height, radius), trim), pattern);
|
|
41431
41625
|
else parts.box.roundRect(0, 0, frame.width, frame.height, radius);
|
|
41432
41626
|
parts.box.stroke({
|
|
@@ -41438,7 +41632,7 @@ function sync$8(container, item, context) {
|
|
|
41438
41632
|
});
|
|
41439
41633
|
}
|
|
41440
41634
|
}
|
|
41441
|
-
parts.label.visible =
|
|
41635
|
+
parts.label.visible = outlined;
|
|
41442
41636
|
const title = locked ? `🔒 ${props.label}`.trim() : props.label;
|
|
41443
41637
|
const labelColor = style.stroke ? baseStroke : context.palette.muted;
|
|
41444
41638
|
const size = context.style.frameLabelSize;
|
|
@@ -42541,7 +42735,8 @@ function sync$3(container, item, context) {
|
|
|
42541
42735
|
parts.assetKey = key;
|
|
42542
42736
|
if (key) context.acquireTexture(key, item);
|
|
42543
42737
|
}
|
|
42544
|
-
const
|
|
42738
|
+
const live = context.mediaTexture?.(item.id) ?? null;
|
|
42739
|
+
const texture = live ?? (key ? context.getTexture(key) : null);
|
|
42545
42740
|
const previewFailed = Boolean(key && !texture && context.hasError(key));
|
|
42546
42741
|
const artifact = featuredTaskArtifact(snapshot.artifacts);
|
|
42547
42742
|
const kind = previewKindFor(artifact);
|
|
@@ -42649,7 +42844,7 @@ function sync$3(container, item, context) {
|
|
|
42649
42844
|
height: Math.max(1, frame.height - 24 - bottomInset)
|
|
42650
42845
|
}, context.colors.brand.stroke);
|
|
42651
42846
|
}
|
|
42652
|
-
if (full && (artifact?.type === "audio" || artifact?.type === "video" && texture)) drawPlayBadge(parts.previewArt, frame, context);
|
|
42847
|
+
if (full && (artifact?.type === "audio" || artifact?.type === "video" && texture && !live)) drawPlayBadge(parts.previewArt, frame, context);
|
|
42653
42848
|
if (surface) {
|
|
42654
42849
|
const markY = frame.y + frame.height / 2 - (full && label ? 18 : 0);
|
|
42655
42850
|
drawStateMark(parts.previewArt, surface, frame.x + frame.width / 2, markY, surface === "failed" ? color : context.colors.neutral.stroke);
|
|
@@ -43213,7 +43408,7 @@ function sync(container, item, context) {
|
|
|
43213
43408
|
} : context.style);
|
|
43214
43409
|
}
|
|
43215
43410
|
parts.chrome.clear();
|
|
43216
|
-
if (boardCardDetailed(context.zoom) && item.props.time === void 0) drawMediaPlayKey(parts.chrome, screen.x + screen.width / 2, screen.y + screen.height / 2, Math.min(18, Math.min(screen.width, screen.height) * .16), context);
|
|
43411
|
+
if (boardCardDetailed(context.zoom) && !live && item.props.time === void 0) drawMediaPlayKey(parts.chrome, screen.x + screen.width / 2, screen.y + screen.height / 2, Math.min(18, Math.min(screen.width, screen.height) * .16), context);
|
|
43217
43412
|
}
|
|
43218
43413
|
function drawFilmRails(graphics, width, height, rail, hole) {
|
|
43219
43414
|
const size = Math.min(FILM_HOLE, rail * .45);
|
|
@@ -43566,6 +43761,7 @@ const itemEnvelope = {
|
|
|
43566
43761
|
visible: boolean().optional().describe("false hides the item and its children; key it on a timeline to show the item only for a span."),
|
|
43567
43762
|
style: BoardStyleSchema.default({}),
|
|
43568
43763
|
locked: boolean().optional(),
|
|
43764
|
+
autoplay: boolean().optional().describe("true shows live content as the Board opens: an app runs, a video loops muted, a 3D model renders. Ignored for other items and for a video whose props.time follows a timeline."),
|
|
43569
43765
|
metadata: record(string(), unknown()).optional()
|
|
43570
43766
|
};
|
|
43571
43767
|
const boxed = (size) => ({
|
|
@@ -44046,9 +44242,12 @@ function resolveScriptImport(from, specifier) {
|
|
|
44046
44242
|
} else parts.push(part);
|
|
44047
44243
|
}
|
|
44048
44244
|
const path = parts.join("/");
|
|
44049
|
-
if (!isSafeBoardSourcePath(path) || !/\.m?js$/.test(path)) throw new Error(`Invalid module path: ${path}`);
|
|
44245
|
+
if (!isSafeBoardSourcePath(path) || !/\.(m?js|json)$/.test(path)) throw new Error(`Invalid module path: ${path}`);
|
|
44050
44246
|
return path;
|
|
44051
44247
|
}
|
|
44248
|
+
function isBoardScriptJson(path) {
|
|
44249
|
+
return path.endsWith(".json");
|
|
44250
|
+
}
|
|
44052
44251
|
async function loadBoardScriptSources(src, read, timeoutMs = 15e3) {
|
|
44053
44252
|
if (!isSafeBoardSourcePath(src) || !/\.m?js$/.test(src)) throw new Error("Invalid script entry path.");
|
|
44054
44253
|
const { init, parse } = await import("./board-kernel/lexer.js");
|
|
@@ -44068,11 +44267,25 @@ async function loadBoardScriptSources(src, read, timeoutMs = 15e3) {
|
|
|
44068
44267
|
})]).finally(() => clearTimeout(timer));
|
|
44069
44268
|
bytes += new TextEncoder().encode(code).byteLength;
|
|
44070
44269
|
if (bytes > 2e6) throw new Error("Script modules exceed the 2 MB limit.");
|
|
44270
|
+
if (isBoardScriptJson(path)) {
|
|
44271
|
+
try {
|
|
44272
|
+
JSON.parse(code);
|
|
44273
|
+
} catch {
|
|
44274
|
+
throw new Error(`${path} is not valid JSON.`);
|
|
44275
|
+
}
|
|
44276
|
+
sources[path] = {
|
|
44277
|
+
code,
|
|
44278
|
+
imports: []
|
|
44279
|
+
};
|
|
44280
|
+
return;
|
|
44281
|
+
}
|
|
44071
44282
|
const [imports] = parse(code, path);
|
|
44072
44283
|
const resolved = [];
|
|
44073
44284
|
for (const entry of imports) {
|
|
44074
44285
|
if (entry.d === -2) throw new Error("import.meta is not available in Board scripts.");
|
|
44075
44286
|
if (entry.n === void 0) throw new Error("Dynamic imports must use a literal relative path.");
|
|
44287
|
+
const typed = entry.d >= 0 ? entry.a >= 0 && /\btype\s*:\s*["']json["']/.test(code.slice(entry.a, entry.se)) : Boolean(entry.at?.some(([key, value]) => key === "type" && value === "json"));
|
|
44288
|
+
if (typed !== isBoardScriptJson(entry.n)) throw new Error(typed ? `Only .json files import with type "json": ${entry.n}` : `Import ${entry.n} with { type: "json" }.`);
|
|
44076
44289
|
resolved.push({
|
|
44077
44290
|
start: entry.s,
|
|
44078
44291
|
end: entry.e,
|
|
@@ -44122,6 +44335,7 @@ function createScriptRuntime(module, initial, host) {
|
|
|
44122
44335
|
let input = initial;
|
|
44123
44336
|
let disposed = false;
|
|
44124
44337
|
let stepping = false;
|
|
44338
|
+
let depth = 0;
|
|
44125
44339
|
let revision = 0;
|
|
44126
44340
|
let sceneRevision = 0;
|
|
44127
44341
|
let randomState = 2166136261;
|
|
@@ -44197,7 +44411,8 @@ function createScriptRuntime(module, initial, host) {
|
|
|
44197
44411
|
await host.call("board.emit", {
|
|
44198
44412
|
target,
|
|
44199
44413
|
type,
|
|
44200
|
-
data
|
|
44414
|
+
data,
|
|
44415
|
+
depth: depth + 1
|
|
44201
44416
|
});
|
|
44202
44417
|
},
|
|
44203
44418
|
get items() {
|
|
@@ -44280,6 +44495,7 @@ function createScriptRuntime(module, initial, host) {
|
|
|
44280
44495
|
invalidate(false);
|
|
44281
44496
|
},
|
|
44282
44497
|
async commit(patch) {
|
|
44498
|
+
if (input.capabilities && !input.capabilities.includes("board.commit")) throw new Error("This viewer cannot edit the Board.");
|
|
44283
44499
|
return await host.call("board.commit", {
|
|
44284
44500
|
patch,
|
|
44285
44501
|
frame: stepping
|
|
@@ -44367,9 +44583,15 @@ function createScriptRuntime(module, initial, host) {
|
|
|
44367
44583
|
if (event.type === "viewchange") view = event.data;
|
|
44368
44584
|
const listeners = handlers.get(event.type);
|
|
44369
44585
|
if (!listeners?.size) return;
|
|
44370
|
-
|
|
44371
|
-
|
|
44372
|
-
|
|
44586
|
+
const outer = depth;
|
|
44587
|
+
depth = event.depth ?? 0;
|
|
44588
|
+
try {
|
|
44589
|
+
seeded(() => {
|
|
44590
|
+
for (const handler of listeners) handler(event);
|
|
44591
|
+
});
|
|
44592
|
+
} finally {
|
|
44593
|
+
depth = outer;
|
|
44594
|
+
}
|
|
44373
44595
|
invalidate();
|
|
44374
44596
|
},
|
|
44375
44597
|
draw(canvas) {
|
|
@@ -45177,6 +45399,98 @@ function seedOf(value) {
|
|
|
45177
45399
|
function boardShaderSeed(seed) {
|
|
45178
45400
|
return seedOf(seed);
|
|
45179
45401
|
}
|
|
45402
|
+
const TEXEL_GROWTH = 128;
|
|
45403
|
+
function createTexels(drawn, pass) {
|
|
45404
|
+
const root = new Container();
|
|
45405
|
+
root.addChild(new Mesh({
|
|
45406
|
+
geometry: drawn.geometry,
|
|
45407
|
+
shader: drawn.shader
|
|
45408
|
+
}));
|
|
45409
|
+
const sprite = new Sprite({
|
|
45410
|
+
texture: Texture.EMPTY,
|
|
45411
|
+
label: "board-shader-texels"
|
|
45412
|
+
});
|
|
45413
|
+
sprite.blendMode = pass.blend ?? "normal";
|
|
45414
|
+
sprite.visible = false;
|
|
45415
|
+
return {
|
|
45416
|
+
size: pass.texel ?? 1,
|
|
45417
|
+
root,
|
|
45418
|
+
sprite,
|
|
45419
|
+
target: null,
|
|
45420
|
+
rect: null
|
|
45421
|
+
};
|
|
45422
|
+
}
|
|
45423
|
+
function texelRect(frame, size) {
|
|
45424
|
+
const [a, b] = frame.localToGlobal;
|
|
45425
|
+
if (Math.hypot(a, b) * frame.density * Math.min(1, frame.shading ?? 1) * size <= 1) return null;
|
|
45426
|
+
const { region, view } = frame;
|
|
45427
|
+
const left = Math.floor(Math.max(region.x, view.x) / size) * size;
|
|
45428
|
+
const top = Math.floor(Math.max(region.y, view.y) / size) * size;
|
|
45429
|
+
const right = Math.ceil(Math.min(region.x + region.width, view.x + view.width) / size) * size;
|
|
45430
|
+
const bottom = Math.ceil(Math.min(region.y + region.height, view.y + view.height) / size) * size;
|
|
45431
|
+
return right > left && bottom > top ? {
|
|
45432
|
+
x: left,
|
|
45433
|
+
y: top,
|
|
45434
|
+
width: right - left,
|
|
45435
|
+
height: bottom - top
|
|
45436
|
+
} : null;
|
|
45437
|
+
}
|
|
45438
|
+
function drawTexels(renderer, texels, rect) {
|
|
45439
|
+
const width = Math.round(rect.width / texels.size);
|
|
45440
|
+
const height = Math.round(rect.height / texels.size);
|
|
45441
|
+
let target = texels.target;
|
|
45442
|
+
if (!target || target.width < width || target.height < height) {
|
|
45443
|
+
releaseTexels(texels);
|
|
45444
|
+
const grow = (edge) => Math.ceil(edge / TEXEL_GROWTH) * TEXEL_GROWTH;
|
|
45445
|
+
target = RenderTexture.create({
|
|
45446
|
+
width: grow(width),
|
|
45447
|
+
height: grow(height),
|
|
45448
|
+
resolution: 1,
|
|
45449
|
+
scaleMode: "nearest",
|
|
45450
|
+
antialias: false,
|
|
45451
|
+
autoGenerateMipmaps: false
|
|
45452
|
+
});
|
|
45453
|
+
texels.target = target;
|
|
45454
|
+
texels.sprite.texture = new Texture({
|
|
45455
|
+
source: target.source,
|
|
45456
|
+
frame: new Rectangle(0, 0, width, height),
|
|
45457
|
+
dynamic: true
|
|
45458
|
+
});
|
|
45459
|
+
}
|
|
45460
|
+
const texture = texels.sprite.texture;
|
|
45461
|
+
if (texture.frame.width !== width || texture.frame.height !== height) {
|
|
45462
|
+
texture.frame.width = width;
|
|
45463
|
+
texture.frame.height = height;
|
|
45464
|
+
texture.update();
|
|
45465
|
+
}
|
|
45466
|
+
texels.root.scale.set(1 / texels.size);
|
|
45467
|
+
texels.root.position.set(-rect.x / texels.size, -rect.y / texels.size);
|
|
45468
|
+
renderer.render({
|
|
45469
|
+
container: texels.root,
|
|
45470
|
+
target,
|
|
45471
|
+
clear: true,
|
|
45472
|
+
clearColor: [
|
|
45473
|
+
0,
|
|
45474
|
+
0,
|
|
45475
|
+
0,
|
|
45476
|
+
0
|
|
45477
|
+
]
|
|
45478
|
+
});
|
|
45479
|
+
texels.sprite.position.set(rect.x, rect.y);
|
|
45480
|
+
texels.sprite.scale.set(texels.size);
|
|
45481
|
+
}
|
|
45482
|
+
function releaseTexels(texels) {
|
|
45483
|
+
if (!texels.target) return;
|
|
45484
|
+
texels.sprite.texture.destroy();
|
|
45485
|
+
texels.sprite.texture = Texture.EMPTY;
|
|
45486
|
+
texels.target.destroy(true);
|
|
45487
|
+
texels.target = null;
|
|
45488
|
+
}
|
|
45489
|
+
function destroyTexels(texels) {
|
|
45490
|
+
releaseTexels(texels);
|
|
45491
|
+
texels.sprite.destroy();
|
|
45492
|
+
texels.root.destroy({ children: true });
|
|
45493
|
+
}
|
|
45180
45494
|
function createBoardShaderLayer(renderer, shader, parameters, label, options = {}) {
|
|
45181
45495
|
const uniforms = boardShaderUniforms(shader.uniforms);
|
|
45182
45496
|
const surfaces = shader.surfaces === true;
|
|
@@ -45258,12 +45572,15 @@ function createBoardShaderLayer(renderer, shader, parameters, label, options = {
|
|
|
45258
45572
|
const container = containers[layer];
|
|
45259
45573
|
container.boundsArea = area;
|
|
45260
45574
|
container.addChild(drawn.mesh);
|
|
45575
|
+
const texels = pass.texel ? createTexels(drawn, pass) : null;
|
|
45576
|
+
if (texels) container.addChild(texels.sprite);
|
|
45261
45577
|
meshes.push({
|
|
45262
45578
|
...drawn,
|
|
45263
45579
|
pass,
|
|
45264
45580
|
sprites,
|
|
45265
45581
|
placement,
|
|
45266
|
-
scaler: null
|
|
45582
|
+
scaler: null,
|
|
45583
|
+
texels
|
|
45267
45584
|
});
|
|
45268
45585
|
});
|
|
45269
45586
|
let state = null;
|
|
@@ -45474,8 +45791,14 @@ function createBoardShaderLayer(renderer, shader, parameters, label, options = {
|
|
|
45474
45791
|
area.width = frame.region.width;
|
|
45475
45792
|
area.height = frame.region.height;
|
|
45476
45793
|
for (const drawn of meshes) {
|
|
45477
|
-
|
|
45478
|
-
|
|
45794
|
+
const on = boardShaderPassOn(drawn.pass, frame.passes);
|
|
45795
|
+
const texels = drawn.texels;
|
|
45796
|
+
if (texels) {
|
|
45797
|
+
texels.rect = on ? texelRect(frame, texels.size) : null;
|
|
45798
|
+
texels.sprite.visible = texels.rect !== null;
|
|
45799
|
+
}
|
|
45800
|
+
drawn.mesh.visible = on && !texels?.rect;
|
|
45801
|
+
if (drawn.mesh.visible && !drawn.sprites) shade(drawn, frame);
|
|
45479
45802
|
}
|
|
45480
45803
|
for (const { filter, pass } of filters) filter.enabled = boardShaderPassOn(pass, frame.passes);
|
|
45481
45804
|
fill(group, frame, frame.region);
|
|
@@ -45499,6 +45822,7 @@ function createBoardShaderLayer(renderer, shader, parameters, label, options = {
|
|
|
45499
45822
|
ran: 0,
|
|
45500
45823
|
behind: false
|
|
45501
45824
|
};
|
|
45825
|
+
for (const { texels } of meshes) if (texels?.rect) drawTexels(target, texels, texels.rect);
|
|
45502
45826
|
if (placementsStale || stepped.ran) {
|
|
45503
45827
|
for (const { placement, mesh } of meshes) if (placement && mesh.visible) target.render({
|
|
45504
45828
|
container: placement.mesh.mesh,
|
|
@@ -45540,6 +45864,7 @@ function createBoardShaderLayer(renderer, shader, parameters, label, options = {
|
|
|
45540
45864
|
for (const compile of compiles) compile.cancel();
|
|
45541
45865
|
for (const drawn of meshes) {
|
|
45542
45866
|
drawn.scaler?.destroy();
|
|
45867
|
+
if (drawn.texels) destroyTexels(drawn.texels);
|
|
45543
45868
|
destroyBoardShaderMesh(drawn);
|
|
45544
45869
|
if (drawn.placement) destroyPlacement(renderer, drawn.placement);
|
|
45545
45870
|
}
|
|
@@ -46180,6 +46505,7 @@ function buildContext(input) {
|
|
|
46180
46505
|
scene: input.scene,
|
|
46181
46506
|
time: input.time ?? 0,
|
|
46182
46507
|
frameAt: input.frameAt,
|
|
46508
|
+
...input.page ? { page: input.page } : {},
|
|
46183
46509
|
selectedIds: /* @__PURE__ */ new Set(),
|
|
46184
46510
|
hoveredId: null,
|
|
46185
46511
|
resizingIds: /* @__PURE__ */ new Set(),
|
|
@@ -46320,6 +46646,7 @@ function createBoardExportScene(input) {
|
|
|
46320
46646
|
const container = containers.get(owner.id);
|
|
46321
46647
|
if (!item || !container) return null;
|
|
46322
46648
|
const group = isSelfGroupedFrame(item) ? groups.get(item.id)?.group : void 0;
|
|
46649
|
+
for (const part of [layer.below, layer.above]) if (part && item.type === "frame") clipFrameShaderLayer(part, item);
|
|
46323
46650
|
if (layer.below) container.addChildAt(layer.below, 0);
|
|
46324
46651
|
if (layer.above) {
|
|
46325
46652
|
if (group) {
|
|
@@ -46471,6 +46798,7 @@ function renderBoardExport(renderer, input, options = {}) {
|
|
|
46471
46798
|
colorScheme
|
|
46472
46799
|
}),
|
|
46473
46800
|
backdropTexture: options.backgroundTexture,
|
|
46801
|
+
...plan.page ? { page: plan.page } : {},
|
|
46474
46802
|
...gpu && owners.length ? { shaders: {
|
|
46475
46803
|
renderer,
|
|
46476
46804
|
owners,
|
|
@@ -46523,6 +46851,10 @@ function renderBoardExport(renderer, input, options = {}) {
|
|
|
46523
46851
|
kind: "shader-failed",
|
|
46524
46852
|
...failure
|
|
46525
46853
|
});
|
|
46854
|
+
if (gpu) for (const miss of boardShaderMisses(scene, plan, owners, exportScene.shaderErrors)) warnings.push({
|
|
46855
|
+
kind: "shader-hidden",
|
|
46856
|
+
...miss
|
|
46857
|
+
});
|
|
46526
46858
|
return {
|
|
46527
46859
|
canvas,
|
|
46528
46860
|
plan,
|
|
@@ -46533,6 +46865,38 @@ function renderBoardExport(renderer, input, options = {}) {
|
|
|
46533
46865
|
flattened?.();
|
|
46534
46866
|
}
|
|
46535
46867
|
}
|
|
46868
|
+
function boardShaderMisses(scene, plan, owners, failed = []) {
|
|
46869
|
+
const planned = new Set(plan.items.map((item) => item.id));
|
|
46870
|
+
const misses = owners.flatMap(({ id, root, output }) => {
|
|
46871
|
+
if (failed.some((failure) => failure.id === id)) return [];
|
|
46872
|
+
const shader = output.shader;
|
|
46873
|
+
if (shader && !shader.state && shader.passes.every((pass) => !boardShaderPassOn(pass, output.passes))) return [{
|
|
46874
|
+
id,
|
|
46875
|
+
reason: "every pass is switched off (ctx.passes() or enabled: false)"
|
|
46876
|
+
}];
|
|
46877
|
+
if (root) return [];
|
|
46878
|
+
const item = scene.get(id);
|
|
46879
|
+
if (!item) return [{
|
|
46880
|
+
id,
|
|
46881
|
+
reason: "its item is not in the document"
|
|
46882
|
+
}];
|
|
46883
|
+
if (scene.opacity(id) <= 0) return [{
|
|
46884
|
+
id,
|
|
46885
|
+
reason: "its item is hidden (opacity 0 or invisible)"
|
|
46886
|
+
}];
|
|
46887
|
+
if (planned.has(id)) return [];
|
|
46888
|
+
return [{
|
|
46889
|
+
id,
|
|
46890
|
+
reason: exportItemBounds(item, scene) ? "its item is outside the exported area" : "its item is clipped away by a parent frame"
|
|
46891
|
+
}];
|
|
46892
|
+
});
|
|
46893
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
46894
|
+
for (const { id, reason } of misses) grouped.set(reason, [...grouped.get(reason) ?? [], id]);
|
|
46895
|
+
return [...grouped].map(([reason, ids]) => ({
|
|
46896
|
+
ids,
|
|
46897
|
+
reason
|
|
46898
|
+
}));
|
|
46899
|
+
}
|
|
46536
46900
|
function listIds(ids) {
|
|
46537
46901
|
return ids.length > 3 ? `${ids.slice(0, 3).join(", ")} and ${ids.length - 3} more` : ids.join(", ");
|
|
46538
46902
|
}
|
|
@@ -46543,6 +46907,7 @@ function describeBoardExportWarning(warning) {
|
|
|
46543
46907
|
case "many-items": return `${warning.count} items exported; this may take a moment.`;
|
|
46544
46908
|
case "shaders-unsupported": return `Shaders need a WebGL renderer; this export ${[warning.omitted.length ? `left out ${listIds(warning.omitted)}` : "", warning.drawn.length ? `drew ${listIds(warning.drawn)} with draw()` : ""].filter(Boolean).join(" and ")}.`;
|
|
46545
46909
|
case "shader-failed": return `Shader ${warning.id} was left out: ${warning.message}`;
|
|
46910
|
+
case "shader-hidden": return `${warning.ids.length === 1 ? "Shader" : "Shaders"} of ${listIds(warning.ids)} drew nothing: ${warning.reason.replace(/^its item is/, warning.ids.length === 1 ? "its item is" : "their items are")}.`;
|
|
46546
46911
|
}
|
|
46547
46912
|
}
|
|
46548
46913
|
//#endregion
|
|
@@ -46596,7 +46961,7 @@ function initializeBoardFonts(registry, fonts) {
|
|
|
46596
46961
|
//#region ../sdk/src/board/export/node/scripts.ts
|
|
46597
46962
|
const WORKER = `
|
|
46598
46963
|
const {parentPort, workerData} = require('node:worker_threads');
|
|
46599
|
-
const {createContext, Script, SourceTextModule} = require('node:vm');
|
|
46964
|
+
const {createContext, Script, SourceTextModule, SyntheticModule} = require('node:vm');
|
|
46600
46965
|
const {createCanvas, GlobalFonts} = require(workerData.canvasModule);
|
|
46601
46966
|
(${initializeBoardFonts.toString()})(GlobalFonts, workerData.fonts);
|
|
46602
46967
|
const instances = new Map();
|
|
@@ -46627,10 +46992,15 @@ async function create(data) {
|
|
|
46627
46992
|
return parts.join('/');
|
|
46628
46993
|
};
|
|
46629
46994
|
const link = (name,ref) => load(resolve(ref.identifier,name));
|
|
46995
|
+
const json = new Script('(text)=>{const freeze=v=>{if(v&&typeof v==="object"&&!Object.isFrozen(v)){Object.freeze(v);for(const k in v)freeze(v[k]);}return v};return freeze(JSON.parse(text))}').runInContext(context);
|
|
46630
46996
|
function load(path) {
|
|
46631
46997
|
if(modules.has(path)) return modules.get(path);
|
|
46632
46998
|
const source=sources[path];
|
|
46633
46999
|
if(!source) throw new Error('Module is unavailable: '+path);
|
|
47000
|
+
if(path.endsWith('.json')) {
|
|
47001
|
+
const module=new SyntheticModule(['default'],function(){this.setExport('default',json(source.code));},{context,identifier:path});
|
|
47002
|
+
modules.set(path,module);return module;
|
|
47003
|
+
}
|
|
46634
47004
|
const module=new SourceTextModule(source.code,{context,identifier:path,importModuleDynamically:async name=>{
|
|
46635
47005
|
const child=load(resolve(path,name));
|
|
46636
47006
|
if(child.status==='unlinked') await child.link(link);
|
|
@@ -46696,6 +47066,16 @@ parentPort.on('message',async data=>{
|
|
|
46696
47066
|
} catch(error) { release(data.input?.id);parentPort.postMessage({kind:'sample',error:String(error.stack||error)}); }
|
|
46697
47067
|
});
|
|
46698
47068
|
`;
|
|
47069
|
+
function describeBoardScriptLanes(lanes) {
|
|
47070
|
+
return lanes.flatMap(({ lane, thread, running, waiting, scripts }) => {
|
|
47071
|
+
if (!running && !waiting) return [];
|
|
47072
|
+
return [`${`lane ${lane}${thread === null ? "" : ` (worker thread ${thread})`}`}: ${running ? `${running.id} busy for ${(running.ms / 1e3).toFixed(1)} s${running.event ? `, last event ${running.event}` : ""}${running.call ? `, last call ${running.call}` : ""}` : "idle"}${waiting ? `; ${waiting} more request${waiting === 1 ? "" : "s"} queued` : ""} (runs ${scripts.join(", ")})`];
|
|
47073
|
+
});
|
|
47074
|
+
}
|
|
47075
|
+
function describeCall(name, input) {
|
|
47076
|
+
const message = input;
|
|
47077
|
+
return name === "board.emit" && message && typeof message.target === "string" ? `emit(${message.target}, "${String(message.type)}")` : name;
|
|
47078
|
+
}
|
|
46699
47079
|
function createNodeScriptLanes(renderer, options) {
|
|
46700
47080
|
const calls = /* @__PURE__ */ new Map();
|
|
46701
47081
|
const settled = /* @__PURE__ */ new Set();
|
|
@@ -46704,8 +47084,11 @@ function createNodeScriptLanes(renderer, options) {
|
|
|
46704
47084
|
const lanes = Array.from({ length: concurrency }, () => ({
|
|
46705
47085
|
worker: null,
|
|
46706
47086
|
tail: Promise.resolve(),
|
|
46707
|
-
graphs: /* @__PURE__ */ new Set()
|
|
47087
|
+
graphs: /* @__PURE__ */ new Set(),
|
|
47088
|
+
running: null,
|
|
47089
|
+
waiting: 0
|
|
46708
47090
|
}));
|
|
47091
|
+
const activity = /* @__PURE__ */ new Map();
|
|
46709
47092
|
const assignments = /* @__PURE__ */ new Map();
|
|
46710
47093
|
const sources = /* @__PURE__ */ new Map();
|
|
46711
47094
|
const modules = createBoardScriptModuleReader(options.readModule, options.readTimeoutMs);
|
|
@@ -46761,6 +47144,10 @@ function createNodeScriptLanes(renderer, options) {
|
|
|
46761
47144
|
calls.delete(key);
|
|
46762
47145
|
}
|
|
46763
47146
|
if (message.kind !== "call") return;
|
|
47147
|
+
activity.set(message.id ?? "", {
|
|
47148
|
+
...activity.get(message.id ?? ""),
|
|
47149
|
+
call: describeCall(message.name ?? "", message.input)
|
|
47150
|
+
});
|
|
46764
47151
|
const answer = (value, error) => {
|
|
46765
47152
|
if (lane.worker !== worker) return;
|
|
46766
47153
|
const done = new Promise((resolve) => {
|
|
@@ -46794,14 +47181,21 @@ function createNodeScriptLanes(renderer, options) {
|
|
|
46794
47181
|
});
|
|
46795
47182
|
return worker;
|
|
46796
47183
|
}
|
|
46797
|
-
function request(lane, message, register) {
|
|
47184
|
+
function request(lane, message, register, id) {
|
|
47185
|
+
lane.waiting++;
|
|
46798
47186
|
const task = lane.tail.then(() => new Promise((resolve, reject) => {
|
|
47187
|
+
lane.waiting--;
|
|
46799
47188
|
if (disposed) return reject(/* @__PURE__ */ new Error("Script host is disposed."));
|
|
46800
47189
|
const worker = start(lane);
|
|
47190
|
+
if (id) lane.running = {
|
|
47191
|
+
id,
|
|
47192
|
+
since: performance.now()
|
|
47193
|
+
};
|
|
46801
47194
|
const cleanup = () => {
|
|
46802
47195
|
clearTimeout(timer);
|
|
46803
47196
|
worker.off("message", reply);
|
|
46804
47197
|
lane.reject = void 0;
|
|
47198
|
+
lane.running = null;
|
|
46805
47199
|
};
|
|
46806
47200
|
const reply = (value) => {
|
|
46807
47201
|
if (value.kind !== "sample") return;
|
|
@@ -46839,6 +47233,10 @@ function createNodeScriptLanes(renderer, options) {
|
|
|
46839
47233
|
if (!Number.isFinite(time) || time < 0 || time > 6e5) return Promise.reject(/* @__PURE__ */ new Error("Script time must be between 0 and 600000 ms."));
|
|
46840
47234
|
const lane = laneOf(input.id);
|
|
46841
47235
|
const src = input.script.src;
|
|
47236
|
+
if (events?.length) activity.set(input.id, {
|
|
47237
|
+
...activity.get(input.id),
|
|
47238
|
+
event: events.map((event) => event.type).join(", ")
|
|
47239
|
+
});
|
|
46842
47240
|
return request(lane, {
|
|
46843
47241
|
input,
|
|
46844
47242
|
src,
|
|
@@ -46852,7 +47250,21 @@ function createNodeScriptLanes(renderer, options) {
|
|
|
46852
47250
|
draw,
|
|
46853
47251
|
shaders,
|
|
46854
47252
|
sources: lane.graphs.has(src) ? void 0 : graph
|
|
46855
|
-
}, () => lane.graphs.add(src));
|
|
47253
|
+
}, () => lane.graphs.add(src), input.id);
|
|
47254
|
+
},
|
|
47255
|
+
status() {
|
|
47256
|
+
const now = performance.now();
|
|
47257
|
+
return lanes.map((lane, index) => ({
|
|
47258
|
+
lane: index + 1,
|
|
47259
|
+
thread: lane.worker?.threadId ?? null,
|
|
47260
|
+
running: lane.running && {
|
|
47261
|
+
id: lane.running.id,
|
|
47262
|
+
ms: now - lane.running.since,
|
|
47263
|
+
...activity.get(lane.running.id)
|
|
47264
|
+
},
|
|
47265
|
+
waiting: lane.waiting,
|
|
47266
|
+
scripts: [...assignments].flatMap(([id, assigned]) => assigned === lane ? [id] : [])
|
|
47267
|
+
}));
|
|
46856
47268
|
},
|
|
46857
47269
|
async snapshot(id) {
|
|
46858
47270
|
const lane = assignments.get(id);
|
|
@@ -46862,6 +47274,7 @@ function createNodeScriptLanes(renderer, options) {
|
|
|
46862
47274
|
release(id) {
|
|
46863
47275
|
const lane = assignments.get(id);
|
|
46864
47276
|
assignments.delete(id);
|
|
47277
|
+
activity.delete(id);
|
|
46865
47278
|
if (lane) lane.tail = lane.tail.then(() => lane.worker?.postMessage({ release: [id] }));
|
|
46866
47279
|
},
|
|
46867
47280
|
assigned: () => assignments.keys(),
|
|
@@ -46901,11 +47314,33 @@ function scopedInput(document, { id, script, item }, size) {
|
|
|
46901
47314
|
};
|
|
46902
47315
|
}
|
|
46903
47316
|
function createNodeBoardScriptHost(renderer, options) {
|
|
46904
|
-
|
|
47317
|
+
let current = null;
|
|
47318
|
+
let ranks = /* @__PURE__ */ new Map();
|
|
47319
|
+
const outbox = createBoardScriptOutbox(() => ranks);
|
|
47320
|
+
const emitFailures = /* @__PURE__ */ new Map();
|
|
47321
|
+
const lanes = createNodeScriptLanes(renderer, {
|
|
47322
|
+
...options,
|
|
47323
|
+
async call(id, name, input) {
|
|
47324
|
+
if (name === "board.emit" && current) {
|
|
47325
|
+
try {
|
|
47326
|
+
const { target, event } = boardScriptEmit(current, id, input);
|
|
47327
|
+
outbox.push(id, target, event);
|
|
47328
|
+
} catch (error) {
|
|
47329
|
+
emitFailures.set(id, error instanceof Error ? error.message : String(error));
|
|
47330
|
+
throw error;
|
|
47331
|
+
}
|
|
47332
|
+
return;
|
|
47333
|
+
}
|
|
47334
|
+
const call = BOARD_SCRIPT_EXPORT_CALLS[name];
|
|
47335
|
+
if (!call) throw new Error("Capabilities are unavailable during export.");
|
|
47336
|
+
return call(input);
|
|
47337
|
+
}
|
|
47338
|
+
});
|
|
46905
47339
|
const textures = /* @__PURE__ */ new Map();
|
|
46906
47340
|
const outputs = /* @__PURE__ */ new Map();
|
|
46907
47341
|
const errors = /* @__PURE__ */ new Map();
|
|
46908
47342
|
const sampled = /* @__PURE__ */ new Map();
|
|
47343
|
+
const views = /* @__PURE__ */ new Map();
|
|
46909
47344
|
const key = (id, time) => `${id}|${time}`;
|
|
46910
47345
|
let disposed = false;
|
|
46911
47346
|
return {
|
|
@@ -46913,6 +47348,8 @@ function createNodeBoardScriptHost(renderer, options) {
|
|
|
46913
47348
|
frame: (item, time) => textures.get(key(item.id, time)) ?? null,
|
|
46914
47349
|
error: (id) => errors.get(id) ?? null,
|
|
46915
47350
|
release() {},
|
|
47351
|
+
emitFailures,
|
|
47352
|
+
status: () => lanes.status(),
|
|
46916
47353
|
shaders: (document, time) => boardShaderOwners(document, outputs.get(time) ?? [], () => time),
|
|
46917
47354
|
document(document, time) {
|
|
46918
47355
|
const at = outputs.get(time);
|
|
@@ -46936,11 +47373,20 @@ function createNodeBoardScriptHost(renderer, options) {
|
|
|
46936
47373
|
items: Object.fromEntries(list.map(({ id, frame: _frame, ...item }) => [id, item]))
|
|
46937
47374
|
});
|
|
46938
47375
|
const document = documentOf(items);
|
|
47376
|
+
current = document;
|
|
47377
|
+
emitFailures.clear();
|
|
46939
47378
|
const scripted = boardScriptAttachments(document);
|
|
47379
|
+
ranks = new Map(scripted.map(({ id }, index) => [id, index]));
|
|
46940
47380
|
const alive = new Set(scripted.map(({ id }) => id));
|
|
46941
|
-
for (const id of [...lanes.assigned()]) if (!alive.has(id))
|
|
47381
|
+
for (const id of [...lanes.assigned()]) if (!alive.has(id)) {
|
|
47382
|
+
lanes.release(id);
|
|
47383
|
+
views.delete(id);
|
|
47384
|
+
sampled.delete(id);
|
|
47385
|
+
}
|
|
46942
47386
|
if (!scripted.length) return;
|
|
46943
47387
|
const frames = new Map(items.map((item) => [item.id, item.frame]));
|
|
47388
|
+
const viewKey = options?.view ? JSON.stringify(options.view) : null;
|
|
47389
|
+
const prepared = /* @__PURE__ */ new Map();
|
|
46944
47390
|
await Promise.all(scripted.map(async (attachment) => {
|
|
46945
47391
|
const { id, item } = attachment;
|
|
46946
47392
|
try {
|
|
@@ -46949,12 +47395,58 @@ function createNodeBoardScriptHost(renderer, options) {
|
|
|
46949
47395
|
const width = item ? "size" in item ? item.size.width : frame?.width ?? 0 : 0;
|
|
46950
47396
|
const height = item ? "size" in item ? item.size.height : frame?.height ?? 0 : 0;
|
|
46951
47397
|
const scale = Math.min(4, Math.max(.25, zoom), 2048 / Math.max(1, width, height));
|
|
46952
|
-
|
|
47398
|
+
prepared.set(id, {
|
|
47399
|
+
attachment,
|
|
47400
|
+
graph,
|
|
47401
|
+
input: scopedInput(document, attachment, {
|
|
47402
|
+
width,
|
|
47403
|
+
height
|
|
47404
|
+
}),
|
|
46953
47405
|
width,
|
|
46954
|
-
height
|
|
47406
|
+
height,
|
|
47407
|
+
scale
|
|
46955
47408
|
});
|
|
46956
|
-
|
|
47409
|
+
} catch (error) {
|
|
47410
|
+
errors.set(id, error instanceof Error ? error.message : String(error));
|
|
47411
|
+
}
|
|
47412
|
+
}));
|
|
47413
|
+
const keep = async (id, time, events) => {
|
|
47414
|
+
const entry = prepared.get(id);
|
|
47415
|
+
if (!entry || errors.has(id)) return;
|
|
47416
|
+
const { attachment, graph, input, scale } = entry;
|
|
47417
|
+
try {
|
|
47418
|
+
const result = await lanes.sample({
|
|
47419
|
+
input,
|
|
47420
|
+
graph,
|
|
47421
|
+
time,
|
|
47422
|
+
scale,
|
|
47423
|
+
events,
|
|
47424
|
+
draw: Boolean(attachment.item),
|
|
47425
|
+
shaders: options?.shaders
|
|
47426
|
+
});
|
|
47427
|
+
if (disposed) return;
|
|
47428
|
+
if (result.png) {
|
|
47429
|
+
const frameKey = key(id, time);
|
|
47430
|
+
textures.get(frameKey)?.destroy(true);
|
|
47431
|
+
const texture = await renderer.decodeImage(result.png);
|
|
47432
|
+
if (result.output.pixelated) texture.source.scaleMode = "nearest";
|
|
47433
|
+
textures.set(frameKey, texture);
|
|
47434
|
+
}
|
|
47435
|
+
let at = outputs.get(time);
|
|
47436
|
+
if (!at) {
|
|
47437
|
+
at = /* @__PURE__ */ new Map();
|
|
47438
|
+
outputs.set(time, at);
|
|
47439
|
+
}
|
|
47440
|
+
at.set(id, result.output);
|
|
47441
|
+
} catch (error) {
|
|
47442
|
+
errors.set(id, error instanceof Error ? error.message : String(error));
|
|
47443
|
+
}
|
|
47444
|
+
};
|
|
47445
|
+
for (const time of times) {
|
|
47446
|
+
await Promise.all([...prepared].map(async ([id, { attachment, graph, input, width, height, scale }]) => {
|
|
47447
|
+
try {
|
|
46957
47448
|
const last = sampled.get(id) ?? 0;
|
|
47449
|
+
if (time < last) views.delete(id);
|
|
46958
47450
|
if (options?.history) {
|
|
46959
47451
|
const from = last <= time ? last : 0;
|
|
46960
47452
|
const run = async (at, document) => {
|
|
@@ -46998,34 +47490,36 @@ function createNodeBoardScriptHost(renderer, options) {
|
|
|
46998
47490
|
}
|
|
46999
47491
|
if (JSON.stringify(input.script.params) !== previous && before.at > ran) await run(before.at, before.document);
|
|
47000
47492
|
}
|
|
47001
|
-
|
|
47002
|
-
|
|
47003
|
-
|
|
47004
|
-
|
|
47005
|
-
|
|
47006
|
-
|
|
47007
|
-
|
|
47008
|
-
|
|
47493
|
+
} catch (error) {
|
|
47494
|
+
errors.set(id, error instanceof Error ? error.message : String(error));
|
|
47495
|
+
return;
|
|
47496
|
+
}
|
|
47497
|
+
sampled.set(id, time);
|
|
47498
|
+
const events = [];
|
|
47499
|
+
const shown = viewKey && `${JSON.stringify({
|
|
47500
|
+
...attachment.script,
|
|
47501
|
+
params: void 0
|
|
47502
|
+
})}|${viewKey}`;
|
|
47503
|
+
if (shown && views.get(id) !== shown) {
|
|
47504
|
+
views.set(id, shown);
|
|
47505
|
+
events.push({
|
|
47506
|
+
type: "viewchange",
|
|
47507
|
+
data: options?.view
|
|
47009
47508
|
});
|
|
47010
|
-
if (disposed) return;
|
|
47011
|
-
if (result.png) {
|
|
47012
|
-
const frameKey = key(id, time);
|
|
47013
|
-
textures.get(frameKey)?.destroy(true);
|
|
47014
|
-
const texture = await renderer.decodeImage(result.png);
|
|
47015
|
-
if (result.output.pixelated) texture.source.scaleMode = "nearest";
|
|
47016
|
-
textures.set(frameKey, texture);
|
|
47017
|
-
}
|
|
47018
|
-
let at = outputs.get(time);
|
|
47019
|
-
if (!at) {
|
|
47020
|
-
at = /* @__PURE__ */ new Map();
|
|
47021
|
-
outputs.set(time, at);
|
|
47022
|
-
}
|
|
47023
|
-
at.set(id, result.output);
|
|
47024
47509
|
}
|
|
47025
|
-
|
|
47026
|
-
|
|
47510
|
+
await keep(id, time, events);
|
|
47511
|
+
}));
|
|
47512
|
+
for (let round = 0; outbox.size && round <= 16 && !disposed; round++) {
|
|
47513
|
+
const delivered = [...outbox.take()].flatMap(([id, events]) => {
|
|
47514
|
+
const output = outputs.get(time)?.get(id);
|
|
47515
|
+
const wanted = events.filter((event) => boardScriptListens(output, event));
|
|
47516
|
+
return wanted.length ? [keep(id, time, wanted)] : [];
|
|
47517
|
+
});
|
|
47518
|
+
await Promise.all(delivered);
|
|
47027
47519
|
}
|
|
47028
|
-
|
|
47520
|
+
outbox.take();
|
|
47521
|
+
}
|
|
47522
|
+
await lanes.idle();
|
|
47029
47523
|
},
|
|
47030
47524
|
destroy() {
|
|
47031
47525
|
disposed = true;
|
|
@@ -47038,6 +47532,7 @@ function createNodeBoardScriptHost(renderer, options) {
|
|
|
47038
47532
|
}
|
|
47039
47533
|
function createNodeBoardScriptRuntime(renderer, options) {
|
|
47040
47534
|
const { callbacks } = options;
|
|
47535
|
+
const capabilities = Object.keys(callbacks.capabilities);
|
|
47041
47536
|
const lanes = createNodeScriptLanes(renderer, {
|
|
47042
47537
|
...options,
|
|
47043
47538
|
call: (id, name, input) => {
|
|
@@ -47158,10 +47653,13 @@ function createNodeBoardScriptRuntime(renderer, options) {
|
|
|
47158
47653
|
entries.set(id, entry);
|
|
47159
47654
|
}
|
|
47160
47655
|
if (entry.error || entry.busy) continue;
|
|
47161
|
-
const input =
|
|
47162
|
-
|
|
47163
|
-
|
|
47164
|
-
|
|
47656
|
+
const input = {
|
|
47657
|
+
...scopedInput(document, attachment, item ? scene.layout.box(id) : {
|
|
47658
|
+
width: 0,
|
|
47659
|
+
height: 0
|
|
47660
|
+
}),
|
|
47661
|
+
capabilities
|
|
47662
|
+
};
|
|
47165
47663
|
const inputKey = JSON.stringify(input);
|
|
47166
47664
|
if (!(inputKey !== entry.inputKey || entry.dirty || entry.events.length > 0) && entry.output && (entry.time === time || !entry.output.animated && !entry.output.updating)) continue;
|
|
47167
47665
|
entry.dirty = false;
|
|
@@ -47183,10 +47681,12 @@ function createNodeBoardScriptRuntime(renderer, options) {
|
|
|
47183
47681
|
},
|
|
47184
47682
|
event(id, event) {
|
|
47185
47683
|
const entry = entries.get(id);
|
|
47186
|
-
if (!entry || entry.error || entry.output
|
|
47187
|
-
entry.events
|
|
47684
|
+
if (!entry || entry.error || !boardScriptListens(entry.output, event)) return true;
|
|
47685
|
+
if (!queueBoardScriptEvent(entry.events, event)) return false;
|
|
47188
47686
|
callbacks.onFrame();
|
|
47687
|
+
return true;
|
|
47189
47688
|
},
|
|
47689
|
+
status: () => lanes.status(),
|
|
47190
47690
|
output: (id) => entries.get(id)?.output ?? null,
|
|
47191
47691
|
snapshot: (id) => lanes.snapshot(id),
|
|
47192
47692
|
restore() {
|
|
@@ -47684,6 +48184,7 @@ const STRUCTURAL_KEYS = [
|
|
|
47684
48184
|
"parent",
|
|
47685
48185
|
"z",
|
|
47686
48186
|
"locked",
|
|
48187
|
+
"autoplay",
|
|
47687
48188
|
"metadata"
|
|
47688
48189
|
];
|
|
47689
48190
|
function keyframe(animations, playhead, recording, id, property, value, storedValue) {
|
|
@@ -49199,7 +49700,7 @@ function createDocumentModule(ctx) {
|
|
|
49199
49700
|
const previous = scripted;
|
|
49200
49701
|
scripted = items;
|
|
49201
49702
|
const changed = [.../* @__PURE__ */ new Set([...previous.keys(), ...items.keys()])].filter((id) => !sameJson(previous.get(id), items.get(id)));
|
|
49202
|
-
if (!changed.length) return;
|
|
49703
|
+
if (!changed.length) return changed;
|
|
49203
49704
|
const restacked = /* @__PURE__ */ new Set();
|
|
49204
49705
|
rescene(changed.some((id) => {
|
|
49205
49706
|
const before = previous.get(id) ?? state.base.items[id];
|
|
@@ -49208,6 +49709,7 @@ function createDocumentModule(ctx) {
|
|
|
49208
49709
|
if (before.z !== after.z) restacked.add(after.parent ?? "");
|
|
49209
49710
|
return false;
|
|
49210
49711
|
}) || [...restacked].some(reordered) ? void 0 : changed);
|
|
49712
|
+
return changed;
|
|
49211
49713
|
}
|
|
49212
49714
|
function reordered(parent) {
|
|
49213
49715
|
const { scene } = state;
|
|
@@ -49245,10 +49747,10 @@ function createDocumentModule(ctx) {
|
|
|
49245
49747
|
state.structureVersion += 1;
|
|
49246
49748
|
state.geometryVersion += 1;
|
|
49247
49749
|
}
|
|
49248
|
-
function setDraftItem(id, item) {
|
|
49750
|
+
function setDraftItem(id, item, shown) {
|
|
49249
49751
|
if (!draft.has(id)) {
|
|
49250
|
-
const
|
|
49251
|
-
if (
|
|
49752
|
+
const origin = shown ?? displayItem(id);
|
|
49753
|
+
if (origin) draftOrigins.set(id, origin);
|
|
49252
49754
|
}
|
|
49253
49755
|
draft.set(id, item);
|
|
49254
49756
|
}
|
|
@@ -49258,9 +49760,9 @@ function createDocumentModule(ctx) {
|
|
|
49258
49760
|
function dropDraftItem(id) {
|
|
49259
49761
|
draft.delete(id);
|
|
49260
49762
|
}
|
|
49261
|
-
function writeDraft(changes, structural = false) {
|
|
49763
|
+
function writeDraft(changes, structural = false, shown) {
|
|
49262
49764
|
if (changes.size === 0) return;
|
|
49263
|
-
for (const [id, item] of changes) setDraftItem(id, item);
|
|
49765
|
+
for (const [id, item] of changes) setDraftItem(id, item, shown?.get(id)?.item);
|
|
49264
49766
|
if (!structural) for (const [id, item] of changes) {
|
|
49265
49767
|
const before = state.scene.get(id);
|
|
49266
49768
|
if (!item || !before || before.parent !== item.parent || before.z !== item.z || !sameJson(arrowBindings(before), arrowBindings(item))) {
|
|
@@ -49838,7 +50340,10 @@ function createInteractionModule(ctx) {
|
|
|
49838
50340
|
});
|
|
49839
50341
|
}
|
|
49840
50342
|
function browsing() {
|
|
49841
|
-
return options.readonly === true || ctx.frames.view()?.present === true;
|
|
50343
|
+
return options.readonly === true || state.tool === "play" || ctx.frames.view()?.present === true;
|
|
50344
|
+
}
|
|
50345
|
+
function movable(item) {
|
|
50346
|
+
return Boolean(item && !ctx.query.isLocked(item) && registry.capabilities(item).canMove);
|
|
49842
50347
|
}
|
|
49843
50348
|
function opensOnTap(item) {
|
|
49844
50349
|
return registry.activation(item, browsing()) === "tap";
|
|
@@ -50052,7 +50557,7 @@ function createInteractionModule(ctx) {
|
|
|
50052
50557
|
const dx = event.screen.x - gesture.start.x;
|
|
50053
50558
|
const dy = event.screen.y - gesture.start.y;
|
|
50054
50559
|
const item = state.scene.get(gesture.itemId);
|
|
50055
|
-
if (!(!
|
|
50560
|
+
if (!(!options.readonly && !ctx.frames.view()?.present && (state.tool === "select" || state.tool === "play") && movable(item))) {
|
|
50056
50561
|
state.interaction = {
|
|
50057
50562
|
type: "panning",
|
|
50058
50563
|
start: gesture.start,
|
|
@@ -50066,7 +50571,7 @@ function createInteractionModule(ctx) {
|
|
|
50066
50571
|
const translating = {
|
|
50067
50572
|
type: "translating",
|
|
50068
50573
|
start: gesture.world,
|
|
50069
|
-
|
|
50574
|
+
...ctx.selection.grab([gesture.itemId]),
|
|
50070
50575
|
moved: false,
|
|
50071
50576
|
duplicate: false
|
|
50072
50577
|
};
|
|
@@ -50088,13 +50593,13 @@ function createInteractionModule(ctx) {
|
|
|
50088
50593
|
}
|
|
50089
50594
|
const id = gesture.type === "pressing" ? gesture.itemId : gesture.type === "panning" && !gesture.moved ? gesture.tapSelection?.targetId : null;
|
|
50090
50595
|
const item = id ? state.scene.get(id) : null;
|
|
50091
|
-
if (!
|
|
50596
|
+
if (!movable(item)) return null;
|
|
50092
50597
|
state.selection = [item.id];
|
|
50093
50598
|
state.tool = "select";
|
|
50094
50599
|
state.interaction = {
|
|
50095
50600
|
type: "translating",
|
|
50096
50601
|
start: last?.world ?? (gesture.type === "pressing" ? gesture.world : rectCenter(item.frame)),
|
|
50097
|
-
|
|
50602
|
+
...ctx.selection.grab([item.id]),
|
|
50098
50603
|
moved: false,
|
|
50099
50604
|
duplicate: false,
|
|
50100
50605
|
held: true
|
|
@@ -50127,11 +50632,28 @@ function createInteractionModule(ctx) {
|
|
|
50127
50632
|
return item?.type === "frame" && registry.hitTest(item, point);
|
|
50128
50633
|
});
|
|
50129
50634
|
}
|
|
50635
|
+
function play(event) {
|
|
50636
|
+
if (!state.spaceHeld && pressCard(event)) return;
|
|
50637
|
+
const item = !state.spaceHeld && event.button === 0 ? ctx.query.pickAt(event.world, event.pointerType) : null;
|
|
50638
|
+
state.interaction = movable(item) ? {
|
|
50639
|
+
type: "translating",
|
|
50640
|
+
start: event.world,
|
|
50641
|
+
...ctx.selection.grab([item.id]),
|
|
50642
|
+
moved: false,
|
|
50643
|
+
duplicate: false
|
|
50644
|
+
} : {
|
|
50645
|
+
type: "panning",
|
|
50646
|
+
start: event.screen,
|
|
50647
|
+
origin: { ...state.camera },
|
|
50648
|
+
moved: false,
|
|
50649
|
+
tapSelection: null
|
|
50650
|
+
};
|
|
50651
|
+
}
|
|
50130
50652
|
function translateSelection(event, tap) {
|
|
50131
50653
|
state.interaction = {
|
|
50132
50654
|
type: "translating",
|
|
50133
50655
|
start: event.world,
|
|
50134
|
-
|
|
50656
|
+
...ctx.selection.grab(ctx.selection.movable()),
|
|
50135
50657
|
moved: false,
|
|
50136
50658
|
duplicate: event.altKey,
|
|
50137
50659
|
...tap ? { tap } : {}
|
|
@@ -50181,6 +50703,7 @@ function createInteractionModule(ctx) {
|
|
|
50181
50703
|
}
|
|
50182
50704
|
browseByTouch(event);
|
|
50183
50705
|
const { tool, spaceHeld } = state;
|
|
50706
|
+
if (tool === "play") return play(event);
|
|
50184
50707
|
const additive = event.shiftKey || event.metaKey || event.ctrlKey;
|
|
50185
50708
|
if (!spaceHeld && (tool === "hand" || options.readonly) && pressCard(event)) return;
|
|
50186
50709
|
const fingerOnPenCanvas = tool === "draw" && event.pointerType === "touch" && penSeen;
|
|
@@ -50278,13 +50801,13 @@ function createInteractionModule(ctx) {
|
|
|
50278
50801
|
pivot,
|
|
50279
50802
|
startAngle: angleFrom(pivot, event.world),
|
|
50280
50803
|
current: event.world,
|
|
50281
|
-
|
|
50804
|
+
...ctx.selection.grab(ctx.selection.movable()),
|
|
50282
50805
|
moved: false
|
|
50283
50806
|
};
|
|
50284
50807
|
return;
|
|
50285
50808
|
}
|
|
50286
50809
|
if (control?.kind === "resize" && bounds && transform) {
|
|
50287
|
-
const origin = ctx.selection.
|
|
50810
|
+
const { origin, grabbed } = ctx.selection.grab(ctx.selection.movable());
|
|
50288
50811
|
const single = origin.size === 1 ? { ...[...origin.values()][0] } : null;
|
|
50289
50812
|
const edge = frameHandlePosition(transform.frame, control.handle);
|
|
50290
50813
|
const grab = {
|
|
@@ -50297,6 +50820,7 @@ function createInteractionModule(ctx) {
|
|
|
50297
50820
|
single,
|
|
50298
50821
|
bounds,
|
|
50299
50822
|
origin,
|
|
50823
|
+
grabbed,
|
|
50300
50824
|
grab,
|
|
50301
50825
|
moved: false
|
|
50302
50826
|
};
|
|
@@ -50388,7 +50912,7 @@ function createInteractionModule(ctx) {
|
|
|
50388
50912
|
state.selection = roots;
|
|
50389
50913
|
current = {
|
|
50390
50914
|
...current,
|
|
50391
|
-
|
|
50915
|
+
...ctx.selection.grab(roots),
|
|
50392
50916
|
duplicate: false
|
|
50393
50917
|
};
|
|
50394
50918
|
}
|
|
@@ -50410,15 +50934,18 @@ function createInteractionModule(ctx) {
|
|
|
50410
50934
|
};
|
|
50411
50935
|
let tx = dx;
|
|
50412
50936
|
let ty = dy;
|
|
50413
|
-
|
|
50937
|
+
const playing = state.tool === "play";
|
|
50938
|
+
if (!playing && !event.metaKey && !event.ctrlKey) {
|
|
50414
50939
|
const snap = computeTranslationSnap(shift(dx, dy), movingWith(current.origin));
|
|
50415
50940
|
tx += snap.dx;
|
|
50416
50941
|
ty += snap.dy;
|
|
50417
50942
|
state.snapGuides = snap.guides;
|
|
50418
50943
|
} else state.snapGuides = [];
|
|
50419
|
-
ctx.document.writeDraft(ctx.selection.placed(shift(tx, ty)));
|
|
50944
|
+
ctx.document.writeDraft(ctx.selection.placed(shift(tx, ty), current.grabbed), false, current.grabbed);
|
|
50420
50945
|
let dropTargetId = null;
|
|
50421
|
-
|
|
50946
|
+
if (!playing) {
|
|
50947
|
+
for (const parent of dropParents(current.origin, true).values()) if (parent) dropTargetId = parent;
|
|
50948
|
+
}
|
|
50422
50949
|
if ((current.dropTargetId ?? null) !== dropTargetId) state.interaction = {
|
|
50423
50950
|
...current,
|
|
50424
50951
|
dropTargetId
|
|
@@ -50446,7 +50973,7 @@ function createInteractionModule(ctx) {
|
|
|
50446
50973
|
if (frame) frames.set(id, frame);
|
|
50447
50974
|
});
|
|
50448
50975
|
}
|
|
50449
|
-
ctx.document.writeDraft(ctx.selection.placed(frames));
|
|
50976
|
+
ctx.document.writeDraft(ctx.selection.placed(frames, gesture.grabbed), false, gesture.grabbed);
|
|
50450
50977
|
}
|
|
50451
50978
|
function rotate(gesture, event) {
|
|
50452
50979
|
if (!gesture.moved && !dragged(event)) return;
|
|
@@ -50466,7 +50993,7 @@ function createInteractionModule(ctx) {
|
|
|
50466
50993
|
rotation: normalizeRotation(frame.rotation)
|
|
50467
50994
|
});
|
|
50468
50995
|
});
|
|
50469
|
-
ctx.document.writeDraft(ctx.selection.placed(frames));
|
|
50996
|
+
ctx.document.writeDraft(ctx.selection.placed(frames, gesture.grabbed), false, gesture.grabbed);
|
|
50470
50997
|
}
|
|
50471
50998
|
function dragArrowHandle(gesture, event) {
|
|
50472
50999
|
if (!gesture.moved) {
|
|
@@ -51313,11 +51840,30 @@ function createSelectionModule(ctx) {
|
|
|
51313
51840
|
}
|
|
51314
51841
|
return frames;
|
|
51315
51842
|
}
|
|
51316
|
-
function
|
|
51843
|
+
function grab(ids) {
|
|
51844
|
+
const { layout } = state.scene;
|
|
51845
|
+
const origin = framesFor(ids);
|
|
51846
|
+
const grabbed = /* @__PURE__ */ new Map();
|
|
51847
|
+
for (const id of origin.keys()) {
|
|
51848
|
+
const item = ctx.document.displayItem(id);
|
|
51849
|
+
if (item) grabbed.set(id, {
|
|
51850
|
+
item,
|
|
51851
|
+
parent: item.parent && layout.has(item.parent) ? layout.matrix(item.parent) : IDENTITY_MATRIX,
|
|
51852
|
+
box: layout.box(id)
|
|
51853
|
+
});
|
|
51854
|
+
}
|
|
51855
|
+
return {
|
|
51856
|
+
origin,
|
|
51857
|
+
grabbed
|
|
51858
|
+
};
|
|
51859
|
+
}
|
|
51860
|
+
function placed(frames, from) {
|
|
51317
51861
|
const changes = /* @__PURE__ */ new Map();
|
|
51318
51862
|
for (const [id, frame] of frames) {
|
|
51863
|
+
const grabbed = from?.get(id);
|
|
51319
51864
|
const item = state.scene.get(id);
|
|
51320
|
-
if (
|
|
51865
|
+
if (grabbed) changes.set(id, placeItem(grabbed.item, frame, grabbed.parent, grabbed.box));
|
|
51866
|
+
else if (item) changes.set(id, sceneItemToItem({
|
|
51321
51867
|
...item,
|
|
51322
51868
|
frame
|
|
51323
51869
|
}, state.scene.layout));
|
|
@@ -51403,6 +51949,22 @@ function createSelectionModule(ctx) {
|
|
|
51403
51949
|
return unlocked;
|
|
51404
51950
|
}, state.selection);
|
|
51405
51951
|
}
|
|
51952
|
+
const autoplayable = () => items().filter((item) => !item.locked && boardAutoplayKind(item));
|
|
51953
|
+
function autoplay() {
|
|
51954
|
+
const eligible = autoplayable();
|
|
51955
|
+
return eligible.length > 0 ? eligible.every((item) => item.autoplay) : null;
|
|
51956
|
+
}
|
|
51957
|
+
function setAutoplay(on) {
|
|
51958
|
+
edit((item) => {
|
|
51959
|
+
if (!boardAutoplayKind(item) || Boolean(item.autoplay) === on) return null;
|
|
51960
|
+
if (on) return {
|
|
51961
|
+
...item,
|
|
51962
|
+
autoplay: true
|
|
51963
|
+
};
|
|
51964
|
+
const { autoplay: _autoplay, ...rest } = item;
|
|
51965
|
+
return rest;
|
|
51966
|
+
}, autoplayable().map((item) => item.id));
|
|
51967
|
+
}
|
|
51406
51968
|
function setColor(color) {
|
|
51407
51969
|
edit((item) => {
|
|
51408
51970
|
switch (item.type) {
|
|
@@ -51492,6 +52054,7 @@ function createSelectionModule(ctx) {
|
|
|
51492
52054
|
clear: () => set([]),
|
|
51493
52055
|
selectAll: () => set(state.scene.children(void 0).slice()),
|
|
51494
52056
|
framesFor,
|
|
52057
|
+
grab,
|
|
51495
52058
|
placed,
|
|
51496
52059
|
movable,
|
|
51497
52060
|
carries,
|
|
@@ -51501,6 +52064,8 @@ function createSelectionModule(ctx) {
|
|
|
51501
52064
|
canFillFrame: () => framed().length > 0,
|
|
51502
52065
|
fillFrame,
|
|
51503
52066
|
toggleLock,
|
|
52067
|
+
autoplay,
|
|
52068
|
+
setAutoplay,
|
|
51504
52069
|
setColor,
|
|
51505
52070
|
setStyle,
|
|
51506
52071
|
setProps,
|
|
@@ -51745,6 +52310,9 @@ function createBoardEditor(options) {
|
|
|
51745
52310
|
return items.length > 0 && items.every((item) => item.locked);
|
|
51746
52311
|
});
|
|
51747
52312
|
},
|
|
52313
|
+
get selectionAutoplay() {
|
|
52314
|
+
return read(["scene", "selection"], selection.autoplay);
|
|
52315
|
+
},
|
|
51748
52316
|
get bounds() {
|
|
51749
52317
|
return read(["scene", "selection"], selection.bounds);
|
|
51750
52318
|
},
|
|
@@ -51783,7 +52351,7 @@ function createBoardEditor(options) {
|
|
|
51783
52351
|
ctx.chosenTool = value;
|
|
51784
52352
|
state.tool = value;
|
|
51785
52353
|
if (isCreationBoardTool(value)) state.hoverId = null;
|
|
51786
|
-
if (value === "draw" || value === "arrow") {
|
|
52354
|
+
if (value === "draw" || value === "arrow" || value === "play") {
|
|
51787
52355
|
state.selection = [];
|
|
51788
52356
|
state.editingId = null;
|
|
51789
52357
|
}
|
|
@@ -51988,6 +52556,7 @@ function createBoardEditor(options) {
|
|
|
51988
52556
|
},
|
|
51989
52557
|
fillFrame: selection.fillFrame,
|
|
51990
52558
|
toggleSelectionLock: selection.toggleLock,
|
|
52559
|
+
setSelectionAutoplay: selection.setAutoplay,
|
|
51991
52560
|
setSelectionColor: selection.setColor,
|
|
51992
52561
|
setSelectionStyle: selection.setStyle,
|
|
51993
52562
|
setSelectionProps: selection.setProps,
|
|
@@ -52400,12 +52969,13 @@ function boardScriptsMayTakeInput(event, editor) {
|
|
|
52400
52969
|
return !editor.onHandle();
|
|
52401
52970
|
}
|
|
52402
52971
|
function boardScriptTakesTool(tools, tool, readonly) {
|
|
52403
|
-
return readonly || (tools ?? DEFAULT_TOOLS).includes(tool);
|
|
52972
|
+
return readonly || tool === "play" || (tools ?? DEFAULT_TOOLS).includes(tool);
|
|
52404
52973
|
}
|
|
52405
52974
|
const DEFAULT_TOOLS = ["select", "hand"];
|
|
52406
52975
|
//#endregion
|
|
52407
52976
|
//#region ../sdk/src/board/stage/script-controller.ts
|
|
52408
52977
|
const ACTIVATION_MS = 5e3;
|
|
52978
|
+
const MOTION_MS = 1e3;
|
|
52409
52979
|
const USER_EVENTS = /* @__PURE__ */ new Set([
|
|
52410
52980
|
"pointerdown",
|
|
52411
52981
|
"pointerup",
|
|
@@ -52435,6 +53005,8 @@ function createBoardScriptController(options) {
|
|
|
52435
53005
|
const interactive = /* @__PURE__ */ new Set();
|
|
52436
53006
|
const screens = /* @__PURE__ */ new Set();
|
|
52437
53007
|
const activations = /* @__PURE__ */ new Map();
|
|
53008
|
+
const emitFailures = /* @__PURE__ */ new Map();
|
|
53009
|
+
const moved = /* @__PURE__ */ new Map();
|
|
52438
53010
|
const listeners = /* @__PURE__ */ new Set();
|
|
52439
53011
|
let version = 0;
|
|
52440
53012
|
let composed = {
|
|
@@ -52526,18 +53098,19 @@ function createBoardScriptController(options) {
|
|
|
52526
53098
|
capabilities: {
|
|
52527
53099
|
...options.capabilities,
|
|
52528
53100
|
"board.emit": async (id, value) => {
|
|
52529
|
-
|
|
52530
|
-
|
|
52531
|
-
|
|
52532
|
-
|
|
52533
|
-
|
|
52534
|
-
|
|
52535
|
-
|
|
53101
|
+
try {
|
|
53102
|
+
const { target, event } = boardScriptEmit(editor.document, id, value);
|
|
53103
|
+
if (activated(id)) activations.set(target, activations.get(id) ?? now());
|
|
53104
|
+
if (host && !host.event(target, event)) throw new Error(`emit(${target}, "${event.type}") from ${id}: ${target} already has 128 events waiting.`);
|
|
53105
|
+
} catch (error) {
|
|
53106
|
+
emitFailures.set(id, error instanceof Error ? error.message : String(error));
|
|
53107
|
+
throw error;
|
|
53108
|
+
}
|
|
52536
53109
|
},
|
|
52537
|
-
"board.commit": (id, value) => {
|
|
53110
|
+
...editor.readonly ? {} : { "board.commit": async (id, value) => {
|
|
52538
53111
|
const { patch, frame } = value;
|
|
52539
53112
|
return commits.commit(id, patch, !frame && activated(id));
|
|
52540
|
-
},
|
|
53113
|
+
} },
|
|
52541
53114
|
"board.layoutText": async (_id, value) => layoutBoardScriptText(value)
|
|
52542
53115
|
},
|
|
52543
53116
|
onOutput: (id, output) => {
|
|
@@ -52583,10 +53156,12 @@ function createBoardScriptController(options) {
|
|
|
52583
53156
|
screens.clear();
|
|
52584
53157
|
outputs.clear();
|
|
52585
53158
|
activations.clear();
|
|
53159
|
+
emitFailures.clear();
|
|
52586
53160
|
presses.clear();
|
|
52587
53161
|
gesture = null;
|
|
52588
53162
|
router.clear();
|
|
52589
53163
|
editor.setScriptItems(/* @__PURE__ */ new Map());
|
|
53164
|
+
moved.clear();
|
|
52590
53165
|
hover = null;
|
|
52591
53166
|
composed = {
|
|
52592
53167
|
...composed,
|
|
@@ -52612,7 +53187,8 @@ function createBoardScriptController(options) {
|
|
|
52612
53187
|
const items = composeBoardScriptItems(editor.document, editor.scene, outputs, animation, camera, (owner, error) => host?.fault(owner, error instanceof Error ? error.message : String(error)), editor.gestureActive ? editor.scene.layout : void 0);
|
|
52613
53188
|
const presented = new Set([...outputs.values()].flatMap((output) => Object.keys(output.patches)));
|
|
52614
53189
|
for (const id of animation.keys()) if (!presented.has(id)) items.delete(id);
|
|
52615
|
-
|
|
53190
|
+
const at = now();
|
|
53191
|
+
for (const id of editor.setScriptItems(items)) if (items.has(id)) moved.set(id, at);
|
|
52616
53192
|
composed = {
|
|
52617
53193
|
version,
|
|
52618
53194
|
document: editor.document,
|
|
@@ -52789,6 +53365,9 @@ function createBoardScriptController(options) {
|
|
|
52789
53365
|
get hovering() {
|
|
52790
53366
|
return hover !== null;
|
|
52791
53367
|
},
|
|
53368
|
+
get hovered() {
|
|
53369
|
+
return hover;
|
|
53370
|
+
},
|
|
52792
53371
|
get paused() {
|
|
52793
53372
|
return paused;
|
|
52794
53373
|
},
|
|
@@ -52804,6 +53383,11 @@ function createBoardScriptController(options) {
|
|
|
52804
53383
|
animated = next;
|
|
52805
53384
|
},
|
|
52806
53385
|
compose,
|
|
53386
|
+
moving() {
|
|
53387
|
+
const at = now();
|
|
53388
|
+
for (const [id, changed] of moved) if (at - changed > MOTION_MS) moved.delete(id);
|
|
53389
|
+
return moved.keys();
|
|
53390
|
+
},
|
|
52807
53391
|
sync,
|
|
52808
53392
|
pointer,
|
|
52809
53393
|
key(event) {
|
|
@@ -52835,6 +53419,7 @@ function createBoardScriptController(options) {
|
|
|
52835
53419
|
return current && !paused ? boardShaderOwners(scriptDocument(), outputs, (id) => current.clock(id)) : [];
|
|
52836
53420
|
},
|
|
52837
53421
|
error: (id) => host?.error(id) ?? null,
|
|
53422
|
+
emitFailures,
|
|
52838
53423
|
async snapshot() {
|
|
52839
53424
|
const result = {};
|
|
52840
53425
|
await Promise.all([...outputs.keys()].map(async (id) => {
|
|
@@ -52863,6 +53448,24 @@ function createBoardScriptController(options) {
|
|
|
52863
53448
|
//#endregion
|
|
52864
53449
|
//#region ../sdk/src/board/testing/index.ts
|
|
52865
53450
|
const FRAME_MS = 1e3 / 60;
|
|
53451
|
+
function describeInteraction(editor) {
|
|
53452
|
+
const interaction = editor.interaction;
|
|
53453
|
+
const ids = () => editor.selection.join(", ");
|
|
53454
|
+
switch (interaction.type) {
|
|
53455
|
+
case "idle":
|
|
53456
|
+
case "pressing": return null;
|
|
53457
|
+
case "translating": return interaction.moved ? `move ${[...interaction.origin.keys()].join(", ")}` : null;
|
|
53458
|
+
case "resizing": return `resize ${ids()}`;
|
|
53459
|
+
case "rotating": return `rotate ${ids()}`;
|
|
53460
|
+
case "brushing": return "select box";
|
|
53461
|
+
case "panning": return interaction.moved ? "pan" : null;
|
|
53462
|
+
case "drawing": return "draw";
|
|
53463
|
+
case "creatingBox": return `create ${interaction.kind}`;
|
|
53464
|
+
case "creatingArrow": return "create arrow";
|
|
53465
|
+
case "creatingText": return "create text";
|
|
53466
|
+
case "draggingArrowHandle": return `arrow ${interaction.which} handle`;
|
|
53467
|
+
}
|
|
53468
|
+
}
|
|
52866
53469
|
async function createBoardScriptHarness(options) {
|
|
52867
53470
|
const renderer = options.renderer ?? await createNodeBoardRenderer();
|
|
52868
53471
|
const commits = [];
|
|
@@ -52943,15 +53546,52 @@ async function createBoardScriptHarness(options) {
|
|
|
52943
53546
|
pressure: .5
|
|
52944
53547
|
};
|
|
52945
53548
|
}
|
|
53549
|
+
let press = null;
|
|
53550
|
+
function editorHit(event) {
|
|
53551
|
+
const control = editor.tool === "select" && selectionTransformControlAt(editor.selectionTransform, event.world, editor.camera.zoom, event.pointerType, editor.controlOutset);
|
|
53552
|
+
if (control) return {
|
|
53553
|
+
on: "handle",
|
|
53554
|
+
handle: control.kind === "rotate" ? "rotate" : control.handle
|
|
53555
|
+
};
|
|
53556
|
+
const item = editor.pickAt(event.world, event.pointerType);
|
|
53557
|
+
if (item) return {
|
|
53558
|
+
on: "item",
|
|
53559
|
+
id: item.id,
|
|
53560
|
+
type: item.type
|
|
53561
|
+
};
|
|
53562
|
+
const under = editor.itemAt(event.world);
|
|
53563
|
+
return {
|
|
53564
|
+
on: "empty",
|
|
53565
|
+
...under ? { under: under.id } : {}
|
|
53566
|
+
};
|
|
53567
|
+
}
|
|
52946
53568
|
async function pointer(phase, point, input, pressed) {
|
|
52947
53569
|
const event = pointerEvent(point, phase, input, pressed);
|
|
52948
|
-
|
|
53570
|
+
const hit = phase === "down" ? editorHit(event) : null;
|
|
53571
|
+
const routed = controller.pointer(phase, event);
|
|
53572
|
+
const target = routed ? controller.hovered : null;
|
|
53573
|
+
if (phase === "down") press = {
|
|
53574
|
+
down: target ? {
|
|
53575
|
+
on: "script",
|
|
53576
|
+
...target
|
|
53577
|
+
} : hit,
|
|
53578
|
+
taken: target ? `script ${target.owner}/${target.target}` : null
|
|
53579
|
+
};
|
|
53580
|
+
if (!routed) {
|
|
52949
53581
|
if (phase === "down") editor.pointerDown(event);
|
|
52950
53582
|
else if (phase === "move") editor.pointerMove(event);
|
|
52951
53583
|
else editor.pointerUp(event);
|
|
52952
53584
|
}
|
|
53585
|
+
if (press && !routed) press.taken = describeInteraction(editor) ?? press.taken;
|
|
52953
53586
|
clock += FRAME_MS;
|
|
52954
53587
|
await frame();
|
|
53588
|
+
if (phase !== "up" || !press) return null;
|
|
53589
|
+
const done = {
|
|
53590
|
+
down: press.down,
|
|
53591
|
+
taken: press.taken ?? (press.down.on === "empty" ? "nothing" : "tap")
|
|
53592
|
+
};
|
|
53593
|
+
press = null;
|
|
53594
|
+
return done;
|
|
52955
53595
|
}
|
|
52956
53596
|
await frame();
|
|
52957
53597
|
return {
|
|
@@ -52967,6 +53607,10 @@ async function createBoardScriptHarness(options) {
|
|
|
52967
53607
|
},
|
|
52968
53608
|
output: (id) => controller.output(id),
|
|
52969
53609
|
error: (id) => controller.error(id),
|
|
53610
|
+
get emitFailures() {
|
|
53611
|
+
return controller.emitFailures;
|
|
53612
|
+
},
|
|
53613
|
+
status: () => runtime?.status() ?? [],
|
|
52970
53614
|
async advance(ms = FRAME_MS) {
|
|
52971
53615
|
const end = clock + ms;
|
|
52972
53616
|
while (clock < end) {
|
|
@@ -52977,14 +53621,14 @@ async function createBoardScriptHarness(options) {
|
|
|
52977
53621
|
pointer,
|
|
52978
53622
|
async tap(point, input) {
|
|
52979
53623
|
await pointer("down", point, input);
|
|
52980
|
-
await pointer("up", point, input);
|
|
53624
|
+
return await pointer("up", point, input);
|
|
52981
53625
|
},
|
|
52982
53626
|
async drag(points, input) {
|
|
52983
53627
|
const [first, ...rest] = points;
|
|
52984
|
-
if (!first) return;
|
|
53628
|
+
if (!first) return null;
|
|
52985
53629
|
await pointer("down", first, input);
|
|
52986
53630
|
for (const point of rest) await pointer("move", point, input);
|
|
52987
|
-
|
|
53631
|
+
return pointer("up", points.at(-1) ?? first, input);
|
|
52988
53632
|
},
|
|
52989
53633
|
async move(points, input) {
|
|
52990
53634
|
for (const point of points) await pointer("move", point, input, false);
|
|
@@ -53042,4 +53686,4 @@ async function createBoardScriptHarness(options) {
|
|
|
53042
53686
|
};
|
|
53043
53687
|
}
|
|
53044
53688
|
//#endregion
|
|
53045
|
-
export { BOARD_SCRIPT_DRAWING_EXAMPLE, BOARD_SCRIPT_RAIN_EXAMPLE, boardAnimatesScriptParams, boardAssetKey, boardAssetKeySource, boardFrameRegions, boardMediaRate, boardMediaSpans, boardPathTrack, boardPlacePatch, boardRegionStep, boardRenderTheme, boardScriptAttachments, boardSequence, boardSequencePatch, boardShaderParameters, boardTextureEdge, boardTexturePixels, boardTimedMedia, buildBoardScene, checkBoardShader, createBoardAnimationSampler, createBoardRenderSampler, createBoardScriptHarness, createNodeBoardRenderer, createNodeBoardScriptHost, describeBoardExportWarning, exportBoardImageBytes, hasBoardScripts, inspectBoardItems, inspectBoardScene, itemBounds, measureBoardText, parseBoardDocument, planBoardExport, prepareBoardExport, rectsIntersect, selectBoardExportAssets };
|
|
53689
|
+
export { BOARD_SCRIPT_DRAWING_EXAMPLE, BOARD_SCRIPT_RAIN_EXAMPLE, boardAnimatesScriptParams, boardAssetKey, boardAssetKeySource, boardAutoplayLoops, boardFrameRegions, boardMediaRate, boardMediaSpans, boardPathTrack, boardPlacePatch, boardRegionStep, boardRenderTheme, boardScriptAttachments, boardSequence, boardSequencePatch, boardShaderParameters, boardTextureEdge, boardTexturePixels, boardTimedMedia, buildBoardScene, checkBoardShader, createBoardAnimationSampler, createBoardRenderSampler, createBoardScriptHarness, createNodeBoardRenderer, createNodeBoardScriptHost, describeBoardExportWarning, describeBoardScriptLanes, exportBoardImageBytes, hasBoardScripts, inspectBoardItems, inspectBoardScene, itemBounds, measureBoardText, parseBoardDocument, planBoardExport, prepareBoardExport, rectsIntersect, selectBoardExportAssets };
|