@reactivescript/runtime 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,186 @@
1
+ import { createContext, flush, getOwner } from "solid-js";
2
+ export { flush };
3
+ export type Acc = () => unknown;
4
+ export type Writer = {
5
+ set: (v: unknown) => void;
6
+ path: (keys: (string | number)[], v: unknown) => void;
7
+ guess: (v: unknown, keys?: (string | number)[]) => void;
8
+ };
9
+ export type Entry = {
10
+ get?: Acc;
11
+ w?: Writer;
12
+ value?: unknown;
13
+ };
14
+ export declare const ERR: {
15
+ toString: () => string;
16
+ };
17
+ export declare const PENDING_MARK: {
18
+ toString: () => string;
19
+ };
20
+ export declare const fmt: (v: unknown) => string;
21
+ type ErrorClass = ((...args: unknown[]) => Error) & {
22
+ cls: new (...args: unknown[]) => Error;
23
+ errorClass: string;
24
+ };
25
+ /** `e catch (x: C) => alt`, reactive: an error boundary around the read whose fallback is the value (Solid: an errored read
26
+ * reaches the nearest boundary even inside a JS `try`). The fallback is decided when read, so a change of class re-decides it. */
27
+ declare function catchAcc(f: () => unknown, match: (err: unknown) => boolean, alt: (err: unknown) => unknown): () => unknown;
28
+ /** Imperative scope: an ordinary try. */
29
+ declare function tryCatch(f: () => unknown, match: (err: unknown) => boolean, alt: (err: unknown) => unknown): unknown;
30
+ /** A controllable flight: an async iterable (a stream — each resolve is a landing) that actions await through `first`. */
31
+ export declare class Flight {
32
+ key: string;
33
+ first: Promise<unknown>;
34
+ private settleFirst;
35
+ private rejectFirst;
36
+ private queue;
37
+ private waiters;
38
+ private started;
39
+ constructor(key: string);
40
+ private push;
41
+ resolve(v: unknown): void;
42
+ reject(e: unknown): void;
43
+ [Symbol.asyncIterator](): {
44
+ next: () => Promise<IteratorResult<unknown>>;
45
+ return: () => Promise<{
46
+ value: undefined;
47
+ done: true;
48
+ }>;
49
+ };
50
+ }
51
+ export declare function createApp(opts: {
52
+ root: any;
53
+ api?: Record<string, (...a: any[]) => unknown>;
54
+ }): {
55
+ root: any;
56
+ log: string[];
57
+ flights: Map<string, Flight>;
58
+ lastKey: Map<string, string>;
59
+ asyncError: unknown;
60
+ /** Mount `view` on the root: build it, or (SV-3) adopt the page the server streamed into it. */
61
+ mount(view: () => unknown, hydrating?: boolean): any;
62
+ B: Record<string, any>;
63
+ /** `import pure { f } from "./api"`: every function is a flight keyed by its name and formatted arguments. */
64
+ /** MO-8: a class `api.d.rx` declares as an error: the real module's, or (in the harness) a stand-in `C(message)`. */
65
+ jsError: (name: string) => unknown;
66
+ api: (name: string) => (...a: any[]) => unknown;
67
+ reg(name: string, e: Entry): void;
68
+ lookup(name: string): Entry;
69
+ dget(name: string, live?: boolean): any;
70
+ dset(name: string, keys: (string | number)[], v: unknown, guess?: boolean): void;
71
+ /** `source x := e`: atomic → a signal; structured → a store behind a signal slot, so the root can be replaced (ST-1, ST-2a). */
72
+ source(name: string, init: unknown): [Acc, Writer];
73
+ /** `source x = e` (ST-5): createSignal(fn); with a guess written to it, a createOptimistic layer over that truth (AC-3);
74
+ * written or probed by path, createStore(fn, {}) whose derive writes its draft. */
75
+ question(name: string, compute: (prev: unknown) => unknown, opts: {
76
+ loadingValue?: unknown;
77
+ } | undefined, mode: {
78
+ optimistic: boolean;
79
+ structured: boolean;
80
+ }, key?: string): [Acc, Writer];
81
+ memo: (name: string | null, fn: (prev: unknown) => unknown, opts?: {
82
+ loadingValue?: unknown;
83
+ }) => Acc;
84
+ deferred: (name: string, fn: (prev: unknown) => unknown, opts?: {
85
+ loadingValue?: unknown;
86
+ }) => Acc;
87
+ /** `x key k = e` (ST-4): a keyed projection. */
88
+ keyed: (name: string, key: string, fn: () => unknown) => Acc;
89
+ /** `x = draft(pre x -> seed) { … }` (ST-3). */
90
+ draft: (seed: unknown, body: (d: any) => void) => Acc;
91
+ /** `pre y` of another node (C-2): a companion memo carrying (current, previous), owned where `y` is declared. */
92
+ pre: (get: Acc) => Acc;
93
+ firstPaint: (f: () => unknown) => {
94
+ loadingValue: any;
95
+ };
96
+ /** `effect (…) { … }`: compute, then apply; an error is an answer the apply receives (E-12); fires on a differing value (EF-2); a store enters whole, as a snapshot. */
97
+ effect(n: number, inputs: () => unknown[], apply: (p: unknown[]) => unknown): void;
98
+ /** `action f(…) { … }` (AC-1): a generator; a statement-level `await` is a hold-safe yield. */
99
+ action(gen: (...a: unknown[]) => Generator<unknown, unknown, unknown>): (...a: unknown[]) => Promise<unknown>;
100
+ awaited: (v: unknown) => unknown;
101
+ /** RG-8: Solid's Portal — client-only: the server renders nothing for it, the browser renders it once it has the page. */
102
+ Portal: any;
103
+ /** CSS-2: a dynamic class with the view's scope class after it. */
104
+ scopedClass: (v: unknown, hash: string) => string;
105
+ /** SV-7b: a client question — not asked on the server; the browser asks it once hydrated (Solid's \`ssrSource: "client"\`). */
106
+ clientQuestion: (o?: {
107
+ loadingValue?: unknown;
108
+ }) => {
109
+ ssrSource: string;
110
+ loadingValue?: unknown;
111
+ };
112
+ /** 12 SF-2: a server fn as the client calls it — every call a flight. Asked in reactive scope it is a question, one
113
+ * flight per arguments, as a JS import's; in imperative scope each call is a new request. \`fn\` is the module-level
114
+ * \`"use server"\` function (SF-7a): the body in place, or — once Solid's \`transformDirectives\` has made it a reference
115
+ * — a request to the server. */
116
+ serverRef(name: string, fn: (...a: unknown[]) => Promise<unknown>): (...args: unknown[]) => Flight;
117
+ /** SF-6: a server fn's body (a generator, as an action's), driven by promises — not by an action: it is no change of
118
+ * the client's — behind a wire that copies arguments and result and lets only declared failures through. */
119
+ serverCall(name: string, gen: (...a: unknown[]) => Generator<unknown, unknown, unknown>, args: unknown[]): Promise<unknown>;
120
+ hoisted(name: string, get: Acc): void;
121
+ until: (p: () => unknown) => any;
122
+ onSettled: (f: () => void) => any;
123
+ onFlush: (f: () => void) => any;
124
+ refresh(name: string, get: Acc): void;
125
+ affects: (get: Acc) => any;
126
+ preOr: (v: unknown, init: () => unknown) => unknown;
127
+ module(key: unknown, factory: (rt: unknown) => Record<string, unknown>): Record<string, unknown>;
128
+ owner: () => any;
129
+ /** `context x: T = d` (RG-7): the declaration is the identity; `d`, if any, is evaluated once, owned where it is declared. */
130
+ /** `context x: T = d` (RG-7): the declaration is the identity (a sentinel default: absence is ours to decide); `d` is
131
+ * evaluated once, owned where it is declared — created now, so it takes its id there on both sides (SV-3). */
132
+ context(name: string, dflt: (() => unknown) | null): {
133
+ name: string;
134
+ ctx: ReturnType<typeof createContext<Entry | undefined>>;
135
+ dflt: (() => unknown) | null;
136
+ owner: ReturnType<typeof getOwner>;
137
+ dv: Entry | null;
138
+ };
139
+ provide(c: {
140
+ name: string;
141
+ ctx: ReturnType<typeof createContext<Entry | undefined>>;
142
+ dflt: (() => unknown) | null;
143
+ owner: ReturnType<typeof getOwner>;
144
+ dv: Entry | null;
145
+ }, e: Entry): void;
146
+ use(c: {
147
+ name: string;
148
+ ctx: ReturnType<typeof createContext<Entry | undefined>>;
149
+ dflt: (() => unknown) | null;
150
+ owner: ReturnType<typeof getOwner>;
151
+ dv: Entry | null;
152
+ }, owner: ReturnType<typeof getOwner>): Entry;
153
+ useGet(c: {
154
+ name: string;
155
+ ctx: ReturnType<typeof createContext<Entry | undefined>>;
156
+ dflt: (() => unknown) | null;
157
+ owner: ReturnType<typeof getOwner>;
158
+ dv: Entry | null;
159
+ }, owner: ReturnType<typeof getOwner>): unknown;
160
+ runWithOwner: any;
161
+ /** An imperative read sees σ (H-10): a pending value is a value; a snapshot of an error throws it (R-f-7). */
162
+ snapshot(get: Acc): any;
163
+ errorClass: (name: string, params: string[], message: (...args: unknown[]) => unknown) => ErrorClass;
164
+ isA: (err: unknown, classes: unknown[] | undefined) => boolean;
165
+ PANIC: {
166
+ readonly panic: true;
167
+ };
168
+ catchMemo: typeof catchAcc;
169
+ tryCatch: typeof tryCatch;
170
+ catchRead: (f: () => unknown, match: (err: unknown) => boolean, alt: (err: unknown) => unknown) => unknown;
171
+ throw: (e: unknown) => never;
172
+ eq: (a: unknown, b: unknown) => boolean;
173
+ untrack: any;
174
+ latest: (f: () => unknown) => any;
175
+ isPending: (f: () => unknown) => any;
176
+ fmt: (v: unknown) => string;
177
+ show: (v: unknown) => unknown;
178
+ /** `errored fallback(e: A | B)`: a failure of another class passes to the boundary above (R-f-4) — the fallback hands it out
179
+ * and a memo throws it there (a rethrow from the fallback itself did not recover until solidjs/solid#4277: ref/oracle/repros/dv7-rethrow.mjs). */
180
+ TypedErrored(props: {
181
+ classes: unknown[];
182
+ fallback: (err: Acc) => unknown;
183
+ children: unknown;
184
+ }): any;
185
+ };
186
+ export type App = ReturnType<typeof createApp>;
package/dist/web.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./types/rt-web.js";