@aevantec/litevue 0.6.1 → 0.6.3

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.
Files changed (97) hide show
  1. package/dist/litevue-devtools.iife.js +1 -1
  2. package/dist/litevue-devtools.mjs +1 -1
  3. package/dist/litevue-devtools.umd.js +1 -1
  4. package/dist/litevue-plugins.dev.iife.js +67 -125
  5. package/dist/litevue-plugins.dev.mjs +67 -124
  6. package/dist/litevue-plugins.iife.js +1 -1
  7. package/dist/litevue-plugins.mjs +1 -1
  8. package/dist/litevue-plugins.umd.js +1 -1
  9. package/dist/litevue.dev.iife.js +122 -159
  10. package/dist/litevue.dev.mjs +122 -158
  11. package/dist/litevue.iife.js +1 -1
  12. package/dist/litevue.mjs +1 -1
  13. package/dist/litevue.umd.js +1 -1
  14. package/dist/plugins/collapse.iife.js +1 -1
  15. package/dist/plugins/collapse.mjs +1 -1
  16. package/dist/plugins/collapse.umd.js +1 -1
  17. package/dist/plugins/focus.iife.js +1 -1
  18. package/dist/plugins/focus.mjs +1 -1
  19. package/dist/plugins/focus.umd.js +1 -1
  20. package/dist/plugins/intersect.iife.js +1 -1
  21. package/dist/plugins/intersect.umd.js +1 -1
  22. package/dist/plugins/mask.iife.js +1 -1
  23. package/dist/plugins/mask.mjs +1 -1
  24. package/dist/plugins/mask.umd.js +1 -1
  25. package/dist/plugins/media.dev.iife.js +5 -39
  26. package/dist/plugins/media.dev.mjs +5 -38
  27. package/dist/plugins/media.iife.js +1 -1
  28. package/dist/plugins/media.mjs +1 -1
  29. package/dist/plugins/media.umd.js +1 -1
  30. package/dist/plugins/morph.dev.iife.js +41 -61
  31. package/dist/plugins/morph.dev.mjs +41 -60
  32. package/dist/plugins/morph.iife.js +1 -1
  33. package/dist/plugins/morph.mjs +1 -1
  34. package/dist/plugins/morph.umd.js +1 -1
  35. package/dist/plugins/navigate.dev.iife.js +24 -26
  36. package/dist/plugins/navigate.dev.mjs +24 -25
  37. package/dist/plugins/navigate.iife.js +1 -1
  38. package/dist/plugins/navigate.mjs +1 -1
  39. package/dist/plugins/navigate.umd.js +1 -1
  40. package/dist/plugins/persist.dev.iife.js +2 -10
  41. package/dist/plugins/persist.dev.mjs +2 -9
  42. package/dist/plugins/persist.iife.js +1 -1
  43. package/dist/plugins/persist.mjs +1 -1
  44. package/dist/plugins/persist.umd.js +1 -1
  45. package/dist/plugins/popover.iife.js +1 -1
  46. package/dist/plugins/popover.mjs +1 -1
  47. package/dist/plugins/popover.umd.js +1 -1
  48. package/dist/plugins/resize.iife.js +1 -1
  49. package/dist/plugins/resize.umd.js +1 -1
  50. package/dist/plugins/transition.iife.js +1 -1
  51. package/dist/plugins/transition.mjs +1 -1
  52. package/dist/plugins/transition.umd.js +1 -1
  53. package/dist/types/app.d.mts +5 -6
  54. package/dist/types/app.d.ts +5 -6
  55. package/dist/types/block.d.mts +0 -4
  56. package/dist/types/block.d.ts +0 -4
  57. package/dist/types/context.d.mts +1 -6
  58. package/dist/types/context.d.ts +1 -6
  59. package/dist/types/devtools-panel/chrome.d.mts +5 -7
  60. package/dist/types/devtools-panel/chrome.d.ts +5 -7
  61. package/dist/types/devtools-panel/menu.d.mts +10 -0
  62. package/dist/types/devtools-panel/menu.d.ts +10 -0
  63. package/dist/types/devtools-panel/plugins.d.mts +0 -4
  64. package/dist/types/devtools-panel/plugins.d.ts +0 -4
  65. package/dist/types/devtools-panel/styles.d.mts +3 -15
  66. package/dist/types/devtools-panel/styles.d.ts +3 -15
  67. package/dist/types/devtools-panel/values.d.mts +1 -20
  68. package/dist/types/devtools-panel/values.d.ts +1 -20
  69. package/dist/types/devtools.d.mts +0 -7
  70. package/dist/types/devtools.d.ts +0 -7
  71. package/dist/types/directives/on.d.mts +0 -1
  72. package/dist/types/directives/on.d.ts +0 -1
  73. package/dist/types/directives/show.d.mts +1 -0
  74. package/dist/types/directives/show.d.ts +1 -0
  75. package/dist/types/errors.d.mts +1 -8
  76. package/dist/types/errors.d.ts +1 -8
  77. package/dist/types/eval.d.mts +0 -3
  78. package/dist/types/eval.d.ts +0 -3
  79. package/dist/types/lazy.d.mts +0 -10
  80. package/dist/types/lazy.d.ts +0 -10
  81. package/dist/types/magics.d.mts +0 -9
  82. package/dist/types/magics.d.ts +0 -9
  83. package/dist/types/ownership.d.mts +0 -19
  84. package/dist/types/ownership.d.ts +0 -19
  85. package/dist/types/plugins/media/index.d.mts +0 -5
  86. package/dist/types/plugins/media/index.d.ts +0 -5
  87. package/dist/types/plugins/morph/index.d.mts +0 -8
  88. package/dist/types/plugins/morph/index.d.ts +0 -8
  89. package/dist/types/scheduler.d.mts +0 -5
  90. package/dist/types/scheduler.d.ts +0 -5
  91. package/dist/types/store.d.mts +5 -1
  92. package/dist/types/store.d.ts +5 -1
  93. package/dist/types/utils.d.mts +0 -5
  94. package/dist/types/utils.d.ts +0 -5
  95. package/dist/types/warn.d.mts +0 -12
  96. package/dist/types/warn.d.ts +0 -12
  97. package/package.json +3 -3
@@ -1,19 +1,9 @@
1
1
  // src/plugins/morph/index.ts
2
- /**
3
- * A `data-` attribute rather than `v-preserve`: an unrecognised `v-` attribute
4
- * logs an unknown-directive error, and registering one would have the walker
5
- * strip it, leaving nothing for the next morph. Matches `data-morph-skip`.
6
- */
7
2
  var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || node.__marker || !!opts.preserve?.(node));
3
+ var LAZY = "[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]";
8
4
  var dirRE = /^(?:v-|:|@)/;
9
5
  var bindRE = /^(?::|v-bind:)/;
10
6
  var clientStyleRE = /^v-(?!scope|on:)/;
11
- /**
12
- * Attributes tried in order when no `key` option is given. All three express
13
- * identity, so none repeat among siblings the way `name` does on a radio group
14
- * — hence its absence. The attribute name is part of the key, so `id="5"` and
15
- * `data-id="5"` stay distinct.
16
- */
17
7
  var KEY_ATTRS = [
18
8
  "id",
19
9
  "data-key",
@@ -26,44 +16,28 @@ var defaultKey = (el) => {
26
16
  }
27
17
  return null;
28
18
  };
29
- /**
30
- * The nearest stashed context, walking up from a live node. `v-scope` elements
31
- * record theirs during walk, so inserted markup binds with the scope it landed
32
- * in rather than the root.
33
- */
34
19
  var nearestCtx = (node) => {
35
20
  for (let el = node; el; el = el.parentElement) if (el.__ctx) return el.__ctx;
36
21
  };
37
- /**
38
- * Disposal is per node, so any context can release any subtree. Outside every
39
- * scope there is no parent context to ask, but a root inside the subtree has
40
- * one; without this, its effects and listeners outlive it.
41
- */
42
22
  var ctxIn = (n) => n.__ctx || [...n.children || []].map(ctxIn).find(Boolean);
43
23
  var release = (node, ctx) => (ctx || ctxIn(node))?.dispose?.(node);
44
- /**
45
- * Attributes the client owns, read from the *incoming* markup — it still
46
- * carries the directives the live DOM had stripped. `:class` there means the
47
- * live `class` is bound and must survive the server's static value.
48
- */
49
24
  var boundAttrs = (to) => {
50
25
  const owned = /* @__PURE__ */ new Set();
51
26
  if (to.matches("details,dialog")) owned.add("open");
52
- for (const { name } of to.attributes) if (bindRE.test(name)) owned.add(name.replace(bindRE, "").split(".")[0]);
53
- else if (name === "v-model") {
27
+ for (const { name } of to.attributes) if (bindRE.test(name)) {
28
+ const attr = name.replace(bindRE, "").split(".")[0];
29
+ owned.add(/\.camel\b/.test(name) ? attr.replace(/-(\w)/g, (_, c) => c.toUpperCase()) : attr);
30
+ } else if (/^v-model\b/.test(name)) {
54
31
  owned.add("value");
55
32
  owned.add("checked");
56
33
  } else if (name === "v-bind") owned.add("*");
57
- else if (clientStyleRE.test(name)) owned.add("style");
34
+ else if (clientStyleRE.test(name)) {
35
+ owned.add("style");
36
+ name == "v-popover" && owned.add("popover");
37
+ }
58
38
  return owned;
59
39
  };
60
- /**
61
- * `v-for` and `v-if` render into Blocks: the live DOM holds anchors plus the
62
- * clones the data produced, while the server still sends one template. Matched
63
- * positionally, the rest would be deleted as "no longer sent".
64
- */
65
40
  var isBlockRoot = (el) => el.hasAttribute("v-for") || el.hasAttribute("v-if") || el.hasAttribute("v-else") || el.hasAttribute("v-else-if");
66
- /** True when the client, not the server, decides this element's contents. */
67
41
  var ownsChildren = (to) => {
68
42
  if (to.hasAttribute("v-text") || to.hasAttribute("v-html") || to.hasAttribute("v-pre") || to.hasAttribute("v-once") || isBlockRoot(to)) return true;
69
43
  for (let c = to.firstElementChild; c; c = c.nextElementSibling) if (isBlockRoot(c)) return true;
@@ -76,15 +50,18 @@ var FIELD_PROPS = [
76
50
  ];
77
51
  var syncValues = (from, to, owned) => {
78
52
  const ctl = boundAttrs(to.closest("select") || to);
79
- if (owned.has("*") || ctl.has("*") || ctl.has("value")) return;
53
+ if (owned.has("*") || ctl.has("*") || ctl.has("value") || from.type == "output" || from.type == "textarea" && to.value.includes("{{")) return;
80
54
  for (const name of FIELD_PROPS) {
81
55
  const prop = name.toLowerCase();
82
56
  const init = "default" + name;
83
- if (!owned.has(prop) && init in from && from[prop] !== to[init]) from[prop] = to[init];
57
+ const src = name == "Selected" ? init : prop;
58
+ if (!owned.has(prop) && init in from && from[prop] !== to[src]) from[prop] = to[src];
84
59
  }
85
60
  };
86
61
  var patchAttrs = (from, to, values) => {
87
62
  const owned = boundAttrs(to);
63
+ if (from.__anchor) owned.add("style");
64
+ for (const name of from.constructor.morphOwnedAttributes || []) owned.add(name);
88
65
  if (values) syncValues(from, to, owned);
89
66
  const bound = Object(from.__bound);
90
67
  for (const { name, value } of to.attributes) {
@@ -96,16 +73,12 @@ var patchAttrs = (from, to, values) => {
96
73
  from.removeAttribute(name);
97
74
  }
98
75
  };
99
- /**
100
- * Incoming text still holding `{{ }}` is rendered by a text directive on the
101
- * live side, so the live value wins.
102
- */
103
76
  var isInterpolation = (data, ctx) => data.includes(ctx ? ctx.delimiters[0] : "{{");
104
77
  var patchNode = (from, to, ctx, opts) => {
105
78
  if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx, opts);
106
79
  if (from.nodeType === 3 || from.nodeType === 8) {
107
80
  const data = to.data;
108
- if (isInterpolation(data, ctx)) return;
81
+ if (isInterpolation(data, ctx) && from.parentNode?.nodeName != "SCRIPT") return;
109
82
  if (!from.data) return replaceNode(from, to, ctx, opts);
110
83
  if (from.data !== data) from.data = data;
111
84
  return;
@@ -115,9 +88,10 @@ var patchNode = (from, to, ctx, opts) => {
115
88
  const b = to;
116
89
  if (a.tagName !== b.tagName) return replaceNode(from, to, ctx, opts);
117
90
  if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
91
+ if (a.matches(LAZY)) return a.isEqualNode(b) ? void 0 : replaceNode(from, to, ctx, opts);
118
92
  patchAttrs(a, b, opts.values);
119
- if (a.tagName == "TEMPLATE") a.innerHTML = b.innerHTML;
120
- if (!ownsChildren(b) && !a.__ctx?.scope.$template) patchChildren(a, b, a.__ctx || ctx, opts);
93
+ if (a.tagName == "TEMPLATE" && !a.content.isEqualNode(b.content)) a.innerHTML = b.innerHTML;
94
+ if (!ownsChildren(b) && !Object.getOwnPropertyDescriptor(Object(a.__ctx?.scope), "$template")) patchChildren(a, b, a.__ctx || ctx, opts);
121
95
  };
122
96
  var replaceNode = (from, to, ctx, opts) => {
123
97
  if (preserved(from, opts)) return;
@@ -127,14 +101,10 @@ var replaceNode = (from, to, ctx, opts) => {
127
101
  from.parentNode.replaceChild(fresh, from);
128
102
  opts.afterNodeRemoved?.(from);
129
103
  mountNew(fresh, ctx);
104
+ return fresh;
130
105
  };
131
- /**
132
- * Bind never-walked markup with the scope it was inserted into. The walker
133
- * comes off the context, not an import, so this plugin doesn't pull a second
134
- * copy of the core into the plugins bundle.
135
- */
136
106
  var mountNew = (node, ctx) => {
137
- if (node.parentElement?.closest("[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]")) return;
107
+ if (node.parentElement?.closest(LAZY)) return;
138
108
  const target = ctx || nearestCtx(node.parentNode);
139
109
  target?.walk?.(node, target);
140
110
  };
@@ -148,6 +118,15 @@ var patchChildren = (from, to, ctx, opts) => {
148
118
  keyed.set(k, n);
149
119
  }
150
120
  const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
121
+ const wanted = /* @__PURE__ */ new Set();
122
+ for (let n = to.firstChild; n; n = n.nextSibling) wanted.add(keyOf(n));
123
+ const drop = (node) => {
124
+ if (!preserved(node, opts)) {
125
+ release(node, ctx);
126
+ from.removeChild(node);
127
+ opts.afterNodeRemoved?.(node);
128
+ }
129
+ };
151
130
  let oldChild = from.firstChild;
152
131
  let newChild = to.firstChild;
153
132
  const insert = (node) => {
@@ -168,7 +147,7 @@ var patchChildren = (from, to, ctx, opts) => {
168
147
  keyed.delete(wantKey);
169
148
  patchNode(match, newChild, ctx, opts);
170
149
  } else insert(newChild);
171
- } else if (oldChild && keyOf(oldChild) == null) {
150
+ } else if (oldChild && (keyOf(oldChild) == null || !wanted.has(keyOf(oldChild)) && oldChild.tagName === newChild.tagName)) {
172
151
  if (preserved(oldChild, opts) && !preserved(newChild, opts)) {
173
152
  oldChild = oldChild.nextSibling;
174
153
  continue;
@@ -176,16 +155,17 @@ var patchChildren = (from, to, ctx, opts) => {
176
155
  const nextOld = oldChild.nextSibling;
177
156
  patchNode(oldChild, newChild, ctx, opts);
178
157
  oldChild = nextOld;
158
+ } else if (oldChild && !wanted.has(keyOf(oldChild))) {
159
+ const nextOld = oldChild.nextSibling;
160
+ drop(oldChild);
161
+ oldChild = nextOld;
162
+ continue;
179
163
  } else insert(newChild);
180
164
  newChild = nextNew;
181
165
  }
182
166
  while (oldChild) {
183
167
  const next = oldChild.nextSibling;
184
- if (!preserved(oldChild, opts)) {
185
- release(oldChild, ctx);
186
- from.removeChild(oldChild);
187
- opts.afterNodeRemoved?.(oldChild);
188
- }
168
+ drop(oldChild);
189
169
  oldChild = next;
190
170
  }
191
171
  };
@@ -197,18 +177,19 @@ var morph = (from, to, opts = {}) => {
197
177
  let target;
198
178
  if (typeof to === "string") {
199
179
  const holder = document.createElement("template");
200
- holder.innerHTML = to.trim();
201
- const content = holder.content;
180
+ const svg = from instanceof SVGElement;
181
+ holder.innerHTML = svg ? `<svg>${to.trim()}</svg>` : to.trim();
182
+ const content = svg ? holder.content.firstChild : holder.content;
202
183
  target = content.childNodes.length === 1 && content.firstElementChild ? content.firstElementChild : (() => {
203
184
  const wrapper = from.cloneNode(false);
204
- wrapper.appendChild(content);
185
+ wrapper.append(...content.childNodes);
205
186
  return wrapper;
206
187
  })();
207
188
  } else target = to;
208
189
  if (target) {
209
190
  const patch = () => {
210
191
  const restore = captureFocus();
211
- patchNode(from, target, nearestCtx(from), opts);
192
+ from = patchNode(from, target, nearestCtx(from.parentNode), opts) || from;
212
193
  restore();
213
194
  };
214
195
  opts.transition && document.startViewTransition ? document.startViewTransition(patch) : patch();
@@ -1 +1 @@
1
- var LiteVueMorph=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),n=/^(?:v-|:|@)/,o=/^(?::|v-bind:)/,r=/^v-(?!scope|on:)/,i=["id","data-key","data-id"],s=e=>{for(const t of i){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},a=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},l=e=>e.__ctx||[...e.children||[]].map(l).find(Boolean),d=(e,t)=>(t||l(e))?.dispose?.(e),c=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)o.test(n)?t.add(n.replace(o,"").split(".")[0]):"v-model"===n?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):r.test(n)&&t.add("style");return t},u=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),f=["Value","Checked","Selected"],h=(e,t,o)=>{const r=c(t);o&&((e,t,n)=>{const o=c(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")))for(const r of f){const o=r.toLowerCase(),i="default"+r;!n.has(o)&&i in e&&e[o]!==t[i]&&(e[o]=t[i])}})(e,t,r);const i=Object(e.__bound);for(const{name:s,value:a}of t.attributes)n.test(s)||r.has(s)||s in i||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:n}of[...e.attributes])r.has("*")||r.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},p=(e,t,n,o)=>{if(e.nodeType!==t.nodeType)return m(e,t,n,o);if(3===e.nodeType||8===e.nodeType){const r=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(r,n))return;return e.data?void(e.data!==r&&(e.data=r)):m(e,t,n,o)}if(1!==e.nodeType)return;const r=e,i=t;if(r.tagName!==i.tagName)return m(e,t,n,o);o.skip?.(r,i)||r.hasAttribute("data-morph-skip")||(h(r,i,o.values),"TEMPLATE"==r.tagName&&(r.innerHTML=i.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||u(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(u(t))return!0;return!1})(i)||r.__ctx?.scope.$template||v(r,i,r.__ctx||n,o))},m=(e,n,o,r)=>{if(t(e,r))return;const i=n.cloneNode(!0);!1!==r.beforeNodeAdded?.(i)&&(d(e,o),e.parentNode.replaceChild(i,e),r.afterNodeRemoved?.(e),b(i,o))},b=(e,t)=>{if(e.parentElement?.closest("[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]"))return;const n=t||a(e.parentNode);n?.walk?.(e,n)},v=(e,n,o,r)=>{const i=r.key||s,a=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=i(t);if(null==e)continue;a.set(e,t)}const l=e=>e&&1===e.nodeType?i(e):null;let c=e.firstChild,u=n.firstChild;const f=t=>{const n=t.cloneNode(!0);!1!==r.beforeNodeAdded?.(n)&&(e.insertBefore(n,c),b(n,o))};for(;u;){const n=u.nextSibling,i=l(u);if(""===c?.data&&u.hasAttribute?.("v-teleport"))c=c.nextSibling;else if(null!=i){const t=a.get(i);t?(t===c?c=c.nextSibling:e.insertBefore(t,c),a.delete(i),p(t,u,o,r)):f(u)}else if(c&&null==l(c)){if(t(c,r)&&!t(u,r)){c=c.nextSibling;continue}const e=c.nextSibling;p(c,u,o,r),c=e}else f(u);u=n}for(;c;){const n=c.nextSibling;t(c,r)||(d(c,o),e.removeChild(c),r.afterNodeRemoved?.(c)),c=n}},g=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const r=n.content;o=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(r),t})()}else o=t;if(o){const t=()=>{const t=A();p(e,o,a(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},A=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}};return e.morph=g,e.morphPlugin=e=>{e.scope.$morph=g},e}({});
1
+ var LiteVueMorph=function(e){var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),n="[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]",o=/^(?:v-|:|@)/,r=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,s=["id","data-key","data-id"],a=e=>{for(const t of s){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},l=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},d=e=>e.__ctx||[...e.children||[]].map(d).find(Boolean),c=(e,t)=>(t||d(e))?.dispose?.(e),u=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)if(r.test(n)){const e=n.replace(r,"").split(".")[0];t.add(/\.camel\b/.test(n)?e.replace(/-(\w)/g,(e,t)=>t.toUpperCase()):e)}else/^v-model\b/.test(n)?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):i.test(n)&&(t.add("style"),"v-popover"==n&&t.add("popover"));return t},f=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),p=["Value","Checked","Selected"],h=(e,t,n)=>{const r=u(t);e.__anchor&&r.add("style");for(const o of e.constructor.morphOwnedAttributes||[])r.add(o);n&&((e,t,n)=>{const o=u(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")||"output"==e.type||"textarea"==e.type&&t.value.includes("{{")))for(const r of p){const o=r.toLowerCase(),i="default"+r,s="Selected"==r?i:o;!n.has(o)&&i in e&&e[o]!==t[s]&&(e[o]=t[s])}})(e,t,r);const i=Object(e.__bound);for(const{name:s,value:a}of t.attributes)o.test(s)||r.has(s)||s in i||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:o}of[...e.attributes])r.has("*")||r.has(o)||t.hasAttribute(o)||e.removeAttribute(o)},m=(e,t,o,r)=>{if(e.nodeType!==t.nodeType)return b(e,t,o,r);if(3===e.nodeType||8===e.nodeType){const n=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(n,o)&&"SCRIPT"!=e.parentNode?.nodeName)return;return e.data?void(e.data!==n&&(e.data=n)):b(e,t,o,r)}if(1!==e.nodeType)return;const i=e,s=t;if(i.tagName!==s.tagName)return b(e,t,o,r);if(!r.skip?.(i,s)&&!i.hasAttribute("data-morph-skip")){if(i.matches(n))return i.isEqualNode(s)?void 0:b(e,t,o,r);h(i,s,r.values),"TEMPLATE"!=i.tagName||i.content.isEqualNode(s.content)||(i.innerHTML=s.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||f(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(f(t))return!0;return!1})(s)||Object.getOwnPropertyDescriptor(Object(i.__ctx?.scope),"$template")||g(i,s,i.__ctx||o,r)}},b=(e,n,o,r)=>{if(t(e,r))return;const i=n.cloneNode(!0);return!1!==r.beforeNodeAdded?.(i)?(c(e,o),e.parentNode.replaceChild(i,e),r.afterNodeRemoved?.(e),v(i,o),i):void 0},v=(e,t)=>{if(e.parentElement?.closest(n))return;const o=t||l(e.parentNode);o?.walk?.(e,o)},g=(e,n,o,r)=>{const i=r.key||a,s=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=i(t);if(null==e)continue;s.set(e,t)}const l=e=>e&&1===e.nodeType?i(e):null,d=new Set;for(let t=n.firstChild;t;t=t.nextSibling)d.add(l(t));const u=n=>{t(n,r)||(c(n,o),e.removeChild(n),r.afterNodeRemoved?.(n))};let f=e.firstChild,p=n.firstChild;const h=t=>{const n=t.cloneNode(!0);!1!==r.beforeNodeAdded?.(n)&&(e.insertBefore(n,f),v(n,o))};for(;p;){const n=p.nextSibling,i=l(p);if(""===f?.data&&p.hasAttribute?.("v-teleport"))f=f.nextSibling;else if(null!=i){const t=s.get(i);t?(t===f?f=f.nextSibling:e.insertBefore(t,f),s.delete(i),m(t,p,o,r)):h(p)}else if(f&&(null==l(f)||!d.has(l(f))&&f.tagName===p.tagName)){if(t(f,r)&&!t(p,r)){f=f.nextSibling;continue}const e=f.nextSibling;m(f,p,o,r),f=e}else{if(f&&!d.has(l(f))){const e=f.nextSibling;u(f),f=e;continue}h(p)}p=n}for(;f;){const e=f.nextSibling;u(f),f=e}},N=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template"),r=e instanceof SVGElement;n.innerHTML=r?`<svg>${t.trim()}</svg>`:t.trim();const i=r?n.content.firstChild:n.content;o=1===i.childNodes.length&&i.firstElementChild?i.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.append(...i.childNodes),t})()}else o=t;if(o){const t=()=>{const t=A();e=m(e,o,l(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},A=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}};return e.morph=N,e.morphPlugin=e=>{e.scope.$morph=N},e}({});
@@ -1 +1 @@
1
- var e=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),t=/^(?:v-|:|@)/,n=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,o=["id","data-key","data-id"],r=e=>{for(const t of o){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},s=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},a=e=>e.__ctx||[...e.children||[]].map(a).find(Boolean),l=(e,t)=>(t||a(e))?.dispose?.(e),d=e=>{const t=/* @__PURE__ */new Set;e.matches("details,dialog")&&t.add("open");for(const{name:o}of e.attributes)n.test(o)?t.add(o.replace(n,"").split(".")[0]):"v-model"===o?(t.add("value"),t.add("checked")):"v-bind"===o?t.add("*"):i.test(o)&&t.add("style");return t},c=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),u=["Value","Checked","Selected"],f=(e,n,i)=>{const o=d(n);i&&((e,t,n)=>{const i=d(t.closest("select")||t);if(!(n.has("*")||i.has("*")||i.has("value")))for(const o of u){const i=o.toLowerCase(),r="default"+o;!n.has(i)&&r in e&&e[i]!==t[r]&&(e[i]=t[r])}})(e,n,o);const r=Object(e.__bound);for(const{name:s,value:a}of n.attributes)t.test(s)||o.has(s)||s in r||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:t}of[...e.attributes])o.has("*")||o.has(t)||n.hasAttribute(t)||e.removeAttribute(t)},h=(e,t,n,i)=>{if(e.nodeType!==t.nodeType)return p(e,t,n,i);if(3===e.nodeType||8===e.nodeType){const o=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(o,n))return;return e.data?void(e.data!==o&&(e.data=o)):p(e,t,n,i)}if(1!==e.nodeType)return;const o=e,r=t;if(o.tagName!==r.tagName)return p(e,t,n,i);i.skip?.(o,r)||o.hasAttribute("data-morph-skip")||(f(o,r,i.values),"TEMPLATE"==o.tagName&&(o.innerHTML=r.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||c(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(c(t))return!0;return!1})(r)||o.__ctx?.scope.$template||b(o,r,o.__ctx||n,i))},p=(t,n,i,o)=>{if(e(t,o))return;const r=n.cloneNode(!0);!1!==o.beforeNodeAdded?.(r)&&(l(t,i),t.parentNode.replaceChild(r,t),o.afterNodeRemoved?.(t),m(r,i))},m=(e,t)=>{if(e.parentElement?.closest("[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]"))return;const n=t||s(e.parentNode);n?.walk?.(e,n)},b=(t,n,i,o)=>{const s=o.key||r,a=/* @__PURE__ */new Map;for(let e=t.firstChild;e;e=e.nextSibling)if(1===e.nodeType){const t=s(e);if(null==t)continue;a.set(t,e)}const d=e=>e&&1===e.nodeType?s(e):null;let c=t.firstChild,u=n.firstChild;const f=e=>{const n=e.cloneNode(!0);!1!==o.beforeNodeAdded?.(n)&&(t.insertBefore(n,c),m(n,i))};for(;u;){const n=u.nextSibling,r=d(u);if(""===c?.data&&u.hasAttribute?.("v-teleport"))c=c.nextSibling;else if(null!=r){const e=a.get(r);e?(e===c?c=c.nextSibling:t.insertBefore(e,c),a.delete(r),h(e,u,i,o)):f(u)}else if(c&&null==d(c)){if(e(c,o)&&!e(u,o)){c=c.nextSibling;continue}const t=c.nextSibling;h(c,u,i,o),c=t}else f(u);u=n}for(;c;){const n=c.nextSibling;e(c,o)||(l(c,i),t.removeChild(c),o.afterNodeRemoved?.(c)),c=n}},v=(e,t,n={})=>{let i;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const o=n.content;i=1===o.childNodes.length&&o.firstElementChild?o.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(o),t})()}else i=t;if(i){const t=()=>{const t=A();h(e,i,s(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},A=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,i=null;try{n=t.selectionStart,i=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,i)}catch{}}},g=e=>{e.scope.$morph=v};export{v as morph,g as morphPlugin};
1
+ var e=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),t="[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]",n=/^(?:v-|:|@)/,o=/^(?::|v-bind:)/,r=/^v-(?!scope|on:)/,i=["id","data-key","data-id"],s=e=>{for(const t of i){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},a=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},d=e=>e.__ctx||[...e.children||[]].map(d).find(Boolean),l=(e,t)=>(t||d(e))?.dispose?.(e),c=e=>{const t=/* @__PURE__ */new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)if(o.test(n)){const e=n.replace(o,"").split(".")[0];t.add(/\.camel\b/.test(n)?e.replace(/-(\w)/g,(e,t)=>t.toUpperCase()):e)}else/^v-model\b/.test(n)?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):r.test(n)&&(t.add("style"),"v-popover"==n&&t.add("popover"));return t},u=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),f=["Value","Checked","Selected"],p=(e,t,o)=>{const r=c(t);e.__anchor&&r.add("style");for(const n of e.constructor.morphOwnedAttributes||[])r.add(n);o&&((e,t,n)=>{const o=c(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")||"output"==e.type||"textarea"==e.type&&t.value.includes("{{")))for(const r of f){const o=r.toLowerCase(),i="default"+r,s="Selected"==r?i:o;!n.has(o)&&i in e&&e[o]!==t[s]&&(e[o]=t[s])}})(e,t,r);const i=Object(e.__bound);for(const{name:s,value:a}of t.attributes)n.test(s)||r.has(s)||s in i||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:n}of[...e.attributes])r.has("*")||r.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},h=(e,n,o,r)=>{if(e.nodeType!==n.nodeType)return m(e,n,o,r);if(3===e.nodeType||8===e.nodeType){const t=n.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(t,o)&&"SCRIPT"!=e.parentNode?.nodeName)return;return e.data?void(e.data!==t&&(e.data=t)):m(e,n,o,r)}if(1!==e.nodeType)return;const i=e,s=n;if(i.tagName!==s.tagName)return m(e,n,o,r);if(!r.skip?.(i,s)&&!i.hasAttribute("data-morph-skip")){if(i.matches(t))return i.isEqualNode(s)?void 0:m(e,n,o,r);p(i,s,r.values),"TEMPLATE"!=i.tagName||i.content.isEqualNode(s.content)||(i.innerHTML=s.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||u(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(u(t))return!0;return!1})(s)||Object.getOwnPropertyDescriptor(Object(i.__ctx?.scope),"$template")||v(i,s,i.__ctx||o,r)}},m=(t,n,o,r)=>{if(e(t,r))return;const i=n.cloneNode(!0);return!1!==r.beforeNodeAdded?.(i)?(l(t,o),t.parentNode.replaceChild(i,t),r.afterNodeRemoved?.(t),b(i,o),i):void 0},b=(e,n)=>{if(e.parentElement?.closest(t))return;const o=n||a(e.parentNode);o?.walk?.(e,o)},v=(t,n,o,r)=>{const i=r.key||s,a=/* @__PURE__ */new Map;for(let e=t.firstChild;e;e=e.nextSibling)if(1===e.nodeType){const t=i(e);if(null==t)continue;a.set(t,e)}const d=e=>e&&1===e.nodeType?i(e):null,c=/* @__PURE__ */new Set;for(let e=n.firstChild;e;e=e.nextSibling)c.add(d(e));const u=n=>{e(n,r)||(l(n,o),t.removeChild(n),r.afterNodeRemoved?.(n))};let f=t.firstChild,p=n.firstChild;const m=e=>{const n=e.cloneNode(!0);!1!==r.beforeNodeAdded?.(n)&&(t.insertBefore(n,f),b(n,o))};for(;p;){const n=p.nextSibling,i=d(p);if(""===f?.data&&p.hasAttribute?.("v-teleport"))f=f.nextSibling;else if(null!=i){const e=a.get(i);e?(e===f?f=f.nextSibling:t.insertBefore(e,f),a.delete(i),h(e,p,o,r)):m(p)}else if(f&&(null==d(f)||!c.has(d(f))&&f.tagName===p.tagName)){if(e(f,r)&&!e(p,r)){f=f.nextSibling;continue}const t=f.nextSibling;h(f,p,o,r),f=t}else{if(f&&!c.has(d(f))){const e=f.nextSibling;u(f),f=e;continue}m(p)}p=n}for(;f;){const e=f.nextSibling;u(f),f=e}},g=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template"),r=e instanceof SVGElement;n.innerHTML=r?`<svg>${t.trim()}</svg>`:t.trim();const i=r?n.content.firstChild:n.content;o=1===i.childNodes.length&&i.firstElementChild?i.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.append(...i.childNodes),t})()}else o=t;if(o){const t=()=>{const t=N();e=h(e,o,a(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},N=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}},A=e=>{e.scope.$morph=g};export{g as morph,A as morphPlugin};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueMorph={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),n=/^(?:v-|:|@)/,o=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,r=["id","data-key","data-id"],s=e=>{for(const t of r){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},l=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},a=e=>e.__ctx||[...e.children||[]].map(a).find(Boolean),d=(e,t)=>(t||a(e))?.dispose?.(e),c=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)o.test(n)?t.add(n.replace(o,"").split(".")[0]):"v-model"===n?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):i.test(n)&&t.add("style");return t},u=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),f=["Value","Checked","Selected"],p=(e,t,o)=>{const i=c(t);o&&((e,t,n)=>{const o=c(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")))for(const i of f){const o=i.toLowerCase(),r="default"+i;!n.has(o)&&r in e&&e[o]!==t[r]&&(e[o]=t[r])}})(e,t,i);const r=Object(e.__bound);for(const{name:s,value:l}of t.attributes)n.test(s)||i.has(s)||s in r||e.getAttribute(s)!==l&&e.setAttribute(s,l);for(const{name:n}of[...e.attributes])i.has("*")||i.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},h=(e,t,n,o)=>{if(e.nodeType!==t.nodeType)return m(e,t,n,o);if(3===e.nodeType||8===e.nodeType){const i=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(i,n))return;return e.data?void(e.data!==i&&(e.data=i)):m(e,t,n,o)}if(1!==e.nodeType)return;const i=e,r=t;if(i.tagName!==r.tagName)return m(e,t,n,o);o.skip?.(i,r)||i.hasAttribute("data-morph-skip")||(p(i,r,o.values),"TEMPLATE"==i.tagName&&(i.innerHTML=r.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||u(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(u(t))return!0;return!1})(r)||i.__ctx?.scope.$template||v(i,r,i.__ctx||n,o))},m=(e,n,o,i)=>{if(t(e,i))return;const r=n.cloneNode(!0);!1!==i.beforeNodeAdded?.(r)&&(d(e,o),e.parentNode.replaceChild(r,e),i.afterNodeRemoved?.(e),b(r,o))},b=(e,t)=>{if(e.parentElement?.closest("[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]"))return;const n=t||l(e.parentNode);n?.walk?.(e,n)},v=(e,n,o,i)=>{const r=i.key||s,l=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=r(t);if(null==e)continue;l.set(e,t)}const a=e=>e&&1===e.nodeType?r(e):null;let c=e.firstChild,u=n.firstChild;const f=t=>{const n=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(e.insertBefore(n,c),b(n,o))};for(;u;){const n=u.nextSibling,r=a(u);if(""===c?.data&&u.hasAttribute?.("v-teleport"))c=c.nextSibling;else if(null!=r){const t=l.get(r);t?(t===c?c=c.nextSibling:e.insertBefore(t,c),l.delete(r),h(t,u,o,i)):f(u)}else if(c&&null==a(c)){if(t(c,i)&&!t(u,i)){c=c.nextSibling;continue}const e=c.nextSibling;h(c,u,o,i),c=e}else f(u);u=n}for(;c;){const n=c.nextSibling;t(c,i)||(d(c,o),e.removeChild(c),i.afterNodeRemoved?.(c)),c=n}},g=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const i=n.content;o=1===i.childNodes.length&&i.firstElementChild?i.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(i),t})()}else o=t;if(o){const t=()=>{const t=y();h(e,o,l(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},y=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}};e.morph=g,e.morphPlugin=e=>{e.scope.$morph=g}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueMorph={})}(this,function(e){var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),n="[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]",o=/^(?:v-|:|@)/,i=/^(?::|v-bind:)/,r=/^v-(?!scope|on:)/,s=["id","data-key","data-id"],a=e=>{for(const t of s){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},d=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},l=e=>e.__ctx||[...e.children||[]].map(l).find(Boolean),c=(e,t)=>(t||l(e))?.dispose?.(e),u=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)if(i.test(n)){const e=n.replace(i,"").split(".")[0];t.add(/\.camel\b/.test(n)?e.replace(/-(\w)/g,(e,t)=>t.toUpperCase()):e)}else/^v-model\b/.test(n)?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):r.test(n)&&(t.add("style"),"v-popover"==n&&t.add("popover"));return t},f=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),p=["Value","Checked","Selected"],h=(e,t,n)=>{const i=u(t);e.__anchor&&i.add("style");for(const o of e.constructor.morphOwnedAttributes||[])i.add(o);n&&((e,t,n)=>{const o=u(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")||"output"==e.type||"textarea"==e.type&&t.value.includes("{{")))for(const i of p){const o=i.toLowerCase(),r="default"+i,s="Selected"==i?r:o;!n.has(o)&&r in e&&e[o]!==t[s]&&(e[o]=t[s])}})(e,t,i);const r=Object(e.__bound);for(const{name:s,value:a}of t.attributes)o.test(s)||i.has(s)||s in r||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:o}of[...e.attributes])i.has("*")||i.has(o)||t.hasAttribute(o)||e.removeAttribute(o)},m=(e,t,o,i)=>{if(e.nodeType!==t.nodeType)return b(e,t,o,i);if(3===e.nodeType||8===e.nodeType){const n=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(n,o)&&"SCRIPT"!=e.parentNode?.nodeName)return;return e.data?void(e.data!==n&&(e.data=n)):b(e,t,o,i)}if(1!==e.nodeType)return;const r=e,s=t;if(r.tagName!==s.tagName)return b(e,t,o,i);if(!i.skip?.(r,s)&&!r.hasAttribute("data-morph-skip")){if(r.matches(n))return r.isEqualNode(s)?void 0:b(e,t,o,i);h(r,s,i.values),"TEMPLATE"!=r.tagName||r.content.isEqualNode(s.content)||(r.innerHTML=s.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||f(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(f(t))return!0;return!1})(s)||Object.getOwnPropertyDescriptor(Object(r.__ctx?.scope),"$template")||g(r,s,r.__ctx||o,i)}},b=(e,n,o,i)=>{if(t(e,i))return;const r=n.cloneNode(!0);return!1!==i.beforeNodeAdded?.(r)?(c(e,o),e.parentNode.replaceChild(r,e),i.afterNodeRemoved?.(e),v(r,o),r):void 0},v=(e,t)=>{if(e.parentElement?.closest(n))return;const o=t||d(e.parentNode);o?.walk?.(e,o)},g=(e,n,o,i)=>{const r=i.key||a,s=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=r(t);if(null==e)continue;s.set(e,t)}const d=e=>e&&1===e.nodeType?r(e):null,l=new Set;for(let t=n.firstChild;t;t=t.nextSibling)l.add(d(t));const u=n=>{t(n,i)||(c(n,o),e.removeChild(n),i.afterNodeRemoved?.(n))};let f=e.firstChild,p=n.firstChild;const h=t=>{const n=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(e.insertBefore(n,f),v(n,o))};for(;p;){const n=p.nextSibling,r=d(p);if(""===f?.data&&p.hasAttribute?.("v-teleport"))f=f.nextSibling;else if(null!=r){const t=s.get(r);t?(t===f?f=f.nextSibling:e.insertBefore(t,f),s.delete(r),m(t,p,o,i)):h(p)}else if(f&&(null==d(f)||!l.has(d(f))&&f.tagName===p.tagName)){if(t(f,i)&&!t(p,i)){f=f.nextSibling;continue}const e=f.nextSibling;m(f,p,o,i),f=e}else{if(f&&!l.has(d(f))){const e=f.nextSibling;u(f),f=e;continue}h(p)}p=n}for(;f;){const e=f.nextSibling;u(f),f=e}},y=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template"),i=e instanceof SVGElement;n.innerHTML=i?`<svg>${t.trim()}</svg>`:t.trim();const r=i?n.content.firstChild:n.content;o=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.append(...r.childNodes),t})()}else o=t;if(o){const t=()=>{const t=N();e=m(e,o,d(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},N=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}};e.morph=y,e.morphPlugin=e=>{e.scope.$morph=y}});
@@ -1,6 +1,4 @@
1
1
  var LiteVueNavigate = (function(exports) {
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- /** Selector matching every scope root, deferred or not. */
4
2
  var SCOPE_SELECTOR = ["[v-scope]", ...[
5
3
  "visible",
6
4
  "idle",
@@ -13,6 +11,13 @@ var LiteVueNavigate = (function(exports) {
13
11
  var SCROLL_SAVE_DELAY = 150;
14
12
  var isLocal = (url) => url.origin === location.origin;
15
13
  var pathOf = (url) => url.pathname + url.search;
14
+ var decode = (s) => {
15
+ try {
16
+ return decodeURIComponent(s);
17
+ } catch {
18
+ return s;
19
+ }
20
+ };
16
21
  var optedOut = (el) => !!el.closest("[data-navigate=\"false\"]");
17
22
  var encode = (data) => new URLSearchParams([...data].map(([k, v]) => [k, v.name ?? v]));
18
23
  var saveScroll = () => history.replaceState({
@@ -25,27 +30,28 @@ var LiteVueNavigate = (function(exports) {
25
30
  }));
26
31
  var assets = (doc) => [...doc.head.querySelectorAll("[data-navigate-track]")].map((el) => el.getAttribute("src") || el.getAttribute("href")).sort().join();
27
32
  /**
28
- * Adds the next page's head elements and returns a function dropping the
29
- * current page's, run after the swap so the old styles hold until then.
30
33
  * Scripts are left out both ways: fetched ones never run, and removing a
31
- * script does not unload it. New stylesheets load before the swap.
34
+ * script does not unload it.
32
35
  */
33
36
  var mergeHead = async (doc) => {
34
37
  const sel = "link,style,meta";
35
38
  const live = [...document.head.querySelectorAll(sel)];
36
39
  const loads = [];
40
+ let at;
37
41
  for (const el of doc.head.querySelectorAll(sel)) {
38
42
  const i = live.findIndex((l) => l.isEqualNode(el));
39
43
  if (i > -1) {
40
- live.splice(i, 1);
44
+ [at] = live.splice(i, 1);
41
45
  continue;
42
46
  }
43
47
  const fresh = document.importNode(el, true);
44
- if (fresh.matches("link[rel=stylesheet][href]:not([disabled],[href=\"\"])")) loads.push(new Promise((r) => {
48
+ if (fresh.matches("link[rel=stylesheet][href]:not([disabled]):not([href=\"\"])")) loads.push(new Promise((r) => {
45
49
  fresh.addEventListener("load", r);
46
50
  fresh.addEventListener("error", r);
47
51
  }));
48
- document.head.append(fresh);
52
+ if (at) at.after(fresh);
53
+ else document.head.prepend(fresh);
54
+ at = fresh;
49
55
  }
50
56
  await Promise.all(loads);
51
57
  return () => live.forEach((el) => el.matches("[data-navigate-preserve]") || el.remove());
@@ -63,13 +69,7 @@ var LiteVueNavigate = (function(exports) {
63
69
  for (; el; el = el.parentElement) if (el.__ctx) return true;
64
70
  return false;
65
71
  };
66
- /**
67
- * Morph with the app's roots kept in step. Under a mounted scope morph binds
68
- * and releases nodes itself; at page level there is no scope, so roots the
69
- * page removes are unmounted and roots it adds are mounted here.
70
- */
71
72
  var render = (app, patch, from, to, values) => {
72
- const roots = [from, ...from.querySelectorAll("*")].filter((el) => el.__ctx && !hasCtxAbove(el.parentElement));
73
73
  const added = [];
74
74
  patch(from, to, {
75
75
  values,
@@ -77,7 +77,6 @@ var LiteVueNavigate = (function(exports) {
77
77
  node.nodeType === 1 && added.push(node);
78
78
  }
79
79
  });
80
- roots.forEach((el) => el.isConnected || app.unmount(el));
81
80
  added.forEach((el) => el.isConnected && !hasCtxAbove(el) && (el.matches(SCOPE_SELECTOR) || el.querySelector(SCOPE_SELECTOR)) && app.mount(el));
82
81
  };
83
82
  var navigate = (app, options = {}) => {
@@ -109,7 +108,8 @@ var LiteVueNavigate = (function(exports) {
109
108
  render(app, app.scope.$morph, from, doc.querySelector(target), ok);
110
109
  dropOld();
111
110
  if (options.scroll !== false) {
112
- const anchor = y == null && url.hash && document.getElementById(url.hash.slice(1));
111
+ const id = url.hash.slice(1);
112
+ const anchor = y == null && id && (document.getElementById(id) || document.getElementById(decode(id)));
113
113
  anchor ? anchor.scrollIntoView() : scrollTo(0, y || 0);
114
114
  }
115
115
  if (ok) moveFocus(from);
@@ -138,7 +138,7 @@ var LiteVueNavigate = (function(exports) {
138
138
  }));
139
139
  const url = new URL(res.url || href);
140
140
  url.hash ||= new URL(href).hash;
141
- if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && !post) {
141
+ if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && (!post || res.redirected)) {
142
142
  res.body?.cancel();
143
143
  throw new Error(`cannot render ${res.status} from ${url.href}`);
144
144
  }
@@ -148,24 +148,22 @@ var LiteVueNavigate = (function(exports) {
148
148
  const from = document.querySelector(target);
149
149
  if (!from || !doc.querySelector(target)) throw new Error(`no ${target} in ${url.href}`);
150
150
  if (assets(doc) !== assets(document)) throw new Error(`${url.href} loads different scripts or styles`);
151
- doc.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove());
151
+ [doc, from].forEach((d) => d.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove()));
152
152
  const dropOld = await mergeHead(doc);
153
153
  const ok = res.ok;
154
- const run = () => c === controller && show(from, doc, url, ok, dropOld, y);
154
+ const run = () => c === controller && (setBusy([]), show(from, doc, url, ok, dropOld, y));
155
155
  options.transition && document.startViewTransition ? document.startViewTransition(run) : run();
156
156
  } catch (error) {
157
157
  if (c.signal.aborted) return;
158
+ setBusy([]);
158
159
  emit("error", {
159
160
  url: href,
160
161
  error
161
162
  });
162
163
  if (!post) location.assign(href);
163
164
  else if (res?.redirected) location.assign(res.url);
164
- } finally {
165
- c === controller && setBusy([]);
166
165
  }
167
166
  };
168
- /** The URL a link leads to, when navigate would take it over. */
169
167
  const linkTo = (e) => {
170
168
  const a = e.target.closest?.("a[href]");
171
169
  if (!(a instanceof HTMLAnchorElement)) return;
@@ -176,9 +174,9 @@ var LiteVueNavigate = (function(exports) {
176
174
  if (url.href.includes("#") && pathOf(url) === pathOf(location)) return;
177
175
  return url;
178
176
  };
177
+ const special = (e) => e.button || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
179
178
  const onClick = (e) => {
180
- if (e.defaultPrevented || e.button || e.metaKey || e.ctrlKey) return;
181
- if (e.shiftKey || e.altKey) return;
179
+ if (e.defaultPrevented || special(e)) return;
182
180
  const url = linkTo(e);
183
181
  if (!url) return;
184
182
  e.preventDefault();
@@ -213,7 +211,7 @@ var LiteVueNavigate = (function(exports) {
213
211
  ["focusin", onHover],
214
212
  ["pointerout", onLeave],
215
213
  ["focusout", onLeave],
216
- ["pointerdown", prefetch]
214
+ ["pointerdown", (e) => special(e) || prefetch(e)]
217
215
  ] : [];
218
216
  const onSubmit = (e) => {
219
217
  const form = e.target;
@@ -225,7 +223,7 @@ var LiteVueNavigate = (function(exports) {
225
223
  if (e.defaultPrevented || method === "dialog" || optedOut(form)) return;
226
224
  if (type === "text/plain") return;
227
225
  if (where && where !== "_self") return;
228
- const url = new URL(attr("action") || location.href, location.href);
226
+ const url = new URL(attr("action") || location.href, document.baseURI);
229
227
  if (!isLocal(url)) return;
230
228
  const data = new FormData(form);
231
229
  if (by?.name) data.append(by.name, by.value);
@@ -1,4 +1,3 @@
1
- /** Selector matching every scope root, deferred or not. */
2
1
  var SCOPE_SELECTOR = ["[v-scope]", ...[
3
2
  "visible",
4
3
  "idle",
@@ -11,6 +10,13 @@ var PREFETCH_TTL = 1e4;
11
10
  var SCROLL_SAVE_DELAY = 150;
12
11
  var isLocal = (url) => url.origin === location.origin;
13
12
  var pathOf = (url) => url.pathname + url.search;
13
+ var decode = (s) => {
14
+ try {
15
+ return decodeURIComponent(s);
16
+ } catch {
17
+ return s;
18
+ }
19
+ };
14
20
  var optedOut = (el) => !!el.closest("[data-navigate=\"false\"]");
15
21
  var encode = (data) => new URLSearchParams([...data].map(([k, v]) => [k, v.name ?? v]));
16
22
  var saveScroll = () => history.replaceState({
@@ -23,27 +29,28 @@ var emit = (name, detail, cancelable = false) => document.dispatchEvent(new Cust
23
29
  }));
24
30
  var assets = (doc) => [...doc.head.querySelectorAll("[data-navigate-track]")].map((el) => el.getAttribute("src") || el.getAttribute("href")).sort().join();
25
31
  /**
26
- * Adds the next page's head elements and returns a function dropping the
27
- * current page's, run after the swap so the old styles hold until then.
28
32
  * Scripts are left out both ways: fetched ones never run, and removing a
29
- * script does not unload it. New stylesheets load before the swap.
33
+ * script does not unload it.
30
34
  */
31
35
  var mergeHead = async (doc) => {
32
36
  const sel = "link,style,meta";
33
37
  const live = [...document.head.querySelectorAll(sel)];
34
38
  const loads = [];
39
+ let at;
35
40
  for (const el of doc.head.querySelectorAll(sel)) {
36
41
  const i = live.findIndex((l) => l.isEqualNode(el));
37
42
  if (i > -1) {
38
- live.splice(i, 1);
43
+ [at] = live.splice(i, 1);
39
44
  continue;
40
45
  }
41
46
  const fresh = document.importNode(el, true);
42
- if (fresh.matches("link[rel=stylesheet][href]:not([disabled],[href=\"\"])")) loads.push(new Promise((r) => {
47
+ if (fresh.matches("link[rel=stylesheet][href]:not([disabled]):not([href=\"\"])")) loads.push(new Promise((r) => {
43
48
  fresh.addEventListener("load", r);
44
49
  fresh.addEventListener("error", r);
45
50
  }));
46
- document.head.append(fresh);
51
+ if (at) at.after(fresh);
52
+ else document.head.prepend(fresh);
53
+ at = fresh;
47
54
  }
48
55
  await Promise.all(loads);
49
56
  return () => live.forEach((el) => el.matches("[data-navigate-preserve]") || el.remove());
@@ -61,13 +68,7 @@ var hasCtxAbove = (el) => {
61
68
  for (; el; el = el.parentElement) if (el.__ctx) return true;
62
69
  return false;
63
70
  };
64
- /**
65
- * Morph with the app's roots kept in step. Under a mounted scope morph binds
66
- * and releases nodes itself; at page level there is no scope, so roots the
67
- * page removes are unmounted and roots it adds are mounted here.
68
- */
69
71
  var render = (app, patch, from, to, values) => {
70
- const roots = [from, ...from.querySelectorAll("*")].filter((el) => el.__ctx && !hasCtxAbove(el.parentElement));
71
72
  const added = [];
72
73
  patch(from, to, {
73
74
  values,
@@ -75,7 +76,6 @@ var render = (app, patch, from, to, values) => {
75
76
  node.nodeType === 1 && added.push(node);
76
77
  }
77
78
  });
78
- roots.forEach((el) => el.isConnected || app.unmount(el));
79
79
  added.forEach((el) => el.isConnected && !hasCtxAbove(el) && (el.matches(SCOPE_SELECTOR) || el.querySelector(SCOPE_SELECTOR)) && app.mount(el));
80
80
  };
81
81
  var navigate = (app, options = {}) => {
@@ -107,7 +107,8 @@ var navigate = (app, options = {}) => {
107
107
  render(app, app.scope.$morph, from, doc.querySelector(target), ok);
108
108
  dropOld();
109
109
  if (options.scroll !== false) {
110
- const anchor = y == null && url.hash && document.getElementById(url.hash.slice(1));
110
+ const id = url.hash.slice(1);
111
+ const anchor = y == null && id && (document.getElementById(id) || document.getElementById(decode(id)));
111
112
  anchor ? anchor.scrollIntoView() : scrollTo(0, y || 0);
112
113
  }
113
114
  if (ok) moveFocus(from);
@@ -136,7 +137,7 @@ var navigate = (app, options = {}) => {
136
137
  }));
137
138
  const url = new URL(res.url || href);
138
139
  url.hash ||= new URL(href).hash;
139
- if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && !post) {
140
+ if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && (!post || res.redirected)) {
140
141
  res.body?.cancel();
141
142
  throw new Error(`cannot render ${res.status} from ${url.href}`);
142
143
  }
@@ -146,24 +147,22 @@ var navigate = (app, options = {}) => {
146
147
  const from = document.querySelector(target);
147
148
  if (!from || !doc.querySelector(target)) throw new Error(`no ${target} in ${url.href}`);
148
149
  if (assets(doc) !== assets(document)) throw new Error(`${url.href} loads different scripts or styles`);
149
- doc.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove());
150
+ [doc, from].forEach((d) => d.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove()));
150
151
  const dropOld = await mergeHead(doc);
151
152
  const ok = res.ok;
152
- const run = () => c === controller && show(from, doc, url, ok, dropOld, y);
153
+ const run = () => c === controller && (setBusy([]), show(from, doc, url, ok, dropOld, y));
153
154
  options.transition && document.startViewTransition ? document.startViewTransition(run) : run();
154
155
  } catch (error) {
155
156
  if (c.signal.aborted) return;
157
+ setBusy([]);
156
158
  emit("error", {
157
159
  url: href,
158
160
  error
159
161
  });
160
162
  if (!post) location.assign(href);
161
163
  else if (res?.redirected) location.assign(res.url);
162
- } finally {
163
- c === controller && setBusy([]);
164
164
  }
165
165
  };
166
- /** The URL a link leads to, when navigate would take it over. */
167
166
  const linkTo = (e) => {
168
167
  const a = e.target.closest?.("a[href]");
169
168
  if (!(a instanceof HTMLAnchorElement)) return;
@@ -174,9 +173,9 @@ var navigate = (app, options = {}) => {
174
173
  if (url.href.includes("#") && pathOf(url) === pathOf(location)) return;
175
174
  return url;
176
175
  };
176
+ const special = (e) => e.button || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
177
177
  const onClick = (e) => {
178
- if (e.defaultPrevented || e.button || e.metaKey || e.ctrlKey) return;
179
- if (e.shiftKey || e.altKey) return;
178
+ if (e.defaultPrevented || special(e)) return;
180
179
  const url = linkTo(e);
181
180
  if (!url) return;
182
181
  e.preventDefault();
@@ -211,7 +210,7 @@ var navigate = (app, options = {}) => {
211
210
  ["focusin", onHover],
212
211
  ["pointerout", onLeave],
213
212
  ["focusout", onLeave],
214
- ["pointerdown", prefetch]
213
+ ["pointerdown", (e) => special(e) || prefetch(e)]
215
214
  ] : [];
216
215
  const onSubmit = (e) => {
217
216
  const form = e.target;
@@ -223,7 +222,7 @@ var navigate = (app, options = {}) => {
223
222
  if (e.defaultPrevented || method === "dialog" || optedOut(form)) return;
224
223
  if (type === "text/plain") return;
225
224
  if (where && where !== "_self") return;
226
- const url = new URL(attr("action") || location.href, location.href);
225
+ const url = new URL(attr("action") || location.href, document.baseURI);
227
226
  if (!isLocal(url)) return;
228
227
  const data = new FormData(form);
229
228
  if (by?.name) data.append(by.name, by.value);