@platforma-sdk/ui-vue 1.55.2 → 1.57.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/.turbo/turbo-build.log +6 -6
- 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 +16 -0
- package/dist/components/PlAnnotations/components/PlAnnotations.vue2.js.map +1 -1
- package/dist/internal/createAppV3.d.ts.map +1 -1
- package/dist/internal/createAppV3.js +36 -39
- package/dist/internal/createAppV3.js.map +1 -1
- package/package.json +5 -5
- package/src/internal/createAppV3.ts +1 -3
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
|
-
> @platforma-sdk/ui-vue@1.
|
|
3
|
+
> @platforma-sdk/ui-vue@1.57.0 build /home/runner/_work/platforma/platforma/sdk/ui-vue
|
|
4
4
|
> ts-builder build --target browser-lib
|
|
5
5
|
|
|
6
6
|
Building browser-lib project...
|
|
@@ -19,8 +19,8 @@ computing gzip size...
|
|
|
19
19
|
[2mdist/[22m[36mcomponents/PlAgCellFile/PlAgCellFile.vue2.js [39m[1m[2m 0.11 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.10 kB[22m
|
|
20
20
|
[2mdist/[22m[36mcomponents/PlAgDataTable/PlAgRowCount.vue2.js [39m[1m[2m 0.11 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.10 kB[22m
|
|
21
21
|
[2mdist/[22m[36mcomponents/PlAgCsvExporter/PlAgCsvExporter.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
22
|
-
[2mdist/[22m[36mcomponents/PlAgColumnHeader/PlAgColumnHeader.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
23
22
|
[2mdist/[22m[36mcomponents/PlAgCellProgress/PlAgCellProgress.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
23
|
+
[2mdist/[22m[36mcomponents/PlAgColumnHeader/PlAgColumnHeader.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
24
24
|
[2mdist/[22m[36mcomponents/PlAgRowNumHeader.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
25
25
|
[2mdist/[22m[36mcomponents/PlTableFastSearch/PlTableFastSearch.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
26
26
|
[2mdist/[22m[36mcomponents/PlAgDataTable/PlAgOverlayLoading.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
@@ -69,8 +69,8 @@ computing gzip size...
|
|
|
69
69
|
[2mdist/[22m[36mcomponents/PlAdvancedFilter/PlAdvancedFilter.vue.js [39m[1m[2m 0.30 kB[22m[1m[22m[2m │ gzip: 0.22 kB[22m[2m │ map: 0.11 kB[22m
|
|
70
70
|
[2mdist/[22m[36mcomponents/PlBtnExportArchive/PlBtnExportArchive.vue.js [39m[1m[2m 0.31 kB[22m[1m[22m[2m │ gzip: 0.22 kB[22m[2m │ map: 0.11 kB[22m
|
|
71
71
|
[2mdist/[22m[36mcomponents/PlAnnotations/components/PlAnnotationsModal.vue.js [39m[1m[2m 0.31 kB[22m[1m[22m[2m │ gzip: 0.22 kB[22m[2m │ map: 0.11 kB[22m
|
|
72
|
-
[2mdist/[22m[36mcomponents/PlAnnotations/components/AnnotationsSidebar.vue.js [39m[1m[2m 0.31 kB[22m[1m[22m[2m │ gzip: 0.22 kB[22m[2m │ map: 0.11 kB[22m
|
|
73
72
|
[2mdist/[22m[36mcomponents/PlAgDataTable/PlAgDataTableSheets.vue.js [39m[1m[2m 0.31 kB[22m[1m[22m[2m │ gzip: 0.22 kB[22m[2m │ map: 0.11 kB[22m
|
|
73
|
+
[2mdist/[22m[36mcomponents/PlAnnotations/components/AnnotationsSidebar.vue.js [39m[1m[2m 0.31 kB[22m[1m[22m[2m │ gzip: 0.22 kB[22m[2m │ map: 0.11 kB[22m
|
|
74
74
|
[2mdist/[22m[36mcomponents/PlAgGridColumnManager/PlAgGridColumnManager.vue.js [39m[1m[2m 0.32 kB[22m[1m[22m[2m │ gzip: 0.23 kB[22m[2m │ map: 0.12 kB[22m
|
|
75
75
|
[2mdist/[22m[36mlib/util/helpers/dist/strings.js [39m[1m[2m 0.35 kB[22m[1m[22m[2m │ gzip: 0.24 kB[22m[2m │ map: 4.22 kB[22m
|
|
76
76
|
[2mdist/[22m[36mcomponents/PlAgDataTable/pl-ag-overlay-loading.module.scss.js [39m[1m[2m 0.36 kB[22m[1m[22m[2m │ gzip: 0.22 kB[22m[2m │ map: 0.12 kB[22m
|
|
@@ -149,7 +149,7 @@ computing gzip size...
|
|
|
149
149
|
[2mdist/[22m[36mcomposition/fileContent.js [39m[1m[2m 5.84 kB[22m[1m[22m[2m │ gzip: 1.97 kB[22m[2m │ map: 14.42 kB[22m
|
|
150
150
|
[2mdist/[22m[36minternal/createAppV1.js [39m[1m[2m 5.98 kB[22m[1m[22m[2m │ gzip: 1.91 kB[22m[2m │ map: 16.18 kB[22m
|
|
151
151
|
[2mdist/[22m[36mcomponents/PlBtnExportArchive/PlBtnExportArchive.vue2.js [39m[1m[2m 5.99 kB[22m[1m[22m[2m │ gzip: 2.23 kB[22m[2m │ map: 12.13 kB[22m
|
|
152
|
-
[2mdist/[22m[36minternal/createAppV3.js [39m[1m[2m 6.
|
|
152
|
+
[2mdist/[22m[36minternal/createAppV3.js [39m[1m[2m 6.14 kB[22m[1m[22m[2m │ gzip: 2.37 kB[22m[2m │ map: 19.04 kB[22m
|
|
153
153
|
[2mdist/[22m[36minternal/createAppV2.js [39m[1m[2m 7.01 kB[22m[1m[22m[2m │ gzip: 2.46 kB[22m[2m │ map: 20.24 kB[22m
|
|
154
154
|
[2mdist/[22m[36mcomponents/PlAgDataTable/sources/table-source-v2.js [39m[1m[2m 7.11 kB[22m[1m[22m[2m │ gzip: 2.61 kB[22m[2m │ map: 21.91 kB[22m
|
|
155
155
|
[2mdist/[22m[36mAgGridVue/useAgGridOptions.js [39m[1m[2m 7.50 kB[22m[1m[22m[2m │ gzip: 2.13 kB[22m[2m │ map: 16.27 kB[22m
|
|
@@ -157,7 +157,7 @@ computing gzip size...
|
|
|
157
157
|
[2mdist/[22m[36mcomponents/PlAdvancedFilter/FilterEditor.vue2.js [39m[1m[2m12.83 kB[22m[1m[22m[2m │ gzip: 3.28 kB[22m[2m │ map: 25.49 kB[22m
|
|
158
158
|
[2mdist/[22m[36mcomponents/PlAgDataTable/PlAgDataTableV2.vue2.js [39m[1m[2m12.92 kB[22m[1m[22m[2m │ gzip: 3.68 kB[22m[2m │ map: 29.49 kB[22m
|
|
159
159
|
[2mdist/[22m[36mindex.js [39m[1m[2m99.95 kB[22m[1m[22m[2m │ gzip: 64.35 kB[22m[2m │ map: 0.13 kB[22m
|
|
160
|
-
[vite:dts] Declaration files built in
|
|
160
|
+
[vite:dts] Declaration files built in 7782ms.
|
|
161
161
|
|
|
162
|
-
[32m✓ built in
|
|
162
|
+
[32m✓ built in 9.12s[39m
|
|
163
163
|
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
|
-
> @platforma-sdk/ui-vue@1.
|
|
3
|
+
> @platforma-sdk/ui-vue@1.57.0 formatter:check /home/runner/_work/platforma/platforma/sdk/ui-vue
|
|
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 2314ms on 125 files using 8 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
|
-
> @platforma-sdk/ui-vue@1.
|
|
3
|
+
> @platforma-sdk/ui-vue@1.57.0 linter:check /home/runner/_work/platforma/platforma/sdk/ui-vue
|
|
4
4
|
> ts-builder linter --check
|
|
5
5
|
|
|
6
6
|
Linting project...
|
|
7
7
|
↳ oxlint --config /home/runner/_work/platforma/platforma/sdk/ui-vue/.oxlintrc.json --deny-warnings
|
|
8
8
|
Found 0 warnings and 0 errors.
|
|
9
|
-
Finished in
|
|
9
|
+
Finished in 27ms on 108 files with 98 rules using 8 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
|
-
> @platforma-sdk/ui-vue@1.
|
|
3
|
+
> @platforma-sdk/ui-vue@1.57.0 types:check /home/runner/_work/platforma/platforma/sdk/ui-vue
|
|
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,21 @@
|
|
|
1
1
|
# @platforma-sdk/ui-vue
|
|
2
2
|
|
|
3
|
+
## 1.57.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8baa2b3]
|
|
8
|
+
- @platforma-sdk/model@1.57.0
|
|
9
|
+
- @milaboratories/uikit@2.10.30
|
|
10
|
+
|
|
11
|
+
## 1.56.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [f2daf69]
|
|
16
|
+
- @platforma-sdk/model@1.56.0
|
|
17
|
+
- @milaboratories/uikit@2.10.29
|
|
18
|
+
|
|
3
19
|
## 1.55.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlAnnotations.vue2.js","sources":["../../../../src/components/PlAnnotations/components/PlAnnotations.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Props as BaseProps } from \"./FilterSidebar.vue\";\nexport type Props = BaseProps & {\n onDeleteSchema?: () => void;\n};\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, effect, shallowRef } from \"vue\";\n\nimport { isNil } from \"@milaboratories/helpers\";\nimport { PlSidebarGroup, useConfirm } from \"@milaboratories/uikit\";\n\nimport type { Annotation } from \"../types\";\nimport AnnotationsSidebar from \"./AnnotationsSidebar.vue\";\nimport FilterSidebar from \"./FilterSidebar.vue\";\n\n// Models\nconst annotation = defineModel<Annotation>(\"annotation\", { required: true });\n// Props\nconst props = defineProps<Props>();\n// State\nconst selectedStepId = shallowRef<number | undefined>(undefined);\nconst selectedStep = computed(() => {\n return isNil(selectedStepId.value) || isNil(annotation.value)\n ? undefined\n : annotation.value.steps.find((step) => step.id === selectedStepId.value);\n});\n\n// Watchers\neffect(function setDefaultStepId() {\n if (selectedStepId.value === undefined && annotation.value.steps.length > 0) {\n selectedStepId.value = annotation.value.steps[0].id;\n }\n});\n// Hooks\nconst confirmResetSchema = useConfirm({\n title: \"Reset Schema\",\n message: \"Are you sure you want to reset the schema? This action cannot be undone.\",\n confirmLabel: \"Yes, reset\",\n cancelLabel: \"No, cancel\",\n});\n// Actions\nasync function handleDeleteSchema() {\n if (await confirmResetSchema()) {\n selectedStepId.value = undefined;\n props.onDeleteSchema?.();\n }\n}\n</script>\n\n<template>\n <PlSidebarGroup>\n <template #item-0>\n <AnnotationsSidebar\n v-model:annotation=\"annotation\"\n v-model:selectedStepId=\"selectedStepId\"\n :class=\"$style.sidebarItem\"\n :columns=\"props.columns\"\n @delete-schema=\"handleDeleteSchema\"\n />\n </template>\n <template #item-1>\n <FilterSidebar\n v-if=\"selectedStep\"\n v-model:step=\"selectedStep\"\n :class=\"$style.sidebarItem\"\n :columns=\"props.columns\"\n :get-suggest-options=\"props.getSuggestOptions\"\n :selectedStepId=\"selectedStepId\"\n :hasSelectedColumns=\"props.hasSelectedColumns\"\n :getValuesForSelectedColumns=\"props.getValuesForSelectedColumns\"\n />\n </template>\n </PlSidebarGroup>\n</template>\n\n<style module>\n.sidebarItem {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["annotation","_useModel","props","__props","selectedStepId","shallowRef","selectedStep","computed","isNil","step","effect","confirmResetSchema","useConfirm","handleDeleteSchema","_a","_createBlock","_unref","PlSidebarGroup","_createVNode","AnnotationsSidebar","$event","_normalizeClass","$style","FilterSidebar"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,UAAMA,IAAaC,KAAwB,YAAgC,GAErEC,IAAQC,GAERC,IAAiBC,EAA+B,MAAS,GACzDC,IAAeC,EAAS,MACrBC,EAAMJ,EAAe,KAAK,KAAKI,EAAMR,EAAW,KAAK,IACxD,SACAA,EAAW,MAAM,MAAM,KAAK,CAACS,MAASA,EAAK,OAAOL,EAAe,KAAK,CAC3E;AAGD,IAAAM,EAAO,WAA4B;AACjC,MAAIN,EAAe,UAAU,UAAaJ,EAAW,MAAM,MAAM,SAAS,MACxEI,EAAe,QAAQJ,EAAW,MAAM,MAAM,CAAC,EAAE;AAAA,IAErD,CAAC;AAED,UAAMW,IAAqBC,EAAW;AAAA,MACpC,OAAO;AAAA,MACP,SAAS;AAAA,MACT,cAAc;AAAA,MACd,aAAa;AAAA,IAAA,CACd;AAED,mBAAeC,IAAqB;;AAClC,MAAI,MAAMF,QACRP,EAAe,QAAQ,SACvBU,IAAAZ,EAAM,mBAAN,QAAAY,EAAA,KAAAZ;AAAA,IAEJ;2BAIEa,EAsBiBC,EAAAC,CAAA,GAAA,MAAA;AAAA,MArBJ,YACT,MAME;AAAA,QANFC,EAMEC,GAAA;AAAA,UALQ,YAAYnB,EAAA;AAAA,wDAAAA,EAAU,QAAAoB;AAAA,UACtB,gBAAgBhB,EAAA;AAAA,4DAAAA,EAAc,QAAAgB;AAAA,UACrC,OAAKC,EAAEC,EAAAA,OAAO,WAAW;AAAA,UACzB,SAASpB,EAAM;AAAA,UACf,gBAAeW;AAAA,QAAA;;MAGT,
|
|
1
|
+
{"version":3,"file":"PlAnnotations.vue2.js","sources":["../../../../src/components/PlAnnotations/components/PlAnnotations.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Props as BaseProps } from \"./FilterSidebar.vue\";\nexport type Props = BaseProps & {\n onDeleteSchema?: () => void;\n};\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, effect, shallowRef } from \"vue\";\n\nimport { isNil } from \"@milaboratories/helpers\";\nimport { PlSidebarGroup, useConfirm } from \"@milaboratories/uikit\";\n\nimport type { Annotation } from \"../types\";\nimport AnnotationsSidebar from \"./AnnotationsSidebar.vue\";\nimport FilterSidebar from \"./FilterSidebar.vue\";\n\n// Models\nconst annotation = defineModel<Annotation>(\"annotation\", { required: true });\n// Props\nconst props = defineProps<Props>();\n// State\nconst selectedStepId = shallowRef<number | undefined>(undefined);\nconst selectedStep = computed(() => {\n return isNil(selectedStepId.value) || isNil(annotation.value)\n ? undefined\n : annotation.value.steps.find((step) => step.id === selectedStepId.value);\n});\n\n// Watchers\neffect(function setDefaultStepId() {\n if (selectedStepId.value === undefined && annotation.value.steps.length > 0) {\n selectedStepId.value = annotation.value.steps[0].id;\n }\n});\n// Hooks\nconst confirmResetSchema = useConfirm({\n title: \"Reset Schema\",\n message: \"Are you sure you want to reset the schema? This action cannot be undone.\",\n confirmLabel: \"Yes, reset\",\n cancelLabel: \"No, cancel\",\n});\n// Actions\nasync function handleDeleteSchema() {\n if (await confirmResetSchema()) {\n selectedStepId.value = undefined;\n props.onDeleteSchema?.();\n }\n}\n</script>\n\n<template>\n <PlSidebarGroup>\n <template #item-0>\n <AnnotationsSidebar\n v-model:annotation=\"annotation\"\n v-model:selectedStepId=\"selectedStepId\"\n :class=\"$style.sidebarItem\"\n :columns=\"props.columns\"\n @delete-schema=\"handleDeleteSchema\"\n />\n </template>\n <template #item-1>\n <FilterSidebar\n v-if=\"selectedStep\"\n v-model:step=\"selectedStep\"\n :class=\"$style.sidebarItem\"\n :columns=\"props.columns\"\n :get-suggest-options=\"props.getSuggestOptions\"\n :selectedStepId=\"selectedStepId\"\n :hasSelectedColumns=\"props.hasSelectedColumns\"\n :getValuesForSelectedColumns=\"props.getValuesForSelectedColumns\"\n />\n </template>\n </PlSidebarGroup>\n</template>\n\n<style module>\n.sidebarItem {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["annotation","_useModel","props","__props","selectedStepId","shallowRef","selectedStep","computed","isNil","step","effect","confirmResetSchema","useConfirm","handleDeleteSchema","_a","_createBlock","_unref","PlSidebarGroup","_createVNode","AnnotationsSidebar","$event","_normalizeClass","$style","FilterSidebar"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,UAAMA,IAAaC,KAAwB,YAAgC,GAErEC,IAAQC,GAERC,IAAiBC,EAA+B,MAAS,GACzDC,IAAeC,EAAS,MACrBC,EAAMJ,EAAe,KAAK,KAAKI,EAAMR,EAAW,KAAK,IACxD,SACAA,EAAW,MAAM,MAAM,KAAK,CAACS,MAASA,EAAK,OAAOL,EAAe,KAAK,CAC3E;AAGD,IAAAM,EAAO,WAA4B;AACjC,MAAIN,EAAe,UAAU,UAAaJ,EA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AC,IAAI,CAAC;;;;;;yBA+IkB,IAAI;oCAEf,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAK3E;;;;;;WAMG;uBACY,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;QAMtD;;;;;WAKG;yBACc,IAAI;;;;EAkDxB;AAED,MAAM,MAAM,SAAS,CACnB,IAAI,GAAG,OAAO,EACd,IAAI,GAAG,OAAO,EACd,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IACtC,UAAU,CAAC,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { delay as
|
|
1
|
+
import { delay as B } from "../lib/util/helpers/dist/utils.js";
|
|
2
2
|
import { uniqueId as R } from "../lib/util/helpers/dist/strings.js";
|
|
3
3
|
import { deepClone as h } from "../lib/util/helpers/dist/objects.js";
|
|
4
|
-
import { deriveDataFromStorage as N, unwrapResult as p, hasAbortError as G,
|
|
4
|
+
import { deriveDataFromStorage as N, unwrapResult as p, hasAbortError as G, getPluginData as K } from "@platforma-sdk/model";
|
|
5
5
|
import { ref as D, reactive as y, computed as g } from "vue";
|
|
6
|
-
import { parseQuery as
|
|
7
|
-
import { ensureOutputHasStableFlag as
|
|
6
|
+
import { parseQuery as X } from "../urls.js";
|
|
7
|
+
import { ensureOutputHasStableFlag as Y, MultiError as Z } from "../utils.js";
|
|
8
8
|
import { applyPatch as V } from "fast-json-patch";
|
|
9
9
|
import { UpdateSerializer as P } from "./UpdateSerializer.js";
|
|
10
|
-
import { watchIgnorable as
|
|
11
|
-
const _ = 150,
|
|
10
|
+
import { watchIgnorable as W } from "@vueuse/core";
|
|
11
|
+
const _ = 150, ee = (r) => ({
|
|
12
12
|
authorId: (r == null ? void 0 : r.authorId) ?? R(),
|
|
13
13
|
localVersion: ((r == null ? void 0 : r.localVersion) ?? 0) + 1
|
|
14
14
|
}), F = (r) => {
|
|
@@ -18,7 +18,7 @@ const _ = 150, te = (r) => ({
|
|
|
18
18
|
return u instanceof Error ? u.message : String(u);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function pe(r, u, f) {
|
|
22
22
|
const n = (e, ...t) => {
|
|
23
23
|
f.debug && console.log(
|
|
24
24
|
`%c>>> %c${e}`,
|
|
@@ -39,31 +39,28 @@ function de(r, u, f) {
|
|
|
39
39
|
authorId: R(),
|
|
40
40
|
localVersion: 0
|
|
41
41
|
}
|
|
42
|
-
}, T = () => (s.author =
|
|
43
|
-
let t =
|
|
44
|
-
return t || (t = new P({ debounceSpan: b }),
|
|
45
|
-
},
|
|
42
|
+
}, T = () => (s.author = ee(s.author), n("nextAuthorMarker", s.author), s.author), m = D(!1), v = D(r.uTag), b = f.debounceSpan ?? 200, w = new P({ debounceSpan: b }), S = /* @__PURE__ */ new Map(), q = (e) => {
|
|
43
|
+
let t = S.get(e);
|
|
44
|
+
return t || (t = new P({ debounceSpan: b }), S.set(e, t)), t;
|
|
45
|
+
}, I = new P({ debounceSpan: b }), c = y({}), o = D(r.value), A = async (e) => u.mutateStorage({ operation: "update-block-data", value: e }, T()), k = async (e, t) => u.mutateStorage(
|
|
46
46
|
{ operation: "update-plugin-data", pluginId: e, value: t },
|
|
47
47
|
T()
|
|
48
|
-
), E = (e) => {
|
|
49
|
-
const t = K(o.value.blockStorage);
|
|
50
|
-
return X(t, e);
|
|
51
|
-
}, z = async (e) => u.setNavigationState(e), C = g(() => {
|
|
48
|
+
), E = (e) => K(o.value.blockStorage, e), C = async (e) => u.setNavigationState(e), U = g(() => {
|
|
52
49
|
const e = Object.entries(o.value.outputs).map(
|
|
53
50
|
([t, a]) => {
|
|
54
51
|
var l;
|
|
55
|
-
return (l = u.blockModelInfo.outputs[t]) != null && l.withStatus ? [t,
|
|
52
|
+
return (l = u.blockModelInfo.outputs[t]) != null && l.withStatus ? [t, Y(a)] : [
|
|
56
53
|
t,
|
|
57
54
|
a.ok && a.value !== void 0 ? a.value : void 0
|
|
58
55
|
];
|
|
59
56
|
}
|
|
60
57
|
);
|
|
61
58
|
return Object.fromEntries(e);
|
|
62
|
-
}),
|
|
59
|
+
}), $ = g(() => {
|
|
63
60
|
const e = Object.entries(o.value.outputs).map(
|
|
64
61
|
([t, a]) => [
|
|
65
62
|
t,
|
|
66
|
-
a && a.ok === !1 ? new
|
|
63
|
+
a && a.ok === !1 ? new Z(a.errors) : void 0
|
|
67
64
|
]
|
|
68
65
|
);
|
|
69
66
|
return Object.fromEntries(e);
|
|
@@ -72,17 +69,17 @@ function de(r, u, f) {
|
|
|
72
69
|
error: "",
|
|
73
70
|
model: {
|
|
74
71
|
data: h(N(o.value.blockStorage)),
|
|
75
|
-
outputs:
|
|
76
|
-
outputErrors:
|
|
72
|
+
outputs: U,
|
|
73
|
+
outputErrors: $
|
|
77
74
|
}
|
|
78
|
-
}), { ignoreUpdates: j } =
|
|
75
|
+
}), { ignoreUpdates: j } = W(
|
|
79
76
|
() => d.model,
|
|
80
77
|
(e) => {
|
|
81
78
|
const t = h(e);
|
|
82
|
-
n("setDataQueue appModel.model, data", t.data),
|
|
79
|
+
n("setDataQueue appModel.model, data", t.data), w.run(() => A(t.data).then(p));
|
|
83
80
|
},
|
|
84
81
|
{ deep: !0 }
|
|
85
|
-
),
|
|
82
|
+
), z = (e) => {
|
|
86
83
|
n("updateAppModel", e), d.model.data = h(e.data);
|
|
87
84
|
};
|
|
88
85
|
(async () => {
|
|
@@ -100,7 +97,7 @@ function de(r, u, f) {
|
|
|
100
97
|
}
|
|
101
98
|
const l = ((e = s.author) == null ? void 0 : e.authorId) !== ((t = a.author) == null ? void 0 : t.authorId);
|
|
102
99
|
l || s.isExternalSnapshot ? (n("got external changes, applying them to the snapshot", a.value), j(() => {
|
|
103
|
-
o.value = V(o.value, a.value, !1, !1).newDocument,
|
|
100
|
+
o.value = V(o.value, a.value, !1, !1).newDocument, z({ data: N(o.value.blockStorage) });
|
|
104
101
|
for (const i of Object.keys(c))
|
|
105
102
|
c[i] = E(i);
|
|
106
103
|
s.isExternalSnapshot = l;
|
|
@@ -111,7 +108,7 @@ function de(r, u, f) {
|
|
|
111
108
|
G(a) ? (n("patches loop aborted"), m.value = !0) : (M("error in patches loop", a), await new Promise((l) => setTimeout(l, 1e3)));
|
|
112
109
|
}
|
|
113
110
|
})();
|
|
114
|
-
const x = () => h(d.model.data), O = () => h(o.value.navigationState),
|
|
111
|
+
const x = () => h(d.model.data), O = () => h(o.value.navigationState), H = {
|
|
115
112
|
cloneData: x,
|
|
116
113
|
cloneNavigationState: O,
|
|
117
114
|
/**
|
|
@@ -123,7 +120,7 @@ function de(r, u, f) {
|
|
|
123
120
|
*/
|
|
124
121
|
updateData(e) {
|
|
125
122
|
const t = e(x());
|
|
126
|
-
return n("updateData", t), d.model.data = t,
|
|
123
|
+
return n("updateData", t), d.model.data = t, w.run(() => A(t).then(p));
|
|
127
124
|
},
|
|
128
125
|
/**
|
|
129
126
|
* Navigates to a specific href by updating the navigation state.
|
|
@@ -133,40 +130,40 @@ function de(r, u, f) {
|
|
|
133
130
|
*/
|
|
134
131
|
navigateTo(e) {
|
|
135
132
|
const t = O();
|
|
136
|
-
return t.href = e,
|
|
133
|
+
return t.href = e, I.run(() => C(t).then(p));
|
|
137
134
|
},
|
|
138
135
|
async allSettled() {
|
|
139
|
-
await
|
|
136
|
+
await B(0);
|
|
140
137
|
const e = [
|
|
141
|
-
|
|
142
|
-
...Array.from(
|
|
138
|
+
w.allSettled(),
|
|
139
|
+
...Array.from(S.values()).map((t) => t.allSettled())
|
|
143
140
|
];
|
|
144
141
|
await Promise.all(e);
|
|
145
142
|
}
|
|
146
|
-
},
|
|
143
|
+
}, J = {
|
|
147
144
|
pluginDataMap: c,
|
|
148
145
|
setPluginData(e, t) {
|
|
149
|
-
return c[e] = t, n("setPluginData", e, t),
|
|
150
|
-
() =>
|
|
146
|
+
return c[e] = t, n("setPluginData", e, t), q(e).run(
|
|
147
|
+
() => k(e, t).then(p)
|
|
151
148
|
);
|
|
152
149
|
},
|
|
153
150
|
initPluginDataSlot(e) {
|
|
154
151
|
e in c || (c[e] = E(e));
|
|
155
152
|
}
|
|
156
|
-
},
|
|
153
|
+
}, L = {
|
|
157
154
|
closedRef: m,
|
|
158
155
|
snapshot: o,
|
|
159
|
-
queryParams: g(() =>
|
|
156
|
+
queryParams: g(() => X(o.value.navigationState.href)),
|
|
160
157
|
href: g(() => o.value.navigationState.href),
|
|
161
158
|
hasErrors: g(
|
|
162
159
|
() => Object.values(o.value.outputs).some((e) => !(e != null && e.ok))
|
|
163
160
|
)
|
|
164
|
-
}, Q = Object.assign(y(Object.assign(d,
|
|
165
|
-
return f.debug && (globalThis.__block_app__ = Q), { app: Q, pluginAccess:
|
|
161
|
+
}, Q = Object.assign(y(Object.assign(d, L)), H);
|
|
162
|
+
return f.debug && (globalThis.__block_app__ = Q), { app: Q, pluginAccess: J };
|
|
166
163
|
}
|
|
167
164
|
export {
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
pe as createAppV3,
|
|
166
|
+
ee as createNextAuthorMarker,
|
|
170
167
|
_ as patchPoolingDelay
|
|
171
168
|
};
|
|
172
169
|
//# sourceMappingURL=createAppV3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAppV3.js","sources":["../../src/internal/createAppV3.ts"],"sourcesContent":["import { deepClone, delay, uniqueId } from \"@milaboratories/helpers\";\nimport type { Mutable } from \"@milaboratories/helpers\";\nimport type {\n NavigationState,\n BlockOutputsBase,\n BlockStateV3,\n PlatformaV3,\n ValueWithUTag,\n AuthorMarker,\n PlatformaExtended,\n} from \"@platforma-sdk/model\";\nimport {\n hasAbortError,\n unwrapResult,\n deriveDataFromStorage,\n getPluginData,\n normalizeBlockStorage,\n} from \"@platforma-sdk/model\";\nimport type { Ref } from \"vue\";\nimport { reactive, computed, ref } from \"vue\";\nimport type { OutputValues, OutputErrors, AppSettings } from \"../types\";\nimport { parseQuery } from \"../urls\";\nimport { ensureOutputHasStableFlag, MultiError } from \"../utils\";\nimport { applyPatch } from \"fast-json-patch\";\nimport { UpdateSerializer } from \"./UpdateSerializer\";\nimport { watchIgnorable } from \"@vueuse/core\";\n\nexport const patchPoolingDelay = 150;\n\n/** Internal interface for plugin data access — injected separately from the app. */\nexport interface PluginDataAccess {\n readonly pluginDataMap: Record<string, unknown>;\n setPluginData(pluginId: string, value: unknown): Promise<boolean>;\n initPluginDataSlot(pluginId: string): void;\n}\n\nexport const createNextAuthorMarker = (marker: AuthorMarker | undefined): AuthorMarker => ({\n authorId: marker?.authorId ?? uniqueId(),\n localVersion: (marker?.localVersion ?? 0) + 1,\n});\n\nconst stringifyForDebug = (v: unknown) => {\n try {\n return JSON.stringify(v, null, 2);\n } catch (err) {\n return err instanceof Error ? err.message : String(err);\n }\n};\n\n/**\n * Creates an application instance with reactive state management, outputs, and methods for state updates and navigation.\n *\n * @template Args - The type of arguments used in the application.\n * @template Outputs - The type of block outputs extending `BlockOutputsBase`.\n * @template Data - The type of the block data.\n * @template Href - The type of navigation href, defaulting to a string starting with `/`.\n *\n * @param state - Initial state of the application, including args, outputs, UI state, and navigation state.\n * @param platforma - A platform interface for interacting with block states.\n * @param settings - Application settings, such as debug flags.\n *\n * @returns A reactive application object with methods, getters, and state.\n */\nexport function createAppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n>(\n state: ValueWithUTag<BlockStateV3<Data, Outputs, Href>>,\n platforma: PlatformaExtended<PlatformaV3<Data, Args, Outputs, Href>>,\n settings: AppSettings,\n) {\n const debug = (msg: string, ...rest: unknown[]) => {\n if (settings.debug) {\n console.log(\n `%c>>> %c${msg}`,\n \"color: orange; font-weight: bold\",\n \"color: orange\",\n ...rest.map((r) => stringifyForDebug(r)),\n );\n }\n };\n\n const error = (msg: string, ...rest: unknown[]) => {\n console.error(\n `%c>>> %c${msg}`,\n \"color: red; font-weight: bold\",\n \"color: red\",\n ...rest.map((r) => stringifyForDebug(r)),\n );\n };\n\n const data = {\n isExternalSnapshot: false,\n author: {\n authorId: uniqueId(),\n localVersion: 0,\n },\n };\n\n const nextAuthorMarker = () => {\n data.author = createNextAuthorMarker(data.author);\n debug(\"nextAuthorMarker\", data.author);\n return data.author;\n };\n\n const closedRef = ref(false);\n\n const uTagRef = ref(state.uTag);\n\n const debounceSpan = settings.debounceSpan ?? 200;\n\n const setDataQueue = new UpdateSerializer({ debounceSpan });\n const pluginDataQueues = new Map<string, UpdateSerializer>();\n const getPluginDataQueue = (pluginId: string): UpdateSerializer => {\n let queue = pluginDataQueues.get(pluginId);\n if (!queue) {\n queue = new UpdateSerializer({ debounceSpan });\n pluginDataQueues.set(pluginId, queue);\n }\n return queue;\n };\n const setNavigationStateQueue = new UpdateSerializer({ debounceSpan });\n\n /** Reactive map of plugin data keyed by pluginId. Optimistic state for plugin components. */\n const pluginDataMap = reactive<Record<string, unknown>>({});\n /**\n * Reactive snapshot of the application state, including args, outputs, UI state, and navigation state.\n */\n const snapshot = ref<{\n outputs: Partial<Outputs>;\n blockStorage: unknown;\n navigationState: NavigationState<Href>;\n }>(state.value) as Ref<{\n outputs: Partial<Outputs>;\n blockStorage: unknown;\n navigationState: NavigationState<Href>;\n }>;\n\n const updateData = async (value: Data) => {\n return platforma.mutateStorage({ operation: \"update-block-data\", value }, nextAuthorMarker());\n };\n\n const updatePluginData = async (pluginId: string, value: unknown) => {\n return platforma.mutateStorage(\n { operation: \"update-plugin-data\", pluginId, value },\n nextAuthorMarker(),\n );\n };\n\n /** Derives plugin data for a given pluginId from the current snapshot. */\n const derivePluginDataFromSnapshot = (pluginId: string): unknown => {\n const storage = normalizeBlockStorage(snapshot.value.blockStorage);\n return getPluginData(storage, pluginId);\n };\n\n const setNavigationState = async (state: NavigationState<Href>) => {\n return platforma.setNavigationState(state);\n };\n\n const outputs = computed<OutputValues<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(\n ([k, outputWithStatus]) =>\n platforma.blockModelInfo.outputs[k]?.withStatus\n ? [k, ensureOutputHasStableFlag(outputWithStatus)]\n : [\n k,\n outputWithStatus.ok && outputWithStatus.value !== undefined\n ? outputWithStatus.value\n : undefined,\n ],\n );\n return Object.fromEntries(entries);\n });\n\n const outputErrors = computed<OutputErrors<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(\n ([k, vOrErr]) => [\n k,\n vOrErr && vOrErr.ok === false ? new MultiError(vOrErr.errors) : undefined,\n ],\n );\n return Object.fromEntries(entries);\n });\n\n const appModel = reactive({\n apiVersion: 3,\n error: \"\",\n model: {\n data: deepClone(deriveDataFromStorage<Data>(snapshot.value.blockStorage)) as Data,\n outputs,\n outputErrors,\n },\n }) as {\n error: string;\n model: {\n data: Data;\n outputs: OutputValues<Outputs>;\n outputErrors: OutputErrors<Outputs>;\n };\n };\n\n const { ignoreUpdates } = watchIgnorable(\n () => appModel.model,\n (_newData) => {\n const newData = deepClone(_newData);\n debug(\"setDataQueue appModel.model, data\", newData.data);\n setDataQueue.run(() => updateData(newData.data).then(unwrapResult));\n },\n { deep: true },\n );\n\n const updateAppModel = (newData: { data: Data }) => {\n debug(\"updateAppModel\", newData);\n appModel.model.data = deepClone(newData.data) as Data;\n };\n\n (async () => {\n window.addEventListener(\"beforeunload\", () => {\n closedRef.value = true;\n platforma\n .dispose()\n .then(unwrapResult)\n .catch((err) => {\n error(\"error in dispose\", err);\n });\n });\n\n while (!closedRef.value) {\n try {\n const patches = await platforma.getPatches(uTagRef.value).then(unwrapResult);\n\n debug(\"patches.length\", patches.value.length);\n debug(\"uTagRef.value\", uTagRef.value);\n debug(\"patches.uTag\", patches.uTag);\n debug(\"patches.author\", patches.author);\n debug(\"data.author\", data.author);\n\n uTagRef.value = patches.uTag;\n\n if (patches.value.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n continue;\n }\n\n const isAuthorChanged = data.author?.authorId !== patches.author?.authorId;\n\n // Immutable behavior, apply external changes to the snapshot\n if (isAuthorChanged || data.isExternalSnapshot) {\n debug(\"got external changes, applying them to the snapshot\", patches.value);\n ignoreUpdates(() => {\n snapshot.value = applyPatch(snapshot.value, patches.value, false, false).newDocument;\n updateAppModel({ data: deriveDataFromStorage<Data>(snapshot.value.blockStorage) });\n // Reconcile plugin data from external source\n for (const pluginId of Object.keys(pluginDataMap)) {\n pluginDataMap[pluginId] = derivePluginDataFromSnapshot(pluginId);\n }\n data.isExternalSnapshot = isAuthorChanged;\n });\n } else {\n // Mutable behavior\n debug(\"outputs changed\", patches.value);\n ignoreUpdates(() => {\n snapshot.value = applyPatch(snapshot.value, patches.value).newDocument;\n });\n }\n\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n } catch (err) {\n if (hasAbortError(err)) {\n debug(\"patches loop aborted\");\n closedRef.value = true;\n } else {\n error(\"error in patches loop\", err);\n await new Promise((resolve) => setTimeout(resolve, 1000));\n }\n }\n }\n })();\n\n const cloneData = () => deepClone(appModel.model.data) as Data;\n const cloneNavigationState = () =>\n deepClone(snapshot.value.navigationState) as Mutable<NavigationState<Href>>;\n\n const methods = {\n cloneData,\n cloneNavigationState,\n /**\n * Updates the UI state by applying a callback.\n *\n * @param cb - Callback to modify the current UI state.\n * @returns A promise resolving after the update is applied.\n * @todo Make it mutable since there is already an initial one\n */\n updateData(cb: (data: Data) => Data): Promise<boolean> {\n const newData = cb(cloneData());\n debug(\"updateData\", newData);\n appModel.model.data = newData;\n return setDataQueue.run(() => updateData(newData).then(unwrapResult));\n },\n /**\n * Navigates to a specific href by updating the navigation state.\n *\n * @param href - The target href to navigate to.\n * @returns A promise resolving after the navigation state is updated.\n */\n navigateTo(href: Href) {\n const newState = cloneNavigationState();\n newState.href = href;\n return setNavigationStateQueue.run(() => setNavigationState(newState).then(unwrapResult));\n },\n async allSettled() {\n await delay(0);\n const allQueues = [\n setDataQueue.allSettled(),\n ...Array.from(pluginDataQueues.values()).map((q) => q.allSettled()),\n ];\n await Promise.all(allQueues);\n },\n };\n\n /** Plugin internals — provided via separate injection key, not exposed on useApp(). */\n const pluginAccess: PluginDataAccess = {\n pluginDataMap,\n setPluginData(pluginId: string, value: unknown): Promise<boolean> {\n pluginDataMap[pluginId] = value;\n debug(\"setPluginData\", pluginId, value);\n return getPluginDataQueue(pluginId).run(() =>\n updatePluginData(pluginId, value).then(unwrapResult),\n );\n },\n initPluginDataSlot(pluginId: string): void {\n if (!(pluginId in pluginDataMap)) {\n pluginDataMap[pluginId] = derivePluginDataFromSnapshot(pluginId);\n }\n },\n };\n\n const getters = {\n closedRef,\n snapshot,\n queryParams: computed(() => parseQuery<Href>(snapshot.value.navigationState.href as Href)),\n href: computed(() => snapshot.value.navigationState.href),\n hasErrors: computed(() =>\n Object.values(snapshot.value.outputs as Partial<Readonly<Outputs>>).some((v) => !v?.ok),\n ),\n };\n\n const app = Object.assign(reactive(Object.assign(appModel, getters)), methods);\n\n if (settings.debug) {\n // @ts-expect-error (to inspect in console in debug mode)\n globalThis.__block_app__ = app;\n }\n\n return { app, pluginAccess };\n}\n\nexport type BaseAppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n> = ReturnType<typeof createAppV3<Data, Args, Outputs, Href>>[\"app\"];\n"],"names":["patchPoolingDelay","createNextAuthorMarker","marker","uniqueId","stringifyForDebug","v","err","createAppV3","state","platforma","settings","debug","msg","rest","r","error","data","nextAuthorMarker","closedRef","ref","uTagRef","debounceSpan","setDataQueue","UpdateSerializer","pluginDataQueues","getPluginDataQueue","pluginId","queue","setNavigationStateQueue","pluginDataMap","reactive","snapshot","updateData","value","updatePluginData","derivePluginDataFromSnapshot","storage","normalizeBlockStorage","getPluginData","setNavigationState","outputs","computed","entries","k","outputWithStatus","_a","ensureOutputHasStableFlag","outputErrors","vOrErr","MultiError","appModel","deepClone","deriveDataFromStorage","ignoreUpdates","watchIgnorable","_newData","newData","unwrapResult","updateAppModel","patches","resolve","isAuthorChanged","_b","applyPatch","hasAbortError","cloneData","cloneNavigationState","methods","cb","href","newState","delay","allQueues","q","pluginAccess","getters","parseQuery","app"],"mappings":";;;;;;;;;;AA2BO,MAAMA,IAAoB,KASpBC,KAAyB,CAACC,OAAoD;AAAA,EACzF,WAAUA,KAAA,gBAAAA,EAAQ,aAAYC,EAAA;AAAA,EAC9B,gBAAeD,KAAA,gBAAAA,EAAQ,iBAAgB,KAAK;AAC9C,IAEME,IAAoB,CAACC,MAAe;AACxC,MAAI;AACF,WAAO,KAAK,UAAUA,GAAG,MAAM,CAAC;AAAA,EAClC,SAASC,GAAK;AACZ,WAAOA,aAAe,QAAQA,EAAI,UAAU,OAAOA,CAAG;AAAA,EACxD;AACF;AAgBO,SAASC,GAMdC,GACAC,GACAC,GACA;AACA,QAAMC,IAAQ,CAACC,MAAgBC,MAAoB;AACjD,IAAIH,EAAS,SACX,QAAQ;AAAA,MACN,WAAWE,CAAG;AAAA,MACd;AAAA,MACA;AAAA,MACA,GAAGC,EAAK,IAAI,CAACC,MAAMV,EAAkBU,CAAC,CAAC;AAAA,IAAA;AAAA,EAG7C,GAEMC,IAAQ,CAACH,MAAgBC,MAAoB;AACjD,YAAQ;AAAA,MACN,WAAWD,CAAG;AAAA,MACd;AAAA,MACA;AAAA,MACA,GAAGC,EAAK,IAAI,CAACC,MAAMV,EAAkBU,CAAC,CAAC;AAAA,IAAA;AAAA,EAE3C,GAEME,IAAO;AAAA,IACX,oBAAoB;AAAA,IACpB,QAAQ;AAAA,MACN,UAAUb,EAAA;AAAA,MACV,cAAc;AAAA,IAAA;AAAA,EAChB,GAGIc,IAAmB,OACvBD,EAAK,SAASf,GAAuBe,EAAK,MAAM,GAChDL,EAAM,oBAAoBK,EAA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AAYG,MAChBA,EAAcH,CAAQ,IAAIS,EAA6BT,CAAQ;AAAA,IAEnE;AAAA,EAAA,GAGIiD,IAAU;AAAA,IACd,WAAAzD;AAAA,IACA,UAAAa;AAAA,IACA,aAAaU,EAAS,MAAMmC,EAAiB7C,EAAS,MAAM,gBAAgB,IAAY,CAAC;AAAA,IACzF,MAAMU,EAAS,MAAMV,EAAS,MAAM,gBAAgB,IAAI;AAAA,IACxD,WAAWU;AAAA,MAAS,MAClB,OAAO,OAAOV,EAAS,MAAM,OAAqC,EAAE,KAAK,CAAC1B,MAAM,EAACA,KAAA,QAAAA,EAAG,GAAE;AAAA,IAAA;AAAA,EACxF,GAGIwE,IAAM,OAAO,OAAO/C,EAAS,OAAO,OAAOoB,GAAUyB,CAAO,CAAC,GAAGR,CAAO;AAE7E,SAAIzD,EAAS,UAEX,WAAW,gBAAgBmE,IAGtB,EAAE,KAAAA,GAAK,cAAAH,EAAA;AAChB;"}
|
|
1
|
+
{"version":3,"file":"createAppV3.js","sources":["../../src/internal/createAppV3.ts"],"sourcesContent":["import { deepClone, delay, uniqueId } from \"@milaboratories/helpers\";\nimport type { Mutable } from \"@milaboratories/helpers\";\nimport type {\n NavigationState,\n BlockOutputsBase,\n BlockStateV3,\n PlatformaV3,\n ValueWithUTag,\n AuthorMarker,\n PlatformaExtended,\n} from \"@platforma-sdk/model\";\nimport {\n hasAbortError,\n unwrapResult,\n deriveDataFromStorage,\n getPluginData,\n} from \"@platforma-sdk/model\";\nimport type { Ref } from \"vue\";\nimport { reactive, computed, ref } from \"vue\";\nimport type { OutputValues, OutputErrors, AppSettings } from \"../types\";\nimport { parseQuery } from \"../urls\";\nimport { ensureOutputHasStableFlag, MultiError } from \"../utils\";\nimport { applyPatch } from \"fast-json-patch\";\nimport { UpdateSerializer } from \"./UpdateSerializer\";\nimport { watchIgnorable } from \"@vueuse/core\";\n\nexport const patchPoolingDelay = 150;\n\n/** Internal interface for plugin data access — injected separately from the app. */\nexport interface PluginDataAccess {\n readonly pluginDataMap: Record<string, unknown>;\n setPluginData(pluginId: string, value: unknown): Promise<boolean>;\n initPluginDataSlot(pluginId: string): void;\n}\n\nexport const createNextAuthorMarker = (marker: AuthorMarker | undefined): AuthorMarker => ({\n authorId: marker?.authorId ?? uniqueId(),\n localVersion: (marker?.localVersion ?? 0) + 1,\n});\n\nconst stringifyForDebug = (v: unknown) => {\n try {\n return JSON.stringify(v, null, 2);\n } catch (err) {\n return err instanceof Error ? err.message : String(err);\n }\n};\n\n/**\n * Creates an application instance with reactive state management, outputs, and methods for state updates and navigation.\n *\n * @template Args - The type of arguments used in the application.\n * @template Outputs - The type of block outputs extending `BlockOutputsBase`.\n * @template Data - The type of the block data.\n * @template Href - The type of navigation href, defaulting to a string starting with `/`.\n *\n * @param state - Initial state of the application, including args, outputs, UI state, and navigation state.\n * @param platforma - A platform interface for interacting with block states.\n * @param settings - Application settings, such as debug flags.\n *\n * @returns A reactive application object with methods, getters, and state.\n */\nexport function createAppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n>(\n state: ValueWithUTag<BlockStateV3<Data, Outputs, Href>>,\n platforma: PlatformaExtended<PlatformaV3<Data, Args, Outputs, Href>>,\n settings: AppSettings,\n) {\n const debug = (msg: string, ...rest: unknown[]) => {\n if (settings.debug) {\n console.log(\n `%c>>> %c${msg}`,\n \"color: orange; font-weight: bold\",\n \"color: orange\",\n ...rest.map((r) => stringifyForDebug(r)),\n );\n }\n };\n\n const error = (msg: string, ...rest: unknown[]) => {\n console.error(\n `%c>>> %c${msg}`,\n \"color: red; font-weight: bold\",\n \"color: red\",\n ...rest.map((r) => stringifyForDebug(r)),\n );\n };\n\n const data = {\n isExternalSnapshot: false,\n author: {\n authorId: uniqueId(),\n localVersion: 0,\n },\n };\n\n const nextAuthorMarker = () => {\n data.author = createNextAuthorMarker(data.author);\n debug(\"nextAuthorMarker\", data.author);\n return data.author;\n };\n\n const closedRef = ref(false);\n\n const uTagRef = ref(state.uTag);\n\n const debounceSpan = settings.debounceSpan ?? 200;\n\n const setDataQueue = new UpdateSerializer({ debounceSpan });\n const pluginDataQueues = new Map<string, UpdateSerializer>();\n const getPluginDataQueue = (pluginId: string): UpdateSerializer => {\n let queue = pluginDataQueues.get(pluginId);\n if (!queue) {\n queue = new UpdateSerializer({ debounceSpan });\n pluginDataQueues.set(pluginId, queue);\n }\n return queue;\n };\n const setNavigationStateQueue = new UpdateSerializer({ debounceSpan });\n\n /** Reactive map of plugin data keyed by pluginId. Optimistic state for plugin components. */\n const pluginDataMap = reactive<Record<string, unknown>>({});\n /**\n * Reactive snapshot of the application state, including args, outputs, UI state, and navigation state.\n */\n const snapshot = ref<{\n outputs: Partial<Outputs>;\n blockStorage: unknown;\n navigationState: NavigationState<Href>;\n }>(state.value) as Ref<{\n outputs: Partial<Outputs>;\n blockStorage: unknown;\n navigationState: NavigationState<Href>;\n }>;\n\n const updateData = async (value: Data) => {\n return platforma.mutateStorage({ operation: \"update-block-data\", value }, nextAuthorMarker());\n };\n\n const updatePluginData = async (pluginId: string, value: unknown) => {\n return platforma.mutateStorage(\n { operation: \"update-plugin-data\", pluginId, value },\n nextAuthorMarker(),\n );\n };\n\n /** Derives plugin data for a given pluginId from the current snapshot. */\n const derivePluginDataFromSnapshot = (pluginId: string): unknown => {\n return getPluginData(snapshot.value.blockStorage, pluginId);\n };\n\n const setNavigationState = async (state: NavigationState<Href>) => {\n return platforma.setNavigationState(state);\n };\n\n const outputs = computed<OutputValues<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(\n ([k, outputWithStatus]) =>\n platforma.blockModelInfo.outputs[k]?.withStatus\n ? [k, ensureOutputHasStableFlag(outputWithStatus)]\n : [\n k,\n outputWithStatus.ok && outputWithStatus.value !== undefined\n ? outputWithStatus.value\n : undefined,\n ],\n );\n return Object.fromEntries(entries);\n });\n\n const outputErrors = computed<OutputErrors<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(\n ([k, vOrErr]) => [\n k,\n vOrErr && vOrErr.ok === false ? new MultiError(vOrErr.errors) : undefined,\n ],\n );\n return Object.fromEntries(entries);\n });\n\n const appModel = reactive({\n apiVersion: 3,\n error: \"\",\n model: {\n data: deepClone(deriveDataFromStorage<Data>(snapshot.value.blockStorage)) as Data,\n outputs,\n outputErrors,\n },\n }) as {\n error: string;\n model: {\n data: Data;\n outputs: OutputValues<Outputs>;\n outputErrors: OutputErrors<Outputs>;\n };\n };\n\n const { ignoreUpdates } = watchIgnorable(\n () => appModel.model,\n (_newData) => {\n const newData = deepClone(_newData);\n debug(\"setDataQueue appModel.model, data\", newData.data);\n setDataQueue.run(() => updateData(newData.data).then(unwrapResult));\n },\n { deep: true },\n );\n\n const updateAppModel = (newData: { data: Data }) => {\n debug(\"updateAppModel\", newData);\n appModel.model.data = deepClone(newData.data) as Data;\n };\n\n (async () => {\n window.addEventListener(\"beforeunload\", () => {\n closedRef.value = true;\n platforma\n .dispose()\n .then(unwrapResult)\n .catch((err) => {\n error(\"error in dispose\", err);\n });\n });\n\n while (!closedRef.value) {\n try {\n const patches = await platforma.getPatches(uTagRef.value).then(unwrapResult);\n\n debug(\"patches.length\", patches.value.length);\n debug(\"uTagRef.value\", uTagRef.value);\n debug(\"patches.uTag\", patches.uTag);\n debug(\"patches.author\", patches.author);\n debug(\"data.author\", data.author);\n\n uTagRef.value = patches.uTag;\n\n if (patches.value.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n continue;\n }\n\n const isAuthorChanged = data.author?.authorId !== patches.author?.authorId;\n\n // Immutable behavior, apply external changes to the snapshot\n if (isAuthorChanged || data.isExternalSnapshot) {\n debug(\"got external changes, applying them to the snapshot\", patches.value);\n ignoreUpdates(() => {\n snapshot.value = applyPatch(snapshot.value, patches.value, false, false).newDocument;\n updateAppModel({ data: deriveDataFromStorage<Data>(snapshot.value.blockStorage) });\n // Reconcile plugin data from external source\n for (const pluginId of Object.keys(pluginDataMap)) {\n pluginDataMap[pluginId] = derivePluginDataFromSnapshot(pluginId);\n }\n data.isExternalSnapshot = isAuthorChanged;\n });\n } else {\n // Mutable behavior\n debug(\"outputs changed\", patches.value);\n ignoreUpdates(() => {\n snapshot.value = applyPatch(snapshot.value, patches.value).newDocument;\n });\n }\n\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n } catch (err) {\n if (hasAbortError(err)) {\n debug(\"patches loop aborted\");\n closedRef.value = true;\n } else {\n error(\"error in patches loop\", err);\n await new Promise((resolve) => setTimeout(resolve, 1000));\n }\n }\n }\n })();\n\n const cloneData = () => deepClone(appModel.model.data) as Data;\n const cloneNavigationState = () =>\n deepClone(snapshot.value.navigationState) as Mutable<NavigationState<Href>>;\n\n const methods = {\n cloneData,\n cloneNavigationState,\n /**\n * Updates the UI state by applying a callback.\n *\n * @param cb - Callback to modify the current UI state.\n * @returns A promise resolving after the update is applied.\n * @todo Make it mutable since there is already an initial one\n */\n updateData(cb: (data: Data) => Data): Promise<boolean> {\n const newData = cb(cloneData());\n debug(\"updateData\", newData);\n appModel.model.data = newData;\n return setDataQueue.run(() => updateData(newData).then(unwrapResult));\n },\n /**\n * Navigates to a specific href by updating the navigation state.\n *\n * @param href - The target href to navigate to.\n * @returns A promise resolving after the navigation state is updated.\n */\n navigateTo(href: Href) {\n const newState = cloneNavigationState();\n newState.href = href;\n return setNavigationStateQueue.run(() => setNavigationState(newState).then(unwrapResult));\n },\n async allSettled() {\n await delay(0);\n const allQueues = [\n setDataQueue.allSettled(),\n ...Array.from(pluginDataQueues.values()).map((q) => q.allSettled()),\n ];\n await Promise.all(allQueues);\n },\n };\n\n /** Plugin internals — provided via separate injection key, not exposed on useApp(). */\n const pluginAccess: PluginDataAccess = {\n pluginDataMap,\n setPluginData(pluginId: string, value: unknown): Promise<boolean> {\n pluginDataMap[pluginId] = value;\n debug(\"setPluginData\", pluginId, value);\n return getPluginDataQueue(pluginId).run(() =>\n updatePluginData(pluginId, value).then(unwrapResult),\n );\n },\n initPluginDataSlot(pluginId: string): void {\n if (!(pluginId in pluginDataMap)) {\n pluginDataMap[pluginId] = derivePluginDataFromSnapshot(pluginId);\n }\n },\n };\n\n const getters = {\n closedRef,\n snapshot,\n queryParams: computed(() => parseQuery<Href>(snapshot.value.navigationState.href as Href)),\n href: computed(() => snapshot.value.navigationState.href),\n hasErrors: computed(() =>\n Object.values(snapshot.value.outputs as Partial<Readonly<Outputs>>).some((v) => !v?.ok),\n ),\n };\n\n const app = Object.assign(reactive(Object.assign(appModel, getters)), methods);\n\n if (settings.debug) {\n // @ts-expect-error (to inspect in console in debug mode)\n globalThis.__block_app__ = app;\n }\n\n return { app, pluginAccess };\n}\n\nexport type BaseAppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n> = ReturnType<typeof createAppV3<Data, Args, Outputs, Href>>[\"app\"];\n"],"names":["patchPoolingDelay","createNextAuthorMarker","marker","uniqueId","stringifyForDebug","v","err","createAppV3","state","platforma","settings","debug","msg","rest","r","error","data","nextAuthorMarker","closedRef","ref","uTagRef","debounceSpan","setDataQueue","UpdateSerializer","pluginDataQueues","getPluginDataQueue","pluginId","queue","setNavigationStateQueue","pluginDataMap","reactive","snapshot","updateData","value","updatePluginData","derivePluginDataFromSnapshot","getPluginData","setNavigationState","outputs","computed","entries","k","outputWithStatus","_a","ensureOutputHasStableFlag","outputErrors","vOrErr","MultiError","appModel","deepClone","deriveDataFromStorage","ignoreUpdates","watchIgnorable","_newData","newData","unwrapResult","updateAppModel","patches","resolve","isAuthorChanged","_b","applyPatch","hasAbortError","cloneData","cloneNavigationState","methods","cb","href","newState","delay","allQueues","q","pluginAccess","getters","parseQuery","app"],"mappings":";;;;;;;;;;AA0BO,MAAMA,IAAoB,KASpBC,KAAyB,CAACC,OAAoD;AAAA,EACzF,WAAUA,KAAA,gBAAAA,EAAQ,aA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xF,GAGIsE,IAAM,OAAO,OAAO7C,EAAS,OAAO,OAAOkB,GAAUyB,CAAO,CAAC,GAAGR,CAAO;AAE7E,SAAIvD,EAAS,UAEX,WAAW,gBAAgBiE,IAGtB,EAAE,KAAAA,GAAK,cAAAH,EAAA;AAChB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/ui-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"lru-cache": "^11.2.2",
|
|
27
27
|
"vue": "^3.5.24",
|
|
28
28
|
"zod": "~3.23.8",
|
|
29
|
-
"@milaboratories/uikit": "2.10.
|
|
30
|
-
"@platforma-sdk/model": "1.
|
|
29
|
+
"@milaboratories/uikit": "2.10.30",
|
|
30
|
+
"@platforma-sdk/model": "1.57.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@faker-js/faker": "^9.2.0",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"typescript": "~5.6.3",
|
|
43
43
|
"vite": "^6.4.1",
|
|
44
44
|
"vitest": "^4.0.16",
|
|
45
|
-
"@milaboratories/ts-builder": "1.2.10",
|
|
46
|
-
"@milaboratories/helpers": "1.13.5",
|
|
47
45
|
"@milaboratories/build-configs": "1.4.4",
|
|
46
|
+
"@milaboratories/helpers": "1.13.5",
|
|
47
|
+
"@milaboratories/ts-builder": "1.2.10",
|
|
48
48
|
"@milaboratories/ts-configs": "1.2.1"
|
|
49
49
|
},
|
|
50
50
|
"styles": "dist/index.js",
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
unwrapResult,
|
|
15
15
|
deriveDataFromStorage,
|
|
16
16
|
getPluginData,
|
|
17
|
-
normalizeBlockStorage,
|
|
18
17
|
} from "@platforma-sdk/model";
|
|
19
18
|
import type { Ref } from "vue";
|
|
20
19
|
import { reactive, computed, ref } from "vue";
|
|
@@ -151,8 +150,7 @@ export function createAppV3<
|
|
|
151
150
|
|
|
152
151
|
/** Derives plugin data for a given pluginId from the current snapshot. */
|
|
153
152
|
const derivePluginDataFromSnapshot = (pluginId: string): unknown => {
|
|
154
|
-
|
|
155
|
-
return getPluginData(storage, pluginId);
|
|
153
|
+
return getPluginData(snapshot.value.blockStorage, pluginId);
|
|
156
154
|
};
|
|
157
155
|
|
|
158
156
|
const setNavigationState = async (state: NavigationState<Href>) => {
|