Comparing version 1.6.12 to 1.6.13
@@ -7,3 +7,2 @@ const equalFn = (a, b) => a === b; | ||
const ERROR = Symbol("error"); | ||
const BRANCH = Symbol("branch"); | ||
function castError(err) { | ||
@@ -21,5 +20,19 @@ if (err instanceof Error || typeof err === "string") return err; | ||
context: null, | ||
owner: null | ||
owner: null, | ||
owned: null, | ||
cleanups: null | ||
}; | ||
let Owner = null; | ||
function createOwner() { | ||
const o = { | ||
owner: Owner, | ||
context: null, | ||
owned: null, | ||
cleanups: null | ||
}; | ||
if (Owner) { | ||
if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o); | ||
} | ||
return o; | ||
} | ||
function createRoot(fn, detachedOwner) { | ||
@@ -29,3 +42,5 @@ const owner = Owner, | ||
context: null, | ||
owner: detachedOwner === undefined ? owner : detachedOwner | ||
owner: detachedOwner === undefined ? owner : detachedOwner, | ||
owned: null, | ||
cleanups: null | ||
}; | ||
@@ -35,3 +50,3 @@ Owner = root; | ||
try { | ||
result = fn(() => {}); | ||
result = fn(fn.length === 0 ? () => {} : () => cleanNode(root)); | ||
} catch (err) { | ||
@@ -50,6 +65,3 @@ handleError(err); | ||
function createComputed(fn, value) { | ||
Owner = { | ||
owner: Owner, | ||
context: null | ||
}; | ||
Owner = createOwner(); | ||
try { | ||
@@ -71,6 +83,3 @@ fn(value); | ||
function createMemo(fn, value) { | ||
Owner = { | ||
owner: Owner, | ||
context: null | ||
}; | ||
Owner = createOwner(); | ||
let v; | ||
@@ -111,5 +120,4 @@ try { | ||
function onCleanup(fn) { | ||
let node; | ||
if (Owner && (node = lookup(Owner, BRANCH))) { | ||
if (!node.cleanups) node.cleanups = [fn];else node.cleanups.push(fn); | ||
if (Owner) { | ||
if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn); | ||
} | ||
@@ -119,5 +127,9 @@ return fn; | ||
function cleanNode(node) { | ||
if (node.owned) { | ||
for (let i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]); | ||
node.owned = null; | ||
} | ||
if (node.cleanups) { | ||
for (let i = 0; i < node.cleanups.length; i++) node.cleanups[i](); | ||
node.cleanups = undefined; | ||
node.cleanups = null; | ||
} | ||
@@ -392,7 +404,4 @@ } | ||
}); | ||
onCleanup(() => cleanNode(clean)); | ||
createMemo(() => { | ||
Owner.context = { | ||
[BRANCH]: clean = {} | ||
}; | ||
clean = Owner; | ||
return res = props.children; | ||
@@ -447,3 +456,3 @@ }); | ||
read.error = undefined; | ||
read.state = "initialValue" in options ? "resolved" : "unresolved"; | ||
read.state = "initialValue" in options ? "ready" : "unresolved"; | ||
Object.defineProperty(read, "latest", { | ||
@@ -481,3 +490,3 @@ get() { | ||
read.loading = false; | ||
read.state = "resolved"; | ||
read.state = "ready"; | ||
ctx.resources[id].data = res; | ||
@@ -572,11 +581,5 @@ p = null; | ||
let done; | ||
let clean; | ||
const ctx = sharedConfig.context; | ||
const id = ctx.id + ctx.count; | ||
const o = Owner; | ||
if (o) { | ||
if (o.context) o.context[BRANCH] = clean = {};else o.context = { | ||
[BRANCH]: clean = {} | ||
}; | ||
} | ||
const o = createOwner(); | ||
const value = ctx.suspense[id] || (ctx.suspense[id] = { | ||
@@ -596,2 +599,3 @@ resources: new Map(), | ||
}); | ||
o && cleanNode(o); | ||
return runWithOwner(o, () => { | ||
@@ -601,3 +605,2 @@ return createComponent(SuspenseContext.Provider, { | ||
get children() { | ||
clean && cleanNode(clean); | ||
return props.children; | ||
@@ -604,0 +607,0 @@ } |
{ | ||
"name": "solid-js", | ||
"description": "A declarative JavaScript library for building user interfaces.", | ||
"version": "1.6.12", | ||
"version": "1.6.13", | ||
"author": "Ryan Carniato", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -9,3 +9,2 @@ export declare const equalFn: <T>(a: T, b: T) => boolean; | ||
export type Signal<T> = [get: Accessor<T>, set: Setter<T>]; | ||
export declare const BRANCH: unique symbol; | ||
export declare function castError(err: any): string | Error; | ||
@@ -16,3 +15,6 @@ export declare let Owner: Owner | null; | ||
context: any | null; | ||
owned: Owner[] | null; | ||
cleanups: (() => void)[] | null; | ||
} | ||
export declare function createOwner(): Owner; | ||
export declare function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: typeof Owner): T; | ||
@@ -37,5 +39,3 @@ export declare function createSignal<T>(value: T, options?: { | ||
export declare function onCleanup(fn: () => void): () => void; | ||
export declare function cleanNode(node: { | ||
cleanups?: Function[] | null; | ||
}): void; | ||
export declare function cleanNode(node: Owner): void; | ||
export declare function onError(fn: (err: any) => void): void; | ||
@@ -42,0 +42,0 @@ export declare function getListener(): null; |
@@ -462,3 +462,6 @@ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js'; | ||
const value = String(item); | ||
if (prev && prev.nodeType === 3 && prev.data === value) { | ||
if (value === "<!>") { | ||
if (prev && prev.nodeType === 8) normalized.push(prev); | ||
} else if (prev && prev.nodeType === 3) { | ||
prev.data = value; | ||
normalized.push(prev); | ||
@@ -465,0 +468,0 @@ } else normalized.push(document.createTextNode(value)); |
@@ -1,2 +0,2 @@ | ||
import { sharedConfig, splitProps } from 'solid-js'; | ||
import { sharedConfig, createRoot, splitProps } from 'solid-js'; | ||
export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, mergeProps } from 'solid-js'; | ||
@@ -280,3 +280,7 @@ | ||
}; | ||
let html = resolveSSRNode(escape(code())); | ||
let html = createRoot(d => { | ||
resolveSSRNode(escape(code())); | ||
d(); | ||
return r; | ||
}); | ||
sharedConfig.context.noHydrate = true; | ||
@@ -307,2 +311,3 @@ html = injectAssets(sharedConfig.context.assets, html); | ||
} = options; | ||
let dispose; | ||
const blockingResources = []; | ||
@@ -321,2 +326,3 @@ const registry = new Map(); | ||
completed = true; | ||
dispose(); | ||
} | ||
@@ -409,3 +415,6 @@ }; | ||
}; | ||
let html = resolveSSRNode(escape(code())); | ||
let html = createRoot(d => { | ||
dispose = d; | ||
return resolveSSRNode(escape(code())); | ||
}); | ||
function doShell() { | ||
@@ -412,0 +421,0 @@ sharedConfig.context = context; |
@@ -462,3 +462,6 @@ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js'; | ||
const value = String(item); | ||
if (prev && prev.nodeType === 3 && prev.data === value) { | ||
if (value === "<!>") { | ||
if (prev && prev.nodeType === 8) normalized.push(prev); | ||
} else if (prev && prev.nodeType === 3) { | ||
prev.data = value; | ||
normalized.push(prev); | ||
@@ -465,0 +468,0 @@ } else normalized.push(document.createTextNode(value)); |
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
798156
22225