@popcraft/cli 0.43.2 → 0.44.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/dist/popcraft.mjs +768 -623
- package/package.json +2 -2
package/dist/popcraft.mjs
CHANGED
|
@@ -1196,7 +1196,7 @@ function operations(spec = openapi) {
|
|
|
1196
1196
|
}
|
|
1197
1197
|
async function call(target2, method, path, opts = {}) {
|
|
1198
1198
|
const qs = new URLSearchParams(opts.query ?? {}).toString();
|
|
1199
|
-
const headers = { "user-agent": `popcraft-cli/${"0.
|
|
1199
|
+
const headers = { "user-agent": `popcraft-cli/${"0.44.0"}`, ...opts.headers };
|
|
1200
1200
|
if (target2.token) headers.authorization = `Bearer ${target2.token}`;
|
|
1201
1201
|
if (opts.contentType) headers["content-type"] = opts.contentType;
|
|
1202
1202
|
try {
|
|
@@ -2258,10 +2258,10 @@ function substituteTokens(node2, pattern, resolve7) {
|
|
|
2258
2258
|
return out;
|
|
2259
2259
|
});
|
|
2260
2260
|
if (!edits.length) return node2;
|
|
2261
|
-
const
|
|
2262
|
-
if (n.styledSegments)
|
|
2263
|
-
if (n.paragraphs)
|
|
2264
|
-
return { ...node2, ...
|
|
2261
|
+
const patch2 = { characters };
|
|
2262
|
+
if (n.styledSegments) patch2.styledSegments = shiftRanges(n.styledSegments, edits);
|
|
2263
|
+
if (n.paragraphs) patch2.paragraphs = shiftRanges(n.paragraphs, edits);
|
|
2264
|
+
return { ...node2, ...patch2 };
|
|
2265
2265
|
}
|
|
2266
2266
|
var init_text_tokens = __esm({
|
|
2267
2267
|
"lib/document/text-tokens.ts"() {
|
|
@@ -5577,9 +5577,9 @@ function instanceChildPatch(nodes, virtualId, props) {
|
|
|
5577
5577
|
if (norm3(rest[k2]) === norm3(child[k2])) delete rest[k2];
|
|
5578
5578
|
}
|
|
5579
5579
|
if (Object.keys(rest).length) overrides2[v.childId] = { ...overrides2[v.childId] || {}, ...rest };
|
|
5580
|
-
const
|
|
5581
|
-
if (componentProperties !== host.componentProperties)
|
|
5582
|
-
return { hostId: v.hostId, patch };
|
|
5580
|
+
const patch2 = { overrides: overrides2 };
|
|
5581
|
+
if (componentProperties !== host.componentProperties) patch2.componentProperties = componentProperties;
|
|
5582
|
+
return { hostId: v.hostId, patch: patch2 };
|
|
5583
5583
|
}
|
|
5584
5584
|
var NO_DEFS, defaultsMemo, boundTracks, BOUND;
|
|
5585
5585
|
var init_instances = __esm({
|
|
@@ -5652,7 +5652,7 @@ function materialise(nodes, hostId, root2) {
|
|
|
5652
5652
|
}
|
|
5653
5653
|
return ids2;
|
|
5654
5654
|
};
|
|
5655
|
-
const
|
|
5655
|
+
const frame3 = {
|
|
5656
5656
|
...root2,
|
|
5657
5657
|
id: hostId,
|
|
5658
5658
|
parentId: null,
|
|
@@ -5663,8 +5663,8 @@ function materialise(nodes, hostId, root2) {
|
|
|
5663
5663
|
layoutSizingHorizontal: host.layoutSizingHorizontal ?? root2.layoutSizingHorizontal,
|
|
5664
5664
|
layoutSizingVertical: root2.layoutSizingVertical
|
|
5665
5665
|
};
|
|
5666
|
-
out[hostId] =
|
|
5667
|
-
|
|
5666
|
+
out[hostId] = frame3;
|
|
5667
|
+
frame3.childIds = walk4(hostId, host, root2.childIds ?? []);
|
|
5668
5668
|
return out;
|
|
5669
5669
|
}
|
|
5670
5670
|
function layoutOf(nodes, hostId) {
|
|
@@ -6879,9 +6879,9 @@ function foldGuides(preset, width, height) {
|
|
|
6879
6879
|
const span3 = preset.folds.axis === "X" ? width : height;
|
|
6880
6880
|
return preset.folds.at.map((t3) => ({ id: v4_default(), axis: preset.folds.axis, pos: Math.round(t3 * span3), kind: "FOLD" }));
|
|
6881
6881
|
}
|
|
6882
|
-
function foldGuidesAt(preset,
|
|
6882
|
+
function foldGuidesAt(preset, frame3) {
|
|
6883
6883
|
if (!preset?.folds) return [];
|
|
6884
|
-
return foldGuides(preset,
|
|
6884
|
+
return foldGuides(preset, frame3.width, frame3.height).map((g) => ({ ...g, pos: g.pos + (g.axis === "X" ? frame3.x : frame3.y) }));
|
|
6885
6885
|
}
|
|
6886
6886
|
function createPrintPage(doc2, pageId2, opts = {}) {
|
|
6887
6887
|
const existing = listPrintPages(doc2, pageId2);
|
|
@@ -6889,7 +6889,7 @@ function createPrintPage(doc2, pageId2, opts = {}) {
|
|
|
6889
6889
|
const size6 = preset ? presetPx(preset) : { width: doc2.settings?.pageSize?.width ?? 816, height: doc2.settings?.pageSize?.height ?? 1056 };
|
|
6890
6890
|
const index2 = existing.length;
|
|
6891
6891
|
const last3 = existing[existing.length - 1];
|
|
6892
|
-
const
|
|
6892
|
+
const frame3 = createFrame({
|
|
6893
6893
|
name: opts.name ?? `Page ${index2 + 1}`,
|
|
6894
6894
|
...pagePositions([...existing, size6], basePageSize(doc2, existing.length ? existing : [size6]), doc2.settings?.facingPages)[index2],
|
|
6895
6895
|
width: size6.width,
|
|
@@ -6898,15 +6898,15 @@ function createPrintPage(doc2, pageId2, opts = {}) {
|
|
|
6898
6898
|
clipsContent: true,
|
|
6899
6899
|
print: { isPrintPage: true, index: index2, ...last3?.print?.masterId ? { masterId: last3.print.masterId } : {} }
|
|
6900
6900
|
});
|
|
6901
|
-
|
|
6902
|
-
return
|
|
6901
|
+
frame3.parentId = pageId2;
|
|
6902
|
+
return frame3;
|
|
6903
6903
|
}
|
|
6904
6904
|
function createMasterPage(doc2, pageId2, opts = {}) {
|
|
6905
6905
|
const masters = listMasterPages(doc2, pageId2);
|
|
6906
6906
|
const preset = presetById(doc2.settings?.pageSize?.presetId);
|
|
6907
6907
|
const size6 = preset ? presetPx(preset) : { width: doc2.settings?.pageSize?.width ?? 816, height: doc2.settings?.pageSize?.height ?? 1056 };
|
|
6908
6908
|
const index2 = masters.length;
|
|
6909
|
-
const
|
|
6909
|
+
const frame3 = createFrame({
|
|
6910
6910
|
name: opts.name ?? `${MASTER_NAMES[index2 % MASTER_NAMES.length]}-Master`,
|
|
6911
6911
|
...masterPosition(index2, size6),
|
|
6912
6912
|
width: size6.width,
|
|
@@ -6915,8 +6915,8 @@ function createMasterPage(doc2, pageId2, opts = {}) {
|
|
|
6915
6915
|
clipsContent: true,
|
|
6916
6916
|
print: { isPrintPage: true, isMaster: true, index: index2 }
|
|
6917
6917
|
});
|
|
6918
|
-
|
|
6919
|
-
return
|
|
6918
|
+
frame3.parentId = pageId2;
|
|
6919
|
+
return frame3;
|
|
6920
6920
|
}
|
|
6921
6921
|
function assignMaster(doc2, pageIds, masterId) {
|
|
6922
6922
|
const patches = {};
|
|
@@ -6929,11 +6929,11 @@ function assignMaster(doc2, pageIds, masterId) {
|
|
|
6929
6929
|
}
|
|
6930
6930
|
return patches;
|
|
6931
6931
|
}
|
|
6932
|
-
function effectiveMasterId(doc2,
|
|
6933
|
-
const print2 =
|
|
6934
|
-
if (!print2 || print2.isMaster || !
|
|
6935
|
-
const pages2 = listPrintPages(doc2,
|
|
6936
|
-
const index2 = pages2.findIndex((p2) => p2.id ===
|
|
6932
|
+
function effectiveMasterId(doc2, frame3) {
|
|
6933
|
+
const print2 = frame3.print;
|
|
6934
|
+
if (!print2 || print2.isMaster || !frame3.parentId) return void 0;
|
|
6935
|
+
const pages2 = listPrintPages(doc2, frame3.parentId);
|
|
6936
|
+
const index2 = pages2.findIndex((p2) => p2.id === frame3.id);
|
|
6937
6937
|
if (index2 < 0) return print2.masterId;
|
|
6938
6938
|
if (index2 === 0 && print2.masterIdFirst && isMasterPage(doc2.nodes[print2.masterIdFirst])) return print2.masterIdFirst;
|
|
6939
6939
|
if (doc2.settings?.facingPages && index2 >= 0) {
|
|
@@ -7018,7 +7018,7 @@ var init_print_pages = __esm({
|
|
|
7018
7018
|
x: index2 * (size6.width + gutter(size6.width)),
|
|
7019
7019
|
y: -(size6.height + 2 * gutter(size6.width))
|
|
7020
7020
|
});
|
|
7021
|
-
foldsOn = (guides,
|
|
7021
|
+
foldsOn = (guides, frame3) => (guides ?? []).filter((g) => g.kind === "FOLD" && (g.axis === "X" ? g.pos >= frame3.x && g.pos <= frame3.x + frame3.width : g.pos >= frame3.y && g.pos <= frame3.y + frame3.height));
|
|
7022
7022
|
MASTER_NAMES = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
7023
7023
|
}
|
|
7024
7024
|
});
|
|
@@ -7086,12 +7086,12 @@ function virtualRootOf(host, doc2) {
|
|
|
7086
7086
|
if (!host) return void 0;
|
|
7087
7087
|
if (host.type === "INSTANCE") return host.mainComponentId || void 0;
|
|
7088
7088
|
if (host.type === "FRAME") {
|
|
7089
|
-
const
|
|
7089
|
+
const frame3 = host;
|
|
7090
7090
|
if (doc2) {
|
|
7091
7091
|
const { effectiveMasterId: effectiveMasterId2 } = (init_print_pages(), __toCommonJS(print_pages_exports));
|
|
7092
|
-
return effectiveMasterId2(doc2,
|
|
7092
|
+
return effectiveMasterId2(doc2, frame3);
|
|
7093
7093
|
}
|
|
7094
|
-
return
|
|
7094
|
+
return frame3.print?.masterId;
|
|
7095
7095
|
}
|
|
7096
7096
|
return void 0;
|
|
7097
7097
|
}
|
|
@@ -7986,13 +7986,13 @@ function createResolver(nodes, scrollState, roots) {
|
|
|
7986
7986
|
const cached3 = frames.get(containerId);
|
|
7987
7987
|
if (cached3) return cached3;
|
|
7988
7988
|
const c2 = placementOf(containerId);
|
|
7989
|
-
let
|
|
7989
|
+
let frame3 = ROOT;
|
|
7990
7990
|
if (c2 && c2.node.type !== "PAGE") {
|
|
7991
7991
|
const scroll = scrollState?.[c2.node.id];
|
|
7992
|
-
|
|
7992
|
+
frame3 = scroll ? place(outerOf(c2.node), c2.node, scroll) : c2.p;
|
|
7993
7993
|
}
|
|
7994
|
-
frames.set(containerId,
|
|
7995
|
-
return
|
|
7994
|
+
frames.set(containerId, frame3);
|
|
7995
|
+
return frame3;
|
|
7996
7996
|
}
|
|
7997
7997
|
return {
|
|
7998
7998
|
matrixOf: (id3) => placementOf(id3)?.p.m ?? IDENTITY,
|
|
@@ -8275,8 +8275,8 @@ function getWorldRenderBounds(document2, nodeId2) {
|
|
|
8275
8275
|
if (clips2 || node2.type === "BOOLEAN") return;
|
|
8276
8276
|
const scene2 = scene3dOf(node2);
|
|
8277
8277
|
if (scene2) {
|
|
8278
|
-
const
|
|
8279
|
-
const toWorld = mul4(mul4(fromAffine(m),
|
|
8278
|
+
const frame3 = sceneFrame(scene2, node2.width, node2.height);
|
|
8279
|
+
const toWorld = mul4(mul4(fromAffine(m), frame3.projection), frame3.view);
|
|
8280
8280
|
for (const card of sceneLayers(document2.nodes, id3)) {
|
|
8281
8281
|
const pad = bleedFor(card.node);
|
|
8282
8282
|
for (const [x2, y] of projectRect(mul4(toWorld, card.model), -pad, -pad, card.node.width + pad, card.node.height + pad)) {
|
|
@@ -33419,6 +33419,19 @@ var init_en2 = __esm({
|
|
|
33419
33419
|
"docsSearch.placeholder": "Search guides, reference and file formats\u2026",
|
|
33420
33420
|
"docsSearch.title": "Search the docs",
|
|
33421
33421
|
"docsSearch.unavailable": "Search isn\u2019t available right now. Reload the page to try again.",
|
|
33422
|
+
"documentLoader.close": "Close",
|
|
33423
|
+
"documentLoader.errorFailed": "Something went wrong while opening this file. Nothing was lost \u2014 try again.",
|
|
33424
|
+
"documentLoader.errorTimeout": "This is taking much longer than it should. Check your connection and try again.",
|
|
33425
|
+
"documentLoader.errorTitle": "Couldn\u2019t open",
|
|
33426
|
+
"documentLoader.opening": "Opening {name}",
|
|
33427
|
+
"documentLoader.openingLabel": "Opening",
|
|
33428
|
+
"documentLoader.progress": "Progress",
|
|
33429
|
+
"documentLoader.retry": "Retry",
|
|
33430
|
+
"documentLoader.stageDownload": "Downloading",
|
|
33431
|
+
"documentLoader.stageFirstFrame": "First frame",
|
|
33432
|
+
"documentLoader.stageMedia": "Fonts and media",
|
|
33433
|
+
"documentLoader.stagePrepare": "Preparing",
|
|
33434
|
+
"documentLoader.untitled": "Your file",
|
|
33422
33435
|
"dopesheet.keyframe": "{n} keyframe{value} \xB7 {formatTime}",
|
|
33423
33436
|
"dopesheet.keyInspector": "Key inspector",
|
|
33424
33437
|
"dopesheet.keyMenu": "Key menu",
|
|
@@ -34547,7 +34560,6 @@ var init_en2 = __esm({
|
|
|
34547
34560
|
"newFileDialog.manageTemplate": "Manage template",
|
|
34548
34561
|
"newFileDialog.newFile": "New file",
|
|
34549
34562
|
"newFileDialog.noTemplatesMatch": "No templates match.",
|
|
34550
|
-
"newFileDialog.openingName": "Opening {name}\u2026",
|
|
34551
34563
|
"newFileDialog.pageSizes": "Page sizes",
|
|
34552
34564
|
"newFileDialog.public": "Public",
|
|
34553
34565
|
"newFileDialog.publishToMarketplace": "Publish to marketplace",
|
|
@@ -39325,7 +39337,6 @@ var require_es = __commonJS({
|
|
|
39325
39337
|
"newFileDialog.manageTemplate": "Administrar plantilla",
|
|
39326
39338
|
"newFileDialog.newFile": "Nuevo archivo",
|
|
39327
39339
|
"newFileDialog.noTemplatesMatch": "Ninguna plantilla coincide.",
|
|
39328
|
-
"newFileDialog.openingName": "Abriendo {name}\u2026",
|
|
39329
39340
|
"newFileDialog.pageSizes": "Tama\xF1os de p\xE1gina",
|
|
39330
39341
|
"newFileDialog.public": "P\xFAblico",
|
|
39331
39342
|
"newFileDialog.publishToMarketplace": "Publicar en el marketplace",
|
|
@@ -44103,7 +44114,6 @@ var require_fr = __commonJS({
|
|
|
44103
44114
|
"newFileDialog.manageTemplate": "G\xE9rer le mod\xE8le",
|
|
44104
44115
|
"newFileDialog.newFile": "Nouveau fichier",
|
|
44105
44116
|
"newFileDialog.noTemplatesMatch": "Aucun mod\xE8le ne correspond.",
|
|
44106
|
-
"newFileDialog.openingName": "Ouverture de {name}\u2026",
|
|
44107
44117
|
"newFileDialog.pageSizes": "Tailles de page",
|
|
44108
44118
|
"newFileDialog.public": "Public",
|
|
44109
44119
|
"newFileDialog.publishToMarketplace": "Publier sur la place de march\xE9",
|
|
@@ -48881,7 +48891,6 @@ var require_de = __commonJS({
|
|
|
48881
48891
|
"newFileDialog.manageTemplate": "Vorlage verwalten",
|
|
48882
48892
|
"newFileDialog.newFile": "Neue Datei",
|
|
48883
48893
|
"newFileDialog.noTemplatesMatch": "Keine Vorlagen gefunden.",
|
|
48884
|
-
"newFileDialog.openingName": "{name} wird ge\xF6ffnet\u2026",
|
|
48885
48894
|
"newFileDialog.pageSizes": "Seitengr\xF6\xDFen",
|
|
48886
48895
|
"newFileDialog.public": "\xD6ffentlich",
|
|
48887
48896
|
"newFileDialog.publishToMarketplace": "Auf dem Marktplatz ver\xF6ffentlichen",
|
|
@@ -53659,7 +53668,6 @@ var require_it = __commonJS({
|
|
|
53659
53668
|
"newFileDialog.manageTemplate": "Gestisci modello",
|
|
53660
53669
|
"newFileDialog.newFile": "Nuovo file",
|
|
53661
53670
|
"newFileDialog.noTemplatesMatch": "Nessun modello corrispondente.",
|
|
53662
|
-
"newFileDialog.openingName": "Apertura di {name}\u2026",
|
|
53663
53671
|
"newFileDialog.pageSizes": "Dimensioni pagina",
|
|
53664
53672
|
"newFileDialog.public": "Pubblico",
|
|
53665
53673
|
"newFileDialog.publishToMarketplace": "Pubblica sul marketplace",
|
|
@@ -58437,7 +58445,6 @@ var require_pt_BR = __commonJS({
|
|
|
58437
58445
|
"newFileDialog.manageTemplate": "Gerenciar modelo",
|
|
58438
58446
|
"newFileDialog.newFile": "Novo arquivo",
|
|
58439
58447
|
"newFileDialog.noTemplatesMatch": "Nenhum modelo corresponde.",
|
|
58440
|
-
"newFileDialog.openingName": "Abrindo {name}\u2026",
|
|
58441
58448
|
"newFileDialog.pageSizes": "Tamanhos de p\xE1gina",
|
|
58442
58449
|
"newFileDialog.public": "P\xFAblico",
|
|
58443
58450
|
"newFileDialog.publishToMarketplace": "Publicar no marketplace",
|
|
@@ -63215,7 +63222,6 @@ var require_ja = __commonJS({
|
|
|
63215
63222
|
"newFileDialog.manageTemplate": "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u7BA1\u7406",
|
|
63216
63223
|
"newFileDialog.newFile": "\u65B0\u898F\u30D5\u30A1\u30A4\u30EB",
|
|
63217
63224
|
"newFileDialog.noTemplatesMatch": "\u4E00\u81F4\u3059\u308B\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",
|
|
63218
|
-
"newFileDialog.openingName": "{name}\u3092\u958B\u3044\u3066\u3044\u307E\u3059\u2026",
|
|
63219
63225
|
"newFileDialog.pageSizes": "\u30DA\u30FC\u30B8\u30B5\u30A4\u30BA",
|
|
63220
63226
|
"newFileDialog.public": "\u516C\u958B",
|
|
63221
63227
|
"newFileDialog.publishToMarketplace": "\u30DE\u30FC\u30B1\u30C3\u30C8\u30D7\u30EC\u30A4\u30B9\u306B\u516C\u958B",
|
|
@@ -67993,7 +67999,6 @@ var require_ko = __commonJS({
|
|
|
67993
67999
|
"newFileDialog.manageTemplate": "\uD15C\uD50C\uB9BF \uAD00\uB9AC",
|
|
67994
68000
|
"newFileDialog.newFile": "\uC0C8 \uD30C\uC77C",
|
|
67995
68001
|
"newFileDialog.noTemplatesMatch": "\uC77C\uCE58\uD558\uB294 \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.",
|
|
67996
|
-
"newFileDialog.openingName": "{name} \uC5EC\uB294 \uC911\u2026",
|
|
67997
68002
|
"newFileDialog.pageSizes": "\uD398\uC774\uC9C0 \uD06C\uAE30",
|
|
67998
68003
|
"newFileDialog.public": "\uACF5\uAC1C",
|
|
67999
68004
|
"newFileDialog.publishToMarketplace": "\uB9C8\uCF13\uD50C\uB808\uC774\uC2A4\uC5D0 \uAC8C\uC2DC",
|
|
@@ -72771,7 +72776,6 @@ var require_zh_CN = __commonJS({
|
|
|
72771
72776
|
"newFileDialog.manageTemplate": "\u7BA1\u7406\u6A21\u677F",
|
|
72772
72777
|
"newFileDialog.newFile": "\u65B0\u5EFA\u6587\u4EF6",
|
|
72773
72778
|
"newFileDialog.noTemplatesMatch": "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u677F\u3002",
|
|
72774
|
-
"newFileDialog.openingName": "\u6B63\u5728\u6253\u5F00 {name}\u2026",
|
|
72775
72779
|
"newFileDialog.pageSizes": "\u9875\u9762\u5C3A\u5BF8",
|
|
72776
72780
|
"newFileDialog.public": "\u516C\u5F00",
|
|
72777
72781
|
"newFileDialog.publishToMarketplace": "\u53D1\u5E03\u5230\u5E02\u573A",
|
|
@@ -77549,7 +77553,6 @@ var require_zh_TW = __commonJS({
|
|
|
77549
77553
|
"newFileDialog.manageTemplate": "\u7BA1\u7406\u7BC4\u672C",
|
|
77550
77554
|
"newFileDialog.newFile": "\u65B0\u589E\u6A94\u6848",
|
|
77551
77555
|
"newFileDialog.noTemplatesMatch": "\u7121\u7B26\u5408\u7684\u7BC4\u672C\u3002",
|
|
77552
|
-
"newFileDialog.openingName": "\u6B63\u5728\u958B\u555F{name}\u2026",
|
|
77553
77556
|
"newFileDialog.pageSizes": "\u9801\u9762\u5C3A\u5BF8",
|
|
77554
77557
|
"newFileDialog.public": "\u516C\u958B",
|
|
77555
77558
|
"newFileDialog.publishToMarketplace": "\u767C\u4F48\u81F3\u5E02\u96C6",
|
|
@@ -82327,7 +82330,6 @@ var require_ru = __commonJS({
|
|
|
82327
82330
|
"newFileDialog.manageTemplate": "\u0423\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0448\u0430\u0431\u043B\u043E\u043D\u043E\u043C",
|
|
82328
82331
|
"newFileDialog.newFile": "\u041D\u043E\u0432\u044B\u0439 \u0444\u0430\u0439\u043B",
|
|
82329
82332
|
"newFileDialog.noTemplatesMatch": "\u0428\u0430\u0431\u043B\u043E\u043D\u044B \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B.",
|
|
82330
|
-
"newFileDialog.openingName": "\u041E\u0442\u043A\u0440\u044B\u0442\u0438\u0435 {name}\u2026",
|
|
82331
82333
|
"newFileDialog.pageSizes": "\u0420\u0430\u0437\u043C\u0435\u0440\u044B \u0441\u0442\u0440\u0430\u043D\u0438\u0446",
|
|
82332
82334
|
"newFileDialog.public": "\u041F\u0443\u0431\u043B\u0438\u0447\u043D\u044B\u0439",
|
|
82333
82335
|
"newFileDialog.publishToMarketplace": "\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u0442\u044C \u043D\u0430 \u0442\u043E\u0440\u0433\u043E\u0432\u043E\u0439 \u043F\u043B\u043E\u0449\u0430\u0434\u043A\u0435",
|
|
@@ -87105,7 +87107,6 @@ var require_ar = __commonJS({
|
|
|
87105
87107
|
"newFileDialog.manageTemplate": "\u0625\u062F\u0627\u0631\u0629 \u0627\u0644\u0642\u0627\u0644\u0628",
|
|
87106
87108
|
"newFileDialog.newFile": "\u0645\u0644\u0641 \u062C\u062F\u064A\u062F",
|
|
87107
87109
|
"newFileDialog.noTemplatesMatch": "\u0644\u0627 \u062A\u0648\u062C\u062F \u0642\u0648\u0627\u0644\u0628 \u0645\u0637\u0627\u0628\u0642\u0629.",
|
|
87108
|
-
"newFileDialog.openingName": "\u062C\u0627\u0631\u064D \u0641\u062A\u062D {name}\u2026",
|
|
87109
87110
|
"newFileDialog.pageSizes": "\u0623\u062D\u062C\u0627\u0645 \u0627\u0644\u0635\u0641\u062D\u0627\u062A",
|
|
87110
87111
|
"newFileDialog.public": "\u0639\u0627\u0645",
|
|
87111
87112
|
"newFileDialog.publishToMarketplace": "\u0627\u0644\u0646\u0634\u0631 \u0625\u0644\u0649 \u0627\u0644\u0645\u062A\u062C\u0631",
|
|
@@ -91883,7 +91884,6 @@ var require_hi = __commonJS({
|
|
|
91883
91884
|
"newFileDialog.manageTemplate": "\u091F\u0947\u092E\u094D\u092A\u0932\u0947\u091F \u092A\u094D\u0930\u092C\u0902\u0927\u093F\u0924 \u0915\u0930\u0947\u0902",
|
|
91884
91885
|
"newFileDialog.newFile": "\u0928\u0908 \u092B\u093C\u093E\u0907\u0932",
|
|
91885
91886
|
"newFileDialog.noTemplatesMatch": "\u0915\u094B\u0908 \u091F\u0947\u092E\u094D\u092A\u0932\u0947\u091F \u092E\u0947\u0932 \u0928\u0939\u0940\u0902 \u0916\u093E\u0924\u093E\u0964",
|
|
91886
|
-
"newFileDialog.openingName": "{name} \u0916\u094B\u0932\u093E \u091C\u093E \u0930\u0939\u093E \u0939\u0948\u2026",
|
|
91887
91887
|
"newFileDialog.pageSizes": "\u092A\u0943\u0937\u094D\u0920 \u0906\u0915\u093E\u0930",
|
|
91888
91888
|
"newFileDialog.public": "\u0938\u093E\u0930\u094D\u0935\u091C\u0928\u093F\u0915",
|
|
91889
91889
|
"newFileDialog.publishToMarketplace": "\u092E\u093E\u0930\u094D\u0915\u0947\u091F\u092A\u094D\u0932\u0947\u0938 \u092A\u0930 \u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924 \u0915\u0930\u0947\u0902",
|
|
@@ -97295,10 +97295,10 @@ function detachInstances(nodes, ids2) {
|
|
|
97295
97295
|
into[newId3] = node2;
|
|
97296
97296
|
return newId3;
|
|
97297
97297
|
};
|
|
97298
|
-
const
|
|
97299
|
-
for (const k2 of INSTANCE_ONLY) delete
|
|
97300
|
-
|
|
97301
|
-
into[id3] =
|
|
97298
|
+
const frame3 = { ...inst, type: "FRAME" };
|
|
97299
|
+
for (const k2 of INSTANCE_ONLY) delete frame3[k2];
|
|
97300
|
+
frame3.childIds = (nodes[inst.mainComponentId].childIds ?? []).map((c2) => copy2(`${id3}::${c2}`, id3)).filter((c2) => !!c2);
|
|
97301
|
+
into[id3] = frame3;
|
|
97302
97302
|
}
|
|
97303
97303
|
return out ?? nodes;
|
|
97304
97304
|
}
|
|
@@ -97398,22 +97398,22 @@ function diffDocuments(before, after) {
|
|
|
97398
97398
|
}
|
|
97399
97399
|
return { nodes, fields };
|
|
97400
97400
|
}
|
|
97401
|
-
function isEmptyPatch(
|
|
97402
|
-
return
|
|
97401
|
+
function isEmptyPatch(patch2) {
|
|
97402
|
+
return patch2.nodes.size === 0 && patch2.fields.size === 0;
|
|
97403
97403
|
}
|
|
97404
|
-
function applyPatch(doc2,
|
|
97405
|
-
if (isEmptyPatch(
|
|
97404
|
+
function applyPatch(doc2, patch2, side) {
|
|
97405
|
+
if (isEmptyPatch(patch2)) return doc2;
|
|
97406
97406
|
let nodes = doc2.nodes;
|
|
97407
|
-
if (
|
|
97407
|
+
if (patch2.nodes.size > 0) {
|
|
97408
97408
|
nodes = { ...doc2.nodes };
|
|
97409
|
-
for (const [id3, change2] of
|
|
97409
|
+
for (const [id3, change2] of patch2.nodes) {
|
|
97410
97410
|
const value3 = change2[side];
|
|
97411
97411
|
if (value3 === void 0) delete nodes[id3];
|
|
97412
97412
|
else nodes[id3] = value3;
|
|
97413
97413
|
}
|
|
97414
97414
|
}
|
|
97415
97415
|
const out = { ...doc2, nodes };
|
|
97416
|
-
for (const [k2, change2] of
|
|
97416
|
+
for (const [k2, change2] of patch2.fields) {
|
|
97417
97417
|
const value3 = change2[side];
|
|
97418
97418
|
if (value3 === void 0) delete out[k2];
|
|
97419
97419
|
else out[k2] = value3;
|
|
@@ -97851,36 +97851,36 @@ function applyAutoLayout(doc2) {
|
|
|
97851
97851
|
const clampedWidth = (w, c2) => Math.max(c2.minWidth ?? 1, Math.min(c2.maxWidth ?? Infinity, w));
|
|
97852
97852
|
const clampedHeight = (h, c2) => Math.max(c2.minHeight ?? 1, Math.min(c2.maxHeight ?? Infinity, h));
|
|
97853
97853
|
if (isAutoLayout(node2)) {
|
|
97854
|
-
const
|
|
97854
|
+
const frame3 = cloneNode(nodeId2);
|
|
97855
97855
|
let totalChildrenPrimary = 0;
|
|
97856
97856
|
let maxChildrenCounter = 0;
|
|
97857
|
-
const isHorizontal =
|
|
97858
|
-
const isGrid2 =
|
|
97859
|
-
const paddingX =
|
|
97860
|
-
const paddingY =
|
|
97861
|
-
const itemSpacing =
|
|
97862
|
-
const counterSpacing =
|
|
97857
|
+
const isHorizontal = frame3.layoutMode === "HORIZONTAL";
|
|
97858
|
+
const isGrid2 = frame3.layoutMode === "GRID";
|
|
97859
|
+
const paddingX = frame3.padding.left + frame3.padding.right;
|
|
97860
|
+
const paddingY = frame3.padding.top + frame3.padding.bottom;
|
|
97861
|
+
const itemSpacing = frame3.itemSpacing;
|
|
97862
|
+
const counterSpacing = frame3.counterAxisSpacing ?? itemSpacing;
|
|
97863
97863
|
let fillChildrenCount = 0;
|
|
97864
|
-
const childIds =
|
|
97864
|
+
const childIds = frame3.childIds.filter((id3) => {
|
|
97865
97865
|
const child = newNodes[id3];
|
|
97866
97866
|
return child && child.visible && child.layoutPositioning !== "ABSOLUTE";
|
|
97867
97867
|
});
|
|
97868
|
-
for (const id3 of
|
|
97868
|
+
for (const id3 of frame3.childIds) {
|
|
97869
97869
|
const child = newNodes[id3];
|
|
97870
97870
|
if (child && child.visible && child.layoutPositioning === "ABSOLUTE") measureNode(id3);
|
|
97871
97871
|
}
|
|
97872
97872
|
let intrinsicW = 0;
|
|
97873
97873
|
let intrinsicH = 0;
|
|
97874
97874
|
if (isGrid2) {
|
|
97875
|
-
const cols =
|
|
97876
|
-
const rows =
|
|
97877
|
-
const minColW =
|
|
97878
|
-
const minRowH =
|
|
97875
|
+
const cols = frame3.layoutGridColumns ?? "AUTO";
|
|
97876
|
+
const rows = frame3.layoutGridRows ?? "AUTO";
|
|
97877
|
+
const minColW = frame3.layoutGridMinColumnWidth ?? 100;
|
|
97878
|
+
const minRowH = frame3.layoutGridMinRowHeight ?? 100;
|
|
97879
97879
|
let actualCols = 1;
|
|
97880
|
-
let colSizes =
|
|
97880
|
+
let colSizes = frame3.layoutGridColumnSizes || [];
|
|
97881
97881
|
if (cols === "AUTO") {
|
|
97882
|
-
if (
|
|
97883
|
-
const availW =
|
|
97882
|
+
if (frame3.layoutSizingHorizontal === "FIXED" || frame3.layoutSizingHorizontal === "FILL") {
|
|
97883
|
+
const availW = frame3.width - paddingX;
|
|
97884
97884
|
actualCols = Math.max(1, Math.floor((availW + itemSpacing) / (minColW + itemSpacing)));
|
|
97885
97885
|
} else {
|
|
97886
97886
|
actualCols = Math.max(1, childIds.length);
|
|
@@ -97893,7 +97893,7 @@ function applyAutoLayout(doc2) {
|
|
|
97893
97893
|
}
|
|
97894
97894
|
}
|
|
97895
97895
|
let actualRows = 1;
|
|
97896
|
-
let rowSizes =
|
|
97896
|
+
let rowSizes = frame3.layoutGridRowSizes || [];
|
|
97897
97897
|
if (rows === "AUTO") {
|
|
97898
97898
|
actualRows = Math.max(1, Math.ceil(childIds.length / actualCols));
|
|
97899
97899
|
rowSizes = Array.from({ length: actualRows }).map(() => ({ sizing: "HUG", value: "113", min: minRowH }));
|
|
@@ -97953,18 +97953,18 @@ function applyAutoLayout(doc2) {
|
|
|
97953
97953
|
const totalSpacing = Math.max(0, childIds.length - 1) * itemSpacing;
|
|
97954
97954
|
intrinsicW = isHorizontal ? totalChildrenPrimary + totalSpacing + paddingX : maxChildrenCounter + paddingX;
|
|
97955
97955
|
intrinsicH = isHorizontal ? maxChildrenCounter + paddingY : totalChildrenPrimary + totalSpacing + paddingY;
|
|
97956
|
-
if (wraps(
|
|
97957
|
-
const lines2 = wrapLines(
|
|
97956
|
+
if (wraps(frame3)) {
|
|
97957
|
+
const lines2 = wrapLines(frame3, childIds, (id3) => measureNode(id3));
|
|
97958
97958
|
const counter = lines2.reduce((a, l) => a + l.counter, 0) + Math.max(0, lines2.length - 1) * counterSpacing;
|
|
97959
97959
|
if (isHorizontal) intrinsicH = counter + paddingY;
|
|
97960
97960
|
else intrinsicW = counter + paddingX;
|
|
97961
97961
|
}
|
|
97962
97962
|
}
|
|
97963
|
-
if (
|
|
97964
|
-
if (
|
|
97963
|
+
if (frame3.layoutSizingHorizontal === "HUG") frame3.width = clampedWidth(intrinsicW, frame3);
|
|
97964
|
+
if (frame3.layoutSizingVertical === "HUG") frame3.height = clampedHeight(intrinsicH, frame3);
|
|
97965
97965
|
return {
|
|
97966
|
-
intrinsicWidth: clampedWidth(
|
|
97967
|
-
intrinsicHeight: clampedHeight(
|
|
97966
|
+
intrinsicWidth: clampedWidth(frame3.layoutSizingHorizontal === "HUG" ? intrinsicW : frame3.width, frame3),
|
|
97967
|
+
intrinsicHeight: clampedHeight(frame3.layoutSizingVertical === "HUG" ? intrinsicH : frame3.height, frame3)
|
|
97968
97968
|
};
|
|
97969
97969
|
} else {
|
|
97970
97970
|
let height = node2.height;
|
|
@@ -97990,18 +97990,18 @@ function applyAutoLayout(doc2) {
|
|
|
97990
97990
|
function layoutNode(nodeId2) {
|
|
97991
97991
|
const node2 = newNodes[nodeId2];
|
|
97992
97992
|
if (!isAutoLayout(node2)) return;
|
|
97993
|
-
const
|
|
97994
|
-
const isHorizontal =
|
|
97995
|
-
const isGrid2 =
|
|
97996
|
-
const paddingX =
|
|
97997
|
-
const paddingY =
|
|
97998
|
-
const itemSpacing =
|
|
97999
|
-
const counterSpacing =
|
|
98000
|
-
const childIds =
|
|
97993
|
+
const frame3 = node2;
|
|
97994
|
+
const isHorizontal = frame3.layoutMode === "HORIZONTAL";
|
|
97995
|
+
const isGrid2 = frame3.layoutMode === "GRID";
|
|
97996
|
+
const paddingX = frame3.padding.left + frame3.padding.right;
|
|
97997
|
+
const paddingY = frame3.padding.top + frame3.padding.bottom;
|
|
97998
|
+
const itemSpacing = frame3.itemSpacing;
|
|
97999
|
+
const counterSpacing = frame3.counterAxisSpacing ?? itemSpacing;
|
|
98000
|
+
const childIds = frame3.childIds.filter((id3) => {
|
|
98001
98001
|
const child = newNodes[id3];
|
|
98002
98002
|
return child && child.visible && child.layoutPositioning !== "ABSOLUTE";
|
|
98003
98003
|
});
|
|
98004
|
-
const absoluteChildIds =
|
|
98004
|
+
const absoluteChildIds = frame3.childIds.filter((id3) => {
|
|
98005
98005
|
const child = newNodes[id3];
|
|
98006
98006
|
return child && child.visible && child.layoutPositioning === "ABSOLUTE";
|
|
98007
98007
|
});
|
|
@@ -98013,14 +98013,14 @@ function applyAutoLayout(doc2) {
|
|
|
98013
98013
|
const clampedWidth = (w, c2) => Math.max(c2.minWidth ?? 1, Math.min(c2.maxWidth ?? Infinity, w));
|
|
98014
98014
|
const clampedHeight = (h, c2) => Math.max(c2.minHeight ?? 1, Math.min(c2.maxHeight ?? Infinity, h));
|
|
98015
98015
|
if (isGrid2) {
|
|
98016
|
-
const cols =
|
|
98017
|
-
const rows =
|
|
98018
|
-
const minColW =
|
|
98019
|
-
const minRowH =
|
|
98016
|
+
const cols = frame3.layoutGridColumns ?? "AUTO";
|
|
98017
|
+
const rows = frame3.layoutGridRows ?? "AUTO";
|
|
98018
|
+
const minColW = frame3.layoutGridMinColumnWidth ?? 100;
|
|
98019
|
+
const minRowH = frame3.layoutGridMinRowHeight ?? 100;
|
|
98020
98020
|
let actualCols = 1;
|
|
98021
|
-
let colSizes =
|
|
98021
|
+
let colSizes = frame3.layoutGridColumnSizes || [];
|
|
98022
98022
|
if (cols === "AUTO") {
|
|
98023
|
-
const availW =
|
|
98023
|
+
const availW = frame3.width - paddingX;
|
|
98024
98024
|
actualCols = Math.max(1, Math.floor((availW + itemSpacing) / (minColW + itemSpacing)));
|
|
98025
98025
|
colSizes = Array.from({ length: actualCols }).map(() => ({ sizing: "FILL", value: "1fr" }));
|
|
98026
98026
|
} else {
|
|
@@ -98030,7 +98030,7 @@ function applyAutoLayout(doc2) {
|
|
|
98030
98030
|
}
|
|
98031
98031
|
}
|
|
98032
98032
|
let actualRows = 1;
|
|
98033
|
-
let rowSizes =
|
|
98033
|
+
let rowSizes = frame3.layoutGridRowSizes || [];
|
|
98034
98034
|
if (rows === "AUTO") {
|
|
98035
98035
|
actualRows = Math.max(1, Math.ceil(childIds.length / actualCols));
|
|
98036
98036
|
rowSizes = Array.from({ length: actualRows }).map(() => ({ sizing: "HUG", value: "113", min: minRowH }));
|
|
@@ -98058,7 +98058,7 @@ function applyAutoLayout(doc2) {
|
|
|
98058
98058
|
else if (s.sizing === "HUG") fixedColW += colMaxHugs[c2];
|
|
98059
98059
|
else if (s.sizing === "FILL") totalColFr += parseFloat(s.value) || 1;
|
|
98060
98060
|
});
|
|
98061
|
-
const availColW = Math.max(0,
|
|
98061
|
+
const availColW = Math.max(0, frame3.width - paddingX - Math.max(0, actualCols - 1) * itemSpacing - fixedColW);
|
|
98062
98062
|
const colW = new Array(actualCols).fill(0);
|
|
98063
98063
|
colSizes.forEach((s, c2) => {
|
|
98064
98064
|
if (s.sizing === "FIXED") colW[c2] = parseFloat(s.value) || 0;
|
|
@@ -98072,7 +98072,7 @@ function applyAutoLayout(doc2) {
|
|
|
98072
98072
|
else if (s.sizing === "HUG") fixedRowH += Math.max(s.min ?? 0, rowMaxHugs[r]);
|
|
98073
98073
|
else if (s.sizing === "FILL") totalRowFr += parseFloat(s.value) || 1;
|
|
98074
98074
|
});
|
|
98075
|
-
const availRowH = Math.max(0,
|
|
98075
|
+
const availRowH = Math.max(0, frame3.height - paddingY - Math.max(0, actualRows - 1) * counterSpacing - fixedRowH);
|
|
98076
98076
|
const rowH = new Array(actualRows).fill(0);
|
|
98077
98077
|
rowSizes.forEach((s, r) => {
|
|
98078
98078
|
if (s.sizing === "FIXED") rowH[r] = parseFloat(s.value) || 0;
|
|
@@ -98080,13 +98080,13 @@ function applyAutoLayout(doc2) {
|
|
|
98080
98080
|
else if (s.sizing === "FILL") rowH[r] = totalRowFr > 0 ? availRowH * ((parseFloat(s.value) || 1) / totalRowFr) : 0;
|
|
98081
98081
|
});
|
|
98082
98082
|
const colX = new Array(actualCols).fill(0);
|
|
98083
|
-
let currX =
|
|
98083
|
+
let currX = frame3.padding.left;
|
|
98084
98084
|
for (let c2 = 0; c2 < actualCols; c2++) {
|
|
98085
98085
|
colX[c2] = currX;
|
|
98086
98086
|
currX += colW[c2] + itemSpacing;
|
|
98087
98087
|
}
|
|
98088
98088
|
const rowY = new Array(actualRows).fill(0);
|
|
98089
|
-
let currY =
|
|
98089
|
+
let currY = frame3.padding.top;
|
|
98090
98090
|
for (let r = 0; r < actualRows; r++) {
|
|
98091
98091
|
rowY[r] = currY;
|
|
98092
98092
|
currY += rowH[r] + counterSpacing;
|
|
@@ -98101,10 +98101,10 @@ function applyAutoLayout(doc2) {
|
|
|
98101
98101
|
const cellY = rowY[r];
|
|
98102
98102
|
child.x = cellX;
|
|
98103
98103
|
child.y = cellY;
|
|
98104
|
-
if (
|
|
98104
|
+
if (frame3.counterAxisAlignItems === "CENTER") {
|
|
98105
98105
|
child.x = cellX + (colW[c2] - child.width) / 2;
|
|
98106
98106
|
child.y = cellY + (rowH[r] - child.height) / 2;
|
|
98107
|
-
} else if (
|
|
98107
|
+
} else if (frame3.counterAxisAlignItems === "MAX") {
|
|
98108
98108
|
child.x = cellX + (colW[c2] - child.width);
|
|
98109
98109
|
child.y = cellY + (rowH[r] - child.height);
|
|
98110
98110
|
}
|
|
@@ -98124,34 +98124,34 @@ function applyAutoLayout(doc2) {
|
|
|
98124
98124
|
}
|
|
98125
98125
|
});
|
|
98126
98126
|
const totalSpacing = Math.max(0, childIds.length - 1) * itemSpacing;
|
|
98127
|
-
const availablePrimary = (isHorizontal ?
|
|
98127
|
+
const availablePrimary = (isHorizontal ? frame3.width - paddingX : frame3.height - paddingY) - totalSpacing - usedPrimarySpace;
|
|
98128
98128
|
const fillPrimarySize = fillPrimaryCount > 0 ? Math.max(0, availablePrimary / fillPrimaryCount) : 0;
|
|
98129
98129
|
childIds.forEach((childId) => {
|
|
98130
98130
|
const child = cloneNode(childId);
|
|
98131
98131
|
if (isHorizontal) {
|
|
98132
98132
|
if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(fillPrimarySize, child);
|
|
98133
|
-
if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(Math.max(0,
|
|
98133
|
+
if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(Math.max(0, frame3.height - paddingY), child);
|
|
98134
98134
|
} else {
|
|
98135
98135
|
if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(fillPrimarySize, child);
|
|
98136
|
-
if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(Math.max(0,
|
|
98136
|
+
if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(Math.max(0, frame3.width - paddingX), child);
|
|
98137
98137
|
}
|
|
98138
98138
|
});
|
|
98139
|
-
if (wraps(
|
|
98140
|
-
const lines2 = wrapLines(
|
|
98141
|
-
let counterPos = isHorizontal ?
|
|
98142
|
-
const availPrimaryTotal = isHorizontal ?
|
|
98139
|
+
if (wraps(frame3)) {
|
|
98140
|
+
const lines2 = wrapLines(frame3, childIds, (id3) => ({ intrinsicWidth: newNodes[id3].width, intrinsicHeight: newNodes[id3].height }));
|
|
98141
|
+
let counterPos = isHorizontal ? frame3.padding.top : frame3.padding.left;
|
|
98142
|
+
const availPrimaryTotal = isHorizontal ? frame3.width - paddingX : frame3.height - paddingY;
|
|
98143
98143
|
for (const line of lines2) {
|
|
98144
98144
|
const used = line.ids.reduce((a, id3) => a + (isHorizontal ? newNodes[id3].width : newNodes[id3].height), 0) + Math.max(0, line.ids.length - 1) * itemSpacing;
|
|
98145
|
-
let primary = isHorizontal ?
|
|
98145
|
+
let primary = isHorizontal ? frame3.padding.left : frame3.padding.top;
|
|
98146
98146
|
let extra = 0;
|
|
98147
98147
|
const free2 = Math.max(0, availPrimaryTotal - used);
|
|
98148
|
-
if (
|
|
98149
|
-
else if (
|
|
98150
|
-
else if (
|
|
98148
|
+
if (frame3.primaryAxisAlignItems === "SPACE_BETWEEN" && line.ids.length > 1) extra = free2 / (line.ids.length - 1);
|
|
98149
|
+
else if (frame3.primaryAxisAlignItems === "CENTER") primary += free2 / 2;
|
|
98150
|
+
else if (frame3.primaryAxisAlignItems === "MAX") primary += free2;
|
|
98151
98151
|
for (const id3 of line.ids) {
|
|
98152
98152
|
const child = newNodes[id3];
|
|
98153
98153
|
const size6 = isHorizontal ? child.height : child.width;
|
|
98154
|
-
const off =
|
|
98154
|
+
const off = frame3.counterAxisAlignItems === "CENTER" ? (line.counter - size6) / 2 : frame3.counterAxisAlignItems === "MAX" ? line.counter - size6 : 0;
|
|
98155
98155
|
if (isHorizontal) {
|
|
98156
98156
|
child.x = primary;
|
|
98157
98157
|
child.y = counterPos + off;
|
|
@@ -98167,13 +98167,13 @@ function applyAutoLayout(doc2) {
|
|
|
98167
98167
|
}
|
|
98168
98168
|
return;
|
|
98169
98169
|
}
|
|
98170
|
-
let currentPrimary = isHorizontal ?
|
|
98170
|
+
let currentPrimary = isHorizontal ? frame3.padding.left : frame3.padding.top;
|
|
98171
98171
|
let extraSpacing = 0;
|
|
98172
|
-
if (
|
|
98172
|
+
if (frame3.primaryAxisAlignItems === "SPACE_BETWEEN" && fillPrimaryCount === 0 && childIds.length > 1) {
|
|
98173
98173
|
extraSpacing = availablePrimary / (childIds.length - 1);
|
|
98174
|
-
} else if (
|
|
98174
|
+
} else if (frame3.primaryAxisAlignItems === "CENTER" && fillPrimaryCount === 0) {
|
|
98175
98175
|
currentPrimary += availablePrimary / 2;
|
|
98176
|
-
} else if (
|
|
98176
|
+
} else if (frame3.primaryAxisAlignItems === "MAX" && fillPrimaryCount === 0) {
|
|
98177
98177
|
currentPrimary += availablePrimary;
|
|
98178
98178
|
}
|
|
98179
98179
|
childIds.forEach((childId) => {
|
|
@@ -98181,22 +98181,22 @@ function applyAutoLayout(doc2) {
|
|
|
98181
98181
|
if (isHorizontal) {
|
|
98182
98182
|
child.x = currentPrimary;
|
|
98183
98183
|
currentPrimary += child.width + itemSpacing + extraSpacing;
|
|
98184
|
-
if (
|
|
98185
|
-
child.y =
|
|
98186
|
-
} else if (
|
|
98187
|
-
child.y =
|
|
98184
|
+
if (frame3.counterAxisAlignItems === "CENTER") {
|
|
98185
|
+
child.y = frame3.padding.top + (frame3.height - paddingY - child.height) / 2;
|
|
98186
|
+
} else if (frame3.counterAxisAlignItems === "MAX") {
|
|
98187
|
+
child.y = frame3.height - frame3.padding.bottom - child.height;
|
|
98188
98188
|
} else {
|
|
98189
|
-
child.y =
|
|
98189
|
+
child.y = frame3.padding.top;
|
|
98190
98190
|
}
|
|
98191
98191
|
} else {
|
|
98192
98192
|
child.y = currentPrimary;
|
|
98193
98193
|
currentPrimary += child.height + itemSpacing + extraSpacing;
|
|
98194
|
-
if (
|
|
98195
|
-
child.x =
|
|
98196
|
-
} else if (
|
|
98197
|
-
child.x =
|
|
98194
|
+
if (frame3.counterAxisAlignItems === "CENTER") {
|
|
98195
|
+
child.x = frame3.padding.left + (frame3.width - paddingX - child.width) / 2;
|
|
98196
|
+
} else if (frame3.counterAxisAlignItems === "MAX") {
|
|
98197
|
+
child.x = frame3.width - frame3.padding.right - child.width;
|
|
98198
98198
|
} else {
|
|
98199
|
-
child.x =
|
|
98199
|
+
child.x = frame3.padding.left;
|
|
98200
98200
|
}
|
|
98201
98201
|
}
|
|
98202
98202
|
layoutNode(childId);
|
|
@@ -98216,27 +98216,27 @@ function applyAutoLayout(doc2) {
|
|
|
98216
98216
|
}
|
|
98217
98217
|
return { ...doc2, nodes: newNodes };
|
|
98218
98218
|
}
|
|
98219
|
-
function wraps(
|
|
98220
|
-
if (
|
|
98221
|
-
return
|
|
98219
|
+
function wraps(frame3) {
|
|
98220
|
+
if (frame3.layoutWrap !== "WRAP" || frame3.layoutMode === "GRID") return false;
|
|
98221
|
+
return frame3.layoutMode === "HORIZONTAL" ? frame3.layoutSizingHorizontal !== "HUG" : frame3.layoutSizingVertical !== "HUG";
|
|
98222
98222
|
}
|
|
98223
|
-
function wrapLines(
|
|
98224
|
-
const isHorizontal =
|
|
98225
|
-
const avail = isHorizontal ?
|
|
98223
|
+
function wrapLines(frame3, childIds, size6) {
|
|
98224
|
+
const isHorizontal = frame3.layoutMode === "HORIZONTAL";
|
|
98225
|
+
const avail = isHorizontal ? frame3.width - frame3.padding.left - frame3.padding.right : frame3.height - frame3.padding.top - frame3.padding.bottom;
|
|
98226
98226
|
const lines2 = [];
|
|
98227
98227
|
let cur = { ids: [], counter: 0 }, used = 0;
|
|
98228
98228
|
for (const id3 of childIds) {
|
|
98229
98229
|
const sz = size6(id3);
|
|
98230
98230
|
const primary = isHorizontal ? sz.intrinsicWidth : sz.intrinsicHeight;
|
|
98231
98231
|
const counter = isHorizontal ? sz.intrinsicHeight : sz.intrinsicWidth;
|
|
98232
|
-
const needed = cur.ids.length ? used +
|
|
98232
|
+
const needed = cur.ids.length ? used + frame3.itemSpacing + primary : primary;
|
|
98233
98233
|
if (cur.ids.length && needed > avail + 1e-3) {
|
|
98234
98234
|
lines2.push(cur);
|
|
98235
98235
|
cur = { ids: [], counter: 0 };
|
|
98236
98236
|
used = 0;
|
|
98237
98237
|
}
|
|
98238
98238
|
cur.ids.push(id3);
|
|
98239
|
-
used = cur.ids.length === 1 ? primary : used +
|
|
98239
|
+
used = cur.ids.length === 1 ? primary : used + frame3.itemSpacing + primary;
|
|
98240
98240
|
cur.counter = Math.max(cur.counter, counter);
|
|
98241
98241
|
}
|
|
98242
98242
|
if (cur.ids.length) lines2.push(cur);
|
|
@@ -98778,10 +98778,10 @@ function scaleTree(nodes, id3, s, isRoot) {
|
|
|
98778
98778
|
if (!n) return;
|
|
98779
98779
|
if (!isRoot) {
|
|
98780
98780
|
const t3 = n;
|
|
98781
|
-
const
|
|
98782
|
-
if (typeof t3.fontSize === "number")
|
|
98783
|
-
if (typeof t3.cornerRadius === "number")
|
|
98784
|
-
nodes[id3] = { ...n, ...
|
|
98781
|
+
const patch2 = { x: n.x * s, y: n.y * s, width: n.width * s, height: n.height * s };
|
|
98782
|
+
if (typeof t3.fontSize === "number") patch2.fontSize = Math.max(12, t3.fontSize * s);
|
|
98783
|
+
if (typeof t3.cornerRadius === "number") patch2.cornerRadius = t3.cornerRadius * s;
|
|
98784
|
+
nodes[id3] = { ...n, ...patch2 };
|
|
98785
98785
|
}
|
|
98786
98786
|
for (const c2 of n.childIds) scaleTree(nodes, c2, s, false);
|
|
98787
98787
|
}
|
|
@@ -100040,11 +100040,11 @@ function addAudioClip(comp, o) {
|
|
|
100040
100040
|
const clip = { id: id3, mediaHash: o.mediaHash, name: o.name, start: Math.max(0, Math.round(o.start ?? 0)), in: 0, out: Math.max(1, Math.round(o.duration)), lane: o.lane ?? 0 };
|
|
100041
100041
|
return { composition: withAudio(comp, placeAudio(audio, clip)), id: id3 };
|
|
100042
100042
|
}
|
|
100043
|
-
function editAudioClip(comp, id3,
|
|
100043
|
+
function editAudioClip(comp, id3, patch2) {
|
|
100044
100044
|
const audio = comp.audio ?? [];
|
|
100045
100045
|
const cur = audio.find((c2) => c2.id === id3);
|
|
100046
100046
|
if (!cur) return comp;
|
|
100047
|
-
const next2 = { ...cur, ...
|
|
100047
|
+
const next2 = { ...cur, ...patch2 };
|
|
100048
100048
|
next2.start = Math.max(0, Math.round(next2.start));
|
|
100049
100049
|
next2.in = Math.max(0, Math.round(next2.in));
|
|
100050
100050
|
next2.out = Math.max(next2.in + 1, Math.round(next2.out));
|
|
@@ -100487,7 +100487,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100487
100487
|
const outer = linkNodes;
|
|
100488
100488
|
if (nodes) linkNodes = nodes;
|
|
100489
100489
|
let posed2 = node2;
|
|
100490
|
-
let
|
|
100490
|
+
let patch2 = null;
|
|
100491
100491
|
let values3 = inputs ? inputs.values : null;
|
|
100492
100492
|
try {
|
|
100493
100493
|
for (const key5 in tracks) {
|
|
@@ -100518,7 +100518,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100518
100518
|
if (prop.valueType === "color") posed2 = unbindItemColor(posed2, path);
|
|
100519
100519
|
continue;
|
|
100520
100520
|
}
|
|
100521
|
-
if (prop.field) (
|
|
100521
|
+
if (prop.field) (patch2 ??= {})[prop.field] = v;
|
|
100522
100522
|
else posed2 = prop.valueType === "color" ? unbindItemColor(prop.write(posed2, path, v), path) : prop.write(posed2, path, v);
|
|
100523
100523
|
}
|
|
100524
100524
|
for (const pair of PAIRS) {
|
|
@@ -100526,7 +100526,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100526
100526
|
if (!tx2 || inputs && (isInputPath(node2, pair[0], inputs.set) || isInputPath(node2, pair[1], inputs.set)) || hasBinding2(tx2) || ty && hasBinding2(ty)) continue;
|
|
100527
100527
|
const d = spatialDelta(tx2, ty, t3);
|
|
100528
100528
|
if (!d) continue;
|
|
100529
|
-
const p2 =
|
|
100529
|
+
const p2 = patch2 ??= {};
|
|
100530
100530
|
for (let axis = 0; axis < 2; axis++) {
|
|
100531
100531
|
const f2 = pair[axis];
|
|
100532
100532
|
const cur = f2 in p2 ? p2[f2] : propertyFor(f2)?.read(node2, f2);
|
|
@@ -100536,7 +100536,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100536
100536
|
} finally {
|
|
100537
100537
|
linkNodes = outer;
|
|
100538
100538
|
}
|
|
100539
|
-
return
|
|
100539
|
+
return patch2 ? { ...posed2, ...patch2 } : posed2;
|
|
100540
100540
|
}
|
|
100541
100541
|
function motionNodes(nodes, rootId) {
|
|
100542
100542
|
let memo5 = motionMemo.get(nodes);
|
|
@@ -100662,7 +100662,7 @@ var init_layer_time_edit = __esm({
|
|
|
100662
100662
|
"lib/motion/layer-time-edit.ts"() {
|
|
100663
100663
|
"use strict";
|
|
100664
100664
|
init_time();
|
|
100665
|
-
withMotion = (motion,
|
|
100665
|
+
withMotion = (motion, patch2) => ({ tracks: {}, ...motion, ...patch2 });
|
|
100666
100666
|
}
|
|
100667
100667
|
});
|
|
100668
100668
|
|
|
@@ -100677,12 +100677,12 @@ function videoClipOf(nodes, id3, frameId, duration3) {
|
|
|
100677
100677
|
const speed = clampSpeed(paint.videoSpeed);
|
|
100678
100678
|
return { nodeId: id3, fill, paint, start: bar.start, end: bar.end, zero, speed, in: sourceMsAt(paint, bar.start - zero), out: sourceMsAt(paint, bar.end - zero) };
|
|
100679
100679
|
}
|
|
100680
|
-
function withVideoPaint(node2, index2,
|
|
100680
|
+
function withVideoPaint(node2, index2, patch2) {
|
|
100681
100681
|
const fills = fillsOf(node2);
|
|
100682
100682
|
const cur = fills[index2];
|
|
100683
100683
|
if (!cur) return node2;
|
|
100684
|
-
const next2 = { ...cur, ...
|
|
100685
|
-
for (const k2 of Object.keys(
|
|
100684
|
+
const next2 = { ...cur, ...patch2 };
|
|
100685
|
+
for (const k2 of Object.keys(patch2)) if (next2[k2] === void 0) delete next2[k2];
|
|
100686
100686
|
if (Object.keys(next2).every((k2) => next2[k2] === cur[k2]) && Object.keys(next2).length === Object.keys(cur).length) return node2;
|
|
100687
100687
|
return { ...node2, fills: fills.map((f2, i2) => i2 === index2 ? next2 : f2) };
|
|
100688
100688
|
}
|
|
@@ -101606,16 +101606,16 @@ function resolveTextNodeStyles(node2, styles) {
|
|
|
101606
101606
|
if (paragraphs) out.paragraphs = paragraphs;
|
|
101607
101607
|
return out;
|
|
101608
101608
|
}
|
|
101609
|
-
function withParagraphFormat(node2, range3,
|
|
101609
|
+
function withParagraphFormat(node2, range3, patch2) {
|
|
101610
101610
|
const ranges = paragraphRanges(node2.characters || "");
|
|
101611
101611
|
const targets = range3 && range3.end > range3.start ? ranges.filter((r) => r.start <= range3.end && r.end >= range3.start) : ranges;
|
|
101612
101612
|
const existing = new Map((node2.paragraphs ?? []).map((p2) => [p2.start, p2]));
|
|
101613
101613
|
for (const r of targets) {
|
|
101614
101614
|
const cur = existing.get(r.start) ?? { start: r.start };
|
|
101615
101615
|
const next2 = { ...cur };
|
|
101616
|
-
for (const k2 of Object.keys(
|
|
101617
|
-
if (
|
|
101618
|
-
else next2[k2] =
|
|
101616
|
+
for (const k2 of Object.keys(patch2)) {
|
|
101617
|
+
if (patch2[k2] === void 0) delete next2[k2];
|
|
101618
|
+
else next2[k2] = patch2[k2];
|
|
101619
101619
|
}
|
|
101620
101620
|
existing.set(r.start, next2);
|
|
101621
101621
|
}
|
|
@@ -244639,6 +244639,23 @@ function trackLoad(p2) {
|
|
|
244639
244639
|
p2.then(done, done);
|
|
244640
244640
|
return p2;
|
|
244641
244641
|
}
|
|
244642
|
+
function loadsSettled(timeoutMs = 1e4) {
|
|
244643
|
+
return new Promise((resolve7) => {
|
|
244644
|
+
let timer = null;
|
|
244645
|
+
const finish3 = (ok2) => {
|
|
244646
|
+
waiters.delete(onIdle);
|
|
244647
|
+
if (timer) clearTimeout(timer);
|
|
244648
|
+
setTimeout(() => resolve7(ok2), 0);
|
|
244649
|
+
};
|
|
244650
|
+
const onIdle = () => finish3(true);
|
|
244651
|
+
if (inflight === 0) {
|
|
244652
|
+
finish3(true);
|
|
244653
|
+
return;
|
|
244654
|
+
}
|
|
244655
|
+
waiters.add(onIdle);
|
|
244656
|
+
timer = setTimeout(() => finish3(false), timeoutMs);
|
|
244657
|
+
});
|
|
244658
|
+
}
|
|
244642
244659
|
var inflight, waiters;
|
|
244643
244660
|
var init_readiness = __esm({
|
|
244644
244661
|
"lib/engine/readiness.ts"() {
|
|
@@ -246900,9 +246917,9 @@ function rescaleTextEffect(node2) {
|
|
|
246900
246917
|
const preset = node2.textEffectPreset;
|
|
246901
246918
|
const at4 = node2.textEffectSize;
|
|
246902
246919
|
if (!preset || !DEFAULTS[preset] || !at4 || at4 === node2.fontSize) return null;
|
|
246903
|
-
const
|
|
246904
|
-
if (preset !== "HOLLOW") delete
|
|
246905
|
-
return
|
|
246920
|
+
const patch2 = textEffectPatch(node2, preset);
|
|
246921
|
+
if (preset !== "HOLLOW") delete patch2.fills;
|
|
246922
|
+
return patch2;
|
|
246906
246923
|
}
|
|
246907
246924
|
var DEFAULTS, BLACK5, WHITE5, fillPaint, fillColor, shadow, round, OUTLINED;
|
|
246908
246925
|
var init_effect_presets = __esm({
|
|
@@ -246943,12 +246960,12 @@ function addMarker(tl, t3, label3) {
|
|
|
246943
246960
|
const marker = { id: id3, t: at4, ...label3 ? { label: label3 } : {} };
|
|
246944
246961
|
return { timeline: withMarkers(tl, sortMarkers([...markers, marker])), id: id3 };
|
|
246945
246962
|
}
|
|
246946
|
-
function updateMarker(tl, id3,
|
|
246963
|
+
function updateMarker(tl, id3, patch2) {
|
|
246947
246964
|
const markers = tl.markers ?? [];
|
|
246948
246965
|
const i2 = markers.findIndex((m2) => m2.id === id3);
|
|
246949
246966
|
if (i2 < 0) return tl;
|
|
246950
|
-
const m = { ...markers[i2], ...
|
|
246951
|
-
if (
|
|
246967
|
+
const m = { ...markers[i2], ...patch2 };
|
|
246968
|
+
if (patch2.t !== void 0) m.t = Math.max(0, Math.round(patch2.t));
|
|
246952
246969
|
if (!m.label) delete m.label;
|
|
246953
246970
|
if (m.kind === "marker" || m.kind === void 0) delete m.kind;
|
|
246954
246971
|
const was = markers[i2];
|
|
@@ -247937,8 +247954,8 @@ function applyInvariants(doc2, touched) {
|
|
|
247937
247954
|
function rescaleTextEffects(doc2, id3) {
|
|
247938
247955
|
const n = doc2.nodes[id3];
|
|
247939
247956
|
if (!n || n.type !== "TEXT") return doc2;
|
|
247940
|
-
const
|
|
247941
|
-
return
|
|
247957
|
+
const patch2 = rescaleTextEffect(n);
|
|
247958
|
+
return patch2 ? updateNode(doc2, id3, patch2) : doc2;
|
|
247942
247959
|
}
|
|
247943
247960
|
function repairDocumentCompositions(doc2) {
|
|
247944
247961
|
const comps = repairCompositions(doc2.compositions, doc2.nodes);
|
|
@@ -248593,9 +248610,9 @@ function writeSoundtrack(doc2, sound) {
|
|
|
248593
248610
|
const compositions = { ...doc2.compositions, [built.composition.id]: built.composition };
|
|
248594
248611
|
return repairDocumentCompositions({ ...doc2, compositions });
|
|
248595
248612
|
}
|
|
248596
|
-
function configure(doc2, pageId2,
|
|
248613
|
+
function configure(doc2, pageId2, patch2) {
|
|
248597
248614
|
const sound = soundOf(doc2, pageId2);
|
|
248598
|
-
return writeSoundtrack(doc2, { ...sound, settings: repairSettings({ ...sound.settings, ...
|
|
248615
|
+
return writeSoundtrack(doc2, { ...sound, settings: repairSettings({ ...sound.settings, ...patch2 }) });
|
|
248599
248616
|
}
|
|
248600
248617
|
function retime(doc2, pageId2, o = {}) {
|
|
248601
248618
|
const sound = soundOf(doc2, pageId2);
|
|
@@ -252420,7 +252437,6 @@ function resizeWindow(doc2, target2, rect) {
|
|
|
252420
252437
|
}
|
|
252421
252438
|
var init_crop = __esm({
|
|
252422
252439
|
"lib/editor/crop.ts"() {
|
|
252423
|
-
"use strict";
|
|
252424
252440
|
init_dist_node();
|
|
252425
252441
|
init_scene_graph();
|
|
252426
252442
|
init_photo_frames();
|
|
@@ -253179,8 +253195,8 @@ async function bakeStroke(dabs, color4, opacity, hardness, wetMix = 0, backdrop,
|
|
|
253179
253195
|
scale = Math.min(scale, Math.sqrt(MAX_STROKE_PIXELS / (worldW * worldH)));
|
|
253180
253196
|
const pxW = Math.max(1, Math.round(worldW * scale));
|
|
253181
253197
|
const pxH = Math.max(1, Math.round(worldH * scale));
|
|
253182
|
-
const
|
|
253183
|
-
const batch = packDabs(dabs,
|
|
253198
|
+
const frame3 = { cx: minX + worldW / 2, cy: minY + worldH / 2, rotationRad: 0, flipX: false, flipY: false, width: worldW, height: worldH, pixelWidth: pxW, pixelHeight: pxH };
|
|
253199
|
+
const batch = packDabs(dabs, frame3, { color: color4, alpha: Math.max(0, Math.min(1, opacity)), hardness, tip, stamp: !!stamp, secondaryColor });
|
|
253184
253200
|
const grainTile = grain && grain.depth > 0 ? grain.image ?? getGrainTile(grain.type) : null;
|
|
253185
253201
|
const wet = backdrop && !stamp ? Math.max(0, Math.min(1, wetMix)) : 0;
|
|
253186
253202
|
const pixels = await layers2.bake(pxW, pxH, batch, {
|
|
@@ -253237,9 +253253,9 @@ function worldToLayer(f2, wx, wy) {
|
|
|
253237
253253
|
function layerDensity(f2) {
|
|
253238
253254
|
return f2.pixelWidth / Math.max(1e-6, f2.width);
|
|
253239
253255
|
}
|
|
253240
|
-
function packDabs(dabs,
|
|
253256
|
+
function packDabs(dabs, frame3, paint, prev) {
|
|
253241
253257
|
const data = new Float32Array(dabs.length * DAB_STRIDE);
|
|
253242
|
-
const k2 = layerDensity(
|
|
253258
|
+
const k2 = layerDensity(frame3);
|
|
253243
253259
|
const base = paint.color;
|
|
253244
253260
|
const baseHsl = rgbToHsl(base.r ?? 0, base.g ?? 0, base.b ?? 0);
|
|
253245
253261
|
const sec = paint.secondaryColor;
|
|
@@ -253247,7 +253263,7 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253247
253263
|
let n = 0;
|
|
253248
253264
|
let last3 = prev ?? null;
|
|
253249
253265
|
for (const d of dabs) {
|
|
253250
|
-
const p2 = worldToLayer(
|
|
253266
|
+
const p2 = worldToLayer(frame3, d.cx, d.cy);
|
|
253251
253267
|
const round5 = Math.max(0.1, d.roundness ?? 1);
|
|
253252
253268
|
let rx = d.r * k2, ry = d.r * round5 * k2;
|
|
253253
253269
|
let mode = 0;
|
|
@@ -253263,14 +253279,14 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253263
253279
|
mode = 1;
|
|
253264
253280
|
ry *= 0.5;
|
|
253265
253281
|
}
|
|
253266
|
-
const angle2 = d.angle -
|
|
253282
|
+
const angle2 = d.angle - frame3.rotationRad;
|
|
253267
253283
|
const o = n * DAB_STRIDE;
|
|
253268
253284
|
data[o] = p2.x;
|
|
253269
253285
|
data[o + 1] = p2.y;
|
|
253270
253286
|
data[o + 2] = rx;
|
|
253271
253287
|
data[o + 3] = ry;
|
|
253272
253288
|
data[o + 12] = d.charge ?? 1;
|
|
253273
|
-
data[o + 13] = (d.travel ?? 0) -
|
|
253289
|
+
data[o + 13] = (d.travel ?? 0) - frame3.rotationRad;
|
|
253274
253290
|
data[o + 4] = angle2;
|
|
253275
253291
|
data[o + 5] = (paint.smudgeStrength !== void 0 || paint.liquify) && mode === 0 ? 0.6 : d.hardness ?? paint.hardness;
|
|
253276
253292
|
data[o + 6] = mode;
|
|
@@ -253283,7 +253299,7 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253283
253299
|
last3 = d;
|
|
253284
253300
|
continue;
|
|
253285
253301
|
}
|
|
253286
|
-
const q = worldToLayer(
|
|
253302
|
+
const q = worldToLayer(frame3, last3.cx, last3.cy);
|
|
253287
253303
|
last3 = d;
|
|
253288
253304
|
data[o + 8] = p2.x - q.x;
|
|
253289
253305
|
data[o + 9] = p2.y - q.y;
|
|
@@ -253294,7 +253310,7 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253294
253310
|
last3 = d;
|
|
253295
253311
|
continue;
|
|
253296
253312
|
}
|
|
253297
|
-
const q = worldToLayer(
|
|
253313
|
+
const q = worldToLayer(frame3, last3.cx, last3.cy);
|
|
253298
253314
|
last3 = d;
|
|
253299
253315
|
data[o + 8] = p2.x - q.x;
|
|
253300
253316
|
data[o + 9] = p2.y - q.y;
|
|
@@ -253379,8 +253395,8 @@ function imageEditGroupOf(nodes, nodeId2) {
|
|
|
253379
253395
|
function wrapTargetFor(doc2, nodeId2) {
|
|
253380
253396
|
const node2 = doc2.nodes[nodeId2];
|
|
253381
253397
|
if (!node2) return null;
|
|
253382
|
-
const
|
|
253383
|
-
return
|
|
253398
|
+
const frame3 = photoFrameOf(doc2.nodes, nodeId2);
|
|
253399
|
+
return frame3 ? frame3.id : nodeId2;
|
|
253384
253400
|
}
|
|
253385
253401
|
function prepareImageEdit(doc2, nodeId2) {
|
|
253386
253402
|
const existing = imageEditGroupOf(doc2.nodes, nodeId2);
|
|
@@ -253940,8 +253956,8 @@ function createDrawPaletteSlice(set4, get4) {
|
|
|
253940
253956
|
commit([...palette2(), tool2], "Add to palette", { activeDrawToolId: tool2.id, editingDrawToolId: tool2.id });
|
|
253941
253957
|
return tool2.id;
|
|
253942
253958
|
},
|
|
253943
|
-
updateDrawTool: (id3,
|
|
253944
|
-
const next2 = palette2().map((t3) => t3.id === id3 ? { ...t3, ...
|
|
253959
|
+
updateDrawTool: (id3, patch2) => {
|
|
253960
|
+
const next2 = palette2().map((t3) => t3.id === id3 ? { ...t3, ...patch2 } : t3);
|
|
253945
253961
|
commit(next2, "Edit palette");
|
|
253946
253962
|
},
|
|
253947
253963
|
removeDrawTool: (id3) => {
|
|
@@ -254308,17 +254324,17 @@ function createModeSlice(set4, get4) {
|
|
|
254308
254324
|
saveTabSides(tabSides);
|
|
254309
254325
|
const from2 = side === "left" ? "right" : "left";
|
|
254310
254326
|
const fromKey = from2 === "left" ? "leftTab" : "rightTab";
|
|
254311
|
-
const
|
|
254327
|
+
const patch2 = { tabSides, tabOrder };
|
|
254312
254328
|
if (state[fromKey] === tab) {
|
|
254313
254329
|
const next2 = tabsOn(tabSides, from2, tabOrder).find((t3) => !ACTION_TABS.has(t3));
|
|
254314
|
-
if (next2)
|
|
254315
|
-
else
|
|
254330
|
+
if (next2) patch2[fromKey] = next2;
|
|
254331
|
+
else patch2[from2 === "left" ? "leftPanelOpen" : "rightPanelOpen"] = false;
|
|
254316
254332
|
}
|
|
254317
254333
|
if (!action3) {
|
|
254318
|
-
|
|
254319
|
-
|
|
254334
|
+
patch2[side === "left" ? "leftTab" : "rightTab"] = tab;
|
|
254335
|
+
patch2[side === "left" ? "leftPanelOpen" : "rightPanelOpen"] = true;
|
|
254320
254336
|
}
|
|
254321
|
-
set4(
|
|
254337
|
+
set4(patch2);
|
|
254322
254338
|
},
|
|
254323
254339
|
setStageView: (on, mode) => {
|
|
254324
254340
|
const state = get4();
|
|
@@ -254472,24 +254488,24 @@ var init_pixel_layers = __esm({
|
|
|
254472
254488
|
});
|
|
254473
254489
|
|
|
254474
254490
|
// lib/engine/pixel/pixel-texture.ts
|
|
254475
|
-
function setWorkingPixels(nodeId2,
|
|
254491
|
+
function setWorkingPixels(nodeId2, frame3, rgba, version7 = 0) {
|
|
254476
254492
|
if (!rgba) working.delete(nodeId2);
|
|
254477
|
-
else working.set(nodeId2, { frame:
|
|
254493
|
+
else working.set(nodeId2, { frame: frame3, rgba, version: version7 });
|
|
254478
254494
|
if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-render"));
|
|
254479
254495
|
}
|
|
254480
254496
|
function frameRGBA(node2, frameIndex) {
|
|
254481
|
-
const
|
|
254497
|
+
const frame3 = node2.frames[Math.max(0, Math.min(node2.frames.length - 1, frameIndex))];
|
|
254482
254498
|
const w = node2.pixelWidth, h = node2.pixelHeight;
|
|
254483
|
-
if (!
|
|
254484
|
-
const key5 = [
|
|
254485
|
-
const holder =
|
|
254499
|
+
if (!frame3) return new Uint32Array(w * h);
|
|
254500
|
+
const key5 = [frame3.cels, node2.palette, node2.colorMode, node2.transparentIndex, node2.tileset, w, h];
|
|
254501
|
+
const holder = frame3;
|
|
254486
254502
|
const hit = rgbaCache.get(holder);
|
|
254487
254503
|
if (hit && hit.key.length === key5.length && hit.key.every((k2, i2) => k2 === key5[i2])) return hit.rgba;
|
|
254488
254504
|
let rgba;
|
|
254489
254505
|
if (node2.tileset) {
|
|
254490
254506
|
const { tileW, tileH, tiles } = node2.tileset;
|
|
254491
254507
|
const cols = Math.max(1, Math.floor(w / tileW)), rows = Math.max(1, Math.floor(h / tileH));
|
|
254492
|
-
const map2 = decodeCels(
|
|
254508
|
+
const map2 = decodeCels(frame3.cels, cols * rows);
|
|
254493
254509
|
rgba = new Uint32Array(w * h);
|
|
254494
254510
|
const tileRGBA = tiles.map((t3) => celsToRGBA(decodeCels(t3, tileW * tileH), node2.colorMode, node2.palette, node2.transparentIndex));
|
|
254495
254511
|
for (let ty = 0; ty < rows; ty++) for (let tx2 = 0; tx2 < cols; tx2++) {
|
|
@@ -254502,7 +254518,7 @@ function frameRGBA(node2, frameIndex) {
|
|
|
254502
254518
|
}
|
|
254503
254519
|
}
|
|
254504
254520
|
} else {
|
|
254505
|
-
rgba = celsToRGBA(decodeCels(
|
|
254521
|
+
rgba = celsToRGBA(decodeCels(frame3.cels, w * h), node2.colorMode, node2.palette, node2.transparentIndex);
|
|
254506
254522
|
}
|
|
254507
254523
|
rgbaCache.set(holder, { key: key5, rgba });
|
|
254508
254524
|
return rgba;
|
|
@@ -254510,8 +254526,8 @@ function frameRGBA(node2, frameIndex) {
|
|
|
254510
254526
|
function setPixelEditingNode(id3) {
|
|
254511
254527
|
editingNodeId = id3;
|
|
254512
254528
|
}
|
|
254513
|
-
function setPixelPreviewFrame(nodeId2,
|
|
254514
|
-
previewFrame = nodeId2 ? { nodeId: nodeId2, frame:
|
|
254529
|
+
function setPixelPreviewFrame(nodeId2, frame3 = 0) {
|
|
254530
|
+
previewFrame = nodeId2 ? { nodeId: nodeId2, frame: frame3 } : null;
|
|
254515
254531
|
if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-render"));
|
|
254516
254532
|
}
|
|
254517
254533
|
var working, rgbaCache, editingNodeId, previewFrame;
|
|
@@ -254636,14 +254652,14 @@ function createPixelSlice(set4, get4) {
|
|
|
254636
254652
|
const empty2 = new Uint32Array(count2);
|
|
254637
254653
|
if (n.tileset) empty2.fill(EMPTY_INDEX);
|
|
254638
254654
|
else if (n.colorMode === "INDEXED") empty2.fill(n.transparentIndex);
|
|
254639
|
-
const
|
|
254640
|
-
const frames = [...n.frames.slice(0, at4),
|
|
254655
|
+
const frame3 = { id: v4_default(), cels: opts.duplicate && src ? src.cels : encodeCels(empty2), duration: src?.duration ?? 100 };
|
|
254656
|
+
const frames = [...n.frames.slice(0, at4), frame3, ...n.frames.slice(at4)];
|
|
254641
254657
|
const tags = n.tags.map((t3) => ({ ...t3, from: t3.from >= at4 ? t3.from + 1 : t3.from, to: t3.to >= at4 ? t3.to + 1 : t3.to }));
|
|
254642
254658
|
let doc2 = updateNode(get4().document, id3, { frames, tags, activeFrame: at4 });
|
|
254643
254659
|
if (opts.duplicate && src) {
|
|
254644
254660
|
for (const l of layersOf(doc2, n)) {
|
|
254645
254661
|
const ids2 = frameIdsOf(l);
|
|
254646
|
-
if (ids2 && ids2.includes(src.id)) doc2 = updateNode(doc2, l.id, { pixelFrameIds: [...ids2,
|
|
254662
|
+
if (ids2 && ids2.includes(src.id)) doc2 = updateNode(doc2, l.id, { pixelFrameIds: [...ids2, frame3.id] });
|
|
254647
254663
|
}
|
|
254648
254664
|
}
|
|
254649
254665
|
commitDoc(doc2, opts.duplicate ? "Duplicate frame" : "New frame");
|
|
@@ -254687,10 +254703,10 @@ function createPixelSlice(set4, get4) {
|
|
|
254687
254703
|
const tag2 = { id: v4_default(), name: `Tag ${n.tags.length + 1}`, from: clampFrame(n, Math.min(from2, to)), to: clampFrame(n, Math.max(from2, to)), direction: "FORWARD", color: colors2[n.tags.length % colors2.length] };
|
|
254688
254704
|
commit(id3, { tags: [...n.tags, tag2] }, "Add tag");
|
|
254689
254705
|
},
|
|
254690
|
-
pixelUpdateTag: (id3, tagId,
|
|
254706
|
+
pixelUpdateTag: (id3, tagId, patch2) => {
|
|
254691
254707
|
const n = node2(id3);
|
|
254692
254708
|
if (!n) return;
|
|
254693
|
-
commit(id3, { tags: n.tags.map((t3) => t3.id === tagId ? { ...t3, ...
|
|
254709
|
+
commit(id3, { tags: n.tags.map((t3) => t3.id === tagId ? { ...t3, ...patch2 } : t3) }, "Edit tag");
|
|
254694
254710
|
},
|
|
254695
254711
|
pixelDeleteTag: (id3, tagId) => {
|
|
254696
254712
|
const n = node2(id3);
|
|
@@ -254698,9 +254714,9 @@ function createPixelSlice(set4, get4) {
|
|
|
254698
254714
|
commit(id3, { tags: n.tags.filter((t3) => t3.id !== tagId) }, "Delete tag");
|
|
254699
254715
|
},
|
|
254700
254716
|
/** Generic pixel-node property change (onion skin, tiled mode, reference…) as one undo step. */
|
|
254701
|
-
pixelUpdate: (id3,
|
|
254717
|
+
pixelUpdate: (id3, patch2, description = "Pixel canvas settings") => {
|
|
254702
254718
|
if (!node2(id3)) return;
|
|
254703
|
-
commit(id3,
|
|
254719
|
+
commit(id3, patch2, description);
|
|
254704
254720
|
},
|
|
254705
254721
|
/**
|
|
254706
254722
|
* Bake layers into pixels as one undo step. Default: the active frame — its layers are merged into its
|
|
@@ -254827,14 +254843,14 @@ function createPixelSlice(set4, get4) {
|
|
|
254827
254843
|
palette2 = extractPalette(all4, 256).map(packedToHex);
|
|
254828
254844
|
}
|
|
254829
254845
|
const conv = (b64, cellCount) => encodeCels(convertCels(decodeCels(b64, cellCount), n.colorMode, mode, n.palette, palette2, n.transparentIndex));
|
|
254830
|
-
const
|
|
254846
|
+
const patch2 = { colorMode: mode, palette: palette2 };
|
|
254831
254847
|
if (n.tileset) {
|
|
254832
254848
|
const tc = n.tileset.tileW * n.tileset.tileH;
|
|
254833
|
-
|
|
254849
|
+
patch2.tileset = { ...n.tileset, tiles: n.tileset.tiles.map((t3) => conv(t3, tc)) };
|
|
254834
254850
|
} else {
|
|
254835
|
-
|
|
254851
|
+
patch2.frames = n.frames.map((f2) => ({ ...f2, cels: conv(f2.cels, count2) }));
|
|
254836
254852
|
}
|
|
254837
|
-
commit(id3,
|
|
254853
|
+
commit(id3, patch2, `Color mode: ${mode.toLowerCase()}`);
|
|
254838
254854
|
},
|
|
254839
254855
|
/** Dedupe the canvas into a tileset + per-frame tile maps (Aseprite "convert to tilemap"). */
|
|
254840
254856
|
pixelConvertToTilemap: (id3, tileW, tileH) => {
|
|
@@ -255948,7 +255964,6 @@ fn shade(uv: vec2<f32>, res: vec2<f32>, tm: f32) -> vec4<f32> {
|
|
|
255948
255964
|
var SHADER_PRESETS, shaderPreset, legacyPresetOf, DEFAULT_SHADER_PRESET, DEFAULT_TEXTURE_PARAMS, f, vec4, NOISE_LIB;
|
|
255949
255965
|
var init_shader_presets = __esm({
|
|
255950
255966
|
"lib/engine/shader-presets.ts"() {
|
|
255951
|
-
"use strict";
|
|
255952
255967
|
init_shader_graph();
|
|
255953
255968
|
init_shader_graph_presets();
|
|
255954
255969
|
init_shader_presets_legacy();
|
|
@@ -256301,20 +256316,20 @@ function createWashiTape(a, b, styleId, edge = "SPIKY", width = 32, seed2 = Date
|
|
|
256301
256316
|
...{ washiStyle: style.id, washiEdge: edge, washiSeed: shortSeed }
|
|
256302
256317
|
});
|
|
256303
256318
|
}
|
|
256304
|
-
function restyleWashiTape(node2,
|
|
256319
|
+
function restyleWashiTape(node2, patch2) {
|
|
256305
256320
|
const n = node2;
|
|
256306
256321
|
if (!n.washiStyle) return node2;
|
|
256307
|
-
const style = washiStyle(
|
|
256308
|
-
const edge =
|
|
256322
|
+
const style = washiStyle(patch2.styleId ?? n.washiStyle);
|
|
256323
|
+
const edge = patch2.edge ?? n.washiEdge ?? "SPIKY";
|
|
256309
256324
|
const seed2 = n.washiSeed ?? 1;
|
|
256310
256325
|
return {
|
|
256311
256326
|
...n,
|
|
256312
|
-
name:
|
|
256327
|
+
name: patch2.styleId ? `Washi tape \xB7 ${style.label}` : n.name,
|
|
256313
256328
|
washiStyle: style.id,
|
|
256314
256329
|
washiEdge: edge,
|
|
256315
256330
|
washiSeed: seed2,
|
|
256316
256331
|
paths: [{ closed: true, points: washiOutline(n.width, n.height, seed2, edge) }],
|
|
256317
|
-
fills:
|
|
256332
|
+
fills: patch2.styleId ? [washiFill(style, n.height, seed2)] : n.fills
|
|
256318
256333
|
};
|
|
256319
256334
|
}
|
|
256320
256335
|
var PLAIN, PATTERNED, WASHI_TAPES, washiStyle;
|
|
@@ -256535,21 +256550,24 @@ function freshIdMap(t3) {
|
|
|
256535
256550
|
return map2;
|
|
256536
256551
|
}
|
|
256537
256552
|
function addTree(document2, t3, map2, rootId, parentId, ox, oy) {
|
|
256538
|
-
const
|
|
256553
|
+
const parent = document2.nodes[parentId];
|
|
256554
|
+
if (!parent || !t3.payload.nodes[rootId]) return document2;
|
|
256555
|
+
const nodes = { ...document2.nodes };
|
|
256556
|
+
const walk4 = (id3, parent2, isRoot) => {
|
|
256539
256557
|
const src = t3.payload.nodes[id3];
|
|
256540
256558
|
if (!src) return;
|
|
256541
|
-
const n = rewriteIds(
|
|
256542
|
-
const kids = src.childIds ?? [];
|
|
256543
|
-
n.childIds = [];
|
|
256559
|
+
const n = rewriteIds(src, map2);
|
|
256544
256560
|
if (isRoot) {
|
|
256545
256561
|
n.x += ox;
|
|
256546
256562
|
n.y += oy;
|
|
256547
256563
|
}
|
|
256548
|
-
|
|
256549
|
-
|
|
256564
|
+
nodes[n.id] = { ...n, childIds: [], parentId: parent2 };
|
|
256565
|
+
const p2 = nodes[parent2];
|
|
256566
|
+
nodes[parent2] = { ...p2, childIds: [...p2.childIds, n.id] };
|
|
256567
|
+
for (const k2 of src.childIds ?? []) walk4(k2, n.id, false);
|
|
256550
256568
|
};
|
|
256551
256569
|
walk4(rootId, parentId, true);
|
|
256552
|
-
return document2;
|
|
256570
|
+
return { ...document2, nodes };
|
|
256553
256571
|
}
|
|
256554
256572
|
function mergeRecords(doc2, t3, map2, roots) {
|
|
256555
256573
|
const p2 = t3.payload;
|
|
@@ -256798,11 +256816,11 @@ function colorFor(id3) {
|
|
|
256798
256816
|
for (let i2 = 0; i2 < id3.length; i2++) h = h * 31 + id3.charCodeAt(i2) >>> 0;
|
|
256799
256817
|
return PALETTE[h % PALETTE.length];
|
|
256800
256818
|
}
|
|
256801
|
-
function updateLocal(
|
|
256819
|
+
function updateLocal(patch2) {
|
|
256802
256820
|
if (!awareness) return;
|
|
256803
256821
|
const cur = awareness.getLocalState();
|
|
256804
256822
|
if (!cur) return;
|
|
256805
|
-
awareness.setLocalState({ ...cur, ...
|
|
256823
|
+
awareness.setLocalState({ ...cur, ...patch2 });
|
|
256806
256824
|
}
|
|
256807
256825
|
function sendCursor() {
|
|
256808
256826
|
cursorTimer = null;
|
|
@@ -256955,12 +256973,12 @@ function createPopcornSlice(set4, get4) {
|
|
|
256955
256973
|
const state = get4();
|
|
256956
256974
|
set4({ document: after, ...extra, history: pushCommand(state.history, createCommand("POPCORN", description, state.document, after)) });
|
|
256957
256975
|
};
|
|
256958
|
-
const restyleSelectedTapes = (
|
|
256976
|
+
const restyleSelectedTapes = (patch2, description) => {
|
|
256959
256977
|
const state = get4();
|
|
256960
256978
|
let doc2 = state.document;
|
|
256961
256979
|
for (const id3 of state.selection) {
|
|
256962
256980
|
const n = doc2.nodes[id3];
|
|
256963
|
-
if (n?.washiStyle) doc2 = { ...doc2, nodes: { ...doc2.nodes, [id3]: restyleWashiTape(n,
|
|
256981
|
+
if (n?.washiStyle) doc2 = { ...doc2, nodes: { ...doc2.nodes, [id3]: restyleWashiTape(n, patch2) } };
|
|
256964
256982
|
}
|
|
256965
256983
|
if (doc2 !== state.document) commit(doc2, description);
|
|
256966
256984
|
};
|
|
@@ -257606,16 +257624,16 @@ async function listDocMetas() {
|
|
|
257606
257624
|
async function getDocMeta(id3) {
|
|
257607
257625
|
return (await readIndex()).find((m) => m.id === id3) ?? null;
|
|
257608
257626
|
}
|
|
257609
|
-
async function upsertDocMeta(
|
|
257610
|
-
if (deletedHere.has(
|
|
257627
|
+
async function upsertDocMeta(patch2, { create: create8 = false } = {}) {
|
|
257628
|
+
if (deletedHere.has(patch2.id)) return;
|
|
257611
257629
|
await update2(INDEX_KEY, (idx) => {
|
|
257612
257630
|
const list2 = Array.isArray(idx) ? [...idx] : [];
|
|
257613
|
-
const i2 = list2.findIndex((m) => m.id ===
|
|
257631
|
+
const i2 = list2.findIndex((m) => m.id === patch2.id);
|
|
257614
257632
|
if (i2 < 0 && !create8) return list2;
|
|
257615
257633
|
if (i2 >= 0) {
|
|
257616
257634
|
const { thumbnail: inline, ...rest } = list2[i2];
|
|
257617
|
-
list2[i2] = { ...rest, ...typeof inline === "string" ? { thumbnail: inline } : {}, ...
|
|
257618
|
-
} else list2.push({ id:
|
|
257635
|
+
list2[i2] = { ...rest, ...typeof inline === "string" ? { thumbnail: inline } : {}, ...patch2 };
|
|
257636
|
+
} else list2.push({ id: patch2.id, name: patch2.name || "Untitled", updatedAt: patch2.updatedAt || Date.now(), thumbAt: patch2.thumbAt });
|
|
257619
257637
|
return list2;
|
|
257620
257638
|
});
|
|
257621
257639
|
}
|
|
@@ -258008,8 +258026,8 @@ function openFramingIds(nodes, pageId2) {
|
|
|
258008
258026
|
const page = nodes[pageId2];
|
|
258009
258027
|
if (!page) return [];
|
|
258010
258028
|
const children = (page.childIds ?? []).filter((id3) => nodes[id3] && nodes[id3].visible !== false);
|
|
258011
|
-
const
|
|
258012
|
-
return
|
|
258029
|
+
const frame3 = children.find((id3) => nodes[id3].type === "FRAME");
|
|
258030
|
+
return frame3 ? [frame3] : children;
|
|
258013
258031
|
}
|
|
258014
258032
|
function isSavedCamera(camera2) {
|
|
258015
258033
|
if (!camera2 || !Number.isFinite(camera2.x) || !Number.isFinite(camera2.y) || !(camera2.zoom > 0)) return false;
|
|
@@ -258075,14 +258093,14 @@ function withCounter(node2, counter) {
|
|
|
258075
258093
|
}
|
|
258076
258094
|
return { ...node2, textCounter: counter, characters: formatCounter(counter, counterRest(counter)) };
|
|
258077
258095
|
}
|
|
258078
|
-
function editCounter(node2,
|
|
258096
|
+
function editCounter(node2, patch2) {
|
|
258079
258097
|
const c2 = node2.textCounter;
|
|
258080
258098
|
if (!c2) return node2;
|
|
258081
|
-
const next2 = { ...c2, ...
|
|
258099
|
+
const next2 = { ...c2, ...patch2 };
|
|
258082
258100
|
let motion = node2.motion;
|
|
258083
258101
|
const track2 = motion?.tracks[COUNTER_PATH];
|
|
258084
|
-
if (track2?.keys.length && (
|
|
258085
|
-
const keys4 = track2.keys.map((k2, i2, all4) => i2 === 0 &&
|
|
258102
|
+
if (track2?.keys.length && (patch2.from !== void 0 || patch2.to !== void 0)) {
|
|
258103
|
+
const keys4 = track2.keys.map((k2, i2, all4) => i2 === 0 && patch2.from !== void 0 ? { ...k2, v: next2.from } : i2 === all4.length - 1 && patch2.to !== void 0 ? { ...k2, v: next2.to } : k2);
|
|
258086
258104
|
motion = withTrack(motion, COUNTER_PATH, { ...track2, keys: keys4 });
|
|
258087
258105
|
}
|
|
258088
258106
|
return { ...withCounter(node2, next2), motion };
|
|
@@ -258349,9 +258367,9 @@ function frameSound(nodes, frameId, lengths2 = NO_LENGTHS) {
|
|
|
258349
258367
|
let list2 = frameMemo.get(nodes);
|
|
258350
258368
|
const hit = list2?.find((m) => m.frameId === frameId && m.lengths === lengths2);
|
|
258351
258369
|
if (hit) return hit.sound;
|
|
258352
|
-
const
|
|
258353
|
-
const sound =
|
|
258354
|
-
if (
|
|
258370
|
+
const frame3 = nodes[frameId];
|
|
258371
|
+
const sound = frame3 ? [...frame3.timeline?.audio ?? []] : [];
|
|
258372
|
+
if (frame3) {
|
|
258355
258373
|
const duration3 = timelineDuration(nodes, frameId);
|
|
258356
258374
|
for (const id3 of videoNodeIds(nodes)) {
|
|
258357
258375
|
if (id3 === frameId || localTime(nodes, id3, frameId, 0) === void 0) continue;
|
|
@@ -258539,7 +258557,7 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
|
|
|
258539
258557
|
});
|
|
258540
258558
|
if (!stage) return pose;
|
|
258541
258559
|
const moment = compositionAt(comp, time4);
|
|
258542
|
-
let
|
|
258560
|
+
let patch2 = null;
|
|
258543
258561
|
const ids2 = /* @__PURE__ */ new Set();
|
|
258544
258562
|
let live = time4 < compositionDuration(comp);
|
|
258545
258563
|
for (const a of [moment.previous, moment.current]) {
|
|
@@ -258547,7 +258565,7 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
|
|
|
258547
258565
|
const fp = evaluatePose(base, { kind: "frame", frameId: a.clip.frameId }, a.local, { clock: clock2, runtime, driveVideo: true, ...audio ? { audio } : {} });
|
|
258548
258566
|
if (fp.live) live = true;
|
|
258549
258567
|
for (const id3 of fp.animatedIds) {
|
|
258550
|
-
(
|
|
258568
|
+
(patch2 ??= {})[id3] = fp.nodes[id3];
|
|
258551
258569
|
ids2.add(id3);
|
|
258552
258570
|
}
|
|
258553
258571
|
}
|
|
@@ -258555,8 +258573,8 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
|
|
|
258555
258573
|
const t3 = placed2(id3), n = base[id3];
|
|
258556
258574
|
return t3 && n ? { width: n.width, height: n.height, cx: t3.cx, cy: t3.cy } : null;
|
|
258557
258575
|
});
|
|
258558
|
-
const posed2 =
|
|
258559
|
-
if (
|
|
258576
|
+
const posed2 = patch2 ? { ...base, ...patch2 } : base;
|
|
258577
|
+
if (patch2) noteChanged(base, posed2, Object.keys(patch2));
|
|
258560
258578
|
return {
|
|
258561
258579
|
...pose,
|
|
258562
258580
|
nodes: posed2,
|
|
@@ -258598,17 +258616,17 @@ function withOrbits(pose, orbits) {
|
|
|
258598
258616
|
const hit = orbitMemo.get(pose);
|
|
258599
258617
|
if (hit && hit.orbits === orbits) return hit.pose;
|
|
258600
258618
|
const nodes = pose.nodes;
|
|
258601
|
-
const
|
|
258619
|
+
const patch2 = {};
|
|
258602
258620
|
const visit2 = (id3) => {
|
|
258603
258621
|
const n = nodes[id3];
|
|
258604
258622
|
if (!n) return;
|
|
258605
258623
|
const o = orbits.turns[n.name];
|
|
258606
|
-
if (o)
|
|
258624
|
+
if (o) patch2[id3] = { ...n, rotateX: (n.rotateX ?? 0) + o.rotateX, rotateY: (n.rotateY ?? 0) + o.rotateY };
|
|
258607
258625
|
for (const c2 of n.childIds ?? []) visit2(c2);
|
|
258608
258626
|
};
|
|
258609
258627
|
for (const r of orbits.roots) visit2(r);
|
|
258610
|
-
const ids2 = Object.keys(
|
|
258611
|
-
const shown2 = ids2.length ? { ...nodes, ...
|
|
258628
|
+
const ids2 = Object.keys(patch2);
|
|
258629
|
+
const shown2 = ids2.length ? { ...nodes, ...patch2 } : nodes;
|
|
258612
258630
|
noteChanged(nodes, shown2, ids2);
|
|
258613
258631
|
const out = { ...pose, nodes: shown2, animatedIds: ids2.length ? /* @__PURE__ */ new Set([...pose.animatedIds, ...ids2]) : pose.animatedIds, orbits };
|
|
258614
258632
|
orbitMemo.set(pose, { orbits, pose: out });
|
|
@@ -258624,7 +258642,7 @@ function withSolo(pose, solo) {
|
|
|
258624
258642
|
const on = new Set(solo.filter((id3) => nodes[id3]));
|
|
258625
258643
|
const onTheWay = /* @__PURE__ */ new Set();
|
|
258626
258644
|
for (const id3 of on) for (let n = nodes[nodes[id3]?.parentId ?? ""]; n; n = n.parentId ? nodes[n.parentId] : void 0) onTheWay.add(n.id);
|
|
258627
|
-
const
|
|
258645
|
+
const patch2 = {};
|
|
258628
258646
|
const visit2 = (id3) => {
|
|
258629
258647
|
const n = nodes[id3];
|
|
258630
258648
|
if (!n || on.has(id3)) return;
|
|
@@ -258632,11 +258650,11 @@ function withSolo(pose, solo) {
|
|
|
258632
258650
|
for (const c2 of n.childIds) visit2(c2);
|
|
258633
258651
|
return;
|
|
258634
258652
|
}
|
|
258635
|
-
if (n.visible !== false)
|
|
258653
|
+
if (n.visible !== false) patch2[id3] = { ...n, visible: false };
|
|
258636
258654
|
};
|
|
258637
258655
|
if (on.size) for (const c2 of nodes[frameId]?.childIds ?? []) visit2(c2);
|
|
258638
|
-
const ids2 = Object.keys(
|
|
258639
|
-
const shown2 = ids2.length ? { ...nodes, ...
|
|
258656
|
+
const ids2 = Object.keys(patch2);
|
|
258657
|
+
const shown2 = ids2.length ? { ...nodes, ...patch2 } : nodes;
|
|
258640
258658
|
noteChanged(nodes, shown2, ids2);
|
|
258641
258659
|
const out = { ...pose, nodes: shown2, animatedIds: ids2.length ? /* @__PURE__ */ new Set([...pose.animatedIds, ...ids2]) : pose.animatedIds, solo };
|
|
258642
258660
|
soloMemo.set(pose, { solo: key5, pose: out });
|
|
@@ -260440,7 +260458,6 @@ function retuneShaderAudio(node2, fillId) {
|
|
|
260440
260458
|
}
|
|
260441
260459
|
var init_shader_audio = __esm({
|
|
260442
260460
|
"lib/motion/shader-audio.ts"() {
|
|
260443
|
-
"use strict";
|
|
260444
260461
|
init_shader_params();
|
|
260445
260462
|
init_modifier_edit();
|
|
260446
260463
|
init_keys();
|
|
@@ -260625,8 +260642,8 @@ function timeBoundsOf(s) {
|
|
|
260625
260642
|
const width = s.timeViewWidth;
|
|
260626
260643
|
const soundEnd = (audio) => Math.max(0, ...(audio ?? []).map(audioClipEnd));
|
|
260627
260644
|
if (t3?.kind === "frame") {
|
|
260628
|
-
const
|
|
260629
|
-
return
|
|
260645
|
+
const frame3 = s.document.nodes[t3.frameId];
|
|
260646
|
+
return frame3 ? { duration: frameDuration(s.document.nodes, t3.frameId), fps: timelineFps(frame3.timeline), width, content: soundEnd(frame3.timeline?.audio) } : null;
|
|
260630
260647
|
}
|
|
260631
260648
|
const comp = t3?.kind === "composition" ? s.document.compositions?.[t3.compositionId] : void 0;
|
|
260632
260649
|
return comp ? { duration: compositionDuration(comp), fps: comp.fps, width, content: soundEnd(comp.audio) } : null;
|
|
@@ -260653,7 +260670,7 @@ function snapTime(tr, t3) {
|
|
|
260653
260670
|
return snapToFrame(at4, tr.fps);
|
|
260654
260671
|
}
|
|
260655
260672
|
function createMotionSlice(set4, get4) {
|
|
260656
|
-
const put3 = (
|
|
260673
|
+
const put3 = (patch2) => set4({ transport: { ...get4().transport, ...patch2 } });
|
|
260657
260674
|
const clock2 = (now2) => now2 ?? transportNow();
|
|
260658
260675
|
const frameId = () => {
|
|
260659
260676
|
const s = get4();
|
|
@@ -260815,9 +260832,9 @@ function createMotionSlice(set4, get4) {
|
|
|
260815
260832
|
set4({ solo: cur.includes(id3) ? cur.filter((x2) => x2 !== id3) : [...cur, id3] });
|
|
260816
260833
|
},
|
|
260817
260834
|
onion: { on: false, count: 2, stepFrames: 3 },
|
|
260818
|
-
setOnion: (
|
|
260835
|
+
setOnion: (patch2) => {
|
|
260819
260836
|
const cur = get4().onion;
|
|
260820
|
-
const next2 = { ...cur, ...
|
|
260837
|
+
const next2 = { ...cur, ...patch2, count: Math.max(1, Math.min(8, Math.round(patch2.count ?? cur.count))), stepFrames: Math.max(1, Math.min(30, Math.round(patch2.stepFrames ?? cur.stepFrames))) };
|
|
260821
260838
|
if (next2.on !== cur.on || next2.count !== cur.count || next2.stepFrames !== cur.stepFrames) set4({ onion: next2 });
|
|
260822
260839
|
},
|
|
260823
260840
|
timeViews: {},
|
|
@@ -261082,8 +261099,8 @@ function foldVariant(doc2, masterId, variantId, id3) {
|
|
|
261082
261099
|
if ((k2 === "fontSize" || k2 === "lineHeight") && restyled) continue;
|
|
261083
261100
|
props[k2] = value3;
|
|
261084
261101
|
}
|
|
261085
|
-
const
|
|
261086
|
-
if ("responsive" in
|
|
261102
|
+
const patch2 = breakpointPatch(master, doc2, id3, props);
|
|
261103
|
+
if ("responsive" in patch2 && !same2(patch2.responsive, master.responsive)) nodes[m] = { ...master, responsive: patch2.responsive };
|
|
261087
261104
|
const a = master.childIds ?? [], b = variant.childIds ?? [];
|
|
261088
261105
|
if (a.length === b.length) a.forEach((c2, i2) => walk4(c2, b[i2], false));
|
|
261089
261106
|
};
|
|
@@ -261351,11 +261368,11 @@ function shownRecordOf(nodes, doc2, id3) {
|
|
|
261351
261368
|
const own2 = pinnedRecord(doc2, nodes[id3]);
|
|
261352
261369
|
if (own2) return own2;
|
|
261353
261370
|
for (let at4 = nodes[id3]?.parentId, hops = 0; at4 && hops < 64; at4 = nodes[at4]?.parentId, hops++) {
|
|
261354
|
-
const
|
|
261355
|
-
const pinned = pinnedRecord(doc2,
|
|
261371
|
+
const frame3 = nodes[at4];
|
|
261372
|
+
const pinned = pinnedRecord(doc2, frame3);
|
|
261356
261373
|
if (pinned) return pinned;
|
|
261357
|
-
if (
|
|
261358
|
-
const of =
|
|
261374
|
+
if (frame3?.repeat) return repeatRecords(doc2, frame3.repeat)[0] ?? null;
|
|
261375
|
+
const of = frame3?.route?.collectionId;
|
|
261359
261376
|
if (of && doc2.collections?.[of]) return repeatRecords(doc2, { collectionId: of })[0] ?? null;
|
|
261360
261377
|
}
|
|
261361
261378
|
return null;
|
|
@@ -261641,11 +261658,11 @@ var init_scroll = __esm({
|
|
|
261641
261658
|
|
|
261642
261659
|
// lib/runtime/actions.ts
|
|
261643
261660
|
function layerCenterIn(doc2, id3, frameId) {
|
|
261644
|
-
const
|
|
261661
|
+
const frame3 = doc2.nodes[frameId];
|
|
261645
261662
|
const real = doc2.nodes[id3] ? id3 : id3.includes("::") ? id3.slice(0, id3.indexOf("::")) : id3;
|
|
261646
|
-
if (!
|
|
261663
|
+
if (!frame3 || !doc2.nodes[real] || frame3.width <= 0 || frame3.height <= 0) return null;
|
|
261647
261664
|
const f2 = getWorldTransform(doc2, frameId), l = getWorldTransform(doc2, real);
|
|
261648
|
-
return { x: (l.cx - (f2.cx -
|
|
261665
|
+
return { x: (l.cx - (f2.cx - frame3.width / 2)) / frame3.width, y: (l.cy - (f2.cy - frame3.height / 2)) / frame3.height };
|
|
261649
261666
|
}
|
|
261650
261667
|
function begin(state, ctx2, id3, arrive) {
|
|
261651
261668
|
const nodes = state.document.nodes;
|
|
@@ -262004,17 +262021,17 @@ var init_present_driver = __esm({
|
|
|
262004
262021
|
// lib/runtime/store-adapter.ts
|
|
262005
262022
|
function storePatch(prev, next2) {
|
|
262006
262023
|
if (next2 === prev) return null;
|
|
262007
|
-
const
|
|
262008
|
-
if (next2.document !== prev.document)
|
|
262009
|
-
if (next2.screen !== prev.screen)
|
|
262010
|
-
if (next2.overlays !== prev.overlays)
|
|
262011
|
-
if (next2.history !== prev.history)
|
|
262012
|
-
if (next2.transition !== prev.transition)
|
|
262013
|
-
if (next2.playback !== prev.playback)
|
|
262014
|
-
if (next2.varBackup !== prev.varBackup)
|
|
262015
|
-
if (next2.varGlides !== prev.varGlides)
|
|
262016
|
-
if (next2.scroll !== prev.scroll)
|
|
262017
|
-
return Object.keys(
|
|
262024
|
+
const patch2 = {};
|
|
262025
|
+
if (next2.document !== prev.document) patch2.document = next2.document;
|
|
262026
|
+
if (next2.screen !== prev.screen) patch2.activePrototypeFrameId = next2.screen;
|
|
262027
|
+
if (next2.overlays !== prev.overlays) patch2.prototypeOverlays = next2.overlays;
|
|
262028
|
+
if (next2.history !== prev.history) patch2.prototypeHistory = next2.history;
|
|
262029
|
+
if (next2.transition !== prev.transition) patch2.prototypeTransition = next2.transition;
|
|
262030
|
+
if (next2.playback !== prev.playback) patch2.presentPlayback = next2.playback;
|
|
262031
|
+
if (next2.varBackup !== prev.varBackup) patch2.prototypeVarBackup = next2.varBackup;
|
|
262032
|
+
if (next2.varGlides !== prev.varGlides) patch2.prototypeVarGlides = next2.varGlides;
|
|
262033
|
+
if (next2.scroll !== prev.scroll) patch2.prototypeScrollState = next2.scroll;
|
|
262034
|
+
return Object.keys(patch2).length ? patch2 : null;
|
|
262018
262035
|
}
|
|
262019
262036
|
var runtimeOf;
|
|
262020
262037
|
var init_store_adapter = __esm({
|
|
@@ -262313,7 +262330,7 @@ var init_plugin_store = __esm({
|
|
|
262313
262330
|
setInstalled: (installed3) => set4({ installed: installed3 }),
|
|
262314
262331
|
setManagerOpen: (managerOpen) => set4({ managerOpen }),
|
|
262315
262332
|
upsertSession: (s) => set4((st) => ({ sessions: [...st.sessions.filter((x2) => x2.sessionId !== s.sessionId), s] })),
|
|
262316
|
-
patchSession: (sessionId,
|
|
262333
|
+
patchSession: (sessionId, patch2) => set4((st) => ({ sessions: st.sessions.map((x2) => x2.sessionId === sessionId ? { ...x2, ...patch2 } : x2) })),
|
|
262317
262334
|
removeSession: (sessionId) => set4((st) => ({ sessions: st.sessions.filter((x2) => x2.sessionId !== sessionId) })),
|
|
262318
262335
|
toast: (message, opts = {}) => {
|
|
262319
262336
|
announce(opts.source ? `${opts.source}: ${message}` : message, opts.error ? "assertive" : "polite");
|
|
@@ -262391,7 +262408,6 @@ function formatDate(date5, opts = { month: "short", day: "numeric", year: "numer
|
|
|
262391
262408
|
var cache5, nf;
|
|
262392
262409
|
var init_format = __esm({
|
|
262393
262410
|
"lib/i18n/format.ts"() {
|
|
262394
|
-
"use strict";
|
|
262395
262411
|
init_runtime();
|
|
262396
262412
|
cache5 = /* @__PURE__ */ new Map();
|
|
262397
262413
|
nf = (opts) => cached2("n", opts, (l) => new Intl.NumberFormat(l, opts));
|
|
@@ -270784,9 +270800,9 @@ var init_yjs = __esm({
|
|
|
270784
270800
|
}
|
|
270785
270801
|
}
|
|
270786
270802
|
const nextClock = getState(store6, ownClientID);
|
|
270787
|
-
const
|
|
270803
|
+
const nextId4 = createID(ownClientID, nextClock);
|
|
270788
270804
|
const redoneItem = new Item(
|
|
270789
|
-
|
|
270805
|
+
nextId4,
|
|
270790
270806
|
left,
|
|
270791
270807
|
left && left.lastId,
|
|
270792
270808
|
right,
|
|
@@ -270795,7 +270811,7 @@ var init_yjs = __esm({
|
|
|
270795
270811
|
item.parentSub,
|
|
270796
270812
|
item.content.copy()
|
|
270797
270813
|
);
|
|
270798
|
-
item.redone =
|
|
270814
|
+
item.redone = nextId4;
|
|
270799
270815
|
keepItem(redoneItem, true);
|
|
270800
270816
|
redoneItem.integrate(transaction, 0);
|
|
270801
270817
|
return redoneItem;
|
|
@@ -272065,11 +272081,11 @@ function createReassembler(maxBytes = MAX_MESSAGE_BYTES) {
|
|
|
272065
272081
|
let buf = null;
|
|
272066
272082
|
let filled2 = 0;
|
|
272067
272083
|
return {
|
|
272068
|
-
push(
|
|
272069
|
-
const dec = createDecoder(
|
|
272084
|
+
push(frame3) {
|
|
272085
|
+
const dec = createDecoder(frame3);
|
|
272070
272086
|
if (readVarUint(dec) !== MSG_CHUNK) {
|
|
272071
272087
|
if (buf) throw new Error("Message interrupted mid-chunk");
|
|
272072
|
-
return
|
|
272088
|
+
return frame3;
|
|
272073
272089
|
}
|
|
272074
272090
|
const total2 = readVarUint(dec);
|
|
272075
272091
|
const part = readVarUint8Array(dec);
|
|
@@ -272212,7 +272228,7 @@ var init_client = __esm({
|
|
|
272212
272228
|
send(msg) {
|
|
272213
272229
|
const ws = this.ws;
|
|
272214
272230
|
if (!ws || ws.readyState !== WebSocket.OPEN) return;
|
|
272215
|
-
for (const
|
|
272231
|
+
for (const frame3 of toFrames(msg)) ws.send(frame3);
|
|
272216
272232
|
}
|
|
272217
272233
|
canWrite() {
|
|
272218
272234
|
return this.role === "owner" || this.role === "editor";
|
|
@@ -272844,6 +272860,96 @@ var init_binding = __esm({
|
|
|
272844
272860
|
}
|
|
272845
272861
|
});
|
|
272846
272862
|
|
|
272863
|
+
// lib/client/open-progress.ts
|
|
272864
|
+
function withDeadline(p2, ms2) {
|
|
272865
|
+
let timer;
|
|
272866
|
+
const deadline = new Promise((_, reject) => {
|
|
272867
|
+
timer = setTimeout(() => reject(new OpenTimeoutError()), ms2);
|
|
272868
|
+
});
|
|
272869
|
+
return Promise.race([p2, deadline]).finally(() => clearTimeout(timer));
|
|
272870
|
+
}
|
|
272871
|
+
async function trackOpen(run4, opts = {}) {
|
|
272872
|
+
const current4 = useOpenProgress.getState().open;
|
|
272873
|
+
if (current4 && !current4.error) {
|
|
272874
|
+
const joined = { stage: (s) => patch(current4.id, { stage: s }) };
|
|
272875
|
+
return run4(joined);
|
|
272876
|
+
}
|
|
272877
|
+
const id3 = nextId++;
|
|
272878
|
+
useOpenProgress.setState({ open: { id: id3, name: opts.name, still: opts.still, stage: "download" } });
|
|
272879
|
+
const handle = { stage: (s) => patch(id3, { stage: s }) };
|
|
272880
|
+
let result;
|
|
272881
|
+
try {
|
|
272882
|
+
result = await withDeadline(run4(handle), opts.timeoutMs ?? OPEN_TIMEOUT_MS);
|
|
272883
|
+
} catch (e) {
|
|
272884
|
+
const timedOut = e instanceof OpenTimeoutError || e instanceof Error && e.name === "TimeoutError";
|
|
272885
|
+
if (timedOut || (opts.showError?.(e) ?? true)) patch(id3, { error: timedOut ? "timeout" : "failed", retry: opts.retry });
|
|
272886
|
+
else finishOpen(id3);
|
|
272887
|
+
throw e;
|
|
272888
|
+
}
|
|
272889
|
+
if (opts.failed?.(result)) {
|
|
272890
|
+
patch(id3, { error: "failed", retry: opts.retry });
|
|
272891
|
+
return result;
|
|
272892
|
+
}
|
|
272893
|
+
const settling = opts.settle?.(result) ?? null;
|
|
272894
|
+
if (!settling) {
|
|
272895
|
+
finishOpen(id3);
|
|
272896
|
+
return result;
|
|
272897
|
+
}
|
|
272898
|
+
handle.stage("first-frame");
|
|
272899
|
+
void withDeadline(Promise.resolve(settling), FIRST_FRAME_CAP_MS).catch(() => {
|
|
272900
|
+
}).then(() => finishOpen(id3));
|
|
272901
|
+
return result;
|
|
272902
|
+
}
|
|
272903
|
+
function finishOpen(id3) {
|
|
272904
|
+
useOpenProgress.setState((s) => s.open?.id === id3 && !s.open.error ? { open: null } : s);
|
|
272905
|
+
}
|
|
272906
|
+
function reportOpenStage(stage) {
|
|
272907
|
+
const open4 = useOpenProgress.getState().open;
|
|
272908
|
+
if (open4 && !open4.error) patch(open4.id, { stage });
|
|
272909
|
+
}
|
|
272910
|
+
var useOpenProgress, OPEN_TIMEOUT_MS, FIRST_FRAME_CAP_MS, OpenTimeoutError, nextId, patch;
|
|
272911
|
+
var init_open_progress = __esm({
|
|
272912
|
+
"lib/client/open-progress.ts"() {
|
|
272913
|
+
init_esm();
|
|
272914
|
+
useOpenProgress = create2(() => ({ open: null }));
|
|
272915
|
+
OPEN_TIMEOUT_MS = 45e3;
|
|
272916
|
+
FIRST_FRAME_CAP_MS = 2e4;
|
|
272917
|
+
OpenTimeoutError = class extends Error {
|
|
272918
|
+
constructor() {
|
|
272919
|
+
super("Opening took too long");
|
|
272920
|
+
this.name = "OpenTimeoutError";
|
|
272921
|
+
}
|
|
272922
|
+
};
|
|
272923
|
+
nextId = 1;
|
|
272924
|
+
patch = (id3, p2) => useOpenProgress.setState((s) => s.open?.id === id3 ? { open: { ...s.open, ...p2 } } : s);
|
|
272925
|
+
}
|
|
272926
|
+
});
|
|
272927
|
+
|
|
272928
|
+
// lib/client/first-frame.ts
|
|
272929
|
+
async function firstFrameOf(docId) {
|
|
272930
|
+
if (useEditorStore.getState().document.id !== docId) {
|
|
272931
|
+
await new Promise((resolve7) => {
|
|
272932
|
+
const stop2 = useEditorStore.subscribe((s) => {
|
|
272933
|
+
if (s.document.id === docId) {
|
|
272934
|
+
stop2();
|
|
272935
|
+
resolve7();
|
|
272936
|
+
}
|
|
272937
|
+
});
|
|
272938
|
+
});
|
|
272939
|
+
}
|
|
272940
|
+
await frame();
|
|
272941
|
+
await frame();
|
|
272942
|
+
await loadsSettled(6e3);
|
|
272943
|
+
}
|
|
272944
|
+
var frame;
|
|
272945
|
+
var init_first_frame = __esm({
|
|
272946
|
+
"lib/client/first-frame.ts"() {
|
|
272947
|
+
init_editor_store();
|
|
272948
|
+
init_readiness();
|
|
272949
|
+
frame = () => new Promise((r) => typeof requestAnimationFrame === "undefined" ? setTimeout(r, 16) : requestAnimationFrame(() => r()));
|
|
272950
|
+
}
|
|
272951
|
+
});
|
|
272952
|
+
|
|
272847
272953
|
// lib/storage/media-refs.ts
|
|
272848
272954
|
function mediaHashes(value3) {
|
|
272849
272955
|
const text = JSON.stringify(value3);
|
|
@@ -272988,6 +273094,8 @@ var init_capture = __esm({
|
|
|
272988
273094
|
// lib/templates/use.ts
|
|
272989
273095
|
var use_exports = {};
|
|
272990
273096
|
__export(use_exports, {
|
|
273097
|
+
MEDIA_FETCH_TIMEOUT_MS: () => MEDIA_FETCH_TIMEOUT_MS2,
|
|
273098
|
+
PREPARE_BUDGET_MS: () => PREPARE_BUDGET_MS,
|
|
272991
273099
|
ensureTemplateFonts: () => ensureTemplateFonts,
|
|
272992
273100
|
ensureTemplateMedia: () => ensureTemplateMedia,
|
|
272993
273101
|
prepareTemplate: () => prepareTemplate,
|
|
@@ -273003,27 +273111,33 @@ async function ensureTemplateFonts(t3) {
|
|
|
273003
273111
|
}
|
|
273004
273112
|
for (const family of fontsIn(t3.payload.nodes)) for (const w of weights.get(family) ?? [400]) ensureFontLoaded2(family, w, "normal");
|
|
273005
273113
|
}
|
|
273006
|
-
async function
|
|
273007
|
-
if (typeof window === "undefined" || !t3.payload.media.length) return;
|
|
273114
|
+
async function fetchOne(t3, hash3) {
|
|
273008
273115
|
const { getMediaBlob: getMediaBlob2, putMedia: putMedia2 } = await Promise.resolve().then(() => (init_media_store(), media_store_exports));
|
|
273009
|
-
await
|
|
273010
|
-
|
|
273011
|
-
|
|
273012
|
-
|
|
273013
|
-
|
|
273014
|
-
|
|
273015
|
-
|
|
273016
|
-
return;
|
|
273017
|
-
}
|
|
273018
|
-
} catch {
|
|
273116
|
+
if (await timeoutOf(getMediaBlob2(hash3).catch(() => null), 5e3, null)) return;
|
|
273117
|
+
for (const url4 of templateMediaSources(t3, hash3)) {
|
|
273118
|
+
try {
|
|
273119
|
+
const res = await fetch(url4, { credentials: "same-origin", signal: AbortSignal.timeout(MEDIA_FETCH_TIMEOUT_MS2) });
|
|
273120
|
+
if (res.ok) {
|
|
273121
|
+
await putMedia2(await res.blob());
|
|
273122
|
+
return;
|
|
273019
273123
|
}
|
|
273124
|
+
} catch {
|
|
273020
273125
|
}
|
|
273021
|
-
}
|
|
273126
|
+
}
|
|
273127
|
+
}
|
|
273128
|
+
async function ensureTemplateMedia(t3) {
|
|
273129
|
+
if (typeof window === "undefined" || !t3.payload.media.length) return;
|
|
273130
|
+
const queue2 = [...t3.payload.media];
|
|
273131
|
+
const worker2 = async () => {
|
|
273132
|
+
for (let h = queue2.shift(); h; h = queue2.shift()) await fetchOne(t3, h);
|
|
273133
|
+
};
|
|
273134
|
+
await Promise.all(Array.from({ length: Math.min(MEDIA_CONCURRENCY, queue2.length) }, worker2));
|
|
273022
273135
|
}
|
|
273023
273136
|
async function prepareTemplate(t3) {
|
|
273024
|
-
await Promise.all([ensureTemplateFonts(t3), ensureTemplateMedia(t3)])
|
|
273137
|
+
await timeoutOf(Promise.all([ensureTemplateFonts(t3), ensureTemplateMedia(t3)]).then(() => {
|
|
273138
|
+
}), PREPARE_BUDGET_MS, void 0);
|
|
273025
273139
|
}
|
|
273026
|
-
var templateMediaSources;
|
|
273140
|
+
var templateMediaSources, MEDIA_FETCH_TIMEOUT_MS2, PREPARE_BUDGET_MS, MEDIA_CONCURRENCY, timeoutOf;
|
|
273027
273141
|
var init_use = __esm({
|
|
273028
273142
|
"lib/templates/use.ts"() {
|
|
273029
273143
|
"use strict";
|
|
@@ -273032,6 +273146,15 @@ var init_use = __esm({
|
|
|
273032
273146
|
`/templates/media/${hash3}`,
|
|
273033
273147
|
...t3.meta.source !== "builtin" && t3.meta.id && !t3.meta.id.startsWith("user-") ? [`/api/templates/${encodeURIComponent(t3.meta.id)}/media/${hash3}`] : []
|
|
273034
273148
|
];
|
|
273149
|
+
MEDIA_FETCH_TIMEOUT_MS2 = 15e3;
|
|
273150
|
+
PREPARE_BUDGET_MS = 2e4;
|
|
273151
|
+
MEDIA_CONCURRENCY = 4;
|
|
273152
|
+
timeoutOf = (p2, ms2, fallback2) => {
|
|
273153
|
+
let timer;
|
|
273154
|
+
return Promise.race([p2, new Promise((r) => {
|
|
273155
|
+
timer = setTimeout(() => r(fallback2), ms2);
|
|
273156
|
+
})]).finally(() => clearTimeout(timer));
|
|
273157
|
+
};
|
|
273035
273158
|
}
|
|
273036
273159
|
});
|
|
273037
273160
|
|
|
@@ -288146,11 +288269,11 @@ var init_flac_demuxer = __esm({
|
|
|
288146
288269
|
assert2(this.lastLoadedPos !== null);
|
|
288147
288270
|
assert2(this.audioInfo);
|
|
288148
288271
|
const startPos = this.lastLoadedPos;
|
|
288149
|
-
const
|
|
288272
|
+
const frame3 = await this.readNextFlacFrame({
|
|
288150
288273
|
startPos,
|
|
288151
288274
|
isFirstPacket: this.loadedSamples.length === 0
|
|
288152
288275
|
});
|
|
288153
|
-
if (!
|
|
288276
|
+
if (!frame3) {
|
|
288154
288277
|
this.lastSampleLoaded = true;
|
|
288155
288278
|
return;
|
|
288156
288279
|
}
|
|
@@ -288158,13 +288281,13 @@ var init_flac_demuxer = __esm({
|
|
|
288158
288281
|
const blockOffset = lastSample ? lastSample.blockOffset + lastSample.blockSize : 0;
|
|
288159
288282
|
const sample = {
|
|
288160
288283
|
blockOffset,
|
|
288161
|
-
blockSize:
|
|
288284
|
+
blockSize: frame3.blockSize,
|
|
288162
288285
|
byteOffset: startPos,
|
|
288163
|
-
byteSize:
|
|
288286
|
+
byteSize: frame3.size
|
|
288164
288287
|
};
|
|
288165
|
-
this.lastLoadedPos = this.lastLoadedPos +
|
|
288288
|
+
this.lastLoadedPos = this.lastLoadedPos + frame3.size;
|
|
288166
288289
|
this.loadedSamples.push(sample);
|
|
288167
|
-
if (
|
|
288290
|
+
if (frame3.isLastFrame) {
|
|
288168
288291
|
this.lastSampleLoaded = true;
|
|
288169
288292
|
return;
|
|
288170
288293
|
}
|
|
@@ -296174,14 +296297,14 @@ var init_encode = __esm({
|
|
|
296174
296297
|
});
|
|
296175
296298
|
encoder.configure(config2);
|
|
296176
296299
|
const frameData = new Uint8Array(width * height * 4);
|
|
296177
|
-
const
|
|
296300
|
+
const frame3 = new VideoFrame(frameData, {
|
|
296178
296301
|
format: "RGBA",
|
|
296179
296302
|
codedWidth: width,
|
|
296180
296303
|
codedHeight: height,
|
|
296181
296304
|
timestamp: 0
|
|
296182
296305
|
});
|
|
296183
|
-
encoder.encode(
|
|
296184
|
-
|
|
296306
|
+
encoder.encode(frame3, quantizer !== null ? buildQuantizerEncodeOptions(codec2, quantizer) : void 0);
|
|
296307
|
+
frame3.close();
|
|
296185
296308
|
await encoder.flush();
|
|
296186
296309
|
resolve7(true);
|
|
296187
296310
|
} catch {
|
|
@@ -298592,30 +298715,30 @@ var init_id3 = __esm({
|
|
|
298592
298715
|
}
|
|
298593
298716
|
}
|
|
298594
298717
|
while (reader.pos <= reader.bytes.length - reader.frameHeaderSize()) {
|
|
298595
|
-
const
|
|
298596
|
-
if (!
|
|
298718
|
+
const frame3 = reader.readId3V2Frame();
|
|
298719
|
+
if (!frame3) {
|
|
298597
298720
|
break;
|
|
298598
298721
|
}
|
|
298599
298722
|
const frameStartPos = reader.pos;
|
|
298600
|
-
const frameEndPos = reader.pos +
|
|
298723
|
+
const frameEndPos = reader.pos + frame3.size;
|
|
298601
298724
|
let frameEncrypted = false;
|
|
298602
298725
|
let frameCompressed = false;
|
|
298603
298726
|
let frameUnsynchronized = false;
|
|
298604
298727
|
if (header.majorVersion === 3) {
|
|
298605
|
-
frameEncrypted = !!(
|
|
298606
|
-
frameCompressed = !!(
|
|
298728
|
+
frameEncrypted = !!(frame3.flags & 1 << 6);
|
|
298729
|
+
frameCompressed = !!(frame3.flags & 1 << 7);
|
|
298607
298730
|
} else if (header.majorVersion === 4) {
|
|
298608
|
-
frameEncrypted = !!(
|
|
298609
|
-
frameCompressed = !!(
|
|
298610
|
-
frameUnsynchronized = !!(
|
|
298731
|
+
frameEncrypted = !!(frame3.flags & 1 << 2);
|
|
298732
|
+
frameCompressed = !!(frame3.flags & 1 << 3);
|
|
298733
|
+
frameUnsynchronized = !!(frame3.flags & 1 << 1) || !!(header.flags & Id3V2HeaderFlags.Unsynchronisation);
|
|
298611
298734
|
}
|
|
298612
298735
|
if (frameEncrypted) {
|
|
298613
|
-
Logging._warn(`Skipping encrypted ID3v2 frame ${
|
|
298736
|
+
Logging._warn(`Skipping encrypted ID3v2 frame ${frame3.id}`);
|
|
298614
298737
|
reader.pos = frameEndPos;
|
|
298615
298738
|
continue;
|
|
298616
298739
|
}
|
|
298617
298740
|
if (frameCompressed) {
|
|
298618
|
-
Logging._warn(`Skipping compressed ID3v2 frame ${
|
|
298741
|
+
Logging._warn(`Skipping compressed ID3v2 frame ${frame3.id}`);
|
|
298619
298742
|
reader.pos = frameEndPos;
|
|
298620
298743
|
continue;
|
|
298621
298744
|
}
|
|
@@ -298623,19 +298746,19 @@ var init_id3 = __esm({
|
|
|
298623
298746
|
reader.ununsynchronizeRegion(reader.pos, frameEndPos);
|
|
298624
298747
|
}
|
|
298625
298748
|
tags.raw ??= {};
|
|
298626
|
-
if (
|
|
298749
|
+
if (frame3.id === "TXXX") {
|
|
298627
298750
|
const txxx = tags.raw["TXXX"] ??= {};
|
|
298628
298751
|
const encoding = reader.readId3V2TextEncoding();
|
|
298629
298752
|
const description = reader.readId3V2Text(encoding, frameEndPos);
|
|
298630
298753
|
const value3 = reader.readId3V2Text(encoding, frameEndPos);
|
|
298631
298754
|
txxx[description] ??= value3;
|
|
298632
|
-
} else if (
|
|
298633
|
-
tags.raw[
|
|
298755
|
+
} else if (frame3.id[0] === "T") {
|
|
298756
|
+
tags.raw[frame3.id] ??= reader.readId3V2EncodingAndText(frameEndPos);
|
|
298634
298757
|
} else {
|
|
298635
|
-
tags.raw[
|
|
298758
|
+
tags.raw[frame3.id] ??= reader.readBytes(frame3.size);
|
|
298636
298759
|
}
|
|
298637
298760
|
reader.pos = frameStartPos;
|
|
298638
|
-
switch (
|
|
298761
|
+
switch (frame3.id) {
|
|
298639
298762
|
case "TIT2":
|
|
298640
298763
|
case "TT2":
|
|
298641
298764
|
{
|
|
@@ -298810,7 +298933,7 @@ var init_id3 = __esm({
|
|
|
298810
298933
|
break;
|
|
298811
298934
|
default:
|
|
298812
298935
|
{
|
|
298813
|
-
reader.pos +=
|
|
298936
|
+
reader.pos += frame3.size;
|
|
298814
298937
|
}
|
|
298815
298938
|
;
|
|
298816
298939
|
break;
|
|
@@ -298921,8 +299044,8 @@ var init_id3 = __esm({
|
|
|
298921
299044
|
}
|
|
298922
299045
|
if (nextPos <= this.bytes.length - this.frameHeaderSize()) {
|
|
298923
299046
|
this.pos += size7;
|
|
298924
|
-
const
|
|
298925
|
-
if (
|
|
299047
|
+
const nextId4 = this.readAscii(4);
|
|
299048
|
+
if (nextId4 !== "\0\0\0\0" && !/[0-9A-Z]{4}/.test(nextId4)) {
|
|
298926
299049
|
return false;
|
|
298927
299050
|
}
|
|
298928
299051
|
}
|
|
@@ -304776,8 +304899,8 @@ var init_media_source = __esm({
|
|
|
304776
304899
|
const { numberOfChannels, numberOfFrames, sampleRate, timestamp } = audioSample;
|
|
304777
304900
|
const CHUNK_SIZE = 2048;
|
|
304778
304901
|
const outputs = [];
|
|
304779
|
-
for (let
|
|
304780
|
-
const frameCount2 = Math.min(CHUNK_SIZE, audioSample.numberOfFrames -
|
|
304902
|
+
for (let frame3 = 0; frame3 < numberOfFrames; frame3 += CHUNK_SIZE) {
|
|
304903
|
+
const frameCount2 = Math.min(CHUNK_SIZE, audioSample.numberOfFrames - frame3);
|
|
304781
304904
|
const outputSize2 = frameCount2 * numberOfChannels * this.outputSampleSize;
|
|
304782
304905
|
const outputBuffer = new ArrayBuffer(outputSize2);
|
|
304783
304906
|
const outputView = new DataView(outputBuffer);
|
|
@@ -306091,9 +306214,9 @@ async function measure2(codec2, sampleRate, numberOfChannels) {
|
|
|
306091
306214
|
const total2 = PROBE + MAX_LAG + 2048;
|
|
306092
306215
|
const data = new Float32Array(total2 * numberOfChannels);
|
|
306093
306216
|
for (let ch = 0; ch < numberOfChannels; ch++) data.set(signal, ch * total2);
|
|
306094
|
-
const
|
|
306095
|
-
enc2.encode(
|
|
306096
|
-
|
|
306217
|
+
const frame3 = new AudioData({ format: "f32-planar", sampleRate, numberOfFrames: total2, numberOfChannels, timestamp: 0, data });
|
|
306218
|
+
enc2.encode(frame3);
|
|
306219
|
+
frame3.close();
|
|
306097
306220
|
await enc2.flush();
|
|
306098
306221
|
enc2.close();
|
|
306099
306222
|
if (failed2 || !config2) throw failed2 ?? new Error("no decoder config");
|
|
@@ -308981,7 +309104,7 @@ function viaWorker(channels, sampleRate) {
|
|
|
308981
309104
|
};
|
|
308982
309105
|
worker.onmessageerror = () => breakWorker("the analysis worker sent something that could not be read");
|
|
308983
309106
|
}
|
|
308984
|
-
const id3 =
|
|
309107
|
+
const id3 = nextId2++;
|
|
308985
309108
|
const answer2 = new Promise((resolve7, reject) => {
|
|
308986
309109
|
waiting.set(id3, { resolve: resolve7, reject });
|
|
308987
309110
|
worker.postMessage({ id: id3, channels: channels.map((c2) => c2.slice()), sampleRate });
|
|
@@ -309050,7 +309173,7 @@ async function ensureAnalyses(sound) {
|
|
|
309050
309173
|
const hashes = new Set(sound.filter((c2) => !c2.muted).map((c2) => c2.mediaHash));
|
|
309051
309174
|
await Promise.all([...hashes].map((h) => loadAnalysis(h)));
|
|
309052
309175
|
}
|
|
309053
|
-
var pending5, failed, RETRY_MS3, now, WORKER_TIMEOUT_MS, worker, workerBroken,
|
|
309176
|
+
var pending5, failed, RETRY_MS3, now, WORKER_TIMEOUT_MS, worker, workerBroken, nextId2, waiting, warned;
|
|
309054
309177
|
var init_audio_analysis_store = __esm({
|
|
309055
309178
|
"lib/motion/audio-analysis-store.ts"() {
|
|
309056
309179
|
"use strict";
|
|
@@ -309065,7 +309188,7 @@ var init_audio_analysis_store = __esm({
|
|
|
309065
309188
|
WORKER_TIMEOUT_MS = 2e4;
|
|
309066
309189
|
worker = null;
|
|
309067
309190
|
workerBroken = false;
|
|
309068
|
-
|
|
309191
|
+
nextId2 = 1;
|
|
309069
309192
|
waiting = /* @__PURE__ */ new Map();
|
|
309070
309193
|
warned = /* @__PURE__ */ new Set();
|
|
309071
309194
|
if (typeof window !== "undefined") {
|
|
@@ -310452,28 +310575,28 @@ async function renderTemplateDetail(node2, doc2) {
|
|
|
310452
310575
|
if (!img?.width || !img?.height) return null;
|
|
310453
310576
|
return { bytes: thumbnailWebp(img), type: DETAIL_TYPE, width: img.width, height: img.height };
|
|
310454
310577
|
}
|
|
310455
|
-
async function render(
|
|
310456
|
-
const bytes2 = await renderThumbnailJpeg(
|
|
310578
|
+
async function render(frame3, doc2) {
|
|
310579
|
+
const bytes2 = await renderThumbnailJpeg(frame3, doc2);
|
|
310457
310580
|
return bytes2 ? URL.createObjectURL(new Blob([bytes2], { type: "image/jpeg" })) : null;
|
|
310458
310581
|
}
|
|
310459
|
-
function usePageThumbnail(
|
|
310460
|
-
const cached3 = cache8.get(
|
|
310582
|
+
function usePageThumbnail(frame3, doc2) {
|
|
310583
|
+
const cached3 = cache8.get(frame3);
|
|
310461
310584
|
const [url4, setUrl] = (0, import_react4.useState)(cached3?.url ?? null);
|
|
310462
310585
|
(0, import_react4.useEffect)(() => {
|
|
310463
310586
|
let cancelled = false;
|
|
310464
|
-
const hit = cache8.get(
|
|
310587
|
+
const hit = cache8.get(frame3);
|
|
310465
310588
|
if (hit && hit.doc === doc2) {
|
|
310466
310589
|
setUrl(hit.url);
|
|
310467
310590
|
return;
|
|
310468
310591
|
}
|
|
310469
310592
|
const run4 = async () => {
|
|
310470
|
-
const next2 = await render(
|
|
310593
|
+
const next2 = await render(frame3, doc2);
|
|
310471
310594
|
if (cancelled) {
|
|
310472
310595
|
if (next2) URL.revokeObjectURL(next2);
|
|
310473
310596
|
return;
|
|
310474
310597
|
}
|
|
310475
|
-
const prev = cache8.get(
|
|
310476
|
-
cache8.set(
|
|
310598
|
+
const prev = cache8.get(frame3)?.url;
|
|
310599
|
+
cache8.set(frame3, { doc: doc2, url: next2 });
|
|
310477
310600
|
if (prev && prev !== next2) URL.revokeObjectURL(prev);
|
|
310478
310601
|
setUrl(next2);
|
|
310479
310602
|
};
|
|
@@ -310486,7 +310609,7 @@ function usePageThumbnail(frame2, doc2) {
|
|
|
310486
310609
|
cancelled = true;
|
|
310487
310610
|
clearTimeout(timer);
|
|
310488
310611
|
};
|
|
310489
|
-
}, [
|
|
310612
|
+
}, [frame3, doc2]);
|
|
310490
310613
|
return url4;
|
|
310491
310614
|
}
|
|
310492
310615
|
var import_react4, THUMB_PX, SETTLE_MS, cache8;
|
|
@@ -310591,7 +310714,7 @@ async function deleteCloudTemplate(id3) {
|
|
|
310591
310714
|
useCloudTemplates.setState((s) => ({ available: s.available.filter((x2) => x2.id !== id3) }));
|
|
310592
310715
|
}
|
|
310593
310716
|
async function fetchCloudTemplate(id3) {
|
|
310594
|
-
const { template: template2, payload } = await api(`/api/templates/${encodeURIComponent(id3)}`, { cache: "no-store" });
|
|
310717
|
+
const { template: template2, payload } = await api(`/api/templates/${encodeURIComponent(id3)}`, { cache: "no-store", signal: AbortSignal.timeout(3e4) });
|
|
310595
310718
|
return { meta: template2, payload };
|
|
310596
310719
|
}
|
|
310597
310720
|
async function searchTemplates(o = {}) {
|
|
@@ -310651,7 +310774,10 @@ async function documentFromSeed(seed2) {
|
|
|
310651
310774
|
let template2 = seed2.template;
|
|
310652
310775
|
if (!template2 && seed2.templateId) template2 = await (await Promise.resolve().then(() => (init_templates(), templates_exports))).fetchCloudTemplate(seed2.templateId);
|
|
310653
310776
|
if (template2) {
|
|
310777
|
+
reportOpenStage("media");
|
|
310654
310778
|
await prepareTemplate(template2);
|
|
310779
|
+
reportOpenStage("prepare");
|
|
310780
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
310655
310781
|
const doc2 = documentFromTemplate(template2, seed2.name ?? template2.meta.name, seed2.sizeId);
|
|
310656
310782
|
if ((await Promise.resolve().then(() => (init_library_link(), library_link_exports))).libraryLink() !== "unlinked") return doc2;
|
|
310657
310783
|
const { unlinkLibrary: unlinkLibrary2 } = await Promise.resolve().then(() => (init_libraries(), libraries_exports));
|
|
@@ -310701,6 +310827,7 @@ async function createNewCloudFile(place4 = {}, seed2 = {}) {
|
|
|
310701
310827
|
const doc2 = await documentFromSeed(seed2);
|
|
310702
310828
|
const body = { name: doc2.name, localDocId: doc2.id, workspaceId: activeTeamWorkspaceId(), pageCount: doc2.pages.length, ...place4 };
|
|
310703
310829
|
let key5;
|
|
310830
|
+
reportOpenStage("create");
|
|
310704
310831
|
try {
|
|
310705
310832
|
;
|
|
310706
310833
|
({ key: key5 } = await cloudApi.createFile(body));
|
|
@@ -310728,7 +310855,8 @@ function countTemplateUse(id3) {
|
|
|
310728
310855
|
}
|
|
310729
310856
|
async function createNewFileOrExplain(place4 = {}, seed2 = {}) {
|
|
310730
310857
|
const result = await createNewFile(place4, seed2);
|
|
310731
|
-
|
|
310858
|
+
const loaderShows = result.ok === false && result.reason === "failed" && !!useOpenProgress.getState().open;
|
|
310859
|
+
if (!result.ok && result.reason !== "plan" && !loaderShows) reportNewFileBlocked(result.reason);
|
|
310732
310860
|
return result;
|
|
310733
310861
|
}
|
|
310734
310862
|
async function createFreshFileOrExplain(place4 = {}, seed2 = {}) {
|
|
@@ -310747,6 +310875,7 @@ var init_new_file = __esm({
|
|
|
310747
310875
|
init_page_presets();
|
|
310748
310876
|
init_apply2();
|
|
310749
310877
|
init_use();
|
|
310878
|
+
init_open_progress();
|
|
310750
310879
|
init_editor_store();
|
|
310751
310880
|
init_document_library();
|
|
310752
310881
|
init_tab_mode();
|
|
@@ -310964,7 +311093,17 @@ async function openCloudFile(key5, opts = {}) {
|
|
|
310964
311093
|
const run4 = (async () => {
|
|
310965
311094
|
opening++;
|
|
310966
311095
|
try {
|
|
310967
|
-
await
|
|
311096
|
+
await trackOpen(async () => {
|
|
311097
|
+
await loadCloudFile(key5, opts);
|
|
311098
|
+
}, {
|
|
311099
|
+
retry: () => {
|
|
311100
|
+
void openCloudFile(key5, opts).catch(() => {
|
|
311101
|
+
});
|
|
311102
|
+
},
|
|
311103
|
+
// A refusal or a failed request: the file's page explains it (sign in, ask the owner). A timeout is the loader's.
|
|
311104
|
+
showError: () => false,
|
|
311105
|
+
settle: () => firstFrameOf(useEditorStore.getState().document.id)
|
|
311106
|
+
});
|
|
310968
311107
|
} finally {
|
|
310969
311108
|
opening--;
|
|
310970
311109
|
}
|
|
@@ -310993,6 +311132,7 @@ async function loadCloudFile(key5, opts) {
|
|
|
310993
311132
|
fetch(`/api/files/${key5}/snapshot`, { headers: { ...await authHeaders(), ...haveLocal ? { "x-have-snapshot-version": String(existing.version) } : {} } })
|
|
310994
311133
|
]);
|
|
310995
311134
|
if (!res.ok) throw new ApiError(res.status, "Could not load file", "load_failed");
|
|
311135
|
+
reportOpenStage("open");
|
|
310996
311136
|
const version7 = Number(res.headers.get("x-snapshot-version") ?? "0");
|
|
310997
311137
|
if (res.status === 204 && haveLocal) {
|
|
310998
311138
|
await useEditorStore.getState().openDocument(existing.docId);
|
|
@@ -311282,6 +311422,7 @@ function startCloudSync() {
|
|
|
311282
311422
|
var status, readOnlyDoc, activeLink, statusListeners, notice, urlArmed, opening, syncStatus, canEdit, uploaded, MEDIA_UPLOAD_PARALLEL, pushTimer, pushing, dirty, pendingMedia, collab, collabSession, collabAnonymous, uploadedThumbs, thumbCheckedAt, THUMB_EVERY_MS, THUMB_MIN_GAP_MS, putThumbnail, openingFiles, mediaHealed, started2;
|
|
311283
311423
|
var init_sync2 = __esm({
|
|
311284
311424
|
"lib/client/cloud/sync.ts"() {
|
|
311425
|
+
"use strict";
|
|
311285
311426
|
init_paint_repair();
|
|
311286
311427
|
init_migrate();
|
|
311287
311428
|
init_view();
|
|
@@ -311298,6 +311439,8 @@ var init_sync2 = __esm({
|
|
|
311298
311439
|
init_private();
|
|
311299
311440
|
init_tab_mode();
|
|
311300
311441
|
init_editor_store();
|
|
311442
|
+
init_open_progress();
|
|
311443
|
+
init_first_frame();
|
|
311301
311444
|
init_new_file();
|
|
311302
311445
|
init_new_file_block();
|
|
311303
311446
|
init_dist_node();
|
|
@@ -311741,8 +311884,8 @@ function tagFrameOrder(node2, tag2) {
|
|
|
311741
311884
|
if (tag2.direction === "REVERSE") return fwd.reverse();
|
|
311742
311885
|
return fwd.length > 2 ? [...fwd, ...fwd.slice(1, -1).reverse()] : fwd;
|
|
311743
311886
|
}
|
|
311744
|
-
function pixelFrameSVGBody(node2,
|
|
311745
|
-
const rgba = frameRGBA2(node2,
|
|
311887
|
+
function pixelFrameSVGBody(node2, frame3) {
|
|
311888
|
+
const rgba = frameRGBA2(node2, frame3);
|
|
311746
311889
|
const cw = node2.width / node2.pixelWidth, ch = node2.height / node2.pixelHeight;
|
|
311747
311890
|
const parts = [];
|
|
311748
311891
|
for (const r of mergeRects(rgba, node2.pixelWidth, node2.pixelHeight)) {
|
|
@@ -311752,12 +311895,12 @@ function pixelFrameSVGBody(node2, frame2) {
|
|
|
311752
311895
|
}
|
|
311753
311896
|
return `<g shape-rendering="crispEdges">${parts.join("")}</g>`;
|
|
311754
311897
|
}
|
|
311755
|
-
function pixelFrameSVG(node2,
|
|
311756
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${fmt(node2.width)}" height="${fmt(node2.height)}" viewBox="0 0 ${fmt(node2.width)} ${fmt(node2.height)}">${pixelFrameSVGBody(node2,
|
|
311898
|
+
function pixelFrameSVG(node2, frame3) {
|
|
311899
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${fmt(node2.width)}" height="${fmt(node2.height)}" viewBox="0 0 ${fmt(node2.width)} ${fmt(node2.height)}">${pixelFrameSVGBody(node2, frame3)}</svg>`;
|
|
311757
311900
|
}
|
|
311758
|
-
async function pixelFramePNG(node2,
|
|
311901
|
+
async function pixelFramePNG(node2, frame3, scale = 1) {
|
|
311759
311902
|
const s = Math.max(1, Math.round(scale));
|
|
311760
|
-
return pngBlob(scaleRGBA(frameRGBA2(node2,
|
|
311903
|
+
return pngBlob(scaleRGBA(frameRGBA2(node2, frame3), node2.pixelWidth, node2.pixelHeight, s), node2.pixelWidth * s, node2.pixelHeight * s);
|
|
311761
311904
|
}
|
|
311762
311905
|
function spriteSheetLayout(node2, layout2, scale, imageName) {
|
|
311763
311906
|
const s = Math.max(1, Math.round(scale));
|
|
@@ -311862,7 +312005,7 @@ var init_pixel_export = __esm({
|
|
|
311862
312005
|
init_pixel_layers();
|
|
311863
312006
|
init_cells();
|
|
311864
312007
|
init_algorithms();
|
|
311865
|
-
frameRGBA2 = (node2,
|
|
312008
|
+
frameRGBA2 = (node2, frame3) => withPixelLayers(frameRGBA(node2, frame3), getPixelLayers(node2, frame3));
|
|
311866
312009
|
fmt = (v) => (Math.round(v * 1e3) / 1e3).toString();
|
|
311867
312010
|
pngBlob = async (bytes2, w, h) => new Blob([await encodePng(w, h, bytes2)], { type: "image/png" });
|
|
311868
312011
|
}
|
|
@@ -311886,6 +312029,7 @@ function creditLine(c2) {
|
|
|
311886
312029
|
var MAX_PHOTO_PAGE, MAX_PHOTO_QUERY, UUID, isPhotoId, photoImagePath;
|
|
311887
312030
|
var init_stock = __esm({
|
|
311888
312031
|
"lib/photos/stock.ts"() {
|
|
312032
|
+
"use strict";
|
|
311889
312033
|
MAX_PHOTO_PAGE = 12;
|
|
311890
312034
|
MAX_PHOTO_QUERY = 200;
|
|
311891
312035
|
UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -316928,17 +317072,17 @@ async function runPixelExport(node2, setting, doc2) {
|
|
|
316928
317072
|
const grid = node2;
|
|
316929
317073
|
const px5 = await Promise.resolve().then(() => (init_pixel_export(), pixel_export_exports));
|
|
316930
317074
|
const layers2 = await Promise.resolve().then(() => (init_pixel_layers(), pixel_layers_exports));
|
|
316931
|
-
const
|
|
317075
|
+
const frame3 = Math.max(0, Math.min(grid.frames.length - 1, grid.activeFrame || 0));
|
|
316932
317076
|
const scale = Math.max(1, Math.round(setting.scale || 1));
|
|
316933
317077
|
const name2 = exportFilename(node2, setting);
|
|
316934
317078
|
switch (setting.format) {
|
|
316935
317079
|
case "PNG":
|
|
316936
|
-
await layers2.ensurePixelLayers(grid, doc2,
|
|
316937
|
-
downloadBlob(await px5.pixelFramePNG(grid,
|
|
317080
|
+
await layers2.ensurePixelLayers(grid, doc2, frame3);
|
|
317081
|
+
downloadBlob(await px5.pixelFramePNG(grid, frame3, scale), name2);
|
|
316938
317082
|
return true;
|
|
316939
317083
|
case "SVG":
|
|
316940
|
-
await layers2.ensurePixelLayers(grid, doc2,
|
|
316941
|
-
downloadBlob(new Blob([px5.pixelFrameSVG(grid,
|
|
317084
|
+
await layers2.ensurePixelLayers(grid, doc2, frame3);
|
|
317085
|
+
downloadBlob(new Blob([px5.pixelFrameSVG(grid, frame3)], { type: "image/svg+xml" }), name2);
|
|
316942
317086
|
return true;
|
|
316943
317087
|
case "GIF": {
|
|
316944
317088
|
await layers2.ensureAllPixelLayers(grid, doc2);
|
|
@@ -317740,9 +317884,9 @@ async function generateVideoFile(req, opts = {}) {
|
|
|
317740
317884
|
if (req.startFrameIds?.length) {
|
|
317741
317885
|
if (!model.startImage) throw new AiClientError(`${model.label} can\u2019t start from an image. Pick a Seedance or Veo 3.1 Fast model, or turn the start frame off.`, "bad_request", 0);
|
|
317742
317886
|
if (!req.doc) throw new AiClientError("The start frame needs the document.", "not_ready", 0);
|
|
317743
|
-
const
|
|
317744
|
-
if (!
|
|
317745
|
-
image =
|
|
317887
|
+
const frame3 = await renderStartFrame(req.doc, req.startFrameIds);
|
|
317888
|
+
if (!frame3) throw new AiClientError("Could not render the start frame \u2014 the canvas may not be ready, or the layers have no visible area.", "not_ready", 0);
|
|
317889
|
+
image = frame3;
|
|
317746
317890
|
}
|
|
317747
317891
|
const result = await requestVideo({
|
|
317748
317892
|
model: model.id,
|
|
@@ -317815,9 +317959,9 @@ async function renderDocument(doc2, nodeIds, options) {
|
|
|
317815
317959
|
if (options?.at !== void 0) {
|
|
317816
317960
|
const { bakeMotion: bakeMotion3 } = await Promise.resolve().then(() => (init_pose(), pose_exports));
|
|
317817
317961
|
for (const id3 of nodeIds) {
|
|
317818
|
-
let
|
|
317819
|
-
while (
|
|
317820
|
-
if (
|
|
317962
|
+
let frame3 = doc2.nodes[id3];
|
|
317963
|
+
while (frame3 && !frame3.timeline && frame3.parentId && doc2.nodes[frame3.parentId]?.type !== "PAGE") frame3 = doc2.nodes[frame3.parentId];
|
|
317964
|
+
if (frame3) doc2 = { ...doc2, nodes: bakeMotion3(doc2.nodes, frame3.id, options.at) };
|
|
317821
317965
|
}
|
|
317822
317966
|
}
|
|
317823
317967
|
return selectionReferenceImages2(doc2, [...nodeIds], { maxEdge: options?.maxEdge, max: 8, format: "JPG", ...options?.bands ? { bands: options.bands } : {} });
|
|
@@ -317943,7 +318087,6 @@ function agentToolList() {
|
|
|
317943
318087
|
var AGENT_CAPABILITIES, legacyCommandId, legacyTools, blobToDataUrl3, provided, legacyTool, legacyToolList;
|
|
317944
318088
|
var init_agent = __esm({
|
|
317945
318089
|
"lib/commands/agent.ts"() {
|
|
317946
|
-
"use strict";
|
|
317947
318090
|
init_types5();
|
|
317948
318091
|
init_registry();
|
|
317949
318092
|
init_errors();
|
|
@@ -318177,7 +318320,7 @@ function bbox2(boxes) {
|
|
|
318177
318320
|
const maxX = Math.max(...boxes.map((b) => b.x + b.width)), maxY = Math.max(...boxes.map((b) => b.y + b.height));
|
|
318178
318321
|
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
318179
318322
|
}
|
|
318180
|
-
function inferAutoLayout(
|
|
318323
|
+
function inferAutoLayout(frame3, children) {
|
|
318181
318324
|
const kids = children.filter((c3) => c3.width >= 0 && c3.height >= 0);
|
|
318182
318325
|
const empty2 = {
|
|
318183
318326
|
layoutMode: "VERTICAL",
|
|
@@ -318197,7 +318340,7 @@ function inferAutoLayout(frame2, children) {
|
|
|
318197
318340
|
const sepV = separation(kids, "VERTICAL");
|
|
318198
318341
|
const sepH = separation(kids, "HORIZONTAL");
|
|
318199
318342
|
let dir;
|
|
318200
|
-
if (kids.length === 1) dir =
|
|
318343
|
+
if (kids.length === 1) dir = frame3.width > frame3.height ? "HORIZONTAL" : "VERTICAL";
|
|
318201
318344
|
else if (rowsV.length !== colsH.length) dir = rowsV.length > colsH.length ? "VERTICAL" : "HORIZONTAL";
|
|
318202
318345
|
else if (Math.abs(sepV - sepH) > 0.01) dir = sepV > sepH ? "VERTICAL" : "HORIZONTAL";
|
|
318203
318346
|
else {
|
|
@@ -318229,8 +318372,8 @@ function inferAutoLayout(frame2, children) {
|
|
|
318229
318372
|
const padding3 = {
|
|
318230
318373
|
top: Math.max(0, Math.round(bb.y)),
|
|
318231
318374
|
left: Math.max(0, Math.round(bb.x)),
|
|
318232
|
-
bottom: Math.max(0, Math.round(
|
|
318233
|
-
right: Math.max(0, Math.round(
|
|
318375
|
+
bottom: Math.max(0, Math.round(frame3.height - (bb.y + bb.height))),
|
|
318376
|
+
right: Math.max(0, Math.round(frame3.width - (bb.x + bb.width)))
|
|
318234
318377
|
};
|
|
318235
318378
|
const before = dir === "HORIZONTAL" ? padding3.left : padding3.top;
|
|
318236
318379
|
const after = dir === "HORIZONTAL" ? padding3.right : padding3.bottom;
|
|
@@ -318272,7 +318415,7 @@ function applyLayoutSuggestion(doc2, nodeId2, s) {
|
|
|
318272
318415
|
const nodes = { ...doc2.nodes };
|
|
318273
318416
|
let host = original;
|
|
318274
318417
|
if (host.type === "GROUP") {
|
|
318275
|
-
const
|
|
318418
|
+
const frame3 = createFrame({
|
|
318276
318419
|
id: host.id,
|
|
318277
318420
|
name: host.name,
|
|
318278
318421
|
x: host.x,
|
|
@@ -318289,7 +318432,7 @@ function applyLayoutSuggestion(doc2, nodeId2, s) {
|
|
|
318289
318432
|
backgroundColor: { r: 1, g: 1, b: 1, a: 0 },
|
|
318290
318433
|
clipsContent: false
|
|
318291
318434
|
});
|
|
318292
|
-
host =
|
|
318435
|
+
host = frame3;
|
|
318293
318436
|
}
|
|
318294
318437
|
const flow = new Set(flowChildren(doc2, host).map((c2) => c2.id));
|
|
318295
318438
|
const rest = host.childIds.filter((id3) => !flow.has(id3));
|
|
@@ -318435,8 +318578,8 @@ function applyOverride(doc2, virtualId, props) {
|
|
|
318435
318578
|
}
|
|
318436
318579
|
function commitUpdates(ctx2, doc2, updates) {
|
|
318437
318580
|
let next2 = doc2;
|
|
318438
|
-
for (const [id3,
|
|
318439
|
-
next2 = isVirtualId2(id3) ? applyOverride(next2, id3,
|
|
318581
|
+
for (const [id3, patch2] of updates) {
|
|
318582
|
+
next2 = isVirtualId2(id3) ? applyOverride(next2, id3, patch2) : updateNode(next2, id3, patch2);
|
|
318440
318583
|
}
|
|
318441
318584
|
next2 = applyInvariants(next2, updates.keys());
|
|
318442
318585
|
ctx2.commit(next2);
|
|
@@ -318710,14 +318853,14 @@ function isSvgMarkup(text) {
|
|
|
318710
318853
|
}
|
|
318711
318854
|
function placeSvgLayers(doc2, parentId, svg, place4) {
|
|
318712
318855
|
if (!doc2.nodes[parentId] || svg.length > MAX_SVG_LAYER_BYTES) return null;
|
|
318713
|
-
const
|
|
318714
|
-
let next2 = addNode(doc2,
|
|
318856
|
+
const frame3 = createFrame({ name: place4.name, x: place4.cx, y: place4.cy, width: 1, height: 1, fills: [], backgroundColor: { r: 1, g: 1, b: 1, a: 0 }, clipsContent: false });
|
|
318857
|
+
let next2 = addNode(doc2, frame3, parentId);
|
|
318715
318858
|
try {
|
|
318716
|
-
next2 = importSVG(svg, next2,
|
|
318859
|
+
next2 = importSVG(svg, next2, frame3.id);
|
|
318717
318860
|
} catch {
|
|
318718
318861
|
return null;
|
|
318719
318862
|
}
|
|
318720
|
-
const kids = next2.nodes[
|
|
318863
|
+
const kids = next2.nodes[frame3.id].childIds.map((id3) => next2.nodes[id3]).filter(Boolean);
|
|
318721
318864
|
if (!kids.length) return null;
|
|
318722
318865
|
const nodes = { ...next2.nodes };
|
|
318723
318866
|
if (place4.intern) {
|
|
@@ -318730,8 +318873,8 @@ function placeSvgLayers(doc2, parentId, svg, place4) {
|
|
|
318730
318873
|
const maxX = Math.max(...kids.map((k2) => k2.x + k2.width)), maxY = Math.max(...kids.map((k2) => k2.y + k2.height));
|
|
318731
318874
|
for (const k2 of kids) nodes[k2.id] = { ...nodes[k2.id], x: k2.x - minX, y: k2.y - minY };
|
|
318732
318875
|
const w = Math.max(1, maxX - minX), h = Math.max(1, maxY - minY);
|
|
318733
|
-
nodes[
|
|
318734
|
-
return { doc: { ...next2, nodes }, id:
|
|
318876
|
+
nodes[frame3.id] = { ...nodes[frame3.id], x: Math.round(place4.cx - w / 2), y: Math.round(place4.cy - h / 2), width: w, height: h };
|
|
318877
|
+
return { doc: { ...next2, nodes }, id: frame3.id };
|
|
318735
318878
|
}
|
|
318736
318879
|
var MAX_SVG_LAYER_BYTES;
|
|
318737
318880
|
var init_svg_place = __esm({
|
|
@@ -319097,15 +319240,15 @@ var init_node = __esm({
|
|
|
319097
319240
|
const changedKeys = /* @__PURE__ */ new Set();
|
|
319098
319241
|
for (const u of args2.updates) {
|
|
319099
319242
|
resolvedNodeOrThrow(doc2, u.id);
|
|
319100
|
-
const
|
|
319243
|
+
const patch2 = {};
|
|
319101
319244
|
for (const [k2, v] of Object.entries(u.props)) {
|
|
319102
319245
|
if (args2.strict && FORBIDDEN_PROPS.has(k2)) throw new ToolError(`update_nodes cannot change "${k2}". Use reparent, delete_nodes or create_node instead.`);
|
|
319103
319246
|
if (FORBIDDEN_PROPS.has(k2) || v === void 0) continue;
|
|
319104
|
-
|
|
319247
|
+
patch2[k2] = v;
|
|
319105
319248
|
changedKeys.add(k2);
|
|
319106
319249
|
}
|
|
319107
|
-
if (args2.strict && !Object.keys(
|
|
319108
|
-
patches.set(u.id,
|
|
319250
|
+
if (args2.strict && !Object.keys(patch2).length) throw new ToolError(`No properties given for "${u.id}".`);
|
|
319251
|
+
patches.set(u.id, patch2);
|
|
319109
319252
|
}
|
|
319110
319253
|
commitUpdates(ctx2, doc2, patches);
|
|
319111
319254
|
return { summary: `Updated ${plural2(patches.size, "layer")} (${[...changedKeys].slice(0, 6).join(", ")})`, data: { ids: [...patches.keys()] } };
|
|
@@ -319806,7 +319949,7 @@ var init_node = __esm({
|
|
|
319806
319949
|
|
|
319807
319950
|
// lib/commands/text.ts
|
|
319808
319951
|
function applyTypeStyle(node2, styles) {
|
|
319809
|
-
const
|
|
319952
|
+
const patch2 = { ...styles };
|
|
319810
319953
|
const segments = node2.styledSegments;
|
|
319811
319954
|
if (segments?.length) {
|
|
319812
319955
|
const keys4 = Object.keys(styles);
|
|
@@ -319815,9 +319958,9 @@ function applyTypeStyle(node2, styles) {
|
|
|
319815
319958
|
for (const k2 of keys4) delete next2[k2];
|
|
319816
319959
|
return next2;
|
|
319817
319960
|
}).filter((seg) => Object.keys(seg).length > 2);
|
|
319818
|
-
|
|
319961
|
+
patch2.styledSegments = stripped;
|
|
319819
319962
|
}
|
|
319820
|
-
return
|
|
319963
|
+
return patch2;
|
|
319821
319964
|
}
|
|
319822
319965
|
var textSet, TYPE_FIELDS, textSetTypography, textSearchFonts, textSetEffect;
|
|
319823
319966
|
var init_text = __esm({
|
|
@@ -320188,8 +320331,8 @@ var init_text_path2 = __esm({
|
|
|
320188
320331
|
if (!isClosedOutline(shape2) || shapeId === textId) throw new ToolError(`"${shape2.name}" (${shapeId}) has no closed outline to flow text into. Use an ellipse, rectangle, polygon, star, frame or a closed vector.`);
|
|
320189
320332
|
const t3 = text;
|
|
320190
320333
|
const area4 = { shapeId, ...args2.inset !== void 0 ? { inset: args2.inset } : t3.textArea?.inset !== void 0 ? { inset: t3.textArea.inset } : {} };
|
|
320191
|
-
const
|
|
320192
|
-
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[textId,
|
|
320334
|
+
const patch2 = { textArea: area4, textPath: void 0, textAutoResize: "NONE", ...args2.fit ? { textFit: args2.fit } : {}, ...areaBoxPatch(doc2.nodes, t3, shapeId) };
|
|
320335
|
+
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[textId, patch2]]));
|
|
320193
320336
|
return { summary: `Flowed "${text.name}" into "${shape2.name}"`, data: { id: textId, shapeId } };
|
|
320194
320337
|
}
|
|
320195
320338
|
});
|
|
@@ -320552,7 +320695,7 @@ var init_paint = __esm({
|
|
|
320552
320695
|
if (!n) continue;
|
|
320553
320696
|
stack.push(...n.childIds ?? []);
|
|
320554
320697
|
const rec = n;
|
|
320555
|
-
const
|
|
320698
|
+
const patch2 = {};
|
|
320556
320699
|
let hit = 0;
|
|
320557
320700
|
const paints = rec.fills;
|
|
320558
320701
|
if (paints?.length) {
|
|
@@ -320581,7 +320724,7 @@ var init_paint = __esm({
|
|
|
320581
320724
|
}
|
|
320582
320725
|
return out;
|
|
320583
320726
|
});
|
|
320584
|
-
if (changed)
|
|
320727
|
+
if (changed) patch2.fills = next2;
|
|
320585
320728
|
}
|
|
320586
320729
|
const strokes = rec.strokes;
|
|
320587
320730
|
if (strokes?.length) {
|
|
@@ -320593,7 +320736,7 @@ var init_paint = __esm({
|
|
|
320593
320736
|
hit++;
|
|
320594
320737
|
return { ...s, color: c2 };
|
|
320595
320738
|
});
|
|
320596
|
-
if (changed)
|
|
320739
|
+
if (changed) patch2.strokes = next2;
|
|
320597
320740
|
}
|
|
320598
320741
|
const effects = effectsOf(n);
|
|
320599
320742
|
if (effects.length) {
|
|
@@ -320607,18 +320750,18 @@ var init_paint = __esm({
|
|
|
320607
320750
|
return { ...e, color: c2 };
|
|
320608
320751
|
});
|
|
320609
320752
|
if (changed) {
|
|
320610
|
-
|
|
320611
|
-
|
|
320612
|
-
|
|
320753
|
+
patch2.effects = next2;
|
|
320754
|
+
patch2.shadows = void 0;
|
|
320755
|
+
patch2.blurs = void 0;
|
|
320613
320756
|
}
|
|
320614
320757
|
}
|
|
320615
320758
|
const bg = swapColor(rec.backgroundColor);
|
|
320616
320759
|
if (bg) {
|
|
320617
|
-
|
|
320760
|
+
patch2.backgroundColor = bg;
|
|
320618
320761
|
hit++;
|
|
320619
320762
|
}
|
|
320620
320763
|
if (hit) {
|
|
320621
|
-
nodes[id3] = { ...n, ...
|
|
320764
|
+
nodes[id3] = { ...n, ...patch2 };
|
|
320622
320765
|
touched.push(id3);
|
|
320623
320766
|
swaps += hit;
|
|
320624
320767
|
}
|
|
@@ -321982,9 +322125,9 @@ function clipOr(doc2, id3, frameId) {
|
|
|
321982
322125
|
if (!c2) throw new Error(`"${doc2.nodes[id3]?.name ?? id3}" is not a video layer.`);
|
|
321983
322126
|
return c2;
|
|
321984
322127
|
}
|
|
321985
|
-
function withSound(node2, fill,
|
|
322128
|
+
function withSound(node2, fill, patch2) {
|
|
321986
322129
|
const cur = fillsOf(node2)[fill]?.videoSound ?? { muted: true };
|
|
321987
|
-
const next2 = { ...cur, ...
|
|
322130
|
+
const next2 = { ...cur, ...patch2 };
|
|
321988
322131
|
for (const k2 of Object.keys(next2)) if (next2[k2] === void 0) delete next2[k2];
|
|
321989
322132
|
if (next2.muted === false) delete next2.muted;
|
|
321990
322133
|
if (next2.offset !== void 0) {
|
|
@@ -322002,10 +322145,10 @@ function withSound(node2, fill, patch) {
|
|
|
322002
322145
|
if (next2.fadeCurve !== "equalPower") delete next2.fadeCurve;
|
|
322003
322146
|
return withVideoPaint(node2, fill, { videoSound: next2 });
|
|
322004
322147
|
}
|
|
322005
|
-
function editVideoSound(doc2, id3, frameId,
|
|
322148
|
+
function editVideoSound(doc2, id3, frameId, patch2) {
|
|
322006
322149
|
const c2 = clipOr(doc2, id3, frameId);
|
|
322007
322150
|
const len3 = c2.end - c2.start;
|
|
322008
|
-
const p2 = { ...
|
|
322151
|
+
const p2 = { ...patch2 };
|
|
322009
322152
|
for (const k2 of ["fadeIn", "fadeOut"]) if (p2[k2] !== void 0) p2[k2] = Math.min(len3, p2[k2]);
|
|
322010
322153
|
return withNode(doc2, withSound(doc2.nodes[id3], c2.fill, p2));
|
|
322011
322154
|
}
|
|
@@ -322110,9 +322253,9 @@ function setVideoSpeed(doc2, id3, frameId, speed) {
|
|
|
322110
322253
|
}
|
|
322111
322254
|
return withNode(doc2, next2);
|
|
322112
322255
|
}
|
|
322113
|
-
function editVideoPaint(doc2, id3, frameId,
|
|
322256
|
+
function editVideoPaint(doc2, id3, frameId, patch2) {
|
|
322114
322257
|
const c2 = clipOr(doc2, id3, frameId);
|
|
322115
|
-
return withNode(doc2, withVideoPaint(doc2.nodes[id3], c2.fill,
|
|
322258
|
+
return withNode(doc2, withVideoPaint(doc2.nodes[id3], c2.fill, patch2));
|
|
322116
322259
|
}
|
|
322117
322260
|
function splitVideo(doc2, id3, frameId, at4) {
|
|
322118
322261
|
const c2 = clipOr(doc2, id3, frameId);
|
|
@@ -322218,7 +322361,7 @@ function crossfadeAudio(holder, aId, bId, ms2, sourceMs) {
|
|
|
322218
322361
|
const aEnd = audioClipEnd(a);
|
|
322219
322362
|
let overlap = aEnd - b.start;
|
|
322220
322363
|
let next2 = holder;
|
|
322221
|
-
const
|
|
322364
|
+
const patch2 = (id3, p2) => {
|
|
322222
322365
|
next2 = editAudioClip(next2, id3, p2);
|
|
322223
322366
|
};
|
|
322224
322367
|
if (overlap < d) {
|
|
@@ -322228,13 +322371,13 @@ function crossfadeAudio(holder, aId, bId, ms2, sourceMs) {
|
|
|
322228
322371
|
const fileLen = sourceMs?.(a.mediaHash);
|
|
322229
322372
|
const tailRoom = fileLen !== void 0 ? Math.max(0, Math.floor((fileLen - a.out) / sa)) : Infinity;
|
|
322230
322373
|
const tail = Math.min(need - head2, tailRoom);
|
|
322231
|
-
if (tail > 0)
|
|
322232
|
-
if (head2 > 0)
|
|
322374
|
+
if (tail > 0) patch2(a.id, { out: Math.round(a.out + tail * sa) });
|
|
322375
|
+
if (head2 > 0) patch2(b.id, { start: b.start - head2, in: Math.round(b.in - head2 * sb) });
|
|
322233
322376
|
overlap = Math.max(0, overlap) + head2 + tail;
|
|
322234
322377
|
}
|
|
322235
322378
|
const fade = Math.max(1, Math.round(overlap));
|
|
322236
|
-
|
|
322237
|
-
|
|
322379
|
+
patch2(a.id, { fadeOut: fade, fadeCurve: "equalPower" });
|
|
322380
|
+
patch2(b.id, { fadeIn: fade, fadeCurve: "equalPower" });
|
|
322238
322381
|
return next2;
|
|
322239
322382
|
}
|
|
322240
322383
|
function clipUnder(doc2, id3, frameId) {
|
|
@@ -322290,9 +322433,9 @@ var init_video_edit = __esm({
|
|
|
322290
322433
|
init_time();
|
|
322291
322434
|
init_video_clip();
|
|
322292
322435
|
withNode = (doc2, node2) => doc2.nodes[node2.id] === node2 ? doc2 : { ...doc2, nodes: { ...doc2.nodes, [node2.id]: node2 } };
|
|
322293
|
-
motionWith = (m,
|
|
322294
|
-
const next2 = { tracks: {}, ...m, ...
|
|
322295
|
-
for (const k2 of Object.keys(
|
|
322436
|
+
motionWith = (m, patch2) => {
|
|
322437
|
+
const next2 = { tracks: {}, ...m, ...patch2 };
|
|
322438
|
+
for (const k2 of Object.keys(patch2)) if (next2[k2] === void 0) delete next2[k2];
|
|
322296
322439
|
return !Object.keys(next2.tracks).length && next2.timeOffset === void 0 && next2.span === void 0 && next2.stagger === void 0 ? void 0 : next2;
|
|
322297
322440
|
};
|
|
322298
322441
|
videoNodeIdsOn = (doc2, frameId) => videoNodeIds(doc2.nodes).filter((id3) => id3 !== frameId && localTime(doc2.nodes, id3, frameId, 0) !== void 0);
|
|
@@ -322367,9 +322510,9 @@ function applyAudioOp(holder, op4, label3) {
|
|
|
322367
322510
|
return { holder: made.composition, clip: made.id };
|
|
322368
322511
|
}
|
|
322369
322512
|
case "audio": {
|
|
322370
|
-
const { kind: _k, clip, ...
|
|
322513
|
+
const { kind: _k, clip, ...patch2 } = op4;
|
|
322371
322514
|
void _k;
|
|
322372
|
-
return { holder: editAudioClip(holder, audioOr(clip),
|
|
322515
|
+
return { holder: editAudioClip(holder, audioOr(clip), patch2) };
|
|
322373
322516
|
}
|
|
322374
322517
|
case "trimAudio":
|
|
322375
322518
|
return { holder: trimAudioClip(holder, audioOr(op4.clip), op4.edge, op4.delta, op4.sourceMs) };
|
|
@@ -323221,10 +323364,10 @@ function constrained(kind, pos, size6, parentSize, start2, end, sizeProp) {
|
|
|
323221
323364
|
return { place: { [start2]: px2(pos) }, style: {} };
|
|
323222
323365
|
}
|
|
323223
323366
|
}
|
|
323224
|
-
function placedChild(node2, parent,
|
|
323367
|
+
function placedChild(node2, parent, frame3 = parent) {
|
|
323225
323368
|
const c2 = node2.constraints ?? { horizontal: "MIN", vertical: "MIN" };
|
|
323226
|
-
const x2 = constrained(c2.horizontal, node2.x, node2.width,
|
|
323227
|
-
const y = constrained(c2.vertical, node2.y, node2.height,
|
|
323369
|
+
const x2 = constrained(c2.horizontal, node2.x, node2.width, frame3.width, "left", "right", "width");
|
|
323370
|
+
const y = constrained(c2.vertical, node2.y, node2.height, frame3.height, "top", "bottom", "height");
|
|
323228
323371
|
return { style: { ...limits(node2), ...x2.style, ...y.style }, place: { position: "absolute", ...x2.place, ...y.place } };
|
|
323229
323372
|
}
|
|
323230
323373
|
function siteLayout(node2, parent, layout2) {
|
|
@@ -323432,8 +323575,8 @@ var init_tokens2 = __esm({
|
|
|
323432
323575
|
// lib/io/web/timeline.ts
|
|
323433
323576
|
function frameWebMotion(doc2, frameId, style) {
|
|
323434
323577
|
const nodes = doc2.nodes;
|
|
323435
|
-
const
|
|
323436
|
-
if (!
|
|
323578
|
+
const frame3 = nodes[frameId];
|
|
323579
|
+
if (!frame3 || !hasFrameMotion(nodes, frameId)) return null;
|
|
323437
323580
|
const len3 = timelineDuration(nodes, frameId);
|
|
323438
323581
|
if (!(len3 > 0)) return null;
|
|
323439
323582
|
const steps = Math.max(1, Math.ceil(len3 / 1e3 * SAMPLE_RATE));
|
|
@@ -327807,7 +327950,7 @@ var init_package = __esm({
|
|
|
327807
327950
|
"packages/runtime/package.json"() {
|
|
327808
327951
|
package_default = {
|
|
327809
327952
|
name: "@popcraft/runtime",
|
|
327810
|
-
version: "0.
|
|
327953
|
+
version: "0.44.0",
|
|
327811
327954
|
description: "What code exported from PopCraft shares: the meaning of expressions (operators and functions) and, as it grows, the parts of a design's behaviour that are common code rather than generated React.",
|
|
327812
327955
|
license: "MIT",
|
|
327813
327956
|
homepage: "https://popcraft.app/docs/exporting/nextjs",
|
|
@@ -352473,6 +352616,7 @@ function exportsOf(source3) {
|
|
|
352473
352616
|
var CODE_LIMITS, packageOf;
|
|
352474
352617
|
var init_source2 = __esm({
|
|
352475
352618
|
"lib/code/source.ts"() {
|
|
352619
|
+
"use strict";
|
|
352476
352620
|
CODE_LIMITS = { modules: 100, sourceLength: 2e5, packages: 12 };
|
|
352477
352621
|
packageOf = (spec) => spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
|
|
352478
352622
|
}
|
|
@@ -352515,6 +352659,7 @@ function compileModule(module2) {
|
|
|
352515
352659
|
var import_sucrase, BUILT_IN, memo4;
|
|
352516
352660
|
var init_compile2 = __esm({
|
|
352517
352661
|
"lib/code/compile.ts"() {
|
|
352662
|
+
"use strict";
|
|
352518
352663
|
import_sucrase = __toESM(require_dist2());
|
|
352519
352664
|
init_source2();
|
|
352520
352665
|
init_source2();
|
|
@@ -353432,13 +353577,13 @@ async function drawShareFrame(doc2, frameId) {
|
|
|
353432
353577
|
Promise.resolve().then(() => (init_export_fills(), export_fills_exports))
|
|
353433
353578
|
]);
|
|
353434
353579
|
const renderer = getActiveRenderer2();
|
|
353435
|
-
const
|
|
353436
|
-
if (!renderer || !
|
|
353580
|
+
const frame3 = doc2.nodes[frameId];
|
|
353581
|
+
if (!renderer || !frame3) return null;
|
|
353437
353582
|
const shown2 = documentForExport2(doc2);
|
|
353438
|
-
const box2 = uprightBounds(getWorldTransform(shown2, frameId),
|
|
353583
|
+
const box2 = uprightBounds(getWorldTransform(shown2, frameId), frame3.width, frame3.height);
|
|
353439
353584
|
const crop = shareCrop(box2.maxX - box2.minX, box2.maxY - box2.minY);
|
|
353440
353585
|
const bounds2 = { minX: box2.minX + crop.x, minY: box2.minY + crop.y, maxX: box2.minX + crop.x + crop.w, maxY: box2.minY + crop.y + crop.h };
|
|
353441
|
-
const pixels = await renderer.exportRegion([shown2.nodes[frameId] ??
|
|
353586
|
+
const pixels = await renderer.exportRegion([shown2.nodes[frameId] ?? frame3], bounds2, crop.scale, shown2, shown2.styles, void 0, true);
|
|
353442
353587
|
if (!pixels) return null;
|
|
353443
353588
|
const png = await encodeImageData2(pixels, "PNG");
|
|
353444
353589
|
if (png && png.size <= SHARE_MAX_BYTES) return { bytes: new Uint8Array(await png.arrayBuffer()), ext: "png" };
|
|
@@ -356352,8 +356497,8 @@ var init_vision = __esm({
|
|
|
356352
356497
|
if (args2.parts) {
|
|
356353
356498
|
if (ids2.length !== 1) throw new ToolError("Look at one frame part by part at a time.");
|
|
356354
356499
|
if (args2.at && args2.at.length > 1) throw new ToolError("Look at a page part by part at one moment at a time.");
|
|
356355
|
-
const
|
|
356356
|
-
const parts = (
|
|
356500
|
+
const frame3 = doc2.nodes[ids2[0]];
|
|
356501
|
+
const parts = (frame3.childIds ?? []).map((c2) => doc2.nodes[c2]).filter((n) => !!n && n.visible !== false && n.layoutPositioning !== "ABSOLUTE" && n.height > 1);
|
|
356357
356502
|
const FOOT = 1e5;
|
|
356358
356503
|
const tops = parts.map((n) => Math.max(0, n.y)).sort((a, b) => a - b);
|
|
356359
356504
|
const bands = tops.length ? tops.map((y, i2) => {
|
|
@@ -356616,16 +356761,16 @@ function placeAudioClip(ctx2, compositionId2, o) {
|
|
|
356616
356761
|
}
|
|
356617
356762
|
function placeFrameAudioClip(ctx2, frameId, o) {
|
|
356618
356763
|
const latest = ctx2.doc();
|
|
356619
|
-
const
|
|
356620
|
-
if (!
|
|
356621
|
-
const made = addAudioClip(frameTimeline(latest.nodes,
|
|
356764
|
+
const frame3 = latest.nodes[frameId];
|
|
356765
|
+
if (!frame3 || frame3.type !== "FRAME" && frame3.type !== "COMPONENT") throw new ToolError(`"${frameId}" is not a frame.`);
|
|
356766
|
+
const made = addAudioClip(frameTimeline(latest.nodes, frame3.id), { mediaHash: o.mediaHash, name: o.name, duration: o.duration, start: o.start, lane: o.lane });
|
|
356622
356767
|
let next2 = made.composition;
|
|
356623
356768
|
if (o.fadeIn !== void 0 || o.fadeOut !== void 0) next2 = editAudioClip(next2, made.id, { fadeIn: o.fadeIn, fadeOut: o.fadeOut });
|
|
356624
356769
|
if (o.gain !== void 0) next2 = setGainKey(next2, made.id, 0, o.gain);
|
|
356625
356770
|
if (o.loop) next2 = editAudioClip(next2, made.id, { loop: true });
|
|
356626
|
-
ctx2.commit({ ...latest, nodes: { ...latest.nodes, [
|
|
356771
|
+
ctx2.commit({ ...latest, nodes: { ...latest.nodes, [frame3.id]: { ...frame3, timeline: next2 } } });
|
|
356627
356772
|
const clip = next2.audio?.find((a) => a.id === made.id);
|
|
356628
|
-
return { summary: `Added "${o.name}" (${(o.duration / 1e3).toFixed(1)} s) to "${
|
|
356773
|
+
return { summary: `Added "${o.name}" (${(o.duration / 1e3).toFixed(1)} s) to "${frame3.name}"`, data: { frame: frame3.id, clip: made.id, mediaHash: o.mediaHash, duration: o.duration, lane: clip?.lane, start: clip?.start } };
|
|
356629
356774
|
}
|
|
356630
356775
|
var ORDERS2, order, orderIds, seed, pickOf, presetList, motionApplyPreset, motionStagger, motionCreateComponent, SCENE_TYPES, motionNewComposition, center, compositionOp, OP_LABELS, motionEditComposition, motionDetectOnsets, motionGetCompositions, motionCutToBeat, motionAddAudio, AUDIO_USE_IDS, motionGenerateAudio;
|
|
356631
356776
|
var init_motion2 = __esm({
|
|
@@ -356930,10 +357075,10 @@ var init_motion2 = __esm({
|
|
|
356930
357075
|
break;
|
|
356931
357076
|
case "frame": {
|
|
356932
357077
|
const clip = comp.clips.find((c2) => c2.id === clipOr2(op4.clip));
|
|
356933
|
-
const [
|
|
356934
|
-
if (!
|
|
357078
|
+
const [frame3] = scenesOf(doc2, [op4.frame]);
|
|
357079
|
+
if (!frame3) throw new ToolError(`"${op4.frame}" is not a frame (or a layer in one).`);
|
|
356935
357080
|
const wholeOld = clip.in === 0 && Math.abs(clip.out - timelineDuration(doc2.nodes, clip.frameId)) < 1;
|
|
356936
|
-
next2 = setClipFrame(comp, clip.id,
|
|
357081
|
+
next2 = setClipFrame(comp, clip.id, frame3.id, timelineDuration(doc2.nodes, frame3.id), wholeOld);
|
|
356937
357082
|
break;
|
|
356938
357083
|
}
|
|
356939
357084
|
case "rename":
|
|
@@ -357357,14 +357502,14 @@ var init_motion_av = __esm({
|
|
|
357357
357502
|
}
|
|
357358
357503
|
case "timing": {
|
|
357359
357504
|
if (op4.speed !== void 0) next2 = wrap2(() => setVideoSpeed(next2, id3, frameId, op4.speed));
|
|
357360
|
-
const
|
|
357361
|
-
if (Object.keys(
|
|
357505
|
+
const patch2 = { ...op4.loop !== void 0 ? { videoLoop: op4.loop } : {}, ...op4.poster !== void 0 ? { videoPosterTime: op4.poster } : {}, ...op4.playback ? { videoPlayback: op4.playback } : {} };
|
|
357506
|
+
if (Object.keys(patch2).length) next2 = wrap2(() => editVideoPaint(next2, id3, frameId, patch2));
|
|
357362
357507
|
break;
|
|
357363
357508
|
}
|
|
357364
357509
|
case "sound": {
|
|
357365
|
-
const { kind: _k, ...
|
|
357510
|
+
const { kind: _k, ...patch2 } = op4;
|
|
357366
357511
|
void _k;
|
|
357367
|
-
next2 = wrap2(() => editVideoSound(doc2, id3, frameId,
|
|
357512
|
+
next2 = wrap2(() => editVideoSound(doc2, id3, frameId, patch2));
|
|
357368
357513
|
break;
|
|
357369
357514
|
}
|
|
357370
357515
|
case "gainKey":
|
|
@@ -357406,13 +357551,13 @@ var init_motion_av = __esm({
|
|
|
357406
357551
|
},
|
|
357407
357552
|
run: (args2, ctx2) => {
|
|
357408
357553
|
const doc2 = ctx2.doc();
|
|
357409
|
-
const
|
|
357410
|
-
if (!
|
|
357411
|
-
const tl = frameTimeline(doc2.nodes,
|
|
357412
|
-
const r = applyAudioOp(tl, args2.op, `"${
|
|
357413
|
-
if (r.holder === tl) return { summary: "Nothing to change", data: { frame:
|
|
357414
|
-
ctx2.commit({ ...doc2, nodes: { ...doc2.nodes, [
|
|
357415
|
-
return { summary: `${args2.op.kind === "addAudio" ? "Added audio to" : "Edited audio of"} "${
|
|
357554
|
+
const frame3 = doc2.nodes[args2.frame];
|
|
357555
|
+
if (!frame3 || frame3.type !== "FRAME" && frame3.type !== "COMPONENT") throw new ToolError(`"${args2.frame}" is not a frame.`);
|
|
357556
|
+
const tl = frameTimeline(doc2.nodes, frame3.id);
|
|
357557
|
+
const r = applyAudioOp(tl, args2.op, `"${frame3.name}"`);
|
|
357558
|
+
if (r.holder === tl) return { summary: "Nothing to change", data: { frame: frame3.id } };
|
|
357559
|
+
ctx2.commit({ ...doc2, nodes: { ...doc2.nodes, [frame3.id]: { ...frame3, timeline: r.holder } } });
|
|
357560
|
+
return { summary: `${args2.op.kind === "addAudio" ? "Added audio to" : "Edited audio of"} "${frame3.name}"`, data: { frame: frame3.id, ...r.clip ? { clip: r.clip } : {} } };
|
|
357416
357561
|
}
|
|
357417
357562
|
});
|
|
357418
357563
|
}
|
|
@@ -357936,9 +358081,9 @@ var init_motion_keys = __esm({
|
|
|
357936
358081
|
delete motion.stagger;
|
|
357937
358082
|
}
|
|
357938
358083
|
}
|
|
357939
|
-
const
|
|
357940
|
-
if (l.label !== void 0)
|
|
357941
|
-
patches.set(node2.id,
|
|
358084
|
+
const patch2 = { ...patches.get(node2.id) ?? {}, motion: tidy(motion) };
|
|
358085
|
+
if (l.label !== void 0) patch2.timelineColor = l.label ?? void 0;
|
|
358086
|
+
patches.set(node2.id, patch2);
|
|
357942
358087
|
}
|
|
357943
358088
|
commitUpdates(ctx2, doc2, patches);
|
|
357944
358089
|
return { summary: `Timed ${plural2(patches.size, "layer")}`, data: { ids: [...patches.keys()] } };
|
|
@@ -358053,7 +358198,7 @@ var init_motion_rich = __esm({
|
|
|
358053
358198
|
MS2 = 36e5;
|
|
358054
358199
|
colorIn = external_exports.union([external_exports.string(), external_exports.object({ r: external_exports.number().min(0).max(1), g: external_exports.number().min(0).max(1), b: external_exports.number().min(0).max(1), a: external_exports.number().min(0).max(1).optional() })]).describe('"#rrggbb[aa]" or {r,g,b,a} (0\u20131).');
|
|
358055
358200
|
colorOf = (c2) => typeof c2 === "string" ? parseHex(c2) : { a: 1, ...c2 };
|
|
358056
|
-
put2 = (patches, id3,
|
|
358201
|
+
put2 = (patches, id3, patch2) => patches.set(id3, { ...patches.get(id3) ?? {}, ...patch2 });
|
|
358057
358202
|
UNITS2 = ["letter", "word", "line"];
|
|
358058
358203
|
ORDERS3 = ["forward", "reverse", "center", "random"];
|
|
358059
358204
|
animatorFields = external_exports.object({
|
|
@@ -358313,12 +358458,12 @@ var init_motion_rich = __esm({
|
|
|
358313
358458
|
case "place": {
|
|
358314
358459
|
for (const l of op4.layers) {
|
|
358315
358460
|
const layer2 = nodeOrThrow(doc2, l.id);
|
|
358316
|
-
const
|
|
358317
|
-
if (l.rotateX !== void 0)
|
|
358318
|
-
if (l.rotateY !== void 0)
|
|
358319
|
-
if (l.z !== void 0)
|
|
358320
|
-
if (l.material)
|
|
358321
|
-
put2(patches, layer2.id,
|
|
358461
|
+
const patch2 = {};
|
|
358462
|
+
if (l.rotateX !== void 0) patch2.rotateX = l.rotateX;
|
|
358463
|
+
if (l.rotateY !== void 0) patch2.rotateY = l.rotateY;
|
|
358464
|
+
if (l.z !== void 0) patch2.z = l.z;
|
|
358465
|
+
if (l.material) patch2.material3d = { ...layer2.material3d, ...clean3(l.material) };
|
|
358466
|
+
put2(patches, layer2.id, patch2);
|
|
358322
358467
|
}
|
|
358323
358468
|
commitUpdates(ctx2, doc2, patches);
|
|
358324
358469
|
return { summary: `Placed ${plural2(op4.layers.length, "layer")} in 3D`, data: { ids: op4.layers.map((l) => l.id) } };
|
|
@@ -358380,8 +358525,8 @@ var init_motion_rich = __esm({
|
|
|
358380
358525
|
playback.range = e.range;
|
|
358381
358526
|
} else delete playback.range;
|
|
358382
358527
|
}
|
|
358383
|
-
const
|
|
358384
|
-
if (touchesPlayback)
|
|
358528
|
+
const patch2 = {};
|
|
358529
|
+
if (touchesPlayback) patch2.playback = Object.keys(playback).length ? playback : void 0;
|
|
358385
358530
|
if (e.properties) {
|
|
358386
358531
|
const defs = componentDefinitions(doc2.nodes, comp);
|
|
358387
358532
|
const values3 = { ...inst.componentProperties ?? {} };
|
|
@@ -358391,9 +358536,9 @@ var init_motion_rich = __esm({
|
|
|
358391
358536
|
values3[name2] = def.type === "COLOR" ? colorOf(raw) : raw;
|
|
358392
358537
|
if (def.type === "NUMBER" && typeof raw !== "number" || def.type === "BOOLEAN" && typeof raw !== "boolean" || def.type === "TEXT" && typeof raw !== "string") throw new ToolError(`${name2} is a ${def.type} property.`);
|
|
358393
358538
|
}
|
|
358394
|
-
|
|
358539
|
+
patch2.componentProperties = values3;
|
|
358395
358540
|
}
|
|
358396
|
-
put2(patches, inst.id,
|
|
358541
|
+
put2(patches, inst.id, patch2);
|
|
358397
358542
|
}
|
|
358398
358543
|
commitUpdates(ctx2, doc2, patches);
|
|
358399
358544
|
return { summary: `Playback on ${plural2(patches.size, "instance")}`, data: { ids: [...patches.keys()] } };
|
|
@@ -358588,19 +358733,19 @@ var init_motion_rich = __esm({
|
|
|
358588
358733
|
function frameOrThrow(doc2, id3) {
|
|
358589
358734
|
nodeOrThrow(doc2, id3);
|
|
358590
358735
|
const host = hostOrThrow(doc2, id3);
|
|
358591
|
-
const
|
|
358592
|
-
if (
|
|
358593
|
-
return
|
|
358736
|
+
const frame3 = doc2.nodes[host];
|
|
358737
|
+
if (frame3.type !== "FRAME") throw new ToolError(`"${frame3.name}" is a component: state machines belong to top-level frames.`);
|
|
358738
|
+
return frame3;
|
|
358594
358739
|
}
|
|
358595
358740
|
function pick4(rec, key5, what) {
|
|
358596
358741
|
const hit = rec[key5] ?? Object.values(rec).find((e) => e.name.toLowerCase() === key5.toLowerCase());
|
|
358597
358742
|
if (!hit) throw new ToolError(`The machine has no ${what} "${key5}". It has: ${sortedValues(rec).map((e) => `${e.name} (${e.id})`).join(", ") || "none"}.`);
|
|
358598
358743
|
return hit;
|
|
358599
358744
|
}
|
|
358600
|
-
function markerOrThrow(
|
|
358601
|
-
const markers = frameTimelineOf(
|
|
358745
|
+
function markerOrThrow(frame3, key5) {
|
|
358746
|
+
const markers = frameTimelineOf(frame3).markers ?? [];
|
|
358602
358747
|
const m = markers.find((x2) => x2.id === key5) ?? markers.find((x2) => (x2.label ?? "").toLowerCase() === key5.toLowerCase());
|
|
358603
|
-
if (!m) throw new ToolError(`"${
|
|
358748
|
+
if (!m) throw new ToolError(`"${frame3.name}" has no marker "${key5}". Add one with set_timeline (addMarkers).`);
|
|
358604
358749
|
return m.id;
|
|
358605
358750
|
}
|
|
358606
358751
|
function valueFor(input2, v, what) {
|
|
@@ -358629,21 +358774,21 @@ function guardsFor(sm, list2) {
|
|
|
358629
358774
|
return { input: input2.id, ...op4 && op4 !== "eq" ? { op: op4 } : {}, ...g.value !== void 0 ? { value: valueFor(input2, g.value, "A guard") } : {} };
|
|
358630
358775
|
});
|
|
358631
358776
|
}
|
|
358632
|
-
function applyOp(
|
|
358777
|
+
function applyOp(frame3, sm, op4) {
|
|
358633
358778
|
if (op4.kind === "create") {
|
|
358634
|
-
if (sm) throw new ToolError(`"${
|
|
358635
|
-
return { next: createStateMachine(
|
|
358779
|
+
if (sm) throw new ToolError(`"${frame3.name}" already has a state machine ("${sm.name}"). Edit it, or remove it first.`);
|
|
358780
|
+
return { next: createStateMachine(frame3.timeline, op4.name) };
|
|
358636
358781
|
}
|
|
358637
|
-
if (!sm) throw new ToolError(`"${
|
|
358782
|
+
if (!sm) throw new ToolError(`"${frame3.name}" has no state machine. Create one first (op kind "create").`);
|
|
358638
358783
|
const stretchOf = (o, s) => {
|
|
358639
358784
|
const out = { ...s };
|
|
358640
358785
|
if (o.from !== void 0) {
|
|
358641
358786
|
if (o.from === null) delete out.from;
|
|
358642
|
-
else out.from = markerOrThrow(
|
|
358787
|
+
else out.from = markerOrThrow(frame3, o.from);
|
|
358643
358788
|
}
|
|
358644
358789
|
if (o.to !== void 0) {
|
|
358645
358790
|
if (o.to === null) delete out.to;
|
|
358646
|
-
else out.to = markerOrThrow(
|
|
358791
|
+
else out.to = markerOrThrow(frame3, o.to);
|
|
358647
358792
|
}
|
|
358648
358793
|
if (o.loop !== void 0) {
|
|
358649
358794
|
if (o.loop) out.loop = true;
|
|
@@ -358825,7 +358970,7 @@ var init_motion_machine = __esm({
|
|
|
358825
358970
|
};
|
|
358826
358971
|
opsOf = (p2) => p2.ops ?? (p2.op ? [p2.op] : []);
|
|
358827
358972
|
opsLabel = (ops2) => ops2.length && ops2.every((o) => o.kind === ops2[0].kind) ? OP_LABELS2[ops2[0].kind] : "Edit state machine";
|
|
358828
|
-
frameTimelineOf = (
|
|
358973
|
+
frameTimelineOf = (frame3) => frame3.timeline ?? { duration: 0 };
|
|
358829
358974
|
stateRef = (sm, key5, allowAny = false) => allowAny && key5 === ANY_STATE ? ANY_STATE : pick4(sm.states, key5, "state").id;
|
|
358830
358975
|
motionEditStateMachine = defineCommand({
|
|
358831
358976
|
id: "motion.editStateMachine",
|
|
@@ -358852,22 +358997,22 @@ var init_motion_machine = __esm({
|
|
|
358852
358997
|
const doc2 = ctx2.doc();
|
|
358853
358998
|
const at4 = args2.id ?? ctx2.selection()[0];
|
|
358854
358999
|
if (!at4) throw new ToolError("edit_state_machine needs the frame (id) or a selection.");
|
|
358855
|
-
const
|
|
359000
|
+
const frame3 = frameOrThrow(doc2, at4);
|
|
358856
359001
|
if (!!args2.op === !!args2.ops) throw new ToolError("edit_state_machine takes op or ops (not both).");
|
|
358857
359002
|
const ops2 = opsOf(args2);
|
|
358858
|
-
let next2 = machineOf(
|
|
359003
|
+
let next2 = machineOf(frame3);
|
|
358859
359004
|
const added = [];
|
|
358860
359005
|
for (const op4 of ops2) {
|
|
358861
|
-
const r = applyOp(
|
|
359006
|
+
const r = applyOp(frame3, next2 ?? void 0, op4);
|
|
358862
359007
|
next2 = r.next;
|
|
358863
359008
|
if (r.added) added.push(r.added);
|
|
358864
359009
|
}
|
|
358865
|
-
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[
|
|
358866
|
-
const sm = machineOf(ctx2.doc().nodes[
|
|
359010
|
+
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[frame3.id, { stateMachine: next2 ?? void 0 }]]));
|
|
359011
|
+
const sm = machineOf(ctx2.doc().nodes[frame3.id]);
|
|
358867
359012
|
const label3 = opsLabel(ops2);
|
|
358868
359013
|
return {
|
|
358869
359014
|
summary: next2 && sm ? `${label3} \u2014 "${sm.name}": ${plural2(Object.keys(sm.states).length, "state")}, ${plural2(Object.keys(sm.transitions).length, "transition")}` : label3,
|
|
358870
|
-
data: { id:
|
|
359015
|
+
data: { id: frame3.id, ...added.length ? { added: added[added.length - 1], addedAll: added } : {}, ...sm ? { stateMachine: sm } : {} }
|
|
358871
359016
|
};
|
|
358872
359017
|
}
|
|
358873
359018
|
});
|
|
@@ -358889,16 +359034,16 @@ var init_motion_machine = __esm({
|
|
|
358889
359034
|
const doc2 = ctx2.doc();
|
|
358890
359035
|
const at4 = args2.id ?? ctx2.selection()[0];
|
|
358891
359036
|
if (!at4) throw new ToolError("get_state_machine needs the frame (id) or a selection.");
|
|
358892
|
-
const
|
|
358893
|
-
const sm = machineOf(
|
|
358894
|
-
const tl = frameTimeline(doc2.nodes,
|
|
359037
|
+
const frame3 = frameOrThrow(doc2, at4);
|
|
359038
|
+
const sm = machineOf(frame3);
|
|
359039
|
+
const tl = frameTimeline(doc2.nodes, frame3.id);
|
|
358895
359040
|
const markers = (tl.markers ?? []).map((m) => ({ id: m.id, t: m.t, ...m.label ? { label: m.label } : {} }));
|
|
358896
|
-
if (!sm) return { summary: `"${
|
|
358897
|
-
const duration3 = timelineDuration(doc2.nodes,
|
|
359041
|
+
if (!sm) return { summary: `"${frame3.name}" has no state machine`, data: { id: frame3.id, stateMachine: null, markers } };
|
|
359042
|
+
const duration3 = timelineDuration(doc2.nodes, frame3.id);
|
|
358898
359043
|
const states = sortedValues(sm.states).map((s) => ({ ...s, stretch: stateStretch(s, tl, duration3) }));
|
|
358899
359044
|
return {
|
|
358900
359045
|
summary: `"${sm.name}": ${plural2(states.length, "state")}, ${plural2(Object.keys(sm.inputs).length, "input")}, ${plural2(Object.keys(sm.listeners).length, "listener")}`,
|
|
358901
|
-
data: { id:
|
|
359046
|
+
data: { id: frame3.id, stateMachine: { ...sm, states, transitions: sortedValues(sm.transitions), inputs: sortedValues(sm.inputs), listeners: sortedValues(sm.listeners) }, markers }
|
|
358902
359047
|
};
|
|
358903
359048
|
}
|
|
358904
359049
|
});
|
|
@@ -359267,7 +359412,7 @@ function placeVideoScene(doc2, pageId2, compositionId2, file2, intoId) {
|
|
|
359267
359412
|
if (!comp || !doc2.nodes[pageId2]) return null;
|
|
359268
359413
|
const durationMs = Math.max(1, Math.round(file2.durationMs));
|
|
359269
359414
|
const at4 = nextScenePosition(doc2, pageId2);
|
|
359270
|
-
const
|
|
359415
|
+
const frame3 = createFrame({
|
|
359271
359416
|
name: file2.name,
|
|
359272
359417
|
...at4,
|
|
359273
359418
|
width: comp.width,
|
|
@@ -359275,26 +359420,26 @@ function placeVideoScene(doc2, pageId2, compositionId2, file2, intoId) {
|
|
|
359275
359420
|
fills: [{ type: "SOLID", color: comp.background ?? { r: 0, g: 0, b: 0, a: 1 }, visible: true }],
|
|
359276
359421
|
timeline: { duration: durationMs, fps: comp.fps }
|
|
359277
359422
|
});
|
|
359278
|
-
let next2 = addNode(doc2,
|
|
359423
|
+
let next2 = addNode(doc2, frame3, pageId2);
|
|
359279
359424
|
let nodeId2;
|
|
359280
359425
|
const existing = intoId ? next2.nodes[intoId] : void 0;
|
|
359281
359426
|
if (existing) {
|
|
359282
359427
|
const oldParent = existing.parentId ? next2.nodes[existing.parentId] : void 0;
|
|
359283
359428
|
const nodes = { ...next2.nodes };
|
|
359284
359429
|
if (oldParent) nodes[oldParent.id] = { ...oldParent, childIds: oldParent.childIds.filter((c2) => c2 !== existing.id) };
|
|
359285
|
-
nodes[
|
|
359286
|
-
nodes[existing.id] = { ...existing, parentId:
|
|
359430
|
+
nodes[frame3.id] = { ...nodes[frame3.id], childIds: [...nodes[frame3.id].childIds, existing.id] };
|
|
359431
|
+
nodes[existing.id] = { ...existing, parentId: frame3.id, x: 0, y: 0, width: comp.width, height: comp.height, rotation: 0 };
|
|
359287
359432
|
next2 = fillWithVideo({ ...next2, nodes }, existing.id, file2);
|
|
359288
359433
|
nodeId2 = existing.id;
|
|
359289
359434
|
} else {
|
|
359290
|
-
const placed2 = placeVideoLayer(next2,
|
|
359435
|
+
const placed2 = placeVideoLayer(next2, frame3.id, file2, { cx: comp.width / 2, cy: comp.height / 2, width: comp.width, height: comp.height });
|
|
359291
359436
|
next2 = placed2.doc;
|
|
359292
359437
|
nodeId2 = placed2.nodeId;
|
|
359293
359438
|
}
|
|
359294
|
-
const withClip = addClip(comp,
|
|
359439
|
+
const withClip = addClip(comp, frame3.id, durationMs);
|
|
359295
359440
|
const clipId = withClip.clips.find((c2) => !comp.clips.some((o) => o.id === c2.id))?.id ?? "";
|
|
359296
359441
|
next2 = repairDocumentCompositions({ ...next2, compositions: { ...next2.compositions, [comp.id]: withClip } });
|
|
359297
|
-
return { doc: next2, frameId:
|
|
359442
|
+
return { doc: next2, frameId: frame3.id, nodeId: nodeId2, clipId };
|
|
359298
359443
|
}
|
|
359299
359444
|
var init_media_placement = __esm({
|
|
359300
359445
|
"lib/ai/media-placement.ts"() {
|
|
@@ -360290,10 +360435,10 @@ async function placePicture(imported, opts = {}) {
|
|
|
360290
360435
|
Promise.resolve().then(() => (init_media_tool(), media_tool_exports))
|
|
360291
360436
|
]);
|
|
360292
360437
|
const st = useEditorStore2.getState();
|
|
360293
|
-
const
|
|
360294
|
-
if (
|
|
360295
|
-
st.fillPhotoFrame(
|
|
360296
|
-
return
|
|
360438
|
+
const frame3 = photoFrameOf2(st.document.nodes, opts.targetId !== void 0 ? opts.targetId : st.selection[0] ?? null);
|
|
360439
|
+
if (frame3) {
|
|
360440
|
+
st.fillPhotoFrame(frame3.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit);
|
|
360441
|
+
return frame3.id;
|
|
360297
360442
|
}
|
|
360298
360443
|
const point2 = opts.at ?? { x: st.camera.x, y: st.camera.y };
|
|
360299
360444
|
return placeImage2(imported.ref, { w: imported.width, h: imported.height }, { kind: "point", ...point2 }, { name: imported.name, ...imported.credit ? { credit: imported.credit } : {} });
|
|
@@ -360323,10 +360468,10 @@ async function placeImportedPicture(ctx2, imported, at4, what, extra = {}) {
|
|
|
360323
360468
|
if (at4.fillLayerId) {
|
|
360324
360469
|
const doc2 = ctx2.doc();
|
|
360325
360470
|
const target2 = nodeOrThrow(doc2, at4.fillLayerId);
|
|
360326
|
-
const
|
|
360327
|
-
if (
|
|
360328
|
-
ctx2.commit(fillPhotoFrame(doc2,
|
|
360329
|
-
return { summary: `Filled photo frame \u201C${
|
|
360471
|
+
const frame3 = photoFrameOf(doc2.nodes, target2.id);
|
|
360472
|
+
if (frame3) {
|
|
360473
|
+
ctx2.commit(fillPhotoFrame(doc2, frame3.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit));
|
|
360474
|
+
return { summary: `Filled photo frame \u201C${frame3.name}\u201D with ${what}`, data: { id: frame3.id, ...extra } };
|
|
360330
360475
|
}
|
|
360331
360476
|
if (!("fills" in target2)) throw new ToolError(`\u201C${target2.name}\u201D has no fills to put a picture in.`);
|
|
360332
360477
|
const fill = client.photoFill({ type: "IMAGE", visible: true, opacity: 1 }, imported);
|
|
@@ -360809,11 +360954,11 @@ var init_prototype = __esm({
|
|
|
360809
360954
|
const patches = /* @__PURE__ */ new Map();
|
|
360810
360955
|
for (const id3 of ids2) {
|
|
360811
360956
|
const node2 = doc2.nodes[id3];
|
|
360812
|
-
const
|
|
360957
|
+
const patch2 = {};
|
|
360813
360958
|
if (replace || add3.length || args2.removeInteractions) {
|
|
360814
360959
|
const drop = new Set(args2.removeInteractions ?? []);
|
|
360815
360960
|
const next2 = [...(replace ?? node2.interactions ?? []).filter((ix) => !drop.has(ix.id)), ...add3];
|
|
360816
|
-
|
|
360961
|
+
patch2.interactions = next2.length ? next2 : void 0;
|
|
360817
360962
|
}
|
|
360818
360963
|
if (args2.liveValues) {
|
|
360819
360964
|
if ("characters" in args2.liveValues && node2.type !== "TEXT" && args2.liveValues.characters) throw new ToolError(`\u201C${node2.name}\u201D is not text, so it has no characters to bind.`);
|
|
@@ -360822,10 +360967,10 @@ var init_prototype = __esm({
|
|
|
360822
360967
|
if (src) bound[prop] = src;
|
|
360823
360968
|
else delete bound[prop];
|
|
360824
360969
|
}
|
|
360825
|
-
|
|
360970
|
+
patch2.boundExpressions = Object.keys(bound).length ? bound : void 0;
|
|
360826
360971
|
}
|
|
360827
|
-
if (args2.sharedElement !== void 0)
|
|
360828
|
-
patches.set(id3,
|
|
360972
|
+
if (args2.sharedElement !== void 0) patch2.sharedElement = args2.sharedElement || void 0;
|
|
360973
|
+
patches.set(id3, patch2);
|
|
360829
360974
|
}
|
|
360830
360975
|
commitUpdates(ctx2, doc2, patches);
|
|
360831
360976
|
return { summary: `Edited the prototype on ${ids2.length === 1 ? "1 layer" : `${ids2.length} layers`}`, data: { ids: ids2 } };
|
|
@@ -367425,8 +367570,8 @@ function libraryMotionPreviews(libraryId, version7) {
|
|
|
367425
367570
|
}
|
|
367426
367571
|
return p2;
|
|
367427
367572
|
}
|
|
367428
|
-
async function updateLibraryListing(libraryId,
|
|
367429
|
-
await api(`/api/libraries/${libraryId}`, { method: "PATCH", json:
|
|
367573
|
+
async function updateLibraryListing(libraryId, patch2) {
|
|
367574
|
+
await api(`/api/libraries/${libraryId}`, { method: "PATCH", json: patch2 });
|
|
367430
367575
|
await refreshLibraries();
|
|
367431
367576
|
}
|
|
367432
367577
|
async function unpublishLibrary(libraryId) {
|
|
@@ -367849,8 +367994,8 @@ function widgetCommands(id3) {
|
|
|
367849
367994
|
const after = layoutWidget(tree);
|
|
367850
367995
|
const sx = node2.widgetTree ? node2.width / before.width : 1;
|
|
367851
367996
|
const sy = node2.widgetTree ? node2.height / before.height : 1;
|
|
367852
|
-
const
|
|
367853
|
-
ctx2.commit(updateNode(ctx2.doc(), node2.id,
|
|
367997
|
+
const patch2 = { widgetTree: tree, widgetState: next2, width: after.width * sx, height: after.height * sy };
|
|
367998
|
+
ctx2.commit(updateNode(ctx2.doc(), node2.id, patch2), ctx2.actor.label ?? "Update widget");
|
|
367854
367999
|
return { summary: "Widget updated" };
|
|
367855
368000
|
}
|
|
367856
368001
|
}),
|
|
@@ -368759,7 +368904,7 @@ async function applyLayoutIr(ir, document2, pageId2, opts = {}) {
|
|
|
368759
368904
|
let cursorX = siblings.reduce((m, n) => Math.max(m, n.x + n.width), 0) + (siblings.length ? 120 : 0);
|
|
368760
368905
|
const cursorY = siblings.length ? Math.min(...siblings.map((n) => n.y)) : 0;
|
|
368761
368906
|
for (const p2 of ir.pages) {
|
|
368762
|
-
const
|
|
368907
|
+
const frame3 = createFrame({
|
|
368763
368908
|
name: p2.name || name2,
|
|
368764
368909
|
x: cursorX,
|
|
368765
368910
|
y: cursorY,
|
|
@@ -368768,9 +368913,9 @@ async function applyLayoutIr(ir, document2, pageId2, opts = {}) {
|
|
|
368768
368913
|
fills: [createSolidPaint(createColor(1, 1, 1))],
|
|
368769
368914
|
clipsContent: true
|
|
368770
368915
|
});
|
|
368771
|
-
doc2 = addNode(doc2,
|
|
368772
|
-
added.push(
|
|
368773
|
-
cursorX +=
|
|
368916
|
+
doc2 = addNode(doc2, frame3, pageId2);
|
|
368917
|
+
added.push(frame3.id);
|
|
368918
|
+
cursorX += frame3.width + 120;
|
|
368774
368919
|
const items = [...p2.items || []].sort((a, b) => {
|
|
368775
368920
|
const rank = (k2) => k2 === "rect" ? 0 : k2 === "image" ? 1 : 2;
|
|
368776
368921
|
return rank(a.kind) - rank(b.kind);
|
|
@@ -368817,7 +368962,7 @@ async function applyLayoutIr(ir, document2, pageId2, opts = {}) {
|
|
|
368817
368962
|
fills: [createSolidPaint(createColor(c2.r, c2.g, c2.b, c2.a))]
|
|
368818
368963
|
});
|
|
368819
368964
|
}
|
|
368820
|
-
if (child) doc2 = addNode(doc2, child,
|
|
368965
|
+
if (child) doc2 = addNode(doc2, child, frame3.id);
|
|
368821
368966
|
}
|
|
368822
368967
|
}
|
|
368823
368968
|
return { document: doc2, added };
|
|
@@ -368839,7 +368984,7 @@ var init_import_layout_ir = __esm({
|
|
|
368839
368984
|
|
|
368840
368985
|
// lib/client/import/import-status.ts
|
|
368841
368986
|
function beginImport(name2) {
|
|
368842
|
-
const id3 = ++
|
|
368987
|
+
const id3 = ++nextId3;
|
|
368843
368988
|
useImportStatus.setState((s) => ({ jobs: [...s.jobs, { id: id3, name: name2, startedAt: Date.now() }] }));
|
|
368844
368989
|
let ended = false;
|
|
368845
368990
|
return () => {
|
|
@@ -368856,13 +369001,13 @@ async function trackImport(name2, task) {
|
|
|
368856
369001
|
end();
|
|
368857
369002
|
}
|
|
368858
369003
|
}
|
|
368859
|
-
var useImportStatus,
|
|
369004
|
+
var useImportStatus, nextId3;
|
|
368860
369005
|
var init_import_status = __esm({
|
|
368861
369006
|
"lib/client/import/import-status.ts"() {
|
|
368862
369007
|
"use strict";
|
|
368863
369008
|
init_esm();
|
|
368864
369009
|
useImportStatus = create2(() => ({ jobs: [], dismissed: [] }));
|
|
368865
|
-
|
|
369010
|
+
nextId3 = 0;
|
|
368866
369011
|
}
|
|
368867
369012
|
});
|
|
368868
369013
|
|
|
@@ -368932,26 +369077,26 @@ function importLottie(input2, opts = {}) {
|
|
|
368932
369077
|
const fps = nearestFps(anim.fr);
|
|
368933
369078
|
if (Math.abs(fps - anim.fr) > 0.01) imp.notes.add(`The timeline runs at ${fps} fps (the file is ${anim.fr} fps; key times are kept exactly).`);
|
|
368934
369079
|
const duration3 = Math.max(1, imp.ms(anim.op - anim.ip));
|
|
368935
|
-
const
|
|
368936
|
-
|
|
369080
|
+
const frame3 = createFrame({ name: name2, x: 0, y: 0, width: anim.w, height: anim.h, fills: [], clipsContent: true });
|
|
369081
|
+
frame3.timeline = {
|
|
368937
369082
|
duration: duration3,
|
|
368938
369083
|
fps,
|
|
368939
369084
|
...anim.markers?.length ? { markers: anim.markers.map((m, i2) => ({ id: `lm${i2}`, t: Math.max(0, imp.ms(m.tm - anim.ip)), label: m.cm })) } : {}
|
|
368940
369085
|
};
|
|
368941
|
-
imp.add(
|
|
368942
|
-
imp.layers(anim.layers ?? [],
|
|
368943
|
-
|
|
369086
|
+
imp.add(frame3, null);
|
|
369087
|
+
imp.layers(anim.layers ?? [], frame3.id, anim.ip, "", { w: anim.w, h: anim.h });
|
|
369088
|
+
frame3.parentId = pageId2;
|
|
368944
369089
|
if (read6.stateMachines.length) {
|
|
368945
369090
|
const byName = /* @__PURE__ */ new Map();
|
|
368946
|
-
for (const n of Object.values(imp.nodes)) if (n.name && n.id !==
|
|
369091
|
+
for (const n of Object.values(imp.nodes)) if (n.name && n.id !== frame3.id && !byName.has(n.name)) byName.set(n.name, n.id);
|
|
368947
369092
|
const first2 = read6.stateMachines[0];
|
|
368948
369093
|
const { machine, notes } = stateMachineFromDotLottie({ raw: first2.raw, markers: anim.markers ?? [], ip: anim.ip, fr: anim.fr, nodeByName: (name3) => byName.get(name3) }, "sm1", first2.id);
|
|
368949
369094
|
for (const n of notes) imp.notes.add(n);
|
|
368950
|
-
if (machine) imp.nodes[
|
|
369095
|
+
if (machine) imp.nodes[frame3.id].stateMachine = machine;
|
|
368951
369096
|
if (read6.stateMachines.length > 1) imp.notes.add(`The file has ${read6.stateMachines.length} state machines: the first, \u201C${first2.id}\u201D, is imported.`);
|
|
368952
369097
|
}
|
|
368953
369098
|
const page = doc2.nodes[pageId2];
|
|
368954
|
-
const nodes = { ...doc2.nodes, ...imp.nodes, [pageId2]: { ...page, childIds: [...page.childIds,
|
|
369099
|
+
const nodes = { ...doc2.nodes, ...imp.nodes, [pageId2]: { ...page, childIds: [...page.childIds, frame3.id] } };
|
|
368955
369100
|
let pages2 = doc2.pages;
|
|
368956
369101
|
if (imp.components.size) {
|
|
368957
369102
|
const comps = createPage("Components");
|
|
@@ -368965,7 +369110,7 @@ function importLottie(input2, opts = {}) {
|
|
|
368965
369110
|
nodes[comps.id] = comps;
|
|
368966
369111
|
pages2 = [...pages2, comps.id];
|
|
368967
369112
|
}
|
|
368968
|
-
return { document: { ...doc2, pages: pages2, nodes }, frameId:
|
|
369113
|
+
return { document: { ...doc2, pages: pages2, nodes }, frameId: frame3.id, notes: [...imp.notes], layerNodes: imp.layerNodes };
|
|
368969
369114
|
}
|
|
368970
369115
|
var GEOMETRY, BLENDS, nearestFps, first, clamp013, Importer;
|
|
368971
369116
|
var init_import = __esm({
|
|
@@ -397525,10 +397670,10 @@ async function importPdf(bytes2, document2, pageId2, opts = {}) {
|
|
|
397525
397670
|
const page = await pdf.getPage(p2);
|
|
397526
397671
|
const vp = page.getViewport({ scale: PX_PER_PT });
|
|
397527
397672
|
const base = vp.transform;
|
|
397528
|
-
const
|
|
397529
|
-
doc2 = addNode(doc2,
|
|
397530
|
-
added.push(
|
|
397531
|
-
cursorX +=
|
|
397673
|
+
const frame3 = createFrame({ name: pdf.numPages > 1 ? `${opts.name ?? "PDF"} ${p2}` : opts.name ?? "PDF", x: cursorX, y: cursorY, width: Math.round(vp.width), height: Math.round(vp.height), fills: [createSolidPaint(createColor(1, 1, 1))], strokes: [], clipsContent: true });
|
|
397674
|
+
doc2 = addNode(doc2, frame3, pageId2);
|
|
397675
|
+
added.push(frame3.id);
|
|
397676
|
+
cursorX += frame3.width + 120;
|
|
397532
397677
|
const children = [];
|
|
397533
397678
|
const textRuns2 = [];
|
|
397534
397679
|
const ops2 = await page.getOperatorList();
|
|
@@ -397648,7 +397793,7 @@ async function importPdf(bytes2, document2, pageId2, opts = {}) {
|
|
|
397648
397793
|
textAutoResize: "WIDTH_AND_HEIGHT"
|
|
397649
397794
|
}));
|
|
397650
397795
|
}
|
|
397651
|
-
for (const c2 of children) doc2 = addNode(doc2, c2,
|
|
397796
|
+
for (const c2 of children) doc2 = addNode(doc2, c2, frame3.id);
|
|
397652
397797
|
page.cleanup();
|
|
397653
397798
|
}
|
|
397654
397799
|
await pdf.cleanup();
|
|
@@ -397867,8 +398012,8 @@ async function buildImportedDocument(file2) {
|
|
|
397867
398012
|
const pageId2 = base.pages[0];
|
|
397868
398013
|
const placed2 = placeSvgLayers2(base, pageId2, await file2.text(), { name: seedName, cx: 0, cy: 0, intern: (url4) => internDataUrl2(url4) });
|
|
397869
398014
|
if (!placed2) return null;
|
|
397870
|
-
const
|
|
397871
|
-
const document2 = { ...placed2.doc, nodes: { ...placed2.doc.nodes, [placed2.id]: { ...
|
|
398015
|
+
const frame3 = placed2.doc.nodes[placed2.id];
|
|
398016
|
+
const document2 = { ...placed2.doc, nodes: { ...placed2.doc.nodes, [placed2.id]: { ...frame3, x: 0, y: 0 } } };
|
|
397872
398017
|
return { document: document2, frameIds: [placed2.id] };
|
|
397873
398018
|
}
|
|
397874
398019
|
if (ext === ".json" || ext === ".popcraft" || ext === ".vizpops") {
|
|
@@ -400605,7 +400750,7 @@ __export(sandbox_exports, {
|
|
|
400605
400750
|
recordInSandbox: () => recordInSandbox
|
|
400606
400751
|
});
|
|
400607
400752
|
function onMessage(e) {
|
|
400608
|
-
if (!
|
|
400753
|
+
if (!frame2 || e.source !== frame2.contentWindow) return;
|
|
400609
400754
|
const d = e.data;
|
|
400610
400755
|
if (d?.kind !== "recorded" || typeof d.id !== "number") return;
|
|
400611
400756
|
const done = pending6.get(d.id);
|
|
@@ -400618,7 +400763,7 @@ function onMessage(e) {
|
|
|
400618
400763
|
}
|
|
400619
400764
|
}
|
|
400620
400765
|
function ensureFrame() {
|
|
400621
|
-
if (ready2 &&
|
|
400766
|
+
if (ready2 && frame2?.isConnected) return ready2;
|
|
400622
400767
|
window.removeEventListener("message", onMessage);
|
|
400623
400768
|
window.addEventListener("message", onMessage);
|
|
400624
400769
|
const el = document.createElement("iframe");
|
|
@@ -400626,7 +400771,7 @@ function ensureFrame() {
|
|
|
400626
400771
|
el.setAttribute("aria-hidden", "true");
|
|
400627
400772
|
el.tabIndex = -1;
|
|
400628
400773
|
el.style.cssText = "position:fixed;width:0;height:0;border:0;opacity:0;pointer-events:none;inset-inline-start:-9999px";
|
|
400629
|
-
|
|
400774
|
+
frame2 = el;
|
|
400630
400775
|
ready2 = new Promise((resolve7) => {
|
|
400631
400776
|
const hello = (e) => {
|
|
400632
400777
|
if (e.source !== el.contentWindow || e.data?.kind !== "ready") return;
|
|
@@ -400640,8 +400785,8 @@ function ensureFrame() {
|
|
|
400640
400785
|
return ready2;
|
|
400641
400786
|
}
|
|
400642
400787
|
function resetFrame() {
|
|
400643
|
-
|
|
400644
|
-
|
|
400788
|
+
frame2?.remove();
|
|
400789
|
+
frame2 = null;
|
|
400645
400790
|
ready2 = null;
|
|
400646
400791
|
}
|
|
400647
400792
|
async function recordInSandbox(source3, namespaces2, globals) {
|
|
@@ -400657,10 +400802,10 @@ async function recordInSandbox(source3, namespaces2, globals) {
|
|
|
400657
400802
|
clearTimeout(backstop);
|
|
400658
400803
|
resolve7(r);
|
|
400659
400804
|
});
|
|
400660
|
-
|
|
400805
|
+
frame2.contentWindow.postMessage({ kind: "record", id: id3, source: source3, namespaces: [...namespaces2], globals: { ...globals }, limits: { ...RECORD_LIMITS2 } }, "*");
|
|
400661
400806
|
});
|
|
400662
400807
|
}
|
|
400663
|
-
var FRAME_SOURCE,
|
|
400808
|
+
var FRAME_SOURCE, frame2, ready2, next, pending6;
|
|
400664
400809
|
var init_sandbox = __esm({
|
|
400665
400810
|
"lib/agent/design-script/sandbox.ts"() {
|
|
400666
400811
|
"use strict";
|
|
@@ -400684,7 +400829,7 @@ window.addEventListener('message', e => {
|
|
|
400684
400829
|
})
|
|
400685
400830
|
parent.postMessage({ kind: 'ready' }, '*')
|
|
400686
400831
|
</script>`;
|
|
400687
|
-
|
|
400832
|
+
frame2 = null;
|
|
400688
400833
|
ready2 = null;
|
|
400689
400834
|
next = 0;
|
|
400690
400835
|
pending6 = /* @__PURE__ */ new Map();
|
|
@@ -401751,8 +401896,8 @@ function createLoupe() {
|
|
|
401751
401896
|
el.style.left = `${x2}px`;
|
|
401752
401897
|
el.style.top = `${y}px`;
|
|
401753
401898
|
},
|
|
401754
|
-
show(
|
|
401755
|
-
for (let i2 = 0; i2 < cells.length; i2++) cells[i2].style.background =
|
|
401899
|
+
show(patch2, hex10) {
|
|
401900
|
+
for (let i2 = 0; i2 < cells.length; i2++) cells[i2].style.background = patch2.cells[i2] ?? "transparent";
|
|
401756
401901
|
label3.textContent = hex10 ?? "transparent";
|
|
401757
401902
|
el.style.opacity = "1";
|
|
401758
401903
|
},
|
|
@@ -401791,10 +401936,10 @@ function beginEyedrop(onPreview) {
|
|
|
401791
401936
|
busy = true;
|
|
401792
401937
|
last3 = now2;
|
|
401793
401938
|
const { x: x2, y } = worldAt(e);
|
|
401794
|
-
void samplePatchAtWorld(x2, y, LOUPE_RADIUS).then((
|
|
401795
|
-
if (
|
|
401796
|
-
loupe.show(
|
|
401797
|
-
onPreview?.(
|
|
401939
|
+
void samplePatchAtWorld(x2, y, LOUPE_RADIUS).then((patch2) => {
|
|
401940
|
+
if (patch2) {
|
|
401941
|
+
loupe.show(patch2, hexOf2(patch2.center));
|
|
401942
|
+
onPreview?.(patch2.center);
|
|
401798
401943
|
}
|
|
401799
401944
|
}).catch(() => {
|
|
401800
401945
|
}).finally(() => {
|
|
@@ -403155,24 +403300,24 @@ function checkDesign(doc2, roots) {
|
|
|
403155
403300
|
const issues = [];
|
|
403156
403301
|
const kind = doc2.settings?.kind ?? "CANVAS";
|
|
403157
403302
|
for (const id3 of roots) {
|
|
403158
|
-
const
|
|
403159
|
-
if (!
|
|
403160
|
-
const size6 = `${Math.round(
|
|
403161
|
-
const preset =
|
|
403303
|
+
const frame3 = doc2.nodes[id3];
|
|
403304
|
+
if (!frame3 || frame3.type !== "FRAME") continue;
|
|
403305
|
+
const size6 = `${Math.round(frame3.width)}\xD7${Math.round(frame3.height)}`;
|
|
403306
|
+
const preset = frame3.print?.presetId ?? presetOf(doc2, Math.round(frame3.width), Math.round(frame3.height));
|
|
403162
403307
|
const min2 = preset && PAGE_PRESETS.find((p2) => p2.id === preset)?.category === "SOCIAL" ? MIN_TEXT_PX.SOCIAL : MIN_TEXT_PX[kind];
|
|
403163
403308
|
const texts = paintedTexts(doc2, [id3]);
|
|
403164
|
-
const box2 = { x: 0, y: 0, width:
|
|
403165
|
-
const safe2 = preset ? presetSafeRect(preset,
|
|
403309
|
+
const box2 = { x: 0, y: 0, width: frame3.width, height: frame3.height };
|
|
403310
|
+
const safe2 = preset ? presetSafeRect(preset, frame3.width, frame3.height) : null;
|
|
403166
403311
|
const add3 = (i2) => {
|
|
403167
403312
|
if (issues.length < MAX_ISSUES) issues.push({ size: size6, ...i2 });
|
|
403168
403313
|
};
|
|
403169
|
-
if (
|
|
403314
|
+
if (frame3.height > MAX_FRAME_PX || frame3.width > MAX_FRAME_PX) add3({ kind: "too-tall", layer: frame3.name, message: `The frame is ${Math.round(frame3.width)}\xD7${Math.round(frame3.height)}: past ${MAX_FRAME_PX} px it renders blank in thumbnails and exports. Tighten spacing, condense lists and drop repeated sections at this size.` });
|
|
403170
403315
|
const moving = (textId) => animatedUp(doc2, textId.split("::")[0], id3);
|
|
403171
403316
|
const tilted = (textId) => tiltedUp(doc2, textId.split("::")[0], id3);
|
|
403172
403317
|
const visibleTexts = texts.filter((t3) => !clippedAway(doc2, t3, id3));
|
|
403173
403318
|
for (const t3 of visibleTexts) {
|
|
403174
|
-
const r = { x: t3.x -
|
|
403175
|
-
const at4 = t3.x >=
|
|
403319
|
+
const r = { x: t3.x - frame3.x, y: t3.y - frame3.y, width: t3.width, height: t3.height };
|
|
403320
|
+
const at4 = t3.x >= frame3.x - 1 && t3.y >= frame3.y - 1 ? r : { x: t3.x, y: t3.y, width: t3.width, height: t3.height };
|
|
403176
403321
|
if (t3.contrast < t3.required) add3({ kind: "contrast", layer: t3.name, message: `${label2(t3)} reads at ${t3.contrast.toFixed(1)}:1 against what is behind it; it needs ${t3.required}:1. Darken or lighten it, or give it a plate.` });
|
|
403177
403322
|
if (t3.fontSize < min2) add3({ kind: "small-text", layer: t3.name, message: `${label2(t3)} is ${t3.fontSize}px; at this size text should be at least ${min2}px.` });
|
|
403178
403323
|
const partly = overlaps2(box2, at4) && !contains(box2, at4);
|
|
@@ -403193,21 +403338,21 @@ function checkDesign(doc2, roots) {
|
|
|
403193
403338
|
n.childIds.forEach(walkInst);
|
|
403194
403339
|
};
|
|
403195
403340
|
walkInst(id3);
|
|
403196
|
-
const seam = seamJump(doc2,
|
|
403341
|
+
const seam = seamJump(doc2, frame3);
|
|
403197
403342
|
if (seam) add3({ kind: "seam", layer: seam.layer, message: seam.message });
|
|
403198
|
-
const band = emptyBand(doc2,
|
|
403199
|
-
if (band) add3({ kind: "empty-band", layer:
|
|
403343
|
+
const band = emptyBand(doc2, frame3);
|
|
403344
|
+
if (band) add3({ kind: "empty-band", layer: frame3.name, message: band });
|
|
403200
403345
|
}
|
|
403201
403346
|
return issues;
|
|
403202
403347
|
}
|
|
403203
|
-
function seamJump(doc2,
|
|
403204
|
-
const tl =
|
|
403205
|
-
if (!tl || tl.audio?.length || tl.duration <= 0 ||
|
|
403206
|
-
if (Object.values(doc2.compositions ?? {}).some((c2) => c2.clips.some((clip) => clip.frameId ===
|
|
403207
|
-
const end = tl.workArea ? tl.workArea[1] : timelineDuration(doc2.nodes,
|
|
403348
|
+
function seamJump(doc2, frame3) {
|
|
403349
|
+
const tl = frame3.timeline;
|
|
403350
|
+
if (!tl || tl.audio?.length || tl.duration <= 0 || frame3.print?.transition || doc2.settings?.kind === "PRESENTATION") return null;
|
|
403351
|
+
if (Object.values(doc2.compositions ?? {}).some((c2) => c2.clips.some((clip) => clip.frameId === frame3.id))) return null;
|
|
403352
|
+
const end = tl.workArea ? tl.workArea[1] : timelineDuration(doc2.nodes, frame3.id);
|
|
403208
403353
|
const start2 = tl.workArea ? tl.workArea[0] : 0;
|
|
403209
403354
|
const shown2 = (ms2) => {
|
|
403210
|
-
const posed2 = evaluatePose(doc2.nodes, { kind: "frame", frameId:
|
|
403355
|
+
const posed2 = evaluatePose(doc2.nodes, { kind: "frame", frameId: frame3.id }, ms2).nodes;
|
|
403211
403356
|
const out = /* @__PURE__ */ new Map();
|
|
403212
403357
|
const walk4 = (id3, alpha2, maskedIn = false) => {
|
|
403213
403358
|
let hidden2 = maskedIn;
|
|
@@ -403229,7 +403374,7 @@ function seamJump(doc2, frame2) {
|
|
|
403229
403374
|
walk4(c2, a2, hidden2);
|
|
403230
403375
|
}
|
|
403231
403376
|
};
|
|
403232
|
-
walk4(
|
|
403377
|
+
walk4(frame3.id, 1);
|
|
403233
403378
|
return out;
|
|
403234
403379
|
};
|
|
403235
403380
|
const a = shown2(start2), b = shown2(end);
|
|
@@ -403270,8 +403415,8 @@ function animatedUp(doc2, id3, frameId) {
|
|
|
403270
403415
|
}
|
|
403271
403416
|
return false;
|
|
403272
403417
|
}
|
|
403273
|
-
function emptyBand(doc2,
|
|
403274
|
-
const H = Math.round(
|
|
403418
|
+
function emptyBand(doc2, frame3) {
|
|
403419
|
+
const H = Math.round(frame3.height), W = frame3.width;
|
|
403275
403420
|
if (H < 200) return null;
|
|
403276
403421
|
const filled2 = new Uint8Array(H);
|
|
403277
403422
|
const walk4 = (id3, ox, oy, depth) => {
|
|
@@ -403284,7 +403429,7 @@ function emptyBand(doc2, frame2) {
|
|
|
403284
403429
|
}
|
|
403285
403430
|
for (const c2 of n.childIds) walk4(c2, x2, y, depth + 1);
|
|
403286
403431
|
};
|
|
403287
|
-
walk4(
|
|
403432
|
+
walk4(frame3.id, 0, 0, 0);
|
|
403288
403433
|
let best = 0, at4 = 0, run4 = 0;
|
|
403289
403434
|
for (let r = 0; r <= H; r++) {
|
|
403290
403435
|
if (r < H && !filled2[r]) {
|
|
@@ -404197,13 +404342,13 @@ var init_site3 = __esm({
|
|
|
404197
404342
|
const patches = /* @__PURE__ */ new Map();
|
|
404198
404343
|
for (const id3 of ids2) {
|
|
404199
404344
|
let node2 = doc2.nodes[id3];
|
|
404200
|
-
let
|
|
404345
|
+
let patch2 = {};
|
|
404201
404346
|
if (args2.reset) {
|
|
404202
|
-
|
|
404203
|
-
node2 = { ...node2, ...
|
|
404347
|
+
patch2 = resetOverrides(node2, args2.breakpoint, args2.reset === "all" ? void 0 : args2.reset);
|
|
404348
|
+
node2 = { ...node2, ...patch2 };
|
|
404204
404349
|
}
|
|
404205
|
-
if (args2.set)
|
|
404206
|
-
patches.set(id3,
|
|
404350
|
+
if (args2.set) patch2 = { ...patch2, ...breakpointPatch(node2, doc2, args2.breakpoint, args2.set) };
|
|
404351
|
+
patches.set(id3, patch2);
|
|
404207
404352
|
}
|
|
404208
404353
|
commitUpdates(ctx2, doc2, patches);
|
|
404209
404354
|
const names = ids2.map((id3) => doc2.nodes[id3].name).slice(0, 3).join(", ");
|
|
@@ -404356,14 +404501,14 @@ var init_site3 = __esm({
|
|
|
404356
404501
|
run: (args2, ctx2) => {
|
|
404357
404502
|
const { doc: doc2, ids: ids2 } = resolveTargets(ctx2, args2.id ? [args2.id] : void 0, "set_route");
|
|
404358
404503
|
const id3 = ids2[0];
|
|
404359
|
-
const
|
|
404360
|
-
if (
|
|
404504
|
+
const frame3 = doc2.nodes[id3];
|
|
404505
|
+
if (frame3.type !== "FRAME" || doc2.nodes[frame3.parentId ?? ""]?.type !== "PAGE") throw new ToolError(`"${frame3.name}" is not a top-level frame: only a screen has an address.`);
|
|
404361
404506
|
const path = args2.path ? cleanPath(args2.path) : args2.path;
|
|
404362
404507
|
if (path) {
|
|
404363
|
-
const other = Object.values(doc2.nodes).find((n) => n.id !== id3 && n.parentId ===
|
|
404508
|
+
const other = Object.values(doc2.nodes).find((n) => n.id !== id3 && n.parentId === frame3.parentId && n.route?.path && cleanPath(n.route.path) === path);
|
|
404364
404509
|
if (other) throw new ToolError(`${path} is already "${other.name}".`);
|
|
404365
404510
|
}
|
|
404366
|
-
const next2 = { ...
|
|
404511
|
+
const next2 = { ...frame3.route };
|
|
404367
404512
|
const put3 = (key5, value3) => {
|
|
404368
404513
|
if (value3 === void 0) return;
|
|
404369
404514
|
if (value3 === null || value3 === false || value3 === "") delete next2[key5];
|
|
@@ -404379,7 +404524,7 @@ var init_site3 = __esm({
|
|
|
404379
404524
|
put3("access", args2.access);
|
|
404380
404525
|
put3("collectionId", args2.collectionId);
|
|
404381
404526
|
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[id3, { route: Object.keys(next2).length ? next2 : void 0 }]]));
|
|
404382
|
-
return { summary: `${
|
|
404527
|
+
return { summary: `${frame3.name}: ${path ?? "automatic address"}`, data: { id: id3, route: next2 } };
|
|
404383
404528
|
}
|
|
404384
404529
|
});
|
|
404385
404530
|
breakpoint = external_exports.object({
|
|
@@ -405478,8 +405623,8 @@ var init_presentation_audio = __esm({
|
|
|
405478
405623
|
run: async (args2, ctx2) => {
|
|
405479
405624
|
const page = pageOf3(ctx2, args2.pageId);
|
|
405480
405625
|
let base = ctx2.doc();
|
|
405481
|
-
const
|
|
405482
|
-
if (Object.keys(
|
|
405626
|
+
const patch2 = settingsOf(args2);
|
|
405627
|
+
if (Object.keys(patch2).length || !soundtrackOf(base, page)) base = doc(() => configure(base, page, patch2));
|
|
405483
405628
|
const view2 = readDeck(base, page);
|
|
405484
405629
|
const what = args2.what ?? "all";
|
|
405485
405630
|
let frameIds = args2.slides;
|
|
@@ -405495,7 +405640,7 @@ var init_presentation_audio = __esm({
|
|
|
405495
405640
|
throw new ToolError(result.errors[0]?.message ?? "Nothing was made.");
|
|
405496
405641
|
}
|
|
405497
405642
|
let latest = ctx2.doc();
|
|
405498
|
-
if (Object.keys(
|
|
405643
|
+
if (Object.keys(patch2).length || !soundtrackOf(latest, page)) latest = doc(() => configure(latest, page, patch2));
|
|
405499
405644
|
const applied = doc(() => applyGeneration(latest, page, result));
|
|
405500
405645
|
const { doc: next2, mix: mix4 } = await withMixTrim(applied, page);
|
|
405501
405646
|
ctx2.commit(next2);
|
|
@@ -406568,7 +406713,7 @@ function generateStressDocument(opts = {}) {
|
|
|
406568
406713
|
for (let f2 = 0; f2 < frames; f2++) {
|
|
406569
406714
|
const col3 = f2 % cols;
|
|
406570
406715
|
const row2 = Math.floor(f2 / cols);
|
|
406571
|
-
const
|
|
406716
|
+
const frame3 = createFrame({
|
|
406572
406717
|
name: `Screen ${f2 + 1}`,
|
|
406573
406718
|
x: col3 * (FRAME_W + GAP),
|
|
406574
406719
|
y: row2 * (FRAME_H + GAP),
|
|
@@ -406587,7 +406732,7 @@ function generateStressDocument(opts = {}) {
|
|
|
406587
406732
|
width: 156,
|
|
406588
406733
|
height: 88,
|
|
406589
406734
|
cornerRadius: 12,
|
|
406590
|
-
parentId:
|
|
406735
|
+
parentId: frame3.id,
|
|
406591
406736
|
fills: [{ type: "SOLID", visible: true, opacity: 1, color: hslToRgb2(hue, 0.55, 0.62) }]
|
|
406592
406737
|
});
|
|
406593
406738
|
nodes[r.id] = r;
|
|
@@ -406600,7 +406745,7 @@ function generateStressDocument(opts = {}) {
|
|
|
406600
406745
|
y: 24 + Math.floor(i2 / 2) * 100,
|
|
406601
406746
|
width: 40,
|
|
406602
406747
|
height: 40,
|
|
406603
|
-
parentId:
|
|
406748
|
+
parentId: frame3.id
|
|
406604
406749
|
});
|
|
406605
406750
|
nodes[e.id] = e;
|
|
406606
406751
|
childIds.push(e.id);
|
|
@@ -406616,14 +406761,14 @@ function generateStressDocument(opts = {}) {
|
|
|
406616
406761
|
width: 140,
|
|
406617
406762
|
height: i2 === 0 ? 30 : 18,
|
|
406618
406763
|
textAutoResize: "HEIGHT",
|
|
406619
|
-
parentId:
|
|
406764
|
+
parentId: frame3.id
|
|
406620
406765
|
});
|
|
406621
406766
|
nodes[t3.id] = t3;
|
|
406622
406767
|
childIds.push(t3.id);
|
|
406623
406768
|
}
|
|
406624
|
-
|
|
406625
|
-
nodes[
|
|
406626
|
-
page.childIds.push(
|
|
406769
|
+
frame3.childIds = childIds;
|
|
406770
|
+
nodes[frame3.id] = frame3;
|
|
406771
|
+
page.childIds.push(frame3.id);
|
|
406627
406772
|
}
|
|
406628
406773
|
return { ...doc2, nodes };
|
|
406629
406774
|
}
|
|
@@ -407421,9 +407566,9 @@ var init_editor_store = __esm({
|
|
|
407421
407566
|
set4((st) => ({ document: { ...st.document, thumbnailNodeId: nodeId2 || void 0 } }));
|
|
407422
407567
|
if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-thumbnail-now"));
|
|
407423
407568
|
},
|
|
407424
|
-
setDocumentSettings: (
|
|
407569
|
+
setDocumentSettings: (patch2) => {
|
|
407425
407570
|
const { document: document2, recordState, commitState } = get4();
|
|
407426
|
-
const settings = { ...document2.settings, ...
|
|
407571
|
+
const settings = { ...document2.settings, ...patch2 };
|
|
407427
407572
|
for (const k2 of Object.keys(settings)) if (settings[k2] === void 0) delete settings[k2];
|
|
407428
407573
|
recordState("property", "Document settings");
|
|
407429
407574
|
set4({ document: { ...document2, settings: Object.keys(settings).length ? settings : void 0 } });
|
|
@@ -407437,13 +407582,13 @@ var init_editor_store = __esm({
|
|
|
407437
407582
|
set4({ document: next2 });
|
|
407438
407583
|
commitState("Page setup");
|
|
407439
407584
|
},
|
|
407440
|
-
applyParagraphFormat: (nodeId2,
|
|
407585
|
+
applyParagraphFormat: (nodeId2, patch2) => {
|
|
407441
407586
|
const state = get4();
|
|
407442
407587
|
const node2 = state.document.nodes[nodeId2];
|
|
407443
407588
|
if (!node2 || node2.type !== "TEXT") return;
|
|
407444
407589
|
const te2 = state.textEditState;
|
|
407445
407590
|
const range3 = te2 && te2.nodeId === nodeId2 ? { start: Math.min(te2.cursor, te2.anchor), end: Math.max(te2.cursor, te2.anchor) } : null;
|
|
407446
|
-
state.updateNodeProps(nodeId2, { paragraphs: withParagraphFormat(node2, range3,
|
|
407591
|
+
state.updateNodeProps(nodeId2, { paragraphs: withParagraphFormat(node2, range3, patch2) });
|
|
407447
407592
|
},
|
|
407448
407593
|
linkTextFrames: (fromId, toId) => {
|
|
407449
407594
|
const state = get4();
|
|
@@ -407518,11 +407663,11 @@ var init_editor_store = __esm({
|
|
|
407518
407663
|
const id3 = s.activePrototypeFrameId;
|
|
407519
407664
|
if (!id3) return;
|
|
407520
407665
|
s.focusOnNode(id3);
|
|
407521
|
-
const
|
|
407522
|
-
const cell =
|
|
407523
|
-
if (
|
|
407666
|
+
const frame3 = s.document.nodes[id3];
|
|
407667
|
+
const cell = frame3?.pixelPerfect ? screenPixelCell(s.document, id3) : null;
|
|
407668
|
+
if (frame3 && cell) {
|
|
407524
407669
|
const t3 = getWorldTransform(s.document, id3);
|
|
407525
|
-
set4({ camera: pixelPerfectCamera(canvasViewport(), { x: t3.cx -
|
|
407670
|
+
set4({ camera: pixelPerfectCamera(canvasViewport(), { x: t3.cx - frame3.width / 2, y: t3.cy - frame3.height / 2, width: frame3.width, height: frame3.height }, cell) });
|
|
407526
407671
|
}
|
|
407527
407672
|
return;
|
|
407528
407673
|
}
|
|
@@ -407645,10 +407790,10 @@ var init_editor_store = __esm({
|
|
|
407645
407790
|
let document2 = st.document;
|
|
407646
407791
|
targets.forEach((t3, i2) => {
|
|
407647
407792
|
const p2 = pasted[i2 % pasted.length];
|
|
407648
|
-
const
|
|
407649
|
-
document2 = updateNode(document2, p2.id,
|
|
407793
|
+
const patch2 = { x: t3.x, y: t3.y, width: t3.width, height: t3.height, rotation: t3.rotation };
|
|
407794
|
+
document2 = updateNode(document2, p2.id, patch2);
|
|
407650
407795
|
if (t3.parentId && p2.parentId !== t3.parentId) document2 = reparentNode(document2, p2.id, t3.parentId, (document2.nodes[t3.parentId]?.childIds.indexOf(t3.id) ?? -1) + 1);
|
|
407651
|
-
if (i2 >= pasted.length) document2 = updateNode(document2, p2.id,
|
|
407796
|
+
if (i2 >= pasted.length) document2 = updateNode(document2, p2.id, patch2);
|
|
407652
407797
|
});
|
|
407653
407798
|
for (const t3 of targets) document2 = removeNode(document2, t3.id);
|
|
407654
407799
|
return { document: document2, selection: pasted.map((p2) => p2.id) };
|
|
@@ -407668,8 +407813,8 @@ var init_editor_store = __esm({
|
|
|
407668
407813
|
navigatePrototype: (action3, firedOn, key5) => {
|
|
407669
407814
|
const before = runtimeOf(get4());
|
|
407670
407815
|
const step3 = runAction(before, action3, { driver: presentDriver, now: performance.now(), firedOn, key: key5, reducedMotion: prefersReducedMotion() });
|
|
407671
|
-
const
|
|
407672
|
-
if (
|
|
407816
|
+
const patch2 = storePatch(before, step3.state);
|
|
407817
|
+
if (patch2) set4(patch2);
|
|
407673
407818
|
const run4 = (effects) => {
|
|
407674
407819
|
for (const e of effects) {
|
|
407675
407820
|
if (e.kind === "arrived") {
|
|
@@ -407692,16 +407837,16 @@ var init_editor_store = __esm({
|
|
|
407692
407837
|
},
|
|
407693
407838
|
setPrototypeScroll: (nodeId2, deltaX, deltaY) => {
|
|
407694
407839
|
const before = runtimeOf(get4());
|
|
407695
|
-
const
|
|
407696
|
-
if (
|
|
407840
|
+
const patch2 = storePatch(before, scrollBy(before, nodeId2, deltaX, deltaY));
|
|
407841
|
+
if (patch2) set4(patch2);
|
|
407697
407842
|
},
|
|
407698
407843
|
// Comment actions
|
|
407699
407844
|
addComment: (comment) => set4((state) => ({
|
|
407700
407845
|
comments: [...state.comments, comment]
|
|
407701
407846
|
})),
|
|
407702
|
-
updateComment: (commentId,
|
|
407847
|
+
updateComment: (commentId, patch2) => set4((state) => ({
|
|
407703
407848
|
comments: state.comments.map(
|
|
407704
|
-
(c2) => c2.id === commentId ? { ...c2, ...
|
|
407849
|
+
(c2) => c2.id === commentId ? { ...c2, ...patch2, updatedAt: Date.now() } : c2
|
|
407705
407850
|
)
|
|
407706
407851
|
})),
|
|
407707
407852
|
deleteComment: (commentId) => set4((state) => ({
|
|
@@ -408813,10 +408958,10 @@ var init_editor_store = __esm({
|
|
|
408813
408958
|
set4((st) => {
|
|
408814
408959
|
let document2 = st.document;
|
|
408815
408960
|
for (let i2 = 0; i2 < count2; i2++) {
|
|
408816
|
-
const
|
|
408817
|
-
document2 = addNode(document2,
|
|
408818
|
-
made.push(
|
|
408819
|
-
const folds = foldGuidesAt(preset,
|
|
408961
|
+
const frame3 = createPrintPage(document2, st.currentPageId, { preset });
|
|
408962
|
+
document2 = addNode(document2, frame3, st.currentPageId);
|
|
408963
|
+
made.push(frame3.id);
|
|
408964
|
+
const folds = foldGuidesAt(preset, frame3);
|
|
408820
408965
|
if (folds.length) {
|
|
408821
408966
|
const page = document2.nodes[st.currentPageId];
|
|
408822
408967
|
document2 = { ...document2, nodes: { ...document2.nodes, [st.currentPageId]: { ...page, guides: [...page.guides ?? [], ...folds] } } };
|
|
@@ -408838,10 +408983,10 @@ var init_editor_store = __esm({
|
|
|
408838
408983
|
let document2 = st.document;
|
|
408839
408984
|
const pageId2 = st.currentPageId;
|
|
408840
408985
|
for (const id3 of ids2) {
|
|
408841
|
-
const
|
|
408842
|
-
if (!
|
|
408986
|
+
const frame3 = document2.nodes[id3];
|
|
408987
|
+
if (!frame3 || frame3.type !== "FRAME") continue;
|
|
408843
408988
|
const page = document2.nodes[pageId2];
|
|
408844
|
-
const stale = new Set(foldsOn(page.guides,
|
|
408989
|
+
const stale = new Set(foldsOn(page.guides, frame3).map((g) => g.id));
|
|
408845
408990
|
document2 = updateNode(document2, id3, { width: size6.width, height: size6.height });
|
|
408846
408991
|
const resized = document2.nodes[id3];
|
|
408847
408992
|
const guides = [...(page.guides ?? []).filter((g) => !stale.has(g.id)), ...foldGuidesAt(preset, resized)];
|
|
@@ -408867,12 +409012,12 @@ var init_editor_store = __esm({
|
|
|
408867
409012
|
},
|
|
408868
409013
|
addMasterPage: () => {
|
|
408869
409014
|
const state = get4();
|
|
408870
|
-
const
|
|
409015
|
+
const frame3 = createMasterPage(state.document, state.currentPageId);
|
|
408871
409016
|
state.recordState("add", "Add master");
|
|
408872
|
-
set4((st) => ({ document: addNode(st.document,
|
|
409017
|
+
set4((st) => ({ document: addNode(st.document, frame3, st.currentPageId), selection: [frame3.id] }));
|
|
408873
409018
|
state.commitState("Add master");
|
|
408874
|
-
get4().zoomToNodes([
|
|
408875
|
-
return
|
|
409019
|
+
get4().zoomToNodes([frame3.id], 0.1);
|
|
409020
|
+
return frame3.id;
|
|
408876
409021
|
},
|
|
408877
409022
|
setPageMaster: (pageIds, masterId) => {
|
|
408878
409023
|
const state = get4();
|
|
@@ -410187,14 +410332,14 @@ var init_editor_store = __esm({
|
|
|
410187
410332
|
const textEdit = state.textEditState;
|
|
410188
410333
|
const charsLength = (node2.characters ?? "").length;
|
|
410189
410334
|
const isFullSelection = !textEdit || textEdit.nodeId !== nodeId2 || textEdit.cursor === textEdit.anchor || Math.min(textEdit.cursor, textEdit.anchor) === 0 && Math.max(textEdit.cursor, textEdit.anchor) === charsLength;
|
|
410190
|
-
let
|
|
410335
|
+
let patch2;
|
|
410191
410336
|
if (isFullSelection) {
|
|
410192
410337
|
const segments = (node2.styledSegments ?? []).map((seg) => {
|
|
410193
410338
|
const next2 = { ...seg };
|
|
410194
410339
|
for (const key5 of Object.keys(styles)) delete next2[key5];
|
|
410195
410340
|
return next2;
|
|
410196
410341
|
}).filter((seg) => Object.keys(seg).length > 2);
|
|
410197
|
-
|
|
410342
|
+
patch2 = { ...styles, ...node2.styledSegments ? { styledSegments: segments } : {} };
|
|
410198
410343
|
} else {
|
|
410199
410344
|
const start2 = Math.min(textEdit.cursor, textEdit.anchor);
|
|
410200
410345
|
const end = Math.max(textEdit.cursor, textEdit.anchor);
|
|
@@ -410215,9 +410360,9 @@ var init_editor_store = __esm({
|
|
|
410215
410360
|
});
|
|
410216
410361
|
if (gapStart < end) punched.push({ start: gapStart, end, ...styles });
|
|
410217
410362
|
punched.sort((a, b) => a.start - b.start);
|
|
410218
|
-
|
|
410363
|
+
patch2 = { styledSegments: punched };
|
|
410219
410364
|
}
|
|
410220
|
-
get4().updateNodeProps(nodeId2,
|
|
410365
|
+
get4().updateNodeProps(nodeId2, patch2);
|
|
410221
410366
|
get4().recordState("APPLY_TEXT_STYLE", "Apply text style");
|
|
410222
410367
|
if (typeof window !== "undefined") {
|
|
410223
410368
|
window.dispatchEvent(new CustomEvent("popcraft-resync-text", { detail: { nodeId: nodeId2 } }));
|
|
@@ -410233,12 +410378,12 @@ var init_editor_store = __esm({
|
|
|
410233
410378
|
return { document: updateNode(state.document, nodeId2, { interactions }) };
|
|
410234
410379
|
});
|
|
410235
410380
|
},
|
|
410236
|
-
updateInteraction: (nodeId2, interactionId,
|
|
410381
|
+
updateInteraction: (nodeId2, interactionId, patch2) => {
|
|
410237
410382
|
set4((state) => {
|
|
410238
410383
|
const node2 = state.document.nodes[nodeId2];
|
|
410239
410384
|
if (!node2) return {};
|
|
410240
410385
|
const interactions = (node2.interactions ?? []).map(
|
|
410241
|
-
(ix) => ix.id === interactionId ? { ...ix, ...
|
|
410386
|
+
(ix) => ix.id === interactionId ? { ...ix, ...patch2 } : ix
|
|
410242
410387
|
);
|
|
410243
410388
|
return { document: updateNode(state.document, nodeId2, { interactions }) };
|
|
410244
410389
|
});
|
|
@@ -410302,7 +410447,7 @@ var init_editor_store = __esm({
|
|
|
410302
410447
|
const command = createCommand("CREATE_VARIABLE", "Create variable", documentBefore, documentAfter);
|
|
410303
410448
|
set4({ document: documentAfter, history: pushCommand(state.history, command) });
|
|
410304
410449
|
},
|
|
410305
|
-
updateVariable: (variableId,
|
|
410450
|
+
updateVariable: (variableId, patch2) => {
|
|
410306
410451
|
const state = get4();
|
|
410307
410452
|
if (!state.document.variables?.[variableId]) return;
|
|
410308
410453
|
const documentBefore = state.document;
|
|
@@ -410312,7 +410457,7 @@ var init_editor_store = __esm({
|
|
|
410312
410457
|
...state.document.variables,
|
|
410313
410458
|
[variableId]: {
|
|
410314
410459
|
...state.document.variables[variableId],
|
|
410315
|
-
...
|
|
410460
|
+
...patch2
|
|
410316
410461
|
}
|
|
410317
410462
|
}
|
|
410318
410463
|
};
|
|
@@ -413359,7 +413504,7 @@ init_resources();
|
|
|
413359
413504
|
init_desktop();
|
|
413360
413505
|
init_hypery();
|
|
413361
413506
|
import { createInterface } from "node:readline";
|
|
413362
|
-
var VERSION2 = "0.
|
|
413507
|
+
var VERSION2 = "0.44.0";
|
|
413363
413508
|
var HELP = `popcraft ${VERSION2} \u2014 the PopCraft command line
|
|
413364
413509
|
|
|
413365
413510
|
Files (headless, on .popcraft files):
|