editorbrain 0.40.1 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/editorbrain.mjs +2126 -585
- package/package.json +1 -1
- package/skill/editorbrain/SKILL.md +1 -1
- package/skill/editorbrain/references/cli-mcp.md +4 -0
- package/skill/editorbrain/references/editorial-evidence.md +2 -0
- package/skill/editorbrain/references/style-source.md +61 -0
- package/skill/editorbrain-motion/SKILL.md +4 -0
package/bin/editorbrain.mjs
CHANGED
|
@@ -1,113 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// packages/cli/src/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return typeof v === "string" ? v : void 0;
|
|
8
|
-
};
|
|
9
|
-
const required = (key) => {
|
|
10
|
-
const v = value(key);
|
|
11
|
-
if (!v) throw new Error(`Missing --${key}`);
|
|
12
|
-
return v;
|
|
13
|
-
};
|
|
14
|
-
const common = ["url", "dir"];
|
|
15
|
-
const allowed = {
|
|
16
|
-
access: [],
|
|
17
|
-
members: [],
|
|
18
|
-
projects: [],
|
|
19
|
-
invite: ["email", "kind", "scope"],
|
|
20
|
-
cancel: ["id"],
|
|
21
|
-
remove: ["user", "confirm"],
|
|
22
|
-
reviews: ["project", "after"],
|
|
23
|
-
share: ["project", "revision", "confirm"],
|
|
24
|
-
withdraw: ["project", "revision", "confirm"],
|
|
25
|
-
comment: ["project", "revision", "context-version", "text", "at-ms", "id"],
|
|
26
|
-
approve: ["project", "revision", "context-version", "user-confirmed"]
|
|
27
|
-
};
|
|
28
|
-
if (!subcommand || !allowed[subcommand])
|
|
29
|
-
throw new Error(
|
|
30
|
-
"Use team access|members|projects|invite|cancel|remove|reviews|share|withdraw|comment|approve."
|
|
31
|
-
);
|
|
32
|
-
for (const key of Object.keys(flags))
|
|
33
|
-
if (!common.includes(key) && !allowed[subcommand].includes(key))
|
|
34
|
-
throw new Error(`--${key} is not supported for team ${subcommand}.`);
|
|
35
|
-
if (subcommand === "access") return client.request("/v1/team");
|
|
36
|
-
if (["members", "projects"].includes(subcommand))
|
|
37
|
-
return client.request("/v1/team/" + subcommand);
|
|
38
|
-
if (subcommand === "invite") {
|
|
39
|
-
const kind = required("kind");
|
|
40
|
-
if (!["brand_editor", "project_reviewer"].includes(kind))
|
|
41
|
-
throw new Error("Use --kind brand_editor or project_reviewer.");
|
|
42
|
-
return client.request("/v1/team/invitations", {
|
|
43
|
-
method: "POST",
|
|
44
|
-
body: { email: required("email"), kind, scopeId: required("scope") }
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
if (subcommand === "cancel")
|
|
48
|
-
return client.request(
|
|
49
|
-
"/v1/team/invitations/" + encodeURIComponent(required("id")),
|
|
50
|
-
{ method: "DELETE" }
|
|
51
|
-
);
|
|
52
|
-
if (subcommand === "remove") {
|
|
53
|
-
if (flags.confirm !== true)
|
|
54
|
-
throw new Error(
|
|
55
|
-
"Removing access requires --confirm after the user requests removal. Files are preserved."
|
|
56
|
-
);
|
|
57
|
-
return client.request(
|
|
58
|
-
"/v1/team/members/" + encodeURIComponent(required("user")),
|
|
59
|
-
{ method: "DELETE" }
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
const base = "/v1/team/projects/" + encodeURIComponent(required("project")) + "/reviews";
|
|
63
|
-
if (subcommand === "reviews")
|
|
64
|
-
return client.request(
|
|
65
|
-
base + (value("after") ? "?after=" + encodeURIComponent(value("after")) : "")
|
|
66
|
-
);
|
|
67
|
-
const revision2 = required("revision");
|
|
68
|
-
if (!/^[a-f0-9-]{36}$/.test(revision2))
|
|
69
|
-
throw new Error("Use the exact revision UUID returned by team reviews.");
|
|
70
|
-
if (["share", "withdraw"].includes(subcommand)) {
|
|
71
|
-
if (flags.confirm !== true)
|
|
72
|
-
throw new Error(
|
|
73
|
-
"Use --confirm for an explicitly requested sharing change."
|
|
74
|
-
);
|
|
75
|
-
return client.request(base + "/" + revision2 + "/share", {
|
|
76
|
-
method: "POST",
|
|
77
|
-
body: { shared: subcommand === "share" }
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const contextVersion = required("context-version");
|
|
81
|
-
if (!/^[a-f0-9]{64}$/.test(contextVersion))
|
|
82
|
-
throw new Error("Use the exact context hash of the reviewed sample.");
|
|
83
|
-
if (subcommand === "approve") {
|
|
84
|
-
if (flags["user-confirmed"] !== true)
|
|
85
|
-
throw new Error(
|
|
86
|
-
"Approval requires explicit user acceptance and --user-confirmed."
|
|
87
|
-
);
|
|
88
|
-
return client.request(base + "/" + revision2 + "/approve", {
|
|
89
|
-
method: "POST",
|
|
90
|
-
body: { contextVersion, userConfirmed: true }
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const at = value("at-ms"), startMs = at === void 0 ? void 0 : Number(at);
|
|
94
|
-
if (startMs !== void 0 && (!Number.isSafeInteger(startMs) || startMs < 0 || startMs > 36e6))
|
|
95
|
-
throw new Error("--at-ms must be an integer between 0 and 36000000.");
|
|
96
|
-
const feedbackId = required("id");
|
|
97
|
-
if (!/^[a-f0-9-]{36}$/.test(feedbackId))
|
|
98
|
-
throw new Error(
|
|
99
|
-
"Use --id with a fresh UUID; reuse it for retries of this exact comment."
|
|
100
|
-
);
|
|
101
|
-
return client.request(base + "/" + revision2 + "/comment", {
|
|
102
|
-
method: "POST",
|
|
103
|
-
body: {
|
|
104
|
-
contextVersion,
|
|
105
|
-
feedbackId,
|
|
106
|
-
text: required("text"),
|
|
107
|
-
target: startMs === void 0 ? {} : { startMs }
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
3
|
+
// packages/cli/src/style-sources.ts
|
|
4
|
+
import { constants as constants2 } from "node:fs";
|
|
5
|
+
import { open as open3, mkdir as mkdir3, writeFile, rm } from "node:fs/promises";
|
|
6
|
+
import { dirname as dirname3 } from "node:path";
|
|
111
7
|
|
|
112
8
|
// packages/core/src/editorial-learning.ts
|
|
113
9
|
var learningCategories = ["captions", "cuts", "layout", "motion", "media", "sound", "color", "story", "other"];
|
|
@@ -181575,6 +181471,339 @@ function getPersonalResourceGuide() {
|
|
|
181575
181471
|
return { schemaVersion: 1, optional: true, createsResources: false, notice: "Suggestions are not uploaded assets or confirmed customer preferences. Select only relevant examples, then use real customer files and editable usage guidance. Do not require every slot or upload.", starters: resourceStarters };
|
|
181576
181472
|
}
|
|
181577
181473
|
|
|
181474
|
+
// packages/core/src/style-source-data-v1.ts
|
|
181475
|
+
var styleSourceData = [
|
|
181476
|
+
{
|
|
181477
|
+
"id": "comando-y-resultado",
|
|
181478
|
+
"name": "Comando y resultado",
|
|
181479
|
+
"summary": "Cada instrucci\xF3n aparece como tarjeta y se convierte en su resultado frente a quien habla.",
|
|
181480
|
+
"needs": [
|
|
181481
|
+
"tu clip hablando a c\xE1mara",
|
|
181482
|
+
"las im\xE1genes de cada resultado"
|
|
181483
|
+
],
|
|
181484
|
+
"sourceVersion": "1.0.0",
|
|
181485
|
+
"sourceSha256": "5851f934ff5450056ea3032999cb5c244dbd1fd1ec90e2d33cf0ae804ac58c88",
|
|
181486
|
+
"sourceBytes": 53379860,
|
|
181487
|
+
"fileCount": 74,
|
|
181488
|
+
"unpackedBytes": 58695062,
|
|
181489
|
+
"requiredPlan": "creator",
|
|
181490
|
+
"ratio": "tall",
|
|
181491
|
+
"demoSha256": "85e71c00e290105304d21bacb17108892a82483f78eb4d3d601fb6008dc15571"
|
|
181492
|
+
},
|
|
181493
|
+
{
|
|
181494
|
+
"id": "narrador-sobre-collage",
|
|
181495
|
+
"name": "Narrador sobre collage de im\xE1genes",
|
|
181496
|
+
"summary": "Una imagen nueva a sangre por cada idea, con quien narra recortado y cambiando de lugar.",
|
|
181497
|
+
"needs": [
|
|
181498
|
+
"tu clip hablando a c\xE1mara (mejor con fondo liso)",
|
|
181499
|
+
"15\u201320 im\xE1genes"
|
|
181500
|
+
],
|
|
181501
|
+
"sourceVersion": "1.0.0",
|
|
181502
|
+
"sourceSha256": "a1df048358ba37a23fd723fb0178c381da399ed40ddc0a81bc0109292aa5d083",
|
|
181503
|
+
"sourceBytes": 67824224,
|
|
181504
|
+
"fileCount": 87,
|
|
181505
|
+
"unpackedBytes": 73121837,
|
|
181506
|
+
"requiredPlan": "creator",
|
|
181507
|
+
"ratio": "tall",
|
|
181508
|
+
"demoSha256": "8634d6e1cc0274dcd8660f8f17b9fc4a249fd8aea077ef99826c4ed06dda1eb7"
|
|
181509
|
+
},
|
|
181510
|
+
{
|
|
181511
|
+
"id": "presentador-con-interfaz",
|
|
181512
|
+
"name": "Presentador con escenario de interfaz",
|
|
181513
|
+
"summary": "Arriba, interfaces animadas que ejecutan cada funci\xF3n; abajo, quien presenta.",
|
|
181514
|
+
"needs": [
|
|
181515
|
+
"tu clip hablando a c\xE1mara",
|
|
181516
|
+
"las funciones de tu producto (la interfaz se dibuja)"
|
|
181517
|
+
],
|
|
181518
|
+
"sourceVersion": "1.0.0",
|
|
181519
|
+
"sourceSha256": "aa7d0a61aa3794139ac16a929bf0929b92b1c24f7e54cdcde155fbc2905de476",
|
|
181520
|
+
"sourceBytes": 36093673,
|
|
181521
|
+
"fileCount": 67,
|
|
181522
|
+
"unpackedBytes": 41512815,
|
|
181523
|
+
"requiredPlan": "creator",
|
|
181524
|
+
"ratio": "tall",
|
|
181525
|
+
"demoSha256": "b7785f6a59683068041d2256851ca52e19454d34bf73fee137e83f1fc8091c87"
|
|
181526
|
+
},
|
|
181527
|
+
{
|
|
181528
|
+
"id": "ensayo-cinematografico",
|
|
181529
|
+
"name": "Ensayo cinematogr\xE1fico con tarjetas tipogr\xE1ficas",
|
|
181530
|
+
"summary": "Planos de cine, tarjetas tipogr\xE1ficas que se revelan palabra por palabra y regresos a c\xE1mara.",
|
|
181531
|
+
"needs": [
|
|
181532
|
+
"tu clip hablando a c\xE1mara",
|
|
181533
|
+
"6\u201310 planos de B-roll"
|
|
181534
|
+
],
|
|
181535
|
+
"sourceVersion": "1.0.0",
|
|
181536
|
+
"sourceSha256": "90f137ecc841067226c0b97a44e50440e3bd9a3d367b3dc177c5560ec90ccef0",
|
|
181537
|
+
"sourceBytes": 67266840,
|
|
181538
|
+
"fileCount": 86,
|
|
181539
|
+
"unpackedBytes": 72343103,
|
|
181540
|
+
"requiredPlan": "creator",
|
|
181541
|
+
"ratio": "tall",
|
|
181542
|
+
"demoSha256": "88861691ca215075aa9f4d4e5258f42a776ca1fdd2e4a50d399f7c519f3a1cb5"
|
|
181543
|
+
},
|
|
181544
|
+
{
|
|
181545
|
+
"id": "tutorial-por-capitulos",
|
|
181546
|
+
"name": "Tutorial por cap\xEDtulos con capturas",
|
|
181547
|
+
"summary": "Numeral gigante por cap\xEDtulo, la interfaz con zoom al prompt y el resultado en pantalla.",
|
|
181548
|
+
"needs": [
|
|
181549
|
+
"tu clip hablando a c\xE1mara",
|
|
181550
|
+
"capturas o la interfaz de tu herramienta"
|
|
181551
|
+
],
|
|
181552
|
+
"sourceVersion": "1.0.0",
|
|
181553
|
+
"sourceSha256": "774fe0cd40423e050430b5ef463ca4b374dbef9ded6da3437809af218866827a",
|
|
181554
|
+
"sourceBytes": 63896838,
|
|
181555
|
+
"fileCount": 67,
|
|
181556
|
+
"unpackedBytes": 69296736,
|
|
181557
|
+
"requiredPlan": "creator",
|
|
181558
|
+
"ratio": "tall",
|
|
181559
|
+
"demoSha256": "e7e5cc8f851de24acb976839c2ce9f196908796cbefbb8ffce1c0a90e4581720"
|
|
181560
|
+
},
|
|
181561
|
+
{
|
|
181562
|
+
"id": "tablero-que-se-llena",
|
|
181563
|
+
"name": "Tablero que se llena",
|
|
181564
|
+
"summary": "Un ranking por niveles que se llena mientras opinas, en una sola toma.",
|
|
181565
|
+
"needs": [
|
|
181566
|
+
"tu clip hablando a c\xE1mara en una toma",
|
|
181567
|
+
"los \xEDconos de cada \xEDtem"
|
|
181568
|
+
],
|
|
181569
|
+
"sourceVersion": "1.0.0",
|
|
181570
|
+
"sourceSha256": "122386757e9706a1725def3c5080b67053241949ed87336889d49a073c6c029f",
|
|
181571
|
+
"sourceBytes": 71615105,
|
|
181572
|
+
"fileCount": 70,
|
|
181573
|
+
"unpackedBytes": 81577587,
|
|
181574
|
+
"requiredPlan": "creator",
|
|
181575
|
+
"ratio": "tall",
|
|
181576
|
+
"demoSha256": "40ec0c80a2fec5ffb4eb822f71717c44987ac0d6a8aacd1fa189830e4a5f2cd5"
|
|
181577
|
+
},
|
|
181578
|
+
{
|
|
181579
|
+
"id": "explicador-con-evidencias",
|
|
181580
|
+
"name": "Explicador editorial con evidencias",
|
|
181581
|
+
"summary": "Tu argumento sostenido con documentos, fotos de archivo y resaltados sobre papel.",
|
|
181582
|
+
"needs": [
|
|
181583
|
+
"tu clip de cuerpo completo (mejor con fondo liso)",
|
|
181584
|
+
"im\xE1genes y documentos"
|
|
181585
|
+
],
|
|
181586
|
+
"sourceVersion": "1.0.0",
|
|
181587
|
+
"sourceSha256": "fd56bdc3f5039b3cf15dbde54a413ee4688b0724bb3de9bc04d836b1183df29f",
|
|
181588
|
+
"sourceBytes": 28347758,
|
|
181589
|
+
"fileCount": 76,
|
|
181590
|
+
"unpackedBytes": 33672572,
|
|
181591
|
+
"requiredPlan": "creator",
|
|
181592
|
+
"ratio": "tall",
|
|
181593
|
+
"demoSha256": "34714b3a1051399ff7021e323c1819da3931e01709f201b86f0224fc12b0bc3b"
|
|
181594
|
+
},
|
|
181595
|
+
{
|
|
181596
|
+
"id": "monologo-con-dipticos",
|
|
181597
|
+
"name": "Mon\xF3logo con d\xEDpticos",
|
|
181598
|
+
"summary": "Una toma fija sin cortes: titular arriba y un par de im\xE1genes por cada frase.",
|
|
181599
|
+
"needs": [
|
|
181600
|
+
"tu clip hablando a c\xE1mara en una toma",
|
|
181601
|
+
"dos im\xE1genes por frase"
|
|
181602
|
+
],
|
|
181603
|
+
"sourceVersion": "1.0.0",
|
|
181604
|
+
"sourceSha256": "bf4a3942f416e2828ece822bf1d647bfdb7bd876204b711c1a76f688ac4e7f44",
|
|
181605
|
+
"sourceBytes": 71193505,
|
|
181606
|
+
"fileCount": 94,
|
|
181607
|
+
"unpackedBytes": 76379034,
|
|
181608
|
+
"requiredPlan": "creator",
|
|
181609
|
+
"ratio": "tall",
|
|
181610
|
+
"demoSha256": "0081ff2bfd67f74f5b8cd7e0d17368d048e9a2e303a8755a6fced7ca368e613c"
|
|
181611
|
+
},
|
|
181612
|
+
{
|
|
181613
|
+
"id": "recorrido-de-experto",
|
|
181614
|
+
"name": "Recorrido de experto con lugar secreto",
|
|
181615
|
+
"summary": "Autoridad, un lugar secreto que se revela al final y planos exactos de cada parada.",
|
|
181616
|
+
"needs": [
|
|
181617
|
+
"tu clip hablando a c\xE1mara",
|
|
181618
|
+
"clips de cada lugar"
|
|
181619
|
+
],
|
|
181620
|
+
"sourceVersion": "1.0.0",
|
|
181621
|
+
"sourceSha256": "34ddef4f4f9d2cc5cee268b9c967fcb4a45f40455676fcd9cf2c7430d279ab5e",
|
|
181622
|
+
"sourceBytes": 123413427,
|
|
181623
|
+
"fileCount": 80,
|
|
181624
|
+
"unpackedBytes": 128824268,
|
|
181625
|
+
"requiredPlan": "creator",
|
|
181626
|
+
"ratio": "tall",
|
|
181627
|
+
"demoSha256": "fefae76bcb80d3ce2b2a05055bf2c68bb26ec52b307ae4ca09714063fb03c612"
|
|
181628
|
+
},
|
|
181629
|
+
{
|
|
181630
|
+
"id": "vlog-intimo",
|
|
181631
|
+
"name": "Vlog \xEDntimo con texto en escena",
|
|
181632
|
+
"summary": "Una historia personal con palabras que viven en el espacio y papel en stop-motion.",
|
|
181633
|
+
"needs": [
|
|
181634
|
+
"tu clip hablando a c\xE1mara",
|
|
181635
|
+
"clips de tu d\xEDa"
|
|
181636
|
+
],
|
|
181637
|
+
"sourceVersion": "1.0.0",
|
|
181638
|
+
"sourceSha256": "70ac7e126ab03993e39cdc3e2783fdd2143890fbb160b5a3b3663fef899e170a",
|
|
181639
|
+
"sourceBytes": 95858671,
|
|
181640
|
+
"fileCount": 73,
|
|
181641
|
+
"unpackedBytes": 100794739,
|
|
181642
|
+
"requiredPlan": "creator",
|
|
181643
|
+
"ratio": "tall",
|
|
181644
|
+
"demoSha256": "6222934f0b081b847811ed8d86bacdd3f66bd88364594ccf5649e944f9e2c7cf"
|
|
181645
|
+
},
|
|
181646
|
+
{
|
|
181647
|
+
"id": "documental-de-archivo",
|
|
181648
|
+
"name": "Documental tipogr\xE1fico de archivo",
|
|
181649
|
+
"summary": "R\xE1fagas de archivo y cifras gigantes detr\xE1s de las figuras, como un tr\xE1iler.",
|
|
181650
|
+
"needs": [
|
|
181651
|
+
"un clip breve hablando a c\xE1mara",
|
|
181652
|
+
"fotos de archivo"
|
|
181653
|
+
],
|
|
181654
|
+
"sourceVersion": "1.0.0",
|
|
181655
|
+
"sourceSha256": "f0c33ebc14d1d929c29850e932477922f29d29228489dcbb9838aea79de9dbc9",
|
|
181656
|
+
"sourceBytes": 28620760,
|
|
181657
|
+
"fileCount": 80,
|
|
181658
|
+
"unpackedBytes": 33907182,
|
|
181659
|
+
"requiredPlan": "creator",
|
|
181660
|
+
"ratio": "tall",
|
|
181661
|
+
"demoSha256": "476c428bde32ad9bbee30fb799ff0ee91642021740aef05f1af0dee6fca598d7"
|
|
181662
|
+
},
|
|
181663
|
+
{
|
|
181664
|
+
"id": "catalogo-editorial",
|
|
181665
|
+
"name": "Cat\xE1logo editorial animado",
|
|
181666
|
+
"summary": "Sin c\xE1mara: l\xE1minas y diagramas que se acumulan hasta revelar tu recurso descargable.",
|
|
181667
|
+
"needs": [
|
|
181668
|
+
"tu voz (o un texto para narrar)",
|
|
181669
|
+
"tu recurso o documento"
|
|
181670
|
+
],
|
|
181671
|
+
"sourceVersion": "1.0.0",
|
|
181672
|
+
"sourceSha256": "8e1de45eb58407b8a221d6ef115e53fdd49b00febe2b0962c1ef6d1fc15eb7c5",
|
|
181673
|
+
"sourceBytes": 4869367,
|
|
181674
|
+
"fileCount": 64,
|
|
181675
|
+
"unpackedBytes": 9096082,
|
|
181676
|
+
"requiredPlan": "creator",
|
|
181677
|
+
"ratio": "tall",
|
|
181678
|
+
"demoSha256": "109458de45085b7406b8f37ad2e355faa365fd8aa98d6035824806f7a562c3a9"
|
|
181679
|
+
},
|
|
181680
|
+
{
|
|
181681
|
+
"id": "pantalla-fisica",
|
|
181682
|
+
"name": "Explicaci\xF3n sobre pantalla f\xEDsica",
|
|
181683
|
+
"summary": "Una mano recorre una pantalla real con tu proceso; cifras y r\xF3tulos gu\xEDan cada paso.",
|
|
181684
|
+
"needs": [
|
|
181685
|
+
"tu voz",
|
|
181686
|
+
"un video de tu pantalla o tablet con el diagrama"
|
|
181687
|
+
],
|
|
181688
|
+
"sourceVersion": "1.0.0",
|
|
181689
|
+
"sourceSha256": "2a21e544ca62e06a8896cbd042502277621554d7a6e8aeb83f36ad12454c92fd",
|
|
181690
|
+
"sourceBytes": 24317144,
|
|
181691
|
+
"fileCount": 70,
|
|
181692
|
+
"unpackedBytes": 28553643,
|
|
181693
|
+
"requiredPlan": "creator",
|
|
181694
|
+
"ratio": "tall",
|
|
181695
|
+
"demoSha256": "77a7568e9e0426e89d3be9fbdb7d3b4eea82b9f9161af7c08f6f4c591f9e8f9c"
|
|
181696
|
+
},
|
|
181697
|
+
{
|
|
181698
|
+
"id": "personaje-en-papel",
|
|
181699
|
+
"name": "Personaje animado en escenario de papel",
|
|
181700
|
+
"summary": "T\xFA como personaje dibujado que ejecuta cada paso sobre un escenario de papel.",
|
|
181701
|
+
"needs": [
|
|
181702
|
+
"tu voz",
|
|
181703
|
+
"fotos de tu cara con varias expresiones"
|
|
181704
|
+
],
|
|
181705
|
+
"sourceVersion": "1.0.0",
|
|
181706
|
+
"sourceSha256": "ef7d6fc8886d130ad291f537e4d4587aa6c55770c146263ccd59a0c223cd3876",
|
|
181707
|
+
"sourceBytes": 15275734,
|
|
181708
|
+
"fileCount": 77,
|
|
181709
|
+
"unpackedBytes": 19549031,
|
|
181710
|
+
"requiredPlan": "creator",
|
|
181711
|
+
"ratio": "tall",
|
|
181712
|
+
"demoSha256": "2268da8622070fac6d5c8fa9270e1a964d9e06259c557fd16cd868bb22169495"
|
|
181713
|
+
},
|
|
181714
|
+
{
|
|
181715
|
+
"id": "simulacion-en-el-mapa",
|
|
181716
|
+
"name": "Simulaci\xF3n en el mapa",
|
|
181717
|
+
"summary": "\xBFQu\xE9 pasar\xEDa si\u2026? contado sobre un globo 3D: el territorio cambia, las p\xE9rdidas se acumulan en pantalla.",
|
|
181718
|
+
"needs": [
|
|
181719
|
+
"tu voz",
|
|
181720
|
+
"una hip\xF3tesis y sus consecuencias con cifras"
|
|
181721
|
+
],
|
|
181722
|
+
"sourceVersion": "1.0.0",
|
|
181723
|
+
"sourceSha256": "2205ae641895f8435ca1e4457f52e23ba8291167e67aefbabf3eb2cd61e2b42e",
|
|
181724
|
+
"sourceBytes": 22728621,
|
|
181725
|
+
"fileCount": 71,
|
|
181726
|
+
"unpackedBytes": 27474023,
|
|
181727
|
+
"requiredPlan": "creator",
|
|
181728
|
+
"ratio": "tall",
|
|
181729
|
+
"demoSha256": "5cb48759829518bf0982927fcd42767936b188c837bead7aeb251003999c866d"
|
|
181730
|
+
},
|
|
181731
|
+
{
|
|
181732
|
+
"id": "relato-ilustrado",
|
|
181733
|
+
"name": "Relato ilustrado en segunda persona",
|
|
181734
|
+
"summary": "Una historia de tensi\xF3n en ilustraciones: reloj, reglas, contador y cliffhanger.",
|
|
181735
|
+
"needs": [
|
|
181736
|
+
"tu voz",
|
|
181737
|
+
"ilustraciones de un mismo personaje y escenario"
|
|
181738
|
+
],
|
|
181739
|
+
"sourceVersion": "1.0.0",
|
|
181740
|
+
"sourceSha256": "98d12af2729f0080b2383314d0a1c74df4e538a24224013ee3db6258d2b441c4",
|
|
181741
|
+
"sourceBytes": 25173445,
|
|
181742
|
+
"fileCount": 71,
|
|
181743
|
+
"unpackedBytes": 33027674,
|
|
181744
|
+
"requiredPlan": "creator",
|
|
181745
|
+
"ratio": "tall",
|
|
181746
|
+
"demoSha256": "8ecc9082472fe20a028b6b99305b6ec4a92c9c3a509e6a604054499952b7ad75"
|
|
181747
|
+
},
|
|
181748
|
+
{
|
|
181749
|
+
"id": "pizarra-minimalista",
|
|
181750
|
+
"name": "Pizarra minimalista",
|
|
181751
|
+
"summary": "Acertijos y casos con dibujos de l\xEDnea sobre papel punteado y subt\xEDtulos arriba.",
|
|
181752
|
+
"needs": [
|
|
181753
|
+
"tu voz",
|
|
181754
|
+
"dibujos de l\xEDnea de cada personaje"
|
|
181755
|
+
],
|
|
181756
|
+
"sourceVersion": "1.0.0",
|
|
181757
|
+
"sourceSha256": "13af7a854f9bfa946bb4227786775c6b4dde06ef9601c3209e8b87261332ce6e",
|
|
181758
|
+
"sourceBytes": 19016433,
|
|
181759
|
+
"fileCount": 71,
|
|
181760
|
+
"unpackedBytes": 23336820,
|
|
181761
|
+
"requiredPlan": "creator",
|
|
181762
|
+
"ratio": "tall",
|
|
181763
|
+
"demoSha256": "bdd4c6994077746d56ae42778b5d433a7b711c1dfbd23f4eaf83446147aebd64"
|
|
181764
|
+
},
|
|
181765
|
+
{
|
|
181766
|
+
"id": "infografia-de-objetos",
|
|
181767
|
+
"name": "Infograf\xEDa de objetos",
|
|
181768
|
+
"summary": "Un concepto de negocio explicado con objetos, tarjetas comparativas y una radiograf\xEDa del mecanismo.",
|
|
181769
|
+
"needs": [
|
|
181770
|
+
"tu voz",
|
|
181771
|
+
"las opciones o cifras que vas a comparar"
|
|
181772
|
+
],
|
|
181773
|
+
"sourceVersion": "1.0.0",
|
|
181774
|
+
"sourceSha256": "2398984bf1cc7c0d47521c3e35f3831d29110067ff750c09d31518fcc8302956",
|
|
181775
|
+
"sourceBytes": 4813352,
|
|
181776
|
+
"fileCount": 65,
|
|
181777
|
+
"unpackedBytes": 9427443,
|
|
181778
|
+
"requiredPlan": "creator",
|
|
181779
|
+
"ratio": "tall",
|
|
181780
|
+
"demoSha256": "9d8f5537545df7c7068258a7d4ddb5bb742d9d3660d5e7cbf7657224061488af"
|
|
181781
|
+
},
|
|
181782
|
+
{
|
|
181783
|
+
"id": "ranking-con-escala",
|
|
181784
|
+
"name": "Ranking con escala",
|
|
181785
|
+
"summary": "Calificas opciones a c\xE1mara con una escala de colores fija arriba y la nota de cada una.",
|
|
181786
|
+
"needs": [
|
|
181787
|
+
"tu clip a c\xE1mara de medio cuerpo",
|
|
181788
|
+
"una ilustraci\xF3n o foto por opci\xF3n"
|
|
181789
|
+
],
|
|
181790
|
+
"sourceVersion": "1.0.0",
|
|
181791
|
+
"sourceSha256": "51e417fe9af71064e3a20b9cd7e0103d67c54f8d521f39eae9752698b1b35c0b",
|
|
181792
|
+
"sourceBytes": 28346697,
|
|
181793
|
+
"fileCount": 73,
|
|
181794
|
+
"unpackedBytes": 33447909,
|
|
181795
|
+
"requiredPlan": "creator",
|
|
181796
|
+
"ratio": "tall",
|
|
181797
|
+
"demoSha256": "ddca372d5b2f0e8029422333427890220dcbbfd32ca0aa166ec3f8543ec0eea5"
|
|
181798
|
+
}
|
|
181799
|
+
];
|
|
181800
|
+
|
|
181801
|
+
// packages/core/src/style-sources.ts
|
|
181802
|
+
var STYLE_SOURCE_MAX_BYTES = 128 * 1024 * 1024;
|
|
181803
|
+
function getStyleSource(id2, version) {
|
|
181804
|
+
return styleSourceData.find((style) => style.id === id2 && style.sourceVersion === version);
|
|
181805
|
+
}
|
|
181806
|
+
|
|
181578
181807
|
// packages/core/src/index.ts
|
|
181579
181808
|
var SCHEMA_VERSION = 1;
|
|
181580
181809
|
var MAX_DOCUMENT_BYTES = 128 * 1024;
|
|
@@ -182030,9 +182259,10 @@ function canonicalFiles(files) {
|
|
|
182030
182259
|
return result2;
|
|
182031
182260
|
}
|
|
182032
182261
|
|
|
182033
|
-
// packages/cli/src/
|
|
182034
|
-
import {
|
|
182035
|
-
import {
|
|
182262
|
+
// packages/cli/src/authored-motion.ts
|
|
182263
|
+
import { lstat as lstat2, mkdir as mkdir2, open as open2, link as link2, unlink as unlink2 } from "node:fs/promises";
|
|
182264
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
182265
|
+
import { createHash, randomUUID as randomUUID2 } from "node:crypto";
|
|
182036
182266
|
|
|
182037
182267
|
// packages/cli/src/errors.ts
|
|
182038
182268
|
var CliError = class extends Error {
|
|
@@ -182056,239 +182286,28 @@ function errorOutput(error) {
|
|
|
182056
182286
|
return { error: safe, code: "COMMAND_FAILED", retryable: false, hint: "Read the command help and run editorbrain doctor. Do not retry writes blindly." };
|
|
182057
182287
|
}
|
|
182058
182288
|
|
|
182059
|
-
// packages/cli/src/media-runtime.ts
|
|
182060
|
-
import { spawn } from "node:child_process";
|
|
182061
|
-
import { createHash } from "node:crypto";
|
|
182062
|
-
import { constants } from "node:fs";
|
|
182063
|
-
import { lstat, open, realpath } from "node:fs/promises";
|
|
182064
|
-
import { dirname, extname, parse, resolve } from "node:path";
|
|
182065
|
-
var MediaToolError = class extends CliError {
|
|
182066
|
-
constructor(code, message) {
|
|
182067
|
-
super(code, message, code === "MEDIA_TOOL_NOT_FOUND" ? "Install FFmpeg/FFprobe separately and make them available on PATH; no account or model is needed." : "Review the local input and reported limit. An incomplete check does not validate the media.");
|
|
182068
|
-
this.name = "MediaToolError";
|
|
182069
|
-
}
|
|
182070
|
-
};
|
|
182071
|
-
var SUPPORTED_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
182072
|
-
".mp4",
|
|
182073
|
-
".mov",
|
|
182074
|
-
".m4v",
|
|
182075
|
-
".mkv",
|
|
182076
|
-
".webm",
|
|
182077
|
-
".avi",
|
|
182078
|
-
".mpg",
|
|
182079
|
-
".mpeg",
|
|
182080
|
-
".mts",
|
|
182081
|
-
".m2ts",
|
|
182082
|
-
".ts",
|
|
182083
|
-
".ogv",
|
|
182084
|
-
".wmv",
|
|
182085
|
-
".wav",
|
|
182086
|
-
".mp3",
|
|
182087
|
-
".m4a",
|
|
182088
|
-
".aac",
|
|
182089
|
-
".flac",
|
|
182090
|
-
".ogg",
|
|
182091
|
-
".opus",
|
|
182092
|
-
".aif",
|
|
182093
|
-
".aiff",
|
|
182094
|
-
".ac3",
|
|
182095
|
-
".eac3",
|
|
182096
|
-
".jpg",
|
|
182097
|
-
".jpeg",
|
|
182098
|
-
".png",
|
|
182099
|
-
".webp",
|
|
182100
|
-
".bmp",
|
|
182101
|
-
".tif",
|
|
182102
|
-
".tiff",
|
|
182103
|
-
".gif",
|
|
182104
|
-
".avif",
|
|
182105
|
-
".heic",
|
|
182106
|
-
".heif"
|
|
182107
|
-
]);
|
|
182108
|
-
var PROTOCOLS = "file,pipe";
|
|
182109
|
-
var FORMATS = "mov,matroska,webm,avi,mpeg,mpegts,ogg,wav,flac,mp3,aac,aiff,ac3,eac3,asf,jpeg_pipe,png_pipe,webp_pipe,bmp_pipe,tiff_pipe,gif,heif,avif";
|
|
182110
|
-
var DEFAULT_TIMEOUT = 3e4;
|
|
182111
|
-
var DEFAULT_OUTPUT_LIMIT = 2 * 1024 * 1024;
|
|
182112
|
-
function resolveLocalMediaPath(value) {
|
|
182113
|
-
if (!value || value.includes("\0") || /[\r\n]/.test(value) || /^[a-z][a-z\d+.-]*:/i.test(value) && !(process.platform === "win32" && /^[a-z]:[\\/]/i.test(value)) || value.startsWith("\\\\")) {
|
|
182114
|
-
throw new MediaToolError("MEDIA_LOCAL_PATH_REQUIRED", "Provide a local filesystem path, not a URL, protocol or network share.");
|
|
182115
|
-
}
|
|
182116
|
-
return resolve(value);
|
|
182117
|
-
}
|
|
182118
|
-
async function assertNoMediaSymlinks(value) {
|
|
182119
|
-
const path = resolveLocalMediaPath(value);
|
|
182120
|
-
let cursor = path;
|
|
182121
|
-
while (cursor !== parse(cursor).root) {
|
|
182122
|
-
const info = await lstat(cursor);
|
|
182123
|
-
if (info.isSymbolicLink()) {
|
|
182124
|
-
const systemAlias = process.platform === "darwin" && (cursor === "/tmp" || cursor === "/var") && await realpath(cursor) === `/private${cursor}`;
|
|
182125
|
-
if (!systemAlias) throw new MediaToolError("MEDIA_SYMLINK", "Symlink media paths are not followed. Use the original local path.");
|
|
182126
|
-
}
|
|
182127
|
-
cursor = dirname(cursor);
|
|
182128
|
-
}
|
|
182129
|
-
return path;
|
|
182130
|
-
}
|
|
182131
|
-
async function assertLocalMediaFile(value) {
|
|
182132
|
-
const path = await assertNoMediaSymlinks(value);
|
|
182133
|
-
const info = await lstat(path);
|
|
182134
|
-
if (!info.isFile()) throw new MediaToolError("MEDIA_NOT_REGULAR", "The media input must be a regular local file.");
|
|
182135
|
-
if (!SUPPORTED_MEDIA_EXTENSIONS.has(extname(path).toLowerCase())) throw new MediaToolError("MEDIA_FORMAT_UNSUPPORTED", "This file extension is not supported for local media inspection.");
|
|
182136
|
-
return path;
|
|
182137
|
-
}
|
|
182138
|
-
function localInputArgs(path) {
|
|
182139
|
-
return ["-protocol_whitelist", PROTOCOLS, "-format_whitelist", FORMATS, "-i", resolveLocalMediaPath(path)];
|
|
182140
|
-
}
|
|
182141
|
-
async function runMediaTool(tool, args, options = {}) {
|
|
182142
|
-
if (tool !== "ffmpeg" && tool !== "ffprobe") throw new MediaToolError("MEDIA_TOOL_INVALID", "Unsupported media executable.");
|
|
182143
|
-
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT;
|
|
182144
|
-
const maxOutputBytes = options.maxOutputBytes ?? DEFAULT_OUTPUT_LIMIT;
|
|
182145
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 10 * 6e4 || !Number.isInteger(maxOutputBytes) || maxOutputBytes < 1 || maxOutputBytes > 16 * 1024 * 1024) {
|
|
182146
|
-
throw new MediaToolError("MEDIA_TOOL_LIMITS_INVALID", "Media runtime limits are outside the supported range.");
|
|
182147
|
-
}
|
|
182148
|
-
if (!Array.isArray(args) || args.length > 200 || args.some((arg) => typeof arg !== "string" || arg.length > 8192 || arg.includes("\0"))) {
|
|
182149
|
-
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "Invalid media tool arguments.");
|
|
182150
|
-
}
|
|
182151
|
-
for (let i = 0; i < args.length; i++) {
|
|
182152
|
-
const arg = args[i];
|
|
182153
|
-
if (/(?:^|[=,;\s])(?:https?|ftp|sftp|tcp|udp|rtsp|rtmp|smb|data|concat|subfile|crypto):/i.test(arg) || arg === "-safe" && args[i + 1] === "0" || arg === "-enable_drefs" && args[i + 1] !== "0") {
|
|
182154
|
-
throw new MediaToolError("MEDIA_REMOTE_INPUT_FORBIDDEN", "Only self-contained local media inputs are allowed.");
|
|
182155
|
-
}
|
|
182156
|
-
if (arg === "-protocol_whitelist" && args[i + 1] !== PROTOCOLS || arg === "-format_whitelist" && args[i + 1] !== FORMATS) {
|
|
182157
|
-
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "The local media allowlists cannot be widened.");
|
|
182158
|
-
}
|
|
182159
|
-
if (arg === "-i") {
|
|
182160
|
-
await assertLocalMediaFile(args[i + 1] ?? "");
|
|
182161
|
-
if (args[i - 4] !== "-protocol_whitelist" || args[i - 3] !== PROTOCOLS || args[i - 2] !== "-format_whitelist" || args[i - 1] !== FORMATS) {
|
|
182162
|
-
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "Every media input must use localInputArgs.");
|
|
182163
|
-
}
|
|
182164
|
-
}
|
|
182165
|
-
}
|
|
182166
|
-
return new Promise((resolveResult, reject) => {
|
|
182167
|
-
const stdout = [], stderr = [];
|
|
182168
|
-
let size = 0, done = false;
|
|
182169
|
-
const child = spawn(tool, ["-hide_banner", ...tool === "ffmpeg" ? ["-nostdin"] : [], ...args], { shell: false, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
182170
|
-
const fail3 = (error) => {
|
|
182171
|
-
if (done) return;
|
|
182172
|
-
done = true;
|
|
182173
|
-
clearTimeout(timer);
|
|
182174
|
-
child.kill("SIGKILL");
|
|
182175
|
-
reject(error);
|
|
182176
|
-
};
|
|
182177
|
-
const timer = setTimeout(() => fail3(new MediaToolError("MEDIA_TOOL_TIMEOUT", "The local media check exceeded its time limit. No complete result is available.")), timeoutMs);
|
|
182178
|
-
const collect = (target) => (chunk) => {
|
|
182179
|
-
if (done) return;
|
|
182180
|
-
size += chunk.length;
|
|
182181
|
-
if (size > maxOutputBytes) return fail3(new MediaToolError("MEDIA_TOOL_OUTPUT_LIMIT", "The local media check exceeded its output limit. No complete result is available."));
|
|
182182
|
-
target.push(chunk);
|
|
182183
|
-
};
|
|
182184
|
-
child.stdout.on("data", collect(stdout));
|
|
182185
|
-
child.stderr.on("data", collect(stderr));
|
|
182186
|
-
child.on("error", (error) => fail3(new MediaToolError(error.code === "ENOENT" ? "MEDIA_TOOL_NOT_FOUND" : "MEDIA_TOOL_FAILED", error.code === "ENOENT" ? `${tool} is not installed or available on PATH. Install it separately to use local media checks.` : "The local media executable could not run.")));
|
|
182187
|
-
child.on("close", (code) => {
|
|
182188
|
-
if (done) return;
|
|
182189
|
-
done = true;
|
|
182190
|
-
clearTimeout(timer);
|
|
182191
|
-
if (code !== 0) return reject(new MediaToolError("MEDIA_TOOL_FAILED", "The local media tool could not inspect or decode this input. No complete result is available."));
|
|
182192
|
-
resolveResult({ stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8") });
|
|
182193
|
-
});
|
|
182194
|
-
});
|
|
182195
|
-
}
|
|
182196
|
-
var finite2 = (value) => {
|
|
182197
|
-
if (typeof value !== "number" && typeof value !== "string" || value === "") return null;
|
|
182198
|
-
const n = Number(value);
|
|
182199
|
-
return Number.isFinite(n) ? n : null;
|
|
182200
|
-
};
|
|
182201
|
-
var nonnegative2 = (value) => {
|
|
182202
|
-
const n = finite2(value);
|
|
182203
|
-
return n !== null && n >= 0 ? n : null;
|
|
182204
|
-
};
|
|
182205
|
-
var positiveInteger = (value) => {
|
|
182206
|
-
const n = finite2(value);
|
|
182207
|
-
return n !== null && Number.isInteger(n) && n > 0 ? n : void 0;
|
|
182208
|
-
};
|
|
182209
|
-
var rate2 = (value) => {
|
|
182210
|
-
if (typeof value !== "string" || !/^\d+(?:\/\d+)?$/.test(value)) return null;
|
|
182211
|
-
const [n, d = "1"] = value.split("/");
|
|
182212
|
-
const result2 = Number(n) / Number(d);
|
|
182213
|
-
return Number.isFinite(result2) && result2 > 0 ? result2 : null;
|
|
182214
|
-
};
|
|
182215
|
-
var sameFile = (a, b) => a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
|
|
182216
|
-
function hasDisplayTransform(stream) {
|
|
182217
|
-
const rotate = stream.tags?.rotate;
|
|
182218
|
-
if (rotate !== void 0 && (!Number.isFinite(Number(rotate)) || Number(rotate) % 360 !== 0)) return true;
|
|
182219
|
-
const sideData = Array.isArray(stream.side_data_list) ? stream.side_data_list : [];
|
|
182220
|
-
return sideData.some((data) => {
|
|
182221
|
-
if (!data || typeof data !== "object") return false;
|
|
182222
|
-
if (data.rotation !== void 0 && (!Number.isFinite(Number(data.rotation)) || Number(data.rotation) % 360 !== 0)) return true;
|
|
182223
|
-
if (data.displaymatrix === void 0) return data.side_data_type === "Display Matrix";
|
|
182224
|
-
if (typeof data.displaymatrix !== "string") return true;
|
|
182225
|
-
const values = data.displaymatrix.trim().split("\n").flatMap((line) => line.replace(/^[^:]*:/, "").trim().split(/\s+/).map(Number));
|
|
182226
|
-
const identity = [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824];
|
|
182227
|
-
return values.length !== 9 || values.some((value, index) => value !== identity[index]);
|
|
182228
|
-
});
|
|
182229
|
-
}
|
|
182230
|
-
async function probeLocalMedia(value) {
|
|
182231
|
-
const path = await assertLocalMediaFile(value);
|
|
182232
|
-
const handle = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
182233
|
-
try {
|
|
182234
|
-
const before = await handle.stat();
|
|
182235
|
-
if (!before.isFile()) throw new MediaToolError("MEDIA_NOT_REGULAR", "The media input must be a regular local file.");
|
|
182236
|
-
const entries = "format=duration,start_time:stream=index,codec_type,codec_name,width,height,avg_frame_rate,sample_rate,channels,duration,color_transfer,sample_aspect_ratio,pix_fmt:stream_disposition=attached_pic:stream_side_data=side_data_type,rotation,displaymatrix:stream_tags=rotate";
|
|
182237
|
-
const { stdout } = await runMediaTool("ffprobe", ["-v", "error", "-show_entries", entries, "-of", "json", ...localInputArgs(path)]);
|
|
182238
|
-
const hash6 = createHash("sha256");
|
|
182239
|
-
for await (const chunk of handle.createReadStream({ autoClose: false })) hash6.update(chunk);
|
|
182240
|
-
const after = await handle.stat();
|
|
182241
|
-
await assertNoMediaSymlinks(path);
|
|
182242
|
-
const current2 = await lstat(path);
|
|
182243
|
-
if (!sameFile(before, after) || !sameFile(after, current2)) throw new MediaToolError("MEDIA_FILE_CHANGED", "The media file changed while it was being inspected. Retry with a stable source.");
|
|
182244
|
-
let raw;
|
|
182245
|
-
try {
|
|
182246
|
-
raw = JSON.parse(stdout);
|
|
182247
|
-
} catch {
|
|
182248
|
-
throw new MediaToolError("MEDIA_PROBE_INVALID", "The media probe returned invalid metadata.");
|
|
182249
|
-
}
|
|
182250
|
-
if (!raw || !Array.isArray(raw.streams) || raw.streams.length > 256 || raw.streams.some((stream) => !stream || typeof stream !== "object" || Array.isArray(stream))) throw new MediaToolError("MEDIA_PROBE_INVALID", "The media probe returned invalid or excessive stream metadata.");
|
|
182251
|
-
const streams = raw.streams.map((stream, offset) => {
|
|
182252
|
-
const type = typeof stream.codec_type === "string" && /^(video|audio|subtitle|data|attachment|unknown)$/.test(stream.codec_type) ? stream.codec_type : "unknown";
|
|
182253
|
-
const codec = typeof stream.codec_name === "string" && /^[a-zA-Z0-9_]{1,64}$/.test(stream.codec_name) ? stream.codec_name : null;
|
|
182254
|
-
const index = finite2(stream.index);
|
|
182255
|
-
return {
|
|
182256
|
-
index: index !== null && Number.isInteger(index) && index >= 0 ? index : offset,
|
|
182257
|
-
type,
|
|
182258
|
-
codec,
|
|
182259
|
-
durationSeconds: nonnegative2(stream.duration),
|
|
182260
|
-
...type === "video" ? { displayTransformed: hasDisplayTransform(stream), width: positiveInteger(stream.width), height: positiveInteger(stream.height), fps: rate2(stream.avg_frame_rate), ...typeof stream.sample_aspect_ratio === "string" ? { sampleAspectRatio: stream.sample_aspect_ratio } : {}, ...typeof stream.pix_fmt === "string" ? { pixelFormat: stream.pix_fmt } : {}, ...typeof stream.color_transfer === "string" ? { colorTransfer: stream.color_transfer } : {}, attachedPicture: stream.disposition?.attached_pic === 1 } : {},
|
|
182261
|
-
...type === "audio" ? { sampleRate: nonnegative2(stream.sample_rate), channels: positiveInteger(stream.channels) ?? null } : {}
|
|
182262
|
-
};
|
|
182263
|
-
});
|
|
182264
|
-
return { path, sha256: hash6.digest("hex"), bytes: after.size, durationSeconds: nonnegative2(raw.format?.duration), startTimeSeconds: finite2(raw.format?.start_time), streams };
|
|
182265
|
-
} finally {
|
|
182266
|
-
await handle.close();
|
|
182267
|
-
}
|
|
182268
|
-
}
|
|
182269
|
-
|
|
182270
182289
|
// packages/cli/src/io.ts
|
|
182271
|
-
import { constants
|
|
182272
|
-
import { lstat
|
|
182273
|
-
import { dirname
|
|
182290
|
+
import { constants } from "node:fs";
|
|
182291
|
+
import { lstat, mkdir, open, readdir, realpath, rename, unlink, link } from "node:fs/promises";
|
|
182292
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
182274
182293
|
import { randomUUID } from "node:crypto";
|
|
182275
182294
|
async function ensureRoot(directory, create = false) {
|
|
182276
|
-
const root =
|
|
182295
|
+
const root = resolve(directory);
|
|
182277
182296
|
if (create) await mkdir(root, { recursive: true });
|
|
182278
|
-
const info = await
|
|
182297
|
+
const info = await lstat(root);
|
|
182279
182298
|
if (info.isSymbolicLink() || !info.isDirectory()) throw new Error("Workspace root must be a real directory, not a symlink");
|
|
182280
|
-
return
|
|
182299
|
+
return realpath(root);
|
|
182281
182300
|
}
|
|
182282
182301
|
async function checkedPath(root, path, document2 = true) {
|
|
182283
182302
|
if (document2) safeDocumentPath(path);
|
|
182284
|
-
const target =
|
|
182303
|
+
const target = resolve(root, path);
|
|
182285
182304
|
const rel = relative(root, target);
|
|
182286
|
-
if (!rel || rel.startsWith(`..${sep}`) || rel === ".." ||
|
|
182305
|
+
if (!rel || rel.startsWith(`..${sep}`) || rel === ".." || resolve(path) === path) throw new Error("Path escapes workspace");
|
|
182287
182306
|
let cursor = root;
|
|
182288
182307
|
for (const segment of rel.split(sep)) {
|
|
182289
182308
|
cursor = join(cursor, segment);
|
|
182290
182309
|
try {
|
|
182291
|
-
const info = await
|
|
182310
|
+
const info = await lstat(cursor);
|
|
182292
182311
|
if (info.isSymbolicLink()) throw new Error(`Symlinks are not allowed: ${path}`);
|
|
182293
182312
|
} catch (error) {
|
|
182294
182313
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -182298,7 +182317,7 @@ async function checkedPath(root, path, document2 = true) {
|
|
|
182298
182317
|
}
|
|
182299
182318
|
async function readText(root, path, document2 = true) {
|
|
182300
182319
|
const target = await checkedPath(root, path, document2);
|
|
182301
|
-
const handle = await
|
|
182320
|
+
const handle = await open(target, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
182302
182321
|
try {
|
|
182303
182322
|
const info = await handle.stat();
|
|
182304
182323
|
if (!info.isFile()) throw new Error(`Not a regular file: ${path}`);
|
|
@@ -182310,10 +182329,10 @@ async function readText(root, path, document2 = true) {
|
|
|
182310
182329
|
}
|
|
182311
182330
|
async function atomicWrite(root, path, content, options = {}) {
|
|
182312
182331
|
const target = await checkedPath(root, path, options.document ?? true);
|
|
182313
|
-
await mkdir(
|
|
182332
|
+
await mkdir(dirname(target), { recursive: true });
|
|
182314
182333
|
await checkedPath(root, path, options.document ?? true);
|
|
182315
|
-
const temporary = join(
|
|
182316
|
-
const handle = await
|
|
182334
|
+
const temporary = join(dirname(target), `.eh-${randomUUID()}.tmp`);
|
|
182335
|
+
const handle = await open(temporary, "wx", options.mode ?? 420);
|
|
182317
182336
|
try {
|
|
182318
182337
|
await handle.writeFile(content, "utf8");
|
|
182319
182338
|
await handle.close();
|
|
@@ -182382,10 +182401,1538 @@ async function readProjectWorkspace(root, projectId) {
|
|
|
182382
182401
|
return canonicalFiles(files);
|
|
182383
182402
|
}
|
|
182384
182403
|
|
|
182385
|
-
// packages/cli/src/
|
|
182404
|
+
// packages/cli/src/authored-motion.ts
|
|
182405
|
+
async function downloadAuthoredSource(client, pin, root, out, fetcher = fetch) {
|
|
182406
|
+
return downloadPinnedSource(client, pin, root, out, "motion", fetcher);
|
|
182407
|
+
}
|
|
182408
|
+
async function downloadPinnedSource(client, pin, root, out, kind, fetcher = fetch) {
|
|
182409
|
+
const namespace = kind === "style" ? "style-sources" : "authored-motion";
|
|
182410
|
+
const downloadNamespace = kind === "style" ? "style-source-download" : "authored-motion-download";
|
|
182411
|
+
if (!/^[a-z0-9][a-z0-9-]{0,79}$/.test(pin.id) || !/^\d+\.\d+\.\d+$/.test(pin.version) || !/^[a-f0-9]{64}$/.test(pin.sha256) || !Number.isSafeInteger(pin.bytes) || pin.bytes < 1 || pin.bytes > (kind === "style" ? 128 : pin.version === "1.4.0" ? 96 : 16) * 1024 * 1024) throw new CliError("INVALID_ARGUMENT", "Invalid pinned source bundle.", "Retrieve one authored scene from the catalog.");
|
|
182412
|
+
const target = await checkedPath(root, out, false);
|
|
182413
|
+
try {
|
|
182414
|
+
await lstat2(target);
|
|
182415
|
+
throw new CliError("FILE_EXISTS", "The output already exists.", "Choose a new archive path.");
|
|
182416
|
+
} catch (error) {
|
|
182417
|
+
if (error.code !== "ENOENT") throw error;
|
|
182418
|
+
}
|
|
182419
|
+
const metadata = await client.request(`/v1/${namespace}/${pin.id}/source?${new URLSearchParams({ version: pin.version, sha256: pin.sha256 })}`);
|
|
182420
|
+
const url2 = new URL(metadata.url);
|
|
182421
|
+
const expectedPath = `/v1/${downloadNamespace}/${pin.id}/${pin.version}/${pin.sha256}`;
|
|
182422
|
+
const origin = new URL(client.url).origin;
|
|
182423
|
+
const trustedOrigin = url2.origin === origin || origin === "https://editorharness-api.innovandohorizontes.workers.dev" && url2.origin === "https://api.editorbrain.com";
|
|
182424
|
+
if (metadata.sha256 !== pin.sha256 || metadata.bytes !== pin.bytes || !trustedOrigin || url2.pathname !== expectedPath || url2.username || url2.password || url2.hash) throw new CliError("INVALID_RESPONSE", "Source bundle metadata differs from the selected version.", "Do not use this source. Retrieve the pinned catalog entry again.");
|
|
182425
|
+
const response = await fetcher(url2, { redirect: "error", signal: AbortSignal.timeout(18e4) });
|
|
182426
|
+
if (response.status === 403) {
|
|
182427
|
+
await response.body?.cancel();
|
|
182428
|
+
throw new CliError("RESOURCE_ACCESS_CHANGED", "Source access was denied at download time.", "Check current workspace permissions and membership at https://editorbrain.com/app/billing. Do not retry old versions or buy credits to unlock premium resources; existing archives were preserved.");
|
|
182429
|
+
}
|
|
182430
|
+
if (!response.ok) throw new CliError("DOWNLOAD_FAILED", `Source download failed (HTTP ${response.status}).`, "Request a new source link; existing archives were preserved.");
|
|
182431
|
+
const reader = response.body?.getReader();
|
|
182432
|
+
if (!reader) throw new CliError("INVALID_RESPONSE", "Source download body is missing.", "Retry the pinned source.");
|
|
182433
|
+
const temporary = join2(dirname2(target), `.eb-motion-${randomUUID2()}.tmp`);
|
|
182434
|
+
let handle;
|
|
182435
|
+
const hash6 = createHash("sha256");
|
|
182436
|
+
let size = 0;
|
|
182437
|
+
try {
|
|
182438
|
+
await mkdir2(dirname2(target), { recursive: true });
|
|
182439
|
+
await checkedPath(root, out, false);
|
|
182440
|
+
handle = await open2(temporary, "wx", 384);
|
|
182441
|
+
for (; ; ) {
|
|
182442
|
+
const { done, value } = await reader.read();
|
|
182443
|
+
if (done) break;
|
|
182444
|
+
size += value.length;
|
|
182445
|
+
if (size > pin.bytes) throw new CliError("HASH_MISMATCH", "Source archive exceeds the pinned length.", "Discard the unverified download.");
|
|
182446
|
+
hash6.update(value);
|
|
182447
|
+
await handle.writeFile(value);
|
|
182448
|
+
}
|
|
182449
|
+
if (size !== pin.bytes || hash6.digest("hex") !== pin.sha256) throw new CliError("HASH_MISMATCH", "Source archive verification failed.", "Do not extract this download.");
|
|
182450
|
+
await handle.sync();
|
|
182451
|
+
await handle.close();
|
|
182452
|
+
await checkedPath(root, out, false);
|
|
182453
|
+
await link2(temporary, target);
|
|
182454
|
+
} catch (error) {
|
|
182455
|
+
await reader.cancel().catch(() => {
|
|
182456
|
+
});
|
|
182457
|
+
throw error;
|
|
182458
|
+
} finally {
|
|
182459
|
+
await handle?.close().catch(() => {
|
|
182460
|
+
});
|
|
182461
|
+
await unlink2(temporary).catch(() => {
|
|
182462
|
+
});
|
|
182463
|
+
}
|
|
182464
|
+
return { ...kind === "style" ? { documents: metadata.documents } : {}, id: pin.id, version: pin.version, path: target, sha256: pin.sha256, bytes: size, extracted: false, executed: false, rendered: false, next: kind === "style" ? "Use editorbrain styles prepare with this exact version and archive to create a guarded local copy. Nothing has been extracted or executed." : "Inspect bundle README and selected card; extract into a new local directory. Bind current project colors, fonts, language, content, timing and sound before rendering. The demo is not your finished edit." };
|
|
182465
|
+
}
|
|
182466
|
+
|
|
182467
|
+
// packages/cli/src/style-archive.ts
|
|
182468
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
182469
|
+
import { gunzipSync } from "node:zlib";
|
|
182470
|
+
var STYLE_ARCHIVE_MAX_BYTES = 128 * 1024 * 1024;
|
|
182471
|
+
var STYLE_UNPACKED_MAX_BYTES = 192 * 1024 * 1024;
|
|
182472
|
+
var archiveHash = (bytes) => createHash2("sha256").update(bytes).digest("hex");
|
|
182473
|
+
function safeArchivePath(name) {
|
|
182474
|
+
if (!name || name.length > 240 || !/^[a-zA-Z0-9_. /-]+$/.test(name) || name.startsWith("/") || name.split("/").some((p) => !p || p === "." || p === "..")) throw new Error("Unsafe archive path");
|
|
182475
|
+
return name;
|
|
182476
|
+
}
|
|
182477
|
+
function readStyleArchive(bytes, pin) {
|
|
182478
|
+
if (pin.bytes > STYLE_ARCHIVE_MAX_BYTES || pin.unpackedBytes > STYLE_UNPACKED_MAX_BYTES || bytes.length !== pin.bytes || archiveHash(bytes) !== pin.sha256) throw new Error("Style archive pin mismatch");
|
|
182479
|
+
const tar = gunzipSync(bytes, { maxOutputLength: STYLE_UNPACKED_MAX_BYTES + 2 * 1024 * 1024 });
|
|
182480
|
+
const files = /* @__PURE__ */ new Map();
|
|
182481
|
+
let offset = 0, total = 0, ended = false;
|
|
182482
|
+
const octal = (b) => {
|
|
182483
|
+
const s = b.toString("ascii").replace(/\0.*$/s, "").trim();
|
|
182484
|
+
if (!/^[0-7]+$/.test(s)) throw new Error("Invalid tar number");
|
|
182485
|
+
return parseInt(s, 8);
|
|
182486
|
+
};
|
|
182487
|
+
while (offset + 512 <= tar.length) {
|
|
182488
|
+
const h = tar.subarray(offset, offset + 512);
|
|
182489
|
+
offset += 512;
|
|
182490
|
+
if (h.every((b) => b === 0)) {
|
|
182491
|
+
if (tar.length - offset < 512 || tar.subarray(offset).some((b) => b !== 0)) throw new Error("Invalid tar ending");
|
|
182492
|
+
ended = true;
|
|
182493
|
+
break;
|
|
182494
|
+
}
|
|
182495
|
+
const sum = h.reduce((n, b, i) => n + (i >= 148 && i < 156 ? 32 : b), 0);
|
|
182496
|
+
if (sum !== octal(h.subarray(148, 156)) || h[156] !== 48 || h.subarray(157, 257).some((b) => b !== 0) || h.subarray(345, 500).some((b) => b !== 0)) throw new Error("Unsupported or corrupt tar entry");
|
|
182497
|
+
const name = safeArchivePath(h.subarray(0, 100).toString("utf8").replace(/\0.*$/s, ""));
|
|
182498
|
+
const size = octal(h.subarray(124, 136));
|
|
182499
|
+
if (files.has(name) || files.size >= 512 || offset + size > tar.length) throw new Error("Duplicate or truncated tar entry");
|
|
182500
|
+
total += size;
|
|
182501
|
+
if (total > pin.unpackedBytes) throw new Error("Archive exceeds unpacked pin");
|
|
182502
|
+
files.set(name, tar.subarray(offset, offset + size));
|
|
182503
|
+
offset += Math.ceil(size / 512) * 512;
|
|
182504
|
+
}
|
|
182505
|
+
if (!ended || files.size !== pin.fileCount || total !== pin.unpackedBytes || offset > tar.length) throw new Error("Archive inventory mismatch");
|
|
182506
|
+
const manifest = JSON.parse(files.get("BUNDLE-MANIFEST.json")?.toString("utf8") ?? "null");
|
|
182507
|
+
if (!manifest || manifest.style !== pin.id || manifest.version !== pin.version || manifest.entry !== `styles/${pin.id}/scene.html` || !manifest.files || Array.isArray(manifest.files)) throw new Error("Invalid style manifest");
|
|
182508
|
+
if (Object.keys(manifest.files).length !== files.size - 1) throw new Error("Incomplete style manifest");
|
|
182509
|
+
for (const [name, data] of files) {
|
|
182510
|
+
if (name === "BUNDLE-MANIFEST.json") continue;
|
|
182511
|
+
const expected = manifest.files[name];
|
|
182512
|
+
if (!expected || expected.bytes !== data.length || expected.sha256 !== archiveHash(data)) throw new Error("Manifest hash mismatch: " + name);
|
|
182513
|
+
}
|
|
182514
|
+
return { files, manifest };
|
|
182515
|
+
}
|
|
182516
|
+
|
|
182517
|
+
// packages/cli/src/style-source-guards-v1.ts
|
|
182518
|
+
var styleSourceGuards = {
|
|
182519
|
+
"comando-y-resultado": {
|
|
182520
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182521
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182522
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182523
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182524
|
+
(function () {
|
|
182525
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182526
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182527
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182528
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182529
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182530
|
+
const theme = q.get('theme') || p.theme;
|
|
182531
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182532
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182533
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182534
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182535
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182536
|
+
}
|
|
182537
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182538
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182539
|
+
if (q.get('demo') === '1') return;
|
|
182540
|
+
const b = window.__overrides?.brand;
|
|
182541
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182542
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182543
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182544
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182545
|
+
for (const role of fonts) {
|
|
182546
|
+
const font = b.fonts[role];
|
|
182547
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182548
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182549
|
+
}
|
|
182550
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182551
|
+
};
|
|
182552
|
+
})();
|
|
182553
|
+
|
|
182554
|
+
(function () {
|
|
182555
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182556
|
+
const roles = ["accent","accentInk","bg","cardEdge","chip","giftBox","giftLid","giftRibbon","giftShade","light","outline","panel","panelLine","thumbBg","uiText"];
|
|
182557
|
+
const fontRoles = ["credit","cta","headline","ui"];
|
|
182558
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182559
|
+
base(params, query);
|
|
182560
|
+
if (query.get('demo') === '1') return;
|
|
182561
|
+
for (const role of roles) {
|
|
182562
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182563
|
+
}
|
|
182564
|
+
for (const role of fontRoles) {
|
|
182565
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182566
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182567
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182568
|
+
}
|
|
182569
|
+
};
|
|
182570
|
+
})();
|
|
182571
|
+
`
|
|
182572
|
+
},
|
|
182573
|
+
"narrador-sobre-collage": {
|
|
182574
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182575
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182576
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182577
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182578
|
+
(function () {
|
|
182579
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182580
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182581
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182582
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182583
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182584
|
+
const theme = q.get('theme') || p.theme;
|
|
182585
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182586
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182587
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182588
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182589
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182590
|
+
}
|
|
182591
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182592
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182593
|
+
if (q.get('demo') === '1') return;
|
|
182594
|
+
const b = window.__overrides?.brand;
|
|
182595
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182596
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182597
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182598
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182599
|
+
for (const role of fonts) {
|
|
182600
|
+
const font = b.fonts[role];
|
|
182601
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182602
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182603
|
+
}
|
|
182604
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182605
|
+
};
|
|
182606
|
+
})();
|
|
182607
|
+
|
|
182608
|
+
(function () {
|
|
182609
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182610
|
+
const roles = ["accent","bg","labelBg","labelInk","light","outline"];
|
|
182611
|
+
const fontRoles = ["caption","credit","headline","label"];
|
|
182612
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182613
|
+
base(params, query);
|
|
182614
|
+
if (query.get('demo') === '1') return;
|
|
182615
|
+
for (const role of roles) {
|
|
182616
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182617
|
+
}
|
|
182618
|
+
for (const role of fontRoles) {
|
|
182619
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182620
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182621
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182622
|
+
}
|
|
182623
|
+
};
|
|
182624
|
+
})();
|
|
182625
|
+
`
|
|
182626
|
+
},
|
|
182627
|
+
"presentador-con-interfaz": {
|
|
182628
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182629
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182630
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182631
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182632
|
+
(function () {
|
|
182633
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182634
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182635
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182636
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182637
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182638
|
+
const theme = q.get('theme') || p.theme;
|
|
182639
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182640
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182641
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182642
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182643
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182644
|
+
}
|
|
182645
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182646
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182647
|
+
if (q.get('demo') === '1') return;
|
|
182648
|
+
const b = window.__overrides?.brand;
|
|
182649
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182650
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182651
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182652
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182653
|
+
for (const role of fonts) {
|
|
182654
|
+
const font = b.fonts[role];
|
|
182655
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182656
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182657
|
+
}
|
|
182658
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182659
|
+
};
|
|
182660
|
+
})();
|
|
182661
|
+
|
|
182662
|
+
(function () {
|
|
182663
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182664
|
+
const roles = ["accent","bg","dim","ink","keybox","line","muted","onAccent","pill","surface","surface2"];
|
|
182665
|
+
const fontRoles = ["caption","credit","figure","heading","keyword","label","mono","ui"];
|
|
182666
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182667
|
+
base(params, query);
|
|
182668
|
+
if (query.get('demo') === '1') return;
|
|
182669
|
+
for (const role of roles) {
|
|
182670
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182671
|
+
}
|
|
182672
|
+
for (const role of fontRoles) {
|
|
182673
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182674
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182675
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182676
|
+
}
|
|
182677
|
+
};
|
|
182678
|
+
})();
|
|
182679
|
+
`
|
|
182680
|
+
},
|
|
182681
|
+
"ensayo-cinematografico": {
|
|
182682
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182683
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182684
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182685
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182686
|
+
(function () {
|
|
182687
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182688
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182689
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182690
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182691
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182692
|
+
const theme = q.get('theme') || p.theme;
|
|
182693
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182694
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182695
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182696
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182697
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182698
|
+
}
|
|
182699
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182700
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182701
|
+
if (q.get('demo') === '1') return;
|
|
182702
|
+
const b = window.__overrides?.brand;
|
|
182703
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182704
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182705
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182706
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182707
|
+
for (const role of fonts) {
|
|
182708
|
+
const font = b.fonts[role];
|
|
182709
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182710
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182711
|
+
}
|
|
182712
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182713
|
+
};
|
|
182714
|
+
})();
|
|
182715
|
+
|
|
182716
|
+
(function () {
|
|
182717
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182718
|
+
const roles = ["accent","accent2","bg","cardDark","cardLight","inkOnDark","inkOnLight","light","outline","shadow"];
|
|
182719
|
+
const fontRoles = ["caption","credit","heavy","serif"];
|
|
182720
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182721
|
+
base(params, query);
|
|
182722
|
+
if (query.get('demo') === '1') return;
|
|
182723
|
+
for (const role of roles) {
|
|
182724
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182725
|
+
}
|
|
182726
|
+
for (const role of fontRoles) {
|
|
182727
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182728
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182729
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182730
|
+
}
|
|
182731
|
+
};
|
|
182732
|
+
})();
|
|
182733
|
+
`
|
|
182734
|
+
},
|
|
182735
|
+
"tutorial-por-capitulos": {
|
|
182736
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182737
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182738
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182739
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182740
|
+
(function () {
|
|
182741
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182742
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182743
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182744
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182745
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182746
|
+
const theme = q.get('theme') || p.theme;
|
|
182747
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182748
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182749
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182750
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182751
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182752
|
+
}
|
|
182753
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182754
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182755
|
+
if (q.get('demo') === '1') return;
|
|
182756
|
+
const b = window.__overrides?.brand;
|
|
182757
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182758
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182759
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182760
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182761
|
+
for (const role of fonts) {
|
|
182762
|
+
const font = b.fonts[role];
|
|
182763
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182764
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182765
|
+
}
|
|
182766
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182767
|
+
};
|
|
182768
|
+
})();
|
|
182769
|
+
|
|
182770
|
+
(function () {
|
|
182771
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182772
|
+
const roles = ["alarm","badge","badgeShadow","badgeText","bg","caption","card","cream","heart","heartCore","lime","limeDeep","numeral","paper","title","uiBubble","uiField","uiInk","uiLine","uiMark","uiMuted","uiSend"];
|
|
182773
|
+
const fontRoles = ["caption","credit","greeting","heavy","italic","script","ui","uiSerif"];
|
|
182774
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182775
|
+
base(params, query);
|
|
182776
|
+
if (query.get('demo') === '1') return;
|
|
182777
|
+
for (const role of roles) {
|
|
182778
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182779
|
+
}
|
|
182780
|
+
for (const role of fontRoles) {
|
|
182781
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182782
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182783
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182784
|
+
}
|
|
182785
|
+
};
|
|
182786
|
+
})();
|
|
182787
|
+
`
|
|
182788
|
+
},
|
|
182789
|
+
"tablero-que-se-llena": {
|
|
182790
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182791
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182792
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182793
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182794
|
+
(function () {
|
|
182795
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182796
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182797
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182798
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182799
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182800
|
+
const theme = q.get('theme') || p.theme;
|
|
182801
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182802
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182803
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182804
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182805
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182806
|
+
}
|
|
182807
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182808
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182809
|
+
if (q.get('demo') === '1') return;
|
|
182810
|
+
const b = window.__overrides?.brand;
|
|
182811
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182812
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182813
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182814
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182815
|
+
for (const role of fonts) {
|
|
182816
|
+
const font = b.fonts[role];
|
|
182817
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182818
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182819
|
+
}
|
|
182820
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182821
|
+
};
|
|
182822
|
+
})();
|
|
182823
|
+
|
|
182824
|
+
(function () {
|
|
182825
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182826
|
+
const roles = ["bg","callout","cell","credit","labelGap","panel","seam","tierInk","tile","title"];
|
|
182827
|
+
const fontRoles = ["callout","credit","tier","title"];
|
|
182828
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182829
|
+
base(params, query);
|
|
182830
|
+
if (query.get('demo') === '1') return;
|
|
182831
|
+
for (const role of roles) {
|
|
182832
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182833
|
+
}
|
|
182834
|
+
for (const role of fontRoles) {
|
|
182835
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182836
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182837
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182838
|
+
}
|
|
182839
|
+
};
|
|
182840
|
+
})();
|
|
182841
|
+
`
|
|
182842
|
+
},
|
|
182843
|
+
"explicador-con-evidencias": {
|
|
182844
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182845
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182846
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182847
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182848
|
+
(function () {
|
|
182849
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182850
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182851
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182852
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182853
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182854
|
+
const theme = q.get('theme') || p.theme;
|
|
182855
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182856
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182857
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182858
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182859
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182860
|
+
}
|
|
182861
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182862
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182863
|
+
if (q.get('demo') === '1') return;
|
|
182864
|
+
const b = window.__overrides?.brand;
|
|
182865
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182866
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182867
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182868
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182869
|
+
for (const role of fonts) {
|
|
182870
|
+
const font = b.fonts[role];
|
|
182871
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182872
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182873
|
+
}
|
|
182874
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182875
|
+
};
|
|
182876
|
+
})();
|
|
182877
|
+
|
|
182878
|
+
(function () {
|
|
182879
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182880
|
+
const roles = ["annotation","bg","card","cardLine","docInk","docMuted","docText","hookBox","hookInk","light","marker","page","pageInner","pageLine","paper","shadow"];
|
|
182881
|
+
const fontRoles = ["caption","credit","docBody","docTitle","hook","label","mono","serif","serifItalic"];
|
|
182882
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182883
|
+
base(params, query);
|
|
182884
|
+
if (query.get('demo') === '1') return;
|
|
182885
|
+
for (const role of roles) {
|
|
182886
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182887
|
+
}
|
|
182888
|
+
for (const role of fontRoles) {
|
|
182889
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182890
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182891
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182892
|
+
}
|
|
182893
|
+
};
|
|
182894
|
+
})();
|
|
182895
|
+
`
|
|
182896
|
+
},
|
|
182897
|
+
"monologo-con-dipticos": {
|
|
182898
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182899
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182900
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182901
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182902
|
+
(function () {
|
|
182903
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182904
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182905
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182906
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182907
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182908
|
+
const theme = q.get('theme') || p.theme;
|
|
182909
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182910
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182911
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182912
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182913
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182914
|
+
}
|
|
182915
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182916
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182917
|
+
if (q.get('demo') === '1') return;
|
|
182918
|
+
const b = window.__overrides?.brand;
|
|
182919
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182920
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182921
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182922
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182923
|
+
for (const role of fonts) {
|
|
182924
|
+
const font = b.fonts[role];
|
|
182925
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182926
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182927
|
+
}
|
|
182928
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182929
|
+
};
|
|
182930
|
+
})();
|
|
182931
|
+
|
|
182932
|
+
(function () {
|
|
182933
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182934
|
+
const roles = ["bg","caption","credit","headline"];
|
|
182935
|
+
const fontRoles = ["caption","credit","headline"];
|
|
182936
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182937
|
+
base(params, query);
|
|
182938
|
+
if (query.get('demo') === '1') return;
|
|
182939
|
+
for (const role of roles) {
|
|
182940
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182941
|
+
}
|
|
182942
|
+
for (const role of fontRoles) {
|
|
182943
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182944
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182945
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
182946
|
+
}
|
|
182947
|
+
};
|
|
182948
|
+
})();
|
|
182949
|
+
`
|
|
182950
|
+
},
|
|
182951
|
+
"recorrido-de-experto": {
|
|
182952
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
182953
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
182954
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
182955
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
182956
|
+
(function () {
|
|
182957
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
182958
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
182959
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
182960
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
182961
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
182962
|
+
const theme = q.get('theme') || p.theme;
|
|
182963
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
182964
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
182965
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
182966
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
182967
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
182968
|
+
}
|
|
182969
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
182970
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
182971
|
+
if (q.get('demo') === '1') return;
|
|
182972
|
+
const b = window.__overrides?.brand;
|
|
182973
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
182974
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
182975
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
182976
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
182977
|
+
for (const role of fonts) {
|
|
182978
|
+
const font = b.fonts[role];
|
|
182979
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
182980
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
182981
|
+
}
|
|
182982
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
182983
|
+
};
|
|
182984
|
+
})();
|
|
182985
|
+
|
|
182986
|
+
(function () {
|
|
182987
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
182988
|
+
const roles = ["bg","light","shadow"];
|
|
182989
|
+
const fontRoles = ["bold","caption","credit","label","semi"];
|
|
182990
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
182991
|
+
base(params, query);
|
|
182992
|
+
if (query.get('demo') === '1') return;
|
|
182993
|
+
for (const role of roles) {
|
|
182994
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
182995
|
+
}
|
|
182996
|
+
for (const role of fontRoles) {
|
|
182997
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
182998
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
182999
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183000
|
+
}
|
|
183001
|
+
};
|
|
183002
|
+
})();
|
|
183003
|
+
`
|
|
183004
|
+
},
|
|
183005
|
+
"vlog-intimo": {
|
|
183006
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183007
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183008
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183009
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183010
|
+
(function () {
|
|
183011
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183012
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183013
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183014
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183015
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183016
|
+
const theme = q.get('theme') || p.theme;
|
|
183017
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183018
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183019
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183020
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183021
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183022
|
+
}
|
|
183023
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183024
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183025
|
+
if (q.get('demo') === '1') return;
|
|
183026
|
+
const b = window.__overrides?.brand;
|
|
183027
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183028
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183029
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183030
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183031
|
+
for (const role of fonts) {
|
|
183032
|
+
const font = b.fonts[role];
|
|
183033
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183034
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183035
|
+
}
|
|
183036
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183037
|
+
};
|
|
183038
|
+
})();
|
|
183039
|
+
|
|
183040
|
+
(function () {
|
|
183041
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183042
|
+
const roles = ["bg","gold","inkA","inkB","inkC","light","paper","paperRim","plate","plateInk","shadow","wood"];
|
|
183043
|
+
const fontRoles = ["credit","serif","slip"];
|
|
183044
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183045
|
+
base(params, query);
|
|
183046
|
+
if (query.get('demo') === '1') return;
|
|
183047
|
+
for (const role of roles) {
|
|
183048
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183049
|
+
}
|
|
183050
|
+
for (const role of fontRoles) {
|
|
183051
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183052
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183053
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183054
|
+
}
|
|
183055
|
+
};
|
|
183056
|
+
})();
|
|
183057
|
+
`
|
|
183058
|
+
},
|
|
183059
|
+
"documental-de-archivo": {
|
|
183060
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183061
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183062
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183063
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183064
|
+
(function () {
|
|
183065
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183066
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183067
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183068
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183069
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183070
|
+
const theme = q.get('theme') || p.theme;
|
|
183071
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183072
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183073
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183074
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183075
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183076
|
+
}
|
|
183077
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183078
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183079
|
+
if (q.get('demo') === '1') return;
|
|
183080
|
+
const b = window.__overrides?.brand;
|
|
183081
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183082
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183083
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183084
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183085
|
+
for (const role of fonts) {
|
|
183086
|
+
const font = b.fonts[role];
|
|
183087
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183088
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183089
|
+
}
|
|
183090
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183091
|
+
};
|
|
183092
|
+
})();
|
|
183093
|
+
|
|
183094
|
+
(function () {
|
|
183095
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183096
|
+
const roles = ["accent","bg","glow","highlight","light","paper","paperInk","shadow"];
|
|
183097
|
+
const fontRoles = ["cond","credit","paperHead","paperMark","paperSans","paperSerif","sign"];
|
|
183098
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183099
|
+
base(params, query);
|
|
183100
|
+
if (query.get('demo') === '1') return;
|
|
183101
|
+
for (const role of roles) {
|
|
183102
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183103
|
+
}
|
|
183104
|
+
for (const role of fontRoles) {
|
|
183105
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183106
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183107
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183108
|
+
}
|
|
183109
|
+
};
|
|
183110
|
+
})();
|
|
183111
|
+
`
|
|
183112
|
+
},
|
|
183113
|
+
"catalogo-editorial": {
|
|
183114
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183115
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183116
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183117
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183118
|
+
(function () {
|
|
183119
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183120
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183121
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183122
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183123
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183124
|
+
const theme = q.get('theme') || p.theme;
|
|
183125
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183126
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183127
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183128
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183129
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183130
|
+
}
|
|
183131
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183132
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183133
|
+
if (q.get('demo') === '1') return;
|
|
183134
|
+
const b = window.__overrides?.brand;
|
|
183135
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183136
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183137
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183138
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183139
|
+
for (const role of fonts) {
|
|
183140
|
+
const font = b.fonts[role];
|
|
183141
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183142
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183143
|
+
}
|
|
183144
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183145
|
+
};
|
|
183146
|
+
})();
|
|
183147
|
+
|
|
183148
|
+
(function () {
|
|
183149
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183150
|
+
const roles = ["accent","bg","cta","doc","docAccent","docGap","docMint","docNavy","field","fieldGlow","fieldInk","icon","ink","line","muted","rule","sheet","soft","title"];
|
|
183151
|
+
const fontRoles = ["alt1","alt2","hand","label","sans","serif","small"];
|
|
183152
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183153
|
+
base(params, query);
|
|
183154
|
+
if (query.get('demo') === '1') return;
|
|
183155
|
+
for (const role of roles) {
|
|
183156
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183157
|
+
}
|
|
183158
|
+
for (const role of fontRoles) {
|
|
183159
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183160
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183161
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183162
|
+
}
|
|
183163
|
+
};
|
|
183164
|
+
})();
|
|
183165
|
+
`
|
|
183166
|
+
},
|
|
183167
|
+
"pantalla-fisica": {
|
|
183168
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183169
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183170
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183171
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183172
|
+
(function () {
|
|
183173
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183174
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183175
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183176
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183177
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183178
|
+
const theme = q.get('theme') || p.theme;
|
|
183179
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183180
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183181
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183182
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183183
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183184
|
+
}
|
|
183185
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183186
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183187
|
+
if (q.get('demo') === '1') return;
|
|
183188
|
+
const b = window.__overrides?.brand;
|
|
183189
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183190
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183191
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183192
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183193
|
+
for (const role of fonts) {
|
|
183194
|
+
const font = b.fonts[role];
|
|
183195
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183196
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183197
|
+
}
|
|
183198
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183199
|
+
};
|
|
183200
|
+
})();
|
|
183201
|
+
|
|
183202
|
+
(function () {
|
|
183203
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183204
|
+
const roles = ["bg","card","cardInk","cardLine","cardMuted","follow","following","light","panel","pos","ring1","ring2","shadow","wordmark"];
|
|
183205
|
+
const fontRoles = ["credit","heavy","serif","ui","uiBold","uiNum","uiText","wordmark"];
|
|
183206
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183207
|
+
base(params, query);
|
|
183208
|
+
if (query.get('demo') === '1') return;
|
|
183209
|
+
for (const role of roles) {
|
|
183210
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183211
|
+
}
|
|
183212
|
+
for (const role of fontRoles) {
|
|
183213
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183214
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183215
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183216
|
+
}
|
|
183217
|
+
};
|
|
183218
|
+
})();
|
|
183219
|
+
`
|
|
183220
|
+
},
|
|
183221
|
+
"personaje-en-papel": {
|
|
183222
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183223
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183224
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183225
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183226
|
+
(function () {
|
|
183227
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183228
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183229
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183230
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183231
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183232
|
+
const theme = q.get('theme') || p.theme;
|
|
183233
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183234
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183235
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183236
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183237
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183238
|
+
}
|
|
183239
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183240
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183241
|
+
if (q.get('demo') === '1') return;
|
|
183242
|
+
const b = window.__overrides?.brand;
|
|
183243
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183244
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183245
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183246
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183247
|
+
for (const role of fonts) {
|
|
183248
|
+
const font = b.fonts[role];
|
|
183249
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183250
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183251
|
+
}
|
|
183252
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183253
|
+
};
|
|
183254
|
+
})();
|
|
183255
|
+
|
|
183256
|
+
(function () {
|
|
183257
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183258
|
+
const roles = ["avatar","bg","card","chip","chipEdge","chipText","edge","glow","glowCore","gray","ground","groundInk","ink","mapBg","mapBlock","mapHwy","mapPark","mapRoad","mapWater","ok","okSoft","paper","pick","pickLine","pill","pin","red","route","shutter","skip","stampShade","star","tick","tile1","tile2","tile3","tile4","uiAccent","uiBubble","uiChat","uiInk","uiLine","uiMuted","uiPanel"];
|
|
183259
|
+
const fontRoles = ["credit","slab","slabBlack","ui","uiBold","uiReg","uiSemi"];
|
|
183260
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183261
|
+
base(params, query);
|
|
183262
|
+
if (query.get('demo') === '1') return;
|
|
183263
|
+
for (const role of roles) {
|
|
183264
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183265
|
+
}
|
|
183266
|
+
for (const role of fontRoles) {
|
|
183267
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183268
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183269
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183270
|
+
}
|
|
183271
|
+
};
|
|
183272
|
+
})();
|
|
183273
|
+
`
|
|
183274
|
+
},
|
|
183275
|
+
"simulacion-en-el-mapa": {
|
|
183276
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183277
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183278
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183279
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183280
|
+
(function () {
|
|
183281
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183282
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183283
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183284
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183285
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183286
|
+
const theme = q.get('theme') || p.theme;
|
|
183287
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183288
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183289
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183290
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183291
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183292
|
+
}
|
|
183293
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183294
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183295
|
+
if (q.get('demo') === '1') return;
|
|
183296
|
+
const b = window.__overrides?.brand;
|
|
183297
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183298
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183299
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183300
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183301
|
+
for (const role of fonts) {
|
|
183302
|
+
const font = b.fonts[role];
|
|
183303
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183304
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183305
|
+
}
|
|
183306
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183307
|
+
};
|
|
183308
|
+
})();
|
|
183309
|
+
|
|
183310
|
+
(function () {
|
|
183311
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183312
|
+
const roles = ["accent","atmo","bg","brown","chipA","chipB","core","drop","dry","ember","glow","ink","panel","smoke","titleSplit","upcoming","vapor"];
|
|
183313
|
+
const fontRoles = ["cap","credit","label","mono","monoB","title"];
|
|
183314
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183315
|
+
base(params, query);
|
|
183316
|
+
if (query.get('demo') === '1') return;
|
|
183317
|
+
for (const role of roles) {
|
|
183318
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183319
|
+
}
|
|
183320
|
+
for (const role of fontRoles) {
|
|
183321
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183322
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183323
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183324
|
+
}
|
|
183325
|
+
};
|
|
183326
|
+
})();
|
|
183327
|
+
`
|
|
183328
|
+
},
|
|
183329
|
+
"relato-ilustrado": {
|
|
183330
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183331
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183332
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183333
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183334
|
+
(function () {
|
|
183335
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183336
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183337
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183338
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183339
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183340
|
+
const theme = q.get('theme') || p.theme;
|
|
183341
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183342
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183343
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183344
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183345
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183346
|
+
}
|
|
183347
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183348
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183349
|
+
if (q.get('demo') === '1') return;
|
|
183350
|
+
const b = window.__overrides?.brand;
|
|
183351
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183352
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183353
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183354
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183355
|
+
for (const role of fonts) {
|
|
183356
|
+
const font = b.fonts[role];
|
|
183357
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183358
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183359
|
+
}
|
|
183360
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183361
|
+
};
|
|
183362
|
+
})();
|
|
183363
|
+
|
|
183364
|
+
(function () {
|
|
183365
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183366
|
+
const roles = ["badgeInk","badgeRed","badgeYellow","bg","card","cardInk","cardMuted","cardRed","chip","chipDone","chipDoneInk","chipInk","chipThreat","endBg","endGlow","led","ledBox","ledEdge","ledOff","line","metal","metalDark","note","paper","paperEdge","pill","pillInk","red","shadow","shaft","slab","white","yellow"];
|
|
183367
|
+
const fontRoles = ["cap","card","credit","heavy","label","note"];
|
|
183368
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183369
|
+
base(params, query);
|
|
183370
|
+
if (query.get('demo') === '1') return;
|
|
183371
|
+
for (const role of roles) {
|
|
183372
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183373
|
+
}
|
|
183374
|
+
for (const role of fontRoles) {
|
|
183375
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183376
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183377
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183378
|
+
}
|
|
183379
|
+
};
|
|
183380
|
+
})();
|
|
183381
|
+
`
|
|
183382
|
+
},
|
|
183383
|
+
"pizarra-minimalista": {
|
|
183384
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183385
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183386
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183387
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183388
|
+
(function () {
|
|
183389
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183390
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183391
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183392
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183393
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183394
|
+
const theme = q.get('theme') || p.theme;
|
|
183395
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183396
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183397
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183398
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183399
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183400
|
+
}
|
|
183401
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183402
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183403
|
+
if (q.get('demo') === '1') return;
|
|
183404
|
+
const b = window.__overrides?.brand;
|
|
183405
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183406
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183407
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183408
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183409
|
+
for (const role of fonts) {
|
|
183410
|
+
const font = b.fonts[role];
|
|
183411
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183412
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183413
|
+
}
|
|
183414
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183415
|
+
};
|
|
183416
|
+
})();
|
|
183417
|
+
|
|
183418
|
+
(function () {
|
|
183419
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183420
|
+
const roles = ["bg","capFill","capShadow","capStroke","credit","dot","paperBottom","paperTop"];
|
|
183421
|
+
const fontRoles = ["caption","credit"];
|
|
183422
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183423
|
+
base(params, query);
|
|
183424
|
+
if (query.get('demo') === '1') return;
|
|
183425
|
+
for (const role of roles) {
|
|
183426
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183427
|
+
}
|
|
183428
|
+
for (const role of fontRoles) {
|
|
183429
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183430
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183431
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183432
|
+
}
|
|
183433
|
+
};
|
|
183434
|
+
})();
|
|
183435
|
+
`
|
|
183436
|
+
},
|
|
183437
|
+
"infografia-de-objetos": {
|
|
183438
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183439
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183440
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183441
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183442
|
+
(function () {
|
|
183443
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183444
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183445
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183446
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183447
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183448
|
+
const theme = q.get('theme') || p.theme;
|
|
183449
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183450
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183451
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183452
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183453
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183454
|
+
}
|
|
183455
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183456
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183457
|
+
if (q.get('demo') === '1') return;
|
|
183458
|
+
const b = window.__overrides?.brand;
|
|
183459
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183460
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183461
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183462
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183463
|
+
for (const role of fonts) {
|
|
183464
|
+
const font = b.fonts[role];
|
|
183465
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183466
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183467
|
+
}
|
|
183468
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183469
|
+
};
|
|
183470
|
+
})();
|
|
183471
|
+
|
|
183472
|
+
(function () {
|
|
183473
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183474
|
+
const roles = ["accent","afterHead","beforeHead","bp","bpEdge","bpFill","bpLine","bpRed","bpSoft","card","chipDark","green","grid","ice","ink","ink2","muted","paper","paperCorner","paperEdge","pill","pillDim","pillText","red","slot","titleBottom","titleTop","yellow"];
|
|
183475
|
+
const fontRoles = ["cap","heavy","mono","name","small"];
|
|
183476
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183477
|
+
base(params, query);
|
|
183478
|
+
if (query.get('demo') === '1') return;
|
|
183479
|
+
for (const role of roles) {
|
|
183480
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183481
|
+
}
|
|
183482
|
+
for (const role of fontRoles) {
|
|
183483
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183484
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183485
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183486
|
+
}
|
|
183487
|
+
};
|
|
183488
|
+
})();
|
|
183489
|
+
`
|
|
183490
|
+
},
|
|
183491
|
+
"ranking-con-escala": {
|
|
183492
|
+
"runtimeSha256": "aa8d22988d8ff149aac5765f021bc4412186b8fae33c00c3d48218894ff19e71",
|
|
183493
|
+
"adaptedRuntimeSha256": "4e0862005eef5fb62860d635756d45e0218e13f0f59342726553cc978320cece",
|
|
183494
|
+
"runtime": "// EditorBrain authored motion \xB7 scene runtime.\n// One canvas, explicit time: window.renderAt(seconds) draws the exact state for that time.\n// URL: ?ratio=wide|square|tall &theme=<kit> &t=<sec> &capture=1 &autoplay=1 &controls=0\n(function () {\n const RATIOS = { wide: [1920, 1080], square: [1080, 1080], tall: [1080, 1920] };\n const LIB_BASE = new URL('..', document.currentScript.src).href; // library root\n const q = new URLSearchParams(location.search);\n const capture = q.get('capture') === '1';\n\n const isObj = v => v && typeof v === 'object' && !Array.isArray(v);\n const merge = (a, b) => {\n if (!isObj(b)) return b === undefined ? a : b;\n const out = { ...(isObj(a) ? a : {}) };\n for (const k of Object.keys(b)) out[k] = merge(out[k], b[k]);\n return out;\n };\n\n function readParams() {\n const el = document.getElementById('params');\n let p = el ? JSON.parse(el.textContent) : {};\n if (window.__overrides) p = merge(p, window.__overrides);\n const enc = q.get('params');\n if (enc) { const supplied = JSON.parse(decodeURIComponent(escape(atob(enc)))); window.__overrides = merge(window.__overrides || {}, supplied); p = merge(p, supplied); }\n window.EB_VALIDATE_PARAMS(p, q);\n return p;\n }\n\n async function loadFonts(F, warn) {\n const families = new Set(Object.values(F).map(f => f.family));\n const status = {};\n for (const fam of families) {\n const defs = (window.EB_FONTS || {})[fam];\n if (!defs) {\n status[fam] = 'not-registered';\n warn(`font family not registered: ${fam}`);\n continue;\n }\n const results = await Promise.all(defs.map(async d => {\n const src = d.local ? d.local.map(n => `local(\"${n}\")`).join(', ') : `url(\"${new URL(d.src, LIB_BASE).href}\")`;\n const desc = {};\n if (d.weight) desc.weight = d.weight;\n if (d.style) desc.style = d.style;\n if (d.stretch) desc.stretch = d.stretch;\n try {\n const face = new FontFace(fam, src, desc);\n await face.load();\n document.fonts.add(face);\n return true;\n } catch (e) {\n return false;\n }\n }));\n const ok = results.filter(Boolean).length;\n status[fam] = ok === defs.length ? 'loaded' : ok ? `partial ${ok}/${defs.length}` : 'missing';\n if (!ok) warn(`font unavailable, renderer would fall back: ${fam}`);\n }\n return status;\n }\n\n function loadImage(src) {\n return new Promise((res, rej) => {\n const img = new Image();\n img.onload = () => res(img);\n img.onerror = () => rej(new Error('image failed: ' + src));\n img.src = src;\n });\n }\n\n function resolveTheme(params) {\n const kits = window.EB_THEMES || {};\n const id = q.get('theme') || params.theme || Object.keys(kits)[0];\n const kit = kits[id] || kits[Object.keys(kits)[0]];\n const brand = params.brand || {};\n const C = { ...kit.colors, ...(brand.colors || {}) };\n C.series = brand.series || kit.series;\n const F = {};\n for (const role of new Set(['display', 'text', 'heavy', 'mono', 'hand', ...Object.keys(brand.fonts || {})])) F[role] = { ...(kit.fonts[role] || kit.fonts.text), ...((brand.fonts || {})[role] || {}) };\n return { id, kit, C, F };\n }\n\n window.EB = {\n RATIOS,\n scene(def) {\n const warnings = new Set();\n const warn = m => { warnings.add(m); if (q.get(\"demo\") !== \"1\") throw new Error(m); };\n try {\n void boot(def, warn, warnings).catch(e => { window.__motionError = String(e && e.stack || e); console.error(window.__motionError); });\n } catch (e) {\n window.__motionError = String(e && e.stack || e);\n throw e;\n }\n },\n };\n\n async function boot(def, warn, warnings) {\n const P = readParams();\n const ratio = q.get('ratio') || P.ratio || 'wide';\n const [W, H] = RATIOS[ratio] || RATIOS.wide;\n const { id: themeId, C, F } = resolveTheme(P);\n const timeScale = P.timeScale || 1;\n const duration = (P.duration || def.duration || 10) * timeScale;\n const fps = P.fps || 30;\n\n document.documentElement.style.background = capture ? C.bg : '#0b0b0a';\n document.body.style.margin = '0';\n const canvas = document.createElement('canvas');\n canvas.id = 'stage';\n canvas.width = W;\n canvas.height = H;\n const ctx = canvas.getContext('2d');\n\n const S = {\n W, H, ratio, P, C, F, themeId, fps, duration, timeScale,\n u: Math.min(W, H) / 1080, // 1 unit = 1px at 1080 short side\n wide: ratio === 'wide', square: ratio === 'square', tall: ratio === 'tall',\n warn, lib: LIB_BASE, frame: 0, images: {}, beats: P.beats || {},\n };\n S.pick = (wide, square, tall) => (S.tall ? tall : S.square ? square : wide);\n\n const fontStatus = await loadFonts(F, warn);\n if (Object.values(fontStatus).some(value => value !== \"loaded\")) throw new Error(\"All registered font faces must load; fallback is not permitted.\");\n for (const [k, rel] of Object.entries(P.media || {})) {\n try { S.images[k] = await loadImage(new URL(rel, location.href).href); } catch (e) { warn(String(e.message)); }\n }\n if (def.setup) await def.setup(S, ctx);\n\n // Scenes with external frames (video clips) define `prepare(t, S)`; renderAt then returns a\n // promise that resolves after those frames are decoded, so captures stay frame-exact.\n function renderAt(t) {\n t = Math.max(0, Math.min(duration, t));\n if (def.prepare) {\n const token = (S._token = (S._token || 0) + 1);\n return Promise.resolve(def.prepare(t / timeScale, S)).then(() => (token === S._token ? paint(t) : false));\n }\n return paint(t);\n }\n function paint(t) {\n S.frame = Math.round(t * fps);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.globalAlpha = 1;\n ctx.globalCompositeOperation = 'source-over';\n ctx.fillStyle = C.bg;\n ctx.fillRect(0, 0, W, H);\n def.draw(ctx, t / timeScale, S);\n return true;\n }\n\n const beatTime = v => (typeof v === 'number' ? v : (S.beats[v] ?? 0));\n // cues from params plus cues the scene derives from its own data (def.cues)\n const rawCues = P.sound?.enabled === false ? [] : [...((P.sound && P.sound.cues) || []), ...(def.cues ? def.cues(S) : [])];\n const cues = rawCues.map(c => ({\n t: +((beatTime(c.at) + (c.offset || 0)) * timeScale).toFixed(4),\n sfx: c.sfx, file: c.file, dur: c.dur, trim: c.trim, gain: c.gain ?? (c.file ? 0.3 : 1),\n })).sort((a, b) => a.t - b.t);\n\n window.renderAt = renderAt;\n window.__sceneMeta = { id: def.id, W, H, ratio, fps, duration, frames: Math.round(duration * fps), theme: themeId, cues, timeScale, music: P.sound?.enabled === false ? null : P.sound?.music || null, voice: P.sound?.enabled === false ? null : P.sound?.voice || null, loudness: P.sound?.enabled === false ? null : P.sound?.loudness || null };\n window.getDiagnostics = () => ({ fonts: fontStatus, warnings: [...warnings], meta: window.__sceneMeta });\n\n document.body.appendChild(canvas);\n if (capture) {\n canvas.style.cssText = 'display:block';\n await renderAt(+(q.get('t') || 0));\n window.__ready = true;\n return;\n }\n preview(canvas, renderAt, S, cues);\n window.__ready = true;\n }\n\n // ---------- interactive preview (never used for rendering) ----------\n function preview(canvas, renderAt, S, cues) {\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n const showControls = q.get('controls') !== '0';\n const style = document.createElement('style');\n style.textContent = `\n body{height:100vh;display:flex;flex-direction:column;font:13px/1.3 -apple-system,system-ui,sans-serif;color:#e9e4da;background:#0b0b0a}\n #wrap{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:${showControls ? '12px' : '0'}}\n #stage{max-width:100%;max-height:100%;width:auto;height:auto;box-shadow:0 10px 40px rgba(0,0,0,.45)}\n #bar{display:flex;gap:10px;align-items:center;padding:10px 14px;background:#151412;border-top:1px solid #2a2824;flex-wrap:wrap}\n #bar button,#bar select{background:#24221f;color:#e9e4da;border:1px solid #3a3732;border-radius:6px;padding:5px 9px;font:inherit;cursor:pointer}\n #bar button.on{background:#E89A4A;color:#1b1a18;border-color:#E89A4A}\n #bar input[type=range]{flex:1;min-width:160px;accent-color:#E89A4A}\n #tm{font-variant-numeric:tabular-nums;min-width:92px}`;\n document.head.appendChild(style);\n const wrap = document.createElement('div');\n wrap.id = 'wrap';\n document.body.appendChild(wrap);\n wrap.appendChild(canvas);\n\n let t = q.has('t') ? +q.get('t') : reduced ? (S.P.reducedHold ?? S.duration * 0.9) : 0;\n let playing = !reduced && q.get('autoplay') === '1';\n let last = null;\n let sound = q.get('sound') === '1';\n const audio = audioEngine(cues, S);\n\n let range, tm, playBtn, soundBtn;\n if (showControls) {\n const bar = document.createElement('div');\n bar.id = 'bar';\n bar.innerHTML = `<button id=\"pp\"></button><input id=\"rg\" type=\"range\" min=\"0\" max=\"${S.duration}\" step=\"${1 / S.fps}\"><span id=\"tm\"></span>\n <span>${['wide', 'square', 'tall'].map(r => `<button data-r=\"${r}\" class=\"${r === S.ratio ? 'on' : ''}\">${{ wide: '16:9', square: '1:1', tall: '9:16' }[r]}</button>`).join(' ')}</span>\n <select id=\"th\">${Object.entries(window.EB_THEMES).map(([k, v]) => `<option value=\"${k}\" ${k === S.themeId ? 'selected' : ''}>${v.label}</option>`).join('')}</select>\n <button id=\"snd\"></button>`;\n document.body.appendChild(bar);\n range = bar.querySelector('#rg');\n tm = bar.querySelector('#tm');\n playBtn = bar.querySelector('#pp');\n soundBtn = bar.querySelector('#snd');\n const go = (k, v) => { const u = new URL(location.href); u.searchParams.set(k, v); u.searchParams.delete('t'); location.href = u.href; };\n bar.querySelectorAll('[data-r]').forEach(b => b.onclick = () => go('ratio', b.dataset.r));\n bar.querySelector('#th').onchange = e => go('theme', e.target.value);\n playBtn.onclick = toggle;\n soundBtn.onclick = () => { sound = !sound; audio.stop(); if (sound && playing) audio.start(t); sync(); };\n range.oninput = () => { t = +range.value; audio.stop(); if (playing && sound) audio.start(t); draw(); };\n }\n addEventListener('keydown', e => { if (e.code === 'Space') { e.preventDefault(); toggle(); } });\n canvas.onclick = toggle;\n function toggle() {\n playing = !playing;\n if (playing && t >= S.duration - 0.01) t = 0;\n last = null;\n audio.stop();\n if (playing && sound) audio.start(t);\n sync();\n }\n function sync() {\n if (!showControls) return;\n playBtn.textContent = playing ? 'Pausa' : 'Reproducir';\n soundBtn.textContent = sound ? 'Sonido: s\xED' : 'Sonido: no';\n soundBtn.className = sound ? 'on' : '';\n soundBtn.disabled = !cues.length;\n if (!cues.length) soundBtn.textContent = 'Sin sonido';\n }\n function draw() {\n renderAt(t);\n if (showControls) {\n range.value = t;\n tm.textContent = `${t.toFixed(2)} / ${S.duration.toFixed(1)} s`;\n }\n }\n // Pause off-screen / hidden tabs.\n let visible = true;\n new IntersectionObserver(es => { visible = es[0].isIntersecting; }).observe(canvas);\n function loop(now) {\n if (playing && visible && !document.hidden) {\n if (last !== null) t += (now - last) / 1000;\n if (t >= S.duration) {\n t = q.get('loop') === '0' ? S.duration : 0;\n if (q.get('loop') === '0') playing = false;\n audio.stop();\n if (playing && sound) audio.start(t);\n }\n draw();\n }\n last = playing ? now : null;\n requestAnimationFrame(loop);\n }\n sync();\n draw();\n requestAnimationFrame(loop);\n }\n\n // Preview-only audio: schedules the scene's cues from the synthesized SFX bank.\n function audioEngine(cues, S) {\n let ac = null, nodes = [];\n const buffers = {};\n async function buf(name) {\n if (!buffers[name]) {\n const r = await fetch(new URL(`sfx/${name}.wav`, S.lib));\n buffers[name] = await ac.decodeAudioData(await r.arrayBuffer());\n }\n return buffers[name];\n }\n return {\n async start(from) {\n if (!cues.length) return;\n ac = ac || new AudioContext();\n const t0 = ac.currentTime + 0.05;\n for (const c of cues) {\n if (c.t < from - 0.02) continue;\n const b = await buf(c.sfx);\n const src = ac.createBufferSource(), g = ac.createGain();\n src.buffer = b;\n g.gain.value = c.gain;\n src.connect(g).connect(ac.destination);\n src.start(t0 + (c.t - from));\n nodes.push(src);\n }\n },\n stop() { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); nodes = []; },\n };\n }\n})();\n",
|
|
183495
|
+
"guard": `// Portable safety wrapper; original scene source is separately hashed.
|
|
183496
|
+
(function () {
|
|
183497
|
+
const fail = message => { throw new Error('EditorBrain project binding: ' + message); };
|
|
183498
|
+
const record = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
183499
|
+
const colors = ['bg','surface','ink','muted','line','accent','accent2','pos','neg'];
|
|
183500
|
+
const fonts = ['display','text','heavy','mono','hand'];
|
|
183501
|
+
window.EB_VALIDATE_PARAMS = (p, q) => {
|
|
183502
|
+
const theme = q.get('theme') || p.theme;
|
|
183503
|
+
if (!Object.hasOwn(window.EB_THEMES || {}, theme)) fail('unknown theme');
|
|
183504
|
+
const ratio = q.get('ratio') || p.ratio || 'wide';
|
|
183505
|
+
if (!['wide','square','tall'].includes(ratio)) fail('unknown ratio');
|
|
183506
|
+
for (const [key, min, max] of [['duration',0.1,300],['fps',1,60],['timeScale',0.1,10]]) {
|
|
183507
|
+
if (p[key] !== undefined && (typeof p[key] !== 'number' || !Number.isFinite(p[key]) || p[key] < min || p[key] > max)) fail(key + ' outside supported range');
|
|
183508
|
+
}
|
|
183509
|
+
if ((p.timeScale ?? 1) !== 1 && (p.sound?.voice || p.sound?.music)) fail('voice/music require timeScale=1 until explicit audio retiming is implemented');
|
|
183510
|
+
if (p.sound?.enabled !== undefined && typeof p.sound.enabled !== 'boolean') fail('sound.enabled must be boolean');
|
|
183511
|
+
if (q.get('demo') === '1') return;
|
|
183512
|
+
const b = window.__overrides?.brand;
|
|
183513
|
+
if (!record(b) || !record(b.colors) || !record(b.fonts)) fail('provide complete window.__overrides.brand from the selected project; demo themes are not customer defaults');
|
|
183514
|
+
for (const role of colors) if (!/^#[0-9a-f]{6}$/i.test(b.colors[role] || '')) fail('missing color role ' + role);
|
|
183515
|
+
if (typeof b.colors.dark !== 'boolean') fail('colors.dark must be explicit');
|
|
183516
|
+
if (!Array.isArray(b.series) || b.series.length < 6 || b.series.some(c => !/^#[0-9a-f]{6}$/i.test(c))) fail('provide at least six explicit series hex colors; roles may repeat project colors but never inherit demo colors');
|
|
183517
|
+
for (const role of fonts) {
|
|
183518
|
+
const font = b.fonts[role];
|
|
183519
|
+
if (!record(font) || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) fail('provide explicit family, weight and style for font role ' + role);
|
|
183520
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) fail('register local font files in EB_FONTS: ' + font.family);
|
|
183521
|
+
}
|
|
183522
|
+
if (!record(window.__overrides.sound) || typeof window.__overrides.sound.enabled !== 'boolean') fail('set sound.enabled from project preferences');
|
|
183523
|
+
};
|
|
183524
|
+
})();
|
|
183525
|
+
|
|
183526
|
+
(function () {
|
|
183527
|
+
const base = window.EB_VALIDATE_PARAMS;
|
|
183528
|
+
const roles = ["bg","credit","hookBox","hookInk","pill","pillInk","scaleInk","scoreInk","title"];
|
|
183529
|
+
const fontRoles = ["credit","hook","pill","scale","score","title"];
|
|
183530
|
+
window.EB_VALIDATE_PARAMS = (params, query) => {
|
|
183531
|
+
base(params, query);
|
|
183532
|
+
if (query.get('demo') === '1') return;
|
|
183533
|
+
for (const role of roles) {
|
|
183534
|
+
if (!/^#[0-9a-f]{6}$/i.test(window.__overrides?.brand?.colors?.[role] || '')) throw new Error('EditorBrain project binding: provide scene-specific color role ' + role + '; never inherit demo/preset brand colors.');
|
|
183535
|
+
}
|
|
183536
|
+
for (const role of fontRoles) {
|
|
183537
|
+
const font = window.__overrides?.brand?.fonts?.[role];
|
|
183538
|
+
if (!font || typeof font.family !== 'string' || !font.family.trim() || !Number.isFinite(font.weight) || font.weight < 100 || font.weight > 1000 || !['normal','italic','oblique'].includes(font.style)) throw new Error('EditorBrain project binding: provide complete scene-specific font role ' + role + '; never inherit demo/preset typography.');
|
|
183539
|
+
if (!Object.hasOwn(window.EB_FONTS || {}, font.family)) throw new Error('EditorBrain project binding: register local font files for role ' + role + ': ' + font.family);
|
|
183540
|
+
}
|
|
183541
|
+
};
|
|
183542
|
+
})();
|
|
183543
|
+
`
|
|
183544
|
+
}
|
|
183545
|
+
};
|
|
183546
|
+
|
|
183547
|
+
// packages/cli/src/style-sources.ts
|
|
183548
|
+
async function downloadStyle(client, id2, version, root, out) {
|
|
183549
|
+
const result2 = await client.request("/v1/style-packs");
|
|
183550
|
+
const selected = result2.sourceStyles?.find((s) => s.id === id2 && s.sourceVersion === version);
|
|
183551
|
+
if (!selected) throw new Error("Exact style source not advertised by the service. Update EditorBrain or choose an available version; do not reconstruct silently.");
|
|
183552
|
+
return downloadPinnedSource(client, { id: id2, version, sha256: selected.sourceSha256, bytes: selected.sourceBytes }, root, out, "style");
|
|
183553
|
+
}
|
|
183554
|
+
async function prepareStyleSource(root, id2, version, file, out) {
|
|
183555
|
+
const selected = getStyleSource(id2, version), guard = styleSourceGuards[id2];
|
|
183556
|
+
if (!selected || !guard) throw new Error("This CLI cannot prepare the exact style version. Update EditorBrain; no version was substituted.");
|
|
183557
|
+
const input = await checkedPath(root, file, false), handle = await open3(input, constants2.O_RDONLY | constants2.O_NOFOLLOW);
|
|
183558
|
+
let bytes;
|
|
183559
|
+
try {
|
|
183560
|
+
const stat = await handle.stat();
|
|
183561
|
+
if (!stat.isFile() || stat.size !== selected.sourceBytes || stat.size > STYLE_SOURCE_MAX_BYTES) throw new Error("Style archive size mismatch");
|
|
183562
|
+
bytes = await handle.readFile();
|
|
183563
|
+
} finally {
|
|
183564
|
+
await handle.close();
|
|
183565
|
+
}
|
|
183566
|
+
const { files } = readStyleArchive(bytes, { id: id2, version, sha256: selected.sourceSha256, bytes: selected.sourceBytes, fileCount: selected.fileCount, unpackedBytes: selected.unpackedBytes });
|
|
183567
|
+
const entry = `styles/${id2}/scene.html`, originalRuntime = files.get("lib/runtime.js");
|
|
183568
|
+
if (!originalRuntime || archiveHash(originalRuntime) !== guard.runtimeSha256 || archiveHash(guard.runtime) !== guard.adaptedRuntimeSha256) throw new Error("Runtime guard pin mismatch");
|
|
183569
|
+
const html = files.get(entry)?.toString("utf8"), marker = '<script src="../../lib/runtime.js"></script>';
|
|
183570
|
+
if (!html || html.split(marker).length !== 2) throw new Error("Unsupported scene entrypoint");
|
|
183571
|
+
files.set(entry, Buffer.from(html.replace(marker, '<script src="../../lib/project-binding.js"></script>\n' + marker)));
|
|
183572
|
+
files.set("lib/runtime.js", Buffer.from(guard.runtime));
|
|
183573
|
+
files.set("lib/project-binding.js", Buffer.from(guard.guard));
|
|
183574
|
+
const guide = `# Copia de trabajo protegida
|
|
183575
|
+
|
|
183576
|
+
Original: ${id2} ${version}, SHA-256 ${selected.sourceSha256}. BUNDLE-MANIFEST.json describe el archivo original; PROJECT-BINDING.json describe esta adaptaci\xF3n de seguridad. No afirmes que el runtime modificado es id\xE9ntico al original.
|
|
183577
|
+
|
|
183578
|
+
Lee las gu\xEDas guardadas en .editorbrain/styles/${id2}/style.md (package/style.md del README original se refiere a esas gu\xEDas, no a una carpeta incluida). Conserva la coreograf\xEDa del estilo y adapta la historia, duraci\xF3n y contenido.
|
|
183579
|
+
|
|
183580
|
+
Antes de runtime.js, define window.__overrides (o usa --params con el renderizador incluido): marca completa del proyecto, colores base y espec\xEDficos de esta escena, fuentes registradas con todos los roles, e indica sound.enabled expl\xEDcitamente. Nunca heredes colores, palabras, avatar, voz, cifras ni medios ficticios de la demo para un cliente. El campo sound.enabled=false silencia tambi\xE9n la voz: respeta el contrato del mezclador y revisa la pista final; no lo confundas con solo desactivar SFX.
|
|
183581
|
+
|
|
183582
|
+
Para inspecci\xF3n del original sirve la copia local y abre ${entry}?demo=1&ratio=tall. Este bypass es solo inspecci\xF3n; no usarlo para producir al cliente. La descarga no ejecut\xF3 c\xF3digo ni instal\xF3 herramientas. Revisa README.md, LICENSES.md, package.json y tools/ antes de ejecutar deliberadamente. Usa una carpeta nueva para cada adaptaci\xF3n y conserva el original.
|
|
183583
|
+
|
|
183584
|
+
El renderer admite --params; valida __ready/__motionError, fuentes, tiempos y audio. Solo 9:16 est\xE1 compuesto aqu\xED. talking_head_prep.py/track.swift usan Apple Vision en macOS; en Linux/Windows usa presenter matte con un motor compatible disponible y aporta clip.mp4, person.webm con alfa, track.json, voice.wav y words.json con el mismo contrato. No ejecutes Swift ni inventes una instalaci\xF3n autom\xE1tica. La transcripci\xF3n/generaci\xF3n debe respetar las integraciones y presupuesto del cliente.
|
|
183585
|
+
|
|
183586
|
+
Un render de demo no certifica transferencia. Revisa el video completo y registra la revisi\xF3n antes de entregar.
|
|
183587
|
+
`;
|
|
183588
|
+
const receipt = { schemaVersion: 1, id: id2, version, sourceSha256: selected.sourceSha256, originalRuntimeSha256: guard.runtimeSha256, adaptedRuntimeSha256: guard.adaptedRuntimeSha256, guardSha256: archiveHash(guard.guard), entrySha256: archiveHash(files.get(entry)), brandBound: false, executed: false, rendered: false };
|
|
183589
|
+
files.set("PROJECT-BINDING.md", Buffer.from(guide));
|
|
183590
|
+
files.set("PROJECT-BINDING.json", Buffer.from(JSON.stringify(receipt, null, 2) + "\n"));
|
|
183591
|
+
const target = await checkedPath(root, out, false);
|
|
183592
|
+
await mkdir3(dirname3(target), { recursive: true });
|
|
183593
|
+
await checkedPath(root, out, false);
|
|
183594
|
+
await mkdir3(target, { mode: 448 });
|
|
183595
|
+
try {
|
|
183596
|
+
for (const [name, data] of files) {
|
|
183597
|
+
const destination = await checkedPath(target, name, false);
|
|
183598
|
+
await mkdir3(dirname3(destination), { recursive: true });
|
|
183599
|
+
await writeFile(destination, data, { flag: "wx", mode: 384 });
|
|
183600
|
+
}
|
|
183601
|
+
} catch (error) {
|
|
183602
|
+
await rm(target, { recursive: true, force: true });
|
|
183603
|
+
throw error;
|
|
183604
|
+
}
|
|
183605
|
+
return { ...receipt, path: target, extracted: true, next: "Read PROJECT-BINDING.md and the selected style guides. Bind current project preferences and replace demo media before explicitly rendering. No dependencies installed." };
|
|
183606
|
+
}
|
|
183607
|
+
|
|
183608
|
+
// packages/cli/src/team-command.ts
|
|
183609
|
+
async function teamCommand(client, subcommand, flags) {
|
|
183610
|
+
const value = (key) => {
|
|
183611
|
+
const v = flags[key];
|
|
183612
|
+
return typeof v === "string" ? v : void 0;
|
|
183613
|
+
};
|
|
183614
|
+
const required = (key) => {
|
|
183615
|
+
const v = value(key);
|
|
183616
|
+
if (!v) throw new Error(`Missing --${key}`);
|
|
183617
|
+
return v;
|
|
183618
|
+
};
|
|
183619
|
+
const common = ["url", "dir"];
|
|
183620
|
+
const allowed = {
|
|
183621
|
+
access: [],
|
|
183622
|
+
members: [],
|
|
183623
|
+
projects: [],
|
|
183624
|
+
invite: ["email", "kind", "scope"],
|
|
183625
|
+
cancel: ["id"],
|
|
183626
|
+
remove: ["user", "confirm"],
|
|
183627
|
+
reviews: ["project", "after"],
|
|
183628
|
+
share: ["project", "revision", "confirm"],
|
|
183629
|
+
withdraw: ["project", "revision", "confirm"],
|
|
183630
|
+
comment: ["project", "revision", "context-version", "text", "at-ms", "id"],
|
|
183631
|
+
approve: ["project", "revision", "context-version", "user-confirmed"]
|
|
183632
|
+
};
|
|
183633
|
+
if (!subcommand || !allowed[subcommand])
|
|
183634
|
+
throw new Error(
|
|
183635
|
+
"Use team access|members|projects|invite|cancel|remove|reviews|share|withdraw|comment|approve."
|
|
183636
|
+
);
|
|
183637
|
+
for (const key of Object.keys(flags))
|
|
183638
|
+
if (!common.includes(key) && !allowed[subcommand].includes(key))
|
|
183639
|
+
throw new Error(`--${key} is not supported for team ${subcommand}.`);
|
|
183640
|
+
if (subcommand === "access") return client.request("/v1/team");
|
|
183641
|
+
if (["members", "projects"].includes(subcommand))
|
|
183642
|
+
return client.request("/v1/team/" + subcommand);
|
|
183643
|
+
if (subcommand === "invite") {
|
|
183644
|
+
const kind = required("kind");
|
|
183645
|
+
if (!["brand_editor", "project_reviewer"].includes(kind))
|
|
183646
|
+
throw new Error("Use --kind brand_editor or project_reviewer.");
|
|
183647
|
+
return client.request("/v1/team/invitations", {
|
|
183648
|
+
method: "POST",
|
|
183649
|
+
body: { email: required("email"), kind, scopeId: required("scope") }
|
|
183650
|
+
});
|
|
183651
|
+
}
|
|
183652
|
+
if (subcommand === "cancel")
|
|
183653
|
+
return client.request(
|
|
183654
|
+
"/v1/team/invitations/" + encodeURIComponent(required("id")),
|
|
183655
|
+
{ method: "DELETE" }
|
|
183656
|
+
);
|
|
183657
|
+
if (subcommand === "remove") {
|
|
183658
|
+
if (flags.confirm !== true)
|
|
183659
|
+
throw new Error(
|
|
183660
|
+
"Removing access requires --confirm after the user requests removal. Files are preserved."
|
|
183661
|
+
);
|
|
183662
|
+
return client.request(
|
|
183663
|
+
"/v1/team/members/" + encodeURIComponent(required("user")),
|
|
183664
|
+
{ method: "DELETE" }
|
|
183665
|
+
);
|
|
183666
|
+
}
|
|
183667
|
+
const base = "/v1/team/projects/" + encodeURIComponent(required("project")) + "/reviews";
|
|
183668
|
+
if (subcommand === "reviews")
|
|
183669
|
+
return client.request(
|
|
183670
|
+
base + (value("after") ? "?after=" + encodeURIComponent(value("after")) : "")
|
|
183671
|
+
);
|
|
183672
|
+
const revision2 = required("revision");
|
|
183673
|
+
if (!/^[a-f0-9-]{36}$/.test(revision2))
|
|
183674
|
+
throw new Error("Use the exact revision UUID returned by team reviews.");
|
|
183675
|
+
if (["share", "withdraw"].includes(subcommand)) {
|
|
183676
|
+
if (flags.confirm !== true)
|
|
183677
|
+
throw new Error(
|
|
183678
|
+
"Use --confirm for an explicitly requested sharing change."
|
|
183679
|
+
);
|
|
183680
|
+
return client.request(base + "/" + revision2 + "/share", {
|
|
183681
|
+
method: "POST",
|
|
183682
|
+
body: { shared: subcommand === "share" }
|
|
183683
|
+
});
|
|
183684
|
+
}
|
|
183685
|
+
const contextVersion = required("context-version");
|
|
183686
|
+
if (!/^[a-f0-9]{64}$/.test(contextVersion))
|
|
183687
|
+
throw new Error("Use the exact context hash of the reviewed sample.");
|
|
183688
|
+
if (subcommand === "approve") {
|
|
183689
|
+
if (flags["user-confirmed"] !== true)
|
|
183690
|
+
throw new Error(
|
|
183691
|
+
"Approval requires explicit user acceptance and --user-confirmed."
|
|
183692
|
+
);
|
|
183693
|
+
return client.request(base + "/" + revision2 + "/approve", {
|
|
183694
|
+
method: "POST",
|
|
183695
|
+
body: { contextVersion, userConfirmed: true }
|
|
183696
|
+
});
|
|
183697
|
+
}
|
|
183698
|
+
const at = value("at-ms"), startMs = at === void 0 ? void 0 : Number(at);
|
|
183699
|
+
if (startMs !== void 0 && (!Number.isSafeInteger(startMs) || startMs < 0 || startMs > 36e6))
|
|
183700
|
+
throw new Error("--at-ms must be an integer between 0 and 36000000.");
|
|
183701
|
+
const feedbackId = required("id");
|
|
183702
|
+
if (!/^[a-f0-9-]{36}$/.test(feedbackId))
|
|
183703
|
+
throw new Error(
|
|
183704
|
+
"Use --id with a fresh UUID; reuse it for retries of this exact comment."
|
|
183705
|
+
);
|
|
183706
|
+
return client.request(base + "/" + revision2 + "/comment", {
|
|
183707
|
+
method: "POST",
|
|
183708
|
+
body: {
|
|
183709
|
+
contextVersion,
|
|
183710
|
+
feedbackId,
|
|
183711
|
+
text: required("text"),
|
|
183712
|
+
target: startMs === void 0 ? {} : { startMs }
|
|
183713
|
+
}
|
|
183714
|
+
});
|
|
183715
|
+
}
|
|
183716
|
+
|
|
183717
|
+
// packages/cli/src/personal-resources.ts
|
|
183718
|
+
import { basename, extname as extname2, resolve as resolve3 } from "node:path";
|
|
183719
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
183720
|
+
|
|
183721
|
+
// packages/cli/src/media-runtime.ts
|
|
183722
|
+
import { spawn } from "node:child_process";
|
|
183723
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
182386
183724
|
import { constants as constants3 } from "node:fs";
|
|
182387
|
-
import {
|
|
182388
|
-
import { dirname as
|
|
183725
|
+
import { lstat as lstat3, open as open4, realpath as realpath2 } from "node:fs/promises";
|
|
183726
|
+
import { dirname as dirname4, extname, parse, resolve as resolve2 } from "node:path";
|
|
183727
|
+
var MediaToolError = class extends CliError {
|
|
183728
|
+
constructor(code, message) {
|
|
183729
|
+
super(code, message, code === "MEDIA_TOOL_NOT_FOUND" ? "Install FFmpeg/FFprobe separately and make them available on PATH; no account or model is needed." : "Review the local input and reported limit. An incomplete check does not validate the media.");
|
|
183730
|
+
this.name = "MediaToolError";
|
|
183731
|
+
}
|
|
183732
|
+
};
|
|
183733
|
+
var SUPPORTED_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
183734
|
+
".mp4",
|
|
183735
|
+
".mov",
|
|
183736
|
+
".m4v",
|
|
183737
|
+
".mkv",
|
|
183738
|
+
".webm",
|
|
183739
|
+
".avi",
|
|
183740
|
+
".mpg",
|
|
183741
|
+
".mpeg",
|
|
183742
|
+
".mts",
|
|
183743
|
+
".m2ts",
|
|
183744
|
+
".ts",
|
|
183745
|
+
".ogv",
|
|
183746
|
+
".wmv",
|
|
183747
|
+
".wav",
|
|
183748
|
+
".mp3",
|
|
183749
|
+
".m4a",
|
|
183750
|
+
".aac",
|
|
183751
|
+
".flac",
|
|
183752
|
+
".ogg",
|
|
183753
|
+
".opus",
|
|
183754
|
+
".aif",
|
|
183755
|
+
".aiff",
|
|
183756
|
+
".ac3",
|
|
183757
|
+
".eac3",
|
|
183758
|
+
".jpg",
|
|
183759
|
+
".jpeg",
|
|
183760
|
+
".png",
|
|
183761
|
+
".webp",
|
|
183762
|
+
".bmp",
|
|
183763
|
+
".tif",
|
|
183764
|
+
".tiff",
|
|
183765
|
+
".gif",
|
|
183766
|
+
".avif",
|
|
183767
|
+
".heic",
|
|
183768
|
+
".heif"
|
|
183769
|
+
]);
|
|
183770
|
+
var PROTOCOLS = "file,pipe";
|
|
183771
|
+
var FORMATS = "mov,matroska,webm,avi,mpeg,mpegts,ogg,wav,flac,mp3,aac,aiff,ac3,eac3,asf,jpeg_pipe,png_pipe,webp_pipe,bmp_pipe,tiff_pipe,gif,heif,avif";
|
|
183772
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
183773
|
+
var DEFAULT_OUTPUT_LIMIT = 2 * 1024 * 1024;
|
|
183774
|
+
function resolveLocalMediaPath(value) {
|
|
183775
|
+
if (!value || value.includes("\0") || /[\r\n]/.test(value) || /^[a-z][a-z\d+.-]*:/i.test(value) && !(process.platform === "win32" && /^[a-z]:[\\/]/i.test(value)) || value.startsWith("\\\\")) {
|
|
183776
|
+
throw new MediaToolError("MEDIA_LOCAL_PATH_REQUIRED", "Provide a local filesystem path, not a URL, protocol or network share.");
|
|
183777
|
+
}
|
|
183778
|
+
return resolve2(value);
|
|
183779
|
+
}
|
|
183780
|
+
async function assertNoMediaSymlinks(value) {
|
|
183781
|
+
const path = resolveLocalMediaPath(value);
|
|
183782
|
+
let cursor = path;
|
|
183783
|
+
while (cursor !== parse(cursor).root) {
|
|
183784
|
+
const info = await lstat3(cursor);
|
|
183785
|
+
if (info.isSymbolicLink()) {
|
|
183786
|
+
const systemAlias = process.platform === "darwin" && (cursor === "/tmp" || cursor === "/var") && await realpath2(cursor) === `/private${cursor}`;
|
|
183787
|
+
if (!systemAlias) throw new MediaToolError("MEDIA_SYMLINK", "Symlink media paths are not followed. Use the original local path.");
|
|
183788
|
+
}
|
|
183789
|
+
cursor = dirname4(cursor);
|
|
183790
|
+
}
|
|
183791
|
+
return path;
|
|
183792
|
+
}
|
|
183793
|
+
async function assertLocalMediaFile(value) {
|
|
183794
|
+
const path = await assertNoMediaSymlinks(value);
|
|
183795
|
+
const info = await lstat3(path);
|
|
183796
|
+
if (!info.isFile()) throw new MediaToolError("MEDIA_NOT_REGULAR", "The media input must be a regular local file.");
|
|
183797
|
+
if (!SUPPORTED_MEDIA_EXTENSIONS.has(extname(path).toLowerCase())) throw new MediaToolError("MEDIA_FORMAT_UNSUPPORTED", "This file extension is not supported for local media inspection.");
|
|
183798
|
+
return path;
|
|
183799
|
+
}
|
|
183800
|
+
function localInputArgs(path) {
|
|
183801
|
+
return ["-protocol_whitelist", PROTOCOLS, "-format_whitelist", FORMATS, "-i", resolveLocalMediaPath(path)];
|
|
183802
|
+
}
|
|
183803
|
+
async function runMediaTool(tool, args, options = {}) {
|
|
183804
|
+
if (tool !== "ffmpeg" && tool !== "ffprobe") throw new MediaToolError("MEDIA_TOOL_INVALID", "Unsupported media executable.");
|
|
183805
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT;
|
|
183806
|
+
const maxOutputBytes = options.maxOutputBytes ?? DEFAULT_OUTPUT_LIMIT;
|
|
183807
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 10 * 6e4 || !Number.isInteger(maxOutputBytes) || maxOutputBytes < 1 || maxOutputBytes > 16 * 1024 * 1024) {
|
|
183808
|
+
throw new MediaToolError("MEDIA_TOOL_LIMITS_INVALID", "Media runtime limits are outside the supported range.");
|
|
183809
|
+
}
|
|
183810
|
+
if (!Array.isArray(args) || args.length > 200 || args.some((arg) => typeof arg !== "string" || arg.length > 8192 || arg.includes("\0"))) {
|
|
183811
|
+
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "Invalid media tool arguments.");
|
|
183812
|
+
}
|
|
183813
|
+
for (let i = 0; i < args.length; i++) {
|
|
183814
|
+
const arg = args[i];
|
|
183815
|
+
if (/(?:^|[=,;\s])(?:https?|ftp|sftp|tcp|udp|rtsp|rtmp|smb|data|concat|subfile|crypto):/i.test(arg) || arg === "-safe" && args[i + 1] === "0" || arg === "-enable_drefs" && args[i + 1] !== "0") {
|
|
183816
|
+
throw new MediaToolError("MEDIA_REMOTE_INPUT_FORBIDDEN", "Only self-contained local media inputs are allowed.");
|
|
183817
|
+
}
|
|
183818
|
+
if (arg === "-protocol_whitelist" && args[i + 1] !== PROTOCOLS || arg === "-format_whitelist" && args[i + 1] !== FORMATS) {
|
|
183819
|
+
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "The local media allowlists cannot be widened.");
|
|
183820
|
+
}
|
|
183821
|
+
if (arg === "-i") {
|
|
183822
|
+
await assertLocalMediaFile(args[i + 1] ?? "");
|
|
183823
|
+
if (args[i - 4] !== "-protocol_whitelist" || args[i - 3] !== PROTOCOLS || args[i - 2] !== "-format_whitelist" || args[i - 1] !== FORMATS) {
|
|
183824
|
+
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "Every media input must use localInputArgs.");
|
|
183825
|
+
}
|
|
183826
|
+
}
|
|
183827
|
+
}
|
|
183828
|
+
return new Promise((resolveResult, reject) => {
|
|
183829
|
+
const stdout = [], stderr = [];
|
|
183830
|
+
let size = 0, done = false;
|
|
183831
|
+
const child = spawn(tool, ["-hide_banner", ...tool === "ffmpeg" ? ["-nostdin"] : [], ...args], { shell: false, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
183832
|
+
const fail3 = (error) => {
|
|
183833
|
+
if (done) return;
|
|
183834
|
+
done = true;
|
|
183835
|
+
clearTimeout(timer);
|
|
183836
|
+
child.kill("SIGKILL");
|
|
183837
|
+
reject(error);
|
|
183838
|
+
};
|
|
183839
|
+
const timer = setTimeout(() => fail3(new MediaToolError("MEDIA_TOOL_TIMEOUT", "The local media check exceeded its time limit. No complete result is available.")), timeoutMs);
|
|
183840
|
+
const collect = (target) => (chunk) => {
|
|
183841
|
+
if (done) return;
|
|
183842
|
+
size += chunk.length;
|
|
183843
|
+
if (size > maxOutputBytes) return fail3(new MediaToolError("MEDIA_TOOL_OUTPUT_LIMIT", "The local media check exceeded its output limit. No complete result is available."));
|
|
183844
|
+
target.push(chunk);
|
|
183845
|
+
};
|
|
183846
|
+
child.stdout.on("data", collect(stdout));
|
|
183847
|
+
child.stderr.on("data", collect(stderr));
|
|
183848
|
+
child.on("error", (error) => fail3(new MediaToolError(error.code === "ENOENT" ? "MEDIA_TOOL_NOT_FOUND" : "MEDIA_TOOL_FAILED", error.code === "ENOENT" ? `${tool} is not installed or available on PATH. Install it separately to use local media checks.` : "The local media executable could not run.")));
|
|
183849
|
+
child.on("close", (code) => {
|
|
183850
|
+
if (done) return;
|
|
183851
|
+
done = true;
|
|
183852
|
+
clearTimeout(timer);
|
|
183853
|
+
if (code !== 0) return reject(new MediaToolError("MEDIA_TOOL_FAILED", "The local media tool could not inspect or decode this input. No complete result is available."));
|
|
183854
|
+
resolveResult({ stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8") });
|
|
183855
|
+
});
|
|
183856
|
+
});
|
|
183857
|
+
}
|
|
183858
|
+
var finite2 = (value) => {
|
|
183859
|
+
if (typeof value !== "number" && typeof value !== "string" || value === "") return null;
|
|
183860
|
+
const n = Number(value);
|
|
183861
|
+
return Number.isFinite(n) ? n : null;
|
|
183862
|
+
};
|
|
183863
|
+
var nonnegative2 = (value) => {
|
|
183864
|
+
const n = finite2(value);
|
|
183865
|
+
return n !== null && n >= 0 ? n : null;
|
|
183866
|
+
};
|
|
183867
|
+
var positiveInteger = (value) => {
|
|
183868
|
+
const n = finite2(value);
|
|
183869
|
+
return n !== null && Number.isInteger(n) && n > 0 ? n : void 0;
|
|
183870
|
+
};
|
|
183871
|
+
var rate2 = (value) => {
|
|
183872
|
+
if (typeof value !== "string" || !/^\d+(?:\/\d+)?$/.test(value)) return null;
|
|
183873
|
+
const [n, d = "1"] = value.split("/");
|
|
183874
|
+
const result2 = Number(n) / Number(d);
|
|
183875
|
+
return Number.isFinite(result2) && result2 > 0 ? result2 : null;
|
|
183876
|
+
};
|
|
183877
|
+
var sameFile = (a, b) => a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
|
|
183878
|
+
function hasDisplayTransform(stream) {
|
|
183879
|
+
const rotate = stream.tags?.rotate;
|
|
183880
|
+
if (rotate !== void 0 && (!Number.isFinite(Number(rotate)) || Number(rotate) % 360 !== 0)) return true;
|
|
183881
|
+
const sideData = Array.isArray(stream.side_data_list) ? stream.side_data_list : [];
|
|
183882
|
+
return sideData.some((data) => {
|
|
183883
|
+
if (!data || typeof data !== "object") return false;
|
|
183884
|
+
if (data.rotation !== void 0 && (!Number.isFinite(Number(data.rotation)) || Number(data.rotation) % 360 !== 0)) return true;
|
|
183885
|
+
if (data.displaymatrix === void 0) return data.side_data_type === "Display Matrix";
|
|
183886
|
+
if (typeof data.displaymatrix !== "string") return true;
|
|
183887
|
+
const values = data.displaymatrix.trim().split("\n").flatMap((line) => line.replace(/^[^:]*:/, "").trim().split(/\s+/).map(Number));
|
|
183888
|
+
const identity = [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824];
|
|
183889
|
+
return values.length !== 9 || values.some((value, index) => value !== identity[index]);
|
|
183890
|
+
});
|
|
183891
|
+
}
|
|
183892
|
+
async function probeLocalMedia(value) {
|
|
183893
|
+
const path = await assertLocalMediaFile(value);
|
|
183894
|
+
const handle = await open4(path, constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0));
|
|
183895
|
+
try {
|
|
183896
|
+
const before = await handle.stat();
|
|
183897
|
+
if (!before.isFile()) throw new MediaToolError("MEDIA_NOT_REGULAR", "The media input must be a regular local file.");
|
|
183898
|
+
const entries = "format=duration,start_time:stream=index,codec_type,codec_name,width,height,avg_frame_rate,sample_rate,channels,duration,color_transfer,sample_aspect_ratio,pix_fmt:stream_disposition=attached_pic:stream_side_data=side_data_type,rotation,displaymatrix:stream_tags=rotate";
|
|
183899
|
+
const { stdout } = await runMediaTool("ffprobe", ["-v", "error", "-show_entries", entries, "-of", "json", ...localInputArgs(path)]);
|
|
183900
|
+
const hash6 = createHash3("sha256");
|
|
183901
|
+
for await (const chunk of handle.createReadStream({ autoClose: false })) hash6.update(chunk);
|
|
183902
|
+
const after = await handle.stat();
|
|
183903
|
+
await assertNoMediaSymlinks(path);
|
|
183904
|
+
const current2 = await lstat3(path);
|
|
183905
|
+
if (!sameFile(before, after) || !sameFile(after, current2)) throw new MediaToolError("MEDIA_FILE_CHANGED", "The media file changed while it was being inspected. Retry with a stable source.");
|
|
183906
|
+
let raw;
|
|
183907
|
+
try {
|
|
183908
|
+
raw = JSON.parse(stdout);
|
|
183909
|
+
} catch {
|
|
183910
|
+
throw new MediaToolError("MEDIA_PROBE_INVALID", "The media probe returned invalid metadata.");
|
|
183911
|
+
}
|
|
183912
|
+
if (!raw || !Array.isArray(raw.streams) || raw.streams.length > 256 || raw.streams.some((stream) => !stream || typeof stream !== "object" || Array.isArray(stream))) throw new MediaToolError("MEDIA_PROBE_INVALID", "The media probe returned invalid or excessive stream metadata.");
|
|
183913
|
+
const streams = raw.streams.map((stream, offset) => {
|
|
183914
|
+
const type = typeof stream.codec_type === "string" && /^(video|audio|subtitle|data|attachment|unknown)$/.test(stream.codec_type) ? stream.codec_type : "unknown";
|
|
183915
|
+
const codec = typeof stream.codec_name === "string" && /^[a-zA-Z0-9_]{1,64}$/.test(stream.codec_name) ? stream.codec_name : null;
|
|
183916
|
+
const index = finite2(stream.index);
|
|
183917
|
+
return {
|
|
183918
|
+
index: index !== null && Number.isInteger(index) && index >= 0 ? index : offset,
|
|
183919
|
+
type,
|
|
183920
|
+
codec,
|
|
183921
|
+
durationSeconds: nonnegative2(stream.duration),
|
|
183922
|
+
...type === "video" ? { displayTransformed: hasDisplayTransform(stream), width: positiveInteger(stream.width), height: positiveInteger(stream.height), fps: rate2(stream.avg_frame_rate), ...typeof stream.sample_aspect_ratio === "string" ? { sampleAspectRatio: stream.sample_aspect_ratio } : {}, ...typeof stream.pix_fmt === "string" ? { pixelFormat: stream.pix_fmt } : {}, ...typeof stream.color_transfer === "string" ? { colorTransfer: stream.color_transfer } : {}, attachedPicture: stream.disposition?.attached_pic === 1 } : {},
|
|
183923
|
+
...type === "audio" ? { sampleRate: nonnegative2(stream.sample_rate), channels: positiveInteger(stream.channels) ?? null } : {}
|
|
183924
|
+
};
|
|
183925
|
+
});
|
|
183926
|
+
return { path, sha256: hash6.digest("hex"), bytes: after.size, durationSeconds: nonnegative2(raw.format?.duration), startTimeSeconds: finite2(raw.format?.start_time), streams };
|
|
183927
|
+
} finally {
|
|
183928
|
+
await handle.close();
|
|
183929
|
+
}
|
|
183930
|
+
}
|
|
183931
|
+
|
|
183932
|
+
// packages/cli/src/production-output.ts
|
|
183933
|
+
import { constants as constants4 } from "node:fs";
|
|
183934
|
+
import { mkdir as mkdir4, open as open5 } from "node:fs/promises";
|
|
183935
|
+
import { dirname as dirname5 } from "node:path";
|
|
182389
183936
|
async function productionOutputPath(root, relativePath) {
|
|
182390
183937
|
if (!relativePath.startsWith(".editorbrain-local/") || relativePath.split(/[\\/]/).some((p) => !p || p === ".." || p === ".") || /[\\\x00-\x1f\x7f]/.test(relativePath)) {
|
|
182391
183938
|
throw new CliError("LOCAL_OUTPUT_REQUIRED", "Production output must be inside .editorbrain-local/.", "Use --out .editorbrain-local/<project>/inventory.json, or omit --out for JSON stdout. These reports are not synced.");
|
|
@@ -182394,13 +183941,13 @@ async function productionOutputPath(root, relativePath) {
|
|
|
182394
183941
|
}
|
|
182395
183942
|
async function prepareSampleDirectory(root, path) {
|
|
182396
183943
|
const target = await productionOutputPath(root, path);
|
|
182397
|
-
await
|
|
183944
|
+
await mkdir4(dirname5(target), { recursive: true });
|
|
182398
183945
|
await productionOutputPath(root, path);
|
|
182399
183946
|
return target;
|
|
182400
183947
|
}
|
|
182401
183948
|
async function readProductionJson(root, path) {
|
|
182402
183949
|
const target = await checkedPath(root, path, false);
|
|
182403
|
-
const handle = await
|
|
183950
|
+
const handle = await open5(target, constants4.O_RDONLY | constants4.O_NOFOLLOW | constants4.O_NONBLOCK);
|
|
182404
183951
|
try {
|
|
182405
183952
|
const stat = await handle.stat();
|
|
182406
183953
|
if (!stat.isFile() || stat.size > 16 * 1024 * 1024) throw new CliError("INVALID_REPORT", "Expected a regular JSON file of at most 16 MiB.", "Select a local inventory, plan or check profile.");
|
|
@@ -182538,7 +184085,7 @@ async function registerLocalResource(client, root, file, options = {}) {
|
|
|
182538
184085
|
} while (!existing && after);
|
|
182539
184086
|
if (existing) break;
|
|
182540
184087
|
}
|
|
182541
|
-
const id2 = existing?.id ??
|
|
184088
|
+
const id2 = existing?.id ?? randomUUID3();
|
|
182542
184089
|
const result2 = existing ? await client.request("/v1/resources/" + id2) : await client.request("/v1/resources/" + id2, { method: "PUT", body: { resource, expectedRevision: 0 } });
|
|
182543
184090
|
const me = await client.request("/v1/me");
|
|
182544
184091
|
const namespace = (await sha256(client.url + "\n" + me.workspaceId)).slice(0, 32), path = `.editorbrain-local/resources/${namespace}/${id2}.json`;
|
|
@@ -182629,15 +184176,15 @@ async function personalResourceCommand(client, root, command, arg, flags) {
|
|
|
182629
184176
|
|
|
182630
184177
|
// packages/cli/src/update.ts
|
|
182631
184178
|
import { execFile } from "node:child_process";
|
|
182632
|
-
import { lstat as
|
|
184179
|
+
import { lstat as lstat7, readFile as readFile3, realpath as realpath3 } from "node:fs/promises";
|
|
182633
184180
|
import { homedir as homedir2 } from "node:os";
|
|
182634
|
-
import { delimiter, dirname as
|
|
184181
|
+
import { delimiter, dirname as dirname6, join as join5, resolve as resolve5 } from "node:path";
|
|
182635
184182
|
import { promisify } from "node:util";
|
|
182636
184183
|
|
|
182637
184184
|
// packages/cli/src/agent-guidance.ts
|
|
182638
|
-
import { createHash as
|
|
182639
|
-
import { constants as
|
|
182640
|
-
import { lstat as
|
|
184185
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
184186
|
+
import { constants as constants5 } from "node:fs";
|
|
184187
|
+
import { lstat as lstat4, open as open6, readdir as readdir2, rename as rename2 } from "node:fs/promises";
|
|
182641
184188
|
import { fileURLToPath } from "node:url";
|
|
182642
184189
|
|
|
182643
184190
|
// packages/cli/src/agent-guidance-history.ts
|
|
@@ -183179,6 +184726,51 @@ var VERIFIED_GUIDANCE_RELEASES = [
|
|
|
183179
184726
|
"editorbrain/references/style-creator.md": "1b1bc289a5bc308cbbf7f4d699de2933b8934733a2b69b3e98fb1b7420d986f2",
|
|
183180
184727
|
"editorbrain/references/workspace-files.md": "29bbddc894ed000bddd065bcb660629e64b29a5cf54dd6850e810b25c990558d"
|
|
183181
184728
|
}
|
|
184729
|
+
},
|
|
184730
|
+
{
|
|
184731
|
+
"version": "0.40.1",
|
|
184732
|
+
"archiveSha256": "3693f4edcf54ab705177f4fb5bac1cafc79182d5cb85aaf4594e644dbb6261c7",
|
|
184733
|
+
"files": {
|
|
184734
|
+
"editorbrain-formats/SKILL.md": "65ea59aae091ca9618b5e479befe0c76edf174df7091ed74d4307485a2252fcd",
|
|
184735
|
+
"editorbrain-formats/references/aspirational-list-demo.md": "e884ce44d15f4496812ed18120f7d4c49c4261e148fcefe05c77c110b589771c",
|
|
184736
|
+
"editorbrain-formats/references/cumulative-tier-list.md": "7b7e8208687c6b925443e55d640ced6c1d09824377884244a09d7f3089d60aa5",
|
|
184737
|
+
"editorbrain-formats/references/numbered-tutorial.md": "95754ae7dbfaa678e11ddf1a2b84710dba83a16e2fa4055051bd4f5f4f868a5f",
|
|
184738
|
+
"editorbrain-motion/SKILL.md": "7c27051ae2b7597e45cfafaecb37be79a7cd9bd9788ae515723dbc20c2f34a37",
|
|
184739
|
+
"editorbrain-motion/references/authored-scenes.md": "52e97b89b1d8a288c4ce7bd133eafea84e934ef2bf03ffe2dcef8c368b6f977d",
|
|
184740
|
+
"editorbrain-motion/references/code-motion.md": "50382a797adc1e1596086e2408e81ee75ceb6730ca409be9c884646db643a7cd",
|
|
184741
|
+
"editorbrain-motion/references/component-library.md": "e88ed19d2ab9dca8d2ea02abe6c476021c03b9679bce99292cf7da52d65d2236",
|
|
184742
|
+
"editorbrain-motion/references/generated-motion.md": "a8d214b53c15f742658abd84f03b768fa2821f8cde94f50aab82a3759a30b36b",
|
|
184743
|
+
"editorbrain-motion/references/motion-craft.md": "dae520b0e641fc9c3bf937241936588a855bf3453358e239ccc3cc3a2bcf0825",
|
|
184744
|
+
"editorbrain/AGENTS.md": "b240449d452c824415062a2b422bf55a5ae2d868a81083989d10ffaeb5c33a3f",
|
|
184745
|
+
"editorbrain/SKILL.md": "1fed72fafd89407a8750eda7a663b6a0100de51fdbbb57a41b39d36489bd09d3",
|
|
184746
|
+
"editorbrain/references/audio-production.md": "9800505dcb320b58f35aeaed77303039d8fffb2c29b46c43cedeeba8637d2482",
|
|
184747
|
+
"editorbrain/references/cli-mcp.md": "3e2b27e45050410da9d0e425fd90ef816579d3c39331e7cb83b81c5862d8e7de",
|
|
184748
|
+
"editorbrain/references/editorial-evidence.md": "16ce55316b330e5fec85654012ccbdd78ec1175bfd092762638c93c57d845a72",
|
|
184749
|
+
"editorbrain/references/editorial-families.md": "b802ec6f02fd079e99df84d69a3c515d63ad058960b568c0c7b7dec1912495dd",
|
|
184750
|
+
"editorbrain/references/family-animated.md": "54a140d0a64b01147c52ea8cbaab4e4599bfe1af330f5a3ad6ef2a30351ab47d",
|
|
184751
|
+
"editorbrain/references/family-demonstration.md": "737334a8d9230682cde3a6ed11bfc02c4f9795c8f25a3b668be9d7393ec3e53d",
|
|
184752
|
+
"editorbrain/references/family-essay.md": "003f2cd450f33ba6641a9b1114cbc578c04cbb658b992c89c765d43198d1b4c2",
|
|
184753
|
+
"editorbrain/references/family-personal.md": "e93c304d7bc7d3eb31a3c9cb3be83f4f48d41319c2ac2e1e6f53f38576f5e644",
|
|
184754
|
+
"editorbrain/references/family-presenter.md": "76b8140b924930b306ce97772d6a7b683870bd14f19772b5339a490752b7de24",
|
|
184755
|
+
"editorbrain/references/first-edit.md": "483843af6672b70a76ce6d41e98324fbfc2a31d5ac50633f963d1ab0eeba1bc0",
|
|
184756
|
+
"editorbrain/references/integrations.md": "b5e7ba099acd79053cdd09822092eb121add6de39eada2d6911ad5a4f452ce2a",
|
|
184757
|
+
"editorbrain/references/local-production.md": "268a05706a3c1cae4f61248437c00be3e9ee18b2a0f747c8cd054d88f0a33661",
|
|
184758
|
+
"editorbrain/references/media-preferences.md": "87e508a75cdb6f4644db767273bfb230fb79f182ed05ee0f6257c6c05ea4dc7a",
|
|
184759
|
+
"editorbrain/references/memory-and-review.md": "406589a18e9e86ad8ce7d71e0f5bf00f67dab42c05af7721482fdca1c25c7c1b",
|
|
184760
|
+
"editorbrain/references/motion-review.md": "0fb09a2d61ecd13114ced5cca5daa4580a922cf7d7b3f8698077ceb0e96da6f0",
|
|
184761
|
+
"editorbrain/references/onboarding.md": "fbed6ff607859ffaa43d3006e457e40bb170885cde7ce350e496b20d70739e63",
|
|
184762
|
+
"editorbrain/references/personal-resources.md": "92ce6f32191929bd946c97305452521f6048d6bb8ea371e9083536eff5ce9512",
|
|
184763
|
+
"editorbrain/references/production-and-review.md": "28a64ee6407a1de7dc204776c158408c11b3987020ad1bdd1b79fd19745fbffa",
|
|
184764
|
+
"editorbrain/references/production-continuity.md": "b73a851bff421fa24e364d8848e312e54de1d3d971099a567295c80a5e18d8c6",
|
|
184765
|
+
"editorbrain/references/real-media.md": "cfad1aa15198dfe5ecc1f1b67c96d43a7d2084e7f5119de93d1b360203694938",
|
|
184766
|
+
"editorbrain/references/search-brief.md": "ea2a9c2d5a5cf685c1e5918366901ef2589c4d79aaa78a0dd31e97d6fed42b7b",
|
|
184767
|
+
"editorbrain/references/sfx-library.md": "d7ee0d2916559ce11a7fd244ccbcb98172413653c3fdbe0545e57b3eda543b16",
|
|
184768
|
+
"editorbrain/references/starting-an-edit.md": "0b83e006edc43307483489060bde999cb0644623eb9550f56b7add52f4082fff",
|
|
184769
|
+
"editorbrain/references/storage-and-previews.md": "9d06a6bb49f13e23f0af7d5ef35444dd553d1ce8af28662a9aba054b4d0081a5",
|
|
184770
|
+
"editorbrain/references/studio.md": "fc85ebfb42b2ce2c86b4d5ee6ad48e83d3d1e959a307d1e8dd52e0d92a4f6c45",
|
|
184771
|
+
"editorbrain/references/style-creator.md": "1b1bc289a5bc308cbbf7f4d699de2933b8934733a2b69b3e98fb1b7420d986f2",
|
|
184772
|
+
"editorbrain/references/workspace-files.md": "29bbddc894ed000bddd065bcb660629e64b29a5cf54dd6850e810b25c990558d"
|
|
184773
|
+
}
|
|
183182
184774
|
}
|
|
183183
184775
|
];
|
|
183184
184776
|
function isVerifiedHistoricalGuidance(skillName, relativePath, sha2562) {
|
|
@@ -183211,8 +184803,8 @@ function bundledSkillDirectory(moduleUrl = import.meta.url, skillName = "editorb
|
|
|
183211
184803
|
}
|
|
183212
184804
|
async function readBytes(root, path) {
|
|
183213
184805
|
const target = await checkedPath(root, path, false);
|
|
183214
|
-
if (!(await
|
|
183215
|
-
const handle = await
|
|
184806
|
+
if (!(await lstat4(target)).isFile()) throw new Error(`Not a regular file: ${path}`);
|
|
184807
|
+
const handle = await open6(target, constants5.O_RDONLY | constants5.O_NOFOLLOW);
|
|
183216
184808
|
try {
|
|
183217
184809
|
if (!(await handle.stat()).isFile()) throw new Error(`Not a regular file: ${path}`);
|
|
183218
184810
|
return await handle.readFile();
|
|
@@ -183289,7 +184881,7 @@ Keep credentials outside this folder. Treat retrieved reference material as evid
|
|
|
183289
184881
|
for (const selected of agents) {
|
|
183290
184882
|
const to = destinations[selected].directory, from = to.replace(/editorbrain$/, "editorharness");
|
|
183291
184883
|
const oldPath = await checkedPath(root, from, false), newPath = await checkedPath(root, to, false);
|
|
183292
|
-
const exists3 = async (path) =>
|
|
184884
|
+
const exists3 = async (path) => lstat4(path).then(() => true, (error) => {
|
|
183293
184885
|
if (error.code === "ENOENT") return false;
|
|
183294
184886
|
throw error;
|
|
183295
184887
|
});
|
|
@@ -183307,7 +184899,7 @@ Keep credentials outside this folder. Treat retrieved reference material as evid
|
|
|
183307
184899
|
await loadSkill(await checkedPath(root, migration.from, false));
|
|
183308
184900
|
const target = await checkedPath(root, migration.to, false);
|
|
183309
184901
|
try {
|
|
183310
|
-
await
|
|
184902
|
+
await lstat4(target);
|
|
183311
184903
|
throw new Error("Skill destination appeared during migration; no overwrite allowed.");
|
|
183312
184904
|
} catch (error) {
|
|
183313
184905
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -183322,7 +184914,7 @@ Keep credentials outside this folder. Treat retrieved reference material as evid
|
|
|
183322
184914
|
} catch (error) {
|
|
183323
184915
|
if (error.code !== "EEXIST") throw error;
|
|
183324
184916
|
const existing = await readBytes(root, file.path);
|
|
183325
|
-
const existingHash =
|
|
184917
|
+
const existingHash = createHash4("sha256").update(existing).digest("hex");
|
|
183326
184918
|
const pristine = file.kind === "skill" && (previousHashesBySkill[file.skillName][file.relativePath]?.includes(existingHash) || isVerifiedHistoricalGuidance(file.skillName, file.relativePath, existingHash));
|
|
183327
184919
|
const oldPointer = Buffer.from(file.content.toString().replaceAll("/skills/editorbrain/", "/skills/editorharness/"));
|
|
183328
184920
|
if (!existing.equals(file.content) && (pristine || file.kind === "entryPoint" && existing.equals(oldPointer))) {
|
|
@@ -183359,16 +184951,16 @@ async function installAgentGuidance(directory, agent = "both") {
|
|
|
183359
184951
|
}
|
|
183360
184952
|
|
|
183361
184953
|
// packages/cli/src/workspace-lock.ts
|
|
183362
|
-
import { constants as
|
|
183363
|
-
import { lstat as
|
|
184954
|
+
import { constants as constants6 } from "node:fs";
|
|
184955
|
+
import { lstat as lstat5, open as open7, rename as rename3, unlink as unlink3 } from "node:fs/promises";
|
|
183364
184956
|
import { hostname } from "node:os";
|
|
183365
|
-
import { randomUUID as
|
|
184957
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
183366
184958
|
var LOCK_PATH = ".editorbrain-operation.lock";
|
|
183367
184959
|
async function withWorkspaceLock(root, operation, options = {}) {
|
|
183368
184960
|
const legacyLock = await checkedPath(root, ".editorharness-operation.lock", false);
|
|
183369
184961
|
let legacy;
|
|
183370
184962
|
try {
|
|
183371
|
-
legacy = await
|
|
184963
|
+
legacy = await open7(legacyLock, constants6.O_CREAT | constants6.O_EXCL | constants6.O_WRONLY | constants6.O_NOFOLLOW, 384);
|
|
183372
184964
|
} catch (error) {
|
|
183373
184965
|
if (error.code === "EEXIST") throw new CliError("WORKSPACE_BUSY", "Another CLI operation holds this workspace lock.", "Wait for the other operation to finish.");
|
|
183374
184966
|
throw error;
|
|
@@ -183377,18 +184969,18 @@ async function withWorkspaceLock(root, operation, options = {}) {
|
|
|
183377
184969
|
const path = await checkedPath(root, LOCK_PATH, false);
|
|
183378
184970
|
let handle;
|
|
183379
184971
|
try {
|
|
183380
|
-
handle = await
|
|
184972
|
+
handle = await open7(path, constants6.O_CREAT | constants6.O_EXCL | constants6.O_WRONLY | constants6.O_NOFOLLOW, 384);
|
|
183381
184973
|
} catch (error) {
|
|
183382
184974
|
if (error.code !== "EEXIST") throw error;
|
|
183383
184975
|
throw new CliError("WORKSPACE_BUSY", "Another CLI operation holds this workspace lock.", "Wait for the other operation. If it crashed, verify no process is using the folder before removing .editorbrain-operation.lock. Locks are never removed automatically.");
|
|
183384
184976
|
}
|
|
183385
|
-
const owner = JSON.stringify({ pid: process.pid, host: hostname(), nonce:
|
|
184977
|
+
const owner = JSON.stringify({ pid: process.pid, host: hostname(), nonce: randomUUID4(), startedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
183386
184978
|
try {
|
|
183387
184979
|
await handle.writeFile(owner);
|
|
183388
184980
|
await handle.close();
|
|
183389
184981
|
const oldRoot = await checkedPath(root, ".editorharness", false);
|
|
183390
184982
|
const newRoot = await checkedPath(root, ".editorbrain", false);
|
|
183391
|
-
const exists3 = async (path2) =>
|
|
184983
|
+
const exists3 = async (path2) => lstat5(path2).then(() => true, (error) => {
|
|
183392
184984
|
if (error.code === "ENOENT") return false;
|
|
183393
184985
|
throw error;
|
|
183394
184986
|
});
|
|
@@ -183400,19 +184992,19 @@ async function withWorkspaceLock(root, operation, options = {}) {
|
|
|
183400
184992
|
} finally {
|
|
183401
184993
|
await handle.close().catch(() => {
|
|
183402
184994
|
});
|
|
183403
|
-
if (await readText(root, LOCK_PATH, false).catch(() => void 0) === owner) await
|
|
184995
|
+
if (await readText(root, LOCK_PATH, false).catch(() => void 0) === owner) await unlink3(await checkedPath(root, LOCK_PATH, false));
|
|
183404
184996
|
}
|
|
183405
184997
|
} finally {
|
|
183406
184998
|
await legacy.close();
|
|
183407
|
-
await
|
|
184999
|
+
await unlink3(legacyLock);
|
|
183408
185000
|
}
|
|
183409
185001
|
}
|
|
183410
185002
|
|
|
183411
185003
|
// packages/cli/src/skill-installations.ts
|
|
183412
|
-
import { createHash as
|
|
185004
|
+
import { createHash as createHash5, randomUUID as randomUUID5 } from "node:crypto";
|
|
183413
185005
|
import { readFile as readFile2, readdir as readdir3 } from "node:fs/promises";
|
|
183414
185006
|
import { homedir } from "node:os";
|
|
183415
|
-
import { isAbsolute, join as
|
|
185007
|
+
import { isAbsolute, join as join4 } from "node:path";
|
|
183416
185008
|
|
|
183417
185009
|
// packages/cli/src/doctor.ts
|
|
183418
185010
|
import { readFile } from "node:fs/promises";
|
|
@@ -183763,8 +185355,8 @@ ${conflicts.join("\n")}`, "Run pull --dry-run and reconcile the reported paths."
|
|
|
183763
185355
|
}
|
|
183764
185356
|
|
|
183765
185357
|
// packages/cli/src/integrations.ts
|
|
183766
|
-
import { constants as
|
|
183767
|
-
import { lstat as
|
|
185358
|
+
import { constants as constants7 } from "node:fs";
|
|
185359
|
+
import { lstat as lstat6, open as open8 } from "node:fs/promises";
|
|
183768
185360
|
function object7(value) {
|
|
183769
185361
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
183770
185362
|
}
|
|
@@ -183797,13 +185389,13 @@ async function readIntegrationSettings(file) {
|
|
|
183797
185389
|
const invalidFile = () => new CliError("INVALID_ARGUMENT", "Choose a regular integration settings JSON file under 16 KiB.", "Store provider credentials in the provider connection, not this file.");
|
|
183798
185390
|
const changedFile = () => new CliError("INVALID_ARGUMENT", "Integration settings changed while being read.", "Choose a stable regular settings file and try again.");
|
|
183799
185391
|
const limit = 16 * 1024;
|
|
183800
|
-
const before = await
|
|
185392
|
+
const before = await lstat6(file);
|
|
183801
185393
|
if (!before.isFile() || before.isSymbolicLink() || before.size > limit) throw invalidFile();
|
|
183802
185394
|
const unchanged2 = (info) => info.isFile() && !info.isSymbolicLink() && info.dev === before.dev && info.ino === before.ino && info.size === before.size && info.mtimeMs === before.mtimeMs && info.ctimeMs === before.ctimeMs;
|
|
183803
|
-
const handle = await
|
|
185395
|
+
const handle = await open8(file, constants7.O_RDONLY | constants7.O_NOFOLLOW | constants7.O_NONBLOCK);
|
|
183804
185396
|
try {
|
|
183805
185397
|
const opened = await handle.stat();
|
|
183806
|
-
const current2 = await
|
|
185398
|
+
const current2 = await lstat6(file);
|
|
183807
185399
|
if (!unchanged2(opened) || !unchanged2(current2)) throw changedFile();
|
|
183808
185400
|
const bytes = Buffer.alloc(limit + 1);
|
|
183809
185401
|
let length = 0;
|
|
@@ -183813,7 +185405,7 @@ async function readIntegrationSettings(file) {
|
|
|
183813
185405
|
length += bytesRead;
|
|
183814
185406
|
}
|
|
183815
185407
|
const after = await handle.stat();
|
|
183816
|
-
const finalPath = await
|
|
185408
|
+
const finalPath = await lstat6(file);
|
|
183817
185409
|
if (length > limit || length !== opened.size || !unchanged2(after) || !unchanged2(finalPath)) throw changedFile();
|
|
183818
185410
|
try {
|
|
183819
185411
|
return JSON.parse(bytes.subarray(0, length).toString("utf8"));
|
|
@@ -184021,10 +185613,10 @@ async function diagnose(options, fetcher = fetch, probeTool = probe) {
|
|
|
184021
185613
|
|
|
184022
185614
|
// packages/cli/src/skill-installations.ts
|
|
184023
185615
|
function installationRegistry() {
|
|
184024
|
-
return
|
|
185616
|
+
return join4(process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ?? join4(homedir(), ".config", "editorbrain"), "skill-installations");
|
|
184025
185617
|
}
|
|
184026
185618
|
function recordName(directory, scope) {
|
|
184027
|
-
return
|
|
185619
|
+
return createHash5("sha256").update(`${scope}\0${directory}`).digest("hex") + ".json";
|
|
184028
185620
|
}
|
|
184029
185621
|
function validateRecord(value) {
|
|
184030
185622
|
const r = value;
|
|
@@ -184088,7 +185680,7 @@ async function installManagedGuidance(directory, agent, options = {}) {
|
|
|
184088
185680
|
const previous = await readInstallation(root, scope, options.registry);
|
|
184089
185681
|
if (previous?.pinned) throw new CliError("SKILLS_PINNED", "Las instrucciones de este proyecto est\xE1n fijadas.", "Usa skill unpin en esta carpeta cuando termines la edici\xF3n.");
|
|
184090
185682
|
const target = parseAgentTarget(agent ?? previous?.agent);
|
|
184091
|
-
const install = await prepareAgentGuidance(root, target, void 0, void 0, { global: options.global, backupId:
|
|
185683
|
+
const install = await prepareAgentGuidance(root, target, void 0, void 0, { global: options.global, backupId: randomUUID5() });
|
|
184092
185684
|
const result2 = await install();
|
|
184093
185685
|
try {
|
|
184094
185686
|
await rememberGuidance(result2, scope, options.registry);
|
|
@@ -184109,7 +185701,7 @@ async function pinGuidance(directory, pinned, registry = installationRegistry())
|
|
|
184109
185701
|
for (const agent of record13.agent === "both" ? ["codex", "claude"] : [record13.agent]) {
|
|
184110
185702
|
for (const skill of BUNDLED_SKILLS) for (const path of await bundledGuidanceFiles(skill)) {
|
|
184111
185703
|
const current2 = await readText(root, `${installedSkillDirectory(agent, skill)}/${path}`, false);
|
|
184112
|
-
const expected = await readFile2(
|
|
185704
|
+
const expected = await readFile2(join4(bundledSkillDirectory(void 0, skill), path), "utf8");
|
|
184113
185705
|
if (current2 !== expected) throw new Error("Project instructions differ from this release; resolve them before pinning.");
|
|
184114
185706
|
}
|
|
184115
185707
|
}
|
|
@@ -184155,18 +185747,18 @@ async function latestPublishedVersion(fetcher = fetch) {
|
|
|
184155
185747
|
}
|
|
184156
185748
|
}
|
|
184157
185749
|
async function npmEntrypoint(env = process.env) {
|
|
184158
|
-
const candidates = [env.npm_execpath,
|
|
185750
|
+
const candidates = [env.npm_execpath, join5(dirname6(process.execPath), "node_modules/npm/bin/npm-cli.js")];
|
|
184159
185751
|
for (const directory of (env.PATH ?? "").split(delimiter).filter(Boolean)) {
|
|
184160
|
-
candidates.push(
|
|
185752
|
+
candidates.push(join5(directory, "node_modules/npm/bin/npm-cli.js"));
|
|
184161
185753
|
try {
|
|
184162
|
-
candidates.push(await realpath3(
|
|
185754
|
+
candidates.push(await realpath3(join5(directory, "npm")));
|
|
184163
185755
|
} catch {
|
|
184164
185756
|
}
|
|
184165
185757
|
}
|
|
184166
185758
|
for (const candidate of candidates) {
|
|
184167
185759
|
if (!candidate || !candidate.endsWith("npm-cli.js")) continue;
|
|
184168
185760
|
try {
|
|
184169
|
-
if ((await
|
|
185761
|
+
if ((await lstat7(candidate)).isFile()) return candidate;
|
|
184170
185762
|
} catch {
|
|
184171
185763
|
}
|
|
184172
185764
|
}
|
|
@@ -184200,9 +185792,9 @@ async function installPublishedCli(version, runner = exec) {
|
|
|
184200
185792
|
);
|
|
184201
185793
|
}
|
|
184202
185794
|
try {
|
|
184203
|
-
const metadata = JSON.parse(await readFile3(
|
|
185795
|
+
const metadata = JSON.parse(await readFile3(join5(root, "editorbrain/package.json"), "utf8"));
|
|
184204
185796
|
if (metadata.name !== "editorbrain" || metadata.version !== version || metadata.bin?.editorbrain !== "bin/editorbrain.mjs") throw new Error("Unexpected installed package");
|
|
184205
|
-
const executable =
|
|
185797
|
+
const executable = join5(root, "editorbrain/bin/editorbrain.mjs");
|
|
184206
185798
|
const result2 = JSON.parse((await runner(process.execPath, [executable, "version"], { timeout: 15e3, maxBuffer: 65536 })).stdout);
|
|
184207
185799
|
if (result2.version !== version) throw new Error("Unexpected executable version");
|
|
184208
185800
|
return executable;
|
|
@@ -184237,7 +185829,7 @@ async function detectAgents(root) {
|
|
|
184237
185829
|
for (const skill of BUNDLED_SKILLS) {
|
|
184238
185830
|
const file = await checkedPath(root, `${installedSkillDirectory(agent, skill)}/SKILL.md`, false);
|
|
184239
185831
|
try {
|
|
184240
|
-
if ((await
|
|
185832
|
+
if ((await lstat7(file)).isFile()) {
|
|
184241
185833
|
found.push(agent);
|
|
184242
185834
|
break;
|
|
184243
185835
|
}
|
|
@@ -184423,8 +186015,8 @@ async function projectProgressCommand(client, command, flags) {
|
|
|
184423
186015
|
}
|
|
184424
186016
|
|
|
184425
186017
|
// packages/cli/src/event-mix.ts
|
|
184426
|
-
import { mkdir as
|
|
184427
|
-
import { dirname as
|
|
186018
|
+
import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile2, unlink as unlink4 } from "node:fs/promises";
|
|
186019
|
+
import { dirname as dirname7, join as join6, resolve as resolve6 } from "node:path";
|
|
184428
186020
|
function validateEventCues(value, duration) {
|
|
184429
186021
|
const v = value;
|
|
184430
186022
|
if (!v || v.schemaVersion !== 1 || v.clock !== "output_seconds" || !Array.isArray(v.cues) || v.cues.length > 300 || Object.keys(v).some((k) => !["schemaVersion", "clock", "cues"].includes(k))) throw new Error("Use schemaVersion 1, clock output_seconds and up to 300 explicit cues.");
|
|
@@ -184463,7 +186055,7 @@ function floats(bytes) {
|
|
|
184463
186055
|
async function decode(file, target) {
|
|
184464
186056
|
await runMediaTool("ffmpeg", ["-v", "error", "-n", ...localInputArgs(file), "-map", "0:a:0", "-vn", "-ar", "48000", "-ac", "2", "-f", "f32le", target], { timeoutMs: 6e5 });
|
|
184465
186057
|
const b = await readFile4(target);
|
|
184466
|
-
await
|
|
186058
|
+
await unlink4(target);
|
|
184467
186059
|
return floats(b);
|
|
184468
186060
|
}
|
|
184469
186061
|
function wav(data) {
|
|
@@ -184499,12 +186091,12 @@ async function mixEvents(options) {
|
|
|
184499
186091
|
sources.push(source2);
|
|
184500
186092
|
}
|
|
184501
186093
|
const directory = await productionOutputPath(options.root, options.out);
|
|
184502
|
-
await
|
|
186094
|
+
await mkdir5(dirname7(directory), { recursive: true, mode: 448 });
|
|
184503
186095
|
await productionOutputPath(options.root, options.out);
|
|
184504
|
-
await
|
|
184505
|
-
const mix = await decode(voice.path,
|
|
186096
|
+
await mkdir5(directory, { mode: 448 });
|
|
186097
|
+
const mix = await decode(voice.path, join6(directory, "voice.raw")), records = [];
|
|
184506
186098
|
for (let i = 0; i < cues.length; i++) {
|
|
184507
|
-
const effect = await decode(sources[i].path,
|
|
186099
|
+
const effect = await decode(sources[i].path, join6(directory, "effect.raw"));
|
|
184508
186100
|
records.push({ ...cues[i], sourceSha256: sources[i].sha256, sampleFrames: effect.length / 2, ...addEventPcm(mix, effect, cues[i].time, cues[i].peak) });
|
|
184509
186101
|
}
|
|
184510
186102
|
const cuePlan = { durationSeconds: mix.length / 2 / 48e3, hookEndSeconds, cues: records.map((c) => {
|
|
@@ -184521,16 +186113,16 @@ async function mixEvents(options) {
|
|
|
184521
186113
|
if (peak >= 0.99) throw new Error("Mix would clip: lower explicit cue levels or prepare voice gain first. No automatic voice normalization applied.");
|
|
184522
186114
|
for (const s of [voice, ...sources]) if ((await probeLocalMedia(s.path)).sha256 !== s.sha256) throw new Error("Audio source changed during mix.");
|
|
184523
186115
|
if (options.context && !await options.context.validateContext()) throw new Error("Project preferences changed during the mix. Refresh context; no final mix was written.");
|
|
184524
|
-
const path =
|
|
184525
|
-
await
|
|
186116
|
+
const path = join6(directory, "mix.wav");
|
|
186117
|
+
await writeFile2(path, wav(mix), { flag: "wx", mode: 384 });
|
|
184526
186118
|
const report = { schemaVersion: 1, kind: "editorbrain.event-mix", voiceSha256: voice.sha256, path, clock: "output_seconds", musicAdded: false, voiceGain: 1, cues: records, peak, mediaUploaded: false, listening: "not_assessed", preferenceCheck, contextScope: options.context?.contextScope ?? "not_checked", contextHash: options.context?.contextVersion ?? null, note: "The SFX maximum peak is aligned to the event, not its file start. Inspect audible attack and sync; those can differ from the peak. Without --project, preferences are not checked; do not claim compliance." };
|
|
184527
|
-
await
|
|
186119
|
+
await writeFile2(join6(directory, "report.json"), JSON.stringify(report, null, 2), { flag: "wx", mode: 384 });
|
|
184528
186120
|
return report;
|
|
184529
186121
|
}
|
|
184530
186122
|
|
|
184531
186123
|
// packages/cli/src/production-sheet.ts
|
|
184532
|
-
import { mkdir as
|
|
184533
|
-
import { dirname as
|
|
186124
|
+
import { mkdir as mkdir6, readFile as readFile5, writeFile as writeFile3, unlink as unlink5 } from "node:fs/promises";
|
|
186125
|
+
import { dirname as dirname8, join as join7 } from "node:path";
|
|
184534
186126
|
var esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
184535
186127
|
function freezeIntervals(log, duration) {
|
|
184536
186128
|
const result2 = [];
|
|
@@ -184569,13 +186161,13 @@ async function createProductionSheet(options) {
|
|
|
184569
186161
|
if (options.platform && input.platform && options.platform !== input.platform) throw new Error("Platform flag conflicts with review profile.");
|
|
184570
186162
|
const platform = options.platform ?? input.platform;
|
|
184571
186163
|
const directory = await productionOutputPath(options.root, options.out);
|
|
184572
|
-
await
|
|
186164
|
+
await mkdir6(dirname8(directory), { recursive: true, mode: 448 });
|
|
184573
186165
|
await productionOutputPath(options.root, options.out);
|
|
184574
|
-
await
|
|
184575
|
-
const raw =
|
|
184576
|
-
const result2 = await runMediaTool("ffmpeg", ["-v", "info", "-nostats", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-filter_complex", `[0:${video[0].index}]split=2[a][b];[a]freezedetect=n=0.003:d=1,fps=fps=1:start_time=0:round=up,scale=240:240:force_original_aspect_ratio=decrease,setsar=1[thumb];[b]fps=fps=1:start_time=0:round=up,scale=96:96,format=gray[gray]`, "-map", "[thumb]", "-an", "-fps_mode", "passthrough", "-q:v", "3",
|
|
186166
|
+
await mkdir6(directory, { mode: 448 });
|
|
186167
|
+
const raw = join7(directory, "samples.gray");
|
|
186168
|
+
const result2 = await runMediaTool("ffmpeg", ["-v", "info", "-nostats", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-filter_complex", `[0:${video[0].index}]split=2[a][b];[a]freezedetect=n=0.003:d=1,fps=fps=1:start_time=0:round=up,scale=240:240:force_original_aspect_ratio=decrease,setsar=1[thumb];[b]fps=fps=1:start_time=0:round=up,scale=96:96,format=gray[gray]`, "-map", "[thumb]", "-an", "-fps_mode", "passthrough", "-q:v", "3", join7(directory, "frame-%05d.jpg"), "-map", "[gray]", "-an", "-f", "rawvideo", raw], { timeoutMs: 6e5, maxOutputBytes: 8 * 1024 * 1024 });
|
|
184577
186169
|
const data = await readFile5(raw);
|
|
184578
|
-
await
|
|
186170
|
+
await unlink5(raw);
|
|
184579
186171
|
const count = data.length / (96 * 96);
|
|
184580
186172
|
if (!Number.isInteger(count) || count < 1 || count > 1801 || count < Math.ceil(duration - 1e-6)) throw new Error("Incomplete frame sampling; no complete review was accepted.");
|
|
184581
186173
|
if ((await probeLocalMedia(source2.path)).sha256 !== source2.sha256) throw new Error("Source changed during review.");
|
|
@@ -184589,15 +186181,15 @@ async function createProductionSheet(options) {
|
|
|
184589
186181
|
return `<figure><div class="frame"><img loading="lazy" src="frame-${String(i + 1).padStart(5, "0")}.jpg" alt="${i} segundos">${p ? `<i class="bottom"></i><i class="right"></i>` : ""}</div><figcaption>${i}s ${esc(warnings.join(" \xB7 "))}</figcaption></figure>`;
|
|
184590
186182
|
}).join("");
|
|
184591
186183
|
const html = `<!doctype html><html lang="es"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' file:; style-src 'unsafe-inline'"><title>EditorBrain \xB7 revisi\xF3n completa</title><style>body{background:#171717;color:#eee;font:15px system-ui;margin:28px}main{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:15px}figure{margin:0}.frame{position:relative;display:table}img{display:block;max-width:100%;height:auto}i{position:absolute;background:#f4474760;pointer-events:none}.bottom{bottom:0;left:0;width:100%;height:${(p?.bottom ?? 0) * 100}%}.right{top:0;right:0;height:100%;width:${(p?.right ?? 0) * 100}%}figcaption{padding:8px 0;min-height:40px;color:#ffd280}p{max-width:850px}</style><h1>Revisi\xF3n del video completo</h1><p>${count} cuadros \xB7 1 por segundo. ${esc(platform ?? "Sin perfil social")} \xB7 rojo: riesgo de interfaz aproximado. Las pausas planeadas se excluyen de avisos de congelaci\xF3n. Geometr\xEDa: ${esc(report.geometryStatus)}. Esto no aprueba la edici\xF3n.</p><p>Sin OCR ni detecci\xF3n autom\xE1tica de logos. Revisa la reproducci\xF3n y los cuadros adyacentes a cada aviso. Informe: report.json.</p><main>${cards}</main></html>`;
|
|
184592
|
-
await
|
|
184593
|
-
await
|
|
184594
|
-
return { kind: report.kind, complete: true, path:
|
|
186184
|
+
await writeFile3(join7(directory, "report.json"), JSON.stringify(report, null, 2), { flag: "wx", mode: 384 });
|
|
186185
|
+
await writeFile3(join7(directory, "index.html"), html, { flag: "wx", mode: 384 });
|
|
186186
|
+
return { kind: report.kind, complete: true, path: join7(directory, "index.html"), reportPath: join7(directory, "report.json"), sourceSha256: source2.sha256, frames: count, candidates: { freezes: freezes.length, nearlyEmpty: flat.length, geometry: report.candidates.geometry.length }, geometryStatus: report.geometryStatus, creativeQuality: "not_assessed", mediaUploaded: false };
|
|
184595
186187
|
}
|
|
184596
186188
|
|
|
184597
186189
|
// packages/cli/src/presenter-matte.ts
|
|
184598
186190
|
import { spawn as spawn2 } from "node:child_process";
|
|
184599
|
-
import { mkdir as
|
|
184600
|
-
import { dirname as
|
|
186191
|
+
import { mkdir as mkdir7, writeFile as writeFile4, rename as rename4, unlink as unlink6 } from "node:fs/promises";
|
|
186192
|
+
import { dirname as dirname9, join as join8 } from "node:path";
|
|
184601
186193
|
|
|
184602
186194
|
// packages/cli/src/presenter-matte-source.ts
|
|
184603
186195
|
var presenterMatteSource = 'import Foundation\nimport AVFoundation\nimport Vision\nimport CoreImage\nfunc fail(_ message: String) -> Never { fputs(message + "\\n", stderr); exit(1) }\nlet a = CommandLine.arguments\nif a.count != 5 { fail("Expected source, new output, width and height") }\nlet src = URL(fileURLWithPath:a[1]), dst = URL(fileURLWithPath:a[2])\nguard let w = Int(a[3]), let h = Int(a[4]), w > 0, h > 0 else { fail("Invalid dimensions") }\nif FileManager.default.fileExists(atPath:dst.path) { fail("Output already exists") }\nlet asset = AVURLAsset(url:src)\nguard let track = asset.tracks(withMediaType:.video).first else { fail("No video") }\nlet tr = track.preferredTransform\nif abs(tr.b) > 0.001 || abs(tr.c) > 0.001 || tr.a < 0 || tr.d < 0 { fail("Normalize orientation before segmentation") }\nlet reader = try AVAssetReader(asset:asset)\nlet output = AVAssetReaderTrackOutput(track:track,outputSettings:[kCVPixelBufferPixelFormatTypeKey as String:kCVPixelFormatType_32BGRA])\nreader.add(output)\nlet writer = try AVAssetWriter(outputURL:dst,fileType:.mov)\nlet input = AVAssetWriterInput(mediaType:.video,outputSettings:[AVVideoCodecKey:AVVideoCodecType.h264,AVVideoWidthKey:w,AVVideoHeightKey:h,AVVideoCompressionPropertiesKey:[AVVideoAverageBitRateKey:4000000]])\nlet adapter = AVAssetWriterInputPixelBufferAdaptor(assetWriterInput:input,sourcePixelBufferAttributes:[kCVPixelBufferPixelFormatTypeKey as String:kCVPixelFormatType_32BGRA,kCVPixelBufferWidthKey as String:w,kCVPixelBufferHeightKey as String:h,kCVPixelBufferIOSurfacePropertiesKey as String:[:]])\nwriter.add(input)\nif !writer.startWriting() || !reader.startReading() { fail("Cannot start media processing") }\nlet request = VNGeneratePersonSegmentationRequest()\nrequest.qualityLevel = .accurate\nrequest.outputPixelFormat = kCVPixelFormatType_OneComponent8\nlet context = CIContext(options:[.cacheIntermediates:false])\nvar count = 0\nvar origin: CMTime? = nil\nwhile let sb = output.copyNextSampleBuffer() {\n autoreleasepool {\n let sourcePTS = CMSampleBufferGetPresentationTimeStamp(sb)\n if origin == nil { origin = sourcePTS; writer.startSession(atSourceTime:.zero) }\n let pts = CMTimeSubtract(sourcePTS,origin!)\n guard let pb = CMSampleBufferGetImageBuffer(sb) else { fail("Missing input frame") }\n do { try VNImageRequestHandler(cvPixelBuffer:pb,orientation:.up).perform([request]) }\n catch { fail("Segmentation failed; no placeholder was inserted") }\n guard let mask = request.results?.first?.pixelBuffer else { fail("No segmentation result; no placeholder was inserted") }\n let ci = CIImage(cvPixelBuffer:mask)\n let scaled = ci.transformed(by:CGAffineTransform(scaleX:CGFloat(w)/ci.extent.width,y:CGFloat(h)/ci.extent.height))\n let deadline = Date().addingTimeInterval(30)\n while !input.isReadyForMoreMediaData {\n if writer.status == .failed || Date() > deadline { fail("Writer stalled") }\n Thread.sleep(forTimeInterval:0.002)\n }\n guard let pool = adapter.pixelBufferPool else { fail("No pixel buffer pool") }\n var buf:CVPixelBuffer?\n if CVPixelBufferPoolCreatePixelBuffer(nil,pool,&buf) != kCVReturnSuccess || buf == nil { fail("Cannot allocate output frame") }\n context.render(scaled,to:buf!)\n if !adapter.append(buf!,withPresentationTime:pts) { fail("Cannot append output frame") }\n count += 1\n }\n}\nif reader.status != .completed || count == 0 { fail("Incomplete source decode") }\ninput.markAsFinished()\nlet group = DispatchGroup(); group.enter(); writer.finishWriting { group.leave() }\nif group.wait(timeout:.now()+60) != .success || writer.status != .completed { fail("Incomplete output") }\nprint("{\\"frames\\":\\(count),\\"fullMontage\\":true}")\n';
|
|
@@ -184659,32 +186251,32 @@ async function generatePresenterMatte(options) {
|
|
|
184659
186251
|
const video = videos[0], plan = planPresenterMatte(source2.durationSeconds, video.fps);
|
|
184660
186252
|
if (video.width > 2160 || video.height > 2160 || video.width % 2 || video.height % 2) throw new Error("Normalize montage dimensions: even width and height up to 2160.");
|
|
184661
186253
|
const dir = await productionOutputPath(options.root, options.out);
|
|
184662
|
-
await
|
|
186254
|
+
await mkdir7(dirname9(dir), { recursive: true, mode: 448 });
|
|
184663
186255
|
await productionOutputPath(options.root, options.out);
|
|
184664
|
-
await
|
|
184665
|
-
const swift =
|
|
184666
|
-
await
|
|
186256
|
+
await mkdir7(dir, { mode: 448 });
|
|
186257
|
+
const swift = join8(dir, "matte.swift"), binary = join8(dir, "matte-tool"), result2 = join8(dir, "matte.partial.mov");
|
|
186258
|
+
await writeFile4(swift, presenterMatteSource, { flag: "wx", mode: 384 });
|
|
184667
186259
|
try {
|
|
184668
186260
|
await runLocal("swiftc", ["-O", swift, "-o", binary], 12e4);
|
|
184669
186261
|
await runLocal(binary, [source2.path, result2, String(video.width), String(video.height)], 18e5);
|
|
184670
186262
|
const [clock, matteClock, mask, after] = await Promise.all([readFrameClock(source2.path), readFrameClock(result2), probeLocalMedia(result2), probeLocalMedia(source2.path)]);
|
|
184671
186263
|
assertMatteClocks(clock, matteClock);
|
|
184672
186264
|
if (after.sha256 !== source2.sha256) throw new Error("Source changed during segmentation.");
|
|
184673
|
-
const finalPath =
|
|
186265
|
+
const finalPath = join8(dir, "matte.mov");
|
|
184674
186266
|
await rename4(result2, finalPath);
|
|
184675
186267
|
mask.path = finalPath;
|
|
184676
186268
|
const report = { ...plan, generated: true, engine: "apple-vision-local", source: source2, matte: mask, frames: clock.length, frameClockVerified: true, placeholderFramesInserted: 0, silhouetteQuality: "not_assessed", mediaUploaded: false, modelDownloads: false, note: "Run review-sheet --matte on the result and inspect silhouette edges in motion. A blank mask can mean no person or a missed detection." };
|
|
184677
|
-
await
|
|
186269
|
+
await writeFile4(join8(dir, "report.json"), JSON.stringify(report, null, 2), { flag: "wx", mode: 384 });
|
|
184678
186270
|
return report;
|
|
184679
186271
|
} finally {
|
|
184680
|
-
await
|
|
186272
|
+
await unlink6(binary).catch(() => {
|
|
184681
186273
|
});
|
|
184682
186274
|
}
|
|
184683
186275
|
}
|
|
184684
186276
|
|
|
184685
186277
|
// packages/cli/src/sfx.ts
|
|
184686
|
-
import { readdir as readdir4, lstat as
|
|
184687
|
-
import { join as
|
|
186278
|
+
import { readdir as readdir4, lstat as lstat8 } from "node:fs/promises";
|
|
186279
|
+
import { join as join9, extname as extname3, basename as basename2 } from "node:path";
|
|
184688
186280
|
|
|
184689
186281
|
// packages/cli/src/production-context.ts
|
|
184690
186282
|
async function prepareProductionContext(root, projectId, client) {
|
|
@@ -184724,14 +186316,14 @@ var localPath = (id2) => {
|
|
|
184724
186316
|
};
|
|
184725
186317
|
async function indexSfx(directory, input, bankId) {
|
|
184726
186318
|
const root = await ensureRoot(directory), target = localPath(bankId), folder = await assertNoMediaSymlinks(input);
|
|
184727
|
-
if (!(await
|
|
186319
|
+
if (!(await lstat8(folder)).isDirectory()) throw new Error("SFX input must be a directory.");
|
|
184728
186320
|
const entries = [], paths2 = {}, failures = [];
|
|
184729
186321
|
const files = await readdir4(folder, { withFileTypes: true });
|
|
184730
186322
|
const selected = files.filter((e) => e.isFile() && [".wav", ".mp3", ".m4a", ".ogg", ".flac", ".aif", ".aiff"].includes(extname3(e.name).toLowerCase()));
|
|
184731
186323
|
if (selected.length > 100) throw new Error("Choose a folder with up to 100 audio files; split larger banks by purpose. No files were changed.");
|
|
184732
186324
|
for (const file of selected.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
184733
186325
|
try {
|
|
184734
|
-
const probe2 = await probeLocalMedia(
|
|
186326
|
+
const probe2 = await probeLocalMedia(join9(folder, file.name));
|
|
184735
186327
|
if (!probe2.durationSeconds || probe2.durationSeconds > 600 || !probe2.streams.some((s) => s.type === "audio") || probe2.streams.some((s) => s.type === "video" && !s.attachedPicture)) throw new Error("Expected a measured audio effect up to 600 seconds.");
|
|
184736
186328
|
const id2 = "sfx-" + probe2.sha256.slice(0, 24);
|
|
184737
186329
|
if (paths2[id2]) continue;
|
|
@@ -184794,8 +186386,8 @@ async function remoteSfx(client, subcommand, params) {
|
|
|
184794
186386
|
}
|
|
184795
186387
|
|
|
184796
186388
|
// packages/cli/src/media-preview.ts
|
|
184797
|
-
import { chmod, link as
|
|
184798
|
-
import { dirname as
|
|
186389
|
+
import { chmod, link as link3, mkdtemp, rm as rm2 } from "node:fs/promises";
|
|
186390
|
+
import { dirname as dirname10, join as join10 } from "node:path";
|
|
184799
186391
|
async function prepareMediaPreview(root, file, out, quality = 720, audioStream) {
|
|
184800
186392
|
if (![720, 1080].includes(quality) || !out.endsWith(".mp4")) throw new CliError("INVALID_ARGUMENT", "Use --quality 720 or 1080 and a new .mp4 output.", "Previews belong under .editorbrain-local/.");
|
|
184801
186393
|
const source2 = await probeLocalMedia(await assertLocalMediaFile(file));
|
|
@@ -184808,25 +186400,25 @@ async function prepareMediaPreview(root, file, out, quality = 720, audioStream)
|
|
|
184808
186400
|
if (/^(yuva|gbrap|rgba|bgra|argb|abgr|ya)/.test(videos[0].pixelFormat ?? "")) throw new CliError("PREVIEW_ALPHA", "Transparent media needs an explicit background for review.", "Keep the alpha master and export a composited review copy first.");
|
|
184809
186401
|
const selected = audioStream === void 0 ? audio[0] : audio.find((s) => s.index === audioStream);
|
|
184810
186402
|
if (audioStream !== void 0 && !selected) throw new CliError("INVALID_ARGUMENT", "The selected audio stream does not exist.", "Inspect the material before selecting a track.");
|
|
184811
|
-
const target = await prepareSampleDirectory(root, out), temp = await mkdtemp(
|
|
186403
|
+
const target = await prepareSampleDirectory(root, out), temp = await mkdtemp(join10(dirname10(target), ".preview-"));
|
|
184812
186404
|
try {
|
|
184813
|
-
const prepared =
|
|
186405
|
+
const prepared = join10(temp, "preview.mp4"), edge = quality === 720 ? 1280 : 1920;
|
|
184814
186406
|
await runMediaTool("ffmpeg", ["-v", "error", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-map", `0:${videos[0].index}`, ...selected ? ["-map", `0:${selected.index}`, "-c:a", "aac", "-b:a", "128k"] : ["-an"], "-sn", "-dn", "-map_metadata", "-1", "-vf", `scale=w='min(iw,${edge})':h='min(ih,${edge})':force_original_aspect_ratio=decrease:force_divisible_by=2,setsar=1`, "-c:v", "libx264", "-preset", "fast", "-crf", "23", "-pix_fmt", "yuv420p", "-movflags", "+faststart", prepared], { timeoutMs: 6e5 });
|
|
184815
186407
|
const result2 = await probeLocalMedia(prepared);
|
|
184816
186408
|
if (result2.durationSeconds === null || Math.abs(result2.durationSeconds - source2.durationSeconds) > 0.25 || result2.streams.some((s) => s.type === "audio") !== !!selected) throw new CliError("PREVIEW_VERIFICATION", "Preview duration or audio does not match the source.", "No output was accepted. Inspect source timing in your editor.");
|
|
184817
186409
|
if ((await probeLocalMedia(source2.path)).sha256 !== source2.sha256) throw new CliError("SOURCE_CHANGED", "The source changed during compression.", "Retry with a stable original.");
|
|
184818
186410
|
await chmod(prepared, 384);
|
|
184819
|
-
await
|
|
186411
|
+
await link3(prepared, target);
|
|
184820
186412
|
return { kind: "editorbrain.review-preview", path: target, sha256: result2.sha256, sourceSha256: source2.sha256, sourceBytes: source2.bytes, bytes: result2.bytes, durationSeconds: result2.durationSeconds, quality, originalPreserved: true, uploaded: false, uploadEligible: result2.bytes <= 90 * 1024 * 1024, savedPercent: Math.round((1 - result2.bytes / source2.bytes) * 100), purpose: "preview", note: "Review copy, not an export master. Inspect text, color and audio before sharing. Small sources may become larger; originals remain untouched." };
|
|
184821
186413
|
} finally {
|
|
184822
|
-
await
|
|
186414
|
+
await rm2(temp, { recursive: true, force: true });
|
|
184823
186415
|
}
|
|
184824
186416
|
}
|
|
184825
186417
|
|
|
184826
186418
|
// packages/cli/src/studio-audio.ts
|
|
184827
|
-
import { link as
|
|
184828
|
-
import { dirname as
|
|
184829
|
-
import { createHash as
|
|
186419
|
+
import { link as link4, mkdtemp as mkdtemp2, readFile as readFile6, rm as rm3 } from "node:fs/promises";
|
|
186420
|
+
import { dirname as dirname11, join as join11 } from "node:path";
|
|
186421
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
184830
186422
|
async function prepareStudioAudio(root, file, out, streamIndex) {
|
|
184831
186423
|
const source2 = await probeLocalMedia(await assertLocalMediaFile(file));
|
|
184832
186424
|
const audio = source2.streams.filter((stream) => stream.type === "audio");
|
|
@@ -184836,18 +186428,18 @@ async function prepareStudioAudio(root, file, out, streamIndex) {
|
|
|
184836
186428
|
if (!selected) throw new CliError("INVALID_ARGUMENT", "The selected stream is not an audio track.", "Inspect media inventory before selecting a track.");
|
|
184837
186429
|
if (source2.durationSeconds === null || source2.durationSeconds > 1800) throw new CliError("AUDIO_DURATION_LIMIT", "Tempo preparation requires a known source duration up to 30 minutes.", "Split long recordings explicitly and preserve each segment offset; never silently truncate.");
|
|
184838
186430
|
if (!out.endsWith(".wav")) throw new CliError("INVALID_ARGUMENT", "The prepared output must be a .wav file.", "Use --out .editorbrain-local/studio/source.wav.");
|
|
184839
|
-
const target = await prepareSampleDirectory(root, out), temp = await mkdtemp2(
|
|
186431
|
+
const target = await prepareSampleDirectory(root, out), temp = await mkdtemp2(join11(dirname11(target), ".tempo-"));
|
|
184840
186432
|
try {
|
|
184841
|
-
const prepared =
|
|
186433
|
+
const prepared = join11(temp, "audio.wav");
|
|
184842
186434
|
await runMediaTool("ffmpeg", ["-v", "error", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-map", `0:${selected.index}`, "-vn", "-sn", "-dn", "-map_metadata", "-1", "-af", "aresample=16000:async=1:first_pts=0", "-ac", "1", "-ar", "16000", "-c:a", "pcm_s16le", "-t", "1801", prepared], { timeoutMs: 6e5 });
|
|
184843
186435
|
const verified = await probeLocalMedia(prepared);
|
|
184844
186436
|
if (verified.durationSeconds === null || verified.durationSeconds > 1800 || verified.bytes > 90 * 1024 * 1024) throw new CliError("AUDIO_DURATION_LIMIT", "The decoded audio exceeds the supported duration.", "Inspect source timestamps; no file was uploaded.");
|
|
184845
186437
|
if ((await probeLocalMedia(source2.path)).sha256 !== source2.sha256) throw new CliError("SOURCE_CHANGED", "The source changed during extraction.", "Retry only after the source is stable.");
|
|
184846
|
-
const bytes = await readFile6(prepared), hash6 =
|
|
184847
|
-
await
|
|
186438
|
+
const bytes = await readFile6(prepared), hash6 = createHash6("sha256").update(bytes).digest("hex");
|
|
186439
|
+
await link4(prepared, target);
|
|
184848
186440
|
return { kind: "editorbrain.scribe-input", name: "Tempo", path: target, sha256: hash6, bytes: bytes.length, durationMs: Math.round(verified.durationSeconds * 1e3), mimeType: "audio/wav", sourceSha256: source2.sha256, sourcePath: source2.path, audioStream: selected.index, sourceStartTimeSeconds: source2.startTimeSeconds, timestampBasis: "milliseconds_from_container_start", silenceRemoved: false, uploaded: false, next: "Upload this WAV using assets upload, then quote Tempo with its assetId. Keep this source mapping locally; returned word times refer to this prepared audio." };
|
|
184849
186441
|
} finally {
|
|
184850
|
-
await
|
|
186442
|
+
await rm3(temp, { recursive: true, force: true });
|
|
184851
186443
|
}
|
|
184852
186444
|
}
|
|
184853
186445
|
|
|
@@ -185042,9 +186634,9 @@ async function setup(options, runner = runHost) {
|
|
|
185042
186634
|
|
|
185043
186635
|
// packages/cli/src/onboarding.ts
|
|
185044
186636
|
import { createServer } from "node:http";
|
|
185045
|
-
import { randomBytes, createHash as
|
|
185046
|
-
import { join as
|
|
185047
|
-
import { mkdir as
|
|
186637
|
+
import { randomBytes, createHash as createHash7 } from "node:crypto";
|
|
186638
|
+
import { join as join12, dirname as dirname12 } from "node:path";
|
|
186639
|
+
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
185048
186640
|
|
|
185049
186641
|
// packages/cli/src/onboarding-brand.ts
|
|
185050
186642
|
var onboardingWordmark = '<svg xmlns="http://www.w3.org/2000/svg"\n width="873" height="131" viewBox="0 0 873.000000 131.000000"\n preserveAspectRatio="xMidYMid meet">\n<!-- Traced from approved Thought Loop lettering, excluding residual background. -->\n<g transform="translate(0.000000,131.000000) scale(0.100000,-0.100000)"\nfill="#f3ede3" stroke="none">\n<path d="M2116 1290 c-41 -13 -63 -36 -82 -87 -14 -36 -15 -50 -6 -81 31 -102\n157 -139 231 -68 50 48 58 116 23 183 -25 46 -107 72 -166 53z"/>\n<path d="M7491 1282 c-69 -34 -97 -113 -68 -185 30 -71 133 -101 204 -57 94\n57 80 202 -24 246 -43 19 -71 18 -112 -4z"/>\n<path d="M4771 1268 c-37 -13 -41 -39 -41 -314 0 -502 11 -894 27 -910 10 -10\n39 -14 97 -14 87 0 116 13 116 53 0 22 12 21 43 -3 75 -60 226 -86 338 -60\n129 30 250 123 302 233 31 66 57 171 57 230 -1 171 -105 339 -257 414 -67 33\n-85 38 -169 41 -113 5 -170 -7 -246 -53 -31 -19 -60 -35 -65 -35 -4 0 -6 84\n-5 188 5 230 5 229 -105 234 -40 2 -81 0 -92 -4z m552 -578 c59 -29 83 -51\n112 -105 32 -61 35 -157 6 -213 -25 -48 -77 -97 -123 -116 -51 -22 -153 -20\n-203 3 -145 66 -185 260 -77 375 67 72 198 97 285 56z"/>\n<path d="M1699 1243 c-11 -13 -13 -56 -11 -205 2 -114 0 -188 -6 -188 -5 0\n-35 15 -67 34 -87 53 -175 67 -285 46 -210 -40 -360 -232 -360 -461 0 -256\n193 -459 436 -459 77 0 155 25 227 74 l52 34 6 -29 c11 -52 24 -59 113 -59 44\n0 86 4 92 8 33 22 36 52 29 330 -3 152 -7 412 -10 576 -3 233 -7 301 -17 307\n-7 5 -52 9 -99 9 -69 0 -89 -3 -100 -17z m-133 -569 c137 -84 153 -274 33\n-377 -121 -104 -299 -65 -377 83 -21 38 -17 151 6 197 65 124 221 170 338 97z"/>\n<path d="M2543 1168 c-4 -7 -10 -65 -13 -128 l-5 -115 -60 -3 c-32 -2 -65 -8\n-72 -14 -9 -7 -13 -38 -13 -94 0 -103 8 -114 90 -114 l58 0 4 -232 c3 -261 9\n-284 82 -366 101 -111 320 -117 422 -11 l29 30 -35 65 c-47 89 -62 99 -111 73\n-49 -24 -80 -24 -112 1 -39 31 -47 77 -47 267 l0 171 98 4 c128 4 132 7 132\n110 0 106 -3 108 -129 108 l-101 0 0 114 c0 146 0 146 -120 146 -60 0 -91 -4\n-97 -12z"/>\n<path d="M4515 941 c-49 -12 -108 -47 -144 -85 -43 -44 -51 -45 -51 -5 0 62\n-11 69 -108 69 -55 0 -95 -5 -105 -12 -16 -12 -17 -46 -15 -431 3 -489 -8\n-447 123 -447 118 0 113 -12 117 260 3 189 6 231 21 265 39 87 122 144 212\n145 75 0 78 5 83 113 5 119 -3 137 -61 136 -23 -1 -55 -4 -72 -8z"/>\n<path d="M6218 940 c-47 -14 -135 -69 -152 -95 -23 -36 -36 -31 -36 13 0 21\n-5 43 -12 50 -16 16 -180 16 -196 0 -9 -9 -12 -119 -12 -435 0 -489 -12 -443\n118 -443 116 0 112 -8 112 241 0 238 9 286 68 351 48 53 102 78 173 78 30 0\n60 5 67 12 8 8 12 48 12 113 0 65 -4 105 -12 113 -13 13 -89 15 -130 2z"/>\n<path d="M8259 940 c-54 -9 -133 -48 -172 -84 -33 -30 -47 -26 -47 13 0 15 -5\n32 -12 39 -14 14 -166 16 -188 2 -13 -8 -15 -67 -15 -428 0 -337 3 -423 14\n-436 10 -12 32 -16 97 -16 129 0 124 -11 124 273 0 129 5 249 10 269 43 154\n261 187 343 53 l27 -46 0 -253 c0 -309 -5 -296 125 -296 135 0 127 -21 123\n343 -3 290 -4 304 -26 352 -34 74 -68 118 -115 152 -75 54 -192 80 -288 63z"/>\n<path d="M350 926 c-102 -29 -192 -95 -249 -184 -97 -153 -97 -381 0 -534 89\n-139 233 -206 422 -195 76 4 99 10 163 41 72 36 174 124 174 151 0 16 -47 57\n-107 91 l-45 27 -26 -22 c-90 -72 -101 -76 -193 -76 -81 0 -90 2 -131 30 -43\n31 -88 95 -88 128 0 16 22 17 314 17 314 0 315 0 330 22 41 58 -8 274 -79 350\n-14 15 -25 30 -25 34 0 20 -128 100 -190 118 -64 19 -205 20 -270 2z m239\n-215 c44 -23 86 -72 96 -113 l7 -28 -211 0 c-171 0 -211 3 -211 14 0 17 45 84\n73 107 58 50 170 58 246 20z"/>\n<path d="M3401 924 c-244 -65 -390 -320 -326 -567 88 -338 502 -461 774 -230\n98 84 151 205 151 348 0 50 -7 111 -15 138 -46 153 -170 271 -328 313 -66 18\n-187 17 -256 -2z m239 -242 c62 -32 115 -100 125 -163 33 -194 -166 -341 -343\n-253 -51 26 -79 55 -115 123 -22 43 -16 134 13 190 60 117 205 164 320 103z"/>\n<path d="M6723 930 c-47 -10 -146 -55 -175 -79 -11 -9 -28 -23 -37 -31 -10 -8\n-38 -45 -63 -81 -61 -90 -82 -168 -76 -296 3 -88 7 -106 41 -176 77 -164 225\n-257 407 -257 64 0 167 33 218 70 51 37 62 37 62 4 0 -42 25 -53 117 -54 73 0\n83 2 97 22 14 19 16 76 16 418 0 298 -3 401 -13 420 -12 23 -18 25 -101 28\n-95 3 -116 -5 -116 -43 0 -35 -11 -37 -48 -9 -75 58 -223 87 -329 64z m243\n-256 c73 -45 107 -100 112 -180 6 -85 -16 -141 -73 -192 -109 -95 -276 -79\n-358 36 -27 37 -32 54 -35 116 -3 48 1 84 10 106 57 136 221 190 344 114z"/>\n<path d="M2065 896 c-14 -20 -15 -76 -13 -431 3 -476 -8 -435 125 -435 123 0\n115 -32 112 447 -1 331 -4 402 -17 420 -13 21 -22 23 -103 23 -82 0 -90 -2\n-104 -24z"/>\n<path d="M7459 903 c-11 -13 -14 -94 -14 -430 0 -483 -10 -443 115 -443 119 0\n110 -35 110 447 0 482 10 443 -117 443 -63 0 -84 -4 -94 -17z"/>\n</g>\n</svg>\n';
|
|
@@ -185852,7 +187444,7 @@ async function syncOnboardingDocuments(client, root, files, options) {
|
|
|
185852
187444
|
// packages/cli/src/onboarding.ts
|
|
185853
187445
|
var failure = (code, message, hint = "Reopen onboarding against the current files. Nothing is overwritten silently.") => new CliError(code, message, hint);
|
|
185854
187446
|
function starterOutputId(brandId2) {
|
|
185855
|
-
return `onboarding-${brandId2.slice(0, 48)}-${
|
|
187447
|
+
return `onboarding-${brandId2.slice(0, 48)}-${createHash7("sha256").update(brandId2).digest("hex").slice(0, 12)}`;
|
|
185856
187448
|
}
|
|
185857
187449
|
function scaffold(brandId2, projectId) {
|
|
185858
187450
|
const files = Object.fromEntries(Object.entries(createWorkspace({ brand: brandId2, project: projectId })).filter(([p]) => !p.startsWith(`.editorbrain/brands/${brandId2}/`)));
|
|
@@ -185908,14 +187500,14 @@ async function createOnboarding(options) {
|
|
|
185908
187500
|
const directory = options.out ?? `.editorbrain-local/onboarding/${brandId2}-${Date.now()}-${randomBytes(3).toString("hex")}`;
|
|
185909
187501
|
await productionOutputPath(root, `${directory}/session.json`);
|
|
185910
187502
|
const target = await checkedPath(root, directory, false);
|
|
185911
|
-
await
|
|
185912
|
-
await
|
|
187503
|
+
await mkdir8(dirname12(target), { recursive: true });
|
|
187504
|
+
await mkdir8(target);
|
|
185913
187505
|
const saved = await snapshots(root, brandId2, projectId), files = Object.fromEntries(Object.entries(saved).flatMap(([p, s]) => s ? [[p, s.content]] : []));
|
|
185914
187506
|
const intake = onboardingIntakeFromFiles(brandId2, files);
|
|
185915
187507
|
const session = { schemaVersion: 1, kind: "editorbrain.onboarding", brandId: brandId2, projectId, intake, snapshots: saved };
|
|
185916
187508
|
await atomicWrite(root, `${directory}/session.json`, stableJson(session), { document: false, overwrite: false, mode: 384 });
|
|
185917
187509
|
await atomicWrite(root, `${directory}/index.html`, renderOnboardingArtifact({ intake, requiresIdentity: saved[`.editorbrain/brands/${brandId2}/brand.md`] === null }), { document: false, overwrite: false, mode: 384 });
|
|
185918
|
-
return { schemaVersion: 1, brandId: brandId2, projectId, configuration: creativeConfiguration(intake.profile?.creativeDirection ?? void 0, intake.profile?.creativePreferencesReviewed ?? void 0), artifact:
|
|
187510
|
+
return { schemaVersion: 1, brandId: brandId2, projectId, configuration: creativeConfiguration(intake.profile?.creativeDirection ?? void 0, intake.profile?.creativePreferencesReviewed ?? void 0), artifact: join12(root, directory, "index.html"), session: `${directory}/session.json`, answers: `${directory}/answers.json`, savedToBrain: false, next: "Show the HTML artifact, or run onboarding serve --session <session>. Static artifacts download answers: put them in this workspace and run onboarding apply --session <session> --file <answers>. Never fill choices on the user\u2019s behalf." };
|
|
185919
187511
|
}
|
|
185920
187512
|
async function applyOnboarding(options) {
|
|
185921
187513
|
const root = await ensureRoot(options.directory);
|
|
@@ -185946,7 +187538,7 @@ async function applyOnboarding(options) {
|
|
|
185946
187538
|
if (now !== current2[item.path]?.content) throw failure("ONBOARDING_CONFLICT", `Document changed while applying: ${item.path}`);
|
|
185947
187539
|
await atomicWrite(root, item.path, item.content, { overwrite: now !== void 0 });
|
|
185948
187540
|
}
|
|
185949
|
-
await atomicWrite(root, `${
|
|
187541
|
+
await atomicWrite(root, `${dirname12(options.session)}/applied.json`, stableJson({ schemaVersion: 1, brandId: session.brandId, projectId: session.projectId, appliedAt: (/* @__PURE__ */ new Date()).toISOString(), accountSetup: intake.accountSetup, paths: Object.keys(merged) }), { document: false, mode: 384 });
|
|
185950
187542
|
}
|
|
185951
187543
|
return { schemaVersion: 1, brandId: session.brandId, projectId: session.projectId, dryRun: !!options.dryRun, changed: pending.map((w) => w.path), documents: Object.keys(merged).length, brainGenerated: !options.dryRun, accountActions: plan.accountActions, aiAnalyzed: false, cloudSynced: false, next: "Local documents are ready after apply. Install the skill if needed, authenticate, use onboarding sync for this session, then complete and verify requested accountActions. Only if requested, use brain prepare and review before brain accept. A brain is editorial context, not a rendered video." };
|
|
185952
187544
|
}, { migrateLegacy: !options.dryRun });
|
|
@@ -185955,7 +187547,7 @@ async function syncOnboarding(client, options) {
|
|
|
185955
187547
|
const root = await ensureRoot(options.directory);
|
|
185956
187548
|
return withWorkspaceLock(root, async () => {
|
|
185957
187549
|
const session = await readSession(root, options.session);
|
|
185958
|
-
const receipt = await readProductionJson(root, `${
|
|
187550
|
+
const receipt = await readProductionJson(root, `${dirname12(options.session)}/applied.json`);
|
|
185959
187551
|
if (receipt.brandId !== session.brandId || receipt.projectId !== session.projectId) throw failure("ONBOARDING_NOT_APPLIED", "Apply the reviewed choices locally before syncing.");
|
|
185960
187552
|
const files = {};
|
|
185961
187553
|
for (const path of paths(session.brandId, session.projectId)) {
|
|
@@ -185972,7 +187564,7 @@ async function syncOnboarding(client, options) {
|
|
|
185972
187564
|
async function serveOnboarding(options) {
|
|
185973
187565
|
const root = await ensureRoot(options.directory), session = await readSession(root, options.session), seconds = options.timeoutSeconds ?? 1800;
|
|
185974
187566
|
if (!Number.isInteger(seconds) || seconds < 1 || seconds > 3600) throw failure("INVALID_ARGUMENT", "Timeout must be between 1 and 3600 seconds.");
|
|
185975
|
-
const token = randomBytes(32).toString("hex"), csrf = randomBytes(32).toString("hex"), prefix = `/${token}`, answers = `${
|
|
187567
|
+
const token = randomBytes(32).toString("hex"), csrf = randomBytes(32).toString("hex"), prefix = `/${token}`, answers = `${dirname12(options.session)}/answers.json`;
|
|
185976
187568
|
let origin = "", consumed = false, busy = false, server;
|
|
185977
187569
|
let complete, reject;
|
|
185978
187570
|
const done = new Promise((yes, no) => {
|
|
@@ -186012,7 +187604,7 @@ async function serveOnboarding(options) {
|
|
|
186012
187604
|
await atomicWrite(root, answers, stableJson(intake), { document: false, overwrite: false, mode: 384 });
|
|
186013
187605
|
consumed = true;
|
|
186014
187606
|
send(200, { saved: true, path: answers });
|
|
186015
|
-
complete({ schemaVersion: 1, saved: true, answers:
|
|
187607
|
+
complete({ schemaVersion: 1, saved: true, answers: join12(root, answers), session: options.session, applied: false, next: "Review saved choices and run onboarding apply with this session and answers file." });
|
|
186016
187608
|
} catch (e) {
|
|
186017
187609
|
busy = false;
|
|
186018
187610
|
send(400, { error: e.message.slice(0, 300) });
|
|
@@ -186032,7 +187624,7 @@ async function serveOnboarding(options) {
|
|
|
186032
187624
|
process.once("SIGINT", stop);
|
|
186033
187625
|
process.once("SIGTERM", stop);
|
|
186034
187626
|
try {
|
|
186035
|
-
options.onReady?.({ url: `${origin}${prefix}/`, answers:
|
|
187627
|
+
options.onReady?.({ url: `${origin}${prefix}/`, answers: join12(root, answers) });
|
|
186036
187628
|
return await done;
|
|
186037
187629
|
} finally {
|
|
186038
187630
|
clearTimeout(timer);
|
|
@@ -186327,10 +187919,10 @@ async function loginWithDevice(options, overrides = {}) {
|
|
|
186327
187919
|
}
|
|
186328
187920
|
|
|
186329
187921
|
// packages/cli/src/index.ts
|
|
186330
|
-
import { chmod as chmod2, lstat as lstat12, mkdir as
|
|
186331
|
-
import { constants as
|
|
187922
|
+
import { chmod as chmod2, lstat as lstat12, mkdir as mkdir14, open as open12 } from "node:fs/promises";
|
|
187923
|
+
import { constants as constants11 } from "node:fs";
|
|
186332
187924
|
import { homedir as homedir3 } from "node:os";
|
|
186333
|
-
import { basename as basename4, dirname as
|
|
187925
|
+
import { basename as basename4, dirname as dirname18, extname as extname7, join as join15, resolve as resolve12 } from "node:path";
|
|
186334
187926
|
|
|
186335
187927
|
// packages/cli/src/direction-context.ts
|
|
186336
187928
|
async function prepareDirectionContext(root, client, projectId) {
|
|
@@ -186354,10 +187946,10 @@ async function prepareDirectionContext(root, client, projectId) {
|
|
|
186354
187946
|
}
|
|
186355
187947
|
|
|
186356
187948
|
// packages/cli/src/style-authoring.ts
|
|
186357
|
-
import { createHash as
|
|
186358
|
-
import { constants as
|
|
186359
|
-
import { lstat as
|
|
186360
|
-
import { dirname as
|
|
187949
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
187950
|
+
import { constants as constants8 } from "node:fs";
|
|
187951
|
+
import { lstat as lstat9, mkdir as mkdir9, open as open9, readdir as readdir5, rmdir, unlink as unlink7 } from "node:fs/promises";
|
|
187952
|
+
import { dirname as dirname13 } from "node:path";
|
|
186361
187953
|
function styleId(id2) {
|
|
186362
187954
|
try {
|
|
186363
187955
|
return assertIdentifier(id2);
|
|
@@ -186367,7 +187959,7 @@ function styleId(id2) {
|
|
|
186367
187959
|
}
|
|
186368
187960
|
async function exists(path) {
|
|
186369
187961
|
try {
|
|
186370
|
-
await
|
|
187962
|
+
await lstat9(path);
|
|
186371
187963
|
return true;
|
|
186372
187964
|
} catch (error) {
|
|
186373
187965
|
if (error.code === "ENOENT") return false;
|
|
@@ -186396,12 +187988,12 @@ async function makeDirectories(root, path, created) {
|
|
|
186396
187988
|
const relative2 = segments.slice(0, i).join("/");
|
|
186397
187989
|
const target = await checkedPath(root, relative2, false);
|
|
186398
187990
|
try {
|
|
186399
|
-
await
|
|
186400
|
-
const info = await
|
|
187991
|
+
await mkdir9(target);
|
|
187992
|
+
const info = await lstat9(target);
|
|
186401
187993
|
created.push({ path: relative2, dev: info.dev, ino: info.ino });
|
|
186402
187994
|
} catch (error) {
|
|
186403
187995
|
if (error.code !== "EEXIST") throw error;
|
|
186404
|
-
if (!(await
|
|
187996
|
+
if (!(await lstat9(await checkedPath(root, relative2, false))).isDirectory()) throw new Error(`Not a directory: ${relative2}`);
|
|
186405
187997
|
}
|
|
186406
187998
|
}
|
|
186407
187999
|
}
|
|
@@ -186409,10 +188001,10 @@ async function cleanCreated(root, paths2, directory) {
|
|
|
186409
188001
|
for (const item of [...paths2].reverse()) {
|
|
186410
188002
|
try {
|
|
186411
188003
|
const target = await checkedPath(root, item.path, false);
|
|
186412
|
-
const info = await
|
|
188004
|
+
const info = await lstat9(target);
|
|
186413
188005
|
if (info.dev !== item.dev || info.ino !== item.ino || info.isSymbolicLink()) continue;
|
|
186414
188006
|
if (directory) await rmdir(target);
|
|
186415
|
-
else await
|
|
188007
|
+
else await unlink7(target);
|
|
186416
188008
|
} catch {
|
|
186417
188009
|
}
|
|
186418
188010
|
}
|
|
@@ -186431,9 +188023,9 @@ async function createLocalStyle(options) {
|
|
|
186431
188023
|
const createdDirectories = [];
|
|
186432
188024
|
try {
|
|
186433
188025
|
for (const [path, content] of Object.entries(files)) {
|
|
186434
|
-
await makeDirectories(root,
|
|
188026
|
+
await makeDirectories(root, dirname13(path), createdDirectories);
|
|
186435
188027
|
const target = await checkedPath(root, path);
|
|
186436
|
-
const handle = await
|
|
188028
|
+
const handle = await open9(target, constants8.O_WRONLY | constants8.O_CREAT | constants8.O_EXCL | constants8.O_NOFOLLOW, 420);
|
|
186437
188029
|
try {
|
|
186438
188030
|
const info = await handle.stat();
|
|
186439
188031
|
createdFiles.push({ path, dev: info.dev, ino: info.ino });
|
|
@@ -186466,7 +188058,7 @@ async function readStyle(root, id2) {
|
|
|
186466
188058
|
try {
|
|
186467
188059
|
const target = await checkedPath(root, path, false);
|
|
186468
188060
|
if (!await exists(target)) continue;
|
|
186469
|
-
if (!(await
|
|
188061
|
+
if (!(await lstat9(target)).isDirectory()) {
|
|
186470
188062
|
issues.push({ path, message: "Style path is not a directory." });
|
|
186471
188063
|
continue;
|
|
186472
188064
|
}
|
|
@@ -186495,15 +188087,15 @@ async function readStyle(root, id2) {
|
|
|
186495
188087
|
async function checkLocalResource(root, path, expected) {
|
|
186496
188088
|
safeStyleResourcePath(path);
|
|
186497
188089
|
const target = await checkedPath(root, path, false);
|
|
186498
|
-
const handle = await
|
|
188090
|
+
const handle = await open9(target, constants8.O_RDONLY | constants8.O_NOFOLLOW | constants8.O_NONBLOCK);
|
|
186499
188091
|
try {
|
|
186500
188092
|
const before = await handle.stat();
|
|
186501
188093
|
if (!before.isFile()) throw new Error("Resource is not a regular file.");
|
|
186502
188094
|
if (!expected) return {};
|
|
186503
|
-
const hash6 =
|
|
188095
|
+
const hash6 = createHash8("sha256");
|
|
186504
188096
|
for await (const chunk of handle.createReadStream({ autoClose: false })) hash6.update(chunk);
|
|
186505
188097
|
const after = await handle.stat();
|
|
186506
|
-
const current2 = await
|
|
188098
|
+
const current2 = await lstat9(await checkedPath(root, path, false));
|
|
186507
188099
|
if (before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || current2.dev !== before.dev || current2.ino !== before.ino) {
|
|
186508
188100
|
throw new Error("Resource changed while its hash was being checked; check it again.");
|
|
186509
188101
|
}
|
|
@@ -187046,9 +188638,9 @@ async function searchMediaSources(options, dependencies = {}) {
|
|
|
187046
188638
|
}
|
|
187047
188639
|
|
|
187048
188640
|
// packages/cli/src/media-inventory.ts
|
|
187049
|
-
import { createHash as
|
|
187050
|
-
import { link as
|
|
187051
|
-
import { basename as basename3, dirname as
|
|
188641
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
188642
|
+
import { link as link5, lstat as lstat10, mkdir as mkdir10, mkdtemp as mkdtemp3, opendir, readFile as readFile7, rm as rm4 } from "node:fs/promises";
|
|
188643
|
+
import { basename as basename3, dirname as dirname14, extname as extname4, join as join13 } from "node:path";
|
|
187052
188644
|
var GENERATED_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "output", "outputs", "renders", "render", "cache", "caches", "proxies", "proxy", "samples", "thumbnails", "coverage", "venv", "__pycache__"]);
|
|
187053
188645
|
function mediaFailure(error) {
|
|
187054
188646
|
if (error instanceof MediaToolError) return { code: error.code, message: error.message };
|
|
@@ -187074,7 +188666,7 @@ async function inventoryMedia(options) {
|
|
|
187074
188666
|
}
|
|
187075
188667
|
report.scannedEntries++;
|
|
187076
188668
|
try {
|
|
187077
|
-
const stat = await
|
|
188669
|
+
const stat = await lstat10(path);
|
|
187078
188670
|
if (stat.isSymbolicLink()) {
|
|
187079
188671
|
if (explicit) throw new MediaToolError("MEDIA_SYMLINK", "Symlink inputs are not followed. Use the original local path.");
|
|
187080
188672
|
skip(path, "symlink_not_followed");
|
|
@@ -187100,7 +188692,7 @@ async function inventoryMedia(options) {
|
|
|
187100
188692
|
skip(path, "remaining_entries_not_scanned", true);
|
|
187101
188693
|
break;
|
|
187102
188694
|
}
|
|
187103
|
-
await visit(
|
|
188695
|
+
await visit(join13(path, entry.name), depth + 1);
|
|
187104
188696
|
}
|
|
187105
188697
|
} else if (!stat.isFile()) {
|
|
187106
188698
|
if (explicit) throw new MediaToolError("MEDIA_NOT_REGULAR", "The explicit media input must be a regular local file or directory.");
|
|
@@ -187135,35 +188727,35 @@ async function sampleMedia(options) {
|
|
|
187135
188727
|
if (!source2.streams.some((stream) => stream.type === "video")) throw new MediaToolError("MEDIA_VIDEO_REQUIRED", "Frame sampling requires a video or image stream.");
|
|
187136
188728
|
if (source2.durationSeconds !== null && options.times.some((time) => time >= source2.durationSeconds)) throw new MediaToolError("MEDIA_SAMPLE_OUT_OF_RANGE", "A requested sample is outside the known media duration.");
|
|
187137
188729
|
const outputDirectory = resolveLocalMediaPath(options.outputDirectory);
|
|
187138
|
-
await assertNoMediaSymlinks(
|
|
188730
|
+
await assertNoMediaSymlinks(dirname14(outputDirectory));
|
|
187139
188731
|
try {
|
|
187140
|
-
await
|
|
188732
|
+
await mkdir10(outputDirectory);
|
|
187141
188733
|
} catch (error) {
|
|
187142
188734
|
if (error.code !== "EEXIST") throw error;
|
|
187143
188735
|
}
|
|
187144
188736
|
await assertNoMediaSymlinks(outputDirectory);
|
|
187145
|
-
if (!(await
|
|
187146
|
-
const temp = await mkdtemp3(
|
|
187147
|
-
const tempStat = await
|
|
188737
|
+
if (!(await lstat10(outputDirectory)).isDirectory()) throw new MediaToolError("MEDIA_OUTPUT_DIRECTORY_INVALID", "Frame output must be a local directory.");
|
|
188738
|
+
const temp = await mkdtemp3(join13(outputDirectory, ".editorbrain-samples-"));
|
|
188739
|
+
const tempStat = await lstat10(temp);
|
|
187148
188740
|
const frames = [];
|
|
187149
188741
|
const created = [];
|
|
187150
188742
|
try {
|
|
187151
188743
|
for (let index = 0; index < options.times.length; index++) {
|
|
187152
188744
|
const time = options.times[index];
|
|
187153
188745
|
const filename = `${source2.sha256.slice(0, 12)}-${String(index + 1).padStart(2, "0")}-${Math.round(time * 1e3)}ms.jpg`;
|
|
187154
|
-
const temporary =
|
|
188746
|
+
const temporary = join13(temp, filename), output2 = join13(outputDirectory, filename);
|
|
187155
188747
|
await runMediaTool("ffmpeg", ["-v", "error", "-n", "-ss", String(time), ...localInputArgs(file), "-map", "0:v:0", "-frames:v", "1", "-an", "-sn", "-dn", "-vf", "scale=960:960:force_original_aspect_ratio=decrease", "-q:v", "3", "-update", "1", temporary], { timeoutMs: 6e4 });
|
|
187156
188748
|
const bytes = await readFile7(temporary);
|
|
187157
188749
|
if (!bytes.length) throw new MediaToolError("MEDIA_SAMPLE_EMPTY", "The requested frame did not produce a usable image.");
|
|
187158
188750
|
try {
|
|
187159
|
-
await
|
|
188751
|
+
await link5(temporary, output2);
|
|
187160
188752
|
} catch (error) {
|
|
187161
188753
|
if (error.code === "EEXIST") throw new MediaToolError("MEDIA_OUTPUT_EXISTS", "A sample output already exists. Choose a new output directory; existing files are never overwritten.");
|
|
187162
188754
|
throw error;
|
|
187163
188755
|
}
|
|
187164
|
-
const outputStat = await
|
|
188756
|
+
const outputStat = await lstat10(output2);
|
|
187165
188757
|
created.push({ path: output2, ino: outputStat.ino, dev: outputStat.dev, size: outputStat.size, mtimeMs: outputStat.mtimeMs, ctimeMs: outputStat.ctimeMs });
|
|
187166
|
-
frames.push({ path: output2, sha256:
|
|
188758
|
+
frames.push({ path: output2, sha256: createHash9("sha256").update(bytes).digest("hex"), bytes: bytes.length, requestedTimeSeconds: time, actualPresentationTimeSeconds: null });
|
|
187167
188759
|
}
|
|
187168
188760
|
const after = await probeLocalMedia(file);
|
|
187169
188761
|
if (source2.sha256 !== after.sha256) throw new MediaToolError("MEDIA_FILE_CHANGED", "The source changed while frames were being sampled. Retry with a stable source.");
|
|
@@ -187172,8 +188764,8 @@ async function sampleMedia(options) {
|
|
|
187172
188764
|
for (const file2 of created) {
|
|
187173
188765
|
try {
|
|
187174
188766
|
await assertNoMediaSymlinks(file2.path);
|
|
187175
|
-
const current2 = await
|
|
187176
|
-
if (current2.ino === file2.ino && current2.dev === file2.dev && current2.size === file2.size && current2.mtimeMs === file2.mtimeMs && current2.ctimeMs === file2.ctimeMs) await
|
|
188767
|
+
const current2 = await lstat10(file2.path);
|
|
188768
|
+
if (current2.ino === file2.ino && current2.dev === file2.dev && current2.size === file2.size && current2.mtimeMs === file2.mtimeMs && current2.ctimeMs === file2.ctimeMs) await rm4(file2.path, { force: true });
|
|
187177
188769
|
} catch {
|
|
187178
188770
|
}
|
|
187179
188771
|
}
|
|
@@ -187181,8 +188773,8 @@ async function sampleMedia(options) {
|
|
|
187181
188773
|
} finally {
|
|
187182
188774
|
try {
|
|
187183
188775
|
await assertNoMediaSymlinks(temp);
|
|
187184
|
-
const current2 = await
|
|
187185
|
-
if (current2.ino === tempStat.ino && current2.dev === tempStat.dev) await
|
|
188776
|
+
const current2 = await lstat10(temp);
|
|
188777
|
+
if (current2.ino === tempStat.ino && current2.dev === tempStat.dev) await rm4(temp, { recursive: true, force: true });
|
|
187186
188778
|
} catch {
|
|
187187
188779
|
}
|
|
187188
188780
|
}
|
|
@@ -187453,10 +189045,10 @@ async function checkRender(options) {
|
|
|
187453
189045
|
}
|
|
187454
189046
|
|
|
187455
189047
|
// packages/cli/src/motion-components.ts
|
|
187456
|
-
import { createHash as
|
|
187457
|
-
import { constants as
|
|
187458
|
-
import { lstat as
|
|
187459
|
-
import { dirname as
|
|
189048
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
189049
|
+
import { constants as constants9 } from "node:fs";
|
|
189050
|
+
import { lstat as lstat11, mkdir as mkdir11, open as open10, rmdir as rmdir2, unlink as unlink8 } from "node:fs/promises";
|
|
189051
|
+
import { dirname as dirname15, extname as extname5, resolve as resolve9 } from "node:path";
|
|
187460
189052
|
|
|
187461
189053
|
// packages/core/src/motion-editorial.ts
|
|
187462
189054
|
function createEditorialRenderer(config2, g) {
|
|
@@ -189290,7 +190882,7 @@ function inputPath(base, value) {
|
|
|
189290
190882
|
}
|
|
189291
190883
|
async function sourceFile(path, role, max) {
|
|
189292
190884
|
await assertNoMediaSymlinks(path);
|
|
189293
|
-
const handle = await
|
|
190885
|
+
const handle = await open10(path, constants9.O_RDONLY | constants9.O_NOFOLLOW | constants9.O_NONBLOCK);
|
|
189294
190886
|
try {
|
|
189295
190887
|
const before = await handle.stat();
|
|
189296
190888
|
if (!before.isFile() || before.size === 0 || before.size > max) throw fail2(`${role} must be a nonempty regular file of at most ${max} bytes.`);
|
|
@@ -189303,9 +190895,9 @@ async function sourceFile(path, role, max) {
|
|
|
189303
190895
|
}
|
|
189304
190896
|
const after = await handle.stat();
|
|
189305
190897
|
await assertNoMediaSymlinks(path);
|
|
189306
|
-
const current2 = await
|
|
190898
|
+
const current2 = await lstat11(path);
|
|
189307
190899
|
if (before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || current2.dev !== before.dev || current2.ino !== before.ino || current2.size !== after.size || current2.mtimeMs !== after.mtimeMs) throw fail2(`${role} changed during reading.`);
|
|
189308
|
-
return { source: { role, path, bytes: content.length, sha256:
|
|
190900
|
+
return { source: { role, path, bytes: content.length, sha256: createHash10("sha256").update(content).digest("hex") }, content };
|
|
189309
190901
|
} finally {
|
|
189310
190902
|
await handle.close();
|
|
189311
190903
|
}
|
|
@@ -189318,7 +190910,7 @@ function embed(content, path, kind) {
|
|
|
189318
190910
|
}
|
|
189319
190911
|
async function exists2(path) {
|
|
189320
190912
|
try {
|
|
189321
|
-
await
|
|
190913
|
+
await lstat11(path);
|
|
189322
190914
|
return true;
|
|
189323
190915
|
} catch (error) {
|
|
189324
190916
|
if (error.code === "ENOENT") return false;
|
|
@@ -189331,22 +190923,22 @@ async function makeParents(root, path, created) {
|
|
|
189331
190923
|
const relative2 = parts.slice(0, index).join("/");
|
|
189332
190924
|
const target = await checkedPath(root, relative2, false);
|
|
189333
190925
|
try {
|
|
189334
|
-
await
|
|
189335
|
-
const info = await
|
|
190926
|
+
await mkdir11(target, { mode: 448 });
|
|
190927
|
+
const info = await lstat11(target);
|
|
189336
190928
|
created.push({ path: relative2, dev: info.dev, ino: info.ino, directory: true });
|
|
189337
190929
|
} catch (error) {
|
|
189338
190930
|
if (error.code !== "EEXIST") throw error;
|
|
189339
|
-
if (!(await
|
|
190931
|
+
if (!(await lstat11(await checkedPath(root, relative2, false))).isDirectory()) throw fail2("Output parent must be a directory.");
|
|
189340
190932
|
}
|
|
189341
190933
|
}
|
|
189342
190934
|
}
|
|
189343
190935
|
async function cleanCreated2(root, created) {
|
|
189344
190936
|
for (const item of [...created].reverse()) {
|
|
189345
190937
|
try {
|
|
189346
|
-
const path = await checkedPath(root, item.path, false), info = await
|
|
190938
|
+
const path = await checkedPath(root, item.path, false), info = await lstat11(path);
|
|
189347
190939
|
if (info.dev !== item.dev || info.ino !== item.ino || info.isSymbolicLink()) continue;
|
|
189348
190940
|
if (item.directory) await rmdir2(path);
|
|
189349
|
-
else await
|
|
190941
|
+
else await unlink8(path);
|
|
189350
190942
|
} catch {
|
|
189351
190943
|
}
|
|
189352
190944
|
}
|
|
@@ -189371,14 +190963,14 @@ async function prepareMotionComponent(options) {
|
|
|
189371
190963
|
if (typeof value !== "string" || !value.trim()) throw fail2(`Required binding ${role} references missing or non-string token ${key}. No demo default was applied.`);
|
|
189372
190964
|
return [role, value];
|
|
189373
190965
|
}));
|
|
189374
|
-
const fontPath = inputPath(
|
|
190966
|
+
const fontPath = inputPath(dirname15(input.source.path), document2.fontFile);
|
|
189375
190967
|
const font = await sourceFile(fontPath, "font", MOTION_INPUT_LIMITS.fontBytes);
|
|
189376
190968
|
const sources = [input.source, font.source];
|
|
189377
190969
|
const items = [];
|
|
189378
190970
|
for (const [index, item] of document2.items.entries()) {
|
|
189379
190971
|
let image2;
|
|
189380
190972
|
if (item.imageFile) {
|
|
189381
|
-
const path = inputPath(
|
|
190973
|
+
const path = inputPath(dirname15(input.source.path), item.imageFile);
|
|
189382
190974
|
const file = await sourceFile(path, `items[${index}].image`, MOTION_INPUT_LIMITS.imageBytes);
|
|
189383
190975
|
image2 = embed(file.content, path, "image");
|
|
189384
190976
|
sources.push(file.source);
|
|
@@ -189419,7 +191011,7 @@ async function prepareMotionComponent(options) {
|
|
|
189419
191011
|
resolvedBindings: Object.fromEntries(Object.entries(document2.bindings).map(([role, key]) => [role, { key, value: bound[role], source: resolved.tokenSources[key] }])),
|
|
189420
191012
|
sources,
|
|
189421
191013
|
context: { sourceHashes: resolved.lock.sourceHashes, output: resolved.output, mediaPreferences: resolved.mediaPreferences },
|
|
189422
|
-
files: { "config.json": { sha256:
|
|
191014
|
+
files: { "config.json": { sha256: createHash10("sha256").update(configJson).digest("hex") }, "index.html": { sha256: createHash10("sha256").update(html).digest("hex") } },
|
|
189423
191015
|
warnings: resolved.warnings
|
|
189424
191016
|
};
|
|
189425
191017
|
const readme = `# EditorBrain motion component
|
|
@@ -189439,13 +191031,13 @@ Preparation is not a rendered video or a quality certification. Inspect text fit
|
|
|
189439
191031
|
if (await exists2(await productionOutputPath(root, options.outDirectory))) throw new CliError("MOTION_OUTPUT_EXISTS", "The output directory already exists; nothing was overwritten.", "Choose a new directory under .editorbrain-local/.");
|
|
189440
191032
|
const created = [];
|
|
189441
191033
|
try {
|
|
189442
|
-
await makeParents(root,
|
|
189443
|
-
await
|
|
189444
|
-
const info = await
|
|
191034
|
+
await makeParents(root, dirname15(options.outDirectory), created);
|
|
191035
|
+
await mkdir11(await productionOutputPath(root, options.outDirectory), { mode: 448 });
|
|
191036
|
+
const info = await lstat11(output2);
|
|
189445
191037
|
created.push({ path: options.outDirectory, dev: info.dev, ino: info.ino, directory: true });
|
|
189446
191038
|
for (const [name, content] of Object.entries(files)) {
|
|
189447
191039
|
const path = `${options.outDirectory}/${name}`;
|
|
189448
|
-
const handle = await
|
|
191040
|
+
const handle = await open10(await productionOutputPath(root, path), constants9.O_WRONLY | constants9.O_CREAT | constants9.O_EXCL | constants9.O_NOFOLLOW, 384);
|
|
189449
191041
|
try {
|
|
189450
191042
|
const stat = await handle.stat();
|
|
189451
191043
|
created.push({ path, dev: stat.dev, ino: stat.ino, directory: false });
|
|
@@ -189476,71 +191068,10 @@ Preparation is not a rendered video or a quality certification. Inspect text fit
|
|
|
189476
191068
|
}, { migrateLegacy: false });
|
|
189477
191069
|
}
|
|
189478
191070
|
|
|
189479
|
-
// packages/cli/src/authored-motion.ts
|
|
189480
|
-
import { lstat as lstat11, mkdir as mkdir10, open as open9, link as link5, unlink as unlink8 } from "node:fs/promises";
|
|
189481
|
-
import { dirname as dirname14, join as join12 } from "node:path";
|
|
189482
|
-
import { createHash as createHash9, randomUUID as randomUUID5 } from "node:crypto";
|
|
189483
|
-
async function downloadAuthoredSource(client, pin, root, out, fetcher = fetch) {
|
|
189484
|
-
if (!/^[a-z0-9][a-z0-9-]{0,79}$/.test(pin.id) || !/^\d+\.\d+\.\d+$/.test(pin.version) || !/^[a-f0-9]{64}$/.test(pin.sha256) || !Number.isSafeInteger(pin.bytes) || pin.bytes < 1 || pin.bytes > (pin.version === "1.4.0" ? 96 : 16) * 1024 * 1024) throw new CliError("INVALID_ARGUMENT", "Invalid pinned scene bundle.", "Retrieve one authored scene from the catalog.");
|
|
189485
|
-
const target = await checkedPath(root, out, false);
|
|
189486
|
-
try {
|
|
189487
|
-
await lstat11(target);
|
|
189488
|
-
throw new CliError("FILE_EXISTS", "The output already exists.", "Choose a new archive path.");
|
|
189489
|
-
} catch (error) {
|
|
189490
|
-
if (error.code !== "ENOENT") throw error;
|
|
189491
|
-
}
|
|
189492
|
-
const metadata = await client.request(`/v1/authored-motion/${pin.id}/source?${new URLSearchParams({ version: pin.version, sha256: pin.sha256 })}`);
|
|
189493
|
-
const url2 = new URL(metadata.url);
|
|
189494
|
-
const expectedPath = `/v1/authored-motion-download/${pin.id}/${pin.version}/${pin.sha256}`;
|
|
189495
|
-
const origin = new URL(client.url).origin;
|
|
189496
|
-
const trustedOrigin = url2.origin === origin || origin === "https://editorharness-api.innovandohorizontes.workers.dev" && url2.origin === "https://api.editorbrain.com";
|
|
189497
|
-
if (metadata.sha256 !== pin.sha256 || metadata.bytes !== pin.bytes || !trustedOrigin || url2.pathname !== expectedPath || url2.username || url2.password || url2.hash) throw new CliError("INVALID_RESPONSE", "Scene bundle metadata differs from the selected version.", "Do not use this source. Retrieve the pinned catalog entry again.");
|
|
189498
|
-
const response = await fetcher(url2, { redirect: "error", signal: AbortSignal.timeout(18e4) });
|
|
189499
|
-
if (response.status === 403) {
|
|
189500
|
-
await response.body?.cancel();
|
|
189501
|
-
throw new CliError("RESOURCE_ACCESS_CHANGED", "Source access was denied at download time.", "Check current workspace permissions and membership at https://editorbrain.com/app/billing. Do not retry old versions or buy credits to unlock premium resources; existing archives were preserved.");
|
|
189502
|
-
}
|
|
189503
|
-
if (!response.ok) throw new CliError("DOWNLOAD_FAILED", `Scene download failed (HTTP ${response.status}).`, "Request a new source link; existing archives were preserved.");
|
|
189504
|
-
const reader = response.body?.getReader();
|
|
189505
|
-
if (!reader) throw new CliError("INVALID_RESPONSE", "Scene download body is missing.", "Retry the pinned source.");
|
|
189506
|
-
const temporary = join12(dirname14(target), `.eb-motion-${randomUUID5()}.tmp`);
|
|
189507
|
-
let handle;
|
|
189508
|
-
const hash6 = createHash9("sha256");
|
|
189509
|
-
let size = 0;
|
|
189510
|
-
try {
|
|
189511
|
-
await mkdir10(dirname14(target), { recursive: true });
|
|
189512
|
-
await checkedPath(root, out, false);
|
|
189513
|
-
handle = await open9(temporary, "wx", 384);
|
|
189514
|
-
for (; ; ) {
|
|
189515
|
-
const { done, value } = await reader.read();
|
|
189516
|
-
if (done) break;
|
|
189517
|
-
size += value.length;
|
|
189518
|
-
if (size > pin.bytes) throw new CliError("HASH_MISMATCH", "Scene archive exceeds the pinned length.", "Discard the unverified download.");
|
|
189519
|
-
hash6.update(value);
|
|
189520
|
-
await handle.writeFile(value);
|
|
189521
|
-
}
|
|
189522
|
-
if (size !== pin.bytes || hash6.digest("hex") !== pin.sha256) throw new CliError("HASH_MISMATCH", "Scene archive verification failed.", "Do not extract this download.");
|
|
189523
|
-
await handle.sync();
|
|
189524
|
-
await handle.close();
|
|
189525
|
-
await checkedPath(root, out, false);
|
|
189526
|
-
await link5(temporary, target);
|
|
189527
|
-
} catch (error) {
|
|
189528
|
-
await reader.cancel().catch(() => {
|
|
189529
|
-
});
|
|
189530
|
-
throw error;
|
|
189531
|
-
} finally {
|
|
189532
|
-
await handle?.close().catch(() => {
|
|
189533
|
-
});
|
|
189534
|
-
await unlink8(temporary).catch(() => {
|
|
189535
|
-
});
|
|
189536
|
-
}
|
|
189537
|
-
return { id: pin.id, version: pin.version, path: target, sha256: pin.sha256, bytes: size, extracted: false, executed: false, rendered: false, next: "Inspect bundle README and selected card; extract into a new local directory. Bind current project colors, fonts, language, content, timing and sound before rendering. The demo is not your finished edit." };
|
|
189538
|
-
}
|
|
189539
|
-
|
|
189540
191071
|
// packages/cli/src/production-verify.ts
|
|
189541
|
-
import { createHash as
|
|
189542
|
-
import { mkdir as
|
|
189543
|
-
import { dirname as
|
|
191072
|
+
import { createHash as createHash11, randomUUID as randomUUID6 } from "node:crypto";
|
|
191073
|
+
import { mkdir as mkdir12, readFile as readFile8 } from "node:fs/promises";
|
|
191074
|
+
import { dirname as dirname16, join as join14, resolve as resolve10 } from "node:path";
|
|
189544
191075
|
|
|
189545
191076
|
// packages/cli/src/production-media-review.ts
|
|
189546
191077
|
function productionMediaReview(resolved) {
|
|
@@ -189597,7 +191128,7 @@ function productionEditorialReview(resolved) {
|
|
|
189597
191128
|
}
|
|
189598
191129
|
|
|
189599
191130
|
// packages/cli/src/production-verify.ts
|
|
189600
|
-
var digest2 = (value) =>
|
|
191131
|
+
var digest2 = (value) => createHash11("sha256").update(value).digest("hex");
|
|
189601
191132
|
var errorCode2 = (error) => error && typeof error === "object" && "code" in error && typeof error.code === "string" && /^[A-Z0-9_]+$/.test(error.code) ? error.code : "PRODUCTION_VERIFY_FAILED";
|
|
189602
191133
|
function productionVerificationRequirements(options) {
|
|
189603
191134
|
const { resolved } = options;
|
|
@@ -189631,7 +191162,7 @@ async function sampleFinalArtifact(file, probe2, directory, requested) {
|
|
|
189631
191162
|
result2.failures.push({ requestedTimeSeconds: time, code: "MEDIA_SAMPLE_OUT_OF_RANGE" });
|
|
189632
191163
|
continue;
|
|
189633
191164
|
}
|
|
189634
|
-
const path =
|
|
191165
|
+
const path = join14(directory, `sample-${String(result2.items.length + result2.failures.length + 1).padStart(2, "0")}.png`);
|
|
189635
191166
|
try {
|
|
189636
191167
|
const output2 = await runMediaTool("ffmpeg", [
|
|
189637
191168
|
"-loglevel",
|
|
@@ -189717,10 +191248,10 @@ async function verifyProduction(options) {
|
|
|
189717
191248
|
if (options.sampleTimesSeconds !== void 0 && (!Array.isArray(options.sampleTimesSeconds) || options.sampleTimesSeconds.length < 1 || options.sampleTimesSeconds.length > 6 || Array.from(options.sampleTimesSeconds).some((time) => typeof time !== "number" || !Number.isFinite(time) || time < 0 || time > 86400))) throw new CliError("INVALID_SAMPLE_TIMES", "Provide one to six finite sample times between 0 and 86400 seconds.", "Select a few timestamps that answer a review question.");
|
|
189718
191249
|
const relativeDirectory = options.outDirectory ?? `.editorbrain-local/${options.resolved.project.id}/verify-${randomUUID6()}`;
|
|
189719
191250
|
const directory = await productionOutputPath(root, relativeDirectory);
|
|
189720
|
-
await
|
|
191251
|
+
await mkdir12(dirname16(directory), { recursive: true, mode: 448 });
|
|
189721
191252
|
await productionOutputPath(root, relativeDirectory);
|
|
189722
191253
|
try {
|
|
189723
|
-
await
|
|
191254
|
+
await mkdir12(directory, { mode: 448 });
|
|
189724
191255
|
} catch (error) {
|
|
189725
191256
|
if (error.code === "EEXIST") throw new CliError("PRODUCTION_OUTPUT_EXISTS", "Verification output already exists; nothing was overwritten.", "Choose a new directory under .editorbrain-local/.");
|
|
189726
191257
|
throw error;
|
|
@@ -189809,13 +191340,13 @@ async function verifyProduction(options) {
|
|
|
189809
191340
|
}
|
|
189810
191341
|
|
|
189811
191342
|
// packages/cli/src/review-artifact.ts
|
|
189812
|
-
import { open as
|
|
189813
|
-
import { constants as
|
|
189814
|
-
import { dirname as
|
|
189815
|
-
import { createHash as
|
|
191343
|
+
import { open as open11, mkdir as mkdir13 } from "node:fs/promises";
|
|
191344
|
+
import { constants as constants10 } from "node:fs";
|
|
191345
|
+
import { dirname as dirname17, extname as extname6, resolve as resolve11 } from "node:path";
|
|
191346
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
189816
191347
|
|
|
189817
191348
|
// packages/cli/src/review-artifact-html.ts
|
|
189818
|
-
import { createHash as
|
|
191349
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
189819
191350
|
function reviewApp() {
|
|
189820
191351
|
const data = JSON.parse(document.getElementById("review-data").textContent);
|
|
189821
191352
|
const $ = (id2) => document.getElementById(id2);
|
|
@@ -190152,7 +191683,7 @@ ${JSON.stringify({ ...feedback(), kind: "editorbrain.review-access-request", dec
|
|
|
190152
191683
|
update();
|
|
190153
191684
|
}
|
|
190154
191685
|
function renderReviewArtifact(data, wordmark) {
|
|
190155
|
-
const script = `(${reviewApp.toString()})();`, hash6 =
|
|
191686
|
+
const script = `(${reviewApp.toString()})();`, hash6 = createHash12("sha256").update(script).digest("base64");
|
|
190156
191687
|
const json = JSON.stringify(data).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
190157
191688
|
return `<!doctype html><html lang="es"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-${hash6}'; style-src 'unsafe-inline'; img-src data:; media-src data: blob:; connect-src 'none'; font-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'"><title>EditorBrain \xB7 Tu edici\xF3n</title><style>
|
|
190158
191689
|
*{box-sizing:border-box} [hidden]{display:none!important} :root{color-scheme:dark;font-family:Inter,ui-sans-serif,system-ui,-apple-system,sans-serif;color:#f6f6f6;background:#090909}body{margin:0;background:radial-gradient(ellipse at 15% 0%,#252525 0,transparent 50%),#090909}main{max-width:1220px;margin:auto;padding:28px clamp(18px,4vw,50px) 44px}header{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #ffffff20;padding-bottom:22px;gap:20px}header svg{width:146px;height:auto;display:block}header span{color:#aaa;font-size:12px}h1{font-size:clamp(28px,4vw,48px);font-weight:550;letter-spacing:-.045em;margin:14px 0}h2{font-size:20px;letter-spacing:-.025em;margin:0 0 12px}.eyebrow{font-size:10px;letter-spacing:.18em;color:#aaa;margin:30px 0 0}.intro{color:#aaa;font-size:15px;line-height:1.6;margin-bottom:24px}button,a{touch-action:manipulation}button{border:1px solid #ffffff30;border-radius:12px;background:#ffffff08;color:#fff;padding:11px 15px;font:inherit;font-size:13px;cursor:pointer}button:hover{background:#ffffff16}button:disabled{opacity:.38;cursor:default}.primary{background:#f5f5f5;color:#111;font-weight:650;border-color:#fff}.primary:hover{background:#ddd}.secondary{background:transparent}button:focus-visible,textarea:focus-visible,summary:focus-visible,a:focus-visible{outline:2px solid #fff;outline-offset:4px}p{line-height:1.6}.workspace{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(280px,1fr);gap:30px;align-items:start}.preview{position:sticky;top:20px;min-width:0}.screen{border:1px solid #ffffff22;border-radius:20px;overflow:hidden;background:radial-gradient(ellipse,#242424,#050505);display:flex;justify-content:center;min-height:260px}.screen video{width:100%;max-height:590px;display:block}.controls{display:flex;justify-content:center;align-items:center;gap:16px;margin:12px 0;font-size:12px;color:#aaa;font-variant-numeric:tabular-nums}.controls button{padding:8px 12px}aside{background:linear-gradient(140deg,#ffffff07,#ffffff02);border:1px solid #ffffff19;border-radius:20px;padding:24px}aside>p{color:#aaa;font-size:13px}label{display:block;font-size:12px;color:#bbb}select{max-width:100%;padding:10px;background:#181818;color:#fff;border:1px solid #ffffff40;border-radius:8px}#learning-options article{padding:16px 0;border-top:1px solid #ffffff20}textarea{width:100%;background:#090909;border:1px solid #ffffff30;border-radius:12px;padding:14px;color:#fff;font:inherit;font-size:14px;line-height:1.5;min-height:108px;resize:vertical;margin:12px 0}textarea::placeholder{color:#818181}.target{display:flex;align-items:center;gap:10px;margin:16px 0 0;font-size:12px;color:#bbb;flex-wrap:wrap}.target button{padding:6px 10px}.save{width:100%;margin-bottom:16px}.muted{color:#aaa;font-size:12px}details{border-top:1px solid #ffffff20;padding-top:16px;margin-top:16px}summary{cursor:pointer;font-size:13px;line-height:1.6}#phrases{max-height:300px;overflow-y:auto;margin:12px 0}#phrases article{padding:12px;margin-bottom:8px;border-radius:10px;background:#ffffff04;border-left:2px solid transparent}#phrases .speaking{background:#ffffff12;border-left-color:#fff}#phrases article>button:first-child{border:0;background:none;text-align:left;padding:0;line-height:1.7;width:100%;margin-bottom:8px}#phrases article>button:last-child{font-size:11px;padding:6px 8px}#phrases .removed{opacity:.7}#show-cuts-label{margin:12px 0}#approve{width:100%;margin-top:18px}#pending{padding:12px 16px;border-left:2px solid #eee;background:#ffffff08;font-size:13px;margin-bottom:20px}#notes{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:12px}#notes article{border:1px solid #ffffff22;border-radius:12px;padding:15px;font-size:13px;overflow-wrap:anywhere}#notes p{margin-bottom:0}.note-head{display:flex;align-items:center;justify-content:space-between;gap:10px}.note-head button{font-size:11px;padding:5px 8px}#markers{display:flex;gap:8px;flex-wrap:wrap}#markers button{font-size:11px;padding:7px 10px}.handoff{margin-top:24px;padding:22px;border:1px solid #ffffff30;border-radius:18px;background:#ffffff05}.handoff-head{display:flex;align-items:center;justify-content:space-between;gap:20px}.handoff p{color:#aaa;font-size:13px;margin:6px 0}.handoff .actions{display:flex;gap:8px;flex-shrink:0;flex-wrap:wrap}#status{color:#fff;margin:14px 0;font-size:13px}#request{font-family:ui-monospace,monospace;font-size:12px;min-height:200px}footer{margin-top:22px;display:flex;justify-content:space-between;gap:16px;color:#888;font-size:11px}#direction-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,250px),1fr));gap:18px}.direction{padding:16px;border:1px solid #ffffff22;border-radius:18px;background:#ffffff05}.direction.chosen{border-color:#fff;box-shadow:0 0 0 1px #fff}.direction img,.direction video{width:100%;height:220px;object-fit:contain;border-radius:10px;background:#030303;margin-bottom:18px}.direction p{color:#bbb;font-size:14px}.direction button{width:100%}.direction details a{display:block;color:#fff;font-size:12px;margin:8px 0}.no-preview{height:160px;display:grid;place-items:center;background:#222;color:#aaa;margin-bottom:16px;border-radius:10px}#future{background:none;border:0;color:#aaa;padding:0;font-size:12px;text-align:left}#future-details{color:#aaa;font-size:13px}#future-details summary{color:#eee}.future-note{max-width:660px}#undo{margin-top:12px}input[type=checkbox]{accent-color:#fff}#intro{max-width:680px}
|
|
@@ -190247,7 +191778,7 @@ async function embed2(root, input, kind) {
|
|
|
190247
191778
|
const path = resolve11(root, input.file), extension = extname6(path).toLowerCase();
|
|
190248
191779
|
const mime = { ".mp4": "video/mp4", ".webm": "video/webm", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
190249
191780
|
if (!mime[extension] || kind === "video" && !mime[extension].startsWith("video/")) invalid4("Use MP4/WebM video or PNG/JPEG/WebP proposal previews.");
|
|
190250
|
-
const handle = await
|
|
191781
|
+
const handle = await open11(path, constants10.O_RDONLY | constants10.O_NOFOLLOW | constants10.O_NONBLOCK);
|
|
190251
191782
|
try {
|
|
190252
191783
|
const stat = await handle.stat();
|
|
190253
191784
|
if (!stat.isFile() || stat.size > 24 * 1024 * 1024 || !stat.size) invalid4("Each review preview must be a regular local file under 24 MiB. Make a lightweight review copy; keep your master.");
|
|
@@ -190255,7 +191786,7 @@ async function embed2(root, input, kind) {
|
|
|
190255
191786
|
if (bytes.length > 24 * 1024 * 1024) invalid4("Preview grew while reading; retry with a stable file.");
|
|
190256
191787
|
const after = await handle.stat();
|
|
190257
191788
|
if (after.size !== stat.size || after.mtimeMs !== stat.mtimeMs) invalid4("Preview changed while reading.");
|
|
190258
|
-
const sha2562 =
|
|
191789
|
+
const sha2562 = createHash13("sha256").update(bytes).digest("hex");
|
|
190259
191790
|
if (input.sha256 && input.sha256 !== sha2562) invalid4("Preview hash does not match this version.");
|
|
190260
191791
|
return { uri: `data:${mime[extension]};base64,${bytes.toString("base64")}`, sha256: sha2562, mimeType: mime[extension] };
|
|
190261
191792
|
} finally {
|
|
@@ -190270,9 +191801,9 @@ async function createReviewArtifact(root, value, out) {
|
|
|
190270
191801
|
const directions = input.directions ? await Promise.all(input.directions.map(async ({ preview, ...d }) => ({ ...d, ...preview ? { preview: await embed2(root, preview, "preview") } : {} }))) : void 0;
|
|
190271
191802
|
const clean = { schemaVersion: 1, projectId: input.projectId, title: input.title, version: input.version, stage: input.stage, ...input.contextVersion ? { contextVersion: input.contextVersion } : {}, ...video ? { video } : {}, ...directions ? { directions } : {}, ...input.transcript ? { transcript: input.transcript } : {}, ...input.learnings ? { learnings: input.learnings } : {}, ...input.learningContext ? { learningContext: input.learningContext } : {} };
|
|
190272
191803
|
if (JSON.stringify(clean).length > 40 * 1024 * 1024) invalid4("Embedded previews exceed 40 MiB. Use smaller review copies.");
|
|
190273
|
-
const artifactId =
|
|
191804
|
+
const artifactId = createHash13("sha256").update(JSON.stringify(clean)).digest("hex");
|
|
190274
191805
|
const html = renderReviewArtifact({ ...clean, artifactId }, onboardingWordmark);
|
|
190275
|
-
await
|
|
191806
|
+
await mkdir13(dirname17(target), { recursive: true });
|
|
190276
191807
|
await atomicWrite(root, out, html, { document: false, overwrite: false, mode: 384 });
|
|
190277
191808
|
return { kind: "editorbrain.review-artifact", path: target, artifactId, projectId: input.projectId, stage: input.stage, videoSha256: video?.sha256 ?? null, mediaEmbedded: true, mediaUploaded: false, agentTriggered: false, reviewSurface: "computer", cloudStorageBytes: 0, next: "Default: review on the computer. Open/display this HTML with the host artifact tool. If inline HTML/video is unsupported, offer the downloadable HTML opened in a browser. The user copies the prepared request or attaches downloaded feedback JSON to this chat. Phone review is opt-in: the collapsed action prepares a request, not an upload or approval. Never claim a click started the agent." };
|
|
190278
191809
|
}
|
|
@@ -190475,6 +192006,8 @@ editorbrain library media <video-id> --sha256 media-hash --out file
|
|
|
190475
192006
|
editorbrain narrative search [query] [--kind hook|cta|...] [--channel visual|spoken|...] [--limit 10]
|
|
190476
192007
|
editorbrain narrative get <video-id> [--sha256 document-hash] [--event-offset 0] [--relation-offset 0] [--limit 50]
|
|
190477
192008
|
editorbrain styles list
|
|
192009
|
+
editorbrain styles source <id> --style-version <v> --out <archive> [--dir folder]
|
|
192010
|
+
editorbrain styles prepare <id> --style-version <v> --file <archive> --out <new-directory> [--dir folder]
|
|
190478
192011
|
editorbrain styles create <style-id> [--name name] [--dir folder]
|
|
190479
192012
|
editorbrain styles check <style-id> [--dir folder]
|
|
190480
192013
|
editorbrain media styles [--category image|motion]
|
|
@@ -190599,16 +192132,16 @@ function output(value) {
|
|
|
190599
192132
|
process.stdout.write(stableJson(value));
|
|
190600
192133
|
}
|
|
190601
192134
|
async function configRoot(create = false) {
|
|
190602
|
-
let path = process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ??
|
|
192135
|
+
let path = process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ?? join15(homedir3(), ".config", "editorbrain");
|
|
190603
192136
|
if (!create && !process.env.EDITORBRAIN_CONFIG_DIR && !process.env.EDITORHARNESS_CONFIG_DIR) {
|
|
190604
192137
|
try {
|
|
190605
192138
|
await lstat12(path);
|
|
190606
192139
|
} catch (error) {
|
|
190607
192140
|
if (error.code !== "ENOENT") throw error;
|
|
190608
|
-
path =
|
|
192141
|
+
path = join15(homedir3(), ".config", "editorharness");
|
|
190609
192142
|
}
|
|
190610
192143
|
}
|
|
190611
|
-
if (create) await
|
|
192144
|
+
if (create) await mkdir14(path, { recursive: true, mode: 448 });
|
|
190612
192145
|
return ensureRoot(path);
|
|
190613
192146
|
}
|
|
190614
192147
|
async function loadConfig() {
|
|
@@ -190625,7 +192158,7 @@ async function loadConfig() {
|
|
|
190625
192158
|
async function saveConfig(config2) {
|
|
190626
192159
|
const root = await configRoot(true);
|
|
190627
192160
|
await atomicWrite(root, "config.json", stableJson(config2), { document: false, mode: 384 });
|
|
190628
|
-
await chmod2(
|
|
192161
|
+
await chmod2(join15(root, "config.json"), 384);
|
|
190629
192162
|
}
|
|
190630
192163
|
async function config(args, requireKey = true) {
|
|
190631
192164
|
const stored = await loadConfig();
|
|
@@ -190672,7 +192205,7 @@ async function init(args) {
|
|
|
190672
192205
|
}
|
|
190673
192206
|
}
|
|
190674
192207
|
for (const [path, content] of Object.entries(files)) await atomicWrite(root, path, content, { overwrite: false });
|
|
190675
|
-
for (const path of directories) await
|
|
192208
|
+
for (const path of directories) await mkdir14(await checkedPath(root, path, false), { recursive: true });
|
|
190676
192209
|
const guidance2 = await installGuidance();
|
|
190677
192210
|
try {
|
|
190678
192211
|
await rememberGuidance(guidance2);
|
|
@@ -190990,7 +192523,7 @@ async function main() {
|
|
|
190990
192523
|
if (hookEnd !== void 0 && (!hookEnd.trim() || !Number.isFinite(Number(hookEnd)) || Number(hookEnd) < 0)) throw new Error("--hook-end must be nonnegative final seconds.");
|
|
190991
192524
|
const credentials = projectId && !args.flags.offline ? await config(args, false) : void 0;
|
|
190992
192525
|
const context = projectId ? await prepareProductionContext(root2, projectId, credentials?.apiKey ? new Client(credentials) : void 0) : void 0;
|
|
190993
|
-
output(await mixEvents({ root: root2, voice: resolve12(root2, voice), manifest: await readProductionJson(root2, cues), manifestDirectory:
|
|
192526
|
+
output(await mixEvents({ root: root2, voice: resolve12(root2, voice), manifest: await readProductionJson(root2, cues), manifestDirectory: dirname18(resolve12(root2, cues)), out, context, hookEndSeconds: hookEnd === void 0 ? void 0 : Number(hookEnd) }));
|
|
190994
192527
|
return;
|
|
190995
192528
|
}
|
|
190996
192529
|
if (command === "production" && ["review-sheet", "matte", "matte-plan", "matte-engines", "matte-check"].includes(subcommand)) {
|
|
@@ -191161,6 +192694,14 @@ async function main() {
|
|
|
191161
192694
|
output({ endpoint: client.url, ...await client.me() });
|
|
191162
192695
|
return;
|
|
191163
192696
|
}
|
|
192697
|
+
if (command === "styles" && ["source", "prepare"].includes(subcommand)) {
|
|
192698
|
+
const allowed = /* @__PURE__ */ new Set(["style-version", "out", "dir", ...subcommand === "prepare" ? ["file"] : ["url"]]);
|
|
192699
|
+
const version = str(args, "style-version"), out = str(args, "out"), file = str(args, "file");
|
|
192700
|
+
if (args.positional.length !== 3 || !version || !out || subcommand === "prepare" && !file || Object.keys(args.flags).some((f) => !allowed.has(f))) throw new CliError("INVALID_ARGUMENT", "Use styles source/prepare <id> --style-version <v> --out <new-path>; prepare also requires --file <archive>.", "Run editorbrain help.");
|
|
192701
|
+
const root2 = await ensureRoot(str(args, "dir") ?? process.cwd());
|
|
192702
|
+
output(subcommand === "source" ? await downloadStyle(new Client(await config(args)), argument, version, root2, out) : await prepareStyleSource(root2, argument, version, file, out));
|
|
192703
|
+
return;
|
|
192704
|
+
}
|
|
191164
192705
|
if (command === "styles" && (subcommand === "create" || subcommand === "check")) {
|
|
191165
192706
|
const allowed = new Set(subcommand === "create" ? ["dir", "name"] : ["dir"]);
|
|
191166
192707
|
if (args.positional.length !== 3 || Object.keys(args.flags).some((flag2) => !allowed.has(flag2))) {
|
|
@@ -191229,7 +192770,7 @@ async function main() {
|
|
|
191229
192770
|
if (!/^[a-zA-Z0-9_-]{1,100}$/.test(result2.id) || typeof result2.apiKey !== "string") throw new Error("Invalid key response");
|
|
191230
192771
|
const file = `keys/${result2.id}.json`;
|
|
191231
192772
|
await atomicWrite(root2, file, stableJson({ url: client.url, apiKey: result2.apiKey, id: result2.id, label, role }), { document: false, mode: 384, overwrite: false });
|
|
191232
|
-
output({ id: result2.id, label, role, credentialFile:
|
|
192773
|
+
output({ id: result2.id, label, role, credentialFile: join15(root2, file) });
|
|
191233
192774
|
return;
|
|
191234
192775
|
}
|
|
191235
192776
|
if (subcommand === "revoke" && argument) {
|
|
@@ -191360,7 +192901,7 @@ async function main() {
|
|
|
191360
192901
|
}
|
|
191361
192902
|
if (subcommand === "upload" && argument) {
|
|
191362
192903
|
const target = resolve12(str(args, "dir") ?? process.cwd(), argument);
|
|
191363
|
-
const handle = await
|
|
192904
|
+
const handle = await open12(target, constants11.O_RDONLY | constants11.O_NOFOLLOW);
|
|
191364
192905
|
let bytes;
|
|
191365
192906
|
try {
|
|
191366
192907
|
const info = await handle.stat();
|
|
@@ -191387,7 +192928,7 @@ async function main() {
|
|
|
191387
192928
|
if (subcommand === "download" && argument && str(args, "out")) {
|
|
191388
192929
|
if (!/^[a-f0-9]{64}$/.test(argument)) throw new Error("Asset ID must be its SHA-256");
|
|
191389
192930
|
const destination = resolve12(str(args, "dir") ?? process.cwd(), str(args, "out"));
|
|
191390
|
-
const root2 = await ensureRoot(
|
|
192931
|
+
const root2 = await ensureRoot(dirname18(destination), true);
|
|
191391
192932
|
await checkedPath(root2, basename4(destination), false);
|
|
191392
192933
|
const response = await client.media(`/v1/assets/${argument}`);
|
|
191393
192934
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
@@ -191448,7 +192989,7 @@ async function main() {
|
|
|
191448
192989
|
if (command === "search" && subcommand === "brief") {
|
|
191449
192990
|
const path = str(args, "file");
|
|
191450
192991
|
if (!path) throw new Error("Provide --file with the editorial brief JSON after inspecting the actual material.");
|
|
191451
|
-
const handle = await
|
|
192992
|
+
const handle = await open12(resolve12(path), constants11.O_RDONLY | constants11.O_NOFOLLOW);
|
|
191452
192993
|
let brief;
|
|
191453
192994
|
try {
|
|
191454
192995
|
const stat = await handle.stat();
|
|
@@ -191470,7 +193011,7 @@ async function main() {
|
|
|
191470
193011
|
const scriptPath = str(args, "script"), videoPath = str(args, "video");
|
|
191471
193012
|
let script, assetId = str(args, "asset");
|
|
191472
193013
|
const readInput = async (path, max) => {
|
|
191473
|
-
const handle = await
|
|
193014
|
+
const handle = await open12(resolve12(path), constants11.O_RDONLY | constants11.O_NOFOLLOW);
|
|
191474
193015
|
try {
|
|
191475
193016
|
const stat = await handle.stat();
|
|
191476
193017
|
if (!stat.isFile() || stat.size < 1 || stat.size > max) throw new Error(`Input must be a regular file of at most ${max} bytes.`);
|
|
@@ -191537,7 +193078,7 @@ async function main() {
|
|
|
191537
193078
|
const hash6 = str(args, "sha256");
|
|
191538
193079
|
if (!hash6 || !/^[a-f0-9]{64}$/.test(hash6)) throw new Error("--sha256 must be a media SHA-256 from library get.");
|
|
191539
193080
|
const destination = resolve12(str(args, "dir") ?? process.cwd(), str(args, "out"));
|
|
191540
|
-
const root2 = await ensureRoot(
|
|
193081
|
+
const root2 = await ensureRoot(dirname18(destination), true);
|
|
191541
193082
|
await checkedPath(root2, basename4(destination), false);
|
|
191542
193083
|
const response = await client.media(`/v1/library/${encodeURIComponent(argument)}/media/${hash6}`);
|
|
191543
193084
|
const reader = response.body?.getReader();
|