@aevantec/litevue 0.6.0 → 0.6.2

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 (76) hide show
  1. package/LICENSE +2 -1
  2. package/dist/litevue-devtools.iife.js +1 -1
  3. package/dist/litevue-devtools.mjs +1 -1
  4. package/dist/litevue-devtools.umd.js +1 -1
  5. package/dist/litevue-plugins.dev.iife.js +120 -81
  6. package/dist/litevue-plugins.dev.mjs +120 -80
  7. package/dist/litevue-plugins.iife.js +1 -1
  8. package/dist/litevue-plugins.mjs +1 -1
  9. package/dist/litevue-plugins.umd.js +1 -1
  10. package/dist/litevue.dev.iife.js +132 -48
  11. package/dist/litevue.dev.mjs +132 -47
  12. package/dist/litevue.iife.js +1 -1
  13. package/dist/litevue.mjs +1 -1
  14. package/dist/litevue.umd.js +1 -1
  15. package/dist/plugins/collapse.iife.js +1 -1
  16. package/dist/plugins/collapse.mjs +1 -1
  17. package/dist/plugins/collapse.umd.js +1 -1
  18. package/dist/plugins/focus.iife.js +1 -1
  19. package/dist/plugins/focus.mjs +1 -1
  20. package/dist/plugins/focus.umd.js +1 -1
  21. package/dist/plugins/intersect.iife.js +1 -1
  22. package/dist/plugins/intersect.umd.js +1 -1
  23. package/dist/plugins/mask.iife.js +1 -1
  24. package/dist/plugins/mask.mjs +1 -1
  25. package/dist/plugins/mask.umd.js +1 -1
  26. package/dist/plugins/media.dev.iife.js +3 -4
  27. package/dist/plugins/media.dev.mjs +3 -3
  28. package/dist/plugins/media.iife.js +1 -1
  29. package/dist/plugins/media.mjs +1 -1
  30. package/dist/plugins/media.umd.js +1 -1
  31. package/dist/plugins/morph.dev.iife.js +58 -19
  32. package/dist/plugins/morph.dev.mjs +58 -18
  33. package/dist/plugins/morph.iife.js +1 -1
  34. package/dist/plugins/morph.mjs +1 -1
  35. package/dist/plugins/morph.umd.js +1 -1
  36. package/dist/plugins/navigate.dev.iife.js +49 -36
  37. package/dist/plugins/navigate.dev.mjs +49 -35
  38. package/dist/plugins/navigate.iife.js +1 -1
  39. package/dist/plugins/navigate.mjs +1 -1
  40. package/dist/plugins/navigate.umd.js +1 -1
  41. package/dist/plugins/persist.dev.iife.js +8 -11
  42. package/dist/plugins/persist.dev.mjs +8 -10
  43. package/dist/plugins/persist.iife.js +1 -1
  44. package/dist/plugins/persist.mjs +1 -1
  45. package/dist/plugins/persist.umd.js +1 -1
  46. package/dist/plugins/popover.iife.js +1 -1
  47. package/dist/plugins/popover.mjs +1 -1
  48. package/dist/plugins/popover.umd.js +1 -1
  49. package/dist/plugins/resize.iife.js +1 -1
  50. package/dist/plugins/resize.umd.js +1 -1
  51. package/dist/plugins/transition.iife.js +1 -1
  52. package/dist/plugins/transition.mjs +1 -1
  53. package/dist/plugins/transition.umd.js +1 -1
  54. package/dist/types/app.d.mts +3 -1
  55. package/dist/types/app.d.ts +3 -1
  56. package/dist/types/context.d.mts +1 -1
  57. package/dist/types/context.d.ts +1 -1
  58. package/dist/types/devtools-panel/chrome.d.mts +6 -5
  59. package/dist/types/devtools-panel/chrome.d.ts +6 -5
  60. package/dist/types/devtools-panel/menu.d.mts +12 -0
  61. package/dist/types/devtools-panel/menu.d.ts +12 -0
  62. package/dist/types/devtools-panel/styles.d.mts +5 -2
  63. package/dist/types/devtools-panel/styles.d.ts +5 -2
  64. package/dist/types/devtools-panel/values.d.mts +17 -5
  65. package/dist/types/devtools-panel/values.d.ts +17 -5
  66. package/dist/types/directives/show.d.mts +1 -0
  67. package/dist/types/directives/show.d.ts +1 -0
  68. package/dist/types/errors.d.mts +1 -1
  69. package/dist/types/errors.d.ts +1 -1
  70. package/dist/types/plugins/focus/index.d.mts +1 -1
  71. package/dist/types/plugins/focus/index.d.ts +1 -1
  72. package/dist/types/plugins/morph/index.d.mts +6 -0
  73. package/dist/types/plugins/morph/index.d.ts +6 -0
  74. package/dist/types/store.d.mts +5 -1
  75. package/dist/types/store.d.ts +5 -1
  76. package/package.json +3 -3
@@ -1,12 +1,12 @@
1
1
  var LiteVueMorph = (function(exports) {
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  // src/plugins/morph/index.ts
4
3
  /**
5
4
  * A `data-` attribute rather than `v-preserve`: an unrecognised `v-` attribute
6
5
  * logs an unknown-directive error, and registering one would have the walker
7
6
  * strip it, leaving nothing for the next morph. Matches `data-morph-skip`.
8
7
  */
9
- var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || !!opts.preserve?.(node));
8
+ var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || node.__marker || !!opts.preserve?.(node));
9
+ var LAZY = "[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]";
10
10
  var dirRE = /^(?:v-|:|@)/;
11
11
  var bindRE = /^(?::|v-bind:)/;
12
12
  var clientStyleRE = /^v-(?!scope|on:)/;
@@ -51,12 +51,17 @@ var LiteVueMorph = (function(exports) {
51
51
  var boundAttrs = (to) => {
52
52
  const owned = /* @__PURE__ */ new Set();
53
53
  if (to.matches("details,dialog")) owned.add("open");
54
- for (const { name } of to.attributes) if (bindRE.test(name)) owned.add(name.replace(bindRE, "").split(".")[0]);
55
- else if (name === "v-model") {
54
+ for (const { name } of to.attributes) if (bindRE.test(name)) {
55
+ const attr = name.replace(bindRE, "").split(".")[0];
56
+ owned.add(/\.camel\b/.test(name) ? attr.replace(/-(\w)/g, (_, c) => c.toUpperCase()) : attr);
57
+ } else if (/^v-model\b/.test(name)) {
56
58
  owned.add("value");
57
59
  owned.add("checked");
58
60
  } else if (name === "v-bind") owned.add("*");
59
- else if (clientStyleRE.test(name)) owned.add("style");
61
+ else if (clientStyleRE.test(name)) {
62
+ owned.add("style");
63
+ name == "v-popover" && owned.add("popover");
64
+ }
60
65
  return owned;
61
66
  };
62
67
  /**
@@ -71,8 +76,25 @@ var LiteVueMorph = (function(exports) {
71
76
  for (let c = to.firstElementChild; c; c = c.nextElementSibling) if (isBlockRoot(c)) return true;
72
77
  return false;
73
78
  };
74
- var patchAttrs = (from, to) => {
79
+ var FIELD_PROPS = [
80
+ "Value",
81
+ "Checked",
82
+ "Selected"
83
+ ];
84
+ var syncValues = (from, to, owned) => {
85
+ const ctl = boundAttrs(to.closest("select") || to);
86
+ if (owned.has("*") || ctl.has("*") || ctl.has("value") || from.type == "output" || from.type == "textarea" && to.value.includes("{{")) return;
87
+ for (const name of FIELD_PROPS) {
88
+ const prop = name.toLowerCase();
89
+ const init = "default" + name;
90
+ const src = name == "Selected" ? init : prop;
91
+ if (!owned.has(prop) && init in from && from[prop] !== to[src]) from[prop] = to[src];
92
+ }
93
+ };
94
+ var patchAttrs = (from, to, values) => {
75
95
  const owned = boundAttrs(to);
96
+ if (from.__anchor) owned.add("style");
97
+ if (values) syncValues(from, to, owned);
76
98
  const bound = Object(from.__bound);
77
99
  for (const { name, value } of to.attributes) {
78
100
  if (dirRE.test(name) || owned.has(name) || name in bound) continue;
@@ -92,7 +114,8 @@ var LiteVueMorph = (function(exports) {
92
114
  if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx, opts);
93
115
  if (from.nodeType === 3 || from.nodeType === 8) {
94
116
  const data = to.data;
95
- if (isInterpolation(data, ctx)) return;
117
+ if (isInterpolation(data, ctx) && from.parentNode?.nodeName != "SCRIPT") return;
118
+ if (!from.data) return replaceNode(from, to, ctx, opts);
96
119
  if (from.data !== data) from.data = data;
97
120
  return;
98
121
  }
@@ -101,8 +124,10 @@ var LiteVueMorph = (function(exports) {
101
124
  const b = to;
102
125
  if (a.tagName !== b.tagName) return replaceNode(from, to, ctx, opts);
103
126
  if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
104
- patchAttrs(a, b);
105
- if (!ownsChildren(b)) patchChildren(a, b, a.__ctx || ctx, opts);
127
+ if (a.matches(LAZY)) return a.isEqualNode(b) ? void 0 : replaceNode(from, to, ctx, opts);
128
+ patchAttrs(a, b, opts.values);
129
+ if (a.tagName == "TEMPLATE" && !a.content.isEqualNode(b.content)) a.innerHTML = b.innerHTML;
130
+ if (!ownsChildren(b) && !Object.getOwnPropertyDescriptor(Object(a.__ctx?.scope), "$template")) patchChildren(a, b, a.__ctx || ctx, opts);
106
131
  };
107
132
  var replaceNode = (from, to, ctx, opts) => {
108
133
  if (preserved(from, opts)) return;
@@ -112,6 +137,7 @@ var LiteVueMorph = (function(exports) {
112
137
  from.parentNode.replaceChild(fresh, from);
113
138
  opts.afterNodeRemoved?.(from);
114
139
  mountNew(fresh, ctx);
140
+ return fresh;
115
141
  };
116
142
  /**
117
143
  * Bind never-walked markup with the scope it was inserted into. The walker
@@ -119,6 +145,7 @@ var LiteVueMorph = (function(exports) {
119
145
  * copy of the core into the plugins bundle.
120
146
  */
121
147
  var mountNew = (node, ctx) => {
148
+ if (node.parentElement?.closest(LAZY)) return;
122
149
  const target = ctx || nearestCtx(node.parentNode);
123
150
  target?.walk?.(node, target);
124
151
  };
@@ -132,6 +159,15 @@ var LiteVueMorph = (function(exports) {
132
159
  keyed.set(k, n);
133
160
  }
134
161
  const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
162
+ const wanted = /* @__PURE__ */ new Set();
163
+ for (let n = to.firstChild; n; n = n.nextSibling) wanted.add(keyOf(n));
164
+ const drop = (node) => {
165
+ if (!preserved(node, opts)) {
166
+ release(node, ctx);
167
+ from.removeChild(node);
168
+ opts.afterNodeRemoved?.(node);
169
+ }
170
+ };
135
171
  let oldChild = from.firstChild;
136
172
  let newChild = to.firstChild;
137
173
  const insert = (node) => {
@@ -143,7 +179,8 @@ var LiteVueMorph = (function(exports) {
143
179
  while (newChild) {
144
180
  const nextNew = newChild.nextSibling;
145
181
  const wantKey = keyOf(newChild);
146
- if (wantKey != null) {
182
+ if (oldChild?.data === "" && newChild.hasAttribute?.("v-teleport")) oldChild = oldChild.nextSibling;
183
+ else if (wantKey != null) {
147
184
  const match = keyed.get(wantKey);
148
185
  if (match) {
149
186
  if (match === oldChild) oldChild = oldChild.nextSibling;
@@ -159,16 +196,17 @@ var LiteVueMorph = (function(exports) {
159
196
  const nextOld = oldChild.nextSibling;
160
197
  patchNode(oldChild, newChild, ctx, opts);
161
198
  oldChild = nextOld;
199
+ } else if (oldChild && !wanted.has(keyOf(oldChild))) {
200
+ const nextOld = oldChild.nextSibling;
201
+ drop(oldChild);
202
+ oldChild = nextOld;
203
+ continue;
162
204
  } else insert(newChild);
163
205
  newChild = nextNew;
164
206
  }
165
207
  while (oldChild) {
166
208
  const next = oldChild.nextSibling;
167
- if (!preserved(oldChild, opts)) {
168
- release(oldChild, ctx);
169
- from.removeChild(oldChild);
170
- opts.afterNodeRemoved?.(oldChild);
171
- }
209
+ drop(oldChild);
172
210
  oldChild = next;
173
211
  }
174
212
  };
@@ -180,18 +218,19 @@ var LiteVueMorph = (function(exports) {
180
218
  let target;
181
219
  if (typeof to === "string") {
182
220
  const holder = document.createElement("template");
183
- holder.innerHTML = to.trim();
184
- const content = holder.content;
221
+ const svg = from instanceof SVGElement;
222
+ holder.innerHTML = svg ? `<svg>${to.trim()}</svg>` : to.trim();
223
+ const content = svg ? holder.content.firstChild : holder.content;
185
224
  target = content.childNodes.length === 1 && content.firstElementChild ? content.firstElementChild : (() => {
186
225
  const wrapper = from.cloneNode(false);
187
- wrapper.appendChild(content);
226
+ wrapper.append(...content.childNodes);
188
227
  return wrapper;
189
228
  })();
190
229
  } else target = to;
191
230
  if (target) {
192
231
  const patch = () => {
193
232
  const restore = captureFocus();
194
- patchNode(from, target, nearestCtx(from), opts);
233
+ from = patchNode(from, target, nearestCtx(from.parentNode), opts) || from;
195
234
  restore();
196
235
  };
197
236
  opts.transition && document.startViewTransition ? document.startViewTransition(patch) : patch();
@@ -4,7 +4,8 @@
4
4
  * logs an unknown-directive error, and registering one would have the walker
5
5
  * strip it, leaving nothing for the next morph. Matches `data-morph-skip`.
6
6
  */
7
- var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || !!opts.preserve?.(node));
7
+ var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || node.__marker || !!opts.preserve?.(node));
8
+ var LAZY = "[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]";
8
9
  var dirRE = /^(?:v-|:|@)/;
9
10
  var bindRE = /^(?::|v-bind:)/;
10
11
  var clientStyleRE = /^v-(?!scope|on:)/;
@@ -49,12 +50,17 @@ var release = (node, ctx) => (ctx || ctxIn(node))?.dispose?.(node);
49
50
  var boundAttrs = (to) => {
50
51
  const owned = /* @__PURE__ */ new Set();
51
52
  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") {
53
+ for (const { name } of to.attributes) if (bindRE.test(name)) {
54
+ const attr = name.replace(bindRE, "").split(".")[0];
55
+ owned.add(/\.camel\b/.test(name) ? attr.replace(/-(\w)/g, (_, c) => c.toUpperCase()) : attr);
56
+ } else if (/^v-model\b/.test(name)) {
54
57
  owned.add("value");
55
58
  owned.add("checked");
56
59
  } else if (name === "v-bind") owned.add("*");
57
- else if (clientStyleRE.test(name)) owned.add("style");
60
+ else if (clientStyleRE.test(name)) {
61
+ owned.add("style");
62
+ name == "v-popover" && owned.add("popover");
63
+ }
58
64
  return owned;
59
65
  };
60
66
  /**
@@ -69,8 +75,25 @@ var ownsChildren = (to) => {
69
75
  for (let c = to.firstElementChild; c; c = c.nextElementSibling) if (isBlockRoot(c)) return true;
70
76
  return false;
71
77
  };
72
- var patchAttrs = (from, to) => {
78
+ var FIELD_PROPS = [
79
+ "Value",
80
+ "Checked",
81
+ "Selected"
82
+ ];
83
+ var syncValues = (from, to, owned) => {
84
+ const ctl = boundAttrs(to.closest("select") || to);
85
+ if (owned.has("*") || ctl.has("*") || ctl.has("value") || from.type == "output" || from.type == "textarea" && to.value.includes("{{")) return;
86
+ for (const name of FIELD_PROPS) {
87
+ const prop = name.toLowerCase();
88
+ const init = "default" + name;
89
+ const src = name == "Selected" ? init : prop;
90
+ if (!owned.has(prop) && init in from && from[prop] !== to[src]) from[prop] = to[src];
91
+ }
92
+ };
93
+ var patchAttrs = (from, to, values) => {
73
94
  const owned = boundAttrs(to);
95
+ if (from.__anchor) owned.add("style");
96
+ if (values) syncValues(from, to, owned);
74
97
  const bound = Object(from.__bound);
75
98
  for (const { name, value } of to.attributes) {
76
99
  if (dirRE.test(name) || owned.has(name) || name in bound) continue;
@@ -90,7 +113,8 @@ var patchNode = (from, to, ctx, opts) => {
90
113
  if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx, opts);
91
114
  if (from.nodeType === 3 || from.nodeType === 8) {
92
115
  const data = to.data;
93
- if (isInterpolation(data, ctx)) return;
116
+ if (isInterpolation(data, ctx) && from.parentNode?.nodeName != "SCRIPT") return;
117
+ if (!from.data) return replaceNode(from, to, ctx, opts);
94
118
  if (from.data !== data) from.data = data;
95
119
  return;
96
120
  }
@@ -99,8 +123,10 @@ var patchNode = (from, to, ctx, opts) => {
99
123
  const b = to;
100
124
  if (a.tagName !== b.tagName) return replaceNode(from, to, ctx, opts);
101
125
  if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
102
- patchAttrs(a, b);
103
- if (!ownsChildren(b)) patchChildren(a, b, a.__ctx || ctx, opts);
126
+ if (a.matches(LAZY)) return a.isEqualNode(b) ? void 0 : replaceNode(from, to, ctx, opts);
127
+ patchAttrs(a, b, opts.values);
128
+ if (a.tagName == "TEMPLATE" && !a.content.isEqualNode(b.content)) a.innerHTML = b.innerHTML;
129
+ if (!ownsChildren(b) && !Object.getOwnPropertyDescriptor(Object(a.__ctx?.scope), "$template")) patchChildren(a, b, a.__ctx || ctx, opts);
104
130
  };
105
131
  var replaceNode = (from, to, ctx, opts) => {
106
132
  if (preserved(from, opts)) return;
@@ -110,6 +136,7 @@ var replaceNode = (from, to, ctx, opts) => {
110
136
  from.parentNode.replaceChild(fresh, from);
111
137
  opts.afterNodeRemoved?.(from);
112
138
  mountNew(fresh, ctx);
139
+ return fresh;
113
140
  };
114
141
  /**
115
142
  * Bind never-walked markup with the scope it was inserted into. The walker
@@ -117,6 +144,7 @@ var replaceNode = (from, to, ctx, opts) => {
117
144
  * copy of the core into the plugins bundle.
118
145
  */
119
146
  var mountNew = (node, ctx) => {
147
+ if (node.parentElement?.closest(LAZY)) return;
120
148
  const target = ctx || nearestCtx(node.parentNode);
121
149
  target?.walk?.(node, target);
122
150
  };
@@ -130,6 +158,15 @@ var patchChildren = (from, to, ctx, opts) => {
130
158
  keyed.set(k, n);
131
159
  }
132
160
  const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
161
+ const wanted = /* @__PURE__ */ new Set();
162
+ for (let n = to.firstChild; n; n = n.nextSibling) wanted.add(keyOf(n));
163
+ const drop = (node) => {
164
+ if (!preserved(node, opts)) {
165
+ release(node, ctx);
166
+ from.removeChild(node);
167
+ opts.afterNodeRemoved?.(node);
168
+ }
169
+ };
133
170
  let oldChild = from.firstChild;
134
171
  let newChild = to.firstChild;
135
172
  const insert = (node) => {
@@ -141,7 +178,8 @@ var patchChildren = (from, to, ctx, opts) => {
141
178
  while (newChild) {
142
179
  const nextNew = newChild.nextSibling;
143
180
  const wantKey = keyOf(newChild);
144
- if (wantKey != null) {
181
+ if (oldChild?.data === "" && newChild.hasAttribute?.("v-teleport")) oldChild = oldChild.nextSibling;
182
+ else if (wantKey != null) {
145
183
  const match = keyed.get(wantKey);
146
184
  if (match) {
147
185
  if (match === oldChild) oldChild = oldChild.nextSibling;
@@ -157,16 +195,17 @@ var patchChildren = (from, to, ctx, opts) => {
157
195
  const nextOld = oldChild.nextSibling;
158
196
  patchNode(oldChild, newChild, ctx, opts);
159
197
  oldChild = nextOld;
198
+ } else if (oldChild && !wanted.has(keyOf(oldChild))) {
199
+ const nextOld = oldChild.nextSibling;
200
+ drop(oldChild);
201
+ oldChild = nextOld;
202
+ continue;
160
203
  } else insert(newChild);
161
204
  newChild = nextNew;
162
205
  }
163
206
  while (oldChild) {
164
207
  const next = oldChild.nextSibling;
165
- if (!preserved(oldChild, opts)) {
166
- release(oldChild, ctx);
167
- from.removeChild(oldChild);
168
- opts.afterNodeRemoved?.(oldChild);
169
- }
208
+ drop(oldChild);
170
209
  oldChild = next;
171
210
  }
172
211
  };
@@ -178,18 +217,19 @@ var morph = (from, to, opts = {}) => {
178
217
  let target;
179
218
  if (typeof to === "string") {
180
219
  const holder = document.createElement("template");
181
- holder.innerHTML = to.trim();
182
- const content = holder.content;
220
+ const svg = from instanceof SVGElement;
221
+ holder.innerHTML = svg ? `<svg>${to.trim()}</svg>` : to.trim();
222
+ const content = svg ? holder.content.firstChild : holder.content;
183
223
  target = content.childNodes.length === 1 && content.firstElementChild ? content.firstElementChild : (() => {
184
224
  const wrapper = from.cloneNode(false);
185
- wrapper.appendChild(content);
225
+ wrapper.append(...content.childNodes);
186
226
  return wrapper;
187
227
  })();
188
228
  } else target = to;
189
229
  if (target) {
190
230
  const patch = () => {
191
231
  const restore = captureFocus();
192
- patchNode(from, target, nearestCtx(from), opts);
232
+ from = patchNode(from, target, nearestCtx(from.parentNode), opts) || from;
193
233
  restore();
194
234
  };
195
235
  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")||!!t.preserve?.(e)),n=/^(?:v-|:|@)/,r=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,o=["id","data-key","data-id"],s=e=>{for(const t of o){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),a=(e,t)=>(t||l(e))?.dispose?.(e),c=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),u=(e,t)=>{const o=(e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)r.test(n)?t.add(n.replace(r,"").split(".")[0]):"v-model"===n?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):i.test(n)&&t.add("style");return t})(t),s=Object(e.__bound);for(const{name:r,value:i}of t.attributes)n.test(r)||o.has(r)||r in s||e.getAttribute(r)!==i&&e.setAttribute(r,i);for(const{name:n}of[...e.attributes])o.has("*")||o.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},f=(e,t,n,r)=>{if(e.nodeType!==t.nodeType)return h(e,t,n,r);if(3===e.nodeType||8===e.nodeType){const r=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(r,n))return;return void(e.data!==r&&(e.data=r))}if(1!==e.nodeType)return;const i=e,o=t;if(i.tagName!==o.tagName)return h(e,t,n,r);r.skip?.(i,o)||i.hasAttribute("data-morph-skip")||(u(i,o),(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})(o)||p(i,o,i.__ctx||n,r))},h=(e,n,r,i)=>{if(t(e,i))return;const o=n.cloneNode(!0);!1!==i.beforeNodeAdded?.(o)&&(a(e,r),e.parentNode.replaceChild(o,e),i.afterNodeRemoved?.(e),m(o,r))},m=(e,t)=>{const n=t||d(e.parentNode);n?.walk?.(e,n)},p=(e,n,r,i)=>{const o=i.key||s,d=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=o(t);if(null==e)continue;d.set(e,t)}const l=e=>e&&1===e.nodeType?o(e):null;let c=e.firstChild,u=n.firstChild;const h=t=>{const n=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(e.insertBefore(n,c),m(n,r))};for(;u;){const n=u.nextSibling,o=l(u);if(null!=o){const t=d.get(o);t?(t===c?c=c.nextSibling:e.insertBefore(t,c),d.delete(o),f(t,u,r,i)):h(u)}else if(c&&null==l(c)){if(t(c,i)&&!t(u,i)){c=c.nextSibling;continue}const e=c.nextSibling;f(c,u,r,i),c=e}else h(u);u=n}for(;c;){const n=c.nextSibling;t(c,i)||(a(c,r),e.removeChild(c),i.afterNodeRemoved?.(c)),c=n}},b=(e,t,n={})=>{let r;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const i=n.content;r=1===i.childNodes.length&&i.firstElementChild?i.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(i),t})()}else r=t;if(r){const t=()=>{const t=v();f(e,r,d(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},v=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,r=null;try{n=t.selectionStart,r=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,r)}catch{}}};return e.morph=b,e.morphPlugin=e=>{e.scope.$morph=b},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-|:|@)/,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},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(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"),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||l(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 l=e=>e&&1===e.nodeType?r(e):null,d=new Set;for(let t=n.firstChild;t;t=t.nextSibling)d.add(l(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=l(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==l(f)){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&&!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}},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=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=y,e.morphPlugin=e=>{e.scope.$morph=y},e}({});
@@ -1 +1 @@
1
- var e=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||!!t.preserve?.(e)),t=/^(?:v-|:|@)/,n=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,r=["id","data-key","data-id"],o=e=>{for(const t of r){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},d=e=>e.__ctx||[...e.children||[]].map(d).find(Boolean),l=(e,t)=>(t||d(e))?.dispose?.(e),a=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),c=(e,r)=>{const o=(e=>{const t=/* @__PURE__ */new Set;e.matches("details,dialog")&&t.add("open");for(const{name:r}of e.attributes)n.test(r)?t.add(r.replace(n,"").split(".")[0]):"v-model"===r?(t.add("value"),t.add("checked")):"v-bind"===r?t.add("*"):i.test(r)&&t.add("style");return t})(r),s=Object(e.__bound);for(const{name:n,value:i}of r.attributes)t.test(n)||o.has(n)||n in s||e.getAttribute(n)!==i&&e.setAttribute(n,i);for(const{name:t}of[...e.attributes])o.has("*")||o.has(t)||r.hasAttribute(t)||e.removeAttribute(t)},u=(e,t,n,i)=>{if(e.nodeType!==t.nodeType)return f(e,t,n,i);if(3===e.nodeType||8===e.nodeType){const i=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(i,n))return;return void(e.data!==i&&(e.data=i))}if(1!==e.nodeType)return;const r=e,o=t;if(r.tagName!==o.tagName)return f(e,t,n,i);i.skip?.(r,o)||r.hasAttribute("data-morph-skip")||(c(r,o),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||a(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(a(t))return!0;return!1})(o)||m(r,o,r.__ctx||n,i))},f=(t,n,i,r)=>{if(e(t,r))return;const o=n.cloneNode(!0);!1!==r.beforeNodeAdded?.(o)&&(l(t,i),t.parentNode.replaceChild(o,t),r.afterNodeRemoved?.(t),h(o,i))},h=(e,t)=>{const n=t||s(e.parentNode);n?.walk?.(e,n)},m=(t,n,i,r)=>{const s=r.key||o,d=/* @__PURE__ */new Map;for(let e=t.firstChild;e;e=e.nextSibling)if(1===e.nodeType){const t=s(e);if(null==t)continue;d.set(t,e)}const a=e=>e&&1===e.nodeType?s(e):null;let c=t.firstChild,f=n.firstChild;const m=e=>{const n=e.cloneNode(!0);!1!==r.beforeNodeAdded?.(n)&&(t.insertBefore(n,c),h(n,i))};for(;f;){const n=f.nextSibling,o=a(f);if(null!=o){const e=d.get(o);e?(e===c?c=c.nextSibling:t.insertBefore(e,c),d.delete(o),u(e,f,i,r)):m(f)}else if(c&&null==a(c)){if(e(c,r)&&!e(f,r)){c=c.nextSibling;continue}const t=c.nextSibling;u(c,f,i,r),c=t}else m(f);f=n}for(;c;){const n=c.nextSibling;e(c,r)||(l(c,i),t.removeChild(c),r.afterNodeRemoved?.(c)),c=n}},p=(e,t,n={})=>{let i;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const r=n.content;i=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(r),t})()}else i=t;if(i){const t=()=>{const t=b();u(e,i,s(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},b=()=>{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{}}},v=e=>{e.scope.$morph=p};export{p as morph,v 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:)/,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},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=/* @__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("*"):i.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 i=c(t);e.__anchor&&i.add("style"),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 i of f){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)n.test(s)||i.has(s)||s in r||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:n}of[...e.attributes])i.has("*")||i.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},h=(e,n,o,i)=>{if(e.nodeType!==n.nodeType)return m(e,n,o,i);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,i)}if(1!==e.nodeType)return;const r=e,s=n;if(r.tagName!==s.tagName)return m(e,n,o,i);if(!i.skip?.(r,s)&&!r.hasAttribute("data-morph-skip")){if(r.matches(t))return r.isEqualNode(s)?void 0:m(e,n,o,i);p(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")||u(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(u(t))return!0;return!1})(s)||Object.getOwnPropertyDescriptor(Object(r.__ctx?.scope),"$template")||v(r,s,r.__ctx||o,i)}},m=(t,n,o,i)=>{if(e(t,i))return;const r=n.cloneNode(!0);return!1!==i.beforeNodeAdded?.(r)?(d(t,o),t.parentNode.replaceChild(r,t),i.afterNodeRemoved?.(t),b(r,o),r):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,i)=>{const r=i.key||s,a=/* @__PURE__ */new Map;for(let e=t.firstChild;e;e=e.nextSibling)if(1===e.nodeType){const t=r(e);if(null==t)continue;a.set(t,e)}const l=e=>e&&1===e.nodeType?r(e):null,c=/* @__PURE__ */new Set;for(let e=n.firstChild;e;e=e.nextSibling)c.add(l(e));const u=n=>{e(n,i)||(d(n,o),t.removeChild(n),i.afterNodeRemoved?.(n))};let f=t.firstChild,p=n.firstChild;const m=e=>{const n=e.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(t.insertBefore(n,f),b(n,o))};for(;p;){const n=p.nextSibling,r=l(p);if(""===f?.data&&p.hasAttribute?.("v-teleport"))f=f.nextSibling;else if(null!=r){const e=a.get(r);e?(e===f?f=f.nextSibling:t.insertBefore(e,f),a.delete(r),h(e,p,o,i)):m(p)}else if(f&&null==l(f)){if(e(f,i)&&!e(p,i)){f=f.nextSibling;continue}const t=f.nextSibling;h(f,p,o,i),f=t}else{if(f&&!c.has(l(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"),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=y();e=h(e,o,a(e.parentNode),n)||e,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{}}},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")||!!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},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),a=(e,t)=>(t||l(e))?.dispose?.(e),c=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),u=(e,t)=>{const r=(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})(t),s=Object(e.__bound);for(const{name:o,value:i}of t.attributes)n.test(o)||r.has(o)||o in s||e.getAttribute(o)!==i&&e.setAttribute(o,i);for(const{name:n}of[...e.attributes])r.has("*")||r.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},f=(e,t,n,o)=>{if(e.nodeType!==t.nodeType)return p(e,t,n,o);if(3===e.nodeType||8===e.nodeType){const o=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(o,n))return;return void(e.data!==o&&(e.data=o))}if(1!==e.nodeType)return;const i=e,r=t;if(i.tagName!==r.tagName)return p(e,t,n,o);o.skip?.(i,r)||i.hasAttribute("data-morph-skip")||(u(i,r),(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)||m(i,r,i.__ctx||n,o))},p=(e,n,o,i)=>{if(t(e,i))return;const r=n.cloneNode(!0);!1!==i.beforeNodeAdded?.(r)&&(a(e,o),e.parentNode.replaceChild(r,e),i.afterNodeRemoved?.(e),h(r,o))},h=(e,t)=>{const n=t||d(e.parentNode);n?.walk?.(e,n)},m=(e,n,o,i)=>{const r=i.key||s,d=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=r(t);if(null==e)continue;d.set(e,t)}const l=e=>e&&1===e.nodeType?r(e):null;let c=e.firstChild,u=n.firstChild;const p=t=>{const n=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(e.insertBefore(n,c),h(n,o))};for(;u;){const n=u.nextSibling,r=l(u);if(null!=r){const t=d.get(r);t?(t===c?c=c.nextSibling:e.insertBefore(t,c),d.delete(r),f(t,u,o,i)):p(u)}else if(c&&null==l(c)){if(t(c,i)&&!t(u,i)){c=c.nextSibling;continue}const e=c.nextSibling;f(c,u,o,i),c=e}else p(u);u=n}for(;c;){const n=c.nextSibling;t(c,i)||(a(c,o),e.removeChild(c),i.afterNodeRemoved?.(c)),c=n}},b=(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=v();f(e,o,d(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},v=()=>{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=b,e.morphPlugin=e=>{e.scope.$morph=b}});
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},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(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"),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||l(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 l=e=>e&&1===e.nodeType?r(e):null,d=new Set;for(let t=n.firstChild;t;t=t.nextSibling)d.add(l(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=l(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==l(f)){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&&!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}},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=x();e=m(e,o,l(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},x=()=>{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,5 +1,4 @@
1
1
  var LiteVueNavigate = (function(exports) {
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  /** Selector matching every scope root, deferred or not. */
4
3
  var SCOPE_SELECTOR = ["[v-scope]", ...[
5
4
  "visible",
@@ -13,6 +12,13 @@ var LiteVueNavigate = (function(exports) {
13
12
  var SCROLL_SAVE_DELAY = 150;
14
13
  var isLocal = (url) => url.origin === location.origin;
15
14
  var pathOf = (url) => url.pathname + url.search;
15
+ var decode = (s) => {
16
+ try {
17
+ return decodeURIComponent(s);
18
+ } catch {
19
+ return s;
20
+ }
21
+ };
16
22
  var optedOut = (el) => !!el.closest("[data-navigate=\"false\"]");
17
23
  var encode = (data) => new URLSearchParams([...data].map(([k, v]) => [k, v.name ?? v]));
18
24
  var saveScroll = () => history.replaceState({
@@ -34,38 +40,51 @@ var LiteVueNavigate = (function(exports) {
34
40
  const sel = "link,style,meta";
35
41
  const live = [...document.head.querySelectorAll(sel)];
36
42
  const loads = [];
43
+ let at;
37
44
  for (const el of doc.head.querySelectorAll(sel)) {
38
45
  const i = live.findIndex((l) => l.isEqualNode(el));
39
46
  if (i > -1) {
40
- live.splice(i, 1);
47
+ [at] = live.splice(i, 1);
41
48
  continue;
42
49
  }
43
50
  const fresh = document.importNode(el, true);
44
- if (fresh.matches("link[rel=stylesheet]")) loads.push(new Promise((r) => {
51
+ if (fresh.matches("link[rel=stylesheet][href]:not([disabled]):not([href=\"\"])")) loads.push(new Promise((r) => {
45
52
  fresh.addEventListener("load", r);
46
53
  fresh.addEventListener("error", r);
47
54
  }));
48
- document.head.append(fresh);
55
+ if (at) at.after(fresh);
56
+ else document.head.prepend(fresh);
57
+ at = fresh;
49
58
  }
50
59
  await Promise.all(loads);
51
60
  return () => live.forEach((el) => el.matches("[data-navigate-preserve]") || el.remove());
52
61
  };
62
+ var moveFocus = (from) => {
63
+ const auto = from.querySelector("[autofocus]");
64
+ if (auto) auto.focus();
65
+ else if (from === document.body) document.activeElement?.blur?.();
66
+ else {
67
+ from.hasAttribute("tabindex") || from.setAttribute("tabindex", "-1");
68
+ from.focus({ preventScroll: true });
69
+ }
70
+ };
53
71
  var hasCtxAbove = (el) => {
54
72
  for (; el; el = el.parentElement) if (el.__ctx) return true;
55
73
  return false;
56
74
  };
57
75
  /**
58
- * Morph with the app's roots kept in step. Under a mounted scope morph binds
59
- * and releases nodes itself; at page level there is no scope, so roots the
60
- * page removes are unmounted and roots it adds are mounted here.
76
+ * Morph with the app's roots kept in step. Morph releases the roots it
77
+ * removes; at page level there is no scope to bind what it adds, so roots
78
+ * the page adds are mounted here.
61
79
  */
62
- var render = (app, patch, from, to) => {
63
- const roots = [from, ...from.querySelectorAll("*")].filter((el) => el.__ctx && !hasCtxAbove(el.parentElement));
80
+ var render = (app, patch, from, to, values) => {
64
81
  const added = [];
65
- patch(from, to, { beforeNodeAdded: (node) => {
66
- node.nodeType === 1 && added.push(node);
67
- } });
68
- roots.forEach((el) => el.isConnected || app.unmount(el));
82
+ patch(from, to, {
83
+ values,
84
+ beforeNodeAdded: (node) => {
85
+ node.nodeType === 1 && added.push(node);
86
+ }
87
+ });
69
88
  added.forEach((el) => el.isConnected && !hasCtxAbove(el) && (el.matches(SCOPE_SELECTOR) || el.querySelector(SCOPE_SELECTOR)) && app.mount(el));
70
89
  };
71
90
  var navigate = (app, options = {}) => {
@@ -90,23 +109,18 @@ var LiteVueNavigate = (function(exports) {
90
109
  status.setAttribute("data-morph-preserve", "");
91
110
  status.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)";
92
111
  document.body.append(status);
93
- const show = (from, doc, url, push, dropOld, y) => {
94
- if (push) history[url.href === location.href ? "replaceState" : "pushState"]({}, "", url.href);
112
+ const show = (from, doc, url, ok, dropOld, y) => {
113
+ if (ok && y == null) history[url.href === location.href ? "replaceState" : "pushState"]({}, "", url.href);
95
114
  rendered = pathOf(location);
96
115
  document.title = doc.title;
97
- render(app, app.scope.$morph, from, doc.querySelector(target));
116
+ render(app, app.scope.$morph, from, doc.querySelector(target), ok);
98
117
  dropOld();
99
118
  if (options.scroll !== false) {
100
- const anchor = y == null && url.hash && document.getElementById(url.hash.slice(1));
119
+ const id = url.hash.slice(1);
120
+ const anchor = y == null && id && (document.getElementById(id) || document.getElementById(decode(id)));
101
121
  anchor ? anchor.scrollIntoView() : scrollTo(0, y || 0);
102
122
  }
103
- const auto = from.querySelector("[autofocus]");
104
- if (auto) auto.focus();
105
- else if (from === document.body) document.activeElement?.blur?.();
106
- else {
107
- from.hasAttribute("tabindex") || from.setAttribute("tabindex", "-1");
108
- from.focus({ preventScroll: true });
109
- }
123
+ if (ok) moveFocus(from);
110
124
  status.textContent = document.title || document.querySelector("h1")?.textContent?.trim() || location.pathname;
111
125
  emit("after", { url: url.href });
112
126
  };
@@ -132,7 +146,7 @@ var LiteVueNavigate = (function(exports) {
132
146
  }));
133
147
  const url = new URL(res.url || href);
134
148
  url.hash ||= new URL(href).hash;
135
- if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && !post) {
149
+ if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && (!post || res.redirected)) {
136
150
  res.body?.cancel();
137
151
  throw new Error(`cannot render ${res.status} from ${url.href}`);
138
152
  }
@@ -142,21 +156,20 @@ var LiteVueNavigate = (function(exports) {
142
156
  const from = document.querySelector(target);
143
157
  if (!from || !doc.querySelector(target)) throw new Error(`no ${target} in ${url.href}`);
144
158
  if (assets(doc) !== assets(document)) throw new Error(`${url.href} loads different scripts or styles`);
145
- doc.querySelectorAll("script").forEach((s) => s.remove());
159
+ [doc, from].forEach((d) => d.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove()));
146
160
  const dropOld = await mergeHead(doc);
147
- const push = res.ok && y == null;
148
- const run = () => c === controller && show(from, doc, url, push, dropOld, y);
161
+ const ok = res.ok;
162
+ const run = () => c === controller && (setBusy([]), show(from, doc, url, ok, dropOld, y));
149
163
  options.transition && document.startViewTransition ? document.startViewTransition(run) : run();
150
164
  } catch (error) {
151
165
  if (c.signal.aborted) return;
166
+ setBusy([]);
152
167
  emit("error", {
153
168
  url: href,
154
169
  error
155
170
  });
156
171
  if (!post) location.assign(href);
157
172
  else if (res?.redirected) location.assign(res.url);
158
- } finally {
159
- c === controller && setBusy([]);
160
173
  }
161
174
  };
162
175
  /** The URL a link leads to, when navigate would take it over. */
@@ -170,9 +183,9 @@ var LiteVueNavigate = (function(exports) {
170
183
  if (url.href.includes("#") && pathOf(url) === pathOf(location)) return;
171
184
  return url;
172
185
  };
186
+ const special = (e) => e.button || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
173
187
  const onClick = (e) => {
174
- if (e.defaultPrevented || e.button || e.metaKey || e.ctrlKey) return;
175
- if (e.shiftKey || e.altKey) return;
188
+ if (e.defaultPrevented || special(e)) return;
176
189
  const url = linkTo(e);
177
190
  if (!url) return;
178
191
  e.preventDefault();
@@ -207,7 +220,7 @@ var LiteVueNavigate = (function(exports) {
207
220
  ["focusin", onHover],
208
221
  ["pointerout", onLeave],
209
222
  ["focusout", onLeave],
210
- ["pointerdown", prefetch]
223
+ ["pointerdown", (e) => special(e) || prefetch(e)]
211
224
  ] : [];
212
225
  const onSubmit = (e) => {
213
226
  const form = e.target;
@@ -215,11 +228,11 @@ var LiteVueNavigate = (function(exports) {
215
228
  const attr = (name) => by?.getAttribute("form" + name) || form.getAttribute(name);
216
229
  const method = (attr("method") || "get").toLowerCase();
217
230
  const where = attr("target");
218
- const type = attr("enctype");
231
+ const type = attr("enctype")?.toLowerCase();
219
232
  if (e.defaultPrevented || method === "dialog" || optedOut(form)) return;
220
233
  if (type === "text/plain") return;
221
234
  if (where && where !== "_self") return;
222
- const url = new URL(attr("action") || location.href, location.href);
235
+ const url = new URL(attr("action") || location.href, document.baseURI);
223
236
  if (!isLocal(url)) return;
224
237
  const data = new FormData(form);
225
238
  if (by?.name) data.append(by.name, by.value);
@@ -252,7 +265,7 @@ var LiteVueNavigate = (function(exports) {
252
265
  return () => {
253
266
  clearTimeout(saving);
254
267
  removeEventListener("scroll", onScroll);
255
- controller?.abort();
268
+ controller = controller?.abort();
256
269
  pre?.c.abort();
257
270
  clearTimeout(timer);
258
271
  document.removeEventListener("click", onClick);