@milaboratories/uikit 2.15.13 → 2.15.15
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/.turbo/turbo-build.log +12 -12
- package/.turbo/turbo-formatter$colon$check.log +2 -2
- package/.turbo/turbo-linter$colon$check.log +2 -2
- package/.turbo/turbo-types$colon$check.log +1 -1
- package/CHANGELOG.md +27 -0
- package/dist/composition/computedCached.d.ts +5 -0
- package/dist/composition/computedCached.d.ts.map +1 -1
- package/dist/composition/computedCached.js +9 -7
- package/dist/composition/computedCached.js.map +1 -1
- package/package.json +5 -5
- package/src/composition/computedCached.ts +15 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
WARN Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @milaboratories/uikit@2.15.
|
|
3
|
+
> @milaboratories/uikit@2.15.15 build /home/runner/_work/platforma/platforma/lib/ui/uikit
|
|
4
4
|
> ts-builder build --target browser-lib --build-config ./build.browser-lib.config.js
|
|
5
5
|
|
|
6
6
|
Building browser-lib project...
|
|
@@ -24,7 +24,7 @@ Using custom config: ./build.browser-lib.config.js
|
|
|
24
24
|
rendering chunks...
|
|
25
25
|
|
|
26
26
|
[vite:dts] Start generate declaration files...
|
|
27
|
-
[vite:dts] Declaration files built in
|
|
27
|
+
[vite:dts] Declaration files built in 6452ms.
|
|
28
28
|
|
|
29
29
|
computing gzip size...
|
|
30
30
|
dist/components/PlClipboard/PlClipboard.vue?vue&type=style&index=0&lang.css 0.04 kB │ gzip: 0.06 kB
|
|
@@ -435,7 +435,6 @@ dist/assets/icons/icon-assets-min/24_error.js
|
|
|
435
435
|
dist/assets/images/required.js 0.49 kB │ gzip: 0.36 kB │ map: 0.56 kB
|
|
436
436
|
dist/assets/icons/icon-assets-min/16_filter-on.js 0.49 kB │ gzip: 0.35 kB │ map: 0.57 kB
|
|
437
437
|
dist/assets/icons/icon-assets-min/24_legend-box-dot.js 0.49 kB │ gzip: 0.33 kB │ map: 0.59 kB
|
|
438
|
-
dist/composition/computedCached.js 0.49 kB │ gzip: 0.32 kB │ map: 1.94 kB
|
|
439
438
|
dist/layout/PlPlaceholder/PlPlaceholder.vue_vue_type_style_index_0_lang.module.js 0.49 kB │ gzip: 0.29 kB │ map: 0.82 kB
|
|
440
439
|
dist/assets/icons/icon-assets-min/24_export.js 0.50 kB │ gzip: 0.34 kB │ map: 0.57 kB
|
|
441
440
|
dist/assets/icons/icon-assets-min/24_import.js 0.50 kB │ gzip: 0.33 kB │ map: 0.57 kB
|
|
@@ -507,6 +506,7 @@ dist/assets/icons/icon-assets-min/24_edit.js
|
|
|
507
506
|
dist/assets/icons/icon-assets-min/24_line-error.js 0.58 kB │ gzip: 0.34 kB │ map: 0.67 kB
|
|
508
507
|
dist/assets/icons/icon-assets-min/16_copy.js 0.59 kB │ gzip: 0.37 kB │ map: 0.68 kB
|
|
509
508
|
dist/assets/icons/icon-assets-min/24_reverse.js 0.59 kB │ gzip: 0.36 kB │ map: 0.66 kB
|
|
509
|
+
dist/composition/computedCached.js 0.59 kB │ gzip: 0.36 kB │ map: 2.72 kB
|
|
510
510
|
dist/assets/icons/icon-assets-min/24_files-export.js 0.59 kB │ gzip: 0.38 kB │ map: 0.68 kB
|
|
511
511
|
dist/assets/icons/icon-assets-min/16_edit.js 0.59 kB │ gzip: 0.38 kB │ map: 0.67 kB
|
|
512
512
|
dist/assets/icons/icon-assets-min/24_files-import.js 0.60 kB │ gzip: 0.38 kB │ map: 0.68 kB
|
|
@@ -534,6 +534,14 @@ dist/composition/useQuery.js
|
|
|
534
534
|
dist/assets/icons/icon-assets-min/16_settings.js 0.64 kB │ gzip: 0.37 kB │ map: 0.71 kB
|
|
535
535
|
dist/assets/icons/icon-assets-min/24_table-upload.js 0.64 kB │ gzip: 0.38 kB │ map: 0.73 kB
|
|
536
536
|
dist/assets/icons/icon-assets-min/16_data-dimentions.js 0.64 kB │ gzip: 0.42 kB │ map: 0.74 kB
|
|
537
|
+
[33m[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugins. Here is a breakdown:
|
|
538
|
+
- vite:asset (39%)
|
|
539
|
+
- vite:css-post (11%)
|
|
540
|
+
- sourcemaps (10%)
|
|
541
|
+
- vite:dts (10%)
|
|
542
|
+
- vite:vue (10%)
|
|
543
|
+
See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
544
|
+
[39m
|
|
537
545
|
dist/assets/icons/icon-assets-min/16_clipboard.js 0.64 kB │ gzip: 0.38 kB │ map: 0.72 kB
|
|
538
546
|
dist/components/PlFileDialog/utils.js 0.64 kB │ gzip: 0.43 kB │ map: 2.18 kB
|
|
539
547
|
dist/assets/icons/icon-assets-min/24_frame-type-none.js 0.65 kB │ gzip: 0.30 kB │ map: 0.72 kB
|
|
@@ -589,14 +597,6 @@ dist/assets/icons/icon-assets-min/24_folder-parent.js
|
|
|
589
597
|
dist/assets/icons/icon-assets-min/24_file-doc-add.js 0.74 kB │ gzip: 0.43 kB │ map: 0.83 kB
|
|
590
598
|
dist/assets/icons/icon-assets-min/24_filter.js 0.74 kB │ gzip: 0.44 kB │ map: 0.83 kB
|
|
591
599
|
dist/assets/icons/icon-assets-min/24_cpu.js 0.74 kB │ gzip: 0.42 kB │ map: 0.82 kB
|
|
592
|
-
[33m[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugins. Here is a breakdown:
|
|
593
|
-
- vite:asset (41%)
|
|
594
|
-
- vite:css-post (11%)
|
|
595
|
-
- vite:dts (10%)
|
|
596
|
-
- vite:vue (10%)
|
|
597
|
-
- sourcemaps (8%)
|
|
598
|
-
See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
599
|
-
[39m
|
|
600
600
|
dist/components/PlChartHistogram/createGridlines.js 0.75 kB │ gzip: 0.42 kB │ map: 2.52 kB
|
|
601
601
|
dist/assets/icons/icon-assets-min/24_cloud-online.js 0.76 kB │ gzip: 0.47 kB │ map: 0.84 kB
|
|
602
602
|
dist/generated/icons-16.js 0.76 kB │ gzip: 0.44 kB │ map: 1.35 kB
|
|
@@ -796,5 +796,5 @@ dist/composition/filters/metadata.js
|
|
|
796
796
|
dist/index.js 12.53 kB │ gzip: 2.96 kB │ map: 21.32 kB
|
|
797
797
|
dist/components/PlSvg/PlSvg.vue_vue_type_script_setup_true_lang.js 39.41 kB │ gzip: 3.40 kB │ map: 8.66 kB
|
|
798
798
|
|
|
799
|
-
[32m✓ built in
|
|
799
|
+
[32m✓ built in 8.64s[39m
|
|
800
800
|
Build completed successfully
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
WARN Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @milaboratories/uikit@2.15.
|
|
3
|
+
> @milaboratories/uikit@2.15.15 formatter:check /home/runner/_work/platforma/platforma/lib/ui/uikit
|
|
4
4
|
> ts-builder formatter --check
|
|
5
5
|
|
|
6
6
|
Checking formatting...
|
|
@@ -8,5 +8,5 @@ Checking formatting...
|
|
|
8
8
|
Checking formatting...
|
|
9
9
|
|
|
10
10
|
All matched files use the correct format.
|
|
11
|
-
Finished in
|
|
11
|
+
Finished in 1956ms on 381 files using 16 threads.
|
|
12
12
|
Format check completed successfully
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
WARN Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @milaboratories/uikit@2.15.
|
|
3
|
+
> @milaboratories/uikit@2.15.15 linter:check /home/runner/_work/platforma/platforma/lib/ui/uikit
|
|
4
4
|
> ts-builder linter --check
|
|
5
5
|
|
|
6
6
|
Linting project...
|
|
7
7
|
↳ oxlint --config /home/runner/_work/platforma/platforma/lib/ui/uikit/.oxlintrc.json --deny-warnings
|
|
8
8
|
Found 0 warnings and 0 errors.
|
|
9
|
-
Finished in
|
|
9
|
+
Finished in 32ms on 308 files with 108 rules using 16 threads.
|
|
10
10
|
Linting completed successfully
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
WARN Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @milaboratories/uikit@2.15.
|
|
3
|
+
> @milaboratories/uikit@2.15.15 types:check /home/runner/_work/platforma/platforma/lib/ui/uikit
|
|
4
4
|
> ts-builder type-check --target browser-lib
|
|
5
5
|
|
|
6
6
|
↳ vue-tsc.js --noEmit --project ./tsconfig.json --customConditions ,
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @milaboratories/uikit
|
|
2
2
|
|
|
3
|
+
## 2.15.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [881d6ba]
|
|
8
|
+
- @platforma-sdk/model@1.80.0
|
|
9
|
+
|
|
10
|
+
## 2.15.14
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- f0b5537: Fix an infinite grid-remount loop in `PlAgDataTableV2` that made the column
|
|
15
|
+
headers strobe (rapid flickering of the column type icons) and flooded the
|
|
16
|
+
console with AG Grid "grid has been destroyed" (#26) errors.
|
|
17
|
+
|
|
18
|
+
The reload watch destroys and recreates the whole grid via `:key="reloadKey"`.
|
|
19
|
+
The stored grid state was read through a debounced cache, so right after a
|
|
20
|
+
reload the cache kept reporting the pre-reload value while the fresh grid
|
|
21
|
+
already reported the state AG Grid normalized it to; the two never converged and
|
|
22
|
+
the grid remounted on every frame. `computedCached` gains a `writeThrough`
|
|
23
|
+
option that adopts a set value into the cache synchronously (the debounce then
|
|
24
|
+
only defers the downstream write), so the reload comparison converges after the
|
|
25
|
+
single remount that applies the state.
|
|
26
|
+
|
|
27
|
+
Also guards the row-number column auto-size so it no longer calls
|
|
28
|
+
`applyColumnState` on an already-destroyed grid.
|
|
29
|
+
|
|
3
30
|
## 2.15.13
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
|
@@ -2,10 +2,15 @@ import { ComputedGetter, ComputedSetter, ComputedRef, WritableComputedRef } from
|
|
|
2
2
|
/**
|
|
3
3
|
* Alternative to `computed`, but triggering only on actual data changes.
|
|
4
4
|
* Always `deep` as the plain `computed` is.
|
|
5
|
+
*
|
|
6
|
+
* With `writeThrough`, a set updates the cache synchronously, so a read reflects
|
|
7
|
+
* the write immediately even when `set` defers its work (e.g. debounced); the
|
|
8
|
+
* getter must then map set values to themselves (`get(x)` deep-equals `x`).
|
|
5
9
|
*/
|
|
6
10
|
export declare function computedCached<T>(options: {
|
|
7
11
|
get: ComputedGetter<T>;
|
|
8
12
|
set: ComputedSetter<T>;
|
|
13
|
+
writeThrough?: boolean;
|
|
9
14
|
}): WritableComputedRef<T>;
|
|
10
15
|
export declare function computedCached<T>(getter: ComputedGetter<T>): ComputedRef<T>;
|
|
11
16
|
//# sourceMappingURL=computedCached.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedCached.d.ts","sourceRoot":"","sources":["../../src/composition/computedCached.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACzB,MAAM,KAAK,CAAC;AAEb
|
|
1
|
+
{"version":3,"file":"computedCached.d.ts","sourceRoot":"","sources":["../../src/composition/computedCached.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACzB,MAAM,KAAK,CAAC;AAEb;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE;IACzC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACvB,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3B,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -2,15 +2,17 @@ import { computed as e, ref as t, watch as n } from "vue";
|
|
|
2
2
|
import { deepClone as r, isJsonEqual as i } from "@milaboratories/helpers";
|
|
3
3
|
//#region src/composition/computedCached.ts
|
|
4
4
|
function a(a) {
|
|
5
|
-
let o, s;
|
|
6
|
-
typeof a == "function" ? o = a : (o = a.get, s = a.set);
|
|
7
|
-
let
|
|
5
|
+
let o, s, c = !1;
|
|
6
|
+
typeof a == "function" ? o = a : (o = a.get, s = a.set, c = a.writeThrough ?? !1);
|
|
7
|
+
let l = t(o());
|
|
8
8
|
return n(o, (e) => {
|
|
9
|
-
i(e,
|
|
9
|
+
i(e, l.value) || (l.value = r(e));
|
|
10
10
|
}, { deep: !0 }), s ? e({
|
|
11
|
-
get: () =>
|
|
12
|
-
set:
|
|
13
|
-
|
|
11
|
+
get: () => l.value,
|
|
12
|
+
set: c ? (e) => {
|
|
13
|
+
i(e, l.value) || (l.value = r(e)), s(e);
|
|
14
|
+
} : s
|
|
15
|
+
}) : l;
|
|
14
16
|
}
|
|
15
17
|
//#endregion
|
|
16
18
|
export { a as computedCached };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedCached.js","names":[],"sources":["../../src/composition/computedCached.ts"],"sourcesContent":["import { deepClone, isJsonEqual } from \"@milaboratories/helpers\";\nimport {\n computed,\n ref,\n watch,\n type ComputedGetter,\n type ComputedSetter,\n type ComputedRef,\n type WritableComputedRef,\n} from \"vue\";\n\n/**\n * Alternative to `computed`, but triggering only on actual data changes.\n * Always `deep` as the plain `computed` is.\n */\nexport function computedCached<T>(options: {\n get: ComputedGetter<T>;\n set: ComputedSetter<T>;\n}): WritableComputedRef<T>;\nexport function computedCached<T>(getter: ComputedGetter<T>): ComputedRef<T>;\nexport function computedCached<T>(\n arg:\n | ComputedGetter<T>\n | {\n get: ComputedGetter<T>;\n set: ComputedSetter<T>;\n },\n) {\n let getter: ComputedGetter<T>;\n let setter: ComputedSetter<T> | undefined = undefined;\n if (typeof arg === \"function\") {\n getter = arg;\n } else {\n getter = arg.get;\n setter = arg.set;\n }\n\n const cachedValue = ref<T>(getter());\n watch(\n getter,\n (newValue) => {\n if (!isJsonEqual(newValue, cachedValue.value)) {\n // `deepClone` is needed because in case some fields are patched the deep would be triggered,\n // but objects would be equal as the saved value was also patched\n cachedValue.value = deepClone(newValue);\n }\n },\n { deep: true },\n );\n\n if (setter) {\n return computed({\n get: () => cachedValue.value,\n set: setter,\n });\n } else {\n return cachedValue;\n }\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"computedCached.js","names":[],"sources":["../../src/composition/computedCached.ts"],"sourcesContent":["import { deepClone, isJsonEqual } from \"@milaboratories/helpers\";\nimport {\n computed,\n ref,\n watch,\n type ComputedGetter,\n type ComputedSetter,\n type ComputedRef,\n type WritableComputedRef,\n} from \"vue\";\n\n/**\n * Alternative to `computed`, but triggering only on actual data changes.\n * Always `deep` as the plain `computed` is.\n *\n * With `writeThrough`, a set updates the cache synchronously, so a read reflects\n * the write immediately even when `set` defers its work (e.g. debounced); the\n * getter must then map set values to themselves (`get(x)` deep-equals `x`).\n */\nexport function computedCached<T>(options: {\n get: ComputedGetter<T>;\n set: ComputedSetter<T>;\n writeThrough?: boolean;\n}): WritableComputedRef<T>;\nexport function computedCached<T>(getter: ComputedGetter<T>): ComputedRef<T>;\nexport function computedCached<T>(\n arg:\n | ComputedGetter<T>\n | {\n get: ComputedGetter<T>;\n set: ComputedSetter<T>;\n writeThrough?: boolean;\n },\n) {\n let getter: ComputedGetter<T>;\n let setter: ComputedSetter<T> | undefined = undefined;\n let writeThrough = false;\n if (typeof arg === \"function\") {\n getter = arg;\n } else {\n getter = arg.get;\n setter = arg.set;\n writeThrough = arg.writeThrough ?? false;\n }\n\n const cachedValue = ref<T>(getter());\n watch(\n getter,\n (newValue) => {\n if (!isJsonEqual(newValue, cachedValue.value)) {\n // `deepClone` is needed because in case some fields are patched the deep would be triggered,\n // but objects would be equal as the saved value was also patched\n cachedValue.value = deepClone(newValue);\n }\n },\n { deep: true },\n );\n\n if (setter) {\n return computed({\n get: () => cachedValue.value,\n set: writeThrough\n ? (newValue) => {\n // Reflect the value in the cache now; `set` itself may defer its work.\n if (!isJsonEqual(newValue, cachedValue.value)) cachedValue.value = deepClone(newValue);\n setter(newValue);\n }\n : setter,\n });\n } else {\n return cachedValue;\n }\n}\n"],"mappings":";;;AAyBA,SAAgB,EACd,GAOA;CACA,IAAI,GACA,GACA,IAAe;AACnB,CAAI,OAAO,KAAQ,aACjB,IAAS,KAET,IAAS,EAAI,KACb,IAAS,EAAI,KACb,IAAe,EAAI,gBAAgB;CAGrC,IAAM,IAAc,EAAO,GAAQ,CAAC;AAyBlC,QAxBF,EACE,IACC,MAAa;AACZ,EAAK,EAAY,GAAU,EAAY,MAAM,KAG3C,EAAY,QAAQ,EAAU,EAAS;IAG3C,EAAE,MAAM,IAAM,CACf,EAEG,IACK,EAAS;EACd,WAAW,EAAY;EACvB,KAAK,KACA,MAAa;AAGZ,GADK,EAAY,GAAU,EAAY,MAAM,KAAE,EAAY,QAAQ,EAAU,EAAS,GACtF,EAAO,EAAS;MAElB;EACL,CAAC,GAEK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/uikit",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"resize-observer-polyfill": "^1.5.1",
|
|
32
32
|
"sortablejs": "^1.15.6",
|
|
33
33
|
"vue": "3.5.24",
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
34
|
+
"@platforma-sdk/model": "1.80.0",
|
|
35
|
+
"@milaboratories/helpers": "1.14.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@vitest/coverage-istanbul": "^4.1.3",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"svgo": "^3.3.2",
|
|
41
41
|
"typescript": "~5.9.3",
|
|
42
42
|
"vitest": "^4.1.3",
|
|
43
|
-
"@milaboratories/build-configs": "2.0.0",
|
|
44
43
|
"@milaboratories/ts-builder": "1.6.0",
|
|
45
|
-
"@milaboratories/ts-configs": "1.3.0"
|
|
44
|
+
"@milaboratories/ts-configs": "1.3.0",
|
|
45
|
+
"@milaboratories/build-configs": "2.0.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"dev": "ts-builder serve --target browser-lib --build-config ./build.browser-lib.config.js",
|
|
@@ -12,10 +12,15 @@ import {
|
|
|
12
12
|
/**
|
|
13
13
|
* Alternative to `computed`, but triggering only on actual data changes.
|
|
14
14
|
* Always `deep` as the plain `computed` is.
|
|
15
|
+
*
|
|
16
|
+
* With `writeThrough`, a set updates the cache synchronously, so a read reflects
|
|
17
|
+
* the write immediately even when `set` defers its work (e.g. debounced); the
|
|
18
|
+
* getter must then map set values to themselves (`get(x)` deep-equals `x`).
|
|
15
19
|
*/
|
|
16
20
|
export function computedCached<T>(options: {
|
|
17
21
|
get: ComputedGetter<T>;
|
|
18
22
|
set: ComputedSetter<T>;
|
|
23
|
+
writeThrough?: boolean;
|
|
19
24
|
}): WritableComputedRef<T>;
|
|
20
25
|
export function computedCached<T>(getter: ComputedGetter<T>): ComputedRef<T>;
|
|
21
26
|
export function computedCached<T>(
|
|
@@ -24,15 +29,18 @@ export function computedCached<T>(
|
|
|
24
29
|
| {
|
|
25
30
|
get: ComputedGetter<T>;
|
|
26
31
|
set: ComputedSetter<T>;
|
|
32
|
+
writeThrough?: boolean;
|
|
27
33
|
},
|
|
28
34
|
) {
|
|
29
35
|
let getter: ComputedGetter<T>;
|
|
30
36
|
let setter: ComputedSetter<T> | undefined = undefined;
|
|
37
|
+
let writeThrough = false;
|
|
31
38
|
if (typeof arg === "function") {
|
|
32
39
|
getter = arg;
|
|
33
40
|
} else {
|
|
34
41
|
getter = arg.get;
|
|
35
42
|
setter = arg.set;
|
|
43
|
+
writeThrough = arg.writeThrough ?? false;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
const cachedValue = ref<T>(getter());
|
|
@@ -51,7 +59,13 @@ export function computedCached<T>(
|
|
|
51
59
|
if (setter) {
|
|
52
60
|
return computed({
|
|
53
61
|
get: () => cachedValue.value,
|
|
54
|
-
set:
|
|
62
|
+
set: writeThrough
|
|
63
|
+
? (newValue) => {
|
|
64
|
+
// Reflect the value in the cache now; `set` itself may defer its work.
|
|
65
|
+
if (!isJsonEqual(newValue, cachedValue.value)) cachedValue.value = deepClone(newValue);
|
|
66
|
+
setter(newValue);
|
|
67
|
+
}
|
|
68
|
+
: setter,
|
|
55
69
|
});
|
|
56
70
|
} else {
|
|
57
71
|
return cachedValue;
|