@atolljs/islands 0.1.12 → 0.1.14
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/app.d.ts +57 -0
- package/dist/callbackProps.d.ts +35 -0
- package/dist/chunk-TX4FAHRB.js +1187 -0
- package/dist/contract.d.ts +96 -0
- package/dist/devtoolsCommands.d.ts +21 -0
- package/dist/devtoolsPreview.d.ts +8 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +30 -0
- package/dist/island.d.ts +175 -0
- package/dist/memory.d.ts +34 -0
- package/dist/metrics.d.ts +38 -0
- package/dist/ops.d.ts +339 -0
- package/dist/worker/defineWorkers.d.ts +207 -0
- package/dist/worker/dom/css.d.ts +24 -0
- package/dist/worker/dom/document.d.ts +274 -0
- package/dist/worker/dom/element.d.ts +199 -0
- package/dist/worker/dom/html.d.ts +7 -0
- package/dist/worker/dom/node.d.ts +172 -0
- package/dist/worker/dom/resizeObserver.d.ts +29 -0
- package/dist/worker/dom/selectors.d.ts +17 -0
- package/dist/worker/dom/window.d.ts +80 -0
- package/dist/worker/index.d.ts +33 -0
- package/dist/worker/index.js +3159 -0
- package/dist/worker/instance.d.ts +187 -0
- package/dist/worker/proxyDom.d.ts +10 -0
- package/dist/worker/subIsland.d.ts +11 -0
- package/package.json +15 -5
- package/src/index.ts +1 -1
- package/src/island.ts +13 -3
- package/src/worker/subIsland.ts +5 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `ResizeObserver` over the pushed-measure channel — the class
|
|
3
|
+
* `globalThis.ResizeObserver`/`window.ResizeObserver` resolve to inside an
|
|
4
|
+
* island instance. Each `observe(el)` registers a `doc.observeSize`
|
|
5
|
+
* subscription (which emits the `measure` op once per element); each pushed
|
|
6
|
+
* rect invokes the callback with a single-entry batch, matching how real RO
|
|
7
|
+
* delivers per-element observations (the driver already batches the wire
|
|
8
|
+
* push, the DOM API just doesn't promise same-batch grouping).
|
|
9
|
+
*
|
|
10
|
+
* Entries carry the fields layout libraries read: `target`, `contentRect`
|
|
11
|
+
* (the measured box), and `borderBoxSize`/`contentBoxSize`/`devicePixelContentBoxSize`
|
|
12
|
+
* arrays (echarts zrender, recharts' ResponsiveContainer, and RO-polyfill-
|
|
13
|
+
* style code paths). Box options are accepted but ignored — the channel
|
|
14
|
+
* delivers one box and it answers both reads.
|
|
15
|
+
*
|
|
16
|
+
* No doc resolvable (module-scope or post-unmount construction) means there
|
|
17
|
+
* is nothing that could ever be measured — observe() silently no-ops rather
|
|
18
|
+
* than pinning a foreign document, the same resolution rule the
|
|
19
|
+
* `document`/`window` global dispatchers use.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ProxyResizeObserver {
|
|
22
|
+
private readonly _callback;
|
|
23
|
+
/** proxy el → the observeSize detacher (unobserve/disconnect paths). */
|
|
24
|
+
private readonly _targets;
|
|
25
|
+
constructor(callback: ResizeObserverCallback);
|
|
26
|
+
observe(target: unknown, _options?: ResizeObserverOptions): void;
|
|
27
|
+
unobserve(target: unknown): void;
|
|
28
|
+
disconnect(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProxyElement } from './element.js';
|
|
2
|
+
interface CompoundSelector {
|
|
3
|
+
tag?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
classes: string[];
|
|
6
|
+
attrs: Array<{
|
|
7
|
+
name: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseCompound(part: string, sel: string): CompoundSelector;
|
|
12
|
+
export declare function parseSelector(selector: string): CompoundSelector[];
|
|
13
|
+
export declare function matchCompound(el: ProxyElement, c: CompoundSelector): boolean;
|
|
14
|
+
/** `el` matches the last compound; each earlier compound must match some
|
|
15
|
+
* ancestor above the previous match — the descendant combinator. */
|
|
16
|
+
export declare function matchesChain(el: ProxyElement, chain: CompoundSelector[]): boolean;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type ProxyDocument } from './document.js';
|
|
2
|
+
import { ProxyResizeObserver } from './resizeObserver.js';
|
|
3
|
+
import { type ProxyEventHandler } from './node.js';
|
|
4
|
+
/** What installDomShim puts on globalThis.window — a facade OBJECT, not
|
|
5
|
+
* globalThis itself (the pool's message channel lives on self). */
|
|
6
|
+
export interface WindowShim {
|
|
7
|
+
document: ProxyDocument;
|
|
8
|
+
navigator: {
|
|
9
|
+
userAgent: string;
|
|
10
|
+
};
|
|
11
|
+
location: {
|
|
12
|
+
href: string;
|
|
13
|
+
reload(): void;
|
|
14
|
+
assign(url: string): void;
|
|
15
|
+
replace(url: string): void;
|
|
16
|
+
};
|
|
17
|
+
innerWidth: number;
|
|
18
|
+
innerHeight: number;
|
|
19
|
+
devicePixelRatio: number;
|
|
20
|
+
requestAnimationFrame(cb: (time: number) => void): number;
|
|
21
|
+
cancelAnimationFrame(id?: number): void;
|
|
22
|
+
setTimeout(callback: (...args: unknown[]) => void, delay?: number, ...args: unknown[]): number;
|
|
23
|
+
clearTimeout(id?: number): void;
|
|
24
|
+
setInterval(callback: (...args: unknown[]) => void, delay?: number, ...args: unknown[]): number;
|
|
25
|
+
clearInterval(id?: number): void;
|
|
26
|
+
getComputedStyle(el: unknown): Record<string, never>;
|
|
27
|
+
/** ResizeObserver over the pushed-measure channel — observe() registers
|
|
28
|
+
* a doc.observeSize subscription, pushed rects arrive as entries. */
|
|
29
|
+
ResizeObserver: typeof ProxyResizeObserver;
|
|
30
|
+
/** Media queries can't be answered worker-side — always `matches: false`. */
|
|
31
|
+
matchMedia(query: string): MediaQueryList;
|
|
32
|
+
addEventListener(type: string, fn: ProxyEventHandler, options?: boolean | AddEventListenerOptions): void;
|
|
33
|
+
removeEventListener(type: string, fn: ProxyEventHandler, options?: boolean | EventListenerOptions): void;
|
|
34
|
+
/** Scrolling is main-thread business — no-ops so window.scrollTo(x,y)
|
|
35
|
+
* calls in libraries don't throw. */
|
|
36
|
+
scrollTo(x?: number | ScrollToOptions, y?: number): void;
|
|
37
|
+
scrollBy(x?: number | ScrollToOptions, y?: number): void;
|
|
38
|
+
scroll(x?: number | ScrollToOptions, y?: number): void;
|
|
39
|
+
}
|
|
40
|
+
export interface WindowFacadeBundle {
|
|
41
|
+
facade: WindowShim;
|
|
42
|
+
/** Detach every surviving window listener — ops and handler-table entries. */
|
|
43
|
+
teardown(): void;
|
|
44
|
+
}
|
|
45
|
+
export declare function installInstanceDispatcher(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Install this document as the instance's DOM surface — the entry point for
|
|
48
|
+
* running real DOM-dependent libraries unmodified inside an island instance:
|
|
49
|
+
*
|
|
50
|
+
* const doc = createProxyDocument(instance);
|
|
51
|
+
* installDomShim(doc);
|
|
52
|
+
* SomeVendorLib.mount(doc.body); // uses document./window./innerHTML…
|
|
53
|
+
*
|
|
54
|
+
* Under the instance dispatcher (installed here automatically, and by
|
|
55
|
+
* definePolyWorker for every island worker) `globalThis.document` and
|
|
56
|
+
* `globalThis.window` already resolve to this document while its instance is
|
|
57
|
+
* active — so this call's real work is building the window facade
|
|
58
|
+
* (navigator/location stubs, timers + rAF passthrough, innerWidth/Height
|
|
59
|
+
* from the pushed container size, empty getComputedStyle, never-matching
|
|
60
|
+
* matchMedia, addEventListener wired to `listen` ops on id 0) and exposing
|
|
61
|
+
* it as `document.defaultView`.
|
|
62
|
+
*
|
|
63
|
+
* It also pins the CLASS globals (`Node`/`Text`/`Comment` → the proxy
|
|
64
|
+
* classes; `HTMLMediaElement`/`customElements` → never-match stubs) for
|
|
65
|
+
* framework feature probes — the instance dispatcher resolves them
|
|
66
|
+
* ambiently anyway, so the assignment makes this document's install
|
|
67
|
+
* explicit and restores the previous values on uninstall.
|
|
68
|
+
*
|
|
69
|
+
* What does NOT get touched — deliberately:
|
|
70
|
+
* - `globalThis.addEventListener`/`removeEventListener` and `self` — the
|
|
71
|
+
* pool's `self.onmessage` channel lives there; `window` is a facade
|
|
72
|
+
* object, not the global.
|
|
73
|
+
* - Any other global (history, fetch, localStorage…) — libraries touching
|
|
74
|
+
* them fail loudly, which is the honest answer.
|
|
75
|
+
*
|
|
76
|
+
* Returns `uninstall()` tearing down the facade's listeners. Also runs
|
|
77
|
+
* automatically on `doc.dispose()` (the updateProps rebuild path) and is
|
|
78
|
+
* superseded by a later installDomShim call — the last install wins.
|
|
79
|
+
*/
|
|
80
|
+
export declare function installDomShim(doc: ProxyDocument): () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worker-side surface of @atolljs/islands — import from
|
|
3
|
+
* '@atolljs/islands/worker' inside the worker entry:
|
|
4
|
+
*
|
|
5
|
+
* import { definePolyWorker } from '@atolljs/islands/worker';
|
|
6
|
+
* export const renderWorker = definePolyWorker({ apps: { ... } });
|
|
7
|
+
*
|
|
8
|
+
* Framework apps also use from here: `emit` (island→shell
|
|
9
|
+
* channel), `runInInstance` (instance scoping for worker-initiated work),
|
|
10
|
+
* `createProxyDocument`/`installDomShim` (imperative DOM), plus the
|
|
11
|
+
* renderer-facing instance factories (`newElement`/`newText`/`serializeProps`,
|
|
12
|
+
* `ROOT_CONTAINER`) the `*-island` worker adapters drive.
|
|
13
|
+
*
|
|
14
|
+
* Framework-neutral by construction: this entry imports no framework — React's
|
|
15
|
+
* reconciler adapter lives in `@atolljs/react-island/worker`.
|
|
16
|
+
*/
|
|
17
|
+
export { definePolyWorker, defineMonoWorker } from './defineWorkers.js';
|
|
18
|
+
export type { ImperativeIslandApp, Instance, IslandApp, PolyWorkerRegistry, RenderContext, RenderedHandle, RenderedIslandApp, } from './defineWorkers.js';
|
|
19
|
+
export { islandApp, islandAppNameOf } from '../app.js';
|
|
20
|
+
export { defineIslandContract, isIslandContract, withContract, contractOf } from '../contract.js';
|
|
21
|
+
export type { IslandContract, IslandContractEventHandler, IslandContractEvents, IslandContractProps, } from '../contract.js';
|
|
22
|
+
export { allocId, bumpOpsVersion, emit, getActiveInstance, getHandler, getLastActiveInstance, getLastTouchedInstance, getInstanceSize, instances, newElement, newText, proxyInstanceStats, pushOp, registerHandler, ROOT_CONTAINER, runInInstance, serializeProps, setActiveInstance, setDoorbellContract, setInstanceSize, takeOps, unregisterHandler, } from './instance.js';
|
|
23
|
+
export type { ElementInstance, HostInstance, RootContainer, TextInstance } from './instance.js';
|
|
24
|
+
export { createProxyDocument, installDomShim, installInstanceDispatcher, ProxyComment, ProxyElement, ProxyFragment, ProxyNode, ProxyResizeObserver, ProxyText, docForInstance, } from './proxyDom.js';
|
|
25
|
+
export type { AdjacentPosition, InternalDocument, ProxyClassList, ProxyDocument, ProxyEventHandler, WindowShim, WireListenerOpts, } from './proxyDom.js';
|
|
26
|
+
export type { EventPayload, IslandWorkerMethods, MeasuredRect, Op, WireProps } from '../ops.js';
|
|
27
|
+
export { isEventRef } from '../ops.js';
|
|
28
|
+
export { renderMemory } from '../memory.js';
|
|
29
|
+
export type { DoorbellSpec } from '../memory.js';
|
|
30
|
+
export { mountSubIsland } from './subIsland.js';
|
|
31
|
+
export type { MountSubIslandOptions, SubIslandHandle } from './subIsland.js';
|
|
32
|
+
export { connectIslandWorker, mountIsland } from '../island.js';
|
|
33
|
+
export type { ConnectIslandWorkerConfig, IslandClient, IslandHandle, Mode, MountIslandOptions, } from '../island.js';
|