@astroscope/wormhole 0.3.0 → 1.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.
- package/README.md +26 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/server.d.ts +19 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +8 -8
- package/dist/server.js.map +1 -1
- package/dist/types-Q2gaO_N_.d.ts +31 -0
- package/dist/types-Q2gaO_N_.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/astro/WormholeScript.astro +10 -2
- package/dist/types-DHysnZE3.d.ts +0 -21
- package/dist/types-DHysnZE3.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ Astro recommends [nanostores](https://docs.astro.build/en/recipes/sharing-state/
|
|
|
22
22
|
|
|
23
23
|
- **No secrets in wormholes.** All wormhole data is serialized into an inline `<script>` tag and sent to the browser. Never store tokens, API keys, credentials, or any sensitive data in a wormhole.
|
|
24
24
|
- **`set()` is client-only.** Calling `set()` does not work on the server. Use `open(wormhole, data, fn)` from `@astroscope/wormhole/server` to populate data in middleware.
|
|
25
|
+
- **Values are deeply readonly.** `get()`, `subscribe()` and `useWormhole()` expose the value as `DeepReadonly<T>` — in-place mutation would silently bypass subscribers (and on the server would corrupt the request-scoped store). The only way to update is `set()` with a new value: `wh.set({ ...wh.get(), count: 1 })`.
|
|
25
26
|
|
|
26
27
|
## Examples
|
|
27
28
|
|
|
@@ -180,12 +181,24 @@ const wh = defineWormhole<{ count: number }>('counter');
|
|
|
180
181
|
|
|
181
182
|
| Method | Description |
|
|
182
183
|
| ------------------ | --------------------------------------------------------------------------------------------------- |
|
|
183
|
-
| `wh.get()` | Read current value (from `AsyncLocalStorage` on server, from `globalThis` or local store on client) |
|
|
184
|
-
| `wh.set(data)` |
|
|
184
|
+
| `wh.get()` | Read current value as `DeepReadonly<T>` (from `AsyncLocalStorage` on server, from `globalThis` or local store on client) |
|
|
185
|
+
| `wh.set(data)` | Replace value with a new one and notify all subscribers (client-side) |
|
|
185
186
|
| `wh.subscribe(fn)` | Listen for changes, returns unsubscribe function |
|
|
186
187
|
| `wh.name` | The wormhole name |
|
|
187
188
|
| `wh.key` | The internal `globalThis` key |
|
|
188
189
|
|
|
190
|
+
### `DeepReadonly<T>`
|
|
191
|
+
|
|
192
|
+
Exported helper type — recursively `readonly` version of `T`. Wormhole values are exposed with this type; use it in your own function signatures when passing wormhole data around:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import type { DeepReadonly } from '@astroscope/wormhole';
|
|
196
|
+
|
|
197
|
+
function isWithinCart(cart: DeepReadonly<Cart>, id: string) {
|
|
198
|
+
return cart.items.some((item) => item.productId === id);
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
189
202
|
### `open(wh, data, fn)` <sub>server only</sub>
|
|
190
203
|
|
|
191
204
|
Runs `fn` with `data` available via `wh.get()` for the duration of the call. Uses `AsyncLocalStorage` for request isolation.
|
|
@@ -196,6 +209,17 @@ import { open } from '@astroscope/wormhole/server';
|
|
|
196
209
|
return open(myWormhole, { count: 0 }, () => next());
|
|
197
210
|
```
|
|
198
211
|
|
|
212
|
+
To open several wormholes at once, pass an array of `[wormhole, data]` pairs — each pair is type-checked against its own wormhole:
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
return open([
|
|
216
|
+
[cartStore, cart],
|
|
217
|
+
[sessionStore, session],
|
|
218
|
+
], () => next());
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Nested `open()` calls shadow only the wormholes they name; everything else stays visible.
|
|
222
|
+
|
|
199
223
|
### `useWormhole(wh)` <sub>React only</sub>
|
|
200
224
|
|
|
201
225
|
React hook that reads the wormhole and re-renders on changes. Uses `useSyncExternalStore` internally.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as Wormhole, t as DeepReadonly } from "./types-Q2gaO_N_.js";
|
|
2
2
|
|
|
3
3
|
//#region src/define.d.ts
|
|
4
4
|
/**
|
|
@@ -9,5 +9,5 @@ import { t as Wormhole } from "./types-DHysnZE3.js";
|
|
|
9
9
|
*/
|
|
10
10
|
declare function defineWormhole<T>(name: string): Wormhole<T>;
|
|
11
11
|
//#endregion
|
|
12
|
-
export { type Wormhole, defineWormhole };
|
|
12
|
+
export { type DeepReadonly, type Wormhole, defineWormhole };
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,9 @@ function defineWormhole(name) {
|
|
|
15
15
|
get() {
|
|
16
16
|
if (store !== void 0) return store;
|
|
17
17
|
const getter = globalThis[key];
|
|
18
|
-
|
|
19
|
-
throw new Error(`wormhole "${name}" is not initialized`);
|
|
18
|
+
const value = typeof getter === "function" ? getter() : void 0;
|
|
19
|
+
if (value === void 0) throw new Error(`wormhole "${name}" is not initialized`);
|
|
20
|
+
return value;
|
|
20
21
|
},
|
|
21
22
|
set(data) {
|
|
22
23
|
if (typeof globalThis.window === "undefined") throw new Error(`wormhole "${name}" set() cannot be called on the server as it is not request-scoped; use open(wormhole, data, fn) from "@astroscope/wormhole/server" instead`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/define.ts"],"sourcesContent":["import type { Wormhole } from './types.js';\n\n/**\n * Define a wormhole that transfers state from server middleware to client components.\n *\n * **Security:** wormhole data is serialized into the HTML and sent to the browser.\n * Never store secrets (tokens, API keys, credentials) in a wormhole.\n */\nexport function defineWormhole<T>(name: string): Wormhole<T> {\n const listeners = new Set<(data: T) => void>();\n const key = `__wormhole_${name}__`;\n let store: T | undefined;\n\n return {\n name,\n key,\n\n get(): T {\n if (store !== undefined) return store;\n\n const getter = (globalThis as any)[key];\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/define.ts"],"sourcesContent":["import type { DeepReadonly, Wormhole } from './types.js';\n\n/**\n * Define a wormhole that transfers state from server middleware to client components.\n *\n * **Security:** wormhole data is serialized into the HTML and sent to the browser.\n * Never store secrets (tokens, API keys, credentials) in a wormhole.\n */\nexport function defineWormhole<T>(name: string): Wormhole<T> {\n const listeners = new Set<(data: DeepReadonly<T>) => void>();\n const key = `__wormhole_${name}__`;\n let store: DeepReadonly<T> | undefined;\n\n return {\n name,\n key,\n\n get(): DeepReadonly<T> {\n if (store !== undefined) return store;\n\n const getter = (globalThis as any)[key];\n const value = typeof getter === 'function' ? (getter() as DeepReadonly<T> | undefined) : undefined;\n\n if (value === undefined) {\n throw new Error(`wormhole \"${name}\" is not initialized`);\n }\n\n return value;\n },\n\n set(data: DeepReadonly<T>): void {\n if (typeof (globalThis as any).window === 'undefined') {\n throw new Error(\n `wormhole \"${name}\" set() cannot be called on the server as it is not request-scoped; use open(wormhole, data, fn) from \"@astroscope/wormhole/server\" instead`,\n );\n }\n\n store = data;\n\n for (const fn of listeners) fn(data);\n },\n\n subscribe(fn: (data: DeepReadonly<T>) => void): () => void {\n listeners.add(fn);\n\n return () => {\n listeners.delete(fn);\n };\n },\n };\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,eAAkB,MAA2B;CAC3D,MAAM,4BAAY,IAAI,IAAqC;CAC3D,MAAM,MAAM,cAAc,KAAK;CAC/B,IAAI;CAEJ,OAAO;EACL;EACA;EAEA,MAAuB;GACrB,IAAI,UAAU,KAAA,GAAW,OAAO;GAEhC,MAAM,SAAU,WAAmB;GACnC,MAAM,QAAQ,OAAO,WAAW,aAAc,OAAO,IAAoC,KAAA;GAEzF,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,aAAa,KAAK,qBAAqB;GAGzD,OAAO;EACT;EAEA,IAAI,MAA6B;GAC/B,IAAI,OAAQ,WAAmB,WAAW,aACxC,MAAM,IAAI,MACR,aAAa,KAAK,4IACpB;GAGF,QAAQ;GAER,KAAK,MAAM,MAAM,WAAW,GAAG,IAAI;EACrC;EAEA,UAAU,IAAiD;GACzD,UAAU,IAAI,EAAE;GAEhB,aAAa;IACX,UAAU,OAAO,EAAE;GACrB;EACF;CACF;AACF"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as Wormhole, t as DeepReadonly } from "../types-Q2gaO_N_.js";
|
|
2
2
|
|
|
3
3
|
//#region src/react/index.d.ts
|
|
4
|
-
declare function useWormhole<T>(wormhole: Wormhole<T>): T
|
|
4
|
+
declare function useWormhole<T>(wormhole: Wormhole<T>): DeepReadonly<T>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { useWormhole };
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/index.ts"],"mappings":";;;iBAGgB,WAAA,IAAe,QAAA,EAAU,QAAA,CAAS,CAAA,IAAK,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/index.ts"],"mappings":";;;iBAGgB,WAAA,IAAe,QAAA,EAAU,QAAA,CAAS,CAAA,IAAK,YAAA,CAAa,CAAA"}
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/react/index.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport type { Wormhole } from '../types.js';\n\nexport function useWormhole<T>(wormhole: Wormhole<T>): T {\n return useSyncExternalStore(wormhole.subscribe, wormhole.get, wormhole.get);\n}\n"],"mappings":";;AAGA,SAAgB,YAAe,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/react/index.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport type { DeepReadonly, Wormhole } from '../types.js';\n\nexport function useWormhole<T>(wormhole: Wormhole<T>): DeepReadonly<T> {\n return useSyncExternalStore(wormhole.subscribe, wormhole.get, wormhole.get);\n}\n"],"mappings":";;AAGA,SAAgB,YAAe,UAAwC;CACrE,OAAO,qBAAqB,SAAS,WAAW,SAAS,KAAK,SAAS,GAAG;AAC5E"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as Wormhole, t as DeepReadonly } from "./types-Q2gaO_N_.js";
|
|
2
2
|
|
|
3
3
|
//#region src/server.d.ts
|
|
4
|
-
|
|
4
|
+
/** One [wormhole, data] pair per element — data is checked against its own wormhole's T. */
|
|
5
|
+
type WormholeEntries<Ts extends readonly unknown[]> = { [K in keyof Ts]: readonly [Wormhole<Ts[K]>, DeepReadonly<Ts[K]>] };
|
|
6
|
+
/**
|
|
7
|
+
* Open a wormhole for the duration of `fn` — `wormhole.get()` returns `data`
|
|
8
|
+
* anywhere in the async execution rooted at `fn`.
|
|
9
|
+
*/
|
|
10
|
+
declare function open<T, R>(wormhole: Wormhole<T>, data: DeepReadonly<T>, fn: () => R): R;
|
|
11
|
+
/**
|
|
12
|
+
* Open several wormholes at once for the duration of `fn`.
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* return open([
|
|
16
|
+
* [cartStore, cart],
|
|
17
|
+
* [sessionStore, session],
|
|
18
|
+
* ], () => next());
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function open<Ts extends readonly unknown[], R>(entries: readonly [...WormholeEntries<Ts>], fn: () => R): R;
|
|
5
22
|
//#endregion
|
|
6
23
|
export { open };
|
|
7
24
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"mappings":";;;;KAIK,eAAA,gDACS,EAAA,aAAe,QAAA,CAAS,EAAA,CAAG,CAAA,IAAK,YAAA,CAAa,EAAA,CAAG,CAAA;;;;;iBAa9C,IAAA,OAAW,QAAA,EAAU,QAAA,CAAS,CAAA,GAAI,IAAA,EAAM,YAAA,CAAa,CAAA,GAAI,EAAA,QAAU,CAAA,GAAI,CAAA;;;;;;;;;;;iBAWvE,IAAA,mCAAuC,OAAA,eAAsB,eAAA,CAAgB,EAAA,IAAM,EAAA,QAAU,CAAA,GAAI,CAAA"}
|
package/dist/server.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
//#region src/server.ts
|
|
3
|
-
const
|
|
4
|
-
function open(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const als = globalThis[Symbol.for("@astroscope/wormhole/als")] ??= new AsyncLocalStorage();
|
|
4
|
+
function open(...args) {
|
|
5
|
+
const [entries, fn] = Array.isArray(args[0]) ? args : [[[args[0], args[1]]], args[2]];
|
|
6
|
+
const ctx = new Map(als.getStore());
|
|
7
|
+
for (const [wormhole, data] of entries) {
|
|
8
|
+
ctx.set(wormhole.key, data);
|
|
9
|
+
globalThis[wormhole.key] ??= () => als.getStore()?.get(wormhole.key);
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
return als.run(data, fn);
|
|
11
|
+
return als.run(ctx, fn);
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
export { open };
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Wormhole } from './types.js';\n\
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { DeepReadonly, Wormhole } from './types.js';\n\n/** One [wormhole, data] pair per element — data is checked against its own wormhole's T. */\ntype WormholeEntries<Ts extends readonly unknown[]> = {\n [K in keyof Ts]: readonly [Wormhole<Ts[K]>, DeepReadonly<Ts[K]>];\n};\n\n// a single ALS holds an immutable map of all open wormholes; keyed on globalThis\n// so the vite-runner and native module instances share one context\nconst als: AsyncLocalStorage<ReadonlyMap<string, unknown>> = ((globalThis as any)[\n Symbol.for('@astroscope/wormhole/als')\n] ??= new AsyncLocalStorage());\n\n/**\n * Open a wormhole for the duration of `fn` — `wormhole.get()` returns `data`\n * anywhere in the async execution rooted at `fn`.\n */\nexport function open<T, R>(wormhole: Wormhole<T>, data: DeepReadonly<T>, fn: () => R): R;\n/**\n * Open several wormholes at once for the duration of `fn`.\n *\n * ```typescript\n * return open([\n * [cartStore, cart],\n * [sessionStore, session],\n * ], () => next());\n * ```\n */\nexport function open<Ts extends readonly unknown[], R>(entries: readonly [...WormholeEntries<Ts>], fn: () => R): R;\nexport function open(...args: unknown[]): unknown {\n const [entries, fn] = (Array.isArray(args[0]) ? args : [[[args[0], args[1]]], args[2]]) as [\n readonly (readonly [Wormhole<unknown>, unknown])[],\n () => unknown,\n ];\n\n const ctx = new Map(als.getStore());\n\n for (const [wormhole, data] of entries) {\n ctx.set(wormhole.key, data);\n\n (globalThis as any)[wormhole.key] ??= () => als.getStore()?.get(wormhole.key);\n }\n\n return als.run(ctx, fn);\n}\n"],"mappings":";;AAUA,MAAM,MAAwD,WAC5D,OAAO,IAAI,0BAA0B,OACjC,IAAI,kBAAkB;AAkB5B,SAAgB,KAAK,GAAG,MAA0B;CAChD,MAAM,CAAC,SAAS,MAAO,MAAM,QAAQ,KAAK,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE;CAKrF,MAAM,MAAM,IAAI,IAAI,IAAI,SAAS,CAAC;CAElC,KAAK,MAAM,CAAC,UAAU,SAAS,SAAS;EACtC,IAAI,IAAI,SAAS,KAAK,IAAI;EAE1B,WAAoB,SAAS,eAAe,IAAI,SAAS,CAAC,EAAE,IAAI,SAAS,GAAG;CAC9E;CAEA,OAAO,IAAI,IAAI,KAAK,EAAE;AACxB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Recursively marks all properties of `T` as `readonly`.
|
|
4
|
+
*
|
|
5
|
+
* Wormhole data is JSON-serializable by design (it is inlined into a `<script>` tag),
|
|
6
|
+
* so only plain objects, arrays, and primitives need to be handled.
|
|
7
|
+
*/
|
|
8
|
+
type DeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
|
|
9
|
+
/**
|
|
10
|
+
* A wormhole transfers state from server middleware to client-side components.
|
|
11
|
+
*
|
|
12
|
+
* **Security:** wormhole data is serialized into an inline `<script>` tag and sent to the browser.
|
|
13
|
+
* Never store secrets (tokens, API keys, credentials) in a wormhole.
|
|
14
|
+
*
|
|
15
|
+
* The stored value is exposed as deeply readonly — the only way to change it is `set()`
|
|
16
|
+
* (client) or `open()` (server) with a new value, which keeps subscribers in sync.
|
|
17
|
+
*/
|
|
18
|
+
interface Wormhole<in out T> {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly key: string;
|
|
21
|
+
get(): DeepReadonly<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Update the wormhole value on the **client only**.
|
|
24
|
+
* Throws on the server — use `open(wormhole, data, fn)` from `@astroscope/wormhole/server` instead.
|
|
25
|
+
*/
|
|
26
|
+
set(data: DeepReadonly<T>): void;
|
|
27
|
+
subscribe(fn: (data: DeepReadonly<T>) => void): () => void;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Wormhole as n, DeepReadonly as t };
|
|
31
|
+
//# sourceMappingURL=types-Q2gaO_N_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-Q2gaO_N_.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;AAMA;;;;;KAAY,YAAA,MAAkB,CAAA,cAAc,IAAA,yBACxC,CAAA,GACA,CAAA,yCACyB,CAAA,GAAI,YAAA,CAAa,CAAA,CAAE,CAAA,OAC1C,CAAA;;;;;;;;;;UAaW,QAAA;EAAA,SACN,IAAA;EAAA,SACA,GAAA;EACT,GAAA,IAAO,YAAA,CAAa,CAAA;EAjBwB;;;;EAsB5C,GAAA,CAAI,IAAA,EAAM,YAAA,CAAa,CAAA;EACvB,SAAA,CAAU,EAAA,GAAK,IAAA,EAAM,YAAA,CAAa,CAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -4,12 +4,20 @@ interface Props {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
const { wormhole } = Astro.props;
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
let data: unknown;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
data = wormhole.get();
|
|
12
|
+
} catch {
|
|
13
|
+
data = undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
const key = wormhole.key;
|
|
9
17
|
---
|
|
10
18
|
|
|
11
19
|
{
|
|
12
|
-
data ? (
|
|
20
|
+
data !== undefined ? (
|
|
13
21
|
<script is:inline define:vars={{ data, key }}>
|
|
14
22
|
globalThis[key] = function(){return data;}
|
|
15
23
|
</script>
|
package/dist/types-DHysnZE3.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* A wormhole transfers state from server middleware to client-side components.
|
|
4
|
-
*
|
|
5
|
-
* **Security:** wormhole data is serialized into an inline `<script>` tag and sent to the browser.
|
|
6
|
-
* Never store secrets (tokens, API keys, credentials) in a wormhole.
|
|
7
|
-
*/
|
|
8
|
-
interface Wormhole<T> {
|
|
9
|
-
readonly name: string;
|
|
10
|
-
readonly key: string;
|
|
11
|
-
get(): T;
|
|
12
|
-
/**
|
|
13
|
-
* Update the wormhole value on the **client only**.
|
|
14
|
-
* Throws on the server — use `open(wormhole, data, fn)` from `@astroscope/wormhole/server` instead.
|
|
15
|
-
*/
|
|
16
|
-
set(data: T): void;
|
|
17
|
-
subscribe(fn: (data: T) => void): () => void;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { Wormhole as t };
|
|
21
|
-
//# sourceMappingURL=types-DHysnZE3.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-DHysnZE3.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;AAMA;;;;;UAAiB,QAAA;EAAA,SACN,IAAA;EAAA,SACA,GAAA;EACT,GAAA,IAAO,CAAA;EAFE;;;;EAOT,GAAA,CAAI,IAAA,EAAM,CAAA;EACV,SAAA,CAAU,EAAA,GAAK,IAAA,EAAM,CAAA;AAAA"}
|