Comparing version 1.6.8 to 1.6.9
267
dist/dev.js
let taskIdCounter = 1, | ||
isCallbackScheduled = false, | ||
isPerformingWork = false, | ||
taskQueue = [], | ||
currentTask = null, | ||
shouldYieldToHost = null, | ||
yieldInterval = 5, | ||
deadline = 0, | ||
maxYieldInterval = 300, | ||
scheduleCallback = null, | ||
scheduledCallback = null; | ||
isCallbackScheduled = false, | ||
isPerformingWork = false, | ||
taskQueue = [], | ||
currentTask = null, | ||
shouldYieldToHost = null, | ||
yieldInterval = 5, | ||
deadline = 0, | ||
maxYieldInterval = 300, | ||
scheduleCallback = null, | ||
scheduledCallback = null; | ||
const maxSigned31BitInt = 1073741823; | ||
function setupScheduler() { | ||
const channel = new MessageChannel(), | ||
port = channel.port2; | ||
port = channel.port2; | ||
scheduleCallback = () => port.postMessage(null); | ||
@@ -66,3 +66,3 @@ channel.port1.onmessage = () => { | ||
let startTime = performance.now(), | ||
timeout = maxSigned31BitInt; | ||
timeout = maxSigned31BitInt; | ||
if (options && options.timeout) timeout = options.timeout; | ||
@@ -123,3 +123,4 @@ const newTask = { | ||
function nextHydrateContext() { | ||
return { ...sharedConfig.context, | ||
return { | ||
...sharedConfig.context, | ||
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`, | ||
@@ -160,18 +161,18 @@ count: 0 | ||
const listener = Listener, | ||
owner = Owner, | ||
unowned = fn.length === 0, | ||
root = unowned ? { | ||
owned: null, | ||
cleanups: null, | ||
context: null, | ||
owner: null | ||
} : { | ||
owned: null, | ||
cleanups: null, | ||
context: null, | ||
owner: detachedOwner || owner | ||
}, | ||
updateFn = unowned ? () => fn(() => { | ||
throw new Error("Dispose method must be an explicit argument to createRoot function"); | ||
}) : () => fn(() => untrack(() => cleanNode(root))); | ||
owner = Owner, | ||
unowned = fn.length === 0, | ||
root = unowned ? { | ||
owned: null, | ||
cleanups: null, | ||
context: null, | ||
owner: null | ||
} : { | ||
owned: null, | ||
cleanups: null, | ||
context: null, | ||
owner: detachedOwner || owner | ||
}, | ||
updateFn = unowned ? () => fn(() => { | ||
throw new Error("Dispose method must be an explicit argument to createRoot function"); | ||
}) : () => fn(() => untrack(() => cleanNode(root))); | ||
{ | ||
@@ -218,3 +219,3 @@ if (owner) root.name = `${owner.name}-r${rootCount++}`; | ||
const c = createComputation(fn, value, false, STALE, options ), | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
if (s) c.suspense = s; | ||
@@ -227,6 +228,6 @@ c.user = true; | ||
const c = createComputation(() => { | ||
fn ? fn() : untrack(onInvalidate); | ||
fn = undefined; | ||
}, undefined, false, 0, options ), | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
fn ? fn() : untrack(onInvalidate); | ||
fn = undefined; | ||
}, undefined, false, 0, options ), | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
if (s) c.suspense = s; | ||
@@ -265,15 +266,15 @@ c.user = true; | ||
let pr = null, | ||
initP = NO_INIT, | ||
id = null, | ||
loadedUnderTransition = false, | ||
scheduled = false, | ||
resolved = ("initialValue" in options), | ||
dynamic = typeof source === "function" && createMemo(source); | ||
initP = NO_INIT, | ||
id = null, | ||
loadedUnderTransition = false, | ||
scheduled = false, | ||
resolved = ("initialValue" in options), | ||
dynamic = typeof source === "function" && createMemo(source); | ||
const contexts = new Set(), | ||
[value, setValue] = (options.storage || createSignal)(options.initialValue), | ||
[error, setError] = createSignal(undefined), | ||
[track, trigger] = createSignal(undefined, { | ||
equals: false | ||
}), | ||
[state, setState] = createSignal(resolved ? "ready" : "unresolved"); | ||
[value, setValue] = (options.storage || createSignal)(options.initialValue), | ||
[error, setError] = createSignal(undefined), | ||
[track, trigger] = createSignal(undefined, { | ||
equals: false | ||
}), | ||
[state, setState] = createSignal(resolved ? "ready" : "unresolved"); | ||
if (sharedConfig.context) { | ||
@@ -314,4 +315,4 @@ id = `${sharedConfig.context.id}${sharedConfig.context.count++}`; | ||
const c = SuspenseContext && lookup(Owner, SuspenseContext.id), | ||
v = value(), | ||
err = error(); | ||
v = value(), | ||
err = error(); | ||
if (err && !pr) throw err; | ||
@@ -388,3 +389,3 @@ if (Listener && !Listener.user && c) { | ||
let t, | ||
timeout = options ? options.timeoutMs : undefined; | ||
timeout = options ? options.timeoutMs : undefined; | ||
const node = createComputation(() => { | ||
@@ -532,7 +533,6 @@ if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? { | ||
return Comp(props); | ||
}), undefined, true); | ||
}), undefined, true, 0); | ||
c.props = props; | ||
c.observers = null; | ||
c.observerSlots = null; | ||
c.state = 0; | ||
c.componentName = Comp.name; | ||
@@ -570,2 +570,3 @@ updateComputation(c); | ||
Owner.sourceMap[tryName] = value; | ||
value.graph = Owner; | ||
} | ||
@@ -577,3 +578,4 @@ return tryName; | ||
if (!owner) return {}; | ||
return { ...serializeValues(owner.sourceMap), | ||
return { | ||
...serializeValues(owner.sourceMap), | ||
...(owner.owned ? serializeChildren(owner) : {}) | ||
@@ -694,4 +696,4 @@ }; | ||
const owner = Owner, | ||
listener = Listener, | ||
time = ExecCount; | ||
listener = Listener, | ||
time = ExecCount; | ||
Listener = Owner = node; | ||
@@ -717,3 +719,13 @@ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time); | ||
} catch (err) { | ||
if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE; | ||
if (node.pure) { | ||
if (Transition && Transition.running) { | ||
node.tState = STALE; | ||
node.tOwned && node.tOwned.forEach(cleanNode); | ||
node.tOwned = undefined; | ||
} else { | ||
node.state = STALE; | ||
node.owned && node.owned.forEach(cleanNode); | ||
node.owned = null; | ||
} | ||
} | ||
handleError(err); | ||
@@ -786,3 +798,3 @@ } | ||
let top = node, | ||
prev = ancestors[i + 1]; | ||
prev = ancestors[i + 1]; | ||
while ((top = top.owner) && top !== prev) { | ||
@@ -884,3 +896,3 @@ if (Transition.disposed.has(top)) return; | ||
let i, | ||
userLength = 0; | ||
userLength = 0; | ||
for (i = 0; i < queue.length; i++) { | ||
@@ -921,7 +933,7 @@ const e = queue[i]; | ||
const source = node.sources.pop(), | ||
index = node.sourceSlots.pop(), | ||
obs = source.observers; | ||
index = node.sourceSlots.pop(), | ||
obs = source.observers; | ||
if (obs && obs.length) { | ||
const n = obs.pop(), | ||
s = source.observerSlots.pop(); | ||
s = source.observerSlots.pop(); | ||
if (index < obs.length) { | ||
@@ -1016,3 +1028,4 @@ n.sourceSlots[s] = index; | ||
const node = root.owned[i]; | ||
result[node.componentName ? `${node.componentName}:${node.name}` : node.name] = { ...serializeValues(node.sourceMap), | ||
result[node.componentName ? `${node.componentName}:${node.name}` : node.name] = { | ||
...serializeValues(node.sourceMap), | ||
...(node.owned ? serializeChildren(node) : {}) | ||
@@ -1075,23 +1088,23 @@ }; | ||
let items = [], | ||
mapped = [], | ||
disposers = [], | ||
len = 0, | ||
indexes = mapFn.length > 1 ? [] : null; | ||
mapped = [], | ||
disposers = [], | ||
len = 0, | ||
indexes = mapFn.length > 1 ? [] : null; | ||
onCleanup(() => dispose(disposers)); | ||
return () => { | ||
let newItems = list() || [], | ||
i, | ||
j; | ||
i, | ||
j; | ||
newItems[$TRACK]; | ||
return untrack(() => { | ||
let newLen = newItems.length, | ||
newIndices, | ||
newIndicesNext, | ||
temp, | ||
tempdisposers, | ||
tempIndexes, | ||
start, | ||
end, | ||
newEnd, | ||
item; | ||
newIndices, | ||
newIndicesNext, | ||
temp, | ||
tempdisposers, | ||
tempIndexes, | ||
start, | ||
end, | ||
newEnd, | ||
item; | ||
if (newLen === 0) { | ||
@@ -1181,7 +1194,7 @@ if (len !== 0) { | ||
let items = [], | ||
mapped = [], | ||
disposers = [], | ||
signals = [], | ||
len = 0, | ||
i; | ||
mapped = [], | ||
disposers = [], | ||
signals = [], | ||
len = 0, | ||
i; | ||
onCleanup(() => dispose(disposers)); | ||
@@ -1468,17 +1481,17 @@ return () => { | ||
const conditions = children(() => props.children), | ||
evalConditions = createMemo(() => { | ||
let conds = conditions(); | ||
if (!Array.isArray(conds)) conds = [conds]; | ||
for (let i = 0; i < conds.length; i++) { | ||
const c = conds[i].when; | ||
if (c) { | ||
keyed = !!conds[i].keyed; | ||
return [i, c, conds[i]]; | ||
evalConditions = createMemo(() => { | ||
let conds = conditions(); | ||
if (!Array.isArray(conds)) conds = [conds]; | ||
for (let i = 0; i < conds.length; i++) { | ||
const c = conds[i].when; | ||
if (c) { | ||
keyed = !!conds[i].keyed; | ||
return [i, c, conds[i]]; | ||
} | ||
} | ||
} | ||
return [-1]; | ||
}, undefined, { | ||
equals, | ||
name: "eval conditions" | ||
} ); | ||
return [-1]; | ||
}, undefined, { | ||
equals, | ||
name: "eval conditions" | ||
} ); | ||
return createMemo(() => { | ||
@@ -1532,5 +1545,5 @@ const [index, when, cond] = evalConditions(); | ||
let [wrapper, setWrapper] = createSignal(() => ({ | ||
inFallback: false | ||
})), | ||
show; | ||
inFallback: false | ||
})), | ||
show; | ||
const listContext = useContext(SuspenseListContext); | ||
@@ -1543,9 +1556,9 @@ const [registry, setRegistry] = createSignal([]); | ||
const reveal = props.revealOrder, | ||
tail = props.tail, | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}, | ||
reg = registry(), | ||
reverse = reveal === "backwards"; | ||
tail = props.tail, | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}, | ||
reg = registry(), | ||
reverse = reveal === "backwards"; | ||
if (reveal === "together") { | ||
@@ -1565,3 +1578,3 @@ const all = reg.every(inFallback => !inFallback()); | ||
const n = reverse ? len - i - 1 : i, | ||
s = reg[n](); | ||
s = reg[n](); | ||
if (!stop && !s) { | ||
@@ -1609,21 +1622,21 @@ res[n] = { | ||
let counter = 0, | ||
show, | ||
ctx, | ||
p, | ||
flicker, | ||
error; | ||
show, | ||
ctx, | ||
p, | ||
flicker, | ||
error; | ||
const [inFallback, setFallback] = createSignal(false), | ||
SuspenseContext = getSuspenseContext(), | ||
store = { | ||
increment: () => { | ||
if (++counter === 1) setFallback(true); | ||
SuspenseContext = getSuspenseContext(), | ||
store = { | ||
increment: () => { | ||
if (++counter === 1) setFallback(true); | ||
}, | ||
decrement: () => { | ||
if (--counter === 0) setFallback(false); | ||
}, | ||
inFallback, | ||
effects: [], | ||
resolved: false | ||
}, | ||
decrement: () => { | ||
if (--counter === 0) setFallback(false); | ||
}, | ||
inFallback, | ||
effects: [], | ||
resolved: false | ||
}, | ||
owner = getOwner(); | ||
owner = getOwner(); | ||
if (sharedConfig.context && sharedConfig.load) { | ||
@@ -1668,6 +1681,6 @@ const key = sharedConfig.context.id + sharedConfig.context.count; | ||
const inFallback = store.inFallback(), | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}; | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}; | ||
if ((!inFallback || p && p !== "$$f") && showContent) { | ||
@@ -1674,0 +1687,0 @@ store.resolved = true; |
@@ -26,6 +26,6 @@ const equalFn = (a, b) => a === b; | ||
const owner = Owner, | ||
root = fn.length === 0 ? UNOWNED : { | ||
context: null, | ||
owner | ||
}; | ||
root = fn.length === 0 ? UNOWNED : { | ||
context: null, | ||
owner | ||
}; | ||
Owner = root; | ||
@@ -266,3 +266,4 @@ let result; | ||
function nextHydrateContext() { | ||
return sharedConfig.context ? { ...sharedConfig.context, | ||
return sharedConfig.context ? { | ||
...sharedConfig.context, | ||
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`, | ||
@@ -314,13 +315,13 @@ count: 0 | ||
const descriptors = Object.getOwnPropertyDescriptors(props), | ||
split = k => { | ||
const clone = {}; | ||
for (let i = 0; i < k.length; i++) { | ||
const key = k[i]; | ||
if (descriptors[key]) { | ||
Object.defineProperty(clone, key, descriptors[key]); | ||
delete descriptors[key]; | ||
split = k => { | ||
const clone = {}; | ||
for (let i = 0; i < k.length; i++) { | ||
const key = k[i]; | ||
if (descriptors[key]) { | ||
Object.defineProperty(clone, key, descriptors[key]); | ||
delete descriptors[key]; | ||
} | ||
} | ||
} | ||
return clone; | ||
}; | ||
return clone; | ||
}; | ||
return keys.map(split).concat(split(Object.keys(descriptors))); | ||
@@ -330,4 +331,4 @@ } | ||
const list = props.each || [], | ||
len = list.length, | ||
fn = props.children; | ||
len = list.length, | ||
fn = props.children; | ||
if (len) { | ||
@@ -368,5 +369,5 @@ let mapped = Array(len); | ||
let error, | ||
res, | ||
clean, | ||
sync = true; | ||
res, | ||
clean, | ||
sync = true; | ||
const ctx = sharedConfig.context; | ||
@@ -377,3 +378,4 @@ const id = ctx.id + ctx.count; | ||
ctx.writeResource(id, error, true); | ||
setHydrateContext({ ...ctx, | ||
setHydrateContext({ | ||
...ctx, | ||
count: 0 | ||
@@ -585,3 +587,4 @@ }); | ||
function runSuspense() { | ||
setHydrateContext({ ...ctx, | ||
setHydrateContext({ | ||
...ctx, | ||
count: 0 | ||
@@ -610,3 +613,4 @@ }); | ||
if (ctx.async) { | ||
setHydrateContext({ ...ctx, | ||
setHydrateContext({ | ||
...ctx, | ||
count: 0, | ||
@@ -617,3 +621,3 @@ id: ctx.id + "0.f", | ||
const res = { | ||
t: `<span id="pl-${id}">${resolveSSRNode(props.fallback)}</span>` | ||
t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!pl-${id}>` | ||
}; | ||
@@ -623,3 +627,4 @@ setHydrateContext(ctx); | ||
} | ||
setHydrateContext({ ...ctx, | ||
setHydrateContext({ | ||
...ctx, | ||
count: 0, | ||
@@ -626,0 +631,0 @@ id: ctx.id + "0.f" |
let taskIdCounter = 1, | ||
isCallbackScheduled = false, | ||
isPerformingWork = false, | ||
taskQueue = [], | ||
currentTask = null, | ||
shouldYieldToHost = null, | ||
yieldInterval = 5, | ||
deadline = 0, | ||
maxYieldInterval = 300, | ||
scheduleCallback = null, | ||
scheduledCallback = null; | ||
isCallbackScheduled = false, | ||
isPerformingWork = false, | ||
taskQueue = [], | ||
currentTask = null, | ||
shouldYieldToHost = null, | ||
yieldInterval = 5, | ||
deadline = 0, | ||
maxYieldInterval = 300, | ||
scheduleCallback = null, | ||
scheduledCallback = null; | ||
const maxSigned31BitInt = 1073741823; | ||
function setupScheduler() { | ||
const channel = new MessageChannel(), | ||
port = channel.port2; | ||
port = channel.port2; | ||
scheduleCallback = () => port.postMessage(null); | ||
@@ -66,3 +66,3 @@ channel.port1.onmessage = () => { | ||
let startTime = performance.now(), | ||
timeout = maxSigned31BitInt; | ||
timeout = maxSigned31BitInt; | ||
if (options && options.timeout) timeout = options.timeout; | ||
@@ -123,3 +123,4 @@ const newTask = { | ||
function nextHydrateContext() { | ||
return { ...sharedConfig.context, | ||
return { | ||
...sharedConfig.context, | ||
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`, | ||
@@ -159,11 +160,11 @@ count: 0 | ||
const listener = Listener, | ||
owner = Owner, | ||
unowned = fn.length === 0, | ||
root = unowned ? UNOWNED : { | ||
owned: null, | ||
cleanups: null, | ||
context: null, | ||
owner: detachedOwner || owner | ||
}, | ||
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root))); | ||
owner = Owner, | ||
unowned = fn.length === 0, | ||
root = unowned ? UNOWNED : { | ||
owned: null, | ||
cleanups: null, | ||
context: null, | ||
owner: detachedOwner || owner | ||
}, | ||
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root))); | ||
Owner = root; | ||
@@ -205,3 +206,3 @@ Listener = null; | ||
const c = createComputation(fn, value, false, STALE), | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
if (s) c.suspense = s; | ||
@@ -214,6 +215,6 @@ c.user = true; | ||
const c = createComputation(() => { | ||
fn ? fn() : untrack(onInvalidate); | ||
fn = undefined; | ||
}, undefined, false, 0), | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
fn ? fn() : untrack(onInvalidate); | ||
fn = undefined; | ||
}, undefined, false, 0), | ||
s = SuspenseContext && lookup(Owner, SuspenseContext.id); | ||
if (s) c.suspense = s; | ||
@@ -252,15 +253,15 @@ c.user = true; | ||
let pr = null, | ||
initP = NO_INIT, | ||
id = null, | ||
loadedUnderTransition = false, | ||
scheduled = false, | ||
resolved = ("initialValue" in options), | ||
dynamic = typeof source === "function" && createMemo(source); | ||
initP = NO_INIT, | ||
id = null, | ||
loadedUnderTransition = false, | ||
scheduled = false, | ||
resolved = ("initialValue" in options), | ||
dynamic = typeof source === "function" && createMemo(source); | ||
const contexts = new Set(), | ||
[value, setValue] = (options.storage || createSignal)(options.initialValue), | ||
[error, setError] = createSignal(undefined), | ||
[track, trigger] = createSignal(undefined, { | ||
equals: false | ||
}), | ||
[state, setState] = createSignal(resolved ? "ready" : "unresolved"); | ||
[value, setValue] = (options.storage || createSignal)(options.initialValue), | ||
[error, setError] = createSignal(undefined), | ||
[track, trigger] = createSignal(undefined, { | ||
equals: false | ||
}), | ||
[state, setState] = createSignal(resolved ? "ready" : "unresolved"); | ||
if (sharedConfig.context) { | ||
@@ -301,4 +302,4 @@ id = `${sharedConfig.context.id}${sharedConfig.context.count++}`; | ||
const c = SuspenseContext && lookup(Owner, SuspenseContext.id), | ||
v = value(), | ||
err = error(); | ||
v = value(), | ||
err = error(); | ||
if (err && !pr) throw err; | ||
@@ -375,3 +376,3 @@ if (Listener && !Listener.user && c) { | ||
let t, | ||
timeout = options ? options.timeoutMs : undefined; | ||
timeout = options ? options.timeoutMs : undefined; | ||
const node = createComputation(() => { | ||
@@ -623,4 +624,4 @@ if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? { | ||
const owner = Owner, | ||
listener = Listener, | ||
time = ExecCount; | ||
listener = Listener, | ||
time = ExecCount; | ||
Listener = Owner = node; | ||
@@ -646,3 +647,13 @@ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time); | ||
} catch (err) { | ||
if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE; | ||
if (node.pure) { | ||
if (Transition && Transition.running) { | ||
node.tState = STALE; | ||
node.tOwned && node.tOwned.forEach(cleanNode); | ||
node.tOwned = undefined; | ||
} else { | ||
node.state = STALE; | ||
node.owned && node.owned.forEach(cleanNode); | ||
node.owned = null; | ||
} | ||
} | ||
handleError(err); | ||
@@ -714,3 +725,3 @@ } | ||
let top = node, | ||
prev = ancestors[i + 1]; | ||
prev = ancestors[i + 1]; | ||
while ((top = top.owner) && top !== prev) { | ||
@@ -812,3 +823,3 @@ if (Transition.disposed.has(top)) return; | ||
let i, | ||
userLength = 0; | ||
userLength = 0; | ||
for (i = 0; i < queue.length; i++) { | ||
@@ -849,7 +860,7 @@ const e = queue[i]; | ||
const source = node.sources.pop(), | ||
index = node.sourceSlots.pop(), | ||
obs = source.observers; | ||
index = node.sourceSlots.pop(), | ||
obs = source.observers; | ||
if (obs && obs.length) { | ||
const n = obs.pop(), | ||
s = source.observerSlots.pop(); | ||
s = source.observerSlots.pop(); | ||
if (index < obs.length) { | ||
@@ -978,23 +989,23 @@ n.sourceSlots[s] = index; | ||
let items = [], | ||
mapped = [], | ||
disposers = [], | ||
len = 0, | ||
indexes = mapFn.length > 1 ? [] : null; | ||
mapped = [], | ||
disposers = [], | ||
len = 0, | ||
indexes = mapFn.length > 1 ? [] : null; | ||
onCleanup(() => dispose(disposers)); | ||
return () => { | ||
let newItems = list() || [], | ||
i, | ||
j; | ||
i, | ||
j; | ||
newItems[$TRACK]; | ||
return untrack(() => { | ||
let newLen = newItems.length, | ||
newIndices, | ||
newIndicesNext, | ||
temp, | ||
tempdisposers, | ||
tempIndexes, | ||
start, | ||
end, | ||
newEnd, | ||
item; | ||
newIndices, | ||
newIndicesNext, | ||
temp, | ||
tempdisposers, | ||
tempIndexes, | ||
start, | ||
end, | ||
newEnd, | ||
item; | ||
if (newLen === 0) { | ||
@@ -1082,7 +1093,7 @@ if (len !== 0) { | ||
let items = [], | ||
mapped = [], | ||
disposers = [], | ||
signals = [], | ||
len = 0, | ||
i; | ||
mapped = [], | ||
disposers = [], | ||
signals = [], | ||
len = 0, | ||
i; | ||
onCleanup(() => dispose(disposers)); | ||
@@ -1358,16 +1369,16 @@ return () => { | ||
const conditions = children(() => props.children), | ||
evalConditions = createMemo(() => { | ||
let conds = conditions(); | ||
if (!Array.isArray(conds)) conds = [conds]; | ||
for (let i = 0; i < conds.length; i++) { | ||
const c = conds[i].when; | ||
if (c) { | ||
keyed = !!conds[i].keyed; | ||
return [i, c, conds[i]]; | ||
evalConditions = createMemo(() => { | ||
let conds = conditions(); | ||
if (!Array.isArray(conds)) conds = [conds]; | ||
for (let i = 0; i < conds.length; i++) { | ||
const c = conds[i].when; | ||
if (c) { | ||
keyed = !!conds[i].keyed; | ||
return [i, c, conds[i]]; | ||
} | ||
} | ||
} | ||
return [-1]; | ||
}, undefined, { | ||
equals | ||
}); | ||
return [-1]; | ||
}, undefined, { | ||
equals | ||
}); | ||
return createMemo(() => { | ||
@@ -1414,5 +1425,5 @@ const [index, when, cond] = evalConditions(); | ||
let [wrapper, setWrapper] = createSignal(() => ({ | ||
inFallback: false | ||
})), | ||
show; | ||
inFallback: false | ||
})), | ||
show; | ||
const listContext = useContext(SuspenseListContext); | ||
@@ -1425,9 +1436,9 @@ const [registry, setRegistry] = createSignal([]); | ||
const reveal = props.revealOrder, | ||
tail = props.tail, | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}, | ||
reg = registry(), | ||
reverse = reveal === "backwards"; | ||
tail = props.tail, | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}, | ||
reg = registry(), | ||
reverse = reveal === "backwards"; | ||
if (reveal === "together") { | ||
@@ -1447,3 +1458,3 @@ const all = reg.every(inFallback => !inFallback()); | ||
const n = reverse ? len - i - 1 : i, | ||
s = reg[n](); | ||
s = reg[n](); | ||
if (!stop && !s) { | ||
@@ -1491,21 +1502,21 @@ res[n] = { | ||
let counter = 0, | ||
show, | ||
ctx, | ||
p, | ||
flicker, | ||
error; | ||
show, | ||
ctx, | ||
p, | ||
flicker, | ||
error; | ||
const [inFallback, setFallback] = createSignal(false), | ||
SuspenseContext = getSuspenseContext(), | ||
store = { | ||
increment: () => { | ||
if (++counter === 1) setFallback(true); | ||
SuspenseContext = getSuspenseContext(), | ||
store = { | ||
increment: () => { | ||
if (++counter === 1) setFallback(true); | ||
}, | ||
decrement: () => { | ||
if (--counter === 0) setFallback(false); | ||
}, | ||
inFallback, | ||
effects: [], | ||
resolved: false | ||
}, | ||
decrement: () => { | ||
if (--counter === 0) setFallback(false); | ||
}, | ||
inFallback, | ||
effects: [], | ||
resolved: false | ||
}, | ||
owner = getOwner(); | ||
owner = getOwner(); | ||
if (sharedConfig.context && sharedConfig.load) { | ||
@@ -1550,6 +1561,6 @@ const key = sharedConfig.context.id + sharedConfig.context.count; | ||
const inFallback = store.inFallback(), | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}; | ||
{ | ||
showContent = true, | ||
showFallback = true | ||
} = show ? show() : {}; | ||
if ((!inFallback || p && p !== "$$f") && showContent) { | ||
@@ -1556,0 +1567,0 @@ store.resolved = true; |
@@ -7,4 +7,4 @@ import { spread, assign, insert, createComponent, dynamicProperty, SVGElements } from 'solid-js/web'; | ||
let args = [].slice.call(arguments), | ||
e, | ||
multiExpression = false; | ||
e, | ||
multiExpression = false; | ||
while (Array.isArray(args[0])) args = args[0]; | ||
@@ -42,3 +42,3 @@ if (args[0][$ELEMENT]) args.unshift(h.Fragment); | ||
let props, | ||
next = args[0]; | ||
next = args[0]; | ||
if (next == null || typeof next === "object" && !Array.isArray(next) && !(next instanceof Element)) props = args.shift(); | ||
@@ -75,3 +75,3 @@ props || (props = {}); | ||
const v = m[i], | ||
s = v.substring(1, v.length); | ||
s = v.substring(1, v.length); | ||
if (!v) continue; | ||
@@ -78,0 +78,0 @@ if (!e) e = r.SVGElements.has(v) ? document.createElementNS("http://www.w3.org/2000/svg", v) : document.createElement(v);else if (v[0] === ".") e.classList.add(s);else if (v[0] === "#") e.setAttribute("id", s); |
@@ -1,2 +0,2 @@ | ||
declare type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node; | ||
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node; | ||
interface Runtime { | ||
@@ -10,6 +10,6 @@ insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any; | ||
} | ||
declare type ExpandableNode = Node & { | ||
type ExpandableNode = Node & { | ||
[key: string]: any; | ||
}; | ||
export declare type HyperScript = { | ||
export type HyperScript = { | ||
(...args: any[]): () => ExpandableNode | ExpandableNode[]; | ||
@@ -16,0 +16,0 @@ Fragment: (props: { |
@@ -23,4 +23,3 @@ import { effect, style, insert, untrack, spread, createComponent, delegateEvents, classList, mergeProps, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, PropAliases, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web'; | ||
}; | ||
function parseTag( | ||
tag) { | ||
function parseTag( tag) { | ||
const res = { | ||
@@ -185,3 +184,3 @@ type: 'tag', | ||
let i = 0, | ||
markup = ""; | ||
markup = ""; | ||
for (; i < statics.length - 1; i++) { | ||
@@ -193,3 +192,3 @@ markup = markup + statics[i] + "<!--#-->"; | ||
const [html, code] = parseTemplate(parse(markup)), | ||
templates = []; | ||
templates = []; | ||
for (let i = 0; i < html.length; i++) { | ||
@@ -217,4 +216,4 @@ templates.push(document.createElement("template")); | ||
let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""), | ||
parts, | ||
namespace; | ||
parts, | ||
namespace; | ||
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) { | ||
@@ -257,5 +256,5 @@ name = parts[1]; | ||
const childOptions = Object.assign({}, options, { | ||
exprs: [] | ||
}), | ||
count = options.counter; | ||
exprs: [] | ||
}), | ||
count = options.counter; | ||
parseKeyValue(tag, name, value, isSVG, isCE, childOptions); | ||
@@ -326,7 +325,7 @@ options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`); | ||
const keys = Object.keys(node.attrs), | ||
propGroups = [props], | ||
componentIdentifier = options.counter++; | ||
propGroups = [props], | ||
componentIdentifier = options.counter++; | ||
for (let i = 0; i < keys.length; i++) { | ||
const name = keys[i], | ||
value = node.attrs[name]; | ||
value = node.attrs[name]; | ||
if (name === "###") { | ||
@@ -343,11 +342,11 @@ propGroups.push(`exprs[${options.counter++}]`); | ||
const children = { | ||
type: "fragment", | ||
children: node.children | ||
}, | ||
childOptions = Object.assign({}, options, { | ||
first: true, | ||
decl: [], | ||
exprs: [], | ||
parent: false | ||
}); | ||
type: "fragment", | ||
children: node.children | ||
}, | ||
childOptions = Object.assign({}, options, { | ||
first: true, | ||
decl: [], | ||
exprs: [], | ||
parent: false | ||
}); | ||
parseNode(children, childOptions); | ||
@@ -418,3 +417,3 @@ props.push(`children: () => { ${childOptions.exprs.join(";\n")}}`); | ||
const name = keys[i], | ||
value = node.attrs[name]; | ||
value = node.attrs[name]; | ||
if (value.includes("###")) { | ||
@@ -438,3 +437,3 @@ let count = options.counter++; | ||
const name = keys[i], | ||
value = node.attrs[name]; | ||
value = node.attrs[name]; | ||
if (value.includes("###")) { | ||
@@ -471,14 +470,14 @@ delete node.attrs[name]; | ||
const options = { | ||
path: "", | ||
decl: [], | ||
exprs: [], | ||
delegatedEvents: new Set(), | ||
counter: 0, | ||
first: true, | ||
multi: false, | ||
templateId: 0, | ||
templateNodes: [] | ||
}, | ||
id = uuid, | ||
origNodes = nodes; | ||
path: "", | ||
decl: [], | ||
exprs: [], | ||
delegatedEvents: new Set(), | ||
counter: 0, | ||
first: true, | ||
multi: false, | ||
templateId: 0, | ||
templateNodes: [] | ||
}, | ||
id = uuid, | ||
origNodes = nodes; | ||
let toplevel; | ||
@@ -485,0 +484,0 @@ if (nodes.length > 1) { |
@@ -1,2 +0,2 @@ | ||
declare type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node; | ||
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node; | ||
interface Runtime { | ||
@@ -32,3 +32,3 @@ effect<T>(fn: (prev?: T) => T, init?: T): any; | ||
} | ||
export declare type HTMLTag = { | ||
export type HTMLTag = { | ||
(statics: TemplateStringsArray, ...args: unknown[]): Node | Node[]; | ||
@@ -35,0 +35,0 @@ }; |
{ | ||
"name": "solid-js", | ||
"description": "A declarative JavaScript library for building user interfaces.", | ||
"version": "1.6.8", | ||
"version": "1.6.9", | ||
"author": "Ryan Carniato", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
import { $PROXY, DEV as DEV$1, $TRACK, getListener, batch, createSignal } from 'solid-js'; | ||
const $RAW = Symbol("store-raw"), | ||
$NODE = Symbol("store-node"), | ||
$NAME = Symbol("store-name"); | ||
$NODE = Symbol("store-node"), | ||
$NAME = Symbol("store-name"); | ||
function wrap$1(value, name) { | ||
@@ -14,3 +14,3 @@ let p = value[$PROXY]; | ||
const keys = Object.keys(value), | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
@@ -49,3 +49,3 @@ const prop = keys[i]; | ||
const keys = Object.keys(item), | ||
desc = Object.getOwnPropertyDescriptors(item); | ||
desc = Object.getOwnPropertyDescriptors(item); | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
@@ -133,7 +133,7 @@ prop = keys[i]; | ||
const prev = state[property], | ||
len = state.length; | ||
len = state.length; | ||
if (globalThis._$onStoreNodeUpdate) globalThis._$onStoreNodeUpdate(state, property, value, prev); | ||
if (value === undefined) delete state[property];else state[property] = value; | ||
let nodes = getDataNodes(state), | ||
node; | ||
node; | ||
if (node = getDataNode(nodes, property, prev)) node.$(() => value); | ||
@@ -156,3 +156,3 @@ if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length); | ||
let i = 0, | ||
len = next.length; | ||
len = next.length; | ||
for (; i < len; i++) { | ||
@@ -167,7 +167,7 @@ const value = next[i]; | ||
let part, | ||
prev = current; | ||
prev = current; | ||
if (path.length > 1) { | ||
part = path.shift(); | ||
const partType = typeof part, | ||
isArray = Array.isArray(current); | ||
isArray = Array.isArray(current); | ||
if (Array.isArray(part)) { | ||
@@ -283,3 +283,3 @@ for (let i = 0; i < part.length; i++) { | ||
const keys = Object.keys(value), | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
@@ -295,3 +295,3 @@ const prop = keys[i]; | ||
const og = desc[prop].set, | ||
set = v => batch(() => og.call(p, v)); | ||
set = v => batch(() => og.call(p, v)); | ||
Object.defineProperty(value, prop, { | ||
@@ -342,3 +342,3 @@ set | ||
const temp = new Array(target.length), | ||
newIndices = new Map(); | ||
newIndices = new Map(); | ||
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]); end--, newEnd--) { | ||
@@ -399,6 +399,6 @@ temp[newEnd] = previous[end]; | ||
const { | ||
merge, | ||
key = "id" | ||
} = options, | ||
v = unwrap(value); | ||
merge, | ||
key = "id" | ||
} = options, | ||
v = unwrap(value); | ||
return state => { | ||
@@ -405,0 +405,0 @@ if (!isWrappable(state) || !isWrappable(v)) return v; |
@@ -26,3 +26,3 @@ const $RAW = Symbol("state-raw"); | ||
let i = 0, | ||
len = next.length; | ||
len = next.length; | ||
for (; i < len; i++) { | ||
@@ -37,7 +37,7 @@ const value = next[i]; | ||
let part, | ||
next = current; | ||
next = current; | ||
if (path.length > 1) { | ||
part = path.shift(); | ||
const partType = typeof part, | ||
isArray = Array.isArray(current); | ||
isArray = Array.isArray(current); | ||
if (Array.isArray(part)) { | ||
@@ -44,0 +44,0 @@ for (let i = 0; i < part.length; i++) { |
import { $PROXY, $TRACK, getListener, batch, createSignal } from 'solid-js'; | ||
const $RAW = Symbol("store-raw"), | ||
$NODE = Symbol("store-node"), | ||
$NAME = Symbol("store-name"); | ||
$NODE = Symbol("store-node"), | ||
$NAME = Symbol("store-name"); | ||
function wrap$1(value, name) { | ||
@@ -14,3 +14,3 @@ let p = value[$PROXY]; | ||
const keys = Object.keys(value), | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
@@ -46,3 +46,3 @@ const prop = keys[i]; | ||
const keys = Object.keys(item), | ||
desc = Object.getOwnPropertyDescriptors(item); | ||
desc = Object.getOwnPropertyDescriptors(item); | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
@@ -128,6 +128,6 @@ prop = keys[i]; | ||
const prev = state[property], | ||
len = state.length; | ||
len = state.length; | ||
if (value === undefined) delete state[property];else state[property] = value; | ||
let nodes = getDataNodes(state), | ||
node; | ||
node; | ||
if (node = getDataNode(nodes, property, prev)) node.$(() => value); | ||
@@ -150,3 +150,3 @@ if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length); | ||
let i = 0, | ||
len = next.length; | ||
len = next.length; | ||
for (; i < len; i++) { | ||
@@ -161,7 +161,7 @@ const value = next[i]; | ||
let part, | ||
prev = current; | ||
prev = current; | ||
if (path.length > 1) { | ||
part = path.shift(); | ||
const partType = typeof part, | ||
isArray = Array.isArray(current); | ||
isArray = Array.isArray(current); | ||
if (Array.isArray(part)) { | ||
@@ -270,3 +270,3 @@ for (let i = 0; i < part.length; i++) { | ||
const keys = Object.keys(value), | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
desc = Object.getOwnPropertyDescriptors(value); | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
@@ -282,3 +282,3 @@ const prop = keys[i]; | ||
const og = desc[prop].set, | ||
set = v => batch(() => og.call(p, v)); | ||
set = v => batch(() => og.call(p, v)); | ||
Object.defineProperty(value, prop, { | ||
@@ -319,3 +319,3 @@ set | ||
const temp = new Array(target.length), | ||
newIndices = new Map(); | ||
newIndices = new Map(); | ||
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]); end--, newEnd--) { | ||
@@ -376,6 +376,6 @@ temp[newEnd] = previous[end]; | ||
const { | ||
merge, | ||
key = "id" | ||
} = options, | ||
v = unwrap(value); | ||
merge, | ||
key = "id" | ||
} = options, | ||
v = unwrap(value); | ||
return state => { | ||
@@ -382,0 +382,0 @@ if (!isWrappable(state) || !isWrappable(v)) return v; |
@@ -16,4 +16,8 @@ import { requestCallback } from "./scheduler.js"; | ||
export declare type ComputationState = 0 | 1 | 2; | ||
export interface SignalState<T> { | ||
value?: T; | ||
export interface SourceMapValue { | ||
value: unknown; | ||
graph?: Owner; | ||
} | ||
export interface SignalState<T> extends SourceMapValue { | ||
value: T; | ||
observers: Computation<any>[] | null; | ||
@@ -30,5 +34,3 @@ observerSlots: number[] | null; | ||
context: any | null; | ||
sourceMap?: Record<string, { | ||
value: unknown; | ||
}>; | ||
sourceMap?: Record<string, SourceMapValue>; | ||
name?: string; | ||
@@ -180,2 +182,3 @@ componentName?: string; | ||
export interface Memo<Prev, Next = Prev> extends SignalState<Next>, Computation<Next> { | ||
value: Next; | ||
tOwned?: Computation<Prev | Next, Next>[]; | ||
@@ -457,5 +460,3 @@ } | ||
export declare function hashValue(v: any): string; | ||
export declare function registerGraph(name: string, value: { | ||
value: unknown; | ||
}): string; | ||
export declare function registerGraph(name: string, value: SourceMapValue): string; | ||
interface GraphRecord { | ||
@@ -462,0 +463,0 @@ [k: string]: GraphRecord | unknown; |
@@ -24,3 +24,3 @@ import { createRoot, createRenderEffect, mergeProps, createMemo, createComponent, untrack } from 'solid-js'; | ||
const t = typeof value, | ||
multi = marker !== undefined; | ||
multi = marker !== undefined; | ||
if (t === "string" || t === "number") { | ||
@@ -87,3 +87,3 @@ if (t === "number") value = value.toString(); | ||
let item = array[i], | ||
t; | ||
t; | ||
if (item == null || item === true || item === false) ; else if (Array.isArray(item)) { | ||
@@ -107,8 +107,8 @@ dynamic = normalizeIncomingArray(normalized, item) || dynamic; | ||
let bLength = b.length, | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = getNextSibling(a[aEnd - 1]), | ||
map = null; | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = getNextSibling(a[aEnd - 1]), | ||
map = null; | ||
while (aStart < aEnd || bStart < bEnd) { | ||
@@ -147,4 +147,4 @@ if (a[aStart] === b[bStart]) { | ||
let i = aStart, | ||
sequence = 1, | ||
t; | ||
sequence = 1, | ||
t; | ||
while (++i < aEnd && i < bEnd) { | ||
@@ -151,0 +151,0 @@ if ((t = map.get(a[i])) == null || t !== index + sequence) break; |
@@ -24,3 +24,3 @@ import { createRoot, createRenderEffect, mergeProps, createMemo, createComponent, untrack } from 'solid-js'; | ||
const t = typeof value, | ||
multi = marker !== undefined; | ||
multi = marker !== undefined; | ||
if (t === "string" || t === "number") { | ||
@@ -87,3 +87,3 @@ if (t === "number") value = value.toString(); | ||
let item = array[i], | ||
t; | ||
t; | ||
if (item == null || item === true || item === false) ; else if (Array.isArray(item)) { | ||
@@ -107,8 +107,8 @@ dynamic = normalizeIncomingArray(normalized, item) || dynamic; | ||
let bLength = b.length, | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = getNextSibling(a[aEnd - 1]), | ||
map = null; | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = getNextSibling(a[aEnd - 1]), | ||
map = null; | ||
while (aStart < aEnd || bStart < bEnd) { | ||
@@ -147,4 +147,4 @@ if (a[aStart] === b[bStart]) { | ||
let i = aStart, | ||
sequence = 1, | ||
t; | ||
sequence = 1, | ||
t; | ||
while (++i < aEnd && i < bEnd) { | ||
@@ -151,0 +151,0 @@ if ((t = map.get(a[i])) == null || t !== index + sequence) break; |
@@ -33,8 +33,8 @@ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createSignal, onCleanup, splitProps, createMemo, $DEVCOMP } from 'solid-js'; | ||
let bLength = b.length, | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = a[aEnd - 1].nextSibling, | ||
map = null; | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = a[aEnd - 1].nextSibling, | ||
map = null; | ||
while (aStart < aEnd || bStart < bEnd) { | ||
@@ -73,4 +73,4 @@ if (a[aStart] === b[bStart]) { | ||
let i = aStart, | ||
sequence = 1, | ||
t; | ||
sequence = 1, | ||
t; | ||
while (++i < aEnd && i < bEnd) { | ||
@@ -148,3 +148,3 @@ if ((t = map.get(a[i])) == null || t !== index + sequence) break; | ||
const classKeys = Object.keys(value || {}), | ||
prevKeys = Object.keys(prev); | ||
prevKeys = Object.keys(prev); | ||
let i, len; | ||
@@ -159,3 +159,3 @@ for (i = 0, len = prevKeys.length; i < len; i++) { | ||
const key = classKeys[i], | ||
classValue = !!value[key]; | ||
classValue = !!value[key]; | ||
if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue; | ||
@@ -267,4 +267,4 @@ toggleClassKey(node, key, true); | ||
let end = start, | ||
count = 0, | ||
current = []; | ||
count = 0, | ||
current = []; | ||
if (sharedConfig.context) { | ||
@@ -361,3 +361,10 @@ while (end) { | ||
sharedConfig.done = true; | ||
document.querySelectorAll("[id^=pl-]").forEach(elem => elem.remove()); | ||
document.querySelectorAll("[id^=pl-]").forEach(elem => { | ||
while (elem && elem.nodeType !== 8 && elem.nodeValue !== "pl-" + e) { | ||
let x = elem.nextSibling; | ||
elem.remove(); | ||
elem = x; | ||
} | ||
elem && elem.remove(); | ||
}); | ||
} | ||
@@ -379,3 +386,3 @@ while (node) { | ||
const t = typeof value, | ||
multi = marker !== undefined; | ||
multi = marker !== undefined; | ||
parent = multi && current[0] && current[0].parentNode || parent; | ||
@@ -447,3 +454,3 @@ if (t === "string" || t === "number") { | ||
let item = array[i], | ||
prev = current && current[i]; | ||
prev = current && current[i]; | ||
if (item instanceof Node) { | ||
@@ -542,6 +549,6 @@ normalized.push(item); | ||
const { | ||
useShadow | ||
} = props, | ||
marker = document.createTextNode(""), | ||
mount = props.mount || document.body; | ||
useShadow | ||
} = props, | ||
marker = document.createTextNode(""), | ||
mount = props.mount || document.body; | ||
function renderPortal() { | ||
@@ -563,5 +570,5 @@ if (sharedConfig.context) { | ||
const container = createElement(props.isSVG ? "g" : "div", props.isSVG), | ||
renderRoot = useShadow && container.attachShadow ? container.attachShadow({ | ||
mode: "open" | ||
}) : container; | ||
renderRoot = useShadow && container.attachShadow ? container.attachShadow({ | ||
mode: "open" | ||
}) : container; | ||
Object.defineProperty(container, "_$host", { | ||
@@ -568,0 +575,0 @@ get() { |
@@ -263,3 +263,3 @@ import { sharedConfig, splitProps } from 'solid-js'; | ||
const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t),_$HY.fe(e)}`; | ||
const REPLACE_SCRIPT = `function $df(e,t,n,o,d){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;o.replaceWith(n.content)}n.remove(),_$HY.set(e,t),_$HY.fe(e)}`; | ||
function renderToString(code, options = {}) { | ||
@@ -395,3 +395,3 @@ let scripts = ""; | ||
} else { | ||
buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div>`); | ||
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`); | ||
pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`); | ||
@@ -499,6 +499,6 @@ scriptFlushed = true; | ||
let classKeys = Object.keys(value), | ||
result = ""; | ||
result = ""; | ||
for (let i = 0, len = classKeys.length; i < len; i++) { | ||
const key = classKeys[i], | ||
classValue = !!value[key]; | ||
classValue = !!value[key]; | ||
if (!key || key === "undefined" || !classValue) continue; | ||
@@ -584,3 +584,3 @@ i && (result += " "); | ||
let left = 0, | ||
out = ""; | ||
out = ""; | ||
while (iDelim >= 0 && iAmp >= 0) { | ||
@@ -649,3 +649,4 @@ if (iDelim < iAmp) { | ||
const context = sharedConfig.context; | ||
sharedConfig.context = { ...context, | ||
sharedConfig.context = { | ||
...context, | ||
count: 0, | ||
@@ -708,17 +709,8 @@ id: `${context.id}${context.count++}-`, | ||
function replacePlaceholder(html, key, value) { | ||
const nextRegex = /(<[/]?span[^>]*>)/g; | ||
const marker = `<span id="pl-${key}">`; | ||
const marker = `<template id="pl-${key}">`; | ||
const close = `<!pl-${key}>`; | ||
const first = html.indexOf(marker); | ||
if (first === -1) return html; | ||
nextRegex.lastIndex = first + marker.length; | ||
let match; | ||
let open = 0, | ||
close = 0; | ||
while (match = nextRegex.exec(html)) { | ||
if (match[0][1] === "/") { | ||
close++; | ||
if (close > open) break; | ||
} else open++; | ||
} | ||
return html.slice(0, first) + value + html.slice(nextRegex.lastIndex); | ||
const last = html.indexOf(close, first + marker.length); | ||
return html.slice(0, first) + value + html.slice(last + close.length); | ||
} | ||
@@ -802,3 +794,3 @@ function Assets(props) { | ||
const comp = p.component, | ||
t = typeof comp; | ||
t = typeof comp; | ||
if (comp) { | ||
@@ -805,0 +797,0 @@ if (t === "function") return comp(others);else if (t === "string") { |
@@ -33,8 +33,8 @@ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createSignal, onCleanup, splitProps, createMemo } from 'solid-js'; | ||
let bLength = b.length, | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = a[aEnd - 1].nextSibling, | ||
map = null; | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = a[aEnd - 1].nextSibling, | ||
map = null; | ||
while (aStart < aEnd || bStart < bEnd) { | ||
@@ -73,4 +73,4 @@ if (a[aStart] === b[bStart]) { | ||
let i = aStart, | ||
sequence = 1, | ||
t; | ||
sequence = 1, | ||
t; | ||
while (++i < aEnd && i < bEnd) { | ||
@@ -147,3 +147,3 @@ if ((t = map.get(a[i])) == null || t !== index + sequence) break; | ||
const classKeys = Object.keys(value || {}), | ||
prevKeys = Object.keys(prev); | ||
prevKeys = Object.keys(prev); | ||
let i, len; | ||
@@ -158,3 +158,3 @@ for (i = 0, len = prevKeys.length; i < len; i++) { | ||
const key = classKeys[i], | ||
classValue = !!value[key]; | ||
classValue = !!value[key]; | ||
if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue; | ||
@@ -264,4 +264,4 @@ toggleClassKey(node, key, true); | ||
let end = start, | ||
count = 0, | ||
current = []; | ||
count = 0, | ||
current = []; | ||
if (sharedConfig.context) { | ||
@@ -358,3 +358,10 @@ while (end) { | ||
sharedConfig.done = true; | ||
document.querySelectorAll("[id^=pl-]").forEach(elem => elem.remove()); | ||
document.querySelectorAll("[id^=pl-]").forEach(elem => { | ||
while (elem && elem.nodeType !== 8 && elem.nodeValue !== "pl-" + e) { | ||
let x = elem.nextSibling; | ||
elem.remove(); | ||
elem = x; | ||
} | ||
elem && elem.remove(); | ||
}); | ||
} | ||
@@ -376,3 +383,3 @@ while (node) { | ||
const t = typeof value, | ||
multi = marker !== undefined; | ||
multi = marker !== undefined; | ||
parent = multi && current[0] && current[0].parentNode || parent; | ||
@@ -444,3 +451,3 @@ if (t === "string" || t === "number") { | ||
let item = array[i], | ||
prev = current && current[i]; | ||
prev = current && current[i]; | ||
if (item instanceof Node) { | ||
@@ -539,6 +546,6 @@ normalized.push(item); | ||
const { | ||
useShadow | ||
} = props, | ||
marker = document.createTextNode(""), | ||
mount = props.mount || document.body; | ||
useShadow | ||
} = props, | ||
marker = document.createTextNode(""), | ||
mount = props.mount || document.body; | ||
function renderPortal() { | ||
@@ -560,5 +567,5 @@ if (sharedConfig.context) { | ||
const container = createElement(props.isSVG ? "g" : "div", props.isSVG), | ||
renderRoot = useShadow && container.attachShadow ? container.attachShadow({ | ||
mode: "open" | ||
}) : container; | ||
renderRoot = useShadow && container.attachShadow ? container.attachShadow({ | ||
mode: "open" | ||
}) : container; | ||
Object.defineProperty(container, "_$host", { | ||
@@ -565,0 +572,0 @@ get() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
790821
22029