mnfst 0.5.261 → 0.5.263

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.261';
19
+ const BUILD_VERSION = '0.5.263';
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);})();
@@ -171,6 +171,7 @@ function initializeTooltipPlugin() {
171
171
  s.el.style.setProperty('position-anchor', anchorName);
172
172
 
173
173
  s.activeTrigger = trigger;
174
+ trigger._tooltipSingleton = s;
174
175
  s.currentAnchorName = anchorName;
175
176
 
176
177
  // A11y: aria-describedby links trigger → tooltip for screen readers.
@@ -212,7 +213,20 @@ function initializeTooltipPlugin() {
212
213
 
213
214
  // ---- Directive ----
214
215
 
215
- Alpine.directive('tooltip', (el, { modifiers, expression }, { effect, evaluateLater }) => {
216
+ Alpine.directive('tooltip', (el, { modifiers, expression }, { effect, evaluateLater, cleanup }) => {
217
+ const listeners = new AbortController();
218
+ const { signal } = listeners;
219
+ cleanup(() => {
220
+ listeners.abort();
221
+ if (_pendingTrigger === el) cancelPendingShow();
222
+ // A removal root is already detached here, so its host can't be looked up
223
+ const s = el._tooltipSingleton;
224
+ el._tooltipSingleton = null;
225
+ if (s && s.activeTrigger === el) {
226
+ if (s.el.matches(':popover-open')) s.el.hidePopover();
227
+ s.activeTrigger = null;
228
+ }
229
+ });
216
230
 
217
231
  // --- Content ---
218
232
  // Escape by default; author literal HTML or .html/.safe opts in.
@@ -288,15 +302,15 @@ function initializeTooltipPlugin() {
288
302
  };
289
303
 
290
304
  // Mouse interactions
291
- el.addEventListener('mouseenter', requestShow);
292
- el.addEventListener('mouseleave', requestHide);
305
+ el.addEventListener('mouseenter', requestShow, { signal });
306
+ el.addEventListener('mouseleave', requestHide, { signal });
293
307
 
294
308
  // Keyboard focus (WCAG 2.1 SC 1.4.13). Gated on :focus-visible so mouse-click
295
309
  // focus doesn't flash the tooltip.
296
310
  el.addEventListener('focus', () => {
297
311
  if (el.matches(':focus-visible')) requestShow();
298
- });
299
- el.addEventListener('blur', requestHide);
312
+ }, { signal });
313
+ el.addEventListener('blur', requestHide, { signal });
300
314
 
301
315
  // Mousedown/click hides now and clears the chain window, so a synthetic
302
316
  // re-hover (content shifting under the cursor) waits the full delay.
@@ -305,8 +319,8 @@ function initializeTooltipPlugin() {
305
319
  hideAnySingleton();
306
320
  clearChainWindow();
307
321
  };
308
- el.addEventListener('mousedown', hideOnInteraction);
309
- el.addEventListener('click', hideOnInteraction);
322
+ el.addEventListener('mousedown', hideOnInteraction, { signal });
323
+ el.addEventListener('click', hideOnInteraction, { signal });
310
324
  });
311
325
 
312
326
  // Global: when ANY other popover opens, close the singleton(s). Dropdowns and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.261",
3
+ "version": "0.5.263",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",