@krate/runtime 0.5.0-rc.8 → 0.5.0-rc.9

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.
@@ -11,6 +11,8 @@ export interface IslandHandle {
11
11
  update(props: unknown, pool?: Record<string, Node[][]>): unknown;
12
12
  unmount(): void;
13
13
  slots?: IslandSlot[];
14
+ /** Re-reads the slots' sets from the document (nested islands changed their nodes). */
15
+ sync?(): void;
14
16
  }
15
17
  /** An island record of window.__krateIslands. */
16
18
  export interface IslandRecord {
@@ -204,24 +204,41 @@ export function maskIslands(html) {
204
204
  i = j;
205
205
  }
206
206
  }
207
- /** Every island record in nodes (nested ones included), in document order. */
207
+ /**
208
+ * Every island record in nodes (nested ones included), in document order. An
209
+ * island's open comment counts with the nodes now between its comments,
210
+ * whether nodes lists them or not: a slot's set lists a nested island as its
211
+ * two comments only.
212
+ */
208
213
  function recordsIn(nodes) {
209
214
  const out = [];
210
- const see = (n) => {
215
+ const seen = new Set();
216
+ const visit = (n) => {
217
+ if (seen.has(n))
218
+ return;
219
+ seen.add(n);
211
220
  const r = n.__krateIsland;
212
221
  if (r && (isOpen(n) || isHost(n)))
213
222
  out.push(r);
214
- };
215
- for (let i = 0; i < nodes.length; i++) {
216
- const n = nodes[i];
217
- see(n);
223
+ if (isOpen(n)) {
224
+ const end = closeOf(n);
225
+ if (end)
226
+ for (let x = n.nextSibling; x && x !== end; x = x.nextSibling)
227
+ visit(x);
228
+ // A set out of the document keeps them on the open comment.
229
+ const inner = n.__krateInner;
230
+ if (inner)
231
+ for (const x of inner)
232
+ visit(x);
233
+ return;
234
+ }
218
235
  if (n.nodeType !== 1)
219
- continue;
220
- const doc = n.ownerDocument || document;
221
- const w = doc.createTreeWalker(n, 129 /* SHOW_ELEMENT | SHOW_COMMENT */);
222
- for (let c = w.nextNode(); c; c = w.nextNode())
223
- see(c);
224
- }
236
+ return;
237
+ for (let c = n.firstChild; c; c = c.nextSibling)
238
+ visit(c);
239
+ };
240
+ for (let i = 0; i < nodes.length; i++)
241
+ visit(nodes[i]);
225
242
  return out;
226
243
  }
227
244
  /**
@@ -595,6 +612,16 @@ function updateIsland(l, n, jobs) {
595
612
  const changed = retaken || JSON.stringify(props) !== JSON.stringify(old ? old.p || {} : null);
596
613
  raw.p = props;
597
614
  l.start.data = OPEN + escapeComment(JSON.stringify(raw));
615
+ // Nested islands in its slots may have replaced their nodes: the sets
616
+ // follow the document before the island renders again.
617
+ if (typeof h.sync === 'function') {
618
+ try {
619
+ h.sync();
620
+ }
621
+ catch (err) {
622
+ console.error(err);
623
+ }
624
+ }
598
625
  if (!changed)
599
626
  return;
600
627
  try {
@@ -1 +1 @@
1
- (()=>{var N="krate-island:",j="/krate-island",I="<!--"+N,_="<!--"+j+"-->",K=/^krate-slot:([0-9a-z]+)$/;function A(e){return e.nodeType===8&&e.data.indexOf(N)===0}function M(e){return e.nodeType===8&&e.data===j}function D(e){return e.nodeType===1&&e.localName==="krate-island"&&e.hasAttribute("data-src")}function F(e){let o=0;for(let t=e.nextSibling;t;t=t.nextSibling)if(A(t))o++;else if(M(t)){if(!o)return t;o--}return null}function H(e,o){let t=[e];for(let n=e.nextSibling;n&&n!==o;n=n.nextSibling)t.push(n);return t.push(o),t}function O(e){return e.el?[e.el]:H(e.start,e.end)}function Q(e){if(e.hasAttribute("data-props"))return e.getAttribute("data-props")||"";let o=e.previousElementSibling;return o&&o.localName==="script"&&o.hasAttribute("data-krate-props")&&o.textContent||""}function T(e,o=[],t=[]){for(let n=0;n<e.length;n++){let r=e[n];if(A(r)){let i=F(r),a=null;try{a=JSON.parse(r.data.slice(N.length))}catch{a=null}if(!i||!a)continue;for(t.push({key:a.m+"#"+a.e,start:r,end:i,json:r.data.slice(N.length),chain:o,rec:r.__krateIsland});n<e.length-1&&e[n]!==i;)n++}else D(r)?t.push({key:r.getAttribute("data-module")+"#"+r.getAttribute("data-export"),el:r,json:Q(r),chain:o,rec:r.__krateIsland}):r.nodeType===1&&T(r.childNodes,o.concat(r),t)}return t}function V(e){let o=e&&e.handle;return!!e&&!e.gone&&e.status==="hydrated"&&!!o&&typeof o.update=="function"&&typeof o.unmount=="function"}function x(e,o){if(Array.isArray(e))return e.map(n=>x(n,o));if(!e||typeof e!="object")return e;let t={};for(let n in e){let r=e[n];n==="__krateSlotRef"&&typeof r=="string"||n==="r"&&e.$==="h"&&typeof r=="string"?t[n]=o(r):t[n]=x(r,o)}return t}function k(e){try{return JSON.parse(e)}catch{return}}function L(e){let o=k(e.json);return JSON.stringify(x(e.el?o:o&&o.p,()=>""))}function P(e){let o="";for(let t=0;t<e.length;t++){let n=e[t];o+=n.nodeType===1?n.outerHTML:n.nodeType===8?"<!--"+n.data+"-->":n.textContent||""}return o}function X(e,o){for(let t=e.indexOf("<krate-island ",o);t>=0;t=e.indexOf("<krate-island ",t+1))if(/\sdata-src=/.test(e.slice(t,e.indexOf(">",t))))return t;return-1}function S(e){let o="",t=0;for(;;){let n=e.indexOf(I,t),r=X(e,t);if(n<0&&r<0)return o+e.slice(t);if(r>=0&&(n<0||r<n)){let c=e.indexOf("</krate-island>",r);if(c<0)return o+e.slice(t);o+=e.slice(t,r)+"<!--i:"+(/data-module="([^"]*)"/.exec(e.slice(r,e.indexOf(">",r)))||["",""])[1]+"-->",t=c+15;continue}let i=e.indexOf("-->",n);if(i<0)return o+e.slice(t);let a=k(e.slice(n+I.length,i)),s=i+3,l=0;for(;;){let c=e.indexOf(I,s),d=e.indexOf(_,s);if(d<0)return o+e.slice(t);if(c>=0&&c<d){l++,s=c+I.length;continue}if(s=d+_.length,!l)break;l--}o+=e.slice(t,n)+"<!--i:"+(a?a.m+"#"+a.e:"")+"-->",t=s}}function Y(e){let o=[],t=n=>{let r=n.__krateIsland;r&&(A(n)||D(n))&&o.push(r)};for(let n=0;n<e.length;n++){let r=e[n];if(t(r),r.nodeType!==1)continue;let a=(r.ownerDocument||document).createTreeWalker(r,129);for(let s=a.nextNode();s;s=a.nextNode())t(s)}return o}function m(e){let o=Y(e);for(let t=o.length-1;t>=0;t--){let n=o[t];if(n.gone)continue;n.gone=!0;let r=n.handle;if(!(!r||typeof r.unmount!="function"))try{r.unmount()}catch(i){console.error(i)}}}function J(e,o){for(let t of Array.from(e.attributes))o.hasAttribute(t.name)||e.removeAttribute(t.name);for(let t of Array.from(o.attributes))e.getAttribute(t.name)!==t.value&&(t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,t.value):e.setAttribute(t.name,t.value))}function Z(e,o,t){let n=e.moveBefore;if(typeof n=="function"&&o.isConnected&&e.isConnected&&o.parentNode)try{n.call(e,o,t);return}catch{}e.insertBefore(o,t)}function b(e,o,t,n){let r=new Set(o),i=globalThis.disposeNode;for(let s=t?t.nextSibling:e.firstChild;s&&s!==n;){let l=s.nextSibling;!r.has(s)&&!(g&&g.has(s))&&(e.removeChild(s),typeof i=="function"&&i(s)),s=l}let a=t?t.nextSibling:e.firstChild;for(let s of o){for(;a&&a!==n&&a!==s&&g&&g.has(a)&&!r.has(a);)a=a.nextSibling;s===a?a=a.nextSibling:Z(e,s,a)}}var g=null;function U(e,o){let t=g,n=new Set(t||[]);e.pairs.forEach(r=>O(r).forEach(i=>n.add(i))),e.map.forEach(r=>n.add(r)),g=n;try{o()}finally{g=t}}function v(e,o,t){let n=T(e),r=T(o),i=new Map,a=0;for(let c of r)for(let d=a;d<n.length;d++)if(n[d].key===c.key){a=d+1,V(n[d].rec)&&(!t||t(n[d],c))&&i.set(c,n[d]);break}let s=new Set(i.values()),l=new Map;return i.forEach((c,d)=>l.set(d.el||d.start,d)),{pairs:i,byStart:l,map:new Map,carry:new Set,gone:n.filter(c=>!s.has(c)),live:n,next:r}}function z(e){let o=new Set(e.map.values());e.pairs.forEach((t,n)=>{let r=!0;n.chain.forEach((i,a)=>{if(e.carry.add(i),!r)return;let s=t.chain[a],l=e.map.get(i);if(l){r=l===s;return}s&&s.localName===i.localName&&!o.has(s)?(e.map.set(i,s),o.add(s)):r=!1})})}function E(e,o){let t=[];for(let n=0;n<o.length;n++){let r=o[n],i=e.byStart.get(r);if(i){if(t.push(...O(e.pairs.get(i))),i.end)for(;n<o.length-1&&o[n]!==i.end;)n++;continue}let a=e.map.get(r);if(a){J(a,r),b(a,E(e,Array.from(r.childNodes)),null,null),t.push(a);continue}e.carry.has(r)&&b(r,E(e,Array.from(r.childNodes)),null,null),t.push(r)}return t}function B(e){return e.gone.length===0&&e.pairs.size===e.next.length}function G(e,o,t,n,r={}){let i=[];for(let l=o?o.nextSibling:e.firstChild;l&&l!==t;l=l.nextSibling)i.push(l);let a=[],s=v(i,n,r.sameProps?(l,c)=>L(l)===L(c):null);if(s.pairs.size>0&&B(s)&&S(P(i))===S(P(n)))return s.pairs.forEach((l,c)=>w(l,c,a)),a;for(let l of s.gone)m(O(l));return z(s),U(s,()=>b(e,E(s,n),o,t)),s.pairs.forEach((l,c)=>w(l,c,a)),a}function ee(e){let o=[],t=0,n=[],r=i=>{if(A(i))return void t++;if(M(i))return void t--;if(t||i.nodeType!==8)return;let a=K.exec(i.data);if(!a)return;let s=i.parentElement&&i.parentElement.closest("krate-island");if(s&&n.some(f=>f===s||f.contains(s)))return;let l="/krate-slot:"+a[1],c=[],d=i.nextSibling;for(;d&&!(d.nodeType===8&&d.data===l);d=d.nextSibling)c.push(d);d&&o.push({id:a[1],nodes:c})};n=H(e.start,e.end).slice(1,-1);for(let i of n){if(i.nodeType===8){r(i);continue}if(i.nodeType!==1)continue;let a=(i.ownerDocument||document).createTreeWalker(i,128);for(let s=a.nextNode();s;s=a.nextNode())r(s)}return o}function ne(e,o,t){let n=v(e,o,null),r=(s,l)=>{let c=new Map;for(let f of l)f.chain.length===0&&c.set(f.el||f.start,f);let d=[];for(let f=0;f<s.length;f++){let h=c.get(s[f]);if(d.push({node:s[f],isl:h}),h&&h.end)for(;f<s.length-1&&s[f]!==h.end;)f++}return d},i=r(e,n.live),a=r(o,n.next);if(i.length!==a.length)return!1;for(let s=0;s<i.length;s++){let l=i[s],c=a[s];if(l.isl||c.isl){if(!l.isl||!c.isl||n.pairs.get(c.isl)!==l.isl)return!1}else if(l.node.nodeType!==c.node.nodeType||l.node.nodeType===1&&l.node.localName!==c.node.localName)return!1}for(let s of n.gone)m(O(s));for(let s=0;s<i.length;s++)!i[s].isl&&i[s].node.nodeType===1&&n.map.set(a[s].node,i[s].node);return z(n),U(n,()=>{for(let s=0;s<i.length;s++){let l=i[s].node,c=a[s].node;i[s].isl||(l.nodeType===1?(J(l,c),b(l,E(n,Array.from(c.childNodes)),null,null)):l.data!==c.data&&(l.data=c.data))}}),n.pairs.forEach((s,l)=>w(s,l,t)),!0}function te(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/--/g,"-\\u002d")}function w(e,o,t){let n=e.rec.handle,r=k(o.json);if(r===void 0)return;if(e.el){if(o.json===e.json)return;try{let u=n.update(r);u&&typeof u.then=="function"&&t.push(u.catch(y=>console.error(y)))}catch(u){console.error(u)}return}let i={},a={},s=!1,l=n.slots||[],c=ee(o),d=[];if(c.forEach((u,y)=>{let p=l.length===c.length?l[y]:void 0,C=P(u.nodes);if(p){if(S(C)===S(p.html)){let R=v(p.set,u.nodes,null);if(B(R)){R.pairs.forEach(($,q)=>w($,q,t)),i[u.id]=p.id,d.push(p);return}}if(ne(p.set,u.nodes,t)){i[u.id]=p.id,p.html=C,d.push(p);return}}p&&m(p.set),a[u.id]=[u.nodes],s=!0,d.push({id:u.id,html:C,set:u.nodes})}),l.length!==c.length)for(let u of l)m(u.set);n.slots=d;let f=x(r.p||{},u=>i[u]||u),h=k(e.json),W=s||JSON.stringify(f)!==JSON.stringify(h?h.p||{}:null);if(r.p=f,e.start.data=N+te(JSON.stringify(r)),!!W)try{let u=s?n.update(f,a):n.update(f);u&&typeof u.then=="function"&&t.push(u.catch(y=>console.error(y)))}catch(u){console.error(u)}}window.__krateIslandSwap={swap:G,unmount:m};})();
1
+ (()=>{var N="krate-island:",j="/krate-island",I="<!--"+N,R="<!--"+j+"-->",F=/^krate-slot:([0-9a-z]+)$/;function x(e){return e.nodeType===8&&e.data.indexOf(N)===0}function M(e){return e.nodeType===8&&e.data===j}function H(e){return e.nodeType===1&&e.localName==="krate-island"&&e.hasAttribute("data-src")}function J(e){let s=0;for(let n=e.nextSibling;n;n=n.nextSibling)if(x(n))s++;else if(M(n)){if(!s)return n;s--}return null}function D(e,s){let n=[e];for(let t=e.nextSibling;t&&t!==s;t=t.nextSibling)n.push(t);return n.push(s),n}function C(e){return e.el?[e.el]:D(e.start,e.end)}function Q(e){if(e.hasAttribute("data-props"))return e.getAttribute("data-props")||"";let s=e.previousElementSibling;return s&&s.localName==="script"&&s.hasAttribute("data-krate-props")&&s.textContent||""}function T(e,s=[],n=[]){for(let t=0;t<e.length;t++){let o=e[t];if(x(o)){let i=J(o),a=null;try{a=JSON.parse(o.data.slice(N.length))}catch{a=null}if(!i||!a)continue;for(n.push({key:a.m+"#"+a.e,start:o,end:i,json:o.data.slice(N.length),chain:s,rec:o.__krateIsland});t<e.length-1&&e[t]!==i;)t++}else H(o)?n.push({key:o.getAttribute("data-module")+"#"+o.getAttribute("data-export"),el:o,json:Q(o),chain:s,rec:o.__krateIsland}):o.nodeType===1&&T(o.childNodes,s.concat(o),n)}return n}function V(e){let s=e&&e.handle;return!!e&&!e.gone&&e.status==="hydrated"&&!!s&&typeof s.update=="function"&&typeof s.unmount=="function"}function k(e,s){if(Array.isArray(e))return e.map(t=>k(t,s));if(!e||typeof e!="object")return e;let n={};for(let t in e){let o=e[t];t==="__krateSlotRef"&&typeof o=="string"||t==="r"&&e.$==="h"&&typeof o=="string"?n[t]=s(o):n[t]=k(o,s)}return n}function S(e){try{return JSON.parse(e)}catch{return}}function L(e){let s=S(e.json);return JSON.stringify(k(e.el?s:s&&s.p,()=>""))}function v(e){let s="";for(let n=0;n<e.length;n++){let t=e[n];s+=t.nodeType===1?t.outerHTML:t.nodeType===8?"<!--"+t.data+"-->":t.textContent||""}return s}function X(e,s){for(let n=e.indexOf("<krate-island ",s);n>=0;n=e.indexOf("<krate-island ",n+1))if(/\sdata-src=/.test(e.slice(n,e.indexOf(">",n))))return n;return-1}function b(e){let s="",n=0;for(;;){let t=e.indexOf(I,n),o=X(e,n);if(t<0&&o<0)return s+e.slice(n);if(o>=0&&(t<0||o<t)){let c=e.indexOf("</krate-island>",o);if(c<0)return s+e.slice(n);s+=e.slice(n,o)+"<!--i:"+(/data-module="([^"]*)"/.exec(e.slice(o,e.indexOf(">",o)))||["",""])[1]+"-->",n=c+15;continue}let i=e.indexOf("-->",t);if(i<0)return s+e.slice(n);let a=S(e.slice(t+I.length,i)),r=i+3,l=0;for(;;){let c=e.indexOf(I,r),d=e.indexOf(R,r);if(d<0)return s+e.slice(n);if(c>=0&&c<d){l++,r=c+I.length;continue}if(r=d+R.length,!l)break;l--}s+=e.slice(n,t)+"<!--i:"+(a?a.m+"#"+a.e:"")+"-->",n=r}}function Y(e){let s=[],n=new Set,t=o=>{if(n.has(o))return;n.add(o);let i=o.__krateIsland;if(i&&(x(o)||H(o))&&s.push(i),x(o)){let a=J(o);if(a)for(let l=o.nextSibling;l&&l!==a;l=l.nextSibling)t(l);let r=o.__krateInner;if(r)for(let l of r)t(l);return}if(o.nodeType===1)for(let a=o.firstChild;a;a=a.nextSibling)t(a)};for(let o=0;o<e.length;o++)t(e[o]);return s}function m(e){let s=Y(e);for(let n=s.length-1;n>=0;n--){let t=s[n];if(t.gone)continue;t.gone=!0;let o=t.handle;if(!(!o||typeof o.unmount!="function"))try{o.unmount()}catch(i){console.error(i)}}}function U(e,s){for(let n of Array.from(e.attributes))s.hasAttribute(n.name)||e.removeAttribute(n.name);for(let n of Array.from(s.attributes))e.getAttribute(n.name)!==n.value&&(n.namespaceURI?e.setAttributeNS(n.namespaceURI,n.name,n.value):e.setAttribute(n.name,n.value))}function Z(e,s,n){let t=e.moveBefore;if(typeof t=="function"&&s.isConnected&&e.isConnected&&s.parentNode)try{t.call(e,s,n);return}catch{}e.insertBefore(s,n)}function E(e,s,n,t){let o=new Set(s),i=globalThis.disposeNode;for(let r=n?n.nextSibling:e.firstChild;r&&r!==t;){let l=r.nextSibling;!o.has(r)&&!(g&&g.has(r))&&(e.removeChild(r),typeof i=="function"&&i(r)),r=l}let a=n?n.nextSibling:e.firstChild;for(let r of s){for(;a&&a!==t&&a!==r&&g&&g.has(a)&&!o.has(a);)a=a.nextSibling;r===a?a=a.nextSibling:Z(e,r,a)}}var g=null;function z(e,s){let n=g,t=new Set(n||[]);e.pairs.forEach(o=>C(o).forEach(i=>t.add(i))),e.map.forEach(o=>t.add(o)),g=t;try{s()}finally{g=n}}function P(e,s,n){let t=T(e),o=T(s),i=new Map,a=0;for(let c of o)for(let d=a;d<t.length;d++)if(t[d].key===c.key){a=d+1,V(t[d].rec)&&(!n||n(t[d],c))&&i.set(c,t[d]);break}let r=new Set(i.values()),l=new Map;return i.forEach((c,d)=>l.set(d.el||d.start,d)),{pairs:i,byStart:l,map:new Map,carry:new Set,gone:t.filter(c=>!r.has(c)),live:t,next:o}}function B(e){let s=new Set(e.map.values());e.pairs.forEach((n,t)=>{let o=!0;t.chain.forEach((i,a)=>{if(e.carry.add(i),!o)return;let r=n.chain[a],l=e.map.get(i);if(l){o=l===r;return}r&&r.localName===i.localName&&!s.has(r)?(e.map.set(i,r),s.add(r)):o=!1})})}function w(e,s){let n=[];for(let t=0;t<s.length;t++){let o=s[t],i=e.byStart.get(o);if(i){if(n.push(...C(e.pairs.get(i))),i.end)for(;t<s.length-1&&s[t]!==i.end;)t++;continue}let a=e.map.get(o);if(a){U(a,o),E(a,w(e,Array.from(o.childNodes)),null,null),n.push(a);continue}e.carry.has(o)&&E(o,w(e,Array.from(o.childNodes)),null,null),n.push(o)}return n}function G(e){return e.gone.length===0&&e.pairs.size===e.next.length}function $(e,s,n,t,o={}){let i=[];for(let l=s?s.nextSibling:e.firstChild;l&&l!==n;l=l.nextSibling)i.push(l);let a=[],r=P(i,t,o.sameProps?(l,c)=>L(l)===L(c):null);if(r.pairs.size>0&&G(r)&&b(v(i))===b(v(t)))return r.pairs.forEach((l,c)=>A(l,c,a)),a;for(let l of r.gone)m(C(l));return B(r),z(r,()=>E(e,w(r,t),s,n)),r.pairs.forEach((l,c)=>A(l,c,a)),a}function ee(e){let s=[],n=0,t=[],o=i=>{if(x(i))return void n++;if(M(i))return void n--;if(n||i.nodeType!==8)return;let a=F.exec(i.data);if(!a)return;let r=i.parentElement&&i.parentElement.closest("krate-island");if(r&&t.some(f=>f===r||f.contains(r)))return;let l="/krate-slot:"+a[1],c=[],d=i.nextSibling;for(;d&&!(d.nodeType===8&&d.data===l);d=d.nextSibling)c.push(d);d&&s.push({id:a[1],nodes:c})};t=D(e.start,e.end).slice(1,-1);for(let i of t){if(i.nodeType===8){o(i);continue}if(i.nodeType!==1)continue;let a=(i.ownerDocument||document).createTreeWalker(i,128);for(let r=a.nextNode();r;r=a.nextNode())o(r)}return s}function ne(e,s,n){let t=P(e,s,null),o=(r,l)=>{let c=new Map;for(let f of l)f.chain.length===0&&c.set(f.el||f.start,f);let d=[];for(let f=0;f<r.length;f++){let h=c.get(r[f]);if(d.push({node:r[f],isl:h}),h&&h.end)for(;f<r.length-1&&r[f]!==h.end;)f++}return d},i=o(e,t.live),a=o(s,t.next);if(i.length!==a.length)return!1;for(let r=0;r<i.length;r++){let l=i[r],c=a[r];if(l.isl||c.isl){if(!l.isl||!c.isl||t.pairs.get(c.isl)!==l.isl)return!1}else if(l.node.nodeType!==c.node.nodeType||l.node.nodeType===1&&l.node.localName!==c.node.localName)return!1}for(let r of t.gone)m(C(r));for(let r=0;r<i.length;r++)!i[r].isl&&i[r].node.nodeType===1&&t.map.set(a[r].node,i[r].node);return B(t),z(t,()=>{for(let r=0;r<i.length;r++){let l=i[r].node,c=a[r].node;i[r].isl||(l.nodeType===1?(U(l,c),E(l,w(t,Array.from(c.childNodes)),null,null)):l.data!==c.data&&(l.data=c.data))}}),t.pairs.forEach((r,l)=>A(r,l,n)),!0}function te(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/--/g,"-\\u002d")}function A(e,s,n){let t=e.rec.handle,o=S(s.json);if(o===void 0)return;if(e.el){if(s.json===e.json)return;try{let u=t.update(o);u&&typeof u.then=="function"&&n.push(u.catch(y=>console.error(y)))}catch(u){console.error(u)}return}let i={},a={},r=!1,l=t.slots||[],c=ee(s),d=[];if(c.forEach((u,y)=>{let p=l.length===c.length?l[y]:void 0,O=v(u.nodes);if(p){if(b(O)===b(p.html)){let _=P(p.set,u.nodes,null);if(G(_)){_.pairs.forEach((K,W)=>A(K,W,n)),i[u.id]=p.id,d.push(p);return}}if(ne(p.set,u.nodes,n)){i[u.id]=p.id,p.html=O,d.push(p);return}}p&&m(p.set),a[u.id]=[u.nodes],r=!0,d.push({id:u.id,html:O,set:u.nodes})}),l.length!==c.length)for(let u of l)m(u.set);t.slots=d;let f=k(o.p||{},u=>i[u]||u),h=S(e.json),q=r||JSON.stringify(f)!==JSON.stringify(h?h.p||{}:null);if(o.p=f,e.start.data=N+te(JSON.stringify(o)),typeof t.sync=="function")try{t.sync()}catch(u){console.error(u)}if(q)try{let u=r?t.update(f,a):t.update(f);u&&typeof u.then=="function"&&n.push(u.catch(y=>console.error(y)))}catch(u){console.error(u)}}window.__krateIslandSwap={swap:$,unmount:m};})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krate/runtime",
3
- "version": "0.5.0-rc.8",
3
+ "version": "0.5.0-rc.9",
4
4
  "description": "Client-side runtime for Krate - signals, hydration, SPA router, resources, and context.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",