@sigrea/vue 0.3.0 → 0.4.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 CHANGED
@@ -6,7 +6,7 @@
6
6
  - **Computed subscriptions.** `useComputed` subscribes to computed values, mirroring Vue's `computed` while tracking through Sigrea scopes.
7
7
  - **Deep signal subscriptions.** `useDeepSignal` subscribes to deep signal objects and exposes them as mutable refs with automatic cleanup.
8
8
  - **Two-way bindings.** `useMutableSignal` wraps primitive signals as `WritableComputedRef` for two-way bindings like `v-model`.
9
- - **Molecule lifecycles.** `useMolcule` mounts molecule factories and binds their lifecycles to Vue components.
9
+ - **Molecule lifecycles.** `useMolecule` mounts molecule factories and binds their lifecycles to Vue components.
10
10
 
11
11
  ## Table of Contents
12
12
 
@@ -21,8 +21,9 @@
21
21
  - [useComputed](#usecomputed)
22
22
  - [useDeepSignal](#usedeepsignal)
23
23
  - [useMutableSignal](#usemutablesignal)
24
- - [useMolcule](#usemolcule)
24
+ - [useMolecule](#usemolecule)
25
25
  - [Testing](#testing)
26
+ - [Handling Scope Cleanup Errors](#handling-scope-cleanup-errors)
26
27
  - [Development](#development)
27
28
  - [License](#license)
28
29
 
@@ -76,11 +77,11 @@ export const CounterMolecule = molecule((props: { initialCount: number }) => {
76
77
  ```vue
77
78
  <!-- Counter.vue -->
78
79
  <script setup lang="ts">
79
- import { useMolcule, useSignal } from "@sigrea/vue";
80
+ import { useMolecule, useSignal } from "@sigrea/vue";
80
81
  import { CounterMolecule } from "./CounterMolecule";
81
82
 
82
83
  const props = defineProps<{ initialCount: number }>();
83
- const counter = useMolcule(CounterMolecule, props);
84
+ const counter = useMolecule(CounterMolecule, props);
84
85
  const value = useSignal(counter.count);
85
86
  </script>
86
87
 
@@ -169,10 +170,10 @@ function useMutableSignal<T>(signal: Signal<T>): WritableComputedRef<T>
169
170
 
170
171
  Wraps a Sigrea signal as a Vue `WritableComputedRef` for two-way bindings like `v-model`. Expects a writable signal created by `signal()`. Passing a readonly signal throws at runtime.
171
172
 
172
- ### useMolcule
173
+ ### useMolecule
173
174
 
174
175
  ```ts
175
- function useMolcule<TReturn extends object, TProps = void>(
176
+ function useMolecule<TReturn extends object, TProps = void>(
176
177
  molecule: MoleculeFactory<TReturn, TProps>,
177
178
  ...args: MoleculeArgs<TProps>
178
179
  ): MoleculeInstance<TReturn>
@@ -198,15 +199,54 @@ it("increments and displays the updated count", async () => {
198
199
  });
199
200
  ```
200
201
 
202
+ ## Handling Scope Cleanup Errors
203
+
204
+ For global error handling configuration, see [@sigrea/core - Handling Scope Cleanup Errors](https://github.com/sigrea/core#handling-scope-cleanup-errors).
205
+
206
+ In Vue apps, configure the handler in your application entry point before mounting:
207
+
208
+ ```ts
209
+ // main.ts
210
+ import { setScopeCleanupErrorHandler } from "@sigrea/core";
211
+ import { createApp } from "vue";
212
+ import App from "./App.vue";
213
+
214
+ setScopeCleanupErrorHandler((error, context) => {
215
+ console.error(`Cleanup failed:`, error);
216
+
217
+ // Forward to monitoring service
218
+ if (typeof Sentry !== "undefined") {
219
+ Sentry.captureException(error, {
220
+ tags: { scopeId: context.scopeId, phase: context.phase },
221
+ });
222
+ }
223
+ });
224
+
225
+ createApp(App).mount("#app");
226
+ ```
227
+
201
228
  ## Development
202
229
 
203
- Development scripts prefer pnpm. npm or yarn work too, but pnpm keeps dependency resolution identical to CI.
230
+ This repo targets Node.js 20 or later.
231
+
232
+ If you use mise:
233
+
234
+ - `mise trust -y` — trust `mise.toml` (first run only).
235
+ - `mise run ci` — run CI-equivalent checks locally.
236
+ - `mise run notes` — preview release notes (optional).
237
+
238
+ You can also run pnpm scripts directly:
204
239
 
205
240
  - `pnpm install` — install dependencies.
206
241
  - `pnpm test` — run the Vitest suite once (no watch).
242
+ - `pnpm typecheck` — run TypeScript type checking.
243
+ - `pnpm test:coverage` — collect coverage.
207
244
  - `pnpm build` — compile via unbuild to produce dual CJS/ESM bundles.
245
+ - `pnpm cicheck` — run CI checks locally.
208
246
  - `pnpm dev` — launch the playground counter demo.
209
247
 
248
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for workflow details.
249
+
210
250
  ## License
211
251
 
212
252
  MIT — see [LICENSE](./LICENSE).
package/dist/index.cjs CHANGED
@@ -3,10 +3,10 @@
3
3
  const vue = require('vue');
4
4
  const core = require('@sigrea/core');
5
5
 
6
- function useMolcule(molecule, ...args) {
6
+ function useMolecule(molecule, ...args) {
7
7
  if (vue.getCurrentInstance() === null) {
8
8
  throw new Error(
9
- "useMolcule can only be used within a Vue component setup()."
9
+ "useMolecule can only be used within a Vue component setup()."
10
10
  );
11
11
  }
12
12
  const instance = molecule(...args);
@@ -85,7 +85,7 @@ function useMutableSignal(source) {
85
85
 
86
86
  exports.useComputed = useComputed;
87
87
  exports.useDeepSignal = useDeepSignal;
88
- exports.useMolcule = useMolcule;
88
+ exports.useMolecule = useMolecule;
89
89
  exports.useMutableSignal = useMutableSignal;
90
90
  exports.useSignal = useSignal;
91
91
  exports.useSnapshot = useSnapshot;
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { MoleculeFactory, MoleculeArgs, MoleculeInstance, Signal, ReadonlySignal
2
2
  import * as vue from 'vue';
3
3
  import { DeepReadonly, ShallowRef } from 'vue';
4
4
 
5
- declare function useMolcule<TReturn extends object, TProps = void>(molecule: MoleculeFactory<TReturn, TProps>, ...args: MoleculeArgs<TProps>): MoleculeInstance<TReturn>;
5
+ declare function useMolecule<TReturn extends object, TProps = void>(molecule: MoleculeFactory<TReturn, TProps>, ...args: MoleculeArgs<TProps>): MoleculeInstance<TReturn>;
6
6
 
7
7
  type ReadableSignal<T> = Signal<T> | ReadonlySignal<T>;
8
8
  declare function useSignal<T>(source: ReadableSignal<T>): Readonly<vue.Ref<vue.DeepReadonly<T>, vue.DeepReadonly<T>>>;
@@ -21,4 +21,4 @@ declare function useSnapshot<T>(handler: SnapshotHandler<T>, options: UseSnapsho
21
21
  mode: "mutable";
22
22
  }): ShallowRef<T>;
23
23
 
24
- export { useComputed, useDeepSignal, useMolcule, useMutableSignal, useSignal, useSnapshot };
24
+ export { useComputed, useDeepSignal, useMolecule, useMutableSignal, useSignal, useSnapshot };
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { MoleculeFactory, MoleculeArgs, MoleculeInstance, Signal, ReadonlySignal
2
2
  import * as vue from 'vue';
3
3
  import { DeepReadonly, ShallowRef } from 'vue';
4
4
 
5
- declare function useMolcule<TReturn extends object, TProps = void>(molecule: MoleculeFactory<TReturn, TProps>, ...args: MoleculeArgs<TProps>): MoleculeInstance<TReturn>;
5
+ declare function useMolecule<TReturn extends object, TProps = void>(molecule: MoleculeFactory<TReturn, TProps>, ...args: MoleculeArgs<TProps>): MoleculeInstance<TReturn>;
6
6
 
7
7
  type ReadableSignal<T> = Signal<T> | ReadonlySignal<T>;
8
8
  declare function useSignal<T>(source: ReadableSignal<T>): Readonly<vue.Ref<vue.DeepReadonly<T>, vue.DeepReadonly<T>>>;
@@ -21,4 +21,4 @@ declare function useSnapshot<T>(handler: SnapshotHandler<T>, options: UseSnapsho
21
21
  mode: "mutable";
22
22
  }): ShallowRef<T>;
23
23
 
24
- export { useComputed, useDeepSignal, useMolcule, useMutableSignal, useSignal, useSnapshot };
24
+ export { useComputed, useDeepSignal, useMolecule, useMutableSignal, useSignal, useSnapshot };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { MoleculeFactory, MoleculeArgs, MoleculeInstance, Signal, ReadonlySignal
2
2
  import * as vue from 'vue';
3
3
  import { DeepReadonly, ShallowRef } from 'vue';
4
4
 
5
- declare function useMolcule<TReturn extends object, TProps = void>(molecule: MoleculeFactory<TReturn, TProps>, ...args: MoleculeArgs<TProps>): MoleculeInstance<TReturn>;
5
+ declare function useMolecule<TReturn extends object, TProps = void>(molecule: MoleculeFactory<TReturn, TProps>, ...args: MoleculeArgs<TProps>): MoleculeInstance<TReturn>;
6
6
 
7
7
  type ReadableSignal<T> = Signal<T> | ReadonlySignal<T>;
8
8
  declare function useSignal<T>(source: ReadableSignal<T>): Readonly<vue.Ref<vue.DeepReadonly<T>, vue.DeepReadonly<T>>>;
@@ -21,4 +21,4 @@ declare function useSnapshot<T>(handler: SnapshotHandler<T>, options: UseSnapsho
21
21
  mode: "mutable";
22
22
  }): ShallowRef<T>;
23
23
 
24
- export { useComputed, useDeepSignal, useMolcule, useMutableSignal, useSignal, useSnapshot };
24
+ export { useComputed, useDeepSignal, useMolecule, useMutableSignal, useSignal, useSnapshot };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { getCurrentInstance, onScopeDispose, shallowRef, readonly, triggerRef, computed } from 'vue';
2
2
  import { disposeMolecule, createSignalHandler, createComputedHandler, createDeepSignalHandler } from '@sigrea/core';
3
3
 
4
- function useMolcule(molecule, ...args) {
4
+ function useMolecule(molecule, ...args) {
5
5
  if (getCurrentInstance() === null) {
6
6
  throw new Error(
7
- "useMolcule can only be used within a Vue component setup()."
7
+ "useMolecule can only be used within a Vue component setup()."
8
8
  );
9
9
  }
10
10
  const instance = molecule(...args);
@@ -81,4 +81,4 @@ function useMutableSignal(source) {
81
81
  });
82
82
  }
83
83
 
84
- export { useComputed, useDeepSignal, useMolcule, useMutableSignal, useSignal, useSnapshot };
84
+ export { useComputed, useDeepSignal, useMolecule, useMutableSignal, useSignal, useSnapshot };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigrea/vue",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Vue adapter bindings for Sigrea molecule modules.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,10 +49,11 @@
49
49
  "test:coverage": "vitest --coverage",
50
50
  "typecheck": "tsc -p tsconfig.json --noEmit",
51
51
  "format": "biome check .",
52
- "format:fix": "biome check --write ."
52
+ "format:fix": "biome check --write .",
53
+ "cicheck": "pnpm test && pnpm typecheck && pnpm format:fix"
53
54
  },
54
55
  "peerDependencies": {
55
- "@sigrea/core": "^0.4.0",
56
+ "@sigrea/core": "^0.4.3",
56
57
  "vue": "^3.4.0"
57
58
  },
58
59
  "devDependencies": {