@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 +0 -15
- package/package.json +1 -1
- package/dist/define.d.ts +0 -5
- package/dist/define.js +0 -29
- package/dist/react.d.ts +0 -5
- package/dist/react.js +0 -8
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
package/dist/define.d.ts
DELETED
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