@vizejs/composable 0.322.0 → 0.323.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/dist/index.d.mts CHANGED
@@ -144,7 +144,8 @@ interface EventListenerControls {
144
144
  *
145
145
  * @returns Whether a new reactive watcher was started. `false` while the
146
146
  * watcher is already active (including a null-target watcher with no
147
- * listener attached) and after the abort signal has fired.
147
+ * listener attached), after the abort signal has fired, and after the
148
+ * owning reactive scope has been disposed.
148
149
  */
149
150
  readonly start: () => boolean;
150
151
  /** Stop listening. Repeated calls are safe. */
package/dist/index.mjs CHANGED
@@ -125,6 +125,7 @@ function useEventListener(target, event, listener, options = {}) {
125
125
  passive,
126
126
  ...signal ? { signal } : {}
127
127
  };
128
+ let disposed = false;
128
129
  let stopWatch;
129
130
  const stop = () => {
130
131
  stopWatch?.stop();
@@ -132,7 +133,7 @@ function useEventListener(target, event, listener, options = {}) {
132
133
  isListening.value = false;
133
134
  };
134
135
  const start = () => {
135
- if (stopWatch || signal?.aborted) return false;
136
+ if (disposed || stopWatch || signal?.aborted) return false;
136
137
  stopWatch = watch(() => toValue(target), (next, _previous, onCleanup) => {
137
138
  isListening.value = false;
138
139
  if (!next || signal?.aborted) return;
@@ -155,7 +156,10 @@ function useEventListener(target, event, listener, options = {}) {
155
156
  });
156
157
  return true;
157
158
  };
158
- tryOnScopeDispose(stop);
159
+ tryOnScopeDispose(() => {
160
+ disposed = true;
161
+ stop();
162
+ });
159
163
  if (immediate) start();
160
164
  return {
161
165
  isListening: readonly(isListening),
@@ -192,7 +196,7 @@ function useLocale(source, options = {}) {
192
196
  return candidate instanceof Intl.Locale ? candidate.toString() : new Intl.Locale(candidate).toString();
193
197
  });
194
198
  const details = computed(() => new Intl.Locale(locale.value));
195
- const direction = computed(() => details.value.getTextInfo().direction);
199
+ const direction = computed(() => details.value.getTextInfo().direction ?? "ltr");
196
200
  const number = createFormatterCache((activeLocale, formatOptions) => new Intl.NumberFormat(activeLocale, formatOptions));
197
201
  const dateTime = createFormatterCache((activeLocale, formatOptions) => new Intl.DateTimeFormat(activeLocale, formatOptions));
198
202
  const list = createFormatterCache((activeLocale, formatOptions) => new Intl.ListFormat(activeLocale, formatOptions));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/composable",
3
- "version": "0.322.0",
3
+ "version": "0.323.0",
4
4
  "description": "Lifecycle-safe composable foundations for Vize applications",
5
5
  "keywords": [
6
6
  "composables",
@@ -61,9 +61,10 @@
61
61
  "dev": "vp pack --watch",
62
62
  "pretest": "vp pack && pnpm check:size",
63
63
  "test": "vp exec node --test 'src/**/*.test.ts'",
64
- "check": "vp check src scripts vite.config.ts",
64
+ "check": "vp check src scripts vite.config.ts && pnpm check:types",
65
65
  "check:fix": "vp check --fix src scripts vite.config.ts",
66
66
  "check:size": "node scripts/check-size.mjs",
67
+ "check:types": "vp exec tsc --noEmit -p tsconfig.json",
67
68
  "fmt": "vp fmt --write src scripts vite.config.ts"
68
69
  }
69
70
  }