@vizejs/composable 0.443.0 → 0.454.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.
@@ -1,4 +1,4 @@
1
- import { computed, shallowRef, watchEffect } from "vue";
1
+ import { customRef, shallowReadonly, shallowRef, watchEffect } from "vue";
2
2
  //#region src/computed-async.ts
3
3
  function computedAsync(evaluator, initial, options = {}) {
4
4
  const started = shallowRef(!(options.lazy ?? false));
@@ -33,10 +33,14 @@ function computedAsync(evaluator, initial, options = {}) {
33
33
  if (own === generation) evaluating.value = false;
34
34
  }
35
35
  });
36
- if (options.lazy ?? false) return computed(() => {
37
- started.value = true;
38
- return current.value;
39
- });
36
+ if (options.lazy ?? false) return shallowReadonly(customRef((track) => ({
37
+ get() {
38
+ track();
39
+ started.value = true;
40
+ return current.value;
41
+ },
42
+ set() {}
43
+ })));
40
44
  return current;
41
45
  }
42
46
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/composable",
3
- "version": "0.443.0",
3
+ "version": "0.454.0",
4
4
  "description": "Lifecycle-safe composable foundations for Vize applications",
5
5
  "keywords": [
6
6
  "composables",
@@ -977,7 +977,7 @@
977
977
  },
978
978
  "devDependencies": {
979
979
  "@types/node": "25.9.2",
980
- "@vizejs/native": "0.443.0",
980
+ "@vizejs/native": "0.454.0",
981
981
  "happy-dom": "20.11.2",
982
982
  "typescript": "6.0.3",
983
983
  "vite-plus": "0.1.24",
@@ -1,4 +1,4 @@
1
- import { computed, shallowRef, watchEffect } from "vue";
1
+ import { customRef, shallowReadonly, shallowRef, watchEffect } from "vue";
2
2
  import type { Ref } from "vue";
3
3
 
4
4
  /** Registers a callback run when the current evaluation becomes stale. */
@@ -114,10 +114,20 @@ export function computedAsync<Value>(
114
114
  });
115
115
 
116
116
  if (options.lazy ?? false) {
117
- return computed(() => {
118
- started.value = true;
119
- return current.value;
120
- });
117
+ // Activation belongs to the lazy ref protocol, not a derived computed
118
+ // getter. Reading current still tracks the evaluator's settled updates.
119
+ return shallowReadonly(
120
+ customRef<Value | undefined>((track) => ({
121
+ get() {
122
+ track();
123
+ started.value = true;
124
+ return current.value;
125
+ },
126
+ set() {
127
+ // The readonly wrapper rejects writes before reaching this protocol.
128
+ },
129
+ })),
130
+ );
121
131
  }
122
132
  return current;
123
133
  }
@@ -3,7 +3,7 @@
3
3
  "registryKind": "vize-lib",
4
4
  "package": {
5
5
  "name": "@vizejs/composable",
6
- "version": "0.443.0"
6
+ "version": "0.454.0"
7
7
  },
8
8
  "kind": "composable",
9
9
  "filesDirectory": "files",
@@ -270,8 +270,8 @@
270
270
  {
271
271
  "path": "computed-async.ts",
272
272
  "role": "entry",
273
- "sha256": "aa34d886510d260170a8f1cbc059874ab2f1d814e4f728bbfa1e0511d723d000",
274
- "size": 3919
273
+ "sha256": "d1b3e9898f9d5c1843b61bf5ec4c56b5cf6c272f153481782105ece107ca0e6d",
274
+ "size": 4309
275
275
  }
276
276
  ],
277
277
  "registryDependencies": [],
@@ -282,7 +282,7 @@
282
282
  "kind": "peer"
283
283
  }
284
284
  ],
285
- "contentHash": "35938ef6ed69ada0564e7b53d2e29a43ca2a05a37654730105cfc9e8305b4555",
285
+ "contentHash": "69bd475ccd37cc7dcea164f6fcbfa7120a681a854a26e4a92e4a5d6e29ab4fa9",
286
286
  "examples": []
287
287
  },
288
288
  {