@popcraft/cli 0.43.2 → 0.44.1
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.1"}`, ...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;
|
|
@@ -97535,7 +97535,6 @@ function relinkCopies(doc2, copies) {
|
|
|
97535
97535
|
var TEXT_PATH_SOURCE_TYPES, isPathSource;
|
|
97536
97536
|
var init_text_links = __esm({
|
|
97537
97537
|
"lib/document/text-links.ts"() {
|
|
97538
|
-
"use strict";
|
|
97539
97538
|
init_transform();
|
|
97540
97539
|
TEXT_PATH_SOURCE_TYPES = ["VECTOR", "ELLIPSE", "RECTANGLE", "POLYGON", "STAR", "LINE", "ARROW", "FRAME"];
|
|
97541
97540
|
isPathSource = (n) => !!n && TEXT_PATH_SOURCE_TYPES.includes(n.type);
|
|
@@ -97851,36 +97850,36 @@ function applyAutoLayout(doc2) {
|
|
|
97851
97850
|
const clampedWidth = (w, c2) => Math.max(c2.minWidth ?? 1, Math.min(c2.maxWidth ?? Infinity, w));
|
|
97852
97851
|
const clampedHeight = (h, c2) => Math.max(c2.minHeight ?? 1, Math.min(c2.maxHeight ?? Infinity, h));
|
|
97853
97852
|
if (isAutoLayout(node2)) {
|
|
97854
|
-
const
|
|
97853
|
+
const frame3 = cloneNode(nodeId2);
|
|
97855
97854
|
let totalChildrenPrimary = 0;
|
|
97856
97855
|
let maxChildrenCounter = 0;
|
|
97857
|
-
const isHorizontal =
|
|
97858
|
-
const isGrid2 =
|
|
97859
|
-
const paddingX =
|
|
97860
|
-
const paddingY =
|
|
97861
|
-
const itemSpacing =
|
|
97862
|
-
const counterSpacing =
|
|
97856
|
+
const isHorizontal = frame3.layoutMode === "HORIZONTAL";
|
|
97857
|
+
const isGrid2 = frame3.layoutMode === "GRID";
|
|
97858
|
+
const paddingX = frame3.padding.left + frame3.padding.right;
|
|
97859
|
+
const paddingY = frame3.padding.top + frame3.padding.bottom;
|
|
97860
|
+
const itemSpacing = frame3.itemSpacing;
|
|
97861
|
+
const counterSpacing = frame3.counterAxisSpacing ?? itemSpacing;
|
|
97863
97862
|
let fillChildrenCount = 0;
|
|
97864
|
-
const childIds =
|
|
97863
|
+
const childIds = frame3.childIds.filter((id3) => {
|
|
97865
97864
|
const child = newNodes[id3];
|
|
97866
97865
|
return child && child.visible && child.layoutPositioning !== "ABSOLUTE";
|
|
97867
97866
|
});
|
|
97868
|
-
for (const id3 of
|
|
97867
|
+
for (const id3 of frame3.childIds) {
|
|
97869
97868
|
const child = newNodes[id3];
|
|
97870
97869
|
if (child && child.visible && child.layoutPositioning === "ABSOLUTE") measureNode(id3);
|
|
97871
97870
|
}
|
|
97872
97871
|
let intrinsicW = 0;
|
|
97873
97872
|
let intrinsicH = 0;
|
|
97874
97873
|
if (isGrid2) {
|
|
97875
|
-
const cols =
|
|
97876
|
-
const rows =
|
|
97877
|
-
const minColW =
|
|
97878
|
-
const minRowH =
|
|
97874
|
+
const cols = frame3.layoutGridColumns ?? "AUTO";
|
|
97875
|
+
const rows = frame3.layoutGridRows ?? "AUTO";
|
|
97876
|
+
const minColW = frame3.layoutGridMinColumnWidth ?? 100;
|
|
97877
|
+
const minRowH = frame3.layoutGridMinRowHeight ?? 100;
|
|
97879
97878
|
let actualCols = 1;
|
|
97880
|
-
let colSizes =
|
|
97879
|
+
let colSizes = frame3.layoutGridColumnSizes || [];
|
|
97881
97880
|
if (cols === "AUTO") {
|
|
97882
|
-
if (
|
|
97883
|
-
const availW =
|
|
97881
|
+
if (frame3.layoutSizingHorizontal === "FIXED" || frame3.layoutSizingHorizontal === "FILL") {
|
|
97882
|
+
const availW = frame3.width - paddingX;
|
|
97884
97883
|
actualCols = Math.max(1, Math.floor((availW + itemSpacing) / (minColW + itemSpacing)));
|
|
97885
97884
|
} else {
|
|
97886
97885
|
actualCols = Math.max(1, childIds.length);
|
|
@@ -97893,7 +97892,7 @@ function applyAutoLayout(doc2) {
|
|
|
97893
97892
|
}
|
|
97894
97893
|
}
|
|
97895
97894
|
let actualRows = 1;
|
|
97896
|
-
let rowSizes =
|
|
97895
|
+
let rowSizes = frame3.layoutGridRowSizes || [];
|
|
97897
97896
|
if (rows === "AUTO") {
|
|
97898
97897
|
actualRows = Math.max(1, Math.ceil(childIds.length / actualCols));
|
|
97899
97898
|
rowSizes = Array.from({ length: actualRows }).map(() => ({ sizing: "HUG", value: "113", min: minRowH }));
|
|
@@ -97953,18 +97952,18 @@ function applyAutoLayout(doc2) {
|
|
|
97953
97952
|
const totalSpacing = Math.max(0, childIds.length - 1) * itemSpacing;
|
|
97954
97953
|
intrinsicW = isHorizontal ? totalChildrenPrimary + totalSpacing + paddingX : maxChildrenCounter + paddingX;
|
|
97955
97954
|
intrinsicH = isHorizontal ? maxChildrenCounter + paddingY : totalChildrenPrimary + totalSpacing + paddingY;
|
|
97956
|
-
if (wraps(
|
|
97957
|
-
const lines2 = wrapLines(
|
|
97955
|
+
if (wraps(frame3)) {
|
|
97956
|
+
const lines2 = wrapLines(frame3, childIds, (id3) => measureNode(id3));
|
|
97958
97957
|
const counter = lines2.reduce((a, l) => a + l.counter, 0) + Math.max(0, lines2.length - 1) * counterSpacing;
|
|
97959
97958
|
if (isHorizontal) intrinsicH = counter + paddingY;
|
|
97960
97959
|
else intrinsicW = counter + paddingX;
|
|
97961
97960
|
}
|
|
97962
97961
|
}
|
|
97963
|
-
if (
|
|
97964
|
-
if (
|
|
97962
|
+
if (frame3.layoutSizingHorizontal === "HUG") frame3.width = clampedWidth(intrinsicW, frame3);
|
|
97963
|
+
if (frame3.layoutSizingVertical === "HUG") frame3.height = clampedHeight(intrinsicH, frame3);
|
|
97965
97964
|
return {
|
|
97966
|
-
intrinsicWidth: clampedWidth(
|
|
97967
|
-
intrinsicHeight: clampedHeight(
|
|
97965
|
+
intrinsicWidth: clampedWidth(frame3.layoutSizingHorizontal === "HUG" ? intrinsicW : frame3.width, frame3),
|
|
97966
|
+
intrinsicHeight: clampedHeight(frame3.layoutSizingVertical === "HUG" ? intrinsicH : frame3.height, frame3)
|
|
97968
97967
|
};
|
|
97969
97968
|
} else {
|
|
97970
97969
|
let height = node2.height;
|
|
@@ -97990,18 +97989,18 @@ function applyAutoLayout(doc2) {
|
|
|
97990
97989
|
function layoutNode(nodeId2) {
|
|
97991
97990
|
const node2 = newNodes[nodeId2];
|
|
97992
97991
|
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 =
|
|
97992
|
+
const frame3 = node2;
|
|
97993
|
+
const isHorizontal = frame3.layoutMode === "HORIZONTAL";
|
|
97994
|
+
const isGrid2 = frame3.layoutMode === "GRID";
|
|
97995
|
+
const paddingX = frame3.padding.left + frame3.padding.right;
|
|
97996
|
+
const paddingY = frame3.padding.top + frame3.padding.bottom;
|
|
97997
|
+
const itemSpacing = frame3.itemSpacing;
|
|
97998
|
+
const counterSpacing = frame3.counterAxisSpacing ?? itemSpacing;
|
|
97999
|
+
const childIds = frame3.childIds.filter((id3) => {
|
|
98001
98000
|
const child = newNodes[id3];
|
|
98002
98001
|
return child && child.visible && child.layoutPositioning !== "ABSOLUTE";
|
|
98003
98002
|
});
|
|
98004
|
-
const absoluteChildIds =
|
|
98003
|
+
const absoluteChildIds = frame3.childIds.filter((id3) => {
|
|
98005
98004
|
const child = newNodes[id3];
|
|
98006
98005
|
return child && child.visible && child.layoutPositioning === "ABSOLUTE";
|
|
98007
98006
|
});
|
|
@@ -98013,14 +98012,14 @@ function applyAutoLayout(doc2) {
|
|
|
98013
98012
|
const clampedWidth = (w, c2) => Math.max(c2.minWidth ?? 1, Math.min(c2.maxWidth ?? Infinity, w));
|
|
98014
98013
|
const clampedHeight = (h, c2) => Math.max(c2.minHeight ?? 1, Math.min(c2.maxHeight ?? Infinity, h));
|
|
98015
98014
|
if (isGrid2) {
|
|
98016
|
-
const cols =
|
|
98017
|
-
const rows =
|
|
98018
|
-
const minColW =
|
|
98019
|
-
const minRowH =
|
|
98015
|
+
const cols = frame3.layoutGridColumns ?? "AUTO";
|
|
98016
|
+
const rows = frame3.layoutGridRows ?? "AUTO";
|
|
98017
|
+
const minColW = frame3.layoutGridMinColumnWidth ?? 100;
|
|
98018
|
+
const minRowH = frame3.layoutGridMinRowHeight ?? 100;
|
|
98020
98019
|
let actualCols = 1;
|
|
98021
|
-
let colSizes =
|
|
98020
|
+
let colSizes = frame3.layoutGridColumnSizes || [];
|
|
98022
98021
|
if (cols === "AUTO") {
|
|
98023
|
-
const availW =
|
|
98022
|
+
const availW = frame3.width - paddingX;
|
|
98024
98023
|
actualCols = Math.max(1, Math.floor((availW + itemSpacing) / (minColW + itemSpacing)));
|
|
98025
98024
|
colSizes = Array.from({ length: actualCols }).map(() => ({ sizing: "FILL", value: "1fr" }));
|
|
98026
98025
|
} else {
|
|
@@ -98030,7 +98029,7 @@ function applyAutoLayout(doc2) {
|
|
|
98030
98029
|
}
|
|
98031
98030
|
}
|
|
98032
98031
|
let actualRows = 1;
|
|
98033
|
-
let rowSizes =
|
|
98032
|
+
let rowSizes = frame3.layoutGridRowSizes || [];
|
|
98034
98033
|
if (rows === "AUTO") {
|
|
98035
98034
|
actualRows = Math.max(1, Math.ceil(childIds.length / actualCols));
|
|
98036
98035
|
rowSizes = Array.from({ length: actualRows }).map(() => ({ sizing: "HUG", value: "113", min: minRowH }));
|
|
@@ -98058,7 +98057,7 @@ function applyAutoLayout(doc2) {
|
|
|
98058
98057
|
else if (s.sizing === "HUG") fixedColW += colMaxHugs[c2];
|
|
98059
98058
|
else if (s.sizing === "FILL") totalColFr += parseFloat(s.value) || 1;
|
|
98060
98059
|
});
|
|
98061
|
-
const availColW = Math.max(0,
|
|
98060
|
+
const availColW = Math.max(0, frame3.width - paddingX - Math.max(0, actualCols - 1) * itemSpacing - fixedColW);
|
|
98062
98061
|
const colW = new Array(actualCols).fill(0);
|
|
98063
98062
|
colSizes.forEach((s, c2) => {
|
|
98064
98063
|
if (s.sizing === "FIXED") colW[c2] = parseFloat(s.value) || 0;
|
|
@@ -98072,7 +98071,7 @@ function applyAutoLayout(doc2) {
|
|
|
98072
98071
|
else if (s.sizing === "HUG") fixedRowH += Math.max(s.min ?? 0, rowMaxHugs[r]);
|
|
98073
98072
|
else if (s.sizing === "FILL") totalRowFr += parseFloat(s.value) || 1;
|
|
98074
98073
|
});
|
|
98075
|
-
const availRowH = Math.max(0,
|
|
98074
|
+
const availRowH = Math.max(0, frame3.height - paddingY - Math.max(0, actualRows - 1) * counterSpacing - fixedRowH);
|
|
98076
98075
|
const rowH = new Array(actualRows).fill(0);
|
|
98077
98076
|
rowSizes.forEach((s, r) => {
|
|
98078
98077
|
if (s.sizing === "FIXED") rowH[r] = parseFloat(s.value) || 0;
|
|
@@ -98080,13 +98079,13 @@ function applyAutoLayout(doc2) {
|
|
|
98080
98079
|
else if (s.sizing === "FILL") rowH[r] = totalRowFr > 0 ? availRowH * ((parseFloat(s.value) || 1) / totalRowFr) : 0;
|
|
98081
98080
|
});
|
|
98082
98081
|
const colX = new Array(actualCols).fill(0);
|
|
98083
|
-
let currX =
|
|
98082
|
+
let currX = frame3.padding.left;
|
|
98084
98083
|
for (let c2 = 0; c2 < actualCols; c2++) {
|
|
98085
98084
|
colX[c2] = currX;
|
|
98086
98085
|
currX += colW[c2] + itemSpacing;
|
|
98087
98086
|
}
|
|
98088
98087
|
const rowY = new Array(actualRows).fill(0);
|
|
98089
|
-
let currY =
|
|
98088
|
+
let currY = frame3.padding.top;
|
|
98090
98089
|
for (let r = 0; r < actualRows; r++) {
|
|
98091
98090
|
rowY[r] = currY;
|
|
98092
98091
|
currY += rowH[r] + counterSpacing;
|
|
@@ -98101,10 +98100,10 @@ function applyAutoLayout(doc2) {
|
|
|
98101
98100
|
const cellY = rowY[r];
|
|
98102
98101
|
child.x = cellX;
|
|
98103
98102
|
child.y = cellY;
|
|
98104
|
-
if (
|
|
98103
|
+
if (frame3.counterAxisAlignItems === "CENTER") {
|
|
98105
98104
|
child.x = cellX + (colW[c2] - child.width) / 2;
|
|
98106
98105
|
child.y = cellY + (rowH[r] - child.height) / 2;
|
|
98107
|
-
} else if (
|
|
98106
|
+
} else if (frame3.counterAxisAlignItems === "MAX") {
|
|
98108
98107
|
child.x = cellX + (colW[c2] - child.width);
|
|
98109
98108
|
child.y = cellY + (rowH[r] - child.height);
|
|
98110
98109
|
}
|
|
@@ -98124,34 +98123,34 @@ function applyAutoLayout(doc2) {
|
|
|
98124
98123
|
}
|
|
98125
98124
|
});
|
|
98126
98125
|
const totalSpacing = Math.max(0, childIds.length - 1) * itemSpacing;
|
|
98127
|
-
const availablePrimary = (isHorizontal ?
|
|
98126
|
+
const availablePrimary = (isHorizontal ? frame3.width - paddingX : frame3.height - paddingY) - totalSpacing - usedPrimarySpace;
|
|
98128
98127
|
const fillPrimarySize = fillPrimaryCount > 0 ? Math.max(0, availablePrimary / fillPrimaryCount) : 0;
|
|
98129
98128
|
childIds.forEach((childId) => {
|
|
98130
98129
|
const child = cloneNode(childId);
|
|
98131
98130
|
if (isHorizontal) {
|
|
98132
98131
|
if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(fillPrimarySize, child);
|
|
98133
|
-
if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(Math.max(0,
|
|
98132
|
+
if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(Math.max(0, frame3.height - paddingY), child);
|
|
98134
98133
|
} else {
|
|
98135
98134
|
if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(fillPrimarySize, child);
|
|
98136
|
-
if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(Math.max(0,
|
|
98135
|
+
if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(Math.max(0, frame3.width - paddingX), child);
|
|
98137
98136
|
}
|
|
98138
98137
|
});
|
|
98139
|
-
if (wraps(
|
|
98140
|
-
const lines2 = wrapLines(
|
|
98141
|
-
let counterPos = isHorizontal ?
|
|
98142
|
-
const availPrimaryTotal = isHorizontal ?
|
|
98138
|
+
if (wraps(frame3)) {
|
|
98139
|
+
const lines2 = wrapLines(frame3, childIds, (id3) => ({ intrinsicWidth: newNodes[id3].width, intrinsicHeight: newNodes[id3].height }));
|
|
98140
|
+
let counterPos = isHorizontal ? frame3.padding.top : frame3.padding.left;
|
|
98141
|
+
const availPrimaryTotal = isHorizontal ? frame3.width - paddingX : frame3.height - paddingY;
|
|
98143
98142
|
for (const line of lines2) {
|
|
98144
98143
|
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 ?
|
|
98144
|
+
let primary = isHorizontal ? frame3.padding.left : frame3.padding.top;
|
|
98146
98145
|
let extra = 0;
|
|
98147
98146
|
const free2 = Math.max(0, availPrimaryTotal - used);
|
|
98148
|
-
if (
|
|
98149
|
-
else if (
|
|
98150
|
-
else if (
|
|
98147
|
+
if (frame3.primaryAxisAlignItems === "SPACE_BETWEEN" && line.ids.length > 1) extra = free2 / (line.ids.length - 1);
|
|
98148
|
+
else if (frame3.primaryAxisAlignItems === "CENTER") primary += free2 / 2;
|
|
98149
|
+
else if (frame3.primaryAxisAlignItems === "MAX") primary += free2;
|
|
98151
98150
|
for (const id3 of line.ids) {
|
|
98152
98151
|
const child = newNodes[id3];
|
|
98153
98152
|
const size6 = isHorizontal ? child.height : child.width;
|
|
98154
|
-
const off =
|
|
98153
|
+
const off = frame3.counterAxisAlignItems === "CENTER" ? (line.counter - size6) / 2 : frame3.counterAxisAlignItems === "MAX" ? line.counter - size6 : 0;
|
|
98155
98154
|
if (isHorizontal) {
|
|
98156
98155
|
child.x = primary;
|
|
98157
98156
|
child.y = counterPos + off;
|
|
@@ -98167,13 +98166,13 @@ function applyAutoLayout(doc2) {
|
|
|
98167
98166
|
}
|
|
98168
98167
|
return;
|
|
98169
98168
|
}
|
|
98170
|
-
let currentPrimary = isHorizontal ?
|
|
98169
|
+
let currentPrimary = isHorizontal ? frame3.padding.left : frame3.padding.top;
|
|
98171
98170
|
let extraSpacing = 0;
|
|
98172
|
-
if (
|
|
98171
|
+
if (frame3.primaryAxisAlignItems === "SPACE_BETWEEN" && fillPrimaryCount === 0 && childIds.length > 1) {
|
|
98173
98172
|
extraSpacing = availablePrimary / (childIds.length - 1);
|
|
98174
|
-
} else if (
|
|
98173
|
+
} else if (frame3.primaryAxisAlignItems === "CENTER" && fillPrimaryCount === 0) {
|
|
98175
98174
|
currentPrimary += availablePrimary / 2;
|
|
98176
|
-
} else if (
|
|
98175
|
+
} else if (frame3.primaryAxisAlignItems === "MAX" && fillPrimaryCount === 0) {
|
|
98177
98176
|
currentPrimary += availablePrimary;
|
|
98178
98177
|
}
|
|
98179
98178
|
childIds.forEach((childId) => {
|
|
@@ -98181,22 +98180,22 @@ function applyAutoLayout(doc2) {
|
|
|
98181
98180
|
if (isHorizontal) {
|
|
98182
98181
|
child.x = currentPrimary;
|
|
98183
98182
|
currentPrimary += child.width + itemSpacing + extraSpacing;
|
|
98184
|
-
if (
|
|
98185
|
-
child.y =
|
|
98186
|
-
} else if (
|
|
98187
|
-
child.y =
|
|
98183
|
+
if (frame3.counterAxisAlignItems === "CENTER") {
|
|
98184
|
+
child.y = frame3.padding.top + (frame3.height - paddingY - child.height) / 2;
|
|
98185
|
+
} else if (frame3.counterAxisAlignItems === "MAX") {
|
|
98186
|
+
child.y = frame3.height - frame3.padding.bottom - child.height;
|
|
98188
98187
|
} else {
|
|
98189
|
-
child.y =
|
|
98188
|
+
child.y = frame3.padding.top;
|
|
98190
98189
|
}
|
|
98191
98190
|
} else {
|
|
98192
98191
|
child.y = currentPrimary;
|
|
98193
98192
|
currentPrimary += child.height + itemSpacing + extraSpacing;
|
|
98194
|
-
if (
|
|
98195
|
-
child.x =
|
|
98196
|
-
} else if (
|
|
98197
|
-
child.x =
|
|
98193
|
+
if (frame3.counterAxisAlignItems === "CENTER") {
|
|
98194
|
+
child.x = frame3.padding.left + (frame3.width - paddingX - child.width) / 2;
|
|
98195
|
+
} else if (frame3.counterAxisAlignItems === "MAX") {
|
|
98196
|
+
child.x = frame3.width - frame3.padding.right - child.width;
|
|
98198
98197
|
} else {
|
|
98199
|
-
child.x =
|
|
98198
|
+
child.x = frame3.padding.left;
|
|
98200
98199
|
}
|
|
98201
98200
|
}
|
|
98202
98201
|
layoutNode(childId);
|
|
@@ -98216,27 +98215,27 @@ function applyAutoLayout(doc2) {
|
|
|
98216
98215
|
}
|
|
98217
98216
|
return { ...doc2, nodes: newNodes };
|
|
98218
98217
|
}
|
|
98219
|
-
function wraps(
|
|
98220
|
-
if (
|
|
98221
|
-
return
|
|
98218
|
+
function wraps(frame3) {
|
|
98219
|
+
if (frame3.layoutWrap !== "WRAP" || frame3.layoutMode === "GRID") return false;
|
|
98220
|
+
return frame3.layoutMode === "HORIZONTAL" ? frame3.layoutSizingHorizontal !== "HUG" : frame3.layoutSizingVertical !== "HUG";
|
|
98222
98221
|
}
|
|
98223
|
-
function wrapLines(
|
|
98224
|
-
const isHorizontal =
|
|
98225
|
-
const avail = isHorizontal ?
|
|
98222
|
+
function wrapLines(frame3, childIds, size6) {
|
|
98223
|
+
const isHorizontal = frame3.layoutMode === "HORIZONTAL";
|
|
98224
|
+
const avail = isHorizontal ? frame3.width - frame3.padding.left - frame3.padding.right : frame3.height - frame3.padding.top - frame3.padding.bottom;
|
|
98226
98225
|
const lines2 = [];
|
|
98227
98226
|
let cur = { ids: [], counter: 0 }, used = 0;
|
|
98228
98227
|
for (const id3 of childIds) {
|
|
98229
98228
|
const sz = size6(id3);
|
|
98230
98229
|
const primary = isHorizontal ? sz.intrinsicWidth : sz.intrinsicHeight;
|
|
98231
98230
|
const counter = isHorizontal ? sz.intrinsicHeight : sz.intrinsicWidth;
|
|
98232
|
-
const needed = cur.ids.length ? used +
|
|
98231
|
+
const needed = cur.ids.length ? used + frame3.itemSpacing + primary : primary;
|
|
98233
98232
|
if (cur.ids.length && needed > avail + 1e-3) {
|
|
98234
98233
|
lines2.push(cur);
|
|
98235
98234
|
cur = { ids: [], counter: 0 };
|
|
98236
98235
|
used = 0;
|
|
98237
98236
|
}
|
|
98238
98237
|
cur.ids.push(id3);
|
|
98239
|
-
used = cur.ids.length === 1 ? primary : used +
|
|
98238
|
+
used = cur.ids.length === 1 ? primary : used + frame3.itemSpacing + primary;
|
|
98240
98239
|
cur.counter = Math.max(cur.counter, counter);
|
|
98241
98240
|
}
|
|
98242
98241
|
if (cur.ids.length) lines2.push(cur);
|
|
@@ -98778,10 +98777,10 @@ function scaleTree(nodes, id3, s, isRoot) {
|
|
|
98778
98777
|
if (!n) return;
|
|
98779
98778
|
if (!isRoot) {
|
|
98780
98779
|
const t3 = n;
|
|
98781
|
-
const
|
|
98782
|
-
if (typeof t3.fontSize === "number")
|
|
98783
|
-
if (typeof t3.cornerRadius === "number")
|
|
98784
|
-
nodes[id3] = { ...n, ...
|
|
98780
|
+
const patch2 = { x: n.x * s, y: n.y * s, width: n.width * s, height: n.height * s };
|
|
98781
|
+
if (typeof t3.fontSize === "number") patch2.fontSize = Math.max(12, t3.fontSize * s);
|
|
98782
|
+
if (typeof t3.cornerRadius === "number") patch2.cornerRadius = t3.cornerRadius * s;
|
|
98783
|
+
nodes[id3] = { ...n, ...patch2 };
|
|
98785
98784
|
}
|
|
98786
98785
|
for (const c2 of n.childIds) scaleTree(nodes, c2, s, false);
|
|
98787
98786
|
}
|
|
@@ -100040,11 +100039,11 @@ function addAudioClip(comp, o) {
|
|
|
100040
100039
|
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
100040
|
return { composition: withAudio(comp, placeAudio(audio, clip)), id: id3 };
|
|
100042
100041
|
}
|
|
100043
|
-
function editAudioClip(comp, id3,
|
|
100042
|
+
function editAudioClip(comp, id3, patch2) {
|
|
100044
100043
|
const audio = comp.audio ?? [];
|
|
100045
100044
|
const cur = audio.find((c2) => c2.id === id3);
|
|
100046
100045
|
if (!cur) return comp;
|
|
100047
|
-
const next2 = { ...cur, ...
|
|
100046
|
+
const next2 = { ...cur, ...patch2 };
|
|
100048
100047
|
next2.start = Math.max(0, Math.round(next2.start));
|
|
100049
100048
|
next2.in = Math.max(0, Math.round(next2.in));
|
|
100050
100049
|
next2.out = Math.max(next2.in + 1, Math.round(next2.out));
|
|
@@ -100487,7 +100486,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100487
100486
|
const outer = linkNodes;
|
|
100488
100487
|
if (nodes) linkNodes = nodes;
|
|
100489
100488
|
let posed2 = node2;
|
|
100490
|
-
let
|
|
100489
|
+
let patch2 = null;
|
|
100491
100490
|
let values3 = inputs ? inputs.values : null;
|
|
100492
100491
|
try {
|
|
100493
100492
|
for (const key5 in tracks) {
|
|
@@ -100518,7 +100517,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100518
100517
|
if (prop.valueType === "color") posed2 = unbindItemColor(posed2, path);
|
|
100519
100518
|
continue;
|
|
100520
100519
|
}
|
|
100521
|
-
if (prop.field) (
|
|
100520
|
+
if (prop.field) (patch2 ??= {})[prop.field] = v;
|
|
100522
100521
|
else posed2 = prop.valueType === "color" ? unbindItemColor(prop.write(posed2, path, v), path) : prop.write(posed2, path, v);
|
|
100523
100522
|
}
|
|
100524
100523
|
for (const pair of PAIRS) {
|
|
@@ -100526,7 +100525,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100526
100525
|
if (!tx2 || inputs && (isInputPath(node2, pair[0], inputs.set) || isInputPath(node2, pair[1], inputs.set)) || hasBinding2(tx2) || ty && hasBinding2(ty)) continue;
|
|
100527
100526
|
const d = spatialDelta(tx2, ty, t3);
|
|
100528
100527
|
if (!d) continue;
|
|
100529
|
-
const p2 =
|
|
100528
|
+
const p2 = patch2 ??= {};
|
|
100530
100529
|
for (let axis = 0; axis < 2; axis++) {
|
|
100531
100530
|
const f2 = pair[axis];
|
|
100532
100531
|
const cur = f2 in p2 ? p2[f2] : propertyFor(f2)?.read(node2, f2);
|
|
@@ -100536,7 +100535,7 @@ function sampleNode(node2, t3, nodes, inputs) {
|
|
|
100536
100535
|
} finally {
|
|
100537
100536
|
linkNodes = outer;
|
|
100538
100537
|
}
|
|
100539
|
-
return
|
|
100538
|
+
return patch2 ? { ...posed2, ...patch2 } : posed2;
|
|
100540
100539
|
}
|
|
100541
100540
|
function motionNodes(nodes, rootId) {
|
|
100542
100541
|
let memo5 = motionMemo.get(nodes);
|
|
@@ -100662,7 +100661,7 @@ var init_layer_time_edit = __esm({
|
|
|
100662
100661
|
"lib/motion/layer-time-edit.ts"() {
|
|
100663
100662
|
"use strict";
|
|
100664
100663
|
init_time();
|
|
100665
|
-
withMotion = (motion,
|
|
100664
|
+
withMotion = (motion, patch2) => ({ tracks: {}, ...motion, ...patch2 });
|
|
100666
100665
|
}
|
|
100667
100666
|
});
|
|
100668
100667
|
|
|
@@ -100677,12 +100676,12 @@ function videoClipOf(nodes, id3, frameId, duration3) {
|
|
|
100677
100676
|
const speed = clampSpeed(paint.videoSpeed);
|
|
100678
100677
|
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
100678
|
}
|
|
100680
|
-
function withVideoPaint(node2, index2,
|
|
100679
|
+
function withVideoPaint(node2, index2, patch2) {
|
|
100681
100680
|
const fills = fillsOf(node2);
|
|
100682
100681
|
const cur = fills[index2];
|
|
100683
100682
|
if (!cur) return node2;
|
|
100684
|
-
const next2 = { ...cur, ...
|
|
100685
|
-
for (const k2 of Object.keys(
|
|
100683
|
+
const next2 = { ...cur, ...patch2 };
|
|
100684
|
+
for (const k2 of Object.keys(patch2)) if (next2[k2] === void 0) delete next2[k2];
|
|
100686
100685
|
if (Object.keys(next2).every((k2) => next2[k2] === cur[k2]) && Object.keys(next2).length === Object.keys(cur).length) return node2;
|
|
100687
100686
|
return { ...node2, fills: fills.map((f2, i2) => i2 === index2 ? next2 : f2) };
|
|
100688
100687
|
}
|
|
@@ -101606,16 +101605,16 @@ function resolveTextNodeStyles(node2, styles) {
|
|
|
101606
101605
|
if (paragraphs) out.paragraphs = paragraphs;
|
|
101607
101606
|
return out;
|
|
101608
101607
|
}
|
|
101609
|
-
function withParagraphFormat(node2, range3,
|
|
101608
|
+
function withParagraphFormat(node2, range3, patch2) {
|
|
101610
101609
|
const ranges = paragraphRanges(node2.characters || "");
|
|
101611
101610
|
const targets = range3 && range3.end > range3.start ? ranges.filter((r) => r.start <= range3.end && r.end >= range3.start) : ranges;
|
|
101612
101611
|
const existing = new Map((node2.paragraphs ?? []).map((p2) => [p2.start, p2]));
|
|
101613
101612
|
for (const r of targets) {
|
|
101614
101613
|
const cur = existing.get(r.start) ?? { start: r.start };
|
|
101615
101614
|
const next2 = { ...cur };
|
|
101616
|
-
for (const k2 of Object.keys(
|
|
101617
|
-
if (
|
|
101618
|
-
else next2[k2] =
|
|
101615
|
+
for (const k2 of Object.keys(patch2)) {
|
|
101616
|
+
if (patch2[k2] === void 0) delete next2[k2];
|
|
101617
|
+
else next2[k2] = patch2[k2];
|
|
101619
101618
|
}
|
|
101620
101619
|
existing.set(r.start, next2);
|
|
101621
101620
|
}
|
|
@@ -244639,6 +244638,23 @@ function trackLoad(p2) {
|
|
|
244639
244638
|
p2.then(done, done);
|
|
244640
244639
|
return p2;
|
|
244641
244640
|
}
|
|
244641
|
+
function loadsSettled(timeoutMs = 1e4) {
|
|
244642
|
+
return new Promise((resolve7) => {
|
|
244643
|
+
let timer = null;
|
|
244644
|
+
const finish3 = (ok2) => {
|
|
244645
|
+
waiters.delete(onIdle);
|
|
244646
|
+
if (timer) clearTimeout(timer);
|
|
244647
|
+
setTimeout(() => resolve7(ok2), 0);
|
|
244648
|
+
};
|
|
244649
|
+
const onIdle = () => finish3(true);
|
|
244650
|
+
if (inflight === 0) {
|
|
244651
|
+
finish3(true);
|
|
244652
|
+
return;
|
|
244653
|
+
}
|
|
244654
|
+
waiters.add(onIdle);
|
|
244655
|
+
timer = setTimeout(() => finish3(false), timeoutMs);
|
|
244656
|
+
});
|
|
244657
|
+
}
|
|
244642
244658
|
var inflight, waiters;
|
|
244643
244659
|
var init_readiness = __esm({
|
|
244644
244660
|
"lib/engine/readiness.ts"() {
|
|
@@ -246900,9 +246916,9 @@ function rescaleTextEffect(node2) {
|
|
|
246900
246916
|
const preset = node2.textEffectPreset;
|
|
246901
246917
|
const at4 = node2.textEffectSize;
|
|
246902
246918
|
if (!preset || !DEFAULTS[preset] || !at4 || at4 === node2.fontSize) return null;
|
|
246903
|
-
const
|
|
246904
|
-
if (preset !== "HOLLOW") delete
|
|
246905
|
-
return
|
|
246919
|
+
const patch2 = textEffectPatch(node2, preset);
|
|
246920
|
+
if (preset !== "HOLLOW") delete patch2.fills;
|
|
246921
|
+
return patch2;
|
|
246906
246922
|
}
|
|
246907
246923
|
var DEFAULTS, BLACK5, WHITE5, fillPaint, fillColor, shadow, round, OUTLINED;
|
|
246908
246924
|
var init_effect_presets = __esm({
|
|
@@ -246943,12 +246959,12 @@ function addMarker(tl, t3, label3) {
|
|
|
246943
246959
|
const marker = { id: id3, t: at4, ...label3 ? { label: label3 } : {} };
|
|
246944
246960
|
return { timeline: withMarkers(tl, sortMarkers([...markers, marker])), id: id3 };
|
|
246945
246961
|
}
|
|
246946
|
-
function updateMarker(tl, id3,
|
|
246962
|
+
function updateMarker(tl, id3, patch2) {
|
|
246947
246963
|
const markers = tl.markers ?? [];
|
|
246948
246964
|
const i2 = markers.findIndex((m2) => m2.id === id3);
|
|
246949
246965
|
if (i2 < 0) return tl;
|
|
246950
|
-
const m = { ...markers[i2], ...
|
|
246951
|
-
if (
|
|
246966
|
+
const m = { ...markers[i2], ...patch2 };
|
|
246967
|
+
if (patch2.t !== void 0) m.t = Math.max(0, Math.round(patch2.t));
|
|
246952
246968
|
if (!m.label) delete m.label;
|
|
246953
246969
|
if (m.kind === "marker" || m.kind === void 0) delete m.kind;
|
|
246954
246970
|
const was = markers[i2];
|
|
@@ -247888,7 +247904,6 @@ function repairCompositions(comps, nodes) {
|
|
|
247888
247904
|
var isObj5, finite6, optFinite, isVec2, TIMELINE_COLOR_IDS, TIMELINE_COLORS, UNITS, ORDERS, PROP_KEYS, ANIMATOR_ID, MOTION_TYPES, TRANSITIONS, isFraction, MEDIA_HASH;
|
|
247889
247905
|
var init_invariants = __esm({
|
|
247890
247906
|
"lib/motion/invariants.ts"() {
|
|
247891
|
-
"use strict";
|
|
247892
247907
|
init_easing();
|
|
247893
247908
|
init_properties();
|
|
247894
247909
|
init_markers();
|
|
@@ -247937,8 +247952,8 @@ function applyInvariants(doc2, touched) {
|
|
|
247937
247952
|
function rescaleTextEffects(doc2, id3) {
|
|
247938
247953
|
const n = doc2.nodes[id3];
|
|
247939
247954
|
if (!n || n.type !== "TEXT") return doc2;
|
|
247940
|
-
const
|
|
247941
|
-
return
|
|
247955
|
+
const patch2 = rescaleTextEffect(n);
|
|
247956
|
+
return patch2 ? updateNode(doc2, id3, patch2) : doc2;
|
|
247942
247957
|
}
|
|
247943
247958
|
function repairDocumentCompositions(doc2) {
|
|
247944
247959
|
const comps = repairCompositions(doc2.compositions, doc2.nodes);
|
|
@@ -248593,9 +248608,9 @@ function writeSoundtrack(doc2, sound) {
|
|
|
248593
248608
|
const compositions = { ...doc2.compositions, [built.composition.id]: built.composition };
|
|
248594
248609
|
return repairDocumentCompositions({ ...doc2, compositions });
|
|
248595
248610
|
}
|
|
248596
|
-
function configure(doc2, pageId2,
|
|
248611
|
+
function configure(doc2, pageId2, patch2) {
|
|
248597
248612
|
const sound = soundOf(doc2, pageId2);
|
|
248598
|
-
return writeSoundtrack(doc2, { ...sound, settings: repairSettings({ ...sound.settings, ...
|
|
248613
|
+
return writeSoundtrack(doc2, { ...sound, settings: repairSettings({ ...sound.settings, ...patch2 }) });
|
|
248599
248614
|
}
|
|
248600
248615
|
function retime(doc2, pageId2, o = {}) {
|
|
248601
248616
|
const sound = soundOf(doc2, pageId2);
|
|
@@ -252420,7 +252435,6 @@ function resizeWindow(doc2, target2, rect) {
|
|
|
252420
252435
|
}
|
|
252421
252436
|
var init_crop = __esm({
|
|
252422
252437
|
"lib/editor/crop.ts"() {
|
|
252423
|
-
"use strict";
|
|
252424
252438
|
init_dist_node();
|
|
252425
252439
|
init_scene_graph();
|
|
252426
252440
|
init_photo_frames();
|
|
@@ -253179,8 +253193,8 @@ async function bakeStroke(dabs, color4, opacity, hardness, wetMix = 0, backdrop,
|
|
|
253179
253193
|
scale = Math.min(scale, Math.sqrt(MAX_STROKE_PIXELS / (worldW * worldH)));
|
|
253180
253194
|
const pxW = Math.max(1, Math.round(worldW * scale));
|
|
253181
253195
|
const pxH = Math.max(1, Math.round(worldH * scale));
|
|
253182
|
-
const
|
|
253183
|
-
const batch = packDabs(dabs,
|
|
253196
|
+
const frame3 = { cx: minX + worldW / 2, cy: minY + worldH / 2, rotationRad: 0, flipX: false, flipY: false, width: worldW, height: worldH, pixelWidth: pxW, pixelHeight: pxH };
|
|
253197
|
+
const batch = packDabs(dabs, frame3, { color: color4, alpha: Math.max(0, Math.min(1, opacity)), hardness, tip, stamp: !!stamp, secondaryColor });
|
|
253184
253198
|
const grainTile = grain && grain.depth > 0 ? grain.image ?? getGrainTile(grain.type) : null;
|
|
253185
253199
|
const wet = backdrop && !stamp ? Math.max(0, Math.min(1, wetMix)) : 0;
|
|
253186
253200
|
const pixels = await layers2.bake(pxW, pxH, batch, {
|
|
@@ -253237,9 +253251,9 @@ function worldToLayer(f2, wx, wy) {
|
|
|
253237
253251
|
function layerDensity(f2) {
|
|
253238
253252
|
return f2.pixelWidth / Math.max(1e-6, f2.width);
|
|
253239
253253
|
}
|
|
253240
|
-
function packDabs(dabs,
|
|
253254
|
+
function packDabs(dabs, frame3, paint, prev) {
|
|
253241
253255
|
const data = new Float32Array(dabs.length * DAB_STRIDE);
|
|
253242
|
-
const k2 = layerDensity(
|
|
253256
|
+
const k2 = layerDensity(frame3);
|
|
253243
253257
|
const base = paint.color;
|
|
253244
253258
|
const baseHsl = rgbToHsl(base.r ?? 0, base.g ?? 0, base.b ?? 0);
|
|
253245
253259
|
const sec = paint.secondaryColor;
|
|
@@ -253247,7 +253261,7 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253247
253261
|
let n = 0;
|
|
253248
253262
|
let last3 = prev ?? null;
|
|
253249
253263
|
for (const d of dabs) {
|
|
253250
|
-
const p2 = worldToLayer(
|
|
253264
|
+
const p2 = worldToLayer(frame3, d.cx, d.cy);
|
|
253251
253265
|
const round5 = Math.max(0.1, d.roundness ?? 1);
|
|
253252
253266
|
let rx = d.r * k2, ry = d.r * round5 * k2;
|
|
253253
253267
|
let mode = 0;
|
|
@@ -253263,14 +253277,14 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253263
253277
|
mode = 1;
|
|
253264
253278
|
ry *= 0.5;
|
|
253265
253279
|
}
|
|
253266
|
-
const angle2 = d.angle -
|
|
253280
|
+
const angle2 = d.angle - frame3.rotationRad;
|
|
253267
253281
|
const o = n * DAB_STRIDE;
|
|
253268
253282
|
data[o] = p2.x;
|
|
253269
253283
|
data[o + 1] = p2.y;
|
|
253270
253284
|
data[o + 2] = rx;
|
|
253271
253285
|
data[o + 3] = ry;
|
|
253272
253286
|
data[o + 12] = d.charge ?? 1;
|
|
253273
|
-
data[o + 13] = (d.travel ?? 0) -
|
|
253287
|
+
data[o + 13] = (d.travel ?? 0) - frame3.rotationRad;
|
|
253274
253288
|
data[o + 4] = angle2;
|
|
253275
253289
|
data[o + 5] = (paint.smudgeStrength !== void 0 || paint.liquify) && mode === 0 ? 0.6 : d.hardness ?? paint.hardness;
|
|
253276
253290
|
data[o + 6] = mode;
|
|
@@ -253283,7 +253297,7 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253283
253297
|
last3 = d;
|
|
253284
253298
|
continue;
|
|
253285
253299
|
}
|
|
253286
|
-
const q = worldToLayer(
|
|
253300
|
+
const q = worldToLayer(frame3, last3.cx, last3.cy);
|
|
253287
253301
|
last3 = d;
|
|
253288
253302
|
data[o + 8] = p2.x - q.x;
|
|
253289
253303
|
data[o + 9] = p2.y - q.y;
|
|
@@ -253294,7 +253308,7 @@ function packDabs(dabs, frame2, paint, prev) {
|
|
|
253294
253308
|
last3 = d;
|
|
253295
253309
|
continue;
|
|
253296
253310
|
}
|
|
253297
|
-
const q = worldToLayer(
|
|
253311
|
+
const q = worldToLayer(frame3, last3.cx, last3.cy);
|
|
253298
253312
|
last3 = d;
|
|
253299
253313
|
data[o + 8] = p2.x - q.x;
|
|
253300
253314
|
data[o + 9] = p2.y - q.y;
|
|
@@ -253379,8 +253393,8 @@ function imageEditGroupOf(nodes, nodeId2) {
|
|
|
253379
253393
|
function wrapTargetFor(doc2, nodeId2) {
|
|
253380
253394
|
const node2 = doc2.nodes[nodeId2];
|
|
253381
253395
|
if (!node2) return null;
|
|
253382
|
-
const
|
|
253383
|
-
return
|
|
253396
|
+
const frame3 = photoFrameOf(doc2.nodes, nodeId2);
|
|
253397
|
+
return frame3 ? frame3.id : nodeId2;
|
|
253384
253398
|
}
|
|
253385
253399
|
function prepareImageEdit(doc2, nodeId2) {
|
|
253386
253400
|
const existing = imageEditGroupOf(doc2.nodes, nodeId2);
|
|
@@ -253940,8 +253954,8 @@ function createDrawPaletteSlice(set4, get4) {
|
|
|
253940
253954
|
commit([...palette2(), tool2], "Add to palette", { activeDrawToolId: tool2.id, editingDrawToolId: tool2.id });
|
|
253941
253955
|
return tool2.id;
|
|
253942
253956
|
},
|
|
253943
|
-
updateDrawTool: (id3,
|
|
253944
|
-
const next2 = palette2().map((t3) => t3.id === id3 ? { ...t3, ...
|
|
253957
|
+
updateDrawTool: (id3, patch2) => {
|
|
253958
|
+
const next2 = palette2().map((t3) => t3.id === id3 ? { ...t3, ...patch2 } : t3);
|
|
253945
253959
|
commit(next2, "Edit palette");
|
|
253946
253960
|
},
|
|
253947
253961
|
removeDrawTool: (id3) => {
|
|
@@ -254308,17 +254322,17 @@ function createModeSlice(set4, get4) {
|
|
|
254308
254322
|
saveTabSides(tabSides);
|
|
254309
254323
|
const from2 = side === "left" ? "right" : "left";
|
|
254310
254324
|
const fromKey = from2 === "left" ? "leftTab" : "rightTab";
|
|
254311
|
-
const
|
|
254325
|
+
const patch2 = { tabSides, tabOrder };
|
|
254312
254326
|
if (state[fromKey] === tab) {
|
|
254313
254327
|
const next2 = tabsOn(tabSides, from2, tabOrder).find((t3) => !ACTION_TABS.has(t3));
|
|
254314
|
-
if (next2)
|
|
254315
|
-
else
|
|
254328
|
+
if (next2) patch2[fromKey] = next2;
|
|
254329
|
+
else patch2[from2 === "left" ? "leftPanelOpen" : "rightPanelOpen"] = false;
|
|
254316
254330
|
}
|
|
254317
254331
|
if (!action3) {
|
|
254318
|
-
|
|
254319
|
-
|
|
254332
|
+
patch2[side === "left" ? "leftTab" : "rightTab"] = tab;
|
|
254333
|
+
patch2[side === "left" ? "leftPanelOpen" : "rightPanelOpen"] = true;
|
|
254320
254334
|
}
|
|
254321
|
-
set4(
|
|
254335
|
+
set4(patch2);
|
|
254322
254336
|
},
|
|
254323
254337
|
setStageView: (on, mode) => {
|
|
254324
254338
|
const state = get4();
|
|
@@ -254472,24 +254486,24 @@ var init_pixel_layers = __esm({
|
|
|
254472
254486
|
});
|
|
254473
254487
|
|
|
254474
254488
|
// lib/engine/pixel/pixel-texture.ts
|
|
254475
|
-
function setWorkingPixels(nodeId2,
|
|
254489
|
+
function setWorkingPixels(nodeId2, frame3, rgba, version7 = 0) {
|
|
254476
254490
|
if (!rgba) working.delete(nodeId2);
|
|
254477
|
-
else working.set(nodeId2, { frame:
|
|
254491
|
+
else working.set(nodeId2, { frame: frame3, rgba, version: version7 });
|
|
254478
254492
|
if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-render"));
|
|
254479
254493
|
}
|
|
254480
254494
|
function frameRGBA(node2, frameIndex) {
|
|
254481
|
-
const
|
|
254495
|
+
const frame3 = node2.frames[Math.max(0, Math.min(node2.frames.length - 1, frameIndex))];
|
|
254482
254496
|
const w = node2.pixelWidth, h = node2.pixelHeight;
|
|
254483
|
-
if (!
|
|
254484
|
-
const key5 = [
|
|
254485
|
-
const holder =
|
|
254497
|
+
if (!frame3) return new Uint32Array(w * h);
|
|
254498
|
+
const key5 = [frame3.cels, node2.palette, node2.colorMode, node2.transparentIndex, node2.tileset, w, h];
|
|
254499
|
+
const holder = frame3;
|
|
254486
254500
|
const hit = rgbaCache.get(holder);
|
|
254487
254501
|
if (hit && hit.key.length === key5.length && hit.key.every((k2, i2) => k2 === key5[i2])) return hit.rgba;
|
|
254488
254502
|
let rgba;
|
|
254489
254503
|
if (node2.tileset) {
|
|
254490
254504
|
const { tileW, tileH, tiles } = node2.tileset;
|
|
254491
254505
|
const cols = Math.max(1, Math.floor(w / tileW)), rows = Math.max(1, Math.floor(h / tileH));
|
|
254492
|
-
const map2 = decodeCels(
|
|
254506
|
+
const map2 = decodeCels(frame3.cels, cols * rows);
|
|
254493
254507
|
rgba = new Uint32Array(w * h);
|
|
254494
254508
|
const tileRGBA = tiles.map((t3) => celsToRGBA(decodeCels(t3, tileW * tileH), node2.colorMode, node2.palette, node2.transparentIndex));
|
|
254495
254509
|
for (let ty = 0; ty < rows; ty++) for (let tx2 = 0; tx2 < cols; tx2++) {
|
|
@@ -254502,7 +254516,7 @@ function frameRGBA(node2, frameIndex) {
|
|
|
254502
254516
|
}
|
|
254503
254517
|
}
|
|
254504
254518
|
} else {
|
|
254505
|
-
rgba = celsToRGBA(decodeCels(
|
|
254519
|
+
rgba = celsToRGBA(decodeCels(frame3.cels, w * h), node2.colorMode, node2.palette, node2.transparentIndex);
|
|
254506
254520
|
}
|
|
254507
254521
|
rgbaCache.set(holder, { key: key5, rgba });
|
|
254508
254522
|
return rgba;
|
|
@@ -254510,8 +254524,8 @@ function frameRGBA(node2, frameIndex) {
|
|
|
254510
254524
|
function setPixelEditingNode(id3) {
|
|
254511
254525
|
editingNodeId = id3;
|
|
254512
254526
|
}
|
|
254513
|
-
function setPixelPreviewFrame(nodeId2,
|
|
254514
|
-
previewFrame = nodeId2 ? { nodeId: nodeId2, frame:
|
|
254527
|
+
function setPixelPreviewFrame(nodeId2, frame3 = 0) {
|
|
254528
|
+
previewFrame = nodeId2 ? { nodeId: nodeId2, frame: frame3 } : null;
|
|
254515
254529
|
if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-render"));
|
|
254516
254530
|
}
|
|
254517
254531
|
var working, rgbaCache, editingNodeId, previewFrame;
|
|
@@ -254636,14 +254650,14 @@ function createPixelSlice(set4, get4) {
|
|
|
254636
254650
|
const empty2 = new Uint32Array(count2);
|
|
254637
254651
|
if (n.tileset) empty2.fill(EMPTY_INDEX);
|
|
254638
254652
|
else if (n.colorMode === "INDEXED") empty2.fill(n.transparentIndex);
|
|
254639
|
-
const
|
|
254640
|
-
const frames = [...n.frames.slice(0, at4),
|
|
254653
|
+
const frame3 = { id: v4_default(), cels: opts.duplicate && src ? src.cels : encodeCels(empty2), duration: src?.duration ?? 100 };
|
|
254654
|
+
const frames = [...n.frames.slice(0, at4), frame3, ...n.frames.slice(at4)];
|
|
254641
254655
|
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
254656
|
let doc2 = updateNode(get4().document, id3, { frames, tags, activeFrame: at4 });
|
|
254643
254657
|
if (opts.duplicate && src) {
|
|
254644
254658
|
for (const l of layersOf(doc2, n)) {
|
|
254645
254659
|
const ids2 = frameIdsOf(l);
|
|
254646
|
-
if (ids2 && ids2.includes(src.id)) doc2 = updateNode(doc2, l.id, { pixelFrameIds: [...ids2,
|
|
254660
|
+
if (ids2 && ids2.includes(src.id)) doc2 = updateNode(doc2, l.id, { pixelFrameIds: [...ids2, frame3.id] });
|
|
254647
254661
|
}
|
|
254648
254662
|
}
|
|
254649
254663
|
commitDoc(doc2, opts.duplicate ? "Duplicate frame" : "New frame");
|
|
@@ -254687,10 +254701,10 @@ function createPixelSlice(set4, get4) {
|
|
|
254687
254701
|
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
254702
|
commit(id3, { tags: [...n.tags, tag2] }, "Add tag");
|
|
254689
254703
|
},
|
|
254690
|
-
pixelUpdateTag: (id3, tagId,
|
|
254704
|
+
pixelUpdateTag: (id3, tagId, patch2) => {
|
|
254691
254705
|
const n = node2(id3);
|
|
254692
254706
|
if (!n) return;
|
|
254693
|
-
commit(id3, { tags: n.tags.map((t3) => t3.id === tagId ? { ...t3, ...
|
|
254707
|
+
commit(id3, { tags: n.tags.map((t3) => t3.id === tagId ? { ...t3, ...patch2 } : t3) }, "Edit tag");
|
|
254694
254708
|
},
|
|
254695
254709
|
pixelDeleteTag: (id3, tagId) => {
|
|
254696
254710
|
const n = node2(id3);
|
|
@@ -254698,9 +254712,9 @@ function createPixelSlice(set4, get4) {
|
|
|
254698
254712
|
commit(id3, { tags: n.tags.filter((t3) => t3.id !== tagId) }, "Delete tag");
|
|
254699
254713
|
},
|
|
254700
254714
|
/** Generic pixel-node property change (onion skin, tiled mode, reference…) as one undo step. */
|
|
254701
|
-
pixelUpdate: (id3,
|
|
254715
|
+
pixelUpdate: (id3, patch2, description = "Pixel canvas settings") => {
|
|
254702
254716
|
if (!node2(id3)) return;
|
|
254703
|
-
commit(id3,
|
|
254717
|
+
commit(id3, patch2, description);
|
|
254704
254718
|
},
|
|
254705
254719
|
/**
|
|
254706
254720
|
* Bake layers into pixels as one undo step. Default: the active frame — its layers are merged into its
|
|
@@ -254827,14 +254841,14 @@ function createPixelSlice(set4, get4) {
|
|
|
254827
254841
|
palette2 = extractPalette(all4, 256).map(packedToHex);
|
|
254828
254842
|
}
|
|
254829
254843
|
const conv = (b64, cellCount) => encodeCels(convertCels(decodeCels(b64, cellCount), n.colorMode, mode, n.palette, palette2, n.transparentIndex));
|
|
254830
|
-
const
|
|
254844
|
+
const patch2 = { colorMode: mode, palette: palette2 };
|
|
254831
254845
|
if (n.tileset) {
|
|
254832
254846
|
const tc = n.tileset.tileW * n.tileset.tileH;
|
|
254833
|
-
|
|
254847
|
+
patch2.tileset = { ...n.tileset, tiles: n.tileset.tiles.map((t3) => conv(t3, tc)) };
|
|
254834
254848
|
} else {
|
|
254835
|
-
|
|
254849
|
+
patch2.frames = n.frames.map((f2) => ({ ...f2, cels: conv(f2.cels, count2) }));
|
|
254836
254850
|
}
|
|
254837
|
-
commit(id3,
|
|
254851
|
+
commit(id3, patch2, `Color mode: ${mode.toLowerCase()}`);
|
|
254838
254852
|
},
|
|
254839
254853
|
/** Dedupe the canvas into a tileset + per-frame tile maps (Aseprite "convert to tilemap"). */
|
|
254840
254854
|
pixelConvertToTilemap: (id3, tileW, tileH) => {
|
|
@@ -256301,20 +256315,20 @@ function createWashiTape(a, b, styleId, edge = "SPIKY", width = 32, seed2 = Date
|
|
|
256301
256315
|
...{ washiStyle: style.id, washiEdge: edge, washiSeed: shortSeed }
|
|
256302
256316
|
});
|
|
256303
256317
|
}
|
|
256304
|
-
function restyleWashiTape(node2,
|
|
256318
|
+
function restyleWashiTape(node2, patch2) {
|
|
256305
256319
|
const n = node2;
|
|
256306
256320
|
if (!n.washiStyle) return node2;
|
|
256307
|
-
const style = washiStyle(
|
|
256308
|
-
const edge =
|
|
256321
|
+
const style = washiStyle(patch2.styleId ?? n.washiStyle);
|
|
256322
|
+
const edge = patch2.edge ?? n.washiEdge ?? "SPIKY";
|
|
256309
256323
|
const seed2 = n.washiSeed ?? 1;
|
|
256310
256324
|
return {
|
|
256311
256325
|
...n,
|
|
256312
|
-
name:
|
|
256326
|
+
name: patch2.styleId ? `Washi tape \xB7 ${style.label}` : n.name,
|
|
256313
256327
|
washiStyle: style.id,
|
|
256314
256328
|
washiEdge: edge,
|
|
256315
256329
|
washiSeed: seed2,
|
|
256316
256330
|
paths: [{ closed: true, points: washiOutline(n.width, n.height, seed2, edge) }],
|
|
256317
|
-
fills:
|
|
256331
|
+
fills: patch2.styleId ? [washiFill(style, n.height, seed2)] : n.fills
|
|
256318
256332
|
};
|
|
256319
256333
|
}
|
|
256320
256334
|
var PLAIN, PATTERNED, WASHI_TAPES, washiStyle;
|
|
@@ -256535,21 +256549,24 @@ function freshIdMap(t3) {
|
|
|
256535
256549
|
return map2;
|
|
256536
256550
|
}
|
|
256537
256551
|
function addTree(document2, t3, map2, rootId, parentId, ox, oy) {
|
|
256538
|
-
const
|
|
256552
|
+
const parent = document2.nodes[parentId];
|
|
256553
|
+
if (!parent || !t3.payload.nodes[rootId]) return document2;
|
|
256554
|
+
const nodes = { ...document2.nodes };
|
|
256555
|
+
const walk4 = (id3, parent2, isRoot) => {
|
|
256539
256556
|
const src = t3.payload.nodes[id3];
|
|
256540
256557
|
if (!src) return;
|
|
256541
|
-
const n = rewriteIds(
|
|
256542
|
-
const kids = src.childIds ?? [];
|
|
256543
|
-
n.childIds = [];
|
|
256558
|
+
const n = rewriteIds(src, map2);
|
|
256544
256559
|
if (isRoot) {
|
|
256545
256560
|
n.x += ox;
|
|
256546
256561
|
n.y += oy;
|
|
256547
256562
|
}
|
|
256548
|
-
|
|
256549
|
-
|
|
256563
|
+
nodes[n.id] = { ...n, childIds: [], parentId: parent2 };
|
|
256564
|
+
const p2 = nodes[parent2];
|
|
256565
|
+
nodes[parent2] = { ...p2, childIds: [...p2.childIds, n.id] };
|
|
256566
|
+
for (const k2 of src.childIds ?? []) walk4(k2, n.id, false);
|
|
256550
256567
|
};
|
|
256551
256568
|
walk4(rootId, parentId, true);
|
|
256552
|
-
return document2;
|
|
256569
|
+
return { ...document2, nodes };
|
|
256553
256570
|
}
|
|
256554
256571
|
function mergeRecords(doc2, t3, map2, roots) {
|
|
256555
256572
|
const p2 = t3.payload;
|
|
@@ -256798,11 +256815,11 @@ function colorFor(id3) {
|
|
|
256798
256815
|
for (let i2 = 0; i2 < id3.length; i2++) h = h * 31 + id3.charCodeAt(i2) >>> 0;
|
|
256799
256816
|
return PALETTE[h % PALETTE.length];
|
|
256800
256817
|
}
|
|
256801
|
-
function updateLocal(
|
|
256818
|
+
function updateLocal(patch2) {
|
|
256802
256819
|
if (!awareness) return;
|
|
256803
256820
|
const cur = awareness.getLocalState();
|
|
256804
256821
|
if (!cur) return;
|
|
256805
|
-
awareness.setLocalState({ ...cur, ...
|
|
256822
|
+
awareness.setLocalState({ ...cur, ...patch2 });
|
|
256806
256823
|
}
|
|
256807
256824
|
function sendCursor() {
|
|
256808
256825
|
cursorTimer = null;
|
|
@@ -256955,12 +256972,12 @@ function createPopcornSlice(set4, get4) {
|
|
|
256955
256972
|
const state = get4();
|
|
256956
256973
|
set4({ document: after, ...extra, history: pushCommand(state.history, createCommand("POPCORN", description, state.document, after)) });
|
|
256957
256974
|
};
|
|
256958
|
-
const restyleSelectedTapes = (
|
|
256975
|
+
const restyleSelectedTapes = (patch2, description) => {
|
|
256959
256976
|
const state = get4();
|
|
256960
256977
|
let doc2 = state.document;
|
|
256961
256978
|
for (const id3 of state.selection) {
|
|
256962
256979
|
const n = doc2.nodes[id3];
|
|
256963
|
-
if (n?.washiStyle) doc2 = { ...doc2, nodes: { ...doc2.nodes, [id3]: restyleWashiTape(n,
|
|
256980
|
+
if (n?.washiStyle) doc2 = { ...doc2, nodes: { ...doc2.nodes, [id3]: restyleWashiTape(n, patch2) } };
|
|
256964
256981
|
}
|
|
256965
256982
|
if (doc2 !== state.document) commit(doc2, description);
|
|
256966
256983
|
};
|
|
@@ -257606,16 +257623,16 @@ async function listDocMetas() {
|
|
|
257606
257623
|
async function getDocMeta(id3) {
|
|
257607
257624
|
return (await readIndex()).find((m) => m.id === id3) ?? null;
|
|
257608
257625
|
}
|
|
257609
|
-
async function upsertDocMeta(
|
|
257610
|
-
if (deletedHere.has(
|
|
257626
|
+
async function upsertDocMeta(patch2, { create: create8 = false } = {}) {
|
|
257627
|
+
if (deletedHere.has(patch2.id)) return;
|
|
257611
257628
|
await update2(INDEX_KEY, (idx) => {
|
|
257612
257629
|
const list2 = Array.isArray(idx) ? [...idx] : [];
|
|
257613
|
-
const i2 = list2.findIndex((m) => m.id ===
|
|
257630
|
+
const i2 = list2.findIndex((m) => m.id === patch2.id);
|
|
257614
257631
|
if (i2 < 0 && !create8) return list2;
|
|
257615
257632
|
if (i2 >= 0) {
|
|
257616
257633
|
const { thumbnail: inline, ...rest } = list2[i2];
|
|
257617
|
-
list2[i2] = { ...rest, ...typeof inline === "string" ? { thumbnail: inline } : {}, ...
|
|
257618
|
-
} else list2.push({ id:
|
|
257634
|
+
list2[i2] = { ...rest, ...typeof inline === "string" ? { thumbnail: inline } : {}, ...patch2 };
|
|
257635
|
+
} else list2.push({ id: patch2.id, name: patch2.name || "Untitled", updatedAt: patch2.updatedAt || Date.now(), thumbAt: patch2.thumbAt });
|
|
257619
257636
|
return list2;
|
|
257620
257637
|
});
|
|
257621
257638
|
}
|
|
@@ -258008,8 +258025,8 @@ function openFramingIds(nodes, pageId2) {
|
|
|
258008
258025
|
const page = nodes[pageId2];
|
|
258009
258026
|
if (!page) return [];
|
|
258010
258027
|
const children = (page.childIds ?? []).filter((id3) => nodes[id3] && nodes[id3].visible !== false);
|
|
258011
|
-
const
|
|
258012
|
-
return
|
|
258028
|
+
const frame3 = children.find((id3) => nodes[id3].type === "FRAME");
|
|
258029
|
+
return frame3 ? [frame3] : children;
|
|
258013
258030
|
}
|
|
258014
258031
|
function isSavedCamera(camera2) {
|
|
258015
258032
|
if (!camera2 || !Number.isFinite(camera2.x) || !Number.isFinite(camera2.y) || !(camera2.zoom > 0)) return false;
|
|
@@ -258075,14 +258092,14 @@ function withCounter(node2, counter) {
|
|
|
258075
258092
|
}
|
|
258076
258093
|
return { ...node2, textCounter: counter, characters: formatCounter(counter, counterRest(counter)) };
|
|
258077
258094
|
}
|
|
258078
|
-
function editCounter(node2,
|
|
258095
|
+
function editCounter(node2, patch2) {
|
|
258079
258096
|
const c2 = node2.textCounter;
|
|
258080
258097
|
if (!c2) return node2;
|
|
258081
|
-
const next2 = { ...c2, ...
|
|
258098
|
+
const next2 = { ...c2, ...patch2 };
|
|
258082
258099
|
let motion = node2.motion;
|
|
258083
258100
|
const track2 = motion?.tracks[COUNTER_PATH];
|
|
258084
|
-
if (track2?.keys.length && (
|
|
258085
|
-
const keys4 = track2.keys.map((k2, i2, all4) => i2 === 0 &&
|
|
258101
|
+
if (track2?.keys.length && (patch2.from !== void 0 || patch2.to !== void 0)) {
|
|
258102
|
+
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
258103
|
motion = withTrack(motion, COUNTER_PATH, { ...track2, keys: keys4 });
|
|
258087
258104
|
}
|
|
258088
258105
|
return { ...withCounter(node2, next2), motion };
|
|
@@ -258349,9 +258366,9 @@ function frameSound(nodes, frameId, lengths2 = NO_LENGTHS) {
|
|
|
258349
258366
|
let list2 = frameMemo.get(nodes);
|
|
258350
258367
|
const hit = list2?.find((m) => m.frameId === frameId && m.lengths === lengths2);
|
|
258351
258368
|
if (hit) return hit.sound;
|
|
258352
|
-
const
|
|
258353
|
-
const sound =
|
|
258354
|
-
if (
|
|
258369
|
+
const frame3 = nodes[frameId];
|
|
258370
|
+
const sound = frame3 ? [...frame3.timeline?.audio ?? []] : [];
|
|
258371
|
+
if (frame3) {
|
|
258355
258372
|
const duration3 = timelineDuration(nodes, frameId);
|
|
258356
258373
|
for (const id3 of videoNodeIds(nodes)) {
|
|
258357
258374
|
if (id3 === frameId || localTime(nodes, id3, frameId, 0) === void 0) continue;
|
|
@@ -258539,7 +258556,7 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
|
|
|
258539
258556
|
});
|
|
258540
258557
|
if (!stage) return pose;
|
|
258541
258558
|
const moment = compositionAt(comp, time4);
|
|
258542
|
-
let
|
|
258559
|
+
let patch2 = null;
|
|
258543
258560
|
const ids2 = /* @__PURE__ */ new Set();
|
|
258544
258561
|
let live = time4 < compositionDuration(comp);
|
|
258545
258562
|
for (const a of [moment.previous, moment.current]) {
|
|
@@ -258547,7 +258564,7 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
|
|
|
258547
258564
|
const fp = evaluatePose(base, { kind: "frame", frameId: a.clip.frameId }, a.local, { clock: clock2, runtime, driveVideo: true, ...audio ? { audio } : {} });
|
|
258548
258565
|
if (fp.live) live = true;
|
|
258549
258566
|
for (const id3 of fp.animatedIds) {
|
|
258550
|
-
(
|
|
258567
|
+
(patch2 ??= {})[id3] = fp.nodes[id3];
|
|
258551
258568
|
ids2.add(id3);
|
|
258552
258569
|
}
|
|
258553
258570
|
}
|
|
@@ -258555,8 +258572,8 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
|
|
|
258555
258572
|
const t3 = placed2(id3), n = base[id3];
|
|
258556
258573
|
return t3 && n ? { width: n.width, height: n.height, cx: t3.cx, cy: t3.cy } : null;
|
|
258557
258574
|
});
|
|
258558
|
-
const posed2 =
|
|
258559
|
-
if (
|
|
258575
|
+
const posed2 = patch2 ? { ...base, ...patch2 } : base;
|
|
258576
|
+
if (patch2) noteChanged(base, posed2, Object.keys(patch2));
|
|
258560
258577
|
return {
|
|
258561
258578
|
...pose,
|
|
258562
258579
|
nodes: posed2,
|
|
@@ -258598,17 +258615,17 @@ function withOrbits(pose, orbits) {
|
|
|
258598
258615
|
const hit = orbitMemo.get(pose);
|
|
258599
258616
|
if (hit && hit.orbits === orbits) return hit.pose;
|
|
258600
258617
|
const nodes = pose.nodes;
|
|
258601
|
-
const
|
|
258618
|
+
const patch2 = {};
|
|
258602
258619
|
const visit2 = (id3) => {
|
|
258603
258620
|
const n = nodes[id3];
|
|
258604
258621
|
if (!n) return;
|
|
258605
258622
|
const o = orbits.turns[n.name];
|
|
258606
|
-
if (o)
|
|
258623
|
+
if (o) patch2[id3] = { ...n, rotateX: (n.rotateX ?? 0) + o.rotateX, rotateY: (n.rotateY ?? 0) + o.rotateY };
|
|
258607
258624
|
for (const c2 of n.childIds ?? []) visit2(c2);
|
|
258608
258625
|
};
|
|
258609
258626
|
for (const r of orbits.roots) visit2(r);
|
|
258610
|
-
const ids2 = Object.keys(
|
|
258611
|
-
const shown2 = ids2.length ? { ...nodes, ...
|
|
258627
|
+
const ids2 = Object.keys(patch2);
|
|
258628
|
+
const shown2 = ids2.length ? { ...nodes, ...patch2 } : nodes;
|
|
258612
258629
|
noteChanged(nodes, shown2, ids2);
|
|
258613
258630
|
const out = { ...pose, nodes: shown2, animatedIds: ids2.length ? /* @__PURE__ */ new Set([...pose.animatedIds, ...ids2]) : pose.animatedIds, orbits };
|
|
258614
258631
|
orbitMemo.set(pose, { orbits, pose: out });
|
|
@@ -258624,7 +258641,7 @@ function withSolo(pose, solo) {
|
|
|
258624
258641
|
const on = new Set(solo.filter((id3) => nodes[id3]));
|
|
258625
258642
|
const onTheWay = /* @__PURE__ */ new Set();
|
|
258626
258643
|
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
|
|
258644
|
+
const patch2 = {};
|
|
258628
258645
|
const visit2 = (id3) => {
|
|
258629
258646
|
const n = nodes[id3];
|
|
258630
258647
|
if (!n || on.has(id3)) return;
|
|
@@ -258632,11 +258649,11 @@ function withSolo(pose, solo) {
|
|
|
258632
258649
|
for (const c2 of n.childIds) visit2(c2);
|
|
258633
258650
|
return;
|
|
258634
258651
|
}
|
|
258635
|
-
if (n.visible !== false)
|
|
258652
|
+
if (n.visible !== false) patch2[id3] = { ...n, visible: false };
|
|
258636
258653
|
};
|
|
258637
258654
|
if (on.size) for (const c2 of nodes[frameId]?.childIds ?? []) visit2(c2);
|
|
258638
|
-
const ids2 = Object.keys(
|
|
258639
|
-
const shown2 = ids2.length ? { ...nodes, ...
|
|
258655
|
+
const ids2 = Object.keys(patch2);
|
|
258656
|
+
const shown2 = ids2.length ? { ...nodes, ...patch2 } : nodes;
|
|
258640
258657
|
noteChanged(nodes, shown2, ids2);
|
|
258641
258658
|
const out = { ...pose, nodes: shown2, animatedIds: ids2.length ? /* @__PURE__ */ new Set([...pose.animatedIds, ...ids2]) : pose.animatedIds, solo };
|
|
258642
258659
|
soloMemo.set(pose, { solo: key5, pose: out });
|
|
@@ -260440,7 +260457,6 @@ function retuneShaderAudio(node2, fillId) {
|
|
|
260440
260457
|
}
|
|
260441
260458
|
var init_shader_audio = __esm({
|
|
260442
260459
|
"lib/motion/shader-audio.ts"() {
|
|
260443
|
-
"use strict";
|
|
260444
260460
|
init_shader_params();
|
|
260445
260461
|
init_modifier_edit();
|
|
260446
260462
|
init_keys();
|
|
@@ -260625,8 +260641,8 @@ function timeBoundsOf(s) {
|
|
|
260625
260641
|
const width = s.timeViewWidth;
|
|
260626
260642
|
const soundEnd = (audio) => Math.max(0, ...(audio ?? []).map(audioClipEnd));
|
|
260627
260643
|
if (t3?.kind === "frame") {
|
|
260628
|
-
const
|
|
260629
|
-
return
|
|
260644
|
+
const frame3 = s.document.nodes[t3.frameId];
|
|
260645
|
+
return frame3 ? { duration: frameDuration(s.document.nodes, t3.frameId), fps: timelineFps(frame3.timeline), width, content: soundEnd(frame3.timeline?.audio) } : null;
|
|
260630
260646
|
}
|
|
260631
260647
|
const comp = t3?.kind === "composition" ? s.document.compositions?.[t3.compositionId] : void 0;
|
|
260632
260648
|
return comp ? { duration: compositionDuration(comp), fps: comp.fps, width, content: soundEnd(comp.audio) } : null;
|
|
@@ -260653,7 +260669,7 @@ function snapTime(tr, t3) {
|
|
|
260653
260669
|
return snapToFrame(at4, tr.fps);
|
|
260654
260670
|
}
|
|
260655
260671
|
function createMotionSlice(set4, get4) {
|
|
260656
|
-
const put3 = (
|
|
260672
|
+
const put3 = (patch2) => set4({ transport: { ...get4().transport, ...patch2 } });
|
|
260657
260673
|
const clock2 = (now2) => now2 ?? transportNow();
|
|
260658
260674
|
const frameId = () => {
|
|
260659
260675
|
const s = get4();
|
|
@@ -260815,9 +260831,9 @@ function createMotionSlice(set4, get4) {
|
|
|
260815
260831
|
set4({ solo: cur.includes(id3) ? cur.filter((x2) => x2 !== id3) : [...cur, id3] });
|
|
260816
260832
|
},
|
|
260817
260833
|
onion: { on: false, count: 2, stepFrames: 3 },
|
|
260818
|
-
setOnion: (
|
|
260834
|
+
setOnion: (patch2) => {
|
|
260819
260835
|
const cur = get4().onion;
|
|
260820
|
-
const next2 = { ...cur, ...
|
|
260836
|
+
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
260837
|
if (next2.on !== cur.on || next2.count !== cur.count || next2.stepFrames !== cur.stepFrames) set4({ onion: next2 });
|
|
260822
260838
|
},
|
|
260823
260839
|
timeViews: {},
|
|
@@ -261082,8 +261098,8 @@ function foldVariant(doc2, masterId, variantId, id3) {
|
|
|
261082
261098
|
if ((k2 === "fontSize" || k2 === "lineHeight") && restyled) continue;
|
|
261083
261099
|
props[k2] = value3;
|
|
261084
261100
|
}
|
|
261085
|
-
const
|
|
261086
|
-
if ("responsive" in
|
|
261101
|
+
const patch2 = breakpointPatch(master, doc2, id3, props);
|
|
261102
|
+
if ("responsive" in patch2 && !same2(patch2.responsive, master.responsive)) nodes[m] = { ...master, responsive: patch2.responsive };
|
|
261087
261103
|
const a = master.childIds ?? [], b = variant.childIds ?? [];
|
|
261088
261104
|
if (a.length === b.length) a.forEach((c2, i2) => walk4(c2, b[i2], false));
|
|
261089
261105
|
};
|
|
@@ -261351,11 +261367,11 @@ function shownRecordOf(nodes, doc2, id3) {
|
|
|
261351
261367
|
const own2 = pinnedRecord(doc2, nodes[id3]);
|
|
261352
261368
|
if (own2) return own2;
|
|
261353
261369
|
for (let at4 = nodes[id3]?.parentId, hops = 0; at4 && hops < 64; at4 = nodes[at4]?.parentId, hops++) {
|
|
261354
|
-
const
|
|
261355
|
-
const pinned = pinnedRecord(doc2,
|
|
261370
|
+
const frame3 = nodes[at4];
|
|
261371
|
+
const pinned = pinnedRecord(doc2, frame3);
|
|
261356
261372
|
if (pinned) return pinned;
|
|
261357
|
-
if (
|
|
261358
|
-
const of =
|
|
261373
|
+
if (frame3?.repeat) return repeatRecords(doc2, frame3.repeat)[0] ?? null;
|
|
261374
|
+
const of = frame3?.route?.collectionId;
|
|
261359
261375
|
if (of && doc2.collections?.[of]) return repeatRecords(doc2, { collectionId: of })[0] ?? null;
|
|
261360
261376
|
}
|
|
261361
261377
|
return null;
|
|
@@ -261641,11 +261657,11 @@ var init_scroll = __esm({
|
|
|
261641
261657
|
|
|
261642
261658
|
// lib/runtime/actions.ts
|
|
261643
261659
|
function layerCenterIn(doc2, id3, frameId) {
|
|
261644
|
-
const
|
|
261660
|
+
const frame3 = doc2.nodes[frameId];
|
|
261645
261661
|
const real = doc2.nodes[id3] ? id3 : id3.includes("::") ? id3.slice(0, id3.indexOf("::")) : id3;
|
|
261646
|
-
if (!
|
|
261662
|
+
if (!frame3 || !doc2.nodes[real] || frame3.width <= 0 || frame3.height <= 0) return null;
|
|
261647
261663
|
const f2 = getWorldTransform(doc2, frameId), l = getWorldTransform(doc2, real);
|
|
261648
|
-
return { x: (l.cx - (f2.cx -
|
|
261664
|
+
return { x: (l.cx - (f2.cx - frame3.width / 2)) / frame3.width, y: (l.cy - (f2.cy - frame3.height / 2)) / frame3.height };
|
|
261649
261665
|
}
|
|
261650
261666
|
function begin(state, ctx2, id3, arrive) {
|
|
261651
261667
|
const nodes = state.document.nodes;
|
|
@@ -262004,17 +262020,17 @@ var init_present_driver = __esm({
|
|
|
262004
262020
|
// lib/runtime/store-adapter.ts
|
|
262005
262021
|
function storePatch(prev, next2) {
|
|
262006
262022
|
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(
|
|
262023
|
+
const patch2 = {};
|
|
262024
|
+
if (next2.document !== prev.document) patch2.document = next2.document;
|
|
262025
|
+
if (next2.screen !== prev.screen) patch2.activePrototypeFrameId = next2.screen;
|
|
262026
|
+
if (next2.overlays !== prev.overlays) patch2.prototypeOverlays = next2.overlays;
|
|
262027
|
+
if (next2.history !== prev.history) patch2.prototypeHistory = next2.history;
|
|
262028
|
+
if (next2.transition !== prev.transition) patch2.prototypeTransition = next2.transition;
|
|
262029
|
+
if (next2.playback !== prev.playback) patch2.presentPlayback = next2.playback;
|
|
262030
|
+
if (next2.varBackup !== prev.varBackup) patch2.prototypeVarBackup = next2.varBackup;
|
|
262031
|
+
if (next2.varGlides !== prev.varGlides) patch2.prototypeVarGlides = next2.varGlides;
|
|
262032
|
+
if (next2.scroll !== prev.scroll) patch2.prototypeScrollState = next2.scroll;
|
|
262033
|
+
return Object.keys(patch2).length ? patch2 : null;
|
|
262018
262034
|
}
|
|
262019
262035
|
var runtimeOf;
|
|
262020
262036
|
var init_store_adapter = __esm({
|
|
@@ -262313,7 +262329,7 @@ var init_plugin_store = __esm({
|
|
|
262313
262329
|
setInstalled: (installed3) => set4({ installed: installed3 }),
|
|
262314
262330
|
setManagerOpen: (managerOpen) => set4({ managerOpen }),
|
|
262315
262331
|
upsertSession: (s) => set4((st) => ({ sessions: [...st.sessions.filter((x2) => x2.sessionId !== s.sessionId), s] })),
|
|
262316
|
-
patchSession: (sessionId,
|
|
262332
|
+
patchSession: (sessionId, patch2) => set4((st) => ({ sessions: st.sessions.map((x2) => x2.sessionId === sessionId ? { ...x2, ...patch2 } : x2) })),
|
|
262317
262333
|
removeSession: (sessionId) => set4((st) => ({ sessions: st.sessions.filter((x2) => x2.sessionId !== sessionId) })),
|
|
262318
262334
|
toast: (message, opts = {}) => {
|
|
262319
262335
|
announce(opts.source ? `${opts.source}: ${message}` : message, opts.error ? "assertive" : "polite");
|
|
@@ -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 } : {} });
|
|
@@ -318177,7 +318321,7 @@ function bbox2(boxes) {
|
|
|
318177
318321
|
const maxX = Math.max(...boxes.map((b) => b.x + b.width)), maxY = Math.max(...boxes.map((b) => b.y + b.height));
|
|
318178
318322
|
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
318179
318323
|
}
|
|
318180
|
-
function inferAutoLayout(
|
|
318324
|
+
function inferAutoLayout(frame3, children) {
|
|
318181
318325
|
const kids = children.filter((c3) => c3.width >= 0 && c3.height >= 0);
|
|
318182
318326
|
const empty2 = {
|
|
318183
318327
|
layoutMode: "VERTICAL",
|
|
@@ -318197,7 +318341,7 @@ function inferAutoLayout(frame2, children) {
|
|
|
318197
318341
|
const sepV = separation(kids, "VERTICAL");
|
|
318198
318342
|
const sepH = separation(kids, "HORIZONTAL");
|
|
318199
318343
|
let dir;
|
|
318200
|
-
if (kids.length === 1) dir =
|
|
318344
|
+
if (kids.length === 1) dir = frame3.width > frame3.height ? "HORIZONTAL" : "VERTICAL";
|
|
318201
318345
|
else if (rowsV.length !== colsH.length) dir = rowsV.length > colsH.length ? "VERTICAL" : "HORIZONTAL";
|
|
318202
318346
|
else if (Math.abs(sepV - sepH) > 0.01) dir = sepV > sepH ? "VERTICAL" : "HORIZONTAL";
|
|
318203
318347
|
else {
|
|
@@ -318229,8 +318373,8 @@ function inferAutoLayout(frame2, children) {
|
|
|
318229
318373
|
const padding3 = {
|
|
318230
318374
|
top: Math.max(0, Math.round(bb.y)),
|
|
318231
318375
|
left: Math.max(0, Math.round(bb.x)),
|
|
318232
|
-
bottom: Math.max(0, Math.round(
|
|
318233
|
-
right: Math.max(0, Math.round(
|
|
318376
|
+
bottom: Math.max(0, Math.round(frame3.height - (bb.y + bb.height))),
|
|
318377
|
+
right: Math.max(0, Math.round(frame3.width - (bb.x + bb.width)))
|
|
318234
318378
|
};
|
|
318235
318379
|
const before = dir === "HORIZONTAL" ? padding3.left : padding3.top;
|
|
318236
318380
|
const after = dir === "HORIZONTAL" ? padding3.right : padding3.bottom;
|
|
@@ -318272,7 +318416,7 @@ function applyLayoutSuggestion(doc2, nodeId2, s) {
|
|
|
318272
318416
|
const nodes = { ...doc2.nodes };
|
|
318273
318417
|
let host = original;
|
|
318274
318418
|
if (host.type === "GROUP") {
|
|
318275
|
-
const
|
|
318419
|
+
const frame3 = createFrame({
|
|
318276
318420
|
id: host.id,
|
|
318277
318421
|
name: host.name,
|
|
318278
318422
|
x: host.x,
|
|
@@ -318289,7 +318433,7 @@ function applyLayoutSuggestion(doc2, nodeId2, s) {
|
|
|
318289
318433
|
backgroundColor: { r: 1, g: 1, b: 1, a: 0 },
|
|
318290
318434
|
clipsContent: false
|
|
318291
318435
|
});
|
|
318292
|
-
host =
|
|
318436
|
+
host = frame3;
|
|
318293
318437
|
}
|
|
318294
318438
|
const flow = new Set(flowChildren(doc2, host).map((c2) => c2.id));
|
|
318295
318439
|
const rest = host.childIds.filter((id3) => !flow.has(id3));
|
|
@@ -318435,8 +318579,8 @@ function applyOverride(doc2, virtualId, props) {
|
|
|
318435
318579
|
}
|
|
318436
318580
|
function commitUpdates(ctx2, doc2, updates) {
|
|
318437
318581
|
let next2 = doc2;
|
|
318438
|
-
for (const [id3,
|
|
318439
|
-
next2 = isVirtualId2(id3) ? applyOverride(next2, id3,
|
|
318582
|
+
for (const [id3, patch2] of updates) {
|
|
318583
|
+
next2 = isVirtualId2(id3) ? applyOverride(next2, id3, patch2) : updateNode(next2, id3, patch2);
|
|
318440
318584
|
}
|
|
318441
318585
|
next2 = applyInvariants(next2, updates.keys());
|
|
318442
318586
|
ctx2.commit(next2);
|
|
@@ -318710,14 +318854,14 @@ function isSvgMarkup(text) {
|
|
|
318710
318854
|
}
|
|
318711
318855
|
function placeSvgLayers(doc2, parentId, svg, place4) {
|
|
318712
318856
|
if (!doc2.nodes[parentId] || svg.length > MAX_SVG_LAYER_BYTES) return null;
|
|
318713
|
-
const
|
|
318714
|
-
let next2 = addNode(doc2,
|
|
318857
|
+
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 });
|
|
318858
|
+
let next2 = addNode(doc2, frame3, parentId);
|
|
318715
318859
|
try {
|
|
318716
|
-
next2 = importSVG(svg, next2,
|
|
318860
|
+
next2 = importSVG(svg, next2, frame3.id);
|
|
318717
318861
|
} catch {
|
|
318718
318862
|
return null;
|
|
318719
318863
|
}
|
|
318720
|
-
const kids = next2.nodes[
|
|
318864
|
+
const kids = next2.nodes[frame3.id].childIds.map((id3) => next2.nodes[id3]).filter(Boolean);
|
|
318721
318865
|
if (!kids.length) return null;
|
|
318722
318866
|
const nodes = { ...next2.nodes };
|
|
318723
318867
|
if (place4.intern) {
|
|
@@ -318730,8 +318874,8 @@ function placeSvgLayers(doc2, parentId, svg, place4) {
|
|
|
318730
318874
|
const maxX = Math.max(...kids.map((k2) => k2.x + k2.width)), maxY = Math.max(...kids.map((k2) => k2.y + k2.height));
|
|
318731
318875
|
for (const k2 of kids) nodes[k2.id] = { ...nodes[k2.id], x: k2.x - minX, y: k2.y - minY };
|
|
318732
318876
|
const w = Math.max(1, maxX - minX), h = Math.max(1, maxY - minY);
|
|
318733
|
-
nodes[
|
|
318734
|
-
return { doc: { ...next2, nodes }, id:
|
|
318877
|
+
nodes[frame3.id] = { ...nodes[frame3.id], x: Math.round(place4.cx - w / 2), y: Math.round(place4.cy - h / 2), width: w, height: h };
|
|
318878
|
+
return { doc: { ...next2, nodes }, id: frame3.id };
|
|
318735
318879
|
}
|
|
318736
318880
|
var MAX_SVG_LAYER_BYTES;
|
|
318737
318881
|
var init_svg_place = __esm({
|
|
@@ -319097,15 +319241,15 @@ var init_node = __esm({
|
|
|
319097
319241
|
const changedKeys = /* @__PURE__ */ new Set();
|
|
319098
319242
|
for (const u of args2.updates) {
|
|
319099
319243
|
resolvedNodeOrThrow(doc2, u.id);
|
|
319100
|
-
const
|
|
319244
|
+
const patch2 = {};
|
|
319101
319245
|
for (const [k2, v] of Object.entries(u.props)) {
|
|
319102
319246
|
if (args2.strict && FORBIDDEN_PROPS.has(k2)) throw new ToolError(`update_nodes cannot change "${k2}". Use reparent, delete_nodes or create_node instead.`);
|
|
319103
319247
|
if (FORBIDDEN_PROPS.has(k2) || v === void 0) continue;
|
|
319104
|
-
|
|
319248
|
+
patch2[k2] = v;
|
|
319105
319249
|
changedKeys.add(k2);
|
|
319106
319250
|
}
|
|
319107
|
-
if (args2.strict && !Object.keys(
|
|
319108
|
-
patches.set(u.id,
|
|
319251
|
+
if (args2.strict && !Object.keys(patch2).length) throw new ToolError(`No properties given for "${u.id}".`);
|
|
319252
|
+
patches.set(u.id, patch2);
|
|
319109
319253
|
}
|
|
319110
319254
|
commitUpdates(ctx2, doc2, patches);
|
|
319111
319255
|
return { summary: `Updated ${plural2(patches.size, "layer")} (${[...changedKeys].slice(0, 6).join(", ")})`, data: { ids: [...patches.keys()] } };
|
|
@@ -319806,7 +319950,7 @@ var init_node = __esm({
|
|
|
319806
319950
|
|
|
319807
319951
|
// lib/commands/text.ts
|
|
319808
319952
|
function applyTypeStyle(node2, styles) {
|
|
319809
|
-
const
|
|
319953
|
+
const patch2 = { ...styles };
|
|
319810
319954
|
const segments = node2.styledSegments;
|
|
319811
319955
|
if (segments?.length) {
|
|
319812
319956
|
const keys4 = Object.keys(styles);
|
|
@@ -319815,9 +319959,9 @@ function applyTypeStyle(node2, styles) {
|
|
|
319815
319959
|
for (const k2 of keys4) delete next2[k2];
|
|
319816
319960
|
return next2;
|
|
319817
319961
|
}).filter((seg) => Object.keys(seg).length > 2);
|
|
319818
|
-
|
|
319962
|
+
patch2.styledSegments = stripped;
|
|
319819
319963
|
}
|
|
319820
|
-
return
|
|
319964
|
+
return patch2;
|
|
319821
319965
|
}
|
|
319822
319966
|
var textSet, TYPE_FIELDS, textSetTypography, textSearchFonts, textSetEffect;
|
|
319823
319967
|
var init_text = __esm({
|
|
@@ -320188,8 +320332,8 @@ var init_text_path2 = __esm({
|
|
|
320188
320332
|
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
320333
|
const t3 = text;
|
|
320190
320334
|
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,
|
|
320335
|
+
const patch2 = { textArea: area4, textPath: void 0, textAutoResize: "NONE", ...args2.fit ? { textFit: args2.fit } : {}, ...areaBoxPatch(doc2.nodes, t3, shapeId) };
|
|
320336
|
+
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[textId, patch2]]));
|
|
320193
320337
|
return { summary: `Flowed "${text.name}" into "${shape2.name}"`, data: { id: textId, shapeId } };
|
|
320194
320338
|
}
|
|
320195
320339
|
});
|
|
@@ -320552,7 +320696,7 @@ var init_paint = __esm({
|
|
|
320552
320696
|
if (!n) continue;
|
|
320553
320697
|
stack.push(...n.childIds ?? []);
|
|
320554
320698
|
const rec = n;
|
|
320555
|
-
const
|
|
320699
|
+
const patch2 = {};
|
|
320556
320700
|
let hit = 0;
|
|
320557
320701
|
const paints = rec.fills;
|
|
320558
320702
|
if (paints?.length) {
|
|
@@ -320581,7 +320725,7 @@ var init_paint = __esm({
|
|
|
320581
320725
|
}
|
|
320582
320726
|
return out;
|
|
320583
320727
|
});
|
|
320584
|
-
if (changed)
|
|
320728
|
+
if (changed) patch2.fills = next2;
|
|
320585
320729
|
}
|
|
320586
320730
|
const strokes = rec.strokes;
|
|
320587
320731
|
if (strokes?.length) {
|
|
@@ -320593,7 +320737,7 @@ var init_paint = __esm({
|
|
|
320593
320737
|
hit++;
|
|
320594
320738
|
return { ...s, color: c2 };
|
|
320595
320739
|
});
|
|
320596
|
-
if (changed)
|
|
320740
|
+
if (changed) patch2.strokes = next2;
|
|
320597
320741
|
}
|
|
320598
320742
|
const effects = effectsOf(n);
|
|
320599
320743
|
if (effects.length) {
|
|
@@ -320607,18 +320751,18 @@ var init_paint = __esm({
|
|
|
320607
320751
|
return { ...e, color: c2 };
|
|
320608
320752
|
});
|
|
320609
320753
|
if (changed) {
|
|
320610
|
-
|
|
320611
|
-
|
|
320612
|
-
|
|
320754
|
+
patch2.effects = next2;
|
|
320755
|
+
patch2.shadows = void 0;
|
|
320756
|
+
patch2.blurs = void 0;
|
|
320613
320757
|
}
|
|
320614
320758
|
}
|
|
320615
320759
|
const bg = swapColor(rec.backgroundColor);
|
|
320616
320760
|
if (bg) {
|
|
320617
|
-
|
|
320761
|
+
patch2.backgroundColor = bg;
|
|
320618
320762
|
hit++;
|
|
320619
320763
|
}
|
|
320620
320764
|
if (hit) {
|
|
320621
|
-
nodes[id3] = { ...n, ...
|
|
320765
|
+
nodes[id3] = { ...n, ...patch2 };
|
|
320622
320766
|
touched.push(id3);
|
|
320623
320767
|
swaps += hit;
|
|
320624
320768
|
}
|
|
@@ -321982,9 +322126,9 @@ function clipOr(doc2, id3, frameId) {
|
|
|
321982
322126
|
if (!c2) throw new Error(`"${doc2.nodes[id3]?.name ?? id3}" is not a video layer.`);
|
|
321983
322127
|
return c2;
|
|
321984
322128
|
}
|
|
321985
|
-
function withSound(node2, fill,
|
|
322129
|
+
function withSound(node2, fill, patch2) {
|
|
321986
322130
|
const cur = fillsOf(node2)[fill]?.videoSound ?? { muted: true };
|
|
321987
|
-
const next2 = { ...cur, ...
|
|
322131
|
+
const next2 = { ...cur, ...patch2 };
|
|
321988
322132
|
for (const k2 of Object.keys(next2)) if (next2[k2] === void 0) delete next2[k2];
|
|
321989
322133
|
if (next2.muted === false) delete next2.muted;
|
|
321990
322134
|
if (next2.offset !== void 0) {
|
|
@@ -322002,10 +322146,10 @@ function withSound(node2, fill, patch) {
|
|
|
322002
322146
|
if (next2.fadeCurve !== "equalPower") delete next2.fadeCurve;
|
|
322003
322147
|
return withVideoPaint(node2, fill, { videoSound: next2 });
|
|
322004
322148
|
}
|
|
322005
|
-
function editVideoSound(doc2, id3, frameId,
|
|
322149
|
+
function editVideoSound(doc2, id3, frameId, patch2) {
|
|
322006
322150
|
const c2 = clipOr(doc2, id3, frameId);
|
|
322007
322151
|
const len3 = c2.end - c2.start;
|
|
322008
|
-
const p2 = { ...
|
|
322152
|
+
const p2 = { ...patch2 };
|
|
322009
322153
|
for (const k2 of ["fadeIn", "fadeOut"]) if (p2[k2] !== void 0) p2[k2] = Math.min(len3, p2[k2]);
|
|
322010
322154
|
return withNode(doc2, withSound(doc2.nodes[id3], c2.fill, p2));
|
|
322011
322155
|
}
|
|
@@ -322110,9 +322254,9 @@ function setVideoSpeed(doc2, id3, frameId, speed) {
|
|
|
322110
322254
|
}
|
|
322111
322255
|
return withNode(doc2, next2);
|
|
322112
322256
|
}
|
|
322113
|
-
function editVideoPaint(doc2, id3, frameId,
|
|
322257
|
+
function editVideoPaint(doc2, id3, frameId, patch2) {
|
|
322114
322258
|
const c2 = clipOr(doc2, id3, frameId);
|
|
322115
|
-
return withNode(doc2, withVideoPaint(doc2.nodes[id3], c2.fill,
|
|
322259
|
+
return withNode(doc2, withVideoPaint(doc2.nodes[id3], c2.fill, patch2));
|
|
322116
322260
|
}
|
|
322117
322261
|
function splitVideo(doc2, id3, frameId, at4) {
|
|
322118
322262
|
const c2 = clipOr(doc2, id3, frameId);
|
|
@@ -322218,7 +322362,7 @@ function crossfadeAudio(holder, aId, bId, ms2, sourceMs) {
|
|
|
322218
322362
|
const aEnd = audioClipEnd(a);
|
|
322219
322363
|
let overlap = aEnd - b.start;
|
|
322220
322364
|
let next2 = holder;
|
|
322221
|
-
const
|
|
322365
|
+
const patch2 = (id3, p2) => {
|
|
322222
322366
|
next2 = editAudioClip(next2, id3, p2);
|
|
322223
322367
|
};
|
|
322224
322368
|
if (overlap < d) {
|
|
@@ -322228,13 +322372,13 @@ function crossfadeAudio(holder, aId, bId, ms2, sourceMs) {
|
|
|
322228
322372
|
const fileLen = sourceMs?.(a.mediaHash);
|
|
322229
322373
|
const tailRoom = fileLen !== void 0 ? Math.max(0, Math.floor((fileLen - a.out) / sa)) : Infinity;
|
|
322230
322374
|
const tail = Math.min(need - head2, tailRoom);
|
|
322231
|
-
if (tail > 0)
|
|
322232
|
-
if (head2 > 0)
|
|
322375
|
+
if (tail > 0) patch2(a.id, { out: Math.round(a.out + tail * sa) });
|
|
322376
|
+
if (head2 > 0) patch2(b.id, { start: b.start - head2, in: Math.round(b.in - head2 * sb) });
|
|
322233
322377
|
overlap = Math.max(0, overlap) + head2 + tail;
|
|
322234
322378
|
}
|
|
322235
322379
|
const fade = Math.max(1, Math.round(overlap));
|
|
322236
|
-
|
|
322237
|
-
|
|
322380
|
+
patch2(a.id, { fadeOut: fade, fadeCurve: "equalPower" });
|
|
322381
|
+
patch2(b.id, { fadeIn: fade, fadeCurve: "equalPower" });
|
|
322238
322382
|
return next2;
|
|
322239
322383
|
}
|
|
322240
322384
|
function clipUnder(doc2, id3, frameId) {
|
|
@@ -322290,9 +322434,9 @@ var init_video_edit = __esm({
|
|
|
322290
322434
|
init_time();
|
|
322291
322435
|
init_video_clip();
|
|
322292
322436
|
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(
|
|
322437
|
+
motionWith = (m, patch2) => {
|
|
322438
|
+
const next2 = { tracks: {}, ...m, ...patch2 };
|
|
322439
|
+
for (const k2 of Object.keys(patch2)) if (next2[k2] === void 0) delete next2[k2];
|
|
322296
322440
|
return !Object.keys(next2.tracks).length && next2.timeOffset === void 0 && next2.span === void 0 && next2.stagger === void 0 ? void 0 : next2;
|
|
322297
322441
|
};
|
|
322298
322442
|
videoNodeIdsOn = (doc2, frameId) => videoNodeIds(doc2.nodes).filter((id3) => id3 !== frameId && localTime(doc2.nodes, id3, frameId, 0) !== void 0);
|
|
@@ -322367,9 +322511,9 @@ function applyAudioOp(holder, op4, label3) {
|
|
|
322367
322511
|
return { holder: made.composition, clip: made.id };
|
|
322368
322512
|
}
|
|
322369
322513
|
case "audio": {
|
|
322370
|
-
const { kind: _k, clip, ...
|
|
322514
|
+
const { kind: _k, clip, ...patch2 } = op4;
|
|
322371
322515
|
void _k;
|
|
322372
|
-
return { holder: editAudioClip(holder, audioOr(clip),
|
|
322516
|
+
return { holder: editAudioClip(holder, audioOr(clip), patch2) };
|
|
322373
322517
|
}
|
|
322374
322518
|
case "trimAudio":
|
|
322375
322519
|
return { holder: trimAudioClip(holder, audioOr(op4.clip), op4.edge, op4.delta, op4.sourceMs) };
|
|
@@ -323221,10 +323365,10 @@ function constrained(kind, pos, size6, parentSize, start2, end, sizeProp) {
|
|
|
323221
323365
|
return { place: { [start2]: px2(pos) }, style: {} };
|
|
323222
323366
|
}
|
|
323223
323367
|
}
|
|
323224
|
-
function placedChild(node2, parent,
|
|
323368
|
+
function placedChild(node2, parent, frame3 = parent) {
|
|
323225
323369
|
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,
|
|
323370
|
+
const x2 = constrained(c2.horizontal, node2.x, node2.width, frame3.width, "left", "right", "width");
|
|
323371
|
+
const y = constrained(c2.vertical, node2.y, node2.height, frame3.height, "top", "bottom", "height");
|
|
323228
323372
|
return { style: { ...limits(node2), ...x2.style, ...y.style }, place: { position: "absolute", ...x2.place, ...y.place } };
|
|
323229
323373
|
}
|
|
323230
323374
|
function siteLayout(node2, parent, layout2) {
|
|
@@ -323432,8 +323576,8 @@ var init_tokens2 = __esm({
|
|
|
323432
323576
|
// lib/io/web/timeline.ts
|
|
323433
323577
|
function frameWebMotion(doc2, frameId, style) {
|
|
323434
323578
|
const nodes = doc2.nodes;
|
|
323435
|
-
const
|
|
323436
|
-
if (!
|
|
323579
|
+
const frame3 = nodes[frameId];
|
|
323580
|
+
if (!frame3 || !hasFrameMotion(nodes, frameId)) return null;
|
|
323437
323581
|
const len3 = timelineDuration(nodes, frameId);
|
|
323438
323582
|
if (!(len3 > 0)) return null;
|
|
323439
323583
|
const steps = Math.max(1, Math.ceil(len3 / 1e3 * SAMPLE_RATE));
|
|
@@ -327807,7 +327951,7 @@ var init_package = __esm({
|
|
|
327807
327951
|
"packages/runtime/package.json"() {
|
|
327808
327952
|
package_default = {
|
|
327809
327953
|
name: "@popcraft/runtime",
|
|
327810
|
-
version: "0.
|
|
327954
|
+
version: "0.44.1",
|
|
327811
327955
|
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
327956
|
license: "MIT",
|
|
327813
327957
|
homepage: "https://popcraft.app/docs/exporting/nextjs",
|
|
@@ -352473,6 +352617,7 @@ function exportsOf(source3) {
|
|
|
352473
352617
|
var CODE_LIMITS, packageOf;
|
|
352474
352618
|
var init_source2 = __esm({
|
|
352475
352619
|
"lib/code/source.ts"() {
|
|
352620
|
+
"use strict";
|
|
352476
352621
|
CODE_LIMITS = { modules: 100, sourceLength: 2e5, packages: 12 };
|
|
352477
352622
|
packageOf = (spec) => spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
|
|
352478
352623
|
}
|
|
@@ -352515,6 +352660,7 @@ function compileModule(module2) {
|
|
|
352515
352660
|
var import_sucrase, BUILT_IN, memo4;
|
|
352516
352661
|
var init_compile2 = __esm({
|
|
352517
352662
|
"lib/code/compile.ts"() {
|
|
352663
|
+
"use strict";
|
|
352518
352664
|
import_sucrase = __toESM(require_dist2());
|
|
352519
352665
|
init_source2();
|
|
352520
352666
|
init_source2();
|
|
@@ -353432,13 +353578,13 @@ async function drawShareFrame(doc2, frameId) {
|
|
|
353432
353578
|
Promise.resolve().then(() => (init_export_fills(), export_fills_exports))
|
|
353433
353579
|
]);
|
|
353434
353580
|
const renderer = getActiveRenderer2();
|
|
353435
|
-
const
|
|
353436
|
-
if (!renderer || !
|
|
353581
|
+
const frame3 = doc2.nodes[frameId];
|
|
353582
|
+
if (!renderer || !frame3) return null;
|
|
353437
353583
|
const shown2 = documentForExport2(doc2);
|
|
353438
|
-
const box2 = uprightBounds(getWorldTransform(shown2, frameId),
|
|
353584
|
+
const box2 = uprightBounds(getWorldTransform(shown2, frameId), frame3.width, frame3.height);
|
|
353439
353585
|
const crop = shareCrop(box2.maxX - box2.minX, box2.maxY - box2.minY);
|
|
353440
353586
|
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] ??
|
|
353587
|
+
const pixels = await renderer.exportRegion([shown2.nodes[frameId] ?? frame3], bounds2, crop.scale, shown2, shown2.styles, void 0, true);
|
|
353442
353588
|
if (!pixels) return null;
|
|
353443
353589
|
const png = await encodeImageData2(pixels, "PNG");
|
|
353444
353590
|
if (png && png.size <= SHARE_MAX_BYTES) return { bytes: new Uint8Array(await png.arrayBuffer()), ext: "png" };
|
|
@@ -356352,8 +356498,8 @@ var init_vision = __esm({
|
|
|
356352
356498
|
if (args2.parts) {
|
|
356353
356499
|
if (ids2.length !== 1) throw new ToolError("Look at one frame part by part at a time.");
|
|
356354
356500
|
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 = (
|
|
356501
|
+
const frame3 = doc2.nodes[ids2[0]];
|
|
356502
|
+
const parts = (frame3.childIds ?? []).map((c2) => doc2.nodes[c2]).filter((n) => !!n && n.visible !== false && n.layoutPositioning !== "ABSOLUTE" && n.height > 1);
|
|
356357
356503
|
const FOOT = 1e5;
|
|
356358
356504
|
const tops = parts.map((n) => Math.max(0, n.y)).sort((a, b) => a - b);
|
|
356359
356505
|
const bands = tops.length ? tops.map((y, i2) => {
|
|
@@ -356616,16 +356762,16 @@ function placeAudioClip(ctx2, compositionId2, o) {
|
|
|
356616
356762
|
}
|
|
356617
356763
|
function placeFrameAudioClip(ctx2, frameId, o) {
|
|
356618
356764
|
const latest = ctx2.doc();
|
|
356619
|
-
const
|
|
356620
|
-
if (!
|
|
356621
|
-
const made = addAudioClip(frameTimeline(latest.nodes,
|
|
356765
|
+
const frame3 = latest.nodes[frameId];
|
|
356766
|
+
if (!frame3 || frame3.type !== "FRAME" && frame3.type !== "COMPONENT") throw new ToolError(`"${frameId}" is not a frame.`);
|
|
356767
|
+
const made = addAudioClip(frameTimeline(latest.nodes, frame3.id), { mediaHash: o.mediaHash, name: o.name, duration: o.duration, start: o.start, lane: o.lane });
|
|
356622
356768
|
let next2 = made.composition;
|
|
356623
356769
|
if (o.fadeIn !== void 0 || o.fadeOut !== void 0) next2 = editAudioClip(next2, made.id, { fadeIn: o.fadeIn, fadeOut: o.fadeOut });
|
|
356624
356770
|
if (o.gain !== void 0) next2 = setGainKey(next2, made.id, 0, o.gain);
|
|
356625
356771
|
if (o.loop) next2 = editAudioClip(next2, made.id, { loop: true });
|
|
356626
|
-
ctx2.commit({ ...latest, nodes: { ...latest.nodes, [
|
|
356772
|
+
ctx2.commit({ ...latest, nodes: { ...latest.nodes, [frame3.id]: { ...frame3, timeline: next2 } } });
|
|
356627
356773
|
const clip = next2.audio?.find((a) => a.id === made.id);
|
|
356628
|
-
return { summary: `Added "${o.name}" (${(o.duration / 1e3).toFixed(1)} s) to "${
|
|
356774
|
+
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
356775
|
}
|
|
356630
356776
|
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
356777
|
var init_motion2 = __esm({
|
|
@@ -356930,10 +357076,10 @@ var init_motion2 = __esm({
|
|
|
356930
357076
|
break;
|
|
356931
357077
|
case "frame": {
|
|
356932
357078
|
const clip = comp.clips.find((c2) => c2.id === clipOr2(op4.clip));
|
|
356933
|
-
const [
|
|
356934
|
-
if (!
|
|
357079
|
+
const [frame3] = scenesOf(doc2, [op4.frame]);
|
|
357080
|
+
if (!frame3) throw new ToolError(`"${op4.frame}" is not a frame (or a layer in one).`);
|
|
356935
357081
|
const wholeOld = clip.in === 0 && Math.abs(clip.out - timelineDuration(doc2.nodes, clip.frameId)) < 1;
|
|
356936
|
-
next2 = setClipFrame(comp, clip.id,
|
|
357082
|
+
next2 = setClipFrame(comp, clip.id, frame3.id, timelineDuration(doc2.nodes, frame3.id), wholeOld);
|
|
356937
357083
|
break;
|
|
356938
357084
|
}
|
|
356939
357085
|
case "rename":
|
|
@@ -357357,14 +357503,14 @@ var init_motion_av = __esm({
|
|
|
357357
357503
|
}
|
|
357358
357504
|
case "timing": {
|
|
357359
357505
|
if (op4.speed !== void 0) next2 = wrap2(() => setVideoSpeed(next2, id3, frameId, op4.speed));
|
|
357360
|
-
const
|
|
357361
|
-
if (Object.keys(
|
|
357506
|
+
const patch2 = { ...op4.loop !== void 0 ? { videoLoop: op4.loop } : {}, ...op4.poster !== void 0 ? { videoPosterTime: op4.poster } : {}, ...op4.playback ? { videoPlayback: op4.playback } : {} };
|
|
357507
|
+
if (Object.keys(patch2).length) next2 = wrap2(() => editVideoPaint(next2, id3, frameId, patch2));
|
|
357362
357508
|
break;
|
|
357363
357509
|
}
|
|
357364
357510
|
case "sound": {
|
|
357365
|
-
const { kind: _k, ...
|
|
357511
|
+
const { kind: _k, ...patch2 } = op4;
|
|
357366
357512
|
void _k;
|
|
357367
|
-
next2 = wrap2(() => editVideoSound(doc2, id3, frameId,
|
|
357513
|
+
next2 = wrap2(() => editVideoSound(doc2, id3, frameId, patch2));
|
|
357368
357514
|
break;
|
|
357369
357515
|
}
|
|
357370
357516
|
case "gainKey":
|
|
@@ -357406,13 +357552,13 @@ var init_motion_av = __esm({
|
|
|
357406
357552
|
},
|
|
357407
357553
|
run: (args2, ctx2) => {
|
|
357408
357554
|
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"} "${
|
|
357555
|
+
const frame3 = doc2.nodes[args2.frame];
|
|
357556
|
+
if (!frame3 || frame3.type !== "FRAME" && frame3.type !== "COMPONENT") throw new ToolError(`"${args2.frame}" is not a frame.`);
|
|
357557
|
+
const tl = frameTimeline(doc2.nodes, frame3.id);
|
|
357558
|
+
const r = applyAudioOp(tl, args2.op, `"${frame3.name}"`);
|
|
357559
|
+
if (r.holder === tl) return { summary: "Nothing to change", data: { frame: frame3.id } };
|
|
357560
|
+
ctx2.commit({ ...doc2, nodes: { ...doc2.nodes, [frame3.id]: { ...frame3, timeline: r.holder } } });
|
|
357561
|
+
return { summary: `${args2.op.kind === "addAudio" ? "Added audio to" : "Edited audio of"} "${frame3.name}"`, data: { frame: frame3.id, ...r.clip ? { clip: r.clip } : {} } };
|
|
357416
357562
|
}
|
|
357417
357563
|
});
|
|
357418
357564
|
}
|
|
@@ -357936,9 +358082,9 @@ var init_motion_keys = __esm({
|
|
|
357936
358082
|
delete motion.stagger;
|
|
357937
358083
|
}
|
|
357938
358084
|
}
|
|
357939
|
-
const
|
|
357940
|
-
if (l.label !== void 0)
|
|
357941
|
-
patches.set(node2.id,
|
|
358085
|
+
const patch2 = { ...patches.get(node2.id) ?? {}, motion: tidy(motion) };
|
|
358086
|
+
if (l.label !== void 0) patch2.timelineColor = l.label ?? void 0;
|
|
358087
|
+
patches.set(node2.id, patch2);
|
|
357942
358088
|
}
|
|
357943
358089
|
commitUpdates(ctx2, doc2, patches);
|
|
357944
358090
|
return { summary: `Timed ${plural2(patches.size, "layer")}`, data: { ids: [...patches.keys()] } };
|
|
@@ -358053,7 +358199,7 @@ var init_motion_rich = __esm({
|
|
|
358053
358199
|
MS2 = 36e5;
|
|
358054
358200
|
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
358201
|
colorOf = (c2) => typeof c2 === "string" ? parseHex(c2) : { a: 1, ...c2 };
|
|
358056
|
-
put2 = (patches, id3,
|
|
358202
|
+
put2 = (patches, id3, patch2) => patches.set(id3, { ...patches.get(id3) ?? {}, ...patch2 });
|
|
358057
358203
|
UNITS2 = ["letter", "word", "line"];
|
|
358058
358204
|
ORDERS3 = ["forward", "reverse", "center", "random"];
|
|
358059
358205
|
animatorFields = external_exports.object({
|
|
@@ -358313,12 +358459,12 @@ var init_motion_rich = __esm({
|
|
|
358313
358459
|
case "place": {
|
|
358314
358460
|
for (const l of op4.layers) {
|
|
358315
358461
|
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,
|
|
358462
|
+
const patch2 = {};
|
|
358463
|
+
if (l.rotateX !== void 0) patch2.rotateX = l.rotateX;
|
|
358464
|
+
if (l.rotateY !== void 0) patch2.rotateY = l.rotateY;
|
|
358465
|
+
if (l.z !== void 0) patch2.z = l.z;
|
|
358466
|
+
if (l.material) patch2.material3d = { ...layer2.material3d, ...clean3(l.material) };
|
|
358467
|
+
put2(patches, layer2.id, patch2);
|
|
358322
358468
|
}
|
|
358323
358469
|
commitUpdates(ctx2, doc2, patches);
|
|
358324
358470
|
return { summary: `Placed ${plural2(op4.layers.length, "layer")} in 3D`, data: { ids: op4.layers.map((l) => l.id) } };
|
|
@@ -358380,8 +358526,8 @@ var init_motion_rich = __esm({
|
|
|
358380
358526
|
playback.range = e.range;
|
|
358381
358527
|
} else delete playback.range;
|
|
358382
358528
|
}
|
|
358383
|
-
const
|
|
358384
|
-
if (touchesPlayback)
|
|
358529
|
+
const patch2 = {};
|
|
358530
|
+
if (touchesPlayback) patch2.playback = Object.keys(playback).length ? playback : void 0;
|
|
358385
358531
|
if (e.properties) {
|
|
358386
358532
|
const defs = componentDefinitions(doc2.nodes, comp);
|
|
358387
358533
|
const values3 = { ...inst.componentProperties ?? {} };
|
|
@@ -358391,9 +358537,9 @@ var init_motion_rich = __esm({
|
|
|
358391
358537
|
values3[name2] = def.type === "COLOR" ? colorOf(raw) : raw;
|
|
358392
358538
|
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
358539
|
}
|
|
358394
|
-
|
|
358540
|
+
patch2.componentProperties = values3;
|
|
358395
358541
|
}
|
|
358396
|
-
put2(patches, inst.id,
|
|
358542
|
+
put2(patches, inst.id, patch2);
|
|
358397
358543
|
}
|
|
358398
358544
|
commitUpdates(ctx2, doc2, patches);
|
|
358399
358545
|
return { summary: `Playback on ${plural2(patches.size, "instance")}`, data: { ids: [...patches.keys()] } };
|
|
@@ -358588,19 +358734,19 @@ var init_motion_rich = __esm({
|
|
|
358588
358734
|
function frameOrThrow(doc2, id3) {
|
|
358589
358735
|
nodeOrThrow(doc2, id3);
|
|
358590
358736
|
const host = hostOrThrow(doc2, id3);
|
|
358591
|
-
const
|
|
358592
|
-
if (
|
|
358593
|
-
return
|
|
358737
|
+
const frame3 = doc2.nodes[host];
|
|
358738
|
+
if (frame3.type !== "FRAME") throw new ToolError(`"${frame3.name}" is a component: state machines belong to top-level frames.`);
|
|
358739
|
+
return frame3;
|
|
358594
358740
|
}
|
|
358595
358741
|
function pick4(rec, key5, what) {
|
|
358596
358742
|
const hit = rec[key5] ?? Object.values(rec).find((e) => e.name.toLowerCase() === key5.toLowerCase());
|
|
358597
358743
|
if (!hit) throw new ToolError(`The machine has no ${what} "${key5}". It has: ${sortedValues(rec).map((e) => `${e.name} (${e.id})`).join(", ") || "none"}.`);
|
|
358598
358744
|
return hit;
|
|
358599
358745
|
}
|
|
358600
|
-
function markerOrThrow(
|
|
358601
|
-
const markers = frameTimelineOf(
|
|
358746
|
+
function markerOrThrow(frame3, key5) {
|
|
358747
|
+
const markers = frameTimelineOf(frame3).markers ?? [];
|
|
358602
358748
|
const m = markers.find((x2) => x2.id === key5) ?? markers.find((x2) => (x2.label ?? "").toLowerCase() === key5.toLowerCase());
|
|
358603
|
-
if (!m) throw new ToolError(`"${
|
|
358749
|
+
if (!m) throw new ToolError(`"${frame3.name}" has no marker "${key5}". Add one with set_timeline (addMarkers).`);
|
|
358604
358750
|
return m.id;
|
|
358605
358751
|
}
|
|
358606
358752
|
function valueFor(input2, v, what) {
|
|
@@ -358629,21 +358775,21 @@ function guardsFor(sm, list2) {
|
|
|
358629
358775
|
return { input: input2.id, ...op4 && op4 !== "eq" ? { op: op4 } : {}, ...g.value !== void 0 ? { value: valueFor(input2, g.value, "A guard") } : {} };
|
|
358630
358776
|
});
|
|
358631
358777
|
}
|
|
358632
|
-
function applyOp(
|
|
358778
|
+
function applyOp(frame3, sm, op4) {
|
|
358633
358779
|
if (op4.kind === "create") {
|
|
358634
|
-
if (sm) throw new ToolError(`"${
|
|
358635
|
-
return { next: createStateMachine(
|
|
358780
|
+
if (sm) throw new ToolError(`"${frame3.name}" already has a state machine ("${sm.name}"). Edit it, or remove it first.`);
|
|
358781
|
+
return { next: createStateMachine(frame3.timeline, op4.name) };
|
|
358636
358782
|
}
|
|
358637
|
-
if (!sm) throw new ToolError(`"${
|
|
358783
|
+
if (!sm) throw new ToolError(`"${frame3.name}" has no state machine. Create one first (op kind "create").`);
|
|
358638
358784
|
const stretchOf = (o, s) => {
|
|
358639
358785
|
const out = { ...s };
|
|
358640
358786
|
if (o.from !== void 0) {
|
|
358641
358787
|
if (o.from === null) delete out.from;
|
|
358642
|
-
else out.from = markerOrThrow(
|
|
358788
|
+
else out.from = markerOrThrow(frame3, o.from);
|
|
358643
358789
|
}
|
|
358644
358790
|
if (o.to !== void 0) {
|
|
358645
358791
|
if (o.to === null) delete out.to;
|
|
358646
|
-
else out.to = markerOrThrow(
|
|
358792
|
+
else out.to = markerOrThrow(frame3, o.to);
|
|
358647
358793
|
}
|
|
358648
358794
|
if (o.loop !== void 0) {
|
|
358649
358795
|
if (o.loop) out.loop = true;
|
|
@@ -358825,7 +358971,7 @@ var init_motion_machine = __esm({
|
|
|
358825
358971
|
};
|
|
358826
358972
|
opsOf = (p2) => p2.ops ?? (p2.op ? [p2.op] : []);
|
|
358827
358973
|
opsLabel = (ops2) => ops2.length && ops2.every((o) => o.kind === ops2[0].kind) ? OP_LABELS2[ops2[0].kind] : "Edit state machine";
|
|
358828
|
-
frameTimelineOf = (
|
|
358974
|
+
frameTimelineOf = (frame3) => frame3.timeline ?? { duration: 0 };
|
|
358829
358975
|
stateRef = (sm, key5, allowAny = false) => allowAny && key5 === ANY_STATE ? ANY_STATE : pick4(sm.states, key5, "state").id;
|
|
358830
358976
|
motionEditStateMachine = defineCommand({
|
|
358831
358977
|
id: "motion.editStateMachine",
|
|
@@ -358852,22 +358998,22 @@ var init_motion_machine = __esm({
|
|
|
358852
358998
|
const doc2 = ctx2.doc();
|
|
358853
358999
|
const at4 = args2.id ?? ctx2.selection()[0];
|
|
358854
359000
|
if (!at4) throw new ToolError("edit_state_machine needs the frame (id) or a selection.");
|
|
358855
|
-
const
|
|
359001
|
+
const frame3 = frameOrThrow(doc2, at4);
|
|
358856
359002
|
if (!!args2.op === !!args2.ops) throw new ToolError("edit_state_machine takes op or ops (not both).");
|
|
358857
359003
|
const ops2 = opsOf(args2);
|
|
358858
|
-
let next2 = machineOf(
|
|
359004
|
+
let next2 = machineOf(frame3);
|
|
358859
359005
|
const added = [];
|
|
358860
359006
|
for (const op4 of ops2) {
|
|
358861
|
-
const r = applyOp(
|
|
359007
|
+
const r = applyOp(frame3, next2 ?? void 0, op4);
|
|
358862
359008
|
next2 = r.next;
|
|
358863
359009
|
if (r.added) added.push(r.added);
|
|
358864
359010
|
}
|
|
358865
|
-
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[
|
|
358866
|
-
const sm = machineOf(ctx2.doc().nodes[
|
|
359011
|
+
commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[frame3.id, { stateMachine: next2 ?? void 0 }]]));
|
|
359012
|
+
const sm = machineOf(ctx2.doc().nodes[frame3.id]);
|
|
358867
359013
|
const label3 = opsLabel(ops2);
|
|
358868
359014
|
return {
|
|
358869
359015
|
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:
|
|
359016
|
+
data: { id: frame3.id, ...added.length ? { added: added[added.length - 1], addedAll: added } : {}, ...sm ? { stateMachine: sm } : {} }
|
|
358871
359017
|
};
|
|
358872
359018
|
}
|
|
358873
359019
|
});
|
|
@@ -358889,16 +359035,16 @@ var init_motion_machine = __esm({
|
|
|
358889
359035
|
const doc2 = ctx2.doc();
|
|
358890
359036
|
const at4 = args2.id ?? ctx2.selection()[0];
|
|
358891
359037
|
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,
|
|
359038
|
+
const frame3 = frameOrThrow(doc2, at4);
|
|
359039
|
+
const sm = machineOf(frame3);
|
|
359040
|
+
const tl = frameTimeline(doc2.nodes, frame3.id);
|
|
358895
359041
|
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,
|
|
359042
|
+
if (!sm) return { summary: `"${frame3.name}" has no state machine`, data: { id: frame3.id, stateMachine: null, markers } };
|
|
359043
|
+
const duration3 = timelineDuration(doc2.nodes, frame3.id);
|
|
358898
359044
|
const states = sortedValues(sm.states).map((s) => ({ ...s, stretch: stateStretch(s, tl, duration3) }));
|
|
358899
359045
|
return {
|
|
358900
359046
|
summary: `"${sm.name}": ${plural2(states.length, "state")}, ${plural2(Object.keys(sm.inputs).length, "input")}, ${plural2(Object.keys(sm.listeners).length, "listener")}`,
|
|
358901
|
-
data: { id:
|
|
359047
|
+
data: { id: frame3.id, stateMachine: { ...sm, states, transitions: sortedValues(sm.transitions), inputs: sortedValues(sm.inputs), listeners: sortedValues(sm.listeners) }, markers }
|
|
358902
359048
|
};
|
|
358903
359049
|
}
|
|
358904
359050
|
});
|
|
@@ -359267,7 +359413,7 @@ function placeVideoScene(doc2, pageId2, compositionId2, file2, intoId) {
|
|
|
359267
359413
|
if (!comp || !doc2.nodes[pageId2]) return null;
|
|
359268
359414
|
const durationMs = Math.max(1, Math.round(file2.durationMs));
|
|
359269
359415
|
const at4 = nextScenePosition(doc2, pageId2);
|
|
359270
|
-
const
|
|
359416
|
+
const frame3 = createFrame({
|
|
359271
359417
|
name: file2.name,
|
|
359272
359418
|
...at4,
|
|
359273
359419
|
width: comp.width,
|
|
@@ -359275,26 +359421,26 @@ function placeVideoScene(doc2, pageId2, compositionId2, file2, intoId) {
|
|
|
359275
359421
|
fills: [{ type: "SOLID", color: comp.background ?? { r: 0, g: 0, b: 0, a: 1 }, visible: true }],
|
|
359276
359422
|
timeline: { duration: durationMs, fps: comp.fps }
|
|
359277
359423
|
});
|
|
359278
|
-
let next2 = addNode(doc2,
|
|
359424
|
+
let next2 = addNode(doc2, frame3, pageId2);
|
|
359279
359425
|
let nodeId2;
|
|
359280
359426
|
const existing = intoId ? next2.nodes[intoId] : void 0;
|
|
359281
359427
|
if (existing) {
|
|
359282
359428
|
const oldParent = existing.parentId ? next2.nodes[existing.parentId] : void 0;
|
|
359283
359429
|
const nodes = { ...next2.nodes };
|
|
359284
359430
|
if (oldParent) nodes[oldParent.id] = { ...oldParent, childIds: oldParent.childIds.filter((c2) => c2 !== existing.id) };
|
|
359285
|
-
nodes[
|
|
359286
|
-
nodes[existing.id] = { ...existing, parentId:
|
|
359431
|
+
nodes[frame3.id] = { ...nodes[frame3.id], childIds: [...nodes[frame3.id].childIds, existing.id] };
|
|
359432
|
+
nodes[existing.id] = { ...existing, parentId: frame3.id, x: 0, y: 0, width: comp.width, height: comp.height, rotation: 0 };
|
|
359287
359433
|
next2 = fillWithVideo({ ...next2, nodes }, existing.id, file2);
|
|
359288
359434
|
nodeId2 = existing.id;
|
|
359289
359435
|
} else {
|
|
359290
|
-
const placed2 = placeVideoLayer(next2,
|
|
359436
|
+
const placed2 = placeVideoLayer(next2, frame3.id, file2, { cx: comp.width / 2, cy: comp.height / 2, width: comp.width, height: comp.height });
|
|
359291
359437
|
next2 = placed2.doc;
|
|
359292
359438
|
nodeId2 = placed2.nodeId;
|
|
359293
359439
|
}
|
|
359294
|
-
const withClip = addClip(comp,
|
|
359440
|
+
const withClip = addClip(comp, frame3.id, durationMs);
|
|
359295
359441
|
const clipId = withClip.clips.find((c2) => !comp.clips.some((o) => o.id === c2.id))?.id ?? "";
|
|
359296
359442
|
next2 = repairDocumentCompositions({ ...next2, compositions: { ...next2.compositions, [comp.id]: withClip } });
|
|
359297
|
-
return { doc: next2, frameId:
|
|
359443
|
+
return { doc: next2, frameId: frame3.id, nodeId: nodeId2, clipId };
|
|
359298
359444
|
}
|
|
359299
359445
|
var init_media_placement = __esm({
|
|
359300
359446
|
"lib/ai/media-placement.ts"() {
|
|
@@ -360290,10 +360436,10 @@ async function placePicture(imported, opts = {}) {
|
|
|
360290
360436
|
Promise.resolve().then(() => (init_media_tool(), media_tool_exports))
|
|
360291
360437
|
]);
|
|
360292
360438
|
const st = useEditorStore2.getState();
|
|
360293
|
-
const
|
|
360294
|
-
if (
|
|
360295
|
-
st.fillPhotoFrame(
|
|
360296
|
-
return
|
|
360439
|
+
const frame3 = photoFrameOf2(st.document.nodes, opts.targetId !== void 0 ? opts.targetId : st.selection[0] ?? null);
|
|
360440
|
+
if (frame3) {
|
|
360441
|
+
st.fillPhotoFrame(frame3.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit);
|
|
360442
|
+
return frame3.id;
|
|
360297
360443
|
}
|
|
360298
360444
|
const point2 = opts.at ?? { x: st.camera.x, y: st.camera.y };
|
|
360299
360445
|
return placeImage2(imported.ref, { w: imported.width, h: imported.height }, { kind: "point", ...point2 }, { name: imported.name, ...imported.credit ? { credit: imported.credit } : {} });
|
|
@@ -360323,10 +360469,10 @@ async function placeImportedPicture(ctx2, imported, at4, what, extra = {}) {
|
|
|
360323
360469
|
if (at4.fillLayerId) {
|
|
360324
360470
|
const doc2 = ctx2.doc();
|
|
360325
360471
|
const target2 = nodeOrThrow(doc2, at4.fillLayerId);
|
|
360326
|
-
const
|
|
360327
|
-
if (
|
|
360328
|
-
ctx2.commit(fillPhotoFrame(doc2,
|
|
360329
|
-
return { summary: `Filled photo frame \u201C${
|
|
360472
|
+
const frame3 = photoFrameOf(doc2.nodes, target2.id);
|
|
360473
|
+
if (frame3) {
|
|
360474
|
+
ctx2.commit(fillPhotoFrame(doc2, frame3.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit));
|
|
360475
|
+
return { summary: `Filled photo frame \u201C${frame3.name}\u201D with ${what}`, data: { id: frame3.id, ...extra } };
|
|
360330
360476
|
}
|
|
360331
360477
|
if (!("fills" in target2)) throw new ToolError(`\u201C${target2.name}\u201D has no fills to put a picture in.`);
|
|
360332
360478
|
const fill = client.photoFill({ type: "IMAGE", visible: true, opacity: 1 }, imported);
|
|
@@ -360809,11 +360955,11 @@ var init_prototype = __esm({
|
|
|
360809
360955
|
const patches = /* @__PURE__ */ new Map();
|
|
360810
360956
|
for (const id3 of ids2) {
|
|
360811
360957
|
const node2 = doc2.nodes[id3];
|
|
360812
|
-
const
|
|
360958
|
+
const patch2 = {};
|
|
360813
360959
|
if (replace || add3.length || args2.removeInteractions) {
|
|
360814
360960
|
const drop = new Set(args2.removeInteractions ?? []);
|
|
360815
360961
|
const next2 = [...(replace ?? node2.interactions ?? []).filter((ix) => !drop.has(ix.id)), ...add3];
|
|
360816
|
-
|
|
360962
|
+
patch2.interactions = next2.length ? next2 : void 0;
|
|
360817
360963
|
}
|
|
360818
360964
|
if (args2.liveValues) {
|
|
360819
360965
|
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 +360968,10 @@ var init_prototype = __esm({
|
|
|
360822
360968
|
if (src) bound[prop] = src;
|
|
360823
360969
|
else delete bound[prop];
|
|
360824
360970
|
}
|
|
360825
|
-
|
|
360971
|
+
patch2.boundExpressions = Object.keys(bound).length ? bound : void 0;
|
|
360826
360972
|
}
|
|
360827
|
-
if (args2.sharedElement !== void 0)
|
|
360828
|
-
patches.set(id3,
|
|
360973
|
+
if (args2.sharedElement !== void 0) patch2.sharedElement = args2.sharedElement || void 0;
|
|
360974
|
+
patches.set(id3, patch2);
|
|
360829
360975
|
}
|
|
360830
360976
|
commitUpdates(ctx2, doc2, patches);
|
|
360831
360977
|
return { summary: `Edited the prototype on ${ids2.length === 1 ? "1 layer" : `${ids2.length} layers`}`, data: { ids: ids2 } };
|
|
@@ -367165,7 +367311,6 @@ var init_doc2 = __esm({
|
|
|
367165
367311
|
var POSTER_KEY, MAX_PREVIEW_BYTES2, PREVIEW_STILL_TYPE, previewPath;
|
|
367166
367312
|
var init_motion3 = __esm({
|
|
367167
367313
|
"lib/marketplace/motion.ts"() {
|
|
367168
|
-
"use strict";
|
|
367169
367314
|
init_instances2();
|
|
367170
367315
|
POSTER_KEY = "poster";
|
|
367171
367316
|
MAX_PREVIEW_BYTES2 = 4 * 1024 * 1024;
|
|
@@ -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.1";
|
|
413363
413508
|
var HELP = `popcraft ${VERSION2} \u2014 the PopCraft command line
|
|
413364
413509
|
|
|
413365
413510
|
Files (headless, on .popcraft files):
|