hyperframes 0.8.155 → 0.8.157
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-QHRTHQDD.js → add-XKIJJAC6.js} +12 -12
- package/dist/{animatedGifPrep-KYVKRWHT.js → animatedGifPrep-MTJRHJ5G.js} +8 -8
- package/dist/api.js +14 -14
- package/dist/{asset-LBQA2IUJ.js → asset-TEWIJMG5.js} +2 -2
- package/dist/{assetCataloger-Y3OELLLW.js → assetCataloger-DI7FC5KZ.js} +3 -3
- package/dist/{auth-3MMX5MLV.js → auth-ERW6EOVW.js} +1 -1
- package/dist/{autoUpdate-6EMWLUKO.js → autoUpdate-IHYT5BQF.js} +2 -2
- package/dist/{backgroundChecks-3VL65XVE.js → backgroundChecks-DTKZTDHN.js} +3 -3
- package/dist/backgroundChecksWorker.js +3 -3
- package/dist/{batchRender-6TD4XSIP.js → batchRender-FTZ67377.js} +4 -4
- package/dist/{beats-NOHE5FA5.js → beats-AE4ZKJ3I.js} +13 -13
- package/dist/{benchmark-7EFNYNYH.js → benchmark-Q3YSQVWW.js} +9 -9
- package/dist/{browser-IZ2DJGGN.js → browser-IRRLG5FG.js} +3 -3
- package/dist/{bundleWithLocalizedFonts-YVGLQ72Z.js → bundleWithLocalizedFonts-IVO43QBQ.js} +2 -2
- package/dist/{capture-YJEM42PR.js → capture-ANATPLOS.js} +11 -11
- package/dist/{capture-HHK4GA4X.js → capture-MVH3XNAE.js} +2 -2
- package/dist/{catalog-GXGFKOX7.js → catalog-5BJJW3G4.js} +12 -12
- package/dist/{catch-up-L6E26OPV.js → catch-up-DU2O72RS.js} +4 -4
- package/dist/{check-HSTEN7PX.js → check-P5D3YU2H.js} +33 -33
- package/dist/{checkBrowser-547BWZG6.js → checkBrowser-RNIDFQZZ.js} +31 -30
- package/dist/{chunk-HXU4DWOZ.js → chunk-23VDPRQ3.js} +1 -1
- package/dist/{chunk-UNO7QJAV.js → chunk-25IXEZXH.js} +2 -2
- package/dist/{chunk-PXOFFSO3.js → chunk-3FRK53UC.js} +1 -1
- package/dist/{chunk-U3BCDVZO.js → chunk-3QATT3QF.js} +1 -1
- package/dist/{chunk-PCBCTD7M.js → chunk-4YDQQQY6.js} +2 -2
- package/dist/{chunk-WQMTHPTK.js → chunk-56QTFOWH.js} +4 -4
- package/dist/{chunk-M2IEAI7L.js → chunk-6B6G3QMQ.js} +10 -9
- package/dist/{chunk-YOEGUBBY.js → chunk-7F3B5YYT.js} +82 -14
- package/dist/{chunk-6ENZIL42.js → chunk-7ZWOLEGS.js} +1 -1
- package/dist/{chunk-45FUWHHV.js → chunk-BB2SFTMY.js} +2 -2
- package/dist/{chunk-O5S54BVW.js → chunk-BPTKOTF2.js} +1 -1
- package/dist/{chunk-P5CMYIC6.js → chunk-CA7IDB4Z.js} +1 -1
- package/dist/{chunk-FSZAFCU7.js → chunk-CBNI34SD.js} +1 -1
- package/dist/{chunk-DM2D67MP.js → chunk-DRT6ZQI2.js} +1 -1
- package/dist/{chunk-B4WWDPNF.js → chunk-EEEUI3ON.js} +20 -12
- package/dist/{chunk-TA5AUF2J.js → chunk-EGKIQS5J.js} +1 -1
- package/dist/{chunk-BEM57QP3.js → chunk-EYNN5DJG.js} +5 -5
- package/dist/{chunk-V6UUZGP6.js → chunk-FJT35XBA.js} +3 -3
- package/dist/{chunk-YYMJEQ4D.js → chunk-GPUVPZRK.js} +1 -1
- package/dist/{chunk-KS4JPMVV.js → chunk-HQG7B5ZE.js} +1 -1
- package/dist/{chunk-TLC4GYT5.js → chunk-IRRRH66M.js} +118 -189
- package/dist/{chunk-BSMBAP7O.js → chunk-J6SJCYAQ.js} +4 -4
- package/dist/{chunk-TXWPPBIW.js → chunk-J7WFHOCW.js} +1 -1
- package/dist/chunk-KCF6GHJP.js +250 -0
- package/dist/chunk-LPOTN5GW.js +3795 -0
- package/dist/{chunk-HGAOO43L.js → chunk-LQXHRO6F.js} +2 -2
- package/dist/{chunk-AF6Y56VA.js → chunk-LZ7C6CXD.js} +3 -3
- package/dist/{chunk-ECFNYTEM.js → chunk-NFX4K6OW.js} +1 -1
- package/dist/{chunk-RTI536FR.js → chunk-NIT2ZCNI.js} +10 -10
- package/dist/{chunk-5GZLD7OW.js → chunk-O4ZB2LUC.js} +1 -1
- package/dist/{chunk-GD5MYXEK.js → chunk-OGJFYVRC.js} +1 -1
- package/dist/{chunk-4U66LIUS.js → chunk-OTG5H2VM.js} +2 -2
- package/dist/{chunk-4OMHV7P2.js → chunk-QAWCWGQG.js} +2 -2
- package/dist/{chunk-2XEBNYG5.js → chunk-QRPYTJBW.js} +1 -1
- package/dist/{chunk-ZDEEHQ2Y.js → chunk-SGIZMTWO.js} +2 -2
- package/dist/{chunk-XQYLUY2F.js → chunk-SLUFA6UM.js} +2 -2
- package/dist/{chunk-GC36GZHM.js → chunk-SMPG26EL.js} +1 -1
- package/dist/{chunk-2Q2KQRG7.js → chunk-SWRIMG46.js} +1 -1
- package/dist/{chunk-6UMBAJRU.js → chunk-T243WV6D.js} +1 -1
- package/dist/{chunk-PCXEFXRK.js → chunk-T76NSAXO.js} +2 -2
- package/dist/{chunk-PSDTKP6K.js → chunk-TQ62EMUI.js} +12 -11
- package/dist/{chunk-GQ73YXKD.js → chunk-UGIIDY6C.js} +3 -3
- package/dist/{chunk-PFERJHKB.js → chunk-WK375PPO.js} +2 -2
- package/dist/{chunk-BADLIO5R.js → chunk-WZBGU46C.js} +1 -1
- package/dist/{chunk-HAKVKAUQ.js → chunk-XRRZZFGI.js} +1 -1
- package/dist/{chunk-D5VMPDTH.js → chunk-YB26LWR2.js} +2 -2
- package/dist/{chunk-AVGGHUVK.js → chunk-YBKIAQNU.js} +4 -4
- package/dist/{chunk-PVGDU7SE.js → chunk-ZFZNPLRJ.js} +2 -2
- package/dist/{chunk-Q3BS3MN5.js → chunk-ZTUZDPHE.js} +2 -2
- package/dist/{chunk-RSNBNSKZ.js → chunk-ZY4A2R7C.js} +7 -7
- package/dist/{chunk-RB6RHOSF.js → chunk-ZZ3ZWTOI.js} +1 -1
- package/dist/{clean-J3IRHNY5.js → clean-4WDZ3TFN.js} +15 -15
- package/dist/cli.js +52 -52
- package/dist/{cloud-TMV666ML.js → cloud-FL6VP6IU.js} +4 -4
- package/dist/{cloudrun-OUGI5NN4.js → cloudrun-STLNWUBW.js} +5 -5
- package/dist/commands/contrast-audit.browser.js +25 -8
- package/dist/commands/layout-audit.browser.js +117 -12
- package/dist/{compare-UXT7YJAD.js → compare-MXZ7QKBN.js} +25 -25
- package/dist/{compiler-WHUQZITN.js → compiler-VFJVUZWR.js} +5 -5
- package/dist/{component-OEWAQBRI.js → component-XKBA5ON2.js} +3 -3
- package/dist/{compositions-J5UAUORI.js → compositions-2LUY6RQW.js} +12 -12
- package/dist/{delete-RIWTBVNH.js → delete-OBAOZCXI.js} +2 -2
- package/dist/{deterministicFonts-EOMDR6ZF.js → deterministicFonts-LNNVHVS2.js} +2 -2
- package/dist/{dist-2YYJYYPY.js → dist-2VXSQLXO.js} +1 -1
- package/dist/{dist-NUSNSGME.js → dist-SVTSOG4Q.js} +3 -3
- package/dist/docker/Dockerfile.render +21 -1
- package/dist/{doctor-L4LKY2ZO.js → doctor-BLXWRHAE.js} +11 -11
- package/dist/{events-CRYKZ3VN.js → events-LSJDXTXK.js} +3 -3
- package/dist/{events-7O35RPKC.js → events-V4LYF3MW.js} +2 -2
- package/dist/{feedback-WL5ILVT2.js → feedback-LMDNGTYB.js} +7 -7
- package/dist/{figma-Y36QOXGR.js → figma-BXHFTYCT.js} +3 -3
- package/dist/fontLocalizeCli.js +11 -11
- package/dist/{get-BKAU2UKN.js → get-2ZKWMYCG.js} +2 -2
- package/dist/{gpuPolicy-5AGAE6DM.js → gpuPolicy-VXNJ4UBN.js} +8 -8
- package/dist/{grade-compare-6F5QLGGK.js → grade-compare-F7JNDXGF.js} +25 -25
- package/dist/{help-VMH6Q3TP.js → help-WGANCPIE.js} +1 -1
- package/dist/{history-WJI7NN5U.js → history-FILLGPWB.js} +6 -6
- package/dist/hyperframe-runtime.js +35 -35
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +35 -35
- package/dist/hyperframes-player.global.js +1 -1
- package/dist/{info-ZPGZJKYK.js → info-QQJ7C6SO.js} +8 -8
- package/dist/{init-FH3HAGUA.js → init-BQYTOLTG.js} +23 -23
- package/dist/{inspect-MIO35XDA.js → inspect-BTBKTW5W.js} +26 -26
- package/dist/{installer-QCHUXV6E.js → installer-HF5BXXXM.js} +5 -5
- package/dist/{keyframes-HL66NSCA.js → keyframes-Y5QDNXST.js} +6 -6
- package/dist/{lambda-Q5FTNY4J.js → lambda-ZCX7KGTY.js} +6 -6
- package/dist/{layout-HLA3MBNJ.js → layout-HITFK2H5.js} +26 -26
- package/dist/{lint-BL4JKGPG.js → lint-6HH5X4NJ.js} +7 -7
- package/dist/{lintProject-XQWXJYSC.js → lintProject-JGHKRO5L.js} +1 -1
- package/dist/{list-34AMRBCS.js → list-KBERMLPP.js} +2 -2
- package/dist/{login-EL5DFM34.js → login-MZNDV73I.js} +4 -4
- package/dist/{media-treatment-UWR4OOHW.js → media-treatment-YACCPVXX.js} +11 -11
- package/dist/{models-2E6AGL43.js → models-WHDUQZQZ.js} +11 -11
- package/dist/{motionShot-JBH6JWB4.js → motionShot-CRQTWUJB.js} +14 -14
- package/dist/{normalize-audio-ZZ3O7VDF.js → normalize-audio-Z7UQTZ5J.js} +4 -4
- package/dist/{open-QN7XTS6J.js → open-GM2J5QEA.js} +4 -4
- package/dist/{parakeetRunner-NUZTNYYF.js → parakeetRunner-5PNBGCGH.js} +11 -11
- package/dist/{pipeline-RUEI6IIO.js → pipeline-QA2422UI.js} +8 -8
- package/dist/{play-2Y6KCFV3.js → play-JGMRZO6G.js} +19 -19
- package/dist/{preflight-JS4P5HFR.js → preflight-BH2XUQBS.js} +1 -1
- package/dist/{present-J2UUEQWF.js → present-SI7ZE6IB.js} +15 -15
- package/dist/{preview-BSUSKQBL.js → preview-PZOQHOIO.js} +18 -18
- package/dist/{producer-6QJ5624B.js → producer-PQMZ7OYH.js} +1 -1
- package/dist/{projectConfig-EX35BZLA.js → projectConfig-EYYDESVO.js} +7 -7
- package/dist/{publication-OUGS3P7W.js → publication-MJY3XYYV.js} +3 -3
- package/dist/{publish-UUFZR6QT.js → publish-UT3L777Q.js} +9 -9
- package/dist/{remove-background-SQUYEUJN.js → remove-background-HT73ZUIG.js} +9 -9
- package/dist/{render-GNHKF76H.js → render-6CJXA7UA.js} +9 -9
- package/dist/{render-U7RMOU2K.js → render-SFIX3O3B.js} +24 -24
- package/dist/{render-AWFQGD4T.js → render-YTJ3SMCD.js} +4 -4
- package/dist/{render-batch-6UN3HT5A.js → render-batch-AFB2XK3I.js} +4 -4
- package/dist/renderSetupWorker.js +1 -1
- package/dist/{resolver-O6ZENVYP.js → resolver-F2D2YCSQ.js} +5 -5
- package/dist/{sherpa-CHOSLER6.js → sherpa-IBKSF6GX.js} +10 -10
- package/dist/{skills-2WUDLVDT.js → skills-G26XO2BY.js} +5 -5
- package/dist/{skillsUpdateCheck-7N4CXFNJ.js → skillsUpdateCheck-ZNDQSDB4.js} +3 -3
- package/dist/{snapshot-E5IT54QQ.js → snapshot-SN7I7O7I.js} +28 -28
- package/dist/{src-CP75EYSP.js → src-4GCHM2LX.js} +10 -10
- package/dist/{src-APLD7CAF.js → src-NDI4KNT3.js} +7 -7
- package/dist/{staticProjectServer-VO5U75UA.js → staticProjectServer-TTC3LYHO.js} +15 -15
- package/dist/studio/assets/{hyperframes-player-BvAidsoQ.js → hyperframes-player-D3ufdOJ_.js} +1 -1
- package/dist/studio/assets/{index-CbWWPYt-.js → index-7oKTFwYd.js} +1 -1
- package/dist/studio/assets/{index-Jt_3ZX4p.js → index-CALVHgsJ.js} +1 -1
- package/dist/studio/assets/{index-z1M2RwXX.js → index-DYk4U8BS.js} +83 -83
- package/dist/studio/index.html +1 -1
- package/dist/{studio-api-7JCPNJA7.js → studio-api-TVIDDUZG.js} +9 -9
- package/dist/{studioServer-A67X3ZLJ.js → studioServer-WBV2Q3SH.js} +40 -40
- package/dist/{telemetry-22DNA5QE.js → telemetry-RVFKZEOH.js} +3 -3
- package/dist/{timeline-K3BXXFQG.js → timeline-BUYUBI5X.js} +15 -15
- package/dist/{tokens-MWRAQMQU.js → tokens-PUA5FQKP.js} +2 -2
- package/dist/{transcribe-O5B3HUFK.js → transcribe-DZ6O6EG5.js} +9 -9
- package/dist/{transcribe-C7J56BLL.js → transcribe-L2QHSNHO.js} +15 -15
- package/dist/{updateCheck-EPJ7WDFT.js → updateCheck-PULEO7CW.js} +2 -2
- package/dist/{upgrade-M5XD6ZPM.js → upgrade-UJJIVNHJ.js} +2 -2
- package/dist/{urlDownloader-IEP2DY4N.js → urlDownloader-INLS5A6I.js} +7 -7
- package/dist/{validate-JAF2KIJI.js → validate-DJAZMEQB.js} +20 -20
- package/dist/{video-TX6DGLND.js → video-3GLT6U6Z.js} +8 -8
- package/package.json +1 -1
- package/dist/chunk-GV7I3ZSQ.js +0 -3795
- package/dist/chunk-NE55C6S5.js +0 -118
- /package/dist/{chunk-VYKPBRCB.js → chunk-ALLKNYC3.js} +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { createRequire as __hf_createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __hf_fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname as __hf_dirname } from "node:path";
|
|
4
|
+
var require = __hf_createRequire(import.meta.url);
|
|
5
|
+
var __filename = __hf_fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __hf_dirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
parseHTML
|
|
9
|
+
} from "./chunk-SDYDNHEE.js";
|
|
10
|
+
|
|
11
|
+
// ../parsers/dist/hfIds.js
|
|
12
|
+
var EXCLUDED_TAGS = /* @__PURE__ */ new Set([
|
|
13
|
+
"script",
|
|
14
|
+
"style",
|
|
15
|
+
"template",
|
|
16
|
+
"meta",
|
|
17
|
+
"link",
|
|
18
|
+
"noscript",
|
|
19
|
+
"base"
|
|
20
|
+
]);
|
|
21
|
+
function fnv1a(str) {
|
|
22
|
+
let h = 2166136261;
|
|
23
|
+
for (let i = 0; i < str.length; i++) {
|
|
24
|
+
h ^= str.charCodeAt(i);
|
|
25
|
+
h = Math.imul(h, 16777619);
|
|
26
|
+
}
|
|
27
|
+
return h >>> 0;
|
|
28
|
+
}
|
|
29
|
+
function toHfId(hash) {
|
|
30
|
+
const s = (hash >>> 0).toString(36);
|
|
31
|
+
const four = s.length >= 4 ? s.slice(-4) : s.padStart(4, "0");
|
|
32
|
+
return `hf-${four}`;
|
|
33
|
+
}
|
|
34
|
+
function ownText(el) {
|
|
35
|
+
let text = "";
|
|
36
|
+
el.childNodes.forEach((n) => {
|
|
37
|
+
if (n.nodeType === 3) text += n.nodeValue ?? "";
|
|
38
|
+
});
|
|
39
|
+
return text.trim();
|
|
40
|
+
}
|
|
41
|
+
function getContractAttribute(el, name) {
|
|
42
|
+
return Array.from(el.attributes).find((attr) => attr.name.toLowerCase() === name)?.value ?? null;
|
|
43
|
+
}
|
|
44
|
+
function contentKey(el) {
|
|
45
|
+
const attrs = Array.from(el.attributes).filter((a) => !a.name.toLowerCase().startsWith("data-hf-")).map((a) => `${a.name.toLowerCase()}\0${a.value}`).sort().join("");
|
|
46
|
+
return `${el.tagName.toLowerCase()}|${attrs}|${ownText(el)}`;
|
|
47
|
+
}
|
|
48
|
+
function mintHfId(el, assigned) {
|
|
49
|
+
const key = contentKey(el);
|
|
50
|
+
let id = toHfId(fnv1a(key));
|
|
51
|
+
let dup = 0;
|
|
52
|
+
while (assigned.has(id)) {
|
|
53
|
+
dup += 1;
|
|
54
|
+
if (dup > 1e4) {
|
|
55
|
+
id = `hf-${(fnv1a(key) >>> 0).toString(36)}-${dup}`;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
id = toHfId(fnv1a(`${key}#${dup}`));
|
|
59
|
+
}
|
|
60
|
+
assigned.add(id);
|
|
61
|
+
return id;
|
|
62
|
+
}
|
|
63
|
+
function getChildElements(parent) {
|
|
64
|
+
const directChildren = Array.from(parent.children);
|
|
65
|
+
if (directChildren.length || parent.tagName.toLowerCase() !== "template") return directChildren;
|
|
66
|
+
const content = parent.content;
|
|
67
|
+
if (content?.children.length) return Array.from(content.children);
|
|
68
|
+
return directChildren;
|
|
69
|
+
}
|
|
70
|
+
function isCompositionTemplate(el) {
|
|
71
|
+
if (el.tagName.toLowerCase() !== "template") return false;
|
|
72
|
+
if (getContractAttribute(el, "data-composition-id") !== null) return true;
|
|
73
|
+
for (const child of getChildElements(el)) {
|
|
74
|
+
if (getContractAttribute(child, "data-composition-id") !== null) return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
function walkCompositionDescendants(root, visit) {
|
|
79
|
+
const rootElement = root.nodeType === 9 ? root.documentElement : root;
|
|
80
|
+
if (!rootElement) return;
|
|
81
|
+
const walk = (parent) => {
|
|
82
|
+
for (const child of getChildElements(parent)) {
|
|
83
|
+
const isTemplate = child.tagName.toLowerCase() === "template";
|
|
84
|
+
if (isTemplate && !isCompositionTemplate(child)) continue;
|
|
85
|
+
visit(child);
|
|
86
|
+
walk(child);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
walk(rootElement);
|
|
90
|
+
}
|
|
91
|
+
function assignHfIds(body) {
|
|
92
|
+
const assigned = /* @__PURE__ */ new Set();
|
|
93
|
+
walkCompositionDescendants(body, (el) => {
|
|
94
|
+
const existing = getContractAttribute(el, "data-hf-id");
|
|
95
|
+
if (existing) assigned.add(existing);
|
|
96
|
+
});
|
|
97
|
+
walkCompositionDescendants(body, (el) => {
|
|
98
|
+
if (EXCLUDED_TAGS.has(el.tagName.toLowerCase())) return;
|
|
99
|
+
if (getContractAttribute(el, "data-hf-id")) return;
|
|
100
|
+
el.setAttribute("data-hf-id", mintHfId(el, assigned));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function ensureHfIds(html) {
|
|
104
|
+
const { document, wrapped } = parseFragmentOrDocument(html);
|
|
105
|
+
if (!document.body) return html;
|
|
106
|
+
assignHfIds(document.body);
|
|
107
|
+
return wrapped ? document.body.innerHTML || "" : document.toString();
|
|
108
|
+
}
|
|
109
|
+
function parseFragmentOrDocument(html) {
|
|
110
|
+
const wrapped = !/^(?:<!doctype|<html[\s>/])/i.test(
|
|
111
|
+
html.replace(/^(?:\s|<!--(?:>|->|[\s\S]*?-->))*/, "")
|
|
112
|
+
);
|
|
113
|
+
const { document } = wrapped ? parseHTML(`<!DOCTYPE html><html><head></head><body>${html}</body></html>`) : parseHTML(html);
|
|
114
|
+
return { document, wrapped };
|
|
115
|
+
}
|
|
116
|
+
function stampHfIdsInPlace(html) {
|
|
117
|
+
const { document, wrapped } = parseFragmentOrDocument(html);
|
|
118
|
+
if (!document.body) return html;
|
|
119
|
+
const elements = wrapped ? getChildElements(document.body).flatMap(inDocumentOrder) : inDocumentOrder(document.documentElement);
|
|
120
|
+
const existing = elements.map((el) => el.getAttribute("data-hf-id"));
|
|
121
|
+
const pinned = existing.map((id) => id !== null && id.length > 0);
|
|
122
|
+
assignHfIds(document.body);
|
|
123
|
+
const minted = elements.map((el, n) => pinned[n] ? null : el.getAttribute("data-hf-id"));
|
|
124
|
+
const tags = startTags(html);
|
|
125
|
+
const inserts = tags && alignInserts(html, tags, elements, minted, existing);
|
|
126
|
+
return inserts ? spliceIds(html, inserts) : ensureHfIds(html);
|
|
127
|
+
}
|
|
128
|
+
function inDocumentOrder(el) {
|
|
129
|
+
return [el, ...getChildElements(el).flatMap(inDocumentOrder)];
|
|
130
|
+
}
|
|
131
|
+
var RAW_TEXT = /* @__PURE__ */ new Set(["script", "style", "textarea", "title", "xmp", "noembed", "noframes"]);
|
|
132
|
+
var IMPLIED = /* @__PURE__ */ new Set(["html", "head", "body", "tbody"]);
|
|
133
|
+
function startTags(html) {
|
|
134
|
+
const lower = html.toLowerCase();
|
|
135
|
+
const tags = [];
|
|
136
|
+
let i = html.indexOf("<");
|
|
137
|
+
while (i >= 0) {
|
|
138
|
+
const name = html.startsWith("<!--", i) ? null : /^<([a-zA-Z][^\s/>]*)/.exec(html.slice(i, i + 128));
|
|
139
|
+
if (!name) {
|
|
140
|
+
i = nextTagAfter(html, i);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const end = closingBracket(html, i + name[0].length);
|
|
144
|
+
if (end < 0) return null;
|
|
145
|
+
const tag = name[1].toLowerCase();
|
|
146
|
+
tags.push({ name: tag, nameEnd: i + name[0].length, bracket: end });
|
|
147
|
+
const after = RAW_TEXT.has(tag) ? rawTextEnd(lower, tag, end) : end;
|
|
148
|
+
i = after < 0 ? -1 : html.indexOf("<", after + 1);
|
|
149
|
+
}
|
|
150
|
+
return tags;
|
|
151
|
+
}
|
|
152
|
+
function rawTextEnd(lower, tag, from) {
|
|
153
|
+
const marker = `</${tag}`;
|
|
154
|
+
for (let at = lower.indexOf(marker, from); at >= 0; at = lower.indexOf(marker, at + marker.length)) {
|
|
155
|
+
const next = lower[at + marker.length];
|
|
156
|
+
if (next !== void 0 && /[\s/>]/.test(next)) return at;
|
|
157
|
+
}
|
|
158
|
+
return -1;
|
|
159
|
+
}
|
|
160
|
+
function nextTagAfter(html, lt) {
|
|
161
|
+
const comment = html.startsWith("<!--", lt);
|
|
162
|
+
const end = comment ? html.indexOf("-->", lt + 4) : html.indexOf(">", lt);
|
|
163
|
+
return end < 0 ? -1 : html.indexOf("<", end + 1);
|
|
164
|
+
}
|
|
165
|
+
function closingBracket(html, from) {
|
|
166
|
+
let quote = "";
|
|
167
|
+
for (let i = from; i < html.length; i++) {
|
|
168
|
+
const c = html[i];
|
|
169
|
+
if (quote) quote = c === quote ? "" : quote;
|
|
170
|
+
else if (c === '"' || c === "'") quote = c;
|
|
171
|
+
else if (c === ">") return i;
|
|
172
|
+
}
|
|
173
|
+
return -1;
|
|
174
|
+
}
|
|
175
|
+
function alignInserts(html, tags, elements, minted, existing) {
|
|
176
|
+
const walked = walkAlign(html, tags, elements, minted, existing);
|
|
177
|
+
if (!walked) return null;
|
|
178
|
+
return walked.next === tags.length ? walked.inserts : null;
|
|
179
|
+
}
|
|
180
|
+
function walkAlign(html, tags, elements, minted, existing) {
|
|
181
|
+
const state = { inserts: [], next: 0 };
|
|
182
|
+
for (const [n, el] of elements.entries()) {
|
|
183
|
+
if (!take(state, html, tags, el, minted[n] ?? null, existing[n] === "")) return null;
|
|
184
|
+
}
|
|
185
|
+
return state;
|
|
186
|
+
}
|
|
187
|
+
function take(state, html, tags, el, id, fillEmpty) {
|
|
188
|
+
const step = alignOne(html, tags[state.next], el, id, fillEmpty);
|
|
189
|
+
if (!step) return false;
|
|
190
|
+
if (step.insert) state.inserts.push(step.insert);
|
|
191
|
+
if (step.next) state.next += 1;
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
function alignOne(html, tag, el, id, fillEmpty) {
|
|
195
|
+
if (tag?.name === el.tagName.toLowerCase()) return matched(html, tag, id, fillEmpty);
|
|
196
|
+
if (IMPLIED.has(el.tagName.toLowerCase()) && !id) return { insert: null, next: false };
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
function matched(html, tag, id, fillEmpty) {
|
|
200
|
+
if (!id) return { insert: null, next: true };
|
|
201
|
+
const placed = placeId(html, tag, id, fillEmpty);
|
|
202
|
+
if (!placed) return null;
|
|
203
|
+
return { insert: placed, next: true };
|
|
204
|
+
}
|
|
205
|
+
function placeId(html, tag, id, fillEmpty) {
|
|
206
|
+
if (!fillEmpty) return { at: tag.nameEnd, text: ` data-hf-id="${id}"` };
|
|
207
|
+
const emptyAt = emptyHfIdValue(html, tag);
|
|
208
|
+
if (emptyAt === null) return null;
|
|
209
|
+
return { at: emptyAt, text: id };
|
|
210
|
+
}
|
|
211
|
+
function emptyHfIdValue(html, tag) {
|
|
212
|
+
const open = outsideQuotes(html.slice(tag.nameEnd, tag.bracket));
|
|
213
|
+
const match = /\sdata-hf-id\s*=\s*(["'])\1/i.exec(open);
|
|
214
|
+
if (!match) return null;
|
|
215
|
+
return tag.nameEnd + match.index + match[0].length - 1;
|
|
216
|
+
}
|
|
217
|
+
function outsideQuotes(open) {
|
|
218
|
+
let quote = "";
|
|
219
|
+
let out = "";
|
|
220
|
+
for (const c of open) {
|
|
221
|
+
out += quotedChar(quote, c);
|
|
222
|
+
quote = quoteOf(quote, c);
|
|
223
|
+
}
|
|
224
|
+
return out;
|
|
225
|
+
}
|
|
226
|
+
function quoteOf(quote, c) {
|
|
227
|
+
if (quote) return c === quote ? "" : quote;
|
|
228
|
+
return c === '"' || c === "'" ? c : "";
|
|
229
|
+
}
|
|
230
|
+
function quotedChar(quote, c) {
|
|
231
|
+
if (!quote || c === quote) return c;
|
|
232
|
+
return " ".repeat(c.length);
|
|
233
|
+
}
|
|
234
|
+
function spliceIds(html, inserts) {
|
|
235
|
+
let out = "";
|
|
236
|
+
let from = 0;
|
|
237
|
+
for (const { at, text } of inserts) {
|
|
238
|
+
out += html.slice(from, at) + text;
|
|
239
|
+
from = at;
|
|
240
|
+
}
|
|
241
|
+
return out + html.slice(from);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export {
|
|
245
|
+
EXCLUDED_TAGS,
|
|
246
|
+
mintHfId,
|
|
247
|
+
walkCompositionDescendants,
|
|
248
|
+
ensureHfIds,
|
|
249
|
+
stampHfIdsInPlace
|
|
250
|
+
};
|