@astroscope/wormhole 0.1.0 → 0.1.1

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 CHANGED
@@ -218,21 +218,6 @@ import {WormholeScript} from '@astroscope/wormhole/astro';
218
218
  3. **Client** calls `wh.get()` — reads from `globalThis[key]()` (the serialized getter)
219
219
  4. **`set()`** updates a local store and notifies all subscribers — `useWormhole()` hooks and `subscribe()` callbacks re-render/fire
220
220
 
221
- ## Monorepo note
222
-
223
- When using this package from a workspace in a monorepo, add `resolve.dedupe` to your Vite config to prevent duplicate React instances:
224
-
225
- ```ts
226
- // astro.config.ts
227
- export default defineConfig({
228
- vite: {
229
- resolve: {
230
- dedupe: ['react', 'react-dom'],
231
- },
232
- },
233
- });
234
- ```
235
-
236
221
  ## License
237
222
 
238
223
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astroscope/wormhole",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Share dynamic server data with React islands and client scripts — typed, reactive",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/dist/define.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { W as Wormhole } from './types-DkH89ULF.js';
2
-
3
- declare function defineWormhole<T>(name: string): Wormhole<T>;
4
-
5
- export { Wormhole, defineWormhole };
package/dist/define.js DELETED
@@ -1,29 +0,0 @@
1
- // src/define.ts
2
- function defineWormhole(name) {
3
- const key = `__wormhole_${name}__`;
4
- let store;
5
- const listeners = /* @__PURE__ */ new Set();
6
- return {
7
- name,
8
- key,
9
- get() {
10
- if (store !== void 0) return store;
11
- const getter = globalThis[key];
12
- if (typeof getter === "function") return getter();
13
- throw new Error(`wormhole "${name}" is not initialized`);
14
- },
15
- set(data) {
16
- store = data;
17
- for (const fn of listeners) fn(data);
18
- },
19
- subscribe(fn) {
20
- listeners.add(fn);
21
- return () => {
22
- listeners.delete(fn);
23
- };
24
- }
25
- };
26
- }
27
- export {
28
- defineWormhole
29
- };
package/dist/react.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { W as Wormhole } from './types-DkH89ULF.js';
2
-
3
- declare function useWormhole<T>(wh: Wormhole<T>): T;
4
-
5
- export { useWormhole };
package/dist/react.js DELETED
@@ -1,8 +0,0 @@
1
- // src/react.ts
2
- import { useSyncExternalStore } from "react";
3
- function useWormhole(wh) {
4
- return useSyncExternalStore(wh.subscribe, wh.get, wh.get);
5
- }
6
- export {
7
- useWormhole
8
- };