@isoloop/runtime 0.0.0-next.69da74b → 0.0.0-next.800569e
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.
- package/dist/bootstrap.js +1003 -178
- package/dist/index.d.ts +1 -1
- package/dist/testing.d.ts +6 -1
- package/dist/testing.js +47 -13
- package/dist/{vanilla-NeyOhMib.d.ts → vanilla-nAEAFMUP.d.ts} +17 -0
- package/dist/worker.js +2706 -0
- package/package.json +12 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as defineIsolate, c as ScrollIntoViewOptionsLike, i as REQUIRES, l as BusClient, n as IsolateDefinition, o as HostApi, r as IsolateRoot, s as HostCallError, t as IsolateContext, u as SubscribeOptions } from "./vanilla-
|
|
1
|
+
import { a as defineIsolate, c as ScrollIntoViewOptionsLike, i as REQUIRES, l as BusClient, n as IsolateDefinition, o as HostApi, r as IsolateRoot, s as HostCallError, t as IsolateContext, u as SubscribeOptions } from "./vanilla-nAEAFMUP.js";
|
|
2
2
|
import { BusError } from "@isoloop/protocol";
|
|
3
3
|
export { type BusClient, BusError, type HostApi, HostCallError, type IsolateContext, type IsolateDefinition, type IsolateRoot, REQUIRES, type ScrollIntoViewOptionsLike, type SubscribeOptions, defineIsolate };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as HostApi, t as IsolateContext } from "./vanilla-
|
|
1
|
+
import { o as HostApi, t as IsolateContext } from "./vanilla-nAEAFMUP.js";
|
|
2
2
|
import { ShutdownReason } from "@isoloop/protocol";
|
|
3
3
|
export type TestContextOptions = {
|
|
4
4
|
id?: string;
|
|
@@ -12,6 +12,11 @@ export type TestContextOptions = {
|
|
|
12
12
|
};
|
|
13
13
|
export type TestContext = {
|
|
14
14
|
readonly ctx: IsolateContext;
|
|
15
|
+
/** What `ctx.reportError` got, in order. */
|
|
16
|
+
readonly errors: {
|
|
17
|
+
error: unknown;
|
|
18
|
+
fatal: boolean;
|
|
19
|
+
}[];
|
|
15
20
|
/** Delivers a record to every subscription on `topic`, in order. */
|
|
16
21
|
emit: (topic: string, value: unknown, key?: string) => void;
|
|
17
22
|
/** Runs `onReset` of every subscription on `topic` (a bus restart lost it, ADR 0007). */
|
package/dist/testing.js
CHANGED
|
@@ -10,7 +10,9 @@ function createTestContext(o = {}) {
|
|
|
10
10
|
const subs = /* @__PURE__ */ new Set();
|
|
11
11
|
const published = [];
|
|
12
12
|
const shutdownFns = [];
|
|
13
|
+
const errors = [];
|
|
13
14
|
let offset = 0;
|
|
15
|
+
let portal;
|
|
14
16
|
const bus = {
|
|
15
17
|
publish(topic, rec) {
|
|
16
18
|
published.push(rec.key === void 0 ? {
|
|
@@ -57,20 +59,52 @@ function createTestContext(o = {}) {
|
|
|
57
59
|
requestCanvas: () => Promise.resolve(new OffscreenCanvas(1, 1)),
|
|
58
60
|
...o.host
|
|
59
61
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
const ctx = {
|
|
63
|
+
id: o.id ?? "test",
|
|
64
|
+
config: o.config ?? null,
|
|
65
|
+
root: o.root,
|
|
66
|
+
portalRoot: void 0,
|
|
67
|
+
reportError: (error, ro = {}) => {
|
|
68
|
+
errors.push({
|
|
69
|
+
error,
|
|
70
|
+
fatal: ro.fatal ?? true
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
host,
|
|
74
|
+
bus,
|
|
75
|
+
styles: () => {},
|
|
76
|
+
setValue: () => {},
|
|
77
|
+
onShutdown: (fn) => {
|
|
78
|
+
shutdownFns.push(fn);
|
|
73
79
|
},
|
|
80
|
+
keepAwake: () => () => {}
|
|
81
|
+
};
|
|
82
|
+
Object.defineProperty(ctx, "portalRoot", {
|
|
83
|
+
enumerable: false,
|
|
84
|
+
get() {
|
|
85
|
+
const root = o.root;
|
|
86
|
+
if (!root) return void 0;
|
|
87
|
+
if (!portal) {
|
|
88
|
+
const doc = Reflect.get(root, "ownerDocument");
|
|
89
|
+
const make = doc ? Reflect.get(doc, "createElement") : void 0;
|
|
90
|
+
if (typeof make !== "function") return void 0;
|
|
91
|
+
const div = Reflect.apply(make, doc, ["div"]);
|
|
92
|
+
if (typeof div !== "object" || div === null) return void 0;
|
|
93
|
+
const set = Reflect.get(div, "setAttribute");
|
|
94
|
+
const add = Reflect.get(root, "appendChild");
|
|
95
|
+
if (typeof set !== "function" || typeof add !== "function") return void 0;
|
|
96
|
+
Reflect.apply(set, div, ["data-isoloop-portal", ""]);
|
|
97
|
+
queueMicrotask(() => {
|
|
98
|
+
if (Reflect.get(div, "parentNode") !== root) Reflect.apply(add, root, [div]);
|
|
99
|
+
});
|
|
100
|
+
portal = div;
|
|
101
|
+
}
|
|
102
|
+
return portal;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
ctx,
|
|
107
|
+
errors,
|
|
74
108
|
published,
|
|
75
109
|
emit(topic, value, key) {
|
|
76
110
|
const rec = {
|
|
@@ -95,6 +95,14 @@ type IsolateContext<Root = IsolateRoot> = {
|
|
|
95
95
|
readonly config: unknown;
|
|
96
96
|
/** The render target; `undefined` for a headless isolate (ADR 0008). */
|
|
97
97
|
readonly root: Root | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* A container inside `root` for modals, tooltips, toasts and menus that
|
|
100
|
+
* libraries would otherwise render into `document.body`, which reaches no
|
|
101
|
+
* surface (ADR 0015, decision 11). Made on first use, typically from a
|
|
102
|
+
* component while it renders, and added as `root`'s last child once that
|
|
103
|
+
* render has committed; `undefined` for a headless isolate.
|
|
104
|
+
*/
|
|
105
|
+
readonly portalRoot: Root | undefined;
|
|
98
106
|
readonly host: HostApi;
|
|
99
107
|
/** The log bus, on its own port to the bus worker (design §5). */
|
|
100
108
|
readonly bus: BusClient;
|
|
@@ -109,6 +117,15 @@ type IsolateContext<Root = IsolateRoot> = {
|
|
|
109
117
|
setValue(node: unknown, value: string, opts?: {
|
|
110
118
|
force?: boolean;
|
|
111
119
|
}): void;
|
|
120
|
+
/**
|
|
121
|
+
* Reports an error as this isolate's own: framework adapters call it for a
|
|
122
|
+
* render error their boundary caught, so in a pool it crashes only this
|
|
123
|
+
* member, not the whole worker (ADR 0015, decision 8). `fatal` (the
|
|
124
|
+
* default) crashes the isolate, which the host restarts as usual.
|
|
125
|
+
*/
|
|
126
|
+
reportError(error: unknown, opts?: {
|
|
127
|
+
fatal?: boolean;
|
|
128
|
+
}): void;
|
|
112
129
|
/** Runs on stop, within the host's grace period, before the worker goes. */
|
|
113
130
|
onShutdown(fn: (reason: ShutdownReason) => void | Promise<void>): void;
|
|
114
131
|
/**
|