Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/create-owner-internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"solid-js": patch
"@solidjs/web": patch
---

`createOwner` leaves solid-js's public types: it is typed only through `solid-js/internal`, like the boundary primitives behind `Errored`, `Loading` and `Reveal` (#3709). It stays a runtime export for the renderers. Solid 1.x had no `createOwner`, and application code that used it in an RC should host a scope with `createRoot()` (its `dispose` argument can be passed around as a plain function) and re-enter one with `runWithOwner()`. A detached `owner.dispose` keeps throwing, since it is a method and not part of the public API (#4444).
7 changes: 6 additions & 1 deletion packages/solid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export {
$TRACK,
action,
affects,
createOwner,
createReaction,
createTrackedEffect,
deep,
Expand Down Expand Up @@ -41,6 +40,12 @@ export {
} from "@solidjs/signals";
/** @internal — the key a root owner carries `render`'s `onError` under, for the web runtime. */
export { ROOT_ERROR_HOOK } from "@solidjs/signals";
// `createOwner`: a bare owner, for the runtimes' own scopes (`NoHydration`,
// `Portal`, a frame's fill). Exported at runtime (typed for renderers through
// `solid-js/internal`), `@internal` because application code hosts a scope
// with `createRoot()` and re-enters one with `runWithOwner()`, as in 1.x.
/** @internal */
export { createOwner } from "@solidjs/signals";
export { from } from "./from.js";

export type {
Expand Down
17 changes: 16 additions & 1 deletion packages/solid/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
* The boundary primitives behind `Errored`, `Loading`, and `Reveal` are
* read back the same way (real on both entries), for renderers that
* build boundaries without the components, and so are `sharedConfig`
* (the hydration/SSR coordination object) and the `$DEVCOMP` brand.
* (the hydration/SSR coordination object), the `$DEVCOMP` brand and
* `createOwner` (a bare owner for a runtime's own scope).
*
* Not here: the container-trace materializer. It lives in its own entry,
* `solid-js/internal/container-trace`, so the store engine it builds on can
Expand All @@ -37,6 +38,7 @@ import type {
Accessor,
Component,
DynamicOptions,
Owner,
RevealOrder,
ServerErrorHook,
ServerErrorSite
Expand Down Expand Up @@ -171,6 +173,19 @@ export const getProjectionTrace: (
export const shareAsyncIterable: <T>(source: AsyncIterable<T>) => AsyncIterable<T> =
core.shareAsyncIterable;

/**
* A fresh owner under the current one (or a detached root if there is none),
* for a runtime's own scope: `NoHydration`, `Portal`, a frame's fill. `id`
* seeds the hydration ids of the tree it owns; `transparent` lets that tree
* draw ids from the parent's counter. Its `dispose` is a method
* (`owner.dispose()`), not a detached function. Not application API: an app
* hosts a scope with `createRoot()` and re-enters one with `runWithOwner()`.
*/
export const createOwner: (options?: {
id?: string;
transparent?: boolean;
}) => Owner & { dispose(self?: boolean): void } = core.createOwner;

/** The primitive behind `<Errored>`: `fn()`, or `fallback(error, reset)` once something under it throws. */
export const createErrorBoundary: <T, U>(
fn: () => T,
Expand Down
7 changes: 6 additions & 1 deletion packages/solid/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export {
createDeferred,
createOptimistic,
createOptimisticStore,
createOwner,
createProjection,
createReaction,
createRenderEffect,
Expand Down Expand Up @@ -58,6 +57,12 @@ export {
ROOT_ERROR_HOOK
} from "./signals.js";
export type { ClientErrorContext, ClientErrorHook, ClientErrorsConfig } from "./signals.js";
// `createOwner`: a bare owner, for the runtimes' own scopes (`NoHydration`,
// `Portal`, a frame's fill). Exported at runtime (typed for renderers through
// `solid-js/internal`), `@internal` because application code hosts a scope
// with `createRoot()` and re-enters one with `runWithOwner()`, as in 1.x.
/** @internal */
export { createOwner } from "./signals.js";

// All type re-exports from signals
export type {
Expand Down
2 changes: 2 additions & 0 deletions packages/web/frames/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import {
OBSERVE,
createMemo,
// @ts-expect-error `createOwner` is `@internal` in solid-js's declarations (typed in
// solid-js/internal); importing it from solid-js keeps it one binding in the bundle.
createOwner,
createRenderEffect,
createSignal,
Expand Down
2 changes: 2 additions & 0 deletions packages/web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
import {
createComponent,
createMemo,
// @ts-expect-error `createOwner` is `@internal` in solid-js's declarations (typed in
// solid-js/internal); importing it from solid-js keeps it one binding in the bundle.
createOwner,
createRoot,
createSignal,
Expand Down
3 changes: 2 additions & 1 deletion packages/web/test/runtime/head.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* first registration and stays for the whole file.
*/
import * as r from "../../src/client.js";
import { createRoot, createSignal, flush, createOwner, runWithOwner } from "solid-js";
import { createRoot, createSignal, flush, runWithOwner } from "solid-js";
import { createOwner } from "solid-js/internal";
import { peekNextChildId } from "@solidjs/signals";

// Registry applies on a microtask.
Expand Down
3 changes: 2 additions & 1 deletion packages/web/test/wait-asset.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* allocated after the call).
*/
import { describe, expect, test } from "vitest";
import { createRoot, createOwner, runWithOwner, getNextChildId, flush } from "solid-js";
import { createRoot, runWithOwner, getNextChildId, flush } from "solid-js";
import { createOwner } from "solid-js/internal";
import { effect } from "../src/render.js";
import { waitAsset } from "../src/client.js";

Expand Down
Loading