mnfst 0.5.262 → 0.5.264

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.
@@ -321,6 +321,23 @@
321
321
  across copies. */
322
322
  if (!window.ManifestUI) {
323
323
  window.ManifestUI = {
324
+ // One cached evaluator per expression: each Alpine.evaluate would register a cleanup on <body>, never run
325
+ _eval(expr) {
326
+ const A = window.Alpine;
327
+ // Magics registered after an evaluator was built stay invisible to it, so a registration drops the cache
328
+ if (!A.magic.__manifestMagicCounted) {
329
+ const magic = A.magic;
330
+ A.magic = function () { window.__manifestMagicVersion = (window.__manifestMagicVersion || 0) + 1; return magic.apply(this, arguments); };
331
+ A.magic.__manifestMagicCounted = true;
332
+ }
333
+ const version = window.__manifestMagicVersion || 0;
334
+ if (!this._evals || this._evalsVersion !== version) { this._evals = new Map(); this._evalsVersion = version; }
335
+ let fn = this._evals.get(expr);
336
+ if (!fn) this._evals.set(expr, fn = A.evaluateLater(document.body, expr));
337
+ let out;
338
+ fn(v => { out = v; });
339
+ return out;
340
+ },
324
341
  _loadedSourceNames() {
325
342
  try {
326
343
  const store = window.ManifestDataStore && window.ManifestDataStore.rawDataStore;
@@ -331,11 +348,11 @@
331
348
  resolve(component, fallbacks) {
332
349
  const merged = JSON.parse(JSON.stringify(fallbacks || {}));
333
350
  try {
334
- if (!window.Alpine || typeof Alpine.evaluate !== 'function') return merged;
335
- try { Alpine.evaluate(document.body, 'typeof $locale !== "undefined" && $locale.current'); } catch (_) { } // dep → re-resolve on locale switch
351
+ if (!window.Alpine || typeof Alpine.evaluateLater !== 'function') return merged;
352
+ try { this._eval('typeof $locale !== "undefined" && $locale.current'); } catch (_) { } // dep → re-resolve on locale switch
336
353
  for (const name of this._loadedSourceNames()) {
337
354
  let ui;
338
- try { ui = Alpine.evaluate(document.body, `$x['${name}'] && $x['${name}']._ui && $x['${name}']._ui['${component}']`); } catch (_) { ui = null; }
355
+ try { ui = this._eval(`$x['${name}'] && $x['${name}']._ui && $x['${name}']._ui['${component}']`); } catch (_) { ui = null; }
339
356
  if (ui && typeof ui === 'object' && !Array.isArray(ui)) this._deepOverlay(merged, ui);
340
357
  }
341
358
  } catch (_) { }
@@ -532,7 +549,7 @@
532
549
  try {
533
550
  if (window.Alpine?.evaluate) {
534
551
  const expr = isBareRef && !hasInterp ? trimmed : '`' + trimmed + '`';
535
- const out = Alpine.evaluate(document.body, expr);
552
+ const out = window.ManifestUI?._eval ? window.ManifestUI._eval(expr) : Alpine.evaluate(document.body, expr);
536
553
  if (out == null) return val;
537
554
  return typeof out === 'string' ? out : String(out);
538
555
  }
@@ -16,7 +16,7 @@
16
16
 
17
17
  // Build stamps the published version here; unstamped (dev) falls back to the
18
18
  // registration URL's `v`, then 'dev'.
19
- const BUILD_VERSION = '0.5.262';
19
+ const BUILD_VERSION = '0.5.264';
20
20
  const CACHE_PREFIX = 'mnfst-sw:';
21
21
  const META_CACHE = CACHE_PREFIX + 'meta';
22
22
  // Sized to hold a full precache.json warm-up (PRECACHE_MAX_ENTRIES server-side)
@@ -551,5 +551,5 @@ ${L}`)}}))m.get(y)?.(C);for(let y of h)y(C);if(p){let y=[];for(let[z,L]of C.them
551
551
  --max-width-prose: 65ch;
552
552
  }
553
553
  `;var Mo=`@tailwind utilities;
554
- `;var Ye={index:jo,preflight:Io,theme:Fo,utilities:Mo};var At=class{start(r){performance.mark(`${r} (start)`)}end(r,o){performance.mark(`${r} (end)`),performance.measure(r,{start:`${r} (start)`,end:`${r} (end)`,detail:o})}hit(r,o){performance.mark(r,{detail:o})}error(r){throw performance.mark("(error)",{detail:{error:`${r}`}}),r}};var Bo="text/tailwindcss",Ct,or=new Set,rr="",ir=document.createElement("style"),Wo=Promise.resolve(),Xn=1,ie=new At;async function el(){ie.start("Create compiler"),ie.start("Reading Stylesheets");let e=document.querySelectorAll(`style[type="${Bo}"]`),r="";for(let o of e)qo(o),r+=o.textContent+`
555
- `;if(r.includes("@import")||(r=`@import "tailwindcss";${r}`),ie.end("Reading Stylesheets",{size:r.length,changed:rr!==r}),rr!==r){rr=r,ie.start("Compile CSS");try{Ct=await Ko(r,{base:"/",loadStylesheet:tl,loadModule:rl})}finally{ie.end("Compile CSS"),ie.end("Create compiler")}or.clear()}}async function tl(e,r){function o(){if(e==="tailwindcss")return{path:"virtual:tailwindcss/index.css",base:r,content:Ye.index};if(e==="tailwindcss/preflight"||e==="tailwindcss/preflight.css"||e==="./preflight.css")return{path:"virtual:tailwindcss/preflight.css",base:r,content:Ye.preflight};if(e==="tailwindcss/theme"||e==="tailwindcss/theme.css"||e==="./theme.css")return{path:"virtual:tailwindcss/theme.css",base:r,content:Ye.theme};if(e==="tailwindcss/utilities"||e==="tailwindcss/utilities.css"||e==="./utilities.css")return{path:"virtual:tailwindcss/utilities.css",base:r,content:Ye.utilities};throw new Error(`The browser build does not support @import for "${e}"`)}try{let t=o();return ie.hit("Loaded stylesheet",{id:e,base:r,size:t.content.length}),t}catch(t){throw ie.hit("Failed to load stylesheet",{id:e,base:r,error:t.message??t}),t}}async function rl(){throw new Error("The browser build does not support plugins or config files.")}async function ol(e){if(!Ct)return;let r=new Set;ie.start("Collect classes");for(let o of document.querySelectorAll("[class]"))for(let t of o.classList)or.has(t)||(or.add(t),r.add(t));ie.end("Collect classes",{count:r.size}),!(r.size===0&&e==="incremental")&&(ie.start("Build utilities"),ir.textContent=Ct.build(Array.from(r)),ie.end("Build utilities"))}function Nt(e){async function r(){if(!Ct&&e!=="full")return;let o=Xn++;ie.start(`Build #${o} (${e})`),e==="full"&&await el(),ie.start("Build"),await ol(e),ie.end("Build"),ie.end(`Build #${o} (${e})`)}Wo=Wo.then(r).catch(o=>ie.error(o))}var il=new MutationObserver(()=>Nt("full"));function qo(e){il.observe(e,{attributes:!0,attributeFilter:["type"],characterData:!0,subtree:!0,childList:!0})}new MutationObserver(e=>{let r=0,o=0;for(let t of e){for(let l of t.addedNodes)l.nodeType===Node.ELEMENT_NODE&&l.tagName==="STYLE"&&l.getAttribute("type")===Bo&&(qo(l),r++);for(let l of t.addedNodes)l.nodeType===1&&l!==ir&&o++;t.type==="attributes"&&o++}if(r>0)return Nt("full");if(o>0)return Nt("incremental")}).observe(document.documentElement,{attributes:!0,attributeFilter:["class"],childList:!0,subtree:!0});Nt("full");document.head.append(ir);})();
554
+ `;var Ye={index:jo,preflight:Io,theme:Fo,utilities:Mo};var At=class{start(r){}end(r,o){}hit(r,o){}error(r){throw r}};var dirtyTrees=new Set,dirtySelves=new Set;var Bo="text/tailwindcss",Ct,or=new Set,rr="",ir=document.createElement("style"),Wo=Promise.resolve(),Xn=1,ie=new At;async function el(){ie.start("Create compiler"),ie.start("Reading Stylesheets");let e=document.querySelectorAll(`style[type="${Bo}"]`),r="";for(let o of e)qo(o),r+=o.textContent+`
555
+ `;if(r.includes("@import")||(r=`@import "tailwindcss";${r}`),ie.end("Reading Stylesheets",{size:r.length,changed:rr!==r}),rr!==r){rr=r,ie.start("Compile CSS");try{Ct=await Ko(r,{base:"/",loadStylesheet:tl,loadModule:rl})}finally{ie.end("Compile CSS"),ie.end("Create compiler")}or.clear()}}async function tl(e,r){function o(){if(e==="tailwindcss")return{path:"virtual:tailwindcss/index.css",base:r,content:Ye.index};if(e==="tailwindcss/preflight"||e==="tailwindcss/preflight.css"||e==="./preflight.css")return{path:"virtual:tailwindcss/preflight.css",base:r,content:Ye.preflight};if(e==="tailwindcss/theme"||e==="tailwindcss/theme.css"||e==="./theme.css")return{path:"virtual:tailwindcss/theme.css",base:r,content:Ye.theme};if(e==="tailwindcss/utilities"||e==="tailwindcss/utilities.css"||e==="./utilities.css")return{path:"virtual:tailwindcss/utilities.css",base:r,content:Ye.utilities};throw new Error(`The browser build does not support @import for "${e}"`)}try{let t=o();return ie.hit("Loaded stylesheet",{id:e,base:r,size:t.content.length}),t}catch(t){throw ie.hit("Failed to load stylesheet",{id:e,base:r,error:t.message??t}),t}}async function rl(){throw new Error("The browser build does not support plugins or config files.")}async function ol(e){if(!Ct)return;let r=new Set;ie.start("Collect classes");let addClasses=o=>{for(let t of o.classList)or.has(t)||(or.add(t),r.add(t))};if(e==="incremental"){for(let o of dirtySelves)addClasses(o);for(let o of dirtyTrees){addClasses(o);for(let t of o.querySelectorAll("[class]"))addClasses(t)}}else for(let o of document.querySelectorAll("[class]"))addClasses(o);dirtyTrees.clear(),dirtySelves.clear();ie.end("Collect classes",{count:r.size}),!(r.size===0&&e==="incremental")&&(ie.start("Build utilities"),ir.textContent=Ct.build(Array.from(r)),ie.end("Build utilities"))}function Nt(e){async function r(){if(!Ct&&e!=="full")return;let o=Xn++;ie.start(`Build #${o} (${e})`),e==="full"&&await el(),ie.start("Build"),await ol(e),ie.end("Build"),ie.end(`Build #${o} (${e})`)}Wo=Wo.then(r).catch(o=>(dirtyTrees.clear(),dirtySelves.clear(),ie.error(o)))}var il=new MutationObserver(()=>Nt("full"));function qo(e){il.observe(e,{attributes:!0,attributeFilter:["type"],characterData:!0,subtree:!0,childList:!0})}new MutationObserver(e=>{let r=0,o=0;for(let t of e){for(let l of t.addedNodes)l.nodeType===Node.ELEMENT_NODE&&l.tagName==="STYLE"&&l.getAttribute("type")===Bo&&(qo(l),r++);for(let l of t.addedNodes)l.nodeType===1&&l!==ir&&(dirtyTrees.add(l),o++);t.type==="attributes"&&(dirtySelves.add(t.target),o++)}if(r>0)return Nt("full");if(o>0)return Nt("incremental")}).observe(document.documentElement,{attributes:!0,attributeFilter:["class"],childList:!0,subtree:!0});Nt("full");document.head.append(ir);})();
@@ -241,6 +241,7 @@ function initializeVirtualPlugin() {
241
241
 
242
242
  const visible = new Set();
243
243
  const keys = [];
244
+ const items = [];
244
245
  for (let i = startItem; i < endItem; i++) {
245
246
  const item = data[i];
246
247
  if (item == null) continue;
@@ -248,15 +249,35 @@ function initializeVirtualPlugin() {
248
249
  if (key == null) continue;
249
250
  visible.add(key);
250
251
  keys.push(key);
251
- let entry = rendered.get(key);
252
- if (!entry) entry = mountRow(item, key);
253
- else if (entry.scope[itemName] !== item) entry.scope[itemName] = item; // rebind by key
254
- host.insertBefore(entry.node, botSpacer); // keep DOM order = data order
252
+ items.push(item);
255
253
  }
256
254
  for (const [key, entry] of rendered) {
257
255
  if (!visible.has(key)) removeRow(key, entry);
258
256
  }
259
257
 
258
+ // Keep DOM order = data order, moving only rows out of place
259
+ const rowNodes = new Set();
260
+ for (const entry of rendered.values()) rowNodes.add(entry.node);
261
+ // Next row in the host; skips what a row root rendered (x-if clones), survives a row's init detaching it
262
+ const nextRow = (n) => {
263
+ while (n && n !== botSpacer && n.parentNode === host && !rowNodes.has(n)) n = n.nextSibling;
264
+ return n && n.parentNode === host ? n : botSpacer;
265
+ };
266
+ let cursor = nextRow(topSpacer.nextSibling);
267
+ for (let i = 0; i < keys.length; i++) {
268
+ if (cursor.parentNode !== host) cursor = botSpacer;
269
+ let entry = rendered.get(keys[i]);
270
+ if (!entry) {
271
+ entry = mountRow(items[i], keys[i], cursor);
272
+ rowNodes.add(entry.node);
273
+ if (entry.node.parentNode !== host) host.insertBefore(entry.node, cursor); // root replaced itself in init
274
+ continue;
275
+ }
276
+ if (entry.scope[itemName] !== items[i]) entry.scope[itemName] = items[i]; // rebind by key
277
+ if (entry.node === cursor) cursor = nextRow(cursor.nextSibling);
278
+ else host.insertBefore(entry.node, cursor);
279
+ }
280
+
260
281
  // Measure anything not yet measured, then reconcile offsets once.
261
282
  scheduleMeasure(keys);
262
283
  }
@@ -306,10 +327,10 @@ function initializeVirtualPlugin() {
306
327
  scheduleMeasure(keys);
307
328
  }
308
329
 
309
- function mountRow(item, key) {
330
+ function mountRow(item, key, before = anchor) {
310
331
  const tpl = template.content.firstElementChild;
311
332
  const node = tpl.cloneNode(true);
312
- host.insertBefore(node, anchor); // connect before init
333
+ host.insertBefore(node, before); // connect before init
313
334
  const scope = Alpine.reactive({ [itemName]: item });
314
335
  const removeScope = Alpine.addScopeToNode(node, scope);
315
336
  Alpine.initTree(node);
@@ -422,11 +443,12 @@ function initializeVirtualPlugin() {
422
443
 
423
444
  // ---- Scroll / resize ----
424
445
 
446
+ let destroyed = false;
425
447
  let scrollScheduled = false;
426
448
  const onScroll = () => {
427
449
  if (scrollScheduled) return;
428
450
  scrollScheduled = true;
429
- requestAnimationFrame(() => { scrollScheduled = false; render(); });
451
+ requestAnimationFrame(() => { scrollScheduled = false; if (!destroyed) render(); });
430
452
  };
431
453
  scrollEl.addEventListener('scroll', onScroll, { passive: true });
432
454
 
@@ -440,6 +462,7 @@ function initializeVirtualPlugin() {
440
462
  if (!kind && !isMasonry && host !== scrollEl) ro.observe(host); // only until a hidden host is classified
441
463
 
442
464
  cleanup(() => {
465
+ destroyed = true;
443
466
  scrollEl.removeEventListener('scroll', onScroll);
444
467
  ro.disconnect();
445
468
  clearTimeout(resizeTimer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.262",
3
+ "version": "0.5.264",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",