hyperframes 0.8.92 → 0.8.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-GCLS5XT7.js → add-62EBF76L.js} +15 -15
- package/dist/{animatedGifPrep-VMFM2PBA.js → animatedGifPrep-ZAXAJRGY.js} +5 -5
- package/dist/{asset-NFBCQ2QB.js → asset-26GEJ6MG.js} +2 -2
- package/dist/{assetCataloger-27YXPNX2.js → assetCataloger-L6BH5XPE.js} +2 -2
- package/dist/{auth-J6MHERMA.js → auth-Y5LOEYIG.js} +2 -2
- package/dist/{autoUpdate-D7RMTMHF.js → autoUpdate-BK3SAE2C.js} +2 -2
- package/dist/{backgroundChecks-ZUXDCYTJ.js → backgroundChecks-5OBL2ZFK.js} +3 -3
- package/dist/backgroundChecksWorker.js +3 -3
- package/dist/{batchRender-DCN2X35X.js → batchRender-P4PGKXMA.js} +3 -3
- package/dist/{beats-5FEJVZZY.js → beats-YAQFEASD.js} +9 -9
- package/dist/{benchmark-ZBDA5GFV.js → benchmark-ELQ43VMY.js} +11 -11
- package/dist/{browser-EAGFAPYB.js → browser-OVLDQCYN.js} +8 -8
- package/dist/{bundleWithLocalizedFonts-W7JJ23TN.js → bundleWithLocalizedFonts-TCS5G3P4.js} +2 -2
- package/dist/{capture-W5XUURVP.js → capture-AA2Z6KXD.js} +2 -2
- package/dist/{capture-27ZCA6CP.js → capture-OIO7KTM3.js} +6 -6
- package/dist/{catalog-SPPSMRB5.js → catalog-42G25U73.js} +15 -15
- package/dist/{check-NV3OKYHO.js → check-BJDE5KAL.js} +29 -29
- package/dist/{checkBrowser-KL4V257E.js → checkBrowser-355KCC5L.js} +28 -28
- package/dist/{chunk-2RWYPLRR.js → chunk-256DRQ3G.js} +2 -2
- package/dist/{chunk-O63VBAED.js → chunk-4VJUZHDP.js} +1 -1
- package/dist/{chunk-J7PWGYI3.js → chunk-54NKSH22.js} +3 -3
- package/dist/{chunk-TXN5R33Q.js → chunk-6MNV6MGA.js} +2 -2
- package/dist/{chunk-UURZ5VB2.js → chunk-7UNOH4HC.js} +1 -1
- package/dist/{chunk-MCR5L5H5.js → chunk-7V4CFEKO.js} +1 -1
- package/dist/{chunk-ENV2LB4E.js → chunk-BJMUZGSS.js} +3 -3
- package/dist/{chunk-GXIHEX7Z.js → chunk-COZAH66K.js} +1 -1
- package/dist/{chunk-TDMX5OUY.js → chunk-CQJVNJVO.js} +1 -1
- package/dist/{chunk-Z44U3GMN.js → chunk-CSXBOTPK.js} +1 -1
- package/dist/{chunk-XGVMRQ6N.js → chunk-DSMBTQNW.js} +8 -8
- package/dist/{chunk-ZOF426FA.js → chunk-EBYT5IKJ.js} +1 -1
- package/dist/{chunk-BMQLA6GZ.js → chunk-GRUP33MY.js} +17 -7
- package/dist/{chunk-WRN74OOR.js → chunk-HIUTUAE2.js} +1 -1
- package/dist/{chunk-AIW6VOK6.js → chunk-IGI5Q2AI.js} +3 -3
- package/dist/{chunk-QOJZKPIC.js → chunk-IYECLKKI.js} +4 -4
- package/dist/{chunk-DU2IMZTI.js → chunk-JG3OS5WP.js} +2 -2
- package/dist/{chunk-2E4WZU4S.js → chunk-JGC7NA6X.js} +2 -2
- package/dist/{chunk-DKTP377I.js → chunk-JMDM3WIJ.js} +1 -1
- package/dist/{chunk-YB7OWCJ7.js → chunk-KM5QZ2IJ.js} +1 -1
- package/dist/{chunk-R7RHFXEK.js → chunk-KP5DXFFF.js} +1 -1
- package/dist/{chunk-JYEIGPLH.js → chunk-LWTFVWUB.js} +4 -4
- package/dist/{chunk-SVQIWXWC.js → chunk-MKUHSQ5W.js} +2 -2
- package/dist/{chunk-7AGI2TLZ.js → chunk-NG236JIF.js} +2 -2
- package/dist/{chunk-2A6FVDIZ.js → chunk-NMMNZRS2.js} +1 -1
- package/dist/{chunk-SSAULSQM.js → chunk-OF66WGOC.js} +8 -8
- package/dist/{chunk-E3UXLITA.js → chunk-OULCKWLN.js} +1 -1
- package/dist/{chunk-RZC26MUU.js → chunk-OZMDUHEE.js} +1 -1
- package/dist/{chunk-NZVRTDVW.js → chunk-PGIJDSBF.js} +1 -1
- package/dist/{chunk-WBASC4GU.js → chunk-QEK5OWWB.js} +2 -2
- package/dist/{chunk-LNYBSC5Z.js → chunk-QKKGOE4B.js} +485 -82
- package/dist/{chunk-NRAXUJQS.js → chunk-QOA4O3E7.js} +2 -2
- package/dist/{chunk-FWLRQHMF.js → chunk-QTOATVZN.js} +1 -1
- package/dist/{chunk-JZP473HH.js → chunk-RAVVSXOF.js} +8 -8
- package/dist/{chunk-NRQLS4HO.js → chunk-TYR5PE7M.js} +4 -4
- package/dist/{chunk-QVOBDLUO.js → chunk-UEBEC2XU.js} +3 -3
- package/dist/{chunk-FLGA3ZUU.js → chunk-UJC2WHB4.js} +5 -5
- package/dist/{chunk-RP6O7QFB.js → chunk-UYRUCTKC.js} +6 -6
- package/dist/{chunk-CU2N7HZD.js → chunk-V4WFRE3S.js} +1 -1
- package/dist/{chunk-MWVZQN2E.js → chunk-XLYKUO64.js} +1 -1
- package/dist/chunk-ZEBQBMB2.js +3528 -0
- package/dist/{chunk-6WIXZ3HB.js → chunk-ZZDVDZMP.js} +2 -2
- package/dist/{clean-CKYQK575.js → clean-IDCWBLNM.js} +13 -13
- package/dist/cli.js +50 -50
- package/dist/{cloud-HRH5HUBL.js → cloud-WW7IHWVK.js} +4 -4
- package/dist/{cloudrun-HSHBRCS4.js → cloudrun-CBZJGN2M.js} +3 -3
- package/dist/{compare-45VBPJBR.js → compare-QO7KUZMU.js} +23 -23
- package/dist/{compiler-HBDJ2FCK.js → compiler-MTLZBZNF.js} +2 -2
- package/dist/{component-IOAEAQSN.js → component-WUUUYLLD.js} +3 -3
- package/dist/{compositions-VECXWCML.js → compositions-ZFX75QCU.js} +10 -10
- package/dist/{delete-ESBMF3XA.js → delete-G3X5E7AE.js} +2 -2
- package/dist/{dist-COKVABAK.js → dist-U6VLQ542.js} +2 -2
- package/dist/{doctor-AGIH65QA.js → doctor-WMEVLW45.js} +9 -9
- package/dist/{events-EAINIMXE.js → events-7XIEDY3M.js} +8 -8
- package/dist/{events-INGDO67S.js → events-LB3B73XE.js} +7 -7
- package/dist/{feedback-XISLH3UL.js → feedback-DEJGD4OP.js} +9 -9
- package/dist/{figma-O36BE6S7.js → figma-3RKMKXLM.js} +3 -3
- package/dist/fontLocalizeCli.js +7 -7
- package/dist/{get-2TBRXWDH.js → get-IYQXQUHU.js} +2 -2
- package/dist/{gpuPolicy-FDXLHK7O.js → gpuPolicy-FNQJDYAE.js} +5 -5
- package/dist/{grade-compare-3AH3U2UM.js → grade-compare-MN4QOS4A.js} +23 -23
- package/dist/{help-AQHVWZ7U.js → help-PCL4OHUN.js} +1 -1
- package/dist/{history-YUY6U7VJ.js → history-BD74GY4E.js} +13 -13
- package/dist/hyperframe-runtime.js +147 -82
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +147 -82
- package/dist/hyperframes-player.global.js +3 -3
- package/dist/{info-CG74OV3N.js → info-TUITY3LM.js} +10 -10
- package/dist/{init-BSRRUJTN.js → init-3IBL3CDR.js} +20 -20
- package/dist/{inspect-T6XSKC5K.js → inspect-AITRWOGY.js} +24 -24
- package/dist/{installer-EGIOS5UQ.js → installer-BICT5ISF.js} +5 -5
- package/dist/{keyframes-HBASU3QG.js → keyframes-API74S5F.js} +11 -11
- package/dist/{lambda-64LK5VBR.js → lambda-ATYZYY2A.js} +4 -4
- package/dist/{layout-QVKBBOF5.js → layout-L2IKLR7Y.js} +24 -24
- package/dist/{lint-GQPGCGYW.js → lint-47JJJTGD.js} +11 -11
- package/dist/{list-MFG3CWUG.js → list-3AVTRIB5.js} +2 -2
- package/dist/{login-UY5HMZ63.js → login-GZ3XQXJI.js} +4 -4
- package/dist/{media-treatment-PLRQ4NJB.js → media-treatment-OOIOWYDR.js} +11 -11
- package/dist/{models-VK3NR4ZI.js → models-GP4GUVD4.js} +6 -6
- package/dist/{motionShot-VNNW6WV6.js → motionShot-HGTAANSQ.js} +9 -9
- package/dist/{normalize-audio-LWC5EDG4.js → normalize-audio-DXOWIRK6.js} +9 -9
- package/dist/{pipeline-S24AZTNK.js → pipeline-EE4ONAMG.js} +5 -5
- package/dist/{play-WOGMI4FU.js → play-RZ4IA4XX.js} +19 -19
- package/dist/{preflight-O7TG2WSZ.js → preflight-IESLP2FD.js} +6 -6
- package/dist/{present-NK4CEHVO.js → present-VZRBWL5Y.js} +14 -14
- package/dist/{preview-6IFZAPIL.js → preview-YAQYBXZA.js} +17 -17
- package/dist/{producer-ULL2HNOC.js → producer-L6G3DQ3D.js} +1 -1
- package/dist/{projectConfig-6DIB7H7E.js → projectConfig-LKYZ2W5I.js} +7 -7
- package/dist/{publication-OAGIQJHU.js → publication-33HZULNX.js} +3 -3
- package/dist/{publish-XRUKN32V.js → publish-ZT4QTUT7.js} +8 -8
- package/dist/{remove-background-P2W275SH.js → remove-background-K53GPG52.js} +6 -6
- package/dist/{render-APAOFW2G.js → render-ABIQLIO4.js} +3 -3
- package/dist/{render-BQ55H4P5.js → render-RFYJ6BR3.js} +21 -21
- package/dist/{render-W5KZWLFB.js → render-ZCAAV67S.js} +11 -11
- package/dist/{render-batch-WPWPY5UA.js → render-batch-LCQ2IMTQ.js} +3 -3
- package/dist/{renderCancellation-LN37WZR4.js → renderCancellation-MJ2IXXMV.js} +5 -5
- package/dist/{resolver-DMRC6NBN.js → resolver-D7A53DNH.js} +5 -5
- package/dist/{sherpa-7DHFDVXD.js → sherpa-EUE27RMH.js} +6 -6
- package/dist/{skills-P42VIJ2S.js → skills-7NEK5F7M.js} +10 -10
- package/dist/{skillsUpdateCheck-MV4HDYO7.js → skillsUpdateCheck-AK52M6EY.js} +3 -3
- package/dist/{snapshot-OFUU3SMV.js → snapshot-F2GZGCNT.js} +24 -24
- package/dist/{src-YUWEFLV4.js → src-BVCQQJNL.js} +6 -6
- package/dist/{src-6CP5D2JF.js → src-HFIQQZG4.js} +4 -4
- package/dist/{staticProjectServer-FPLN4VJQ.js → staticProjectServer-R3ENYAFY.js} +13 -13
- package/dist/{status-Z3CRKR35.js → status-YCTO72L6.js} +5 -5
- package/dist/studio/assets/{hyperframes-player-DKJPDHUp.js → hyperframes-player-Bkm-3G56.js} +3 -3
- package/dist/studio/assets/{index-DpzpqJ_j.js → index-BUn5H_np.js} +1 -1
- package/dist/studio/assets/{index-C5_j5-3u.js → index-BupvpoiM.js} +188 -188
- package/dist/studio/assets/{index-CHZ4kFWm.js → index-n2ZRiO44.js} +1 -1
- package/dist/studio/index.d.ts +62 -46
- package/dist/studio/index.html +1 -1
- package/dist/studio/index.js +156 -102
- package/dist/studio/index.js.map +1 -1
- package/dist/{studio-api-4FHIU7WA.js → studio-api-LKMMVAVG.js} +6 -6
- package/dist/{studioServer-PIPRPNH2.js → studioServer-HZKH5BK2.js} +36 -36
- package/dist/{system-47NPBMGC.js → system-TRDN5G42.js} +5 -5
- package/dist/{telemetry-AH7RMCZ5.js → telemetry-4V6CYSZO.js} +8 -8
- package/dist/{timeline-E7QT5JZZ.js → timeline-LZG2X3LW.js} +13 -13
- package/dist/{tokens-OJWP37XP.js → tokens-PJQNUFTP.js} +2 -2
- package/dist/{transcribe-ZUVU222E.js → transcribe-7S6MKV72.js} +11 -11
- package/dist/{transcribe-AZ3MXBCY.js → transcribe-FYRFP3L5.js} +6 -6
- package/dist/{updateCheck-B57VMFQ3.js → updateCheck-YIDLZWHO.js} +2 -2
- package/dist/{upgrade-P67KFD64.js → upgrade-KNEDIALO.js} +2 -2
- package/dist/{urlDownloader-3LDWI4UF.js → urlDownloader-3DYGACLB.js} +4 -4
- package/dist/{validate-I7W4ERNH.js → validate-G7FIJEEO.js} +14 -14
- package/dist/{video-X4WQOX3E.js → video-7MDJ2CIG.js} +5 -5
- package/package.json +1 -1
- package/dist/chunk-WNYPPH3Y.js +0 -3528
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
shouldClampResolvedMediaDuration,
|
|
24
24
|
stripEmbeddedRuntimeScripts,
|
|
25
25
|
warnUnknownEnumValues
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ZEBQBMB2.js";
|
|
27
27
|
import {
|
|
28
28
|
cssVariableName
|
|
29
29
|
} from "./chunk-VC76R6W2.js";
|
|
@@ -317,6 +317,122 @@ import { transformSync } from "esbuild";
|
|
|
317
317
|
|
|
318
318
|
// ../core/dist/compiler/compositionScoping.js
|
|
319
319
|
import postcss from "postcss";
|
|
320
|
+
|
|
321
|
+
// ../core/dist/compiler/selectorIdTokens.js
|
|
322
|
+
function isNameChar(char) {
|
|
323
|
+
if (!char)
|
|
324
|
+
return false;
|
|
325
|
+
return /[\w-]/.test(char) || char.charCodeAt(0) >= 128;
|
|
326
|
+
}
|
|
327
|
+
function isCssWhitespace(char) {
|
|
328
|
+
return char === " " || char === " " || char === "\n" || char === "\r" || char === "\f";
|
|
329
|
+
}
|
|
330
|
+
var HEX_ESCAPE_RE = /^[0-9a-fA-F]{1,6}/;
|
|
331
|
+
function sanitizeCodePoint(codePoint) {
|
|
332
|
+
const isSurrogate = codePoint >= 55296 && codePoint <= 57343;
|
|
333
|
+
return codePoint === 0 || codePoint > 1114111 || isSurrogate ? 65533 : codePoint;
|
|
334
|
+
}
|
|
335
|
+
function skipEscapeWhitespace(text, index) {
|
|
336
|
+
if (text[index] === "\r" && text[index + 1] === "\n")
|
|
337
|
+
return index + 2;
|
|
338
|
+
return isCssWhitespace(text[index]) ? index + 1 : index;
|
|
339
|
+
}
|
|
340
|
+
function consumeCssEscape(text, index) {
|
|
341
|
+
const next = text[index + 1];
|
|
342
|
+
if (next === void 0 || next === "\n")
|
|
343
|
+
return null;
|
|
344
|
+
const hex = HEX_ESCAPE_RE.exec(text.slice(index + 1, index + 7));
|
|
345
|
+
if (!hex)
|
|
346
|
+
return { value: next, end: index + 2 };
|
|
347
|
+
const codePoint = sanitizeCodePoint(Number.parseInt(hex[0], 16));
|
|
348
|
+
return {
|
|
349
|
+
value: String.fromCodePoint(codePoint),
|
|
350
|
+
end: skipEscapeWhitespace(text, index + 1 + hex[0].length)
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function decodeCssIdentifierAt(text, start) {
|
|
354
|
+
let index = start;
|
|
355
|
+
let value = "";
|
|
356
|
+
while (index < text.length) {
|
|
357
|
+
const char = text[index];
|
|
358
|
+
if (char === "\\") {
|
|
359
|
+
const escape = consumeCssEscape(text, index);
|
|
360
|
+
if (!escape)
|
|
361
|
+
break;
|
|
362
|
+
value += escape.value;
|
|
363
|
+
index = escape.end;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (!isNameChar(char))
|
|
367
|
+
break;
|
|
368
|
+
value += char;
|
|
369
|
+
index += 1;
|
|
370
|
+
}
|
|
371
|
+
return index === start ? null : { value, end: index };
|
|
372
|
+
}
|
|
373
|
+
var CODE_UNIT_HYPHEN = 45;
|
|
374
|
+
function isDigitCodeUnit(codeUnit) {
|
|
375
|
+
return codeUnit >= 48 && codeUnit <= 57;
|
|
376
|
+
}
|
|
377
|
+
function isPlainNameCodeUnit(codeUnit) {
|
|
378
|
+
return codeUnit >= 128 || codeUnit === CODE_UNIT_HYPHEN || codeUnit === 95 || isDigitCodeUnit(codeUnit) || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122;
|
|
379
|
+
}
|
|
380
|
+
function needsHexEscape(value, index) {
|
|
381
|
+
const codeUnit = value.charCodeAt(index);
|
|
382
|
+
if (codeUnit >= 1 && codeUnit <= 31 || codeUnit === 127)
|
|
383
|
+
return true;
|
|
384
|
+
if (!isDigitCodeUnit(codeUnit))
|
|
385
|
+
return false;
|
|
386
|
+
return index === 0 || index === 1 && value.charCodeAt(0) === CODE_UNIT_HYPHEN;
|
|
387
|
+
}
|
|
388
|
+
function escapeCssIdentifier(value) {
|
|
389
|
+
let result = "";
|
|
390
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
391
|
+
const codeUnit = value.charCodeAt(index);
|
|
392
|
+
const char = value[index];
|
|
393
|
+
if (codeUnit === 0)
|
|
394
|
+
result += "\uFFFD";
|
|
395
|
+
else if (needsHexEscape(value, index))
|
|
396
|
+
result += `\\${codeUnit.toString(16)} `;
|
|
397
|
+
else if (index === 0 && value.length === 1 && codeUnit === CODE_UNIT_HYPHEN)
|
|
398
|
+
result += `\\${char}`;
|
|
399
|
+
else if (isPlainNameCodeUnit(codeUnit))
|
|
400
|
+
result += char;
|
|
401
|
+
else
|
|
402
|
+
result += `\\${char}`;
|
|
403
|
+
}
|
|
404
|
+
return result;
|
|
405
|
+
}
|
|
406
|
+
var GUARDED_SELECTOR_SEGMENT_RE = /\\(?:[0-9a-fA-F]{1,6}(?:\r\n|[ \t\r\n\f])?|[\s\S])|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\[(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^\]"'])*\]/g;
|
|
407
|
+
function markUnguardedOffsets(selector) {
|
|
408
|
+
const mask = new Array(selector.length).fill(true);
|
|
409
|
+
for (const match of selector.matchAll(GUARDED_SELECTOR_SEGMENT_RE)) {
|
|
410
|
+
const start = match.index;
|
|
411
|
+
mask.fill(false, start, start + match[0].length);
|
|
412
|
+
}
|
|
413
|
+
return mask;
|
|
414
|
+
}
|
|
415
|
+
function replaceSelectorIdTokens(selector, candidateIds, resolveReplacement) {
|
|
416
|
+
if (candidateIds.length === 0 || !selector.includes("#"))
|
|
417
|
+
return selector;
|
|
418
|
+
const candidates = new Set(candidateIds);
|
|
419
|
+
const unguarded = markUnguardedOffsets(selector);
|
|
420
|
+
let result = "";
|
|
421
|
+
let index = 0;
|
|
422
|
+
while (index < selector.length) {
|
|
423
|
+
const token = unguarded[index] && selector[index] === "#" ? decodeCssIdentifierAt(selector, index + 1) : null;
|
|
424
|
+
if (token && candidates.has(token.value)) {
|
|
425
|
+
result += resolveReplacement(token.value);
|
|
426
|
+
index = token.end;
|
|
427
|
+
} else {
|
|
428
|
+
result += selector[index];
|
|
429
|
+
index += 1;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// ../core/dist/compiler/compositionScoping.js
|
|
320
436
|
var AUTHORED_ROOT_ID_ATTR = "data-hf-authored-id";
|
|
321
437
|
var INNER_ROOT_ATTR = "data-hf-inner-root";
|
|
322
438
|
function escapeRegExp(value) {
|
|
@@ -325,67 +441,15 @@ function escapeRegExp(value) {
|
|
|
325
441
|
function escapeCssAttributeValue(value) {
|
|
326
442
|
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
327
443
|
}
|
|
328
|
-
function escapeCssIdentifier(value) {
|
|
329
|
-
if (!value)
|
|
330
|
-
return value;
|
|
331
|
-
const escaped = value.replace(/[^a-zA-Z0-9_-]/g, (char) => `\\${char}`);
|
|
332
|
-
return escaped.replace(/^-?\d/, (match) => `\\${match}`);
|
|
333
|
-
}
|
|
334
444
|
function getAuthoredRootIdSelectorForms(authoredRootId) {
|
|
335
445
|
const trimmed = authoredRootId.trim();
|
|
336
446
|
if (!trimmed)
|
|
337
447
|
return [];
|
|
338
448
|
return Array.from(/* @__PURE__ */ new Set([trimmed, escapeCssIdentifier(trimmed)])).filter(Boolean);
|
|
339
449
|
}
|
|
340
|
-
function isSelectorNameChar(char) {
|
|
341
|
-
return !!char && /[\w-]/.test(char);
|
|
342
|
-
}
|
|
343
450
|
function replaceAuthoredRootIdSelectors(selector, authoredRootId, replacement) {
|
|
344
|
-
const forms = getAuthoredRootIdSelectorForms(authoredRootId)
|
|
345
|
-
|
|
346
|
-
return selector;
|
|
347
|
-
let result = "";
|
|
348
|
-
let bracketDepth = 0;
|
|
349
|
-
let quote = null;
|
|
350
|
-
for (let index = 0; index < selector.length; index += 1) {
|
|
351
|
-
const char = selector[index];
|
|
352
|
-
const previousChar = index > 0 ? selector[index - 1] : "";
|
|
353
|
-
if (quote) {
|
|
354
|
-
result += char;
|
|
355
|
-
if (char === quote && previousChar !== "\\") {
|
|
356
|
-
quote = null;
|
|
357
|
-
}
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
if (char === '"' || char === "'") {
|
|
361
|
-
quote = char;
|
|
362
|
-
result += char;
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
if (char === "[") {
|
|
366
|
-
bracketDepth += 1;
|
|
367
|
-
result += char;
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
if (char === "]") {
|
|
371
|
-
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
372
|
-
result += char;
|
|
373
|
-
continue;
|
|
374
|
-
}
|
|
375
|
-
if (char === "#" && bracketDepth === 0) {
|
|
376
|
-
const matchedForm = forms.find((form) => selector.startsWith(form, index + 1));
|
|
377
|
-
if (matchedForm) {
|
|
378
|
-
const nextChar = selector[index + 1 + matchedForm.length];
|
|
379
|
-
if (!isSelectorNameChar(nextChar)) {
|
|
380
|
-
result += replacement;
|
|
381
|
-
index += matchedForm.length;
|
|
382
|
-
continue;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
result += char;
|
|
387
|
-
}
|
|
388
|
-
return result;
|
|
451
|
+
const forms = getAuthoredRootIdSelectorForms(authoredRootId);
|
|
452
|
+
return replaceSelectorIdTokens(selector, forms, () => replacement);
|
|
389
453
|
}
|
|
390
454
|
function normalizeAuthoredRootIdSelector(selector, authoredRootId) {
|
|
391
455
|
const trimmed = authoredRootId?.trim();
|
|
@@ -532,6 +596,7 @@ function scopedModulePrelude(timelineCompositionId, compositionSrc) {
|
|
|
532
596
|
return `const __hyperframes = (function(__hfBaseHyperframes, __hfTimelineCompId, __hfCompositionSrc) {
|
|
533
597
|
return ${SCOPED_HYPERFRAMES_EXPRESSION};
|
|
534
598
|
})(window.__hyperframes, ${jsonScriptLiteral(timelineCompositionId)}, ${jsonScriptLiteral(compositionSrc?.trim() || null)});
|
|
599
|
+
${wrapScopedCompositionScript("", timelineCompositionId)}
|
|
535
600
|
`;
|
|
536
601
|
}
|
|
537
602
|
function wrapScopedCompositionScript(source, compositionId, errorLabel = "[HyperFrames] composition script error:", scopeSelectorOverride, timelineCompositionId = compositionId, authoredRootId, compositionSrc) {
|
|
@@ -543,7 +608,6 @@ function wrapScopedCompositionScript(source, compositionId, errorLabel = "[Hyper
|
|
|
543
608
|
const scopeSelectorLiteral = jsonScriptLiteral(scopeSelectorOverride ?? null);
|
|
544
609
|
const rootSelectorPatternLiteral = jsonScriptLiteral(String.raw`\[\s*data-composition-id\s*=\s*(?:"${escapedCompositionId}"|'${escapedCompositionId}')\s*\]`);
|
|
545
610
|
const timingSelectorPatternLiteral = jsonScriptLiteral(String.raw`\s*\[\s*data-(?:start|duration)\s*=\s*(?:"[^"]*"|'[^']*')\s*\]`);
|
|
546
|
-
const authoredRootIdFormsLiteral = jsonScriptLiteral(getAuthoredRootIdSelectorForms(authoredRootId?.trim() || ""));
|
|
547
611
|
return `(function(){
|
|
548
612
|
var __hfCompId = ${compositionIdLiteral};
|
|
549
613
|
var __hfTimelineCompId = ${timelineCompositionIdLiteral};
|
|
@@ -560,15 +624,19 @@ function wrapScopedCompositionScript(source, compositionId, errorLabel = "[Hyper
|
|
|
560
624
|
var __hfRoot = null;
|
|
561
625
|
var __hfRootSelectorPattern = ${rootSelectorPatternLiteral};
|
|
562
626
|
var __hfTimingSelectorPattern = ${timingSelectorPatternLiteral};
|
|
563
|
-
var __hfAuthoredRootIdForms = ${authoredRootIdFormsLiteral};
|
|
564
627
|
var __hfAuthoredRootSelector = __hfAuthoredRootId
|
|
565
628
|
? "[" + __hfAuthoredRootAttr + '="' + __hfEscapeAttr(__hfAuthoredRootId) + '"]'
|
|
566
629
|
: "";
|
|
567
|
-
var
|
|
568
|
-
|
|
630
|
+
var __hfCssEscape = function(value) {
|
|
631
|
+
var text = value + "";
|
|
632
|
+
if (typeof CSS !== "undefined" && CSS && typeof CSS.escape === "function") {
|
|
633
|
+
try { return CSS.escape(text); } catch {}
|
|
634
|
+
}
|
|
635
|
+
return text.replace(/[^a-zA-Z0-9_-]/g, function(char) { return "\\\\" + char; });
|
|
569
636
|
};
|
|
570
|
-
|
|
571
|
-
|
|
637
|
+
// Decode complete CSS identifiers before comparing authored ids.
|
|
638
|
+
var __hfRewriteIdSelectors = function(selector, entries) {
|
|
639
|
+
if (!entries || !entries.length || typeof selector !== "string" || selector.indexOf("#") === -1) {
|
|
572
640
|
return selector;
|
|
573
641
|
}
|
|
574
642
|
var result = "";
|
|
@@ -576,10 +644,17 @@ function wrapScopedCompositionScript(source, compositionId, errorLabel = "[Hyper
|
|
|
576
644
|
var quote = null;
|
|
577
645
|
for (var index = 0; index < selector.length; index += 1) {
|
|
578
646
|
var char = selector[index];
|
|
579
|
-
|
|
647
|
+
if (char === "\\\\") {
|
|
648
|
+
var escape = selector.slice(index).match(/^\\\\(?:[0-9a-fA-F]{1,6}(?:\\r\\n|[ \\t\\r\\n\\f])?|[\\s\\S])/);
|
|
649
|
+
if (escape) {
|
|
650
|
+
result += escape[0];
|
|
651
|
+
index += escape[0].length - 1;
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
580
655
|
if (quote) {
|
|
581
656
|
result += char;
|
|
582
|
-
if (char === quote
|
|
657
|
+
if (char === quote) {
|
|
583
658
|
quote = null;
|
|
584
659
|
}
|
|
585
660
|
continue;
|
|
@@ -600,36 +675,83 @@ function wrapScopedCompositionScript(source, compositionId, errorLabel = "[Hyper
|
|
|
600
675
|
continue;
|
|
601
676
|
}
|
|
602
677
|
if (char === "#" && bracketDepth === 0) {
|
|
603
|
-
var
|
|
604
|
-
|
|
605
|
-
var
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
result += __hfAuthoredRootSelector;
|
|
615
|
-
index += matchedForm.length;
|
|
616
|
-
continue;
|
|
617
|
-
}
|
|
678
|
+
var token = selector.slice(index + 1).match(/^(?:[\\w\\u0080-\\uffff-]|\\\\(?:[0-9a-fA-F]{1,6}(?:\\r\\n|[ \\t\\r\\n\\f])?|[^\\r\\n\\f]))+/);
|
|
679
|
+
if (token) {
|
|
680
|
+
var decoded = token[0].replace(/\\\\([0-9a-fA-F]{1,6})(?:\\r\\n|[ \\t\\r\\n\\f])?|\\\\([^\\r\\n\\f])/g, function(_, hex, escaped) {
|
|
681
|
+
if (!hex) return escaped;
|
|
682
|
+
var code = parseInt(hex, 16);
|
|
683
|
+
return String.fromCodePoint(!code || code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff) ? 0xfffd : code);
|
|
684
|
+
});
|
|
685
|
+
var matched = entries.find(function(entry) { return entry.id === decoded; });
|
|
686
|
+
result += matched ? matched.replacement : "#" + token[0];
|
|
687
|
+
index += token[0].length;
|
|
688
|
+
continue;
|
|
618
689
|
}
|
|
619
690
|
}
|
|
620
691
|
result += char;
|
|
621
692
|
}
|
|
622
693
|
return result;
|
|
623
694
|
};
|
|
695
|
+
var __hfAuthoredRootEntries = __hfAuthoredRootSelector
|
|
696
|
+
? [{ id: __hfAuthoredRootId, replacement: __hfAuthoredRootSelector }]
|
|
697
|
+
: [];
|
|
698
|
+
// Include both renamed and untouched instances. Each wrapper refreshes this
|
|
699
|
+
// document-wide cache because preview scene swaps can introduce new ids.
|
|
700
|
+
var __hfRenamedIdEntries = function() {
|
|
701
|
+
if (window.__hfRenamedIdSelectorEntries) return window.__hfRenamedIdSelectorEntries;
|
|
702
|
+
var entries = [];
|
|
703
|
+
var seen = Object.create(null);
|
|
704
|
+
var nodes;
|
|
705
|
+
try {
|
|
706
|
+
nodes = window.document.querySelectorAll("[" + __hfAuthoredRootAttr + "][id]");
|
|
707
|
+
} catch {
|
|
708
|
+
nodes = [];
|
|
709
|
+
}
|
|
710
|
+
for (var i = 0; i < nodes.length; i += 1) {
|
|
711
|
+
var authored = nodes[i].getAttribute(__hfAuthoredRootAttr);
|
|
712
|
+
if (!authored || seen[authored] || authored === nodes[i].id) continue;
|
|
713
|
+
seen[authored] = true;
|
|
714
|
+
var escaped = __hfCssEscape(authored);
|
|
715
|
+
entries.push({
|
|
716
|
+
id: authored,
|
|
717
|
+
replacement: ":is(#" + escaped + ", [" + __hfAuthoredRootAttr + '="' + __hfEscapeAttr(authored) + '"])',
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
window.__hfRenamedIdSelectorEntries = entries;
|
|
721
|
+
return window.__hfRenamedIdSelectorEntries;
|
|
722
|
+
};
|
|
723
|
+
// element.querySelector("#authored") on an arbitrary Element never passes
|
|
724
|
+
// through the scoped document proxy, so the same rewrite is installed once
|
|
725
|
+
// per document on Element.prototype \u2014 only when at least one id was
|
|
726
|
+
// actually renamed, so a document without collisions runs untouched
|
|
727
|
+
// natives. Document.prototype is deliberately NOT patched: an unscoped
|
|
728
|
+
// document-wide lookup cannot know which instance it means, and rewriting
|
|
729
|
+
// it would only widen the ambiguity.
|
|
730
|
+
var __hfInstallRenamedIdSelectorShim = function() {
|
|
731
|
+
if (window.__hfRenamedIdSelectorShim) return;
|
|
732
|
+
var entries = __hfRenamedIdEntries();
|
|
733
|
+
if (!entries.length) return;
|
|
734
|
+
var proto = window.Element && window.Element.prototype;
|
|
735
|
+
if (!proto || typeof proto.querySelector !== "function" || typeof proto.querySelectorAll !== "function") {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
var nativeQuerySelector = proto.querySelector;
|
|
739
|
+
var nativeQuerySelectorAll = proto.querySelectorAll;
|
|
740
|
+
proto.querySelector = function(selector) {
|
|
741
|
+
return nativeQuerySelector.call(this, __hfRewriteIdSelectors(selector, __hfRenamedIdEntries()));
|
|
742
|
+
};
|
|
743
|
+
proto.querySelectorAll = function(selector) {
|
|
744
|
+
return nativeQuerySelectorAll.call(this, __hfRewriteIdSelectors(selector, __hfRenamedIdEntries()));
|
|
745
|
+
};
|
|
746
|
+
window.__hfRenamedIdSelectorShim = true;
|
|
747
|
+
};
|
|
624
748
|
var __hfNormalizeSelector = function(selector) {
|
|
625
749
|
if (!__hfCompId || typeof selector !== "string") return selector;
|
|
626
750
|
var normalized = selector
|
|
627
751
|
.replace(new RegExp(__hfRootSelectorPattern + '(?:' + __hfTimingSelectorPattern + ')+', 'g'), __hfRootSelector)
|
|
628
752
|
.replace(new RegExp('(?:' + __hfTimingSelectorPattern + ')+' + __hfRootSelectorPattern, 'g'), __hfRootSelector);
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}
|
|
632
|
-
return normalized;
|
|
753
|
+
normalized = __hfRewriteIdSelectors(normalized, __hfAuthoredRootEntries);
|
|
754
|
+
return __hfRewriteIdSelectors(normalized, __hfRenamedIdEntries());
|
|
633
755
|
};
|
|
634
756
|
var __hfFindRoot = function() {
|
|
635
757
|
if (!__hfRoot && __hfRootSelector) {
|
|
@@ -779,6 +901,7 @@ function wrapScopedCompositionScript(source, compositionId, errorLabel = "[Hyper
|
|
|
779
901
|
resolved.push(item);
|
|
780
902
|
return resolved;
|
|
781
903
|
}, []);
|
|
904
|
+
|
|
782
905
|
};
|
|
783
906
|
var __hfScopeTimeline = function(timeline) {
|
|
784
907
|
if (!timeline || timeline.__hfScopedCompositionRoot === __hfFindRoot()) return timeline;
|
|
@@ -891,6 +1014,8 @@ ${source.replace(/<\/(script)/gi, "<\\/$1")}
|
|
|
891
1014
|
});
|
|
892
1015
|
};
|
|
893
1016
|
__hfFindRoot();
|
|
1017
|
+
window.__hfRenamedIdSelectorEntries = null;
|
|
1018
|
+
__hfInstallRenamedIdSelectorShim();
|
|
894
1019
|
__hfRecordAnimations(__hfRun);
|
|
895
1020
|
})();`;
|
|
896
1021
|
}
|
|
@@ -925,6 +1050,260 @@ async function validateHyperframeHtmlContract(html) {
|
|
|
925
1050
|
return { isValid: false, missingKeys, failureReason };
|
|
926
1051
|
}
|
|
927
1052
|
|
|
1053
|
+
// ../core/dist/compiler/svgIdNamespacing.js
|
|
1054
|
+
import postcss2 from "postcss";
|
|
1055
|
+
var ID_ATTR = "id";
|
|
1056
|
+
var SVG_AUTHORED_ID_ATTR = "data-hf-authored-id";
|
|
1057
|
+
var URL_HASH_REF_RE = /(url\(\s*)(["']?)#([^"')\s]+)\2(\s*\))/gi;
|
|
1058
|
+
function isHrefAttrName(name) {
|
|
1059
|
+
return name === "href" || name.endsWith(":href");
|
|
1060
|
+
}
|
|
1061
|
+
function sanitizeNamespaceSegment(value) {
|
|
1062
|
+
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
1063
|
+
}
|
|
1064
|
+
function rewriteUrlHashRefs(value, idMap) {
|
|
1065
|
+
if (!value || !value.toLowerCase().includes("url("))
|
|
1066
|
+
return value;
|
|
1067
|
+
return value.replace(URL_HASH_REF_RE, (full, pre, quote, id, post) => {
|
|
1068
|
+
const mapped = idMap.get(id);
|
|
1069
|
+
return mapped ? `${pre}${quote}#${mapped}${quote}${post}` : full;
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
function rewriteHrefValue(value, idMap) {
|
|
1073
|
+
if (!value.startsWith("#"))
|
|
1074
|
+
return null;
|
|
1075
|
+
const mapped = idMap.get(value.slice(1));
|
|
1076
|
+
return mapped ? `#${mapped}` : null;
|
|
1077
|
+
}
|
|
1078
|
+
function rewriteElementIdReferences(el, idMap) {
|
|
1079
|
+
const attrs = el.attributes ? Array.from(el.attributes) : [];
|
|
1080
|
+
for (const attr of attrs) {
|
|
1081
|
+
const { name, value } = attr;
|
|
1082
|
+
if (!value)
|
|
1083
|
+
continue;
|
|
1084
|
+
if (isHrefAttrName(name)) {
|
|
1085
|
+
const rewritten = rewriteHrefValue(value, idMap);
|
|
1086
|
+
if (rewritten) {
|
|
1087
|
+
el.setAttribute(name, rewritten);
|
|
1088
|
+
continue;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
if (value.toLowerCase().includes("url(")) {
|
|
1092
|
+
const rewritten = rewriteUrlHashRefs(value, idMap);
|
|
1093
|
+
if (rewritten !== value)
|
|
1094
|
+
el.setAttribute(name, rewritten);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
function collectUrlHashRefsFromText(text, filter, out) {
|
|
1099
|
+
let m;
|
|
1100
|
+
URL_HASH_REF_RE.lastIndex = 0;
|
|
1101
|
+
while (m = URL_HASH_REF_RE.exec(text)) {
|
|
1102
|
+
const refId = m[3];
|
|
1103
|
+
if (filter.has(refId))
|
|
1104
|
+
out.add(refId);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function collectHrefFragmentRef(attr, filter, out) {
|
|
1108
|
+
if (isHrefAttrName(attr.name) && attr.value.startsWith("#")) {
|
|
1109
|
+
const id = attr.value.slice(1);
|
|
1110
|
+
if (filter.has(id))
|
|
1111
|
+
out.add(id);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
function collectNativelyReferencedIds(elements, cssTexts, svgIds) {
|
|
1115
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1116
|
+
for (const el of elements) {
|
|
1117
|
+
for (const attr of el.attributes ? Array.from(el.attributes) : []) {
|
|
1118
|
+
if (!attr.value)
|
|
1119
|
+
continue;
|
|
1120
|
+
collectHrefFragmentRef(attr, svgIds, referenced);
|
|
1121
|
+
if (attr.value.toLowerCase().includes("url("))
|
|
1122
|
+
collectUrlHashRefsFromText(attr.value, svgIds, referenced);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
for (const text of cssTexts) {
|
|
1126
|
+
if (text.toLowerCase().includes("url("))
|
|
1127
|
+
collectUrlHashRefsFromText(text, svgIds, referenced);
|
|
1128
|
+
}
|
|
1129
|
+
return referenced;
|
|
1130
|
+
}
|
|
1131
|
+
function isExcluded(el, exclude) {
|
|
1132
|
+
return exclude.some((excluded) => excluded === el || excluded.contains(el));
|
|
1133
|
+
}
|
|
1134
|
+
function collectScopeElements(scope) {
|
|
1135
|
+
const exclude = scope.exclude ?? [];
|
|
1136
|
+
const descendants = [...scope.root.querySelectorAll("*")];
|
|
1137
|
+
const own = exclude.length ? descendants.filter((el) => !isExcluded(el, exclude)) : descendants;
|
|
1138
|
+
return [scope.root, ...own];
|
|
1139
|
+
}
|
|
1140
|
+
function collectSvgIdElements(scope) {
|
|
1141
|
+
const exclude = scope.exclude ?? [];
|
|
1142
|
+
const matches = [...scope.root.querySelectorAll("svg [id], svg[id]")];
|
|
1143
|
+
return exclude.length ? matches.filter((el) => !isExcluded(el, exclude)) : matches;
|
|
1144
|
+
}
|
|
1145
|
+
function resolveScope(scope) {
|
|
1146
|
+
const elements = collectScopeElements(scope);
|
|
1147
|
+
const renamable = /* @__PURE__ */ new Set();
|
|
1148
|
+
if (!scope.namespace)
|
|
1149
|
+
return { elements, renamable };
|
|
1150
|
+
const svgIdElements = collectSvgIdElements(scope);
|
|
1151
|
+
const svgIds = /* @__PURE__ */ new Set();
|
|
1152
|
+
for (const el of svgIdElements) {
|
|
1153
|
+
const id = el.getAttribute(ID_ATTR);
|
|
1154
|
+
if (id)
|
|
1155
|
+
svgIds.add(id);
|
|
1156
|
+
}
|
|
1157
|
+
if (svgIds.size === 0)
|
|
1158
|
+
return { elements, renamable };
|
|
1159
|
+
const nativelyReferenced = collectNativelyReferencedIds(elements, scope.cssTexts ?? [], svgIds);
|
|
1160
|
+
for (const el of svgIdElements) {
|
|
1161
|
+
const id = el.getAttribute(ID_ATTR);
|
|
1162
|
+
if (id && nativelyReferenced.has(id))
|
|
1163
|
+
renamable.add(el);
|
|
1164
|
+
}
|
|
1165
|
+
return { elements, renamable };
|
|
1166
|
+
}
|
|
1167
|
+
function buildIdCensus(document) {
|
|
1168
|
+
const elementsById = /* @__PURE__ */ new Map();
|
|
1169
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
1170
|
+
for (const el of document.querySelectorAll("[id]")) {
|
|
1171
|
+
const id = el.getAttribute(ID_ATTR);
|
|
1172
|
+
if (!id)
|
|
1173
|
+
continue;
|
|
1174
|
+
usedIds.add(id);
|
|
1175
|
+
const list = elementsById.get(id);
|
|
1176
|
+
if (list)
|
|
1177
|
+
list.push(el);
|
|
1178
|
+
else
|
|
1179
|
+
elementsById.set(id, [el]);
|
|
1180
|
+
}
|
|
1181
|
+
return { elementsById, usedIds };
|
|
1182
|
+
}
|
|
1183
|
+
function hasAnyCollision(census) {
|
|
1184
|
+
for (const elements of census.elementsById.values()) {
|
|
1185
|
+
if (elements.length > 1)
|
|
1186
|
+
return true;
|
|
1187
|
+
}
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
function mintNamespacedId(namespace, originalId, usedIds) {
|
|
1191
|
+
const base = `${sanitizeNamespaceSegment(namespace)}--${originalId}`;
|
|
1192
|
+
let candidate = base;
|
|
1193
|
+
for (let n = 2; usedIds.has(candidate); n += 1)
|
|
1194
|
+
candidate = `${base}-${n}`;
|
|
1195
|
+
usedIds.add(candidate);
|
|
1196
|
+
return candidate;
|
|
1197
|
+
}
|
|
1198
|
+
function planRenames(census, scopes, scopeIndexByRenamable) {
|
|
1199
|
+
const idMaps = scopes.map(() => /* @__PURE__ */ new Map());
|
|
1200
|
+
for (const [id, elements] of census.elementsById) {
|
|
1201
|
+
if (elements.length < 2)
|
|
1202
|
+
continue;
|
|
1203
|
+
const keeper = elements.find((el) => !scopeIndexByRenamable.has(el)) ?? elements[0];
|
|
1204
|
+
for (const el of elements) {
|
|
1205
|
+
if (el === keeper)
|
|
1206
|
+
continue;
|
|
1207
|
+
const scopeIndex = scopeIndexByRenamable.get(el);
|
|
1208
|
+
if (scopeIndex === void 0)
|
|
1209
|
+
continue;
|
|
1210
|
+
const idMap = idMaps[scopeIndex];
|
|
1211
|
+
if (!idMap.has(id)) {
|
|
1212
|
+
idMap.set(id, mintNamespacedId(scopes[scopeIndex].namespace, id, census.usedIds));
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
return idMaps;
|
|
1217
|
+
}
|
|
1218
|
+
function applyRenames(resolved, idMap) {
|
|
1219
|
+
for (const el of resolved.elements) {
|
|
1220
|
+
const currentId = el.getAttribute(ID_ATTR);
|
|
1221
|
+
if (currentId && resolved.renamable.has(el) && idMap.has(currentId)) {
|
|
1222
|
+
if (!el.hasAttribute(SVG_AUTHORED_ID_ATTR))
|
|
1223
|
+
el.setAttribute(SVG_AUTHORED_ID_ATTR, currentId);
|
|
1224
|
+
el.setAttribute(ID_ATTR, idMap.get(currentId));
|
|
1225
|
+
}
|
|
1226
|
+
rewriteElementIdReferences(el, idMap);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
function namespaceCollidingSvgIds(document, scopes) {
|
|
1230
|
+
const untouched = scopes.map(() => /* @__PURE__ */ new Map());
|
|
1231
|
+
if (scopes.length === 0)
|
|
1232
|
+
return untouched;
|
|
1233
|
+
const census = buildIdCensus(document);
|
|
1234
|
+
if (!hasAnyCollision(census))
|
|
1235
|
+
return untouched;
|
|
1236
|
+
const resolved = scopes.map(resolveScope);
|
|
1237
|
+
const scopeIndexByRenamable = /* @__PURE__ */ new Map();
|
|
1238
|
+
resolved.forEach(({ renamable }, index) => {
|
|
1239
|
+
for (const el of renamable)
|
|
1240
|
+
scopeIndexByRenamable.set(el, index);
|
|
1241
|
+
});
|
|
1242
|
+
if (scopeIndexByRenamable.size === 0)
|
|
1243
|
+
return untouched;
|
|
1244
|
+
const idMaps = planRenames(census, scopes, scopeIndexByRenamable);
|
|
1245
|
+
const referenceMaps = resolved.map((scope, index) => {
|
|
1246
|
+
const references = new Map(idMaps[index]);
|
|
1247
|
+
const localIds = new Set(scope.elements.map((el) => el.getAttribute(ID_ATTR)));
|
|
1248
|
+
for (const [id, elements] of census.elementsById) {
|
|
1249
|
+
if (localIds.has(id))
|
|
1250
|
+
continue;
|
|
1251
|
+
const targetScope = scopeIndexByRenamable.get(elements[0]);
|
|
1252
|
+
if (targetScope === void 0)
|
|
1253
|
+
continue;
|
|
1254
|
+
const mapped = idMaps[targetScope].get(id);
|
|
1255
|
+
if (mapped)
|
|
1256
|
+
references.set(id, mapped);
|
|
1257
|
+
}
|
|
1258
|
+
return references;
|
|
1259
|
+
});
|
|
1260
|
+
referenceMaps.forEach((idMap, index) => {
|
|
1261
|
+
if (idMap.size > 0)
|
|
1262
|
+
applyRenames(resolved[index], idMap);
|
|
1263
|
+
});
|
|
1264
|
+
return referenceMaps;
|
|
1265
|
+
}
|
|
1266
|
+
function renameIdTokensInSelector(selector, idMap) {
|
|
1267
|
+
return replaceSelectorIdTokens(selector, [...idMap.keys()], (matchedId) => `#${escapeCssIdentifier(idMap.get(matchedId))}`);
|
|
1268
|
+
}
|
|
1269
|
+
function rewriteSvgIdReferencesInCss(css, idMap) {
|
|
1270
|
+
if (!css || idMap.size === 0)
|
|
1271
|
+
return css;
|
|
1272
|
+
if (!css.includes("#") && !css.toLowerCase().includes("url("))
|
|
1273
|
+
return css;
|
|
1274
|
+
let root;
|
|
1275
|
+
try {
|
|
1276
|
+
root = postcss2.parse(css);
|
|
1277
|
+
} catch {
|
|
1278
|
+
return css;
|
|
1279
|
+
}
|
|
1280
|
+
let mutated = false;
|
|
1281
|
+
root.walkRules((rule) => {
|
|
1282
|
+
const rewritten = rule.selectors.map((selector) => renameIdTokensInSelector(selector, idMap));
|
|
1283
|
+
if (rewritten.some((selector, index) => selector !== rule.selectors[index])) {
|
|
1284
|
+
rule.selectors = rewritten;
|
|
1285
|
+
mutated = true;
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
root.walkDecls((decl) => {
|
|
1289
|
+
const rewritten = rewriteUrlHashRefs(decl.value, idMap);
|
|
1290
|
+
if (rewritten !== decl.value) {
|
|
1291
|
+
decl.value = rewritten;
|
|
1292
|
+
mutated = true;
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
root.walkAtRules((atRule) => {
|
|
1296
|
+
if (!atRule.params)
|
|
1297
|
+
return;
|
|
1298
|
+
const rewritten = rewriteUrlHashRefs(atRule.params, idMap);
|
|
1299
|
+
if (rewritten !== atRule.params) {
|
|
1300
|
+
atRule.params = rewritten;
|
|
1301
|
+
mutated = true;
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
return mutated ? root.toResult({ map: false }).css : css;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
928
1307
|
// ../core/dist/compiler/compositionAssembly.js
|
|
929
1308
|
var COMPOSITION_ID_ATTR = "data-composition-id";
|
|
930
1309
|
var COMPOSITION_SRC_ATTR = "data-composition-src";
|
|
@@ -1060,6 +1439,7 @@ function inlineSubCompositions(document, hosts, options) {
|
|
|
1060
1439
|
const moduleScripts = [];
|
|
1061
1440
|
const externalLinks = [];
|
|
1062
1441
|
const variablesByComp = {};
|
|
1442
|
+
const svgIdScopes = [];
|
|
1063
1443
|
const sceneHosts = /* @__PURE__ */ new Map();
|
|
1064
1444
|
const queue = hosts.map((element) => ({
|
|
1065
1445
|
element,
|
|
@@ -1159,6 +1539,7 @@ function inlineSubCompositions(document, hosts, options) {
|
|
|
1159
1539
|
externalLinks.push({ href, rel, crossorigin, media, title, type, disabled });
|
|
1160
1540
|
}
|
|
1161
1541
|
}
|
|
1542
|
+
const styleStart = styles.length;
|
|
1162
1543
|
for (const styleEl of plan.styleSources) {
|
|
1163
1544
|
if (cssStyleMergeKey(styleEl) === void 0)
|
|
1164
1545
|
continue;
|
|
@@ -1167,6 +1548,7 @@ function inlineSubCompositions(document, hosts, options) {
|
|
|
1167
1548
|
styleScenes.push(scene);
|
|
1168
1549
|
styleEl.remove();
|
|
1169
1550
|
}
|
|
1551
|
+
const styleEnd = styles.length;
|
|
1170
1552
|
for (const scriptEl of plan.scriptSources) {
|
|
1171
1553
|
const externalSrc = resolveSubAssetPath(scriptEl.getAttribute("src"));
|
|
1172
1554
|
const type = (scriptEl.getAttribute("type") || "").trim().toLowerCase();
|
|
@@ -1258,7 +1640,28 @@ function inlineSubCompositions(document, hosts, options) {
|
|
|
1258
1640
|
for (const nestedHost of nested.hosts) {
|
|
1259
1641
|
queue.push({ element: nestedHost.host, ancestry: nestedAncestry, scene });
|
|
1260
1642
|
}
|
|
1643
|
+
svgIdScopes.push({
|
|
1644
|
+
root: hostEl,
|
|
1645
|
+
namespace: runtimeCompId || scopeCompId,
|
|
1646
|
+
exclude: nested.hosts.map((nestedHost) => nestedHost.host),
|
|
1647
|
+
styleStart,
|
|
1648
|
+
styleEnd
|
|
1649
|
+
});
|
|
1261
1650
|
}
|
|
1651
|
+
const svgIdMaps = namespaceCollidingSvgIds(document, svgIdScopes.map(({ root, namespace, exclude, styleStart, styleEnd }) => ({
|
|
1652
|
+
root,
|
|
1653
|
+
namespace,
|
|
1654
|
+
exclude,
|
|
1655
|
+
cssTexts: styles.slice(styleStart, styleEnd).map((style) => style.css)
|
|
1656
|
+
})));
|
|
1657
|
+
svgIdMaps.forEach((idMap, index) => {
|
|
1658
|
+
if (idMap.size === 0)
|
|
1659
|
+
return;
|
|
1660
|
+
const { styleStart, styleEnd } = svgIdScopes[index];
|
|
1661
|
+
for (let i = styleStart; i < styleEnd; i += 1) {
|
|
1662
|
+
styles[i].css = rewriteSvgIdReferencesInCss(styles[i].css, idMap);
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1262
1665
|
return {
|
|
1263
1666
|
styles,
|
|
1264
1667
|
styleScenes,
|