mnfst 0.5.333 → 0.5.335

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.
@@ -2,7 +2,7 @@
2
2
  "manifest.accordion.css": "sha384-XA/UMMX/m2c8/rtvH3LeUez5j/jjNq+sTvihfja4fT2r47bWdpLH/wRpR+4PGdRN",
3
3
  "manifest.appwrite.auth.js": "sha384-n+Fohtui5o2h3HpM7ifnop9YsAdlTj0uHYfzljQMghLJeDkODC6OXop6ds6OTZha",
4
4
  "manifest.appwrite.auth.min.js": "sha384-qN5XF96RpRVTzBeOBoxwh6ziq2+eZ2rS0cLUtlwp4CFcbyuMCaf6kHFJKoWEGNvp",
5
- "manifest.appwrite.data.js": "sha384-hARZEL4CJ0E0GyRyiWmabHIY5SmAoo+lEcmAJv29RPUCEfmvzRhZIBXRbz35lLZr",
5
+ "manifest.appwrite.data.js": "sha384-zNBGEr7E6SXTXUoDFjBBOxUAWhIdl1WqRSY2JjUlDsLz6R1E9qFfhlbfAlg/YOMB",
6
6
  "manifest.appwrite.data.min.js": "sha384-PCp21DVdPqQVudd4FsA2stYdmql8verhQZ3WapA/oR4uAap/+KPFP0sgOjEPT6yZ",
7
7
  "manifest.appwrite.presences.js": "sha384-O3EedwV2QTzd4YotjvGPsDHbxaGbtRaZuNopC7/Cfoo5uYPo8ZHYkCPCWurXpA2/",
8
8
  "manifest.appwrite.presences.min.js": "sha384-7AHt7baL29VI3S1Nbkkyq34j2eJ2ysGpDnllmpXXSlc4GHvTk5hdCrXra2R3mSfH",
@@ -18,9 +18,9 @@
18
18
  "manifest.chat.min.js": "sha384-gAXMQ/es7WMQiJ/MqnzgCMlNJa4kBCvK4i+VMXuyL7/xWeBxF/Azw+8tD/4ITbKQ",
19
19
  "manifest.checkbox.css": "sha384-j7pFoR3rC/UUh5wTN9rvOcEl/S51KIxNkWjXXFdk+6VUI16GMj+G/7EXP31c8F6v",
20
20
  "manifest.code.css": "sha384-mJrNM6mEgDCtttmcy+4MnkTw7krv3HdS9ab5Zi5eSq7lDfEaJ8STxdqvx7NhAMqr",
21
- "manifest.code.js": "sha384-HQdsz0H1e3VUvit/tx7RR393/PeVlJ0ffPkP2+TiBaHWyMDjXkFpyBRHBYMjK2L9",
21
+ "manifest.code.js": "sha384-B94N86P9ORHC5iXm/AfG0Nk4hYhY3WaFx8kcQsDDOKVU/a94QFbwvVPjsknrvCmX",
22
22
  "manifest.code.min.css": "sha384-5cg224mDaqT8POAV4AONXpdWxRPOyCvN/afaNvHBXaY7oqs5Tt90tTK5y0d7X5ek",
23
- "manifest.code.min.js": "sha384-hjazmIu+2ZKcTVMqVqNrXBXdjeV0OupdsCvj8UJHV0OgDXOY2KuWW+ieA8w95uW8",
23
+ "manifest.code.min.js": "sha384-gfzsg44LIe7pe0PA8Ki6bqJvCvqBNtyhKsZORLNzh2aX4wGS4dSflMv+gjoOiENe",
24
24
  "manifest.color.js": "sha384-tLmmr7KwPIjznXr2tJfJtuAOV9pohdr+Ojj4L4BaOZ8WngCNOPUp27Dfz47YqU2R",
25
25
  "manifest.color.min.js": "sha384-tk5KgiWjRcXtcbZQbLbAYJY48BJ88NX4UUIrN1kO8EWSzTG4Vw8xbNNWZn7Vuz+0",
26
26
  "manifest.colorpicker.css": "sha384-LO51JgsgIVBsjiVzoHTCCVvVk3j/iO39RbLj1bsJoUK82oIHrOYJlZADmzaOAtgd",
@@ -35,8 +35,8 @@
35
35
  "manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
36
36
  "manifest.computed.min.js": "sha384-90LbCcEOhrjhxi0GWBRb3DJyOkKWLRwzK7Z2nkbc1uaZ5B9EGmNKqx+mstTLWFGJ",
37
37
  "manifest.css": "sha384-WvntWYbbzn/qhMLloLI/aTaw1TIuYuPuISMLLBaC2ELhmFPYu1rix/WNzyDeG/Z+",
38
- "manifest.data.js": "sha384-Dlkyz1KGqWZHRMLje++aclXPrLInBRGhsqtsH+MkLf4G2vNaT7xI09GERCSOwa/A",
39
- "manifest.data.min.js": "sha384-KIF8sGE7lvhewtrY1zqz3wBYe51CAjJ3hbrncIvjhHOFBeflSPyGDD+22ODgL4+o",
38
+ "manifest.data.js": "sha384-dbxiq8PZbSkUKSHuQDjmlwwey9Gae2vj0ZCQu+bCFJp3bxXLt1okxbveqwKy7fvl",
39
+ "manifest.data.min.js": "sha384-R8D4/Avzph1gKruvafmr3tTqVcMMMtRj+x9A3fjGJMXPvIFiMvXgVRBEdJzHh6XU",
40
40
  "manifest.datepicker.css": "sha384-lW6PLZxKr2GjR/O16oPq+5wrBZjQ1UCQUo2PTQZaj0FW8hCh6dydjzCF1qcp9up4",
41
41
  "manifest.datepicker.js": "sha384-pZUQhUK6u5cl6g0myBXND/Wtrs1RTovYmy/ETQLUV0JujvTvUdRNc/XjPpVhtK16",
42
42
  "manifest.datepicker.min.js": "sha384-e6xN1xQW3LLFvmSWrh3INMCgfUwD+gJca6n9fJfUFArA/OSm2KY0MDeN0pHVsYiw",
@@ -58,14 +58,14 @@
58
58
  "manifest.icons.js": "sha384-gLb9vW0MRJTQi6M1HFUylSLGNohkaCyUaCfhcoRPPzJOIxVrQzMeQuFUMqRMj2Yy",
59
59
  "manifest.icons.min.js": "sha384-TZpazdx9K8xe3e7jmYoCzg7YD/7kBp1u8ScByfigopAvGJOzR4K10zpmGovwA0nv",
60
60
  "manifest.input.css": "sha384-6+ErMsR67xE2xQWUS6QPhYH89pqf4wY4GEIDPq6jcQrHDqZMthyX4I93N4DttG7c",
61
- "manifest.js": "sha384-knaJ7p/WG97ZTFXSsX9YFuBuuO6TaR7gg4ROcfOlGp8uD5gPsSFACnpZkFqk0g1n",
61
+ "manifest.js": "sha384-hmNDfIdHUNUb7qf4T66pxZqLsNFr9tlcZp40Yl1ViVdzZUZsiif7vawXXufsgyYH",
62
62
  "manifest.localization.js": "sha384-9EDAqnI7MNCZp4Vas0RMZgceCuz9EJUi/OARm8iI+Hi4S8HF//yyVOhhhhQ+XcLq",
63
63
  "manifest.localization.min.js": "sha384-5EkwrlpE29wmsy0JBq7UwWy8rVzEsu8tTprnsiNThVddFWsbFd63C/il4JjnWLmP",
64
64
  "manifest.markdown.js": "sha384-akK4967sMccfrxOkhvpsv4H8ylIJRVHpkzX5EUGCwhHeamWr8JLv7awh8sR34LBq",
65
65
  "manifest.markdown.min.js": "sha384-xQukORRTifFp3K1SICjNiIiOSwfzv8MMEPTGv0jFb6zsnpiYCOrM4n6KvTMFYMAp",
66
66
  "manifest.min.css": "sha384-ZLXKtchybe6D6nmOkd2CYR9LzplunAqxpUkvf8yfrn8BLT/M2jNo83Tb95mdx98L",
67
- "manifest.min.js": "sha384-BQwxidpcsj1GREGyWmp20gMXTHHonBRHvvFLiGOEJXy5XHcpVxxp4ZATEwqwGe7T",
68
- "manifest.modules.integrity.json": "sha384-EoPUnvcTd0V6ugOg+8X6DWOIWmgwj36CxAAGVd+PwRq2h5Rmxh+vUp0wjh+xzml5",
67
+ "manifest.min.js": "sha384-Va3v6FteLdnFhRy9paFSBYaut2b9trOgTUQb39vIF763noKnUY6sgngLpD3pbMlP",
68
+ "manifest.modules.integrity.json": "sha384-gR4N6WAnYxI7f1AtKI43kMNEaiuG6f4Cv+JAfulbrtc1Wzmn11/ZBNHiQ6VoYD28",
69
69
  "manifest.native.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
70
70
  "manifest.native.min.js": "sha384-3xZep6D5icnCvKbzPxQ6QxqvJMfWI0GiADQrGkiFJEhe8sXg6P6vfIAjLUykFi+2",
71
71
  "manifest.payments.js": "sha384-3Db2i47QA5I/Id5XMkwJThxSe8wZFiEEcJaKuuIjE5yBjGBxPMWFwhE4wgdvWgOo",
@@ -88,8 +88,8 @@
88
88
  "manifest.submissions.min.js": "sha384-p/5Ekd6u/cTsyVQbRgGzEi3h1hJU9zD7+hjdR+upcwt++26sfrLXMjFI2YjS8zWt",
89
89
  "manifest.svg.js": "sha384-D1jF3a0pXIuzm7T2sltyzblF8BTZ8sv1CkfJyQ33q21G6QlYyjdPv8DJi80eCISD",
90
90
  "manifest.svg.min.js": "sha384-rsvQ50FgVpTxX2Wvba3hed2TQvZR+CHHfgS4Cg7V1Dyjx6rxkS1s6rG6UMWDIMez",
91
- "manifest.sw.js": "sha384-sRctgJsW1hJBdlWv26BsfvdlmHcTrr9DaW1A8bqvhpgNYvYc7kbZ3oKjQCGVsMsW",
92
- "manifest.sw.min.js": "sha384-asEXF1LrK0aByFO0XJWxlfTO0u5vyq+ooz1b3ZTzjzdn+zfKmYwamWZ5fhAt3TdY",
91
+ "manifest.sw.js": "sha384-JZlikVV7Vte5kidLTKrENtL2MsXu4+h9fg+HCAS0yqD1fgE6PtFRZpQZW2d+vjXb",
92
+ "manifest.sw.min.js": "sha384-C9L5fDXqmVWpAvxgJsdxs1EoS0mGUPIV3kjW27zmTOkckCTAVT62bW/qP5u4rw2l",
93
93
  "manifest.switch.css": "sha384-s3+th9ojcLpRGhxxS9u4VR+AVRUqK6sNI62h4TAuZG7G1r1bNqXo1z/UMhTon00x",
94
94
  "manifest.table.css": "sha384-1XqR9mQSrxogf6fGcbVEbQ/cObABBAlMNfpW6T0vibXYwHv6l9kF3AVTXg/FknpM",
95
95
  "manifest.tabs.js": "sha384-LoPOo8mCAzyil9BLFV1BsDNBVyKmijKieKl7mbVAHEH/Nd7Ye0E6fM6yOgdBKcHZ",
@@ -107,8 +107,8 @@
107
107
  "manifest.url.parameters.js": "sha384-J2aSVBOPsoqsbafHndrWLHEDpKb4AKJAoQnVmKA4gZh5P/8HHjFWHO/lkusmG84l",
108
108
  "manifest.url.parameters.min.js": "sha384-0C6e6FIjB9TKVGy5W0LH0TDQ3Eg4mRAokM4MANHUuwoG0IzUZV7HaYUQd2AnkB7a",
109
109
  "manifest.utilities.css": "sha384-+y0FwD4lna9Ud4w1rbauDlfHQzBXcwluAdrNhtMKMP1L1ygAn6KSvUUceZBGq19U",
110
- "manifest.utilities.js": "sha384-G1Tg8KsB7z7ANHiYZCzqijjOCtogvdEM+dYb8P/h0a1XafTThQOkp1gHlvNsjtPm",
111
- "manifest.utilities.min.js": "sha384-WilK2hRJ6X1wKLv8RaXDxKllqqGWbux83+yL1Tdv/VoYP0T2YxRH2YXT2bZkxUh1",
110
+ "manifest.utilities.js": "sha384-S2NYQJfAbRVsXpucdl5DFZVHz8li+p3YEQBFFzqDYAmJUmpYGD0yc0xa8JqD1CLl",
111
+ "manifest.utilities.min.js": "sha384-1188wXKPoXUnzqzfuIvmx/ZMhsLuJaz16ss8Z98ZtHKJzmGQMOk1aXnC4WghffZL",
112
112
  "manifest.vendor.integrity.json": "sha384-xMKQh8gEBZhtaYhv09XUs3amAIT3Oh7aKrsGN0ABsnlIpbgxr5OHi5FxQTQhqz3E",
113
113
  "manifest.virtual.js": "sha384-2Kmw+B6cLKUVvkXtZb7x+5OrWcJWooOQ/QBB51vpQC7P3Jdd9jcoSSAiwQ6LCNQo",
114
114
  "manifest.virtual.min.js": "sha384-FqBrlNUM9wT6q7FRg1KVLVA9pUJv60NUr3o7Mxcis7tXWYax6h/8NBDfOsMCUkLS"
package/lib/manifest.js CHANGED
@@ -353,8 +353,8 @@
353
353
  const DEFAULT_VERSION = 'latest';
354
354
 
355
355
  // Stamped at build
356
- const LOADER_VERSION = '0.5.333';
357
- const MODULES_INTEGRITY = 'sha384-EoPUnvcTd0V6ugOg+8X6DWOIWmgwj36CxAAGVd+PwRq2h5Rmxh+vUp0wjh+xzml5';
356
+ const LOADER_VERSION = '0.5.335';
357
+ const MODULES_INTEGRITY = 'sha384-gR4N6WAnYxI7f1AtKI43kMNEaiuG6f4Cv+JAfulbrtc1Wzmn11/ZBNHiQ6VoYD28';
358
358
  const INTEGRITY_FILE = 'manifest.modules.integrity.json';
359
359
  const VENDOR_FILE = 'manifest.vendor.integrity.json';
360
360
  // 'strict' | 'warn' while checks are requested; map promise while they apply
@@ -498,8 +498,11 @@
498
498
 
499
499
  // Has DOMContentLoaded fired? readyState can't tell ('interactive' spans
500
500
  // both DCL-pending and DCL-done); the navigation timing entry disambiguates.
501
+ // Its end stays 0 while DCL listeners run: seen here first, so code run from them doesn't wait for load
502
+ let dclStarted = false;
503
+ if (typeof document !== 'undefined' && document.readyState !== 'complete') document.addEventListener('DOMContentLoaded', () => { dclStarted = true; }, { once: true });
501
504
  function domContentLoadedFired() {
502
- if (document.readyState === 'complete') return true;
505
+ if (dclStarted || document.readyState === 'complete') return true;
503
506
  if (document.readyState === 'loading') return false;
504
507
  try {
505
508
  const nav = performance.getEntriesByType('navigation')[0];
@@ -710,7 +713,7 @@
710
713
  return verifiedFetch(CDN_HOSTS.map(h => `${h}/${path}`), hash, path);
711
714
  }
712
715
 
713
- async function fetchPluginScript(pluginName, version) {
716
+ async function fetchPluginScript(pluginName, version, ordered = true) {
714
717
  let unchecked = false;
715
718
  if (integrityActive && version !== LOADER_VERSION) {
716
719
  integrityProblem(`Integrity checks cover this loader's own version (${LOADER_VERSION}); ${pluginName} was requested at ${version}.`, 'Not loaded.');
@@ -718,7 +721,7 @@
718
721
  }
719
722
  // Known only once manifest.json lands, and the first view waits on them: ahead of the hinted modules
720
723
  const priority = ['components', 'data', 'localization'].includes(pluginName) ? 'high' : null;
721
- return injectFrom(getPluginUrlCandidates(pluginName, version), { unchecked, priority });
724
+ return injectFrom(getPluginUrlCandidates(pluginName, version), { unchecked, priority, ordered });
722
725
  }
723
726
 
724
727
  // One execution per plugin per page. injectScript dedupes by URL, which two
@@ -727,8 +730,13 @@
727
730
  // fights the first. A failed load is forgotten so a retry can still run.
728
731
  const pluginLoads = new Map();
729
732
  const pluginsSettled = new Set();
733
+ // When each file ran: one 10 s give-up per module from then, however many waits share it
734
+ const ranAt = new Map();
735
+ const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
736
+ const sinceRan = (p) => ranAt.has(p) ? now() - ranAt.get(p) : 0;
737
+ const giveUpIn = (p) => Math.max(0, 10000 - sinceRan(p));
730
738
 
731
- async function addScript(pluginName, version = RESOLVED_VERSION) {
739
+ async function addScript(pluginName, version = RESOLVED_VERSION, ordered = true) {
732
740
  const prior = pluginLoads.get(pluginName);
733
741
  if (prior) {
734
742
  if (prior.version !== version) {
@@ -736,9 +744,9 @@
736
744
  }
737
745
  return prior.promise;
738
746
  }
739
- const promise = fetchPluginScript(pluginName, version);
747
+ const promise = fetchPluginScript(pluginName, version, ordered);
740
748
  pluginLoads.set(pluginName, { version, promise });
741
- promise.then(() => pluginsSettled.add(pluginName), () => pluginLoads.delete(pluginName));
749
+ promise.then(() => { pluginsSettled.add(pluginName); ranAt.set(pluginName, now()); }, () => pluginLoads.delete(pluginName));
742
750
  return promise;
743
751
  }
744
752
 
@@ -955,6 +963,9 @@
955
963
  return load ? load.promise : null;
956
964
  }
957
965
  const heldEls = new WeakSet();
966
+ // Holds not yet released (restore included), and controls an outer restore left to an inner one: outer root
967
+ const holding = new WeakSet();
968
+ const passedOn = new WeakMap();
958
969
  let heldCount = 0;
959
970
  let heldRelease = null;
960
971
  // Rendered from source: hidden while held so raw markdown/code never shows
@@ -979,23 +990,34 @@
979
990
  const focus = a && root.contains(a) ? [a, a.selectionStart, a.selectionEnd] : null;
980
991
  return () => {
981
992
  // Outside the held element these edits were already seen live: stop the replay at its root
982
- const replay = new WeakSet();
983
- const stop = (e) => { if (replay.has(e)) e.stopPropagation(); };
984
- root.addEventListener('input', stop);
985
- root.addEventListener('change', stop);
986
- const fire = (c, type) => { const e = new Event(type, { bubbles: true }); replay.add(e); c.dispatchEvent(e); };
993
+ const replay = new WeakMap();
994
+ const stop = (e) => { if (replay.get(e) === e.currentTarget) e.stopPropagation(); };
995
+ const plan = [];
987
996
  for (const [c, k, v] of typed) {
988
997
  try {
989
998
  // Taken over by its directive on start (e.g. a date field turned read-only): not typable there
990
999
  if (!c.isConnected || c.readOnly || c.disabled) continue;
1000
+ // Inside a nested hold still to restore: that one replays it, up to this root
1001
+ let inner = false;
1002
+ for (let n = c; n && n !== root; n = n.parentElement) if (holding.has(n)) { inner = true; break; }
1003
+ if (inner) { if (!passedOn.has(c)) passedOn.set(c, root); continue; }
1004
+ const at = passedOn.get(c) || root;
1005
+ passedOn.delete(c);
1006
+ plan.push([c, k, v, at]);
1007
+ } catch (_) { /* skipped */ }
1008
+ }
1009
+ const stops = new Set(plan.map(p => p[3]));
1010
+ stops.forEach(s => { s.addEventListener('input', stop); s.addEventListener('change', stop); });
1011
+ const fire = (c, type, at) => { const e = new Event(type, { bubbles: true }); replay.set(e, at); c.dispatchEvent(e); };
1012
+ for (const [c, k, v, at] of plan) {
1013
+ try {
991
1014
  if (k === 'options') [...c.options].forEach((o, i) => { o.selected = !!v[i]; });
992
1015
  else if (k !== 'files') c[k] = v;
993
- fire(c, 'input');
994
- fire(c, 'change');
1016
+ fire(c, 'input', at);
1017
+ fire(c, 'change', at);
995
1018
  } catch (_) { /* skipped */ }
996
1019
  }
997
- root.removeEventListener('input', stop);
998
- root.removeEventListener('change', stop);
1020
+ stops.forEach(s => { s.removeEventListener('input', stop); s.removeEventListener('change', stop); });
999
1021
  if (focus && focus[0].isConnected) {
1000
1022
  try { focus[0].focus({ preventScroll: true }); if (focus[1] != null) focus[0].setSelectionRange(focus[1], focus[2]); } catch (_) { }
1001
1023
  }
@@ -1006,6 +1028,7 @@
1006
1028
  if (!load) return false;
1007
1029
  const name = u.attr.slice(2);
1008
1030
  heldEls.add(el);
1031
+ holding.add(el);
1009
1032
  if (!heldCount++ && window.ManifestPending) heldRelease = window.ManifestPending.hold('held');
1010
1033
  // Once per hold, whatever throws on the way
1011
1034
  let released = false;
@@ -1013,6 +1036,7 @@
1013
1036
  if (released) return;
1014
1037
  released = true;
1015
1038
  heldEls.delete(el);
1039
+ holding.delete(el);
1016
1040
  if (!--heldCount && heldRelease) { const r = heldRelease; heldRelease = null; r(); }
1017
1041
  };
1018
1042
  const early = [];
@@ -1043,7 +1067,7 @@
1043
1067
  };
1044
1068
  load.catch(() => giveUp('failed to load'));
1045
1069
  // Loaded but never registered (e.g. its own vendor file failed): don't hold forever
1046
- load.then(() => setTimeout(() => giveUp('has not started 10 s after loading'), 10000), () => { });
1070
+ load.then(() => setTimeout(() => giveUp('has not started 10 s after loading'), giveUpIn(u.plugin)), () => { });
1047
1071
  });
1048
1072
  const start = ready.then(() => {
1049
1073
  let restore = null;
@@ -1268,12 +1292,16 @@
1268
1292
  // Post-boot usage: component HTML, x-html and markdown content load the
1269
1293
  // on-use plugins they reference. Derive path only, like the boot sniff.
1270
1294
  let usageSniff = false;
1295
+ // Derive path: loadUsed works once the loader has queued its own modules; earlier calls wait for that
1296
+ let usageArmed = false;
1297
+ let usageGate = null;
1271
1298
  // A failed on-use load is not retried within this page load
1272
1299
  const usageFailed = new Set();
1273
1300
  // Settled loads only: a second caller waits on a load still in flight
1274
1301
  const usageLoaded = (p) => pluginsSettled.has(p) || usageFailed.has(p);
1275
1302
  function loadUsed(source, version = RESOLVED_VERSION) {
1276
- if (!usageSniff || !source || typeof document === 'undefined') return Promise.resolve([]);
1303
+ if (!usageArmed) return usageGate && source ? usageGate.promise.then(() => usageArmed ? loadUsed(source, version) : []) : Promise.resolve([]);
1304
+ if (!source || typeof document === 'undefined') return Promise.resolve([]);
1277
1305
  let root = source;
1278
1306
  if (typeof source === 'string') {
1279
1307
  if (source.indexOf('x-') === -1 && source.indexOf('$') === -1 && source.indexOf('<code') === -1) return Promise.resolve([]);
@@ -1290,11 +1318,22 @@
1290
1318
  if (!list.length) return Promise.resolve([]);
1291
1319
  // Prerender waits for the module and the adoption it schedules
1292
1320
  const release = window.ManifestPending ? window.ManifestPending.hold('module') : () => { };
1293
- return Promise.all(list.map(p => addScript(p, version).catch(error => {
1321
+ // On-use modules run as they arrive: nothing (Alpine included) queues behind them
1322
+ const ready = Promise.all(list.map(p => addScript(p, version, !lateEntries.some(u => u.plugin === p)).catch(error => {
1294
1323
  if (usageFailed.has(p)) return;
1295
1324
  usageFailed.add(p);
1296
1325
  console.warn(`[Manifest Loader] Failed to load plugin ${p}:`, error);
1297
- }))).then(() => new Promise(r => setTimeout(r, 0))).then(() => { release(); return list; });
1326
+ }))).then(() => Promise.all(list.map(started))).then(() => new Promise(r => setTimeout(r, 0)));
1327
+ ready.then(release);
1328
+ // Content waits at most 1.5 s: a slower module is left to the hold
1329
+ return Promise.race([ready, new Promise(r => setTimeout(r, USED_WAIT))]).then(() => list);
1330
+ }
1331
+ const USED_WAIT = 1500;
1332
+ // Its directive registered (Markdown waits for its parser first), at most 1.5 s after the file ran
1333
+ function started(p) {
1334
+ const u = lateEntries.find(e => e.plugin === p && e.attr);
1335
+ if (!u || !window[u.present] || usageFailed.has(p) || gaveUp.has(p) || preloaded.includes(p) || registered.has(u.attr.slice(2))) return null;
1336
+ return Promise.race([whenRegistered(u.attr.slice(2)), new Promise(r => setTimeout(r, Math.max(0, USED_WAIT - sinceRan(p))))]);
1298
1337
  }
1299
1338
 
1300
1339
  function watchUsage(version) {
@@ -1361,6 +1400,8 @@
1361
1400
  const plugins = script.getAttribute('data-modules') ?? script.getAttribute('data-plugins');
1362
1401
  const omit = script.getAttribute('data-omit');
1363
1402
  const tailwind = script.getAttribute('data-tailwind') !== null;
1403
+ // data-tailwind="cache": opt in to replaying the engine's stored output
1404
+ const tailwindCache = script.getAttribute('data-tailwind') === 'cache';
1364
1405
  const version = script.getAttribute('data-version') || DEFAULT_VERSION;
1365
1406
  const versionSet = !!script.getAttribute('data-version');
1366
1407
  const alpine = script.getAttribute('data-alpine');
@@ -1418,6 +1459,7 @@
1418
1459
  omitted,
1419
1460
  deriveFromManifest,
1420
1461
  tailwind,
1462
+ tailwindCache,
1421
1463
  version,
1422
1464
  versionSet,
1423
1465
  alpine,
@@ -1447,6 +1489,112 @@
1447
1489
  }
1448
1490
  }
1449
1491
 
1492
+ // Tailwind engine output cache: written and watched by the utilities module (manifest.utilities.tailwind-cache.js)
1493
+ const TAILWIND_ENGINE_VERSION = '4.3.1';
1494
+ const TAILWIND_CACHE_KEY = 'tailwind-engine-cache:v2';
1495
+ const TAILWIND_CACHE_MAX_AGE = 7 * 24 * 60 * 60 * 1000;
1496
+ function tailwindAuthorBlocks() {
1497
+ return Array.from(document.querySelectorAll('style[type="text/tailwindcss"]:not(#manifest-tailwind-variants)'), s => s.textContent);
1498
+ }
1499
+ // One entry per ordered set of author blocks
1500
+ function tailwindCacheId(v, blocks) {
1501
+ const text = [v, ...blocks].join('\u0000');
1502
+ let h = 0x811c9dc5;
1503
+ for (let i = 0; i < text.length; i++) h = Math.imul(h ^ text.charCodeAt(i), 0x01000193);
1504
+ return (h >>> 0).toString(36);
1505
+ }
1506
+ function placeTailwindCache(style) {
1507
+ const ours = document.getElementById('manifest-styles');
1508
+ document.head.insertBefore(style, ours && ours.parentNode === document.head ? ours : null);
1509
+ }
1510
+ const allStrings = (a) => Array.isArray(a) && a.every(x => typeof x === 'string');
1511
+ // Head fully parsed: replay only an entry built from exactly these blocks, in this order
1512
+ function tryTailwindReplay(state, index) {
1513
+ try {
1514
+ // A page that turned out to need a block in <body> goes straight to the engine
1515
+ const skipped = index.skip && index.skip[state.pathId];
1516
+ if (typeof skipped === 'number' && Date.now() - skipped >= 0 && Date.now() - skipped <= TAILWIND_CACHE_MAX_AGE) return false;
1517
+ const blocks = tailwindAuthorBlocks();
1518
+ const id = tailwindCacheId(state.v, blocks);
1519
+ const rec = JSON.parse(localStorage.getItem(`${TAILWIND_CACHE_KEY}:${id}`) || 'null');
1520
+ const age = rec ? Date.now() - rec.t : -1;
1521
+ if (!rec || rec.v !== state.v || typeof rec.css !== 'string' || !allStrings(rec.tokens) || !allStrings(rec.blocks)) return false;
1522
+ if (!(age >= 0 && age <= TAILWIND_CACHE_MAX_AGE) || rec.blocks.join('\u0000') !== blocks.join('\u0000') || rec.blocks.length !== blocks.length) return false;
1523
+ if (rec.body) return false;
1524
+ const style = document.createElement('style');
1525
+ style.setAttribute('data-tailwind-cache', '');
1526
+ style.textContent = rec.css;
1527
+ placeTailwindCache(style);
1528
+ Object.assign(state, { record: rec, style, id });
1529
+ return true;
1530
+ } catch (e) {
1531
+ return false;
1532
+ }
1533
+ }
1534
+ // Resolves true once the stored output is where the engine's sheet would go; decided when <head> is parsed, before first paint.
1535
+ // A <body> block, or a pathname skipped in the last 7 days, means the engine (SPA routes keep the first pathname's decision)
1536
+ function replayTailwindCache(cfg) {
1537
+ const miss = Promise.resolve(false);
1538
+ try {
1539
+ if (!cfg.tailwindCache || window.__manifestRender === true || window.__mnfstRun || isDevHost(location.hostname)) return miss;
1540
+ if (!cfg.plugins.includes('utilities') || staticUtilitiesFullyCovered()) return miss;
1541
+ if (document.querySelector('[data-mnfst-utilities], link[href*="prerender.tailwind.css"], link[href*="prerender.utilities.css"]')) return miss;
1542
+ const v = `${LOADER_VERSION}|${cfg.version}|${TAILWIND_ENGINE_VERSION}`;
1543
+ const state = window.__tailwindCache = { key: TAILWIND_CACHE_KEY, v, idFor: (blocks) => tailwindCacheId(v, blocks), pathId: tailwindCacheId('', [location.pathname]), record: null, armed: false };
1544
+ const index = JSON.parse(localStorage.getItem(TAILWIND_CACHE_KEY) || 'null');
1545
+ if (!index || !allStrings(index.ids) || !index.ids.length) return miss;
1546
+ return state.decision = new Promise(resolve => {
1547
+ let done = false;
1548
+ const decide = () => {
1549
+ if (done) return;
1550
+ done = true;
1551
+ const hit = tryTailwindReplay(state, index);
1552
+ if (hit) watchParsedTailwindBlocks(state, cfg.version);
1553
+ resolve(hit);
1554
+ };
1555
+ if (document.body) return decide();
1556
+ const o = new MutationObserver(() => { if (document.body) { o.disconnect(); decide(); } });
1557
+ o.observe(document.documentElement, { childList: true });
1558
+ document.addEventListener('DOMContentLoaded', () => { o.disconnect(); decide(); }, { once: true });
1559
+ });
1560
+ } catch (e) {
1561
+ return miss;
1562
+ }
1563
+ }
1564
+ // Until DOMContentLoaded: a parsed block the entry wasn't built from means it is another page's theme; engine now
1565
+ function watchParsedTailwindBlocks(state, version) {
1566
+ const o = new MutationObserver((records) => {
1567
+ for (const r of records) {
1568
+ for (const n of r.addedNodes) {
1569
+ if (n.localName !== 'style' || n.getAttribute('type') !== 'text/tailwindcss' || n.id === 'manifest-tailwind-variants') continue;
1570
+ const blocks = tailwindAuthorBlocks();
1571
+ if (blocks.length <= state.record.blocks.length && blocks.every((b, i) => b === state.record.blocks[i])) continue;
1572
+ o.disconnect();
1573
+ if (state.style) state.style.remove();
1574
+ Object.assign(state, { style: null, parsedMismatch: true });
1575
+ state.load = loadTailwind(version).catch(() => { });
1576
+ return;
1577
+ }
1578
+ }
1579
+ });
1580
+ o.observe(document.documentElement, { childList: true, subtree: true });
1581
+ document.addEventListener('DOMContentLoaded', () => o.disconnect(), { once: true });
1582
+ }
1583
+
1584
+ // Where the eager engine would have landed (after the module wave), or the engine itself if nothing armed
1585
+ function settleTailwindCache(version) {
1586
+ const state = window.__tailwindCache;
1587
+ if (!state || !state.style || !state.style.isConnected) return;
1588
+ if (!state.armed) {
1589
+ state.load = loadTailwind(version).catch(() => { });
1590
+ return;
1591
+ }
1592
+ let next = state.style.nextElementSibling;
1593
+ const isCss = (el) => (el.localName === 'style' && el.id !== 'manifest-styles' && el.getAttribute('type') !== 'text/tailwindcss') || (el.localName === 'link' && /\bstylesheet\b/i.test(el.rel));
1594
+ while (next && !isCss(next)) next = next.nextElementSibling;
1595
+ if (next) placeTailwindCache(state.style);
1596
+ }
1597
+
1450
1598
  // Load custom Tailwind CDN script, falling through the CDN chain on error
1451
1599
  async function loadTailwind(version = RESOLVED_VERSION) {
1452
1600
  const urls = CDN_HOSTS.map(h => `${getBaseUrl(version, h)}/${hostFile(h, 'manifest.tailwind.min.js')}`);
@@ -1638,6 +1786,7 @@
1638
1786
  return;
1639
1787
  }
1640
1788
  window.__manifestLoaderStarted = true;
1789
+ if (config.deriveFromManifest) { let resolve; usageGate = { promise: new Promise(r => { resolve = r; }), resolve }; }
1641
1790
 
1642
1791
  const MANIFEST_DEPENDENT_PLUGINS = [
1643
1792
  'data', 'localization', 'components',
@@ -1753,7 +1902,7 @@
1753
1902
  // On-use modules this page uses, while manifest.json may still be in flight
1754
1903
  if (config.deriveFromManifest) {
1755
1904
  const used = sniffBoot().used.filter(p => p !== 'components' && !_omitted.includes(p));
1756
- for (const p of resolveDependencies(used)) if (!config.plugins.includes(p)) hint('preload', getPluginUrl(p, config.version), 'script');
1905
+ for (const p of resolveDependencies(used)) if (!config.plugins.includes(p) && !pluginLoads.has(p)) hint('preload', getPluginUrl(p, config.version), 'script');
1757
1906
  }
1758
1907
  } catch (_) { /* optional */ }
1759
1908
  });
@@ -1800,8 +1949,12 @@
1800
1949
  console.warn(`[Manifest Loader] Failed to load plugin ${pluginName}:`, error);
1801
1950
  });
1802
1951
  });
1952
+ // Content fetched before the document is parsed (components) loads its modules now
1953
+ if (config.deriveFromManifest) { usageArmed = true; usageGate.resolve(); }
1803
1954
  if (config.tailwind && !staticUtilitiesFullyCovered()) {
1804
- pluginPromises.push(loadTailwind(config.version).catch(() => { }));
1955
+ pluginPromises.push(config.tailwindCache
1956
+ ? tailwindReplay.then(hit => hit ? null : loadTailwind(config.version)).catch(() => { })
1957
+ : loadTailwind(config.version).catch(() => { }));
1805
1958
  }
1806
1959
  // Usage sniff once the document is parsed: on-use modules download alongside the
1807
1960
  // rest and run before Alpine. Derive path only — an explicit data-modules list is an
@@ -1827,6 +1980,7 @@
1827
1980
  resolve(Promise.all(late));
1828
1981
  }));
1829
1982
  await Promise.all(pluginPromises);
1983
+ settleTailwindCache(config.version);
1830
1984
  if (manifestPromise) {
1831
1985
  manifest = await manifestPromise;
1832
1986
  }
@@ -1886,7 +2040,9 @@
1886
2040
  check();
1887
2041
  }
1888
2042
 
2043
+ const tailwindReplay = config.tailwindCache ? replayTailwindCache(config) : null;
1889
2044
  hintEarlyFetches();
1890
- loadPlugins();
2045
+ // Never leaves a loadUsed caller waiting, whatever stops the boot
2046
+ loadPlugins().finally(() => { if (usageGate) usageGate.resolve(); });
1891
2047
  }
1892
2048
  })();