@platforma-sdk/ui-vue 1.63.1 → 1.63.8
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 +160 -162
- 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 +18 -0
- package/dist/AgGridVue/AgGridTheme.js +3 -1
- package/dist/AgGridVue/AgGridTheme.js.map +1 -1
- package/dist/AgGridVue/ag-override.js +2 -0
- package/dist/AgGridVue/ag-override.js.map +1 -1
- package/dist/AgGridVue/createAgGridColDef.js +2 -35
- package/dist/AgGridVue/createAgGridColDef.js.map +1 -1
- package/dist/AgGridVue/selection.js +2 -23
- package/dist/AgGridVue/selection.js.map +1 -1
- package/dist/AgGridVue/useAgGridOptions.js +2 -83
- package/dist/AgGridVue/useAgGridOptions.js.map +1 -1
- package/dist/_virtual/_plugin-vue_export-helper.js +2 -0
- package/dist/_virtual/_rolldown/runtime.js +2 -0
- package/dist/components/BlockLayout.js +1 -0
- package/dist/components/BlockLayout.style.js +1 -0
- package/dist/components/BlockLayout.vue2.js +2 -0
- package/dist/components/BlockLayout.vue2.js.map +1 -1
- package/dist/components/BlockLoader.js +2 -0
- package/dist/components/BlockLoader.vue2.js +2 -0
- package/dist/components/BlockLoader.vue2.js.map +1 -1
- package/dist/components/LoaderPage.js +2 -0
- package/dist/components/LoaderPage.js.map +1 -1
- package/dist/components/NotFound.js +2 -0
- package/dist/components/NotFound.vue2.js +2 -0
- package/dist/components/NotFound.vue2.js.map +1 -1
- package/dist/components/PlAdvancedFilter/FilterEditor.js +1 -0
- package/dist/components/PlAdvancedFilter/FilterEditor.style.js +1 -0
- package/dist/components/PlAdvancedFilter/FilterEditor.vue2.js +2 -0
- package/dist/components/PlAdvancedFilter/FilterEditor.vue2.js.map +1 -1
- package/dist/components/PlAdvancedFilter/OperandButton.js +1 -0
- package/dist/components/PlAdvancedFilter/OperandButton.style.js +1 -0
- package/dist/components/PlAdvancedFilter/OperandButton.vue2.js +2 -0
- package/dist/components/PlAdvancedFilter/OperandButton.vue2.js.map +1 -1
- package/dist/components/PlAdvancedFilter/PlAdvancedFilter.js +1 -0
- package/dist/components/PlAdvancedFilter/PlAdvancedFilter.style.js +1 -0
- package/dist/components/PlAdvancedFilter/PlAdvancedFilter.vue2.js +2 -0
- package/dist/components/PlAdvancedFilter/PlAdvancedFilter.vue2.js.map +1 -1
- package/dist/components/PlAdvancedFilter/constants.js +4 -4
- package/dist/components/PlAdvancedFilter/constants.js.map +1 -1
- package/dist/components/PlAdvancedFilter/index.js +3 -1
- package/dist/components/PlAdvancedFilter/index.js.map +1 -1
- package/dist/components/PlAdvancedFilter/utils.js +2 -0
- package/dist/components/PlAdvancedFilter/utils.js.map +1 -1
- package/dist/components/PlAgCellFile/PlAgCellFile.js +2 -0
- package/dist/components/PlAgCellFile/PlAgCellFile.vue2.js +2 -4
- package/dist/components/PlAgCellFile/PlAgCellFile.vue2.js.map +1 -1
- package/dist/components/PlAgCellProgress/PlAgCellProgress.js +2 -0
- package/dist/components/PlAgCellProgress/PlAgCellProgress.vue2.js +2 -0
- package/dist/components/PlAgCellProgress/PlAgCellProgress.vue2.js.map +1 -1
- package/dist/components/PlAgCellStatusTag/PlAgCellStatusTag.js +2 -0
- package/dist/components/PlAgCellStatusTag/PlAgCellStatusTag.vue2.js +2 -0
- package/dist/components/PlAgCellStatusTag/PlAgCellStatusTag.vue2.js.map +1 -1
- package/dist/components/PlAgChartHistogramCell/PlAgChartHistogramCell.js +2 -0
- package/dist/components/PlAgChartHistogramCell/PlAgChartHistogramCell.vue2.js +2 -0
- package/dist/components/PlAgChartHistogramCell/PlAgChartHistogramCell.vue2.js.map +1 -1
- package/dist/components/PlAgChartStackedBarCell/PlAgChartStackedBarCell.js +2 -0
- package/dist/components/PlAgChartStackedBarCell/PlAgChartStackedBarCell.vue2.js +2 -0
- package/dist/components/PlAgChartStackedBarCell/PlAgChartStackedBarCell.vue2.js.map +1 -1
- package/dist/components/PlAgColumnHeader/PlAgColumnHeader.js +2 -0
- package/dist/components/PlAgColumnHeader/PlAgColumnHeader.vue2.js +2 -0
- package/dist/components/PlAgColumnHeader/PlAgColumnHeader.vue2.js.map +1 -1
- package/dist/components/PlAgCsvExporter/PlAgCsvExporter.js +2 -0
- package/dist/components/PlAgCsvExporter/PlAgCsvExporter.vue2.js +2 -0
- package/dist/components/PlAgCsvExporter/PlAgCsvExporter.vue2.js.map +1 -1
- package/dist/components/PlAgCsvExporter/export-csv.js +2 -0
- package/dist/components/PlAgCsvExporter/export-csv.js.map +1 -1
- package/dist/components/PlAgDataTable/PlAgDataTableSheets.js +1 -0
- package/dist/components/PlAgDataTable/PlAgDataTableSheets.style.js +1 -0
- package/dist/components/PlAgDataTable/PlAgDataTableSheets.vue2.js +2 -0
- package/dist/components/PlAgDataTable/PlAgDataTableSheets.vue2.js.map +1 -1
- package/dist/components/PlAgDataTable/PlAgDataTableV2.js +1 -0
- package/dist/components/PlAgDataTable/PlAgDataTableV2.style.js +1 -0
- package/dist/components/PlAgDataTable/PlAgDataTableV2.vue2.js +2 -0
- package/dist/components/PlAgDataTable/PlAgDataTableV2.vue2.js.map +1 -1
- package/dist/components/PlAgDataTable/PlAgOverlayLoading.js +2 -0
- package/dist/components/PlAgDataTable/PlAgOverlayLoading.vue2.js +2 -0
- package/dist/components/PlAgDataTable/PlAgOverlayLoading.vue2.js.map +1 -1
- package/dist/components/PlAgDataTable/PlAgOverlayNoRows.js +2 -0
- package/dist/components/PlAgDataTable/PlAgOverlayNoRows.vue2.js +2 -0
- package/dist/components/PlAgDataTable/PlAgOverlayNoRows.vue2.js.map +1 -1
- package/dist/components/PlAgDataTable/PlAgRowCount.js +2 -0
- package/dist/components/PlAgDataTable/PlAgRowCount.vue2.js +2 -0
- package/dist/components/PlAgDataTable/PlAgRowCount.vue2.js.map +1 -1
- package/dist/components/PlAgDataTable/compositions/useFilterableColumns.js +2 -0
- package/dist/components/PlAgDataTable/compositions/useFilterableColumns.js.map +1 -1
- package/dist/components/PlAgDataTable/compositions/useGrid.js +2 -0
- package/dist/components/PlAgDataTable/compositions/useGrid.js.map +1 -1
- package/dist/components/PlAgDataTable/index.js +2 -0
- package/dist/components/PlAgDataTable/index.js.map +1 -1
- package/dist/components/PlAgDataTable/pl-ag-overlay-loading.module.js +1 -0
- package/dist/components/PlAgDataTable/sources/common.js +3 -1
- package/dist/components/PlAgDataTable/sources/common.js.map +1 -1
- package/dist/components/PlAgDataTable/sources/focus-row.js +2 -0
- package/dist/components/PlAgDataTable/sources/focus-row.js.map +1 -1
- package/dist/components/PlAgDataTable/sources/menu-items.js +2 -0
- package/dist/components/PlAgDataTable/sources/menu-items.js.map +1 -1
- package/dist/components/PlAgDataTable/sources/row-number.js +3 -2
- package/dist/components/PlAgDataTable/sources/row-number.js.map +1 -1
- package/dist/components/PlAgDataTable/sources/table-source-v2.js +2 -5
- package/dist/components/PlAgDataTable/sources/table-source-v2.js.map +1 -1
- package/dist/components/PlAgDataTable/sources/table-state-v2.js +2 -0
- package/dist/components/PlAgDataTable/sources/table-state-v2.js.map +1 -1
- package/dist/components/PlAgDataTable/sources/value-rendering.js +2 -0
- package/dist/components/PlAgDataTable/sources/value-rendering.js.map +1 -1
- package/dist/components/PlAgDataTable/types.js +2 -0
- package/dist/components/PlAgDataTable/types.js.map +1 -1
- package/dist/components/PlAgGridColumnManager/PlAgGridColumnManager.js +1 -0
- package/dist/components/PlAgGridColumnManager/PlAgGridColumnManager.style.js +1 -0
- package/dist/components/PlAgGridColumnManager/PlAgGridColumnManager.vue2.js +2 -0
- package/dist/components/PlAgGridColumnManager/PlAgGridColumnManager.vue2.js.map +1 -1
- package/dist/components/PlAgGridColumnManager/useFilteredItems.js +2 -0
- package/dist/components/PlAgGridColumnManager/useFilteredItems.js.map +1 -1
- package/dist/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.js +2 -0
- package/dist/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue2.js +2 -0
- package/dist/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue2.js.map +1 -1
- package/dist/components/PlAgRowNumCheckbox/pl-ag-row-num-checkbox.module.js +1 -0
- package/dist/components/PlAgRowNumHeader.js +2 -0
- package/dist/components/PlAgRowNumHeader.vue2.js +2 -0
- package/dist/components/PlAgRowNumHeader.vue2.js.map +1 -1
- package/dist/components/PlAgTextAndButtonCell/PlAgTextAndButtonCell.js +2 -0
- package/dist/components/PlAgTextAndButtonCell/PlAgTextAndButtonCell.vue2.js +2 -0
- package/dist/components/PlAgTextAndButtonCell/PlAgTextAndButtonCell.vue2.js.map +1 -1
- package/dist/components/PlAnnotations/components/AnnotationsSidebar.js +1 -0
- package/dist/components/PlAnnotations/components/AnnotationsSidebar.style.js +1 -0
- package/dist/components/PlAnnotations/components/AnnotationsSidebar.vue2.js +2 -0
- package/dist/components/PlAnnotations/components/AnnotationsSidebar.vue2.js.map +1 -1
- package/dist/components/PlAnnotations/components/FilterSidebar.js +1 -0
- package/dist/components/PlAnnotations/components/FilterSidebar.style.js +1 -0
- package/dist/components/PlAnnotations/components/FilterSidebar.vue2.js +2 -0
- package/dist/components/PlAnnotations/components/FilterSidebar.vue2.js.map +1 -1
- package/dist/components/PlAnnotations/components/PlAnnotations.js +1 -0
- package/dist/components/PlAnnotations/components/PlAnnotations.style.js +1 -0
- package/dist/components/PlAnnotations/components/PlAnnotations.vue2.js +2 -0
- package/dist/components/PlAnnotations/components/PlAnnotations.vue2.js.map +1 -1
- package/dist/components/PlAnnotations/components/PlAnnotationsModal.js +1 -0
- package/dist/components/PlAnnotations/components/PlAnnotationsModal.style.js +1 -0
- package/dist/components/PlAnnotations/components/PlAnnotationsModal.vue2.js +2 -0
- package/dist/components/PlAnnotations/components/PlAnnotationsModal.vue2.js.map +1 -1
- package/dist/components/PlAnnotations/components/style.module.js +1 -0
- package/dist/components/PlAnnotations/utils.js +2 -0
- package/dist/components/PlAnnotations/utils.js.map +1 -1
- package/dist/components/PlAppErrorNotificationAlert/PlAppErrorNotificationAlert.js +2 -0
- package/dist/components/PlAppErrorNotificationAlert/PlAppErrorNotificationAlert.vue2.js +2 -0
- package/dist/components/PlAppErrorNotificationAlert/PlAppErrorNotificationAlert.vue2.js.map +1 -1
- package/dist/components/PlBtnExportArchive/Item.js +1 -0
- package/dist/components/PlBtnExportArchive/Item.style.js +1 -0
- package/dist/components/PlBtnExportArchive/Item.vue2.js +2 -0
- package/dist/components/PlBtnExportArchive/Item.vue2.js.map +1 -1
- package/dist/components/PlBtnExportArchive/PlBtnExportArchive.js +1 -0
- package/dist/components/PlBtnExportArchive/PlBtnExportArchive.style.js +1 -0
- package/dist/components/PlBtnExportArchive/PlBtnExportArchive.vue2.js +2 -0
- package/dist/components/PlBtnExportArchive/PlBtnExportArchive.vue2.js.map +1 -1
- package/dist/components/PlBtnExportArchive/Summary.js +1 -0
- package/dist/components/PlBtnExportArchive/Summary.style.js +1 -0
- package/dist/components/PlBtnExportArchive/Summary.vue2.js +2 -0
- package/dist/components/PlBtnExportArchive/Summary.vue2.js.map +1 -1
- package/dist/components/PlTableFastSearch/PlTableFastSearch.js +2 -0
- package/dist/components/PlTableFastSearch/PlTableFastSearch.vue2.js +2 -0
- package/dist/components/PlTableFastSearch/PlTableFastSearch.vue2.js.map +1 -1
- package/dist/components/PlTableFilters/PlTableFiltersV2.js +1 -0
- package/dist/components/PlTableFilters/PlTableFiltersV2.style.js +1 -0
- package/dist/components/PlTableFilters/PlTableFiltersV2.vue2.js +2 -0
- package/dist/components/PlTableFilters/PlTableFiltersV2.vue2.js.map +1 -1
- package/dist/composition/AgGrid/index.js +2 -0
- package/dist/composition/AgGrid/index.js.map +1 -1
- package/dist/composition/fileContent.js +2 -38
- package/dist/composition/fileContent.js.map +1 -1
- package/dist/computedResult.js +2 -30
- package/dist/computedResult.js.map +1 -1
- package/dist/createModel.js +2 -0
- package/dist/createModel.js.map +1 -1
- package/dist/defineApp.js +3 -2
- package/dist/defineApp.js.map +1 -1
- package/dist/defineStore.js +2 -0
- package/dist/defineStore.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/UpdateSerializer.js +2 -6
- package/dist/internal/UpdateSerializer.js.map +1 -1
- package/dist/internal/createAppModel.js +2 -0
- package/dist/internal/createAppModel.js.map +1 -1
- package/dist/internal/createAppV1.js +2 -14
- package/dist/internal/createAppV1.js.map +1 -1
- package/dist/internal/createAppV2.js +3 -17
- package/dist/internal/createAppV2.js.map +1 -1
- package/dist/internal/createAppV3.js +3 -17
- package/dist/internal/createAppV3.js.map +1 -1
- package/dist/internal/service_factories.js +2 -8
- package/dist/internal/service_factories.js.map +1 -1
- package/dist/lib/util/helpers/dist/functions.js +2 -3
- package/dist/lib/util/helpers/dist/functions.js.map +1 -1
- package/dist/lib/util/helpers/dist/hash.js +1 -1
- package/dist/lib/util/helpers/dist/hash.js.map +1 -1
- package/dist/lib/util/helpers/dist/index.js +0 -2
- package/dist/lib/util/helpers/dist/objects.js +2 -45
- package/dist/lib/util/helpers/dist/objects.js.map +1 -1
- package/dist/lib/util/helpers/dist/prettyBytes.js +2 -0
- package/dist/lib/util/helpers/dist/prettyBytes.js.map +1 -1
- package/dist/lib/util/helpers/dist/random.js +2 -0
- package/dist/lib/util/helpers/dist/random.js.map +1 -1
- package/dist/lib/util/helpers/dist/strings.js +2 -0
- package/dist/lib/util/helpers/dist/strings.js.map +1 -1
- package/dist/lib/util/helpers/dist/uniqId.js +2 -0
- package/dist/lib/util/helpers/dist/uniqId.js.map +1 -1
- package/dist/lib/util/helpers/dist/utils.js +2 -1
- package/dist/lib/util/helpers/dist/utils.js.map +1 -1
- package/dist/objectHash.js +2 -5
- package/dist/objectHash.js.map +1 -1
- package/dist/plugins/Monetization/EndOfPeriod.js +1 -0
- package/dist/plugins/Monetization/EndOfPeriod.style.js +1 -0
- package/dist/plugins/Monetization/EndOfPeriod.vue2.js +2 -0
- package/dist/plugins/Monetization/EndOfPeriod.vue2.js.map +1 -1
- package/dist/plugins/Monetization/LimitCard.js +1 -0
- package/dist/plugins/Monetization/LimitCard.style.js +1 -0
- package/dist/plugins/Monetization/LimitCard.vue2.js +2 -0
- package/dist/plugins/Monetization/LimitCard.vue2.js.map +1 -1
- package/dist/plugins/Monetization/MonetizationSidebar.js +2 -0
- package/dist/plugins/Monetization/MonetizationSidebar.vue2.js +2 -0
- package/dist/plugins/Monetization/MonetizationSidebar.vue2.js.map +1 -1
- package/dist/plugins/Monetization/RunStatus.js +1 -0
- package/dist/plugins/Monetization/RunStatus.style.js +1 -0
- package/dist/plugins/Monetization/RunStatus.vue2.js +2 -0
- package/dist/plugins/Monetization/RunStatus.vue2.js.map +1 -1
- package/dist/plugins/Monetization/UserCabinetCard.js +1 -0
- package/dist/plugins/Monetization/UserCabinetCard.style.js +1 -0
- package/dist/plugins/Monetization/UserCabinetCard.vue2.js +2 -0
- package/dist/plugins/Monetization/UserCabinetCard.vue2.js.map +1 -1
- package/dist/plugins/Monetization/useButtonTarget.js +2 -0
- package/dist/plugins/Monetization/useButtonTarget.js.map +1 -1
- package/dist/plugins/Monetization/useInfo.js +2 -0
- package/dist/plugins/Monetization/useInfo.js.map +1 -1
- package/dist/plugins/Monetization/validation.js +4 -4
- package/dist/plugins/Monetization/validation.js.map +1 -1
- package/dist/urls.js +3 -1
- package/dist/urls.js.map +1 -1
- package/dist/usePlugin.js +2 -24
- package/dist/usePlugin.js.map +1 -1
- package/dist/utils.js +3 -1
- package/dist/utils.js.map +1 -1
- package/package.json +11 -11
- package/dist/lib/util/helpers/dist/disposable.js +0 -9
- package/dist/lib/util/helpers/dist/disposable.js.map +0 -1
- package/dist/lib/util/helpers/dist/ref_count_pool.js +0 -4
- package/dist/lib/util/helpers/dist/ref_count_pool.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createBlock as e, createElementVNode as t, createTextVNode as n, defineComponent as r, openBlock as i, unref as a, useModel as o, withCtx as s } from "vue";
|
|
2
2
|
import { PlSearchField as c } from "@milaboratories/uikit";
|
|
3
|
+
//#region src/components/PlTableFastSearch/PlTableFastSearch.vue?vue&type=script&setup=true&lang.ts
|
|
3
4
|
var l = /* @__PURE__ */ r({
|
|
4
5
|
__name: "PlTableFastSearch",
|
|
5
6
|
props: {
|
|
@@ -36,6 +37,7 @@ var l = /* @__PURE__ */ r({
|
|
|
36
37
|
}, 8, ["modelValue"]));
|
|
37
38
|
}
|
|
38
39
|
});
|
|
40
|
+
//#endregion
|
|
39
41
|
export { l as default };
|
|
40
42
|
|
|
41
43
|
//# sourceMappingURL=PlTableFastSearch.vue2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlTableFastSearch.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/PlTableFastSearch/PlTableFastSearch.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { PlSearchField } from \"@milaboratories/uikit\";\n\nconst model = defineModel<string>({ required: true });\n</script>\n\n<template>\n <PlSearchField v-model=\"model\" clearable placeholder=\"Search...\">\n <template #helper>\n <b>How table search works:</b>\n <br />\n <ul>\n <li>\n <b>Exact match only.</b><br />\n No partials, wildcards, ranges, or regex.\n </li>\n <li>\n <b>Scope:</b> Searches all visible columns. To include a column, make it visible in\n Columns.\n </li>\n <li>\n <b>Text columns:</b> Exact string equality. Characters must match exactly (including case,\n spaces, and punctuation).\n </li>\n <li>\n <b>Number columns:</b> Exact numeric equality. 71 matches 71 and 71.0; it does not match\n 715 or 0.71/0.85.\n </li>\n </ul>\n <b>Examples:</b>\n <br />\n <ul>\n <li>CASSLDRGTEAFF → shows rows where any visible column equals that full string.</li>\n <li>85 → matches 85 / 85.0, not 0.85 or 850.</li>\n </ul>\n </template>\n </PlSearchField>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlTableFastSearch.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/PlTableFastSearch/PlTableFastSearch.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { PlSearchField } from \"@milaboratories/uikit\";\n\nconst model = defineModel<string>({ required: true });\n</script>\n\n<template>\n <PlSearchField v-model=\"model\" clearable placeholder=\"Search...\">\n <template #helper>\n <b>How table search works:</b>\n <br />\n <ul>\n <li>\n <b>Exact match only.</b><br />\n No partials, wildcards, ranges, or regex.\n </li>\n <li>\n <b>Scope:</b> Searches all visible columns. To include a column, make it visible in\n Columns.\n </li>\n <li>\n <b>Text columns:</b> Exact string equality. Characters must match exactly (including case,\n spaces, and punctuation).\n </li>\n <li>\n <b>Number columns:</b> Exact numeric equality. 71 matches 71 and 71.0; it does not match\n 715 or 0.71/0.85.\n </li>\n </ul>\n <b>Examples:</b>\n <br />\n <ul>\n <li>CASSLDRGTEAFF → shows rows where any visible column equals that full string.</li>\n <li>85 → matches 85 / 85.0, not 0.85 or 850.</li>\n </ul>\n </template>\n </PlSearchField>\n</template>\n"],"mappings":";;;;;;;;;;;EAGA,IAAM,IAAQ,EAAmB,GAAA,aAAoB;yBAInD,EA6BgB,EAAA,EAAA,EAAA;eA7BQ,EAAA;4CAAK,QAAA;GAAE,WAAA;GAAU,aAAY;;GACxC,QAAM,QACe,CAAA,GAAA,AAAA,EAAA,OAAA;IAA9B,EAA8B,KAAA,MAA3B,2BAAuB,GAAA;IAC1B,EAAM,MAAA,MAAA,MAAA,GAAA;IACN,EAiBK,MAAA,MAAA;KAhBH,EAGK,MAAA,MAAA;MAFH,EAAwB,KAAA,MAArB,oBAAiB;MAAI,EAAM,KAAA;QAAA,8CAEhC;;KACA,EAGK,MAAA,MAAA,CAFH,EAAa,KAAA,MAAV,SAAM,EAAA,EAAI,mFAEf,CAAA,CAAA;KACA,EAGK,MAAA,MAAA,CAFH,EAAoB,KAAA,MAAjB,gBAAa,EAAA,EAAI,oGAEtB,CAAA,CAAA;KACA,EAGK,MAAA,MAAA,CAFH,EAAsB,KAAA,MAAnB,kBAAe,EAAA,EAAI,wFAExB,CAAA,CAAA;;IAEF,EAAgB,KAAA,MAAb,aAAS,GAAA;IACZ,EAAM,MAAA,MAAA,MAAA,GAAA;IACN,EAGK,MAAA,MAAA,CAFH,EAAqF,MAAA,MAAjF,+EAA4E,EAChF,EAAiD,MAAA,MAA7C,2CAAwC,CAAA,EAAA,GAAA"}
|
|
@@ -2,6 +2,7 @@ import e from "../../_virtual/_plugin-vue_export-helper.js";
|
|
|
2
2
|
import t from "./PlTableFiltersV2.vue2.js";
|
|
3
3
|
import n from "./PlTableFiltersV2.style.js";
|
|
4
4
|
var r = /* @__PURE__ */ e(t, [["__cssModules", { $style: n }]]);
|
|
5
|
+
//#endregion
|
|
5
6
|
export { r as default };
|
|
6
7
|
|
|
7
8
|
//# sourceMappingURL=PlTableFiltersV2.js.map
|
|
@@ -4,6 +4,7 @@ import { Fragment as t, Teleport as n, computed as r, createBlock as i, createCo
|
|
|
4
4
|
import { Annotation as b, Domain as x, canonicalizeJson as S, getAxisId as C, getUniqueSourceValuesWithLabels as w, parseJson as T, readAnnotation as E, readDomain as D } from "@platforma-sdk/model";
|
|
5
5
|
import { PlBtnGhost as O, PlSlideModal as k, usePlBlockPageTitleTeleportTarget as A } from "@milaboratories/uikit";
|
|
6
6
|
import { isNil as j } from "es-toolkit";
|
|
7
|
+
//#region src/components/PlTableFilters/PlTableFiltersV2.vue?vue&type=script&setup=true&lang.ts
|
|
7
8
|
var M = /* @__PURE__ */ u({
|
|
8
9
|
__name: "PlTableFiltersV2",
|
|
9
10
|
props: /* @__PURE__ */ d({
|
|
@@ -93,6 +94,7 @@ var M = /* @__PURE__ */ u({
|
|
|
93
94
|
}, 8, ["modelValue"])], 64));
|
|
94
95
|
}
|
|
95
96
|
});
|
|
97
|
+
//#endregion
|
|
96
98
|
export { M as default };
|
|
97
99
|
|
|
98
100
|
//# sourceMappingURL=PlTableFiltersV2.vue2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlTableFiltersV2.vue_vue_type_script_setup_true_lang.js","names":["$style"],"sources":["../../../src/components/PlTableFilters/PlTableFiltersV2.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n PTableColumnSpec,\n PlDataTableFiltersWithMeta,\n PFrameHandle,\n PTableColumnId,\n CanonicalizedJson,\n} from \"@platforma-sdk/model\";\nimport {\n canonicalizeJson,\n Annotation,\n Domain,\n readAnnotation,\n readDomain,\n getAxisId,\n getUniqueSourceValuesWithLabels,\n parseJson,\n} from \"@platforma-sdk/model\";\nimport { computed, onMounted, ref } from \"vue\";\nimport { PlBtnGhost, PlSlideModal, usePlBlockPageTitleTeleportTarget } from \"@milaboratories/uikit\";\nimport {\n PlAdvancedFilter,\n PlAdvancedFilterComponent,\n PlAdvancedFilterSupportedFilters,\n type PlAdvancedFilterItem,\n} from \"../PlAdvancedFilter\";\nimport type { PlAdvancedFilterColumnId } from \"../PlAdvancedFilter/types\";\nimport type { Nil } from \"@milaboratories/helpers\";\nimport { isNil } from \"es-toolkit\";\n\nconst model = defineModel<PlDataTableFiltersWithMeta>({ required: true });\nconst props = defineProps<{\n pframeHandle: Nil | PFrameHandle;\n columns: PTableColumnSpec[];\n}>();\n\n// Teleport for \"Filters\" button\nconst mounted = ref(false);\nonMounted(() => {\n mounted.value = true;\n});\nconst teleportTarget = usePlBlockPageTitleTeleportTarget(\"PlTableFiltersV2\");\nconst showManager = ref(false);\n\n// Check if any filters are active\nconst filtersOn = computed(() => {\n return model.value.filters.length > 0;\n});\n\nfunction makeFilterColumnId(spec: PTableColumnSpec): CanonicalizedJson<PTableColumnId> {\n const id: PTableColumnId =\n spec.type === \"axis\"\n ? { type: \"axis\", id: getAxisId(spec.spec) }\n : { type: \"column\", id: spec.id };\n return canonicalizeJson<PTableColumnId>(id);\n}\n\nconst items = computed<PlAdvancedFilterItem[]>(() => {\n return props.columns.map((col, idx) => {\n const id = makeFilterColumnId(col);\n const label =\n readAnnotation(col.spec, Annotation.Label)?.trim() ?? `Unlabeled ${col.type} ${idx}`;\n const alphabet =\n readDomain(col.spec, Domain.Alphabet) ?? readAnnotation(col.spec, Annotation.Alphabet);\n return {\n id,\n label,\n spec: col.spec,\n alphabet: alphabet ?? undefined,\n };\n });\n});\n\n// Supported filters (same set as FilterSidebar)\nconst supportedFilters = [\n \"isNA\",\n \"isNotNA\",\n \"greaterThan\",\n \"greaterThanOrEqual\",\n \"lessThan\",\n \"lessThanOrEqual\",\n \"patternEquals\",\n \"patternNotEquals\",\n \"patternContainSubsequence\",\n \"patternNotContainSubsequence\",\n \"patternMatchesRegularExpression\",\n \"patternFuzzyContainSubsequence\",\n \"equal\",\n \"notEqual\",\n] as (typeof PlAdvancedFilterSupportedFilters)[number][];\n\n// getSuggestOptions - provide discrete values from column annotations\nfunction handleSuggestOptions(params: {\n columnId: PlAdvancedFilterColumnId;\n axisIdx?: number;\n searchStr: string;\n searchType: \"value\" | \"label\";\n}) {\n if (isNil(props.pframeHandle)) {\n console.warn(\"PFrame handle is not available, cannot fetch suggest options\");\n return [];\n }\n\n const strId = params.columnId as CanonicalizedJson<PTableColumnId>;\n const tableColumnId = parseJson<PTableColumnId>(strId);\n\n if (tableColumnId.type !== \"column\") {\n throw new Error(\"ColumnId should be of type 'column' for suggest options\");\n }\n\n return getUniqueSourceValuesWithLabels(props.pframeHandle, {\n columnId: tableColumnId.id,\n axisIdx: params.axisIdx,\n limit: 100,\n searchQuery: params.searchType === \"label\" ? params.searchStr : undefined,\n searchQueryValue: params.searchType === \"value\" ? params.searchStr : undefined,\n }).then((v) => v.values);\n}\n</script>\n\n<template>\n <Teleport v-if=\"mounted && teleportTarget\" :to=\"teleportTarget\">\n <PlBtnGhost :icon=\"filtersOn ? 'filter-on' : 'filter'\" @click.stop=\"showManager = true\">\n Filters\n </PlBtnGhost>\n </Teleport>\n\n <PlSlideModal v-model=\"showManager\" :close-on-outside-click=\"false\">\n <template #title>Manage Filters</template>\n\n <div :class=\"$style.root\">\n <PlAdvancedFilterComponent\n v-model:filters=\"model as PlAdvancedFilter\"\n :items=\"items\"\n :supported-filters=\"supportedFilters\"\n :get-suggest-options=\"handleSuggestOptions\"\n :enable-dnd=\"false\"\n :enable-add-group-button=\"true\"\n />\n </div>\n </PlSlideModal>\n</template>\n\n<style module>\n.root {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n</style>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlTableFiltersV2.vue_vue_type_script_setup_true_lang.js","names":["$style"],"sources":["../../../src/components/PlTableFilters/PlTableFiltersV2.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n PTableColumnSpec,\n PlDataTableFiltersWithMeta,\n PFrameHandle,\n PTableColumnId,\n CanonicalizedJson,\n} from \"@platforma-sdk/model\";\nimport {\n canonicalizeJson,\n Annotation,\n Domain,\n readAnnotation,\n readDomain,\n getAxisId,\n getUniqueSourceValuesWithLabels,\n parseJson,\n} from \"@platforma-sdk/model\";\nimport { computed, onMounted, ref } from \"vue\";\nimport { PlBtnGhost, PlSlideModal, usePlBlockPageTitleTeleportTarget } from \"@milaboratories/uikit\";\nimport {\n PlAdvancedFilter,\n PlAdvancedFilterComponent,\n PlAdvancedFilterSupportedFilters,\n type PlAdvancedFilterItem,\n} from \"../PlAdvancedFilter\";\nimport type { PlAdvancedFilterColumnId } from \"../PlAdvancedFilter/types\";\nimport type { Nil } from \"@milaboratories/helpers\";\nimport { isNil } from \"es-toolkit\";\n\nconst model = defineModel<PlDataTableFiltersWithMeta>({ required: true });\nconst props = defineProps<{\n pframeHandle: Nil | PFrameHandle;\n columns: PTableColumnSpec[];\n}>();\n\n// Teleport for \"Filters\" button\nconst mounted = ref(false);\nonMounted(() => {\n mounted.value = true;\n});\nconst teleportTarget = usePlBlockPageTitleTeleportTarget(\"PlTableFiltersV2\");\nconst showManager = ref(false);\n\n// Check if any filters are active\nconst filtersOn = computed(() => {\n return model.value.filters.length > 0;\n});\n\nfunction makeFilterColumnId(spec: PTableColumnSpec): CanonicalizedJson<PTableColumnId> {\n const id: PTableColumnId =\n spec.type === \"axis\"\n ? { type: \"axis\", id: getAxisId(spec.spec) }\n : { type: \"column\", id: spec.id };\n return canonicalizeJson<PTableColumnId>(id);\n}\n\nconst items = computed<PlAdvancedFilterItem[]>(() => {\n return props.columns.map((col, idx) => {\n const id = makeFilterColumnId(col);\n const label =\n readAnnotation(col.spec, Annotation.Label)?.trim() ?? `Unlabeled ${col.type} ${idx}`;\n const alphabet =\n readDomain(col.spec, Domain.Alphabet) ?? readAnnotation(col.spec, Annotation.Alphabet);\n return {\n id,\n label,\n spec: col.spec,\n alphabet: alphabet ?? undefined,\n };\n });\n});\n\n// Supported filters (same set as FilterSidebar)\nconst supportedFilters = [\n \"isNA\",\n \"isNotNA\",\n \"greaterThan\",\n \"greaterThanOrEqual\",\n \"lessThan\",\n \"lessThanOrEqual\",\n \"patternEquals\",\n \"patternNotEquals\",\n \"patternContainSubsequence\",\n \"patternNotContainSubsequence\",\n \"patternMatchesRegularExpression\",\n \"patternFuzzyContainSubsequence\",\n \"equal\",\n \"notEqual\",\n] as (typeof PlAdvancedFilterSupportedFilters)[number][];\n\n// getSuggestOptions - provide discrete values from column annotations\nfunction handleSuggestOptions(params: {\n columnId: PlAdvancedFilterColumnId;\n axisIdx?: number;\n searchStr: string;\n searchType: \"value\" | \"label\";\n}) {\n if (isNil(props.pframeHandle)) {\n console.warn(\"PFrame handle is not available, cannot fetch suggest options\");\n return [];\n }\n\n const strId = params.columnId as CanonicalizedJson<PTableColumnId>;\n const tableColumnId = parseJson<PTableColumnId>(strId);\n\n if (tableColumnId.type !== \"column\") {\n throw new Error(\"ColumnId should be of type 'column' for suggest options\");\n }\n\n return getUniqueSourceValuesWithLabels(props.pframeHandle, {\n columnId: tableColumnId.id,\n axisIdx: params.axisIdx,\n limit: 100,\n searchQuery: params.searchType === \"label\" ? params.searchStr : undefined,\n searchQueryValue: params.searchType === \"value\" ? params.searchStr : undefined,\n }).then((v) => v.values);\n}\n</script>\n\n<template>\n <Teleport v-if=\"mounted && teleportTarget\" :to=\"teleportTarget\">\n <PlBtnGhost :icon=\"filtersOn ? 'filter-on' : 'filter'\" @click.stop=\"showManager = true\">\n Filters\n </PlBtnGhost>\n </Teleport>\n\n <PlSlideModal v-model=\"showManager\" :close-on-outside-click=\"false\">\n <template #title>Manage Filters</template>\n\n <div :class=\"$style.root\">\n <PlAdvancedFilterComponent\n v-model:filters=\"model as PlAdvancedFilter\"\n :items=\"items\"\n :supported-filters=\"supportedFilters\"\n :get-suggest-options=\"handleSuggestOptions\"\n :enable-dnd=\"false\"\n :enable-add-group-button=\"true\"\n />\n </div>\n </PlSlideModal>\n</template>\n\n<style module>\n.root {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;EA8BA,IAAM,IAAQ,EAAuC,GAAA,aAAoB,EACnE,IAAQ,GAMR,IAAU,EAAI,GAAM;AAC1B,UAAgB;AACd,KAAQ,QAAQ;IAChB;EACF,IAAM,IAAiB,EAAkC,mBAAmB,EACtE,IAAc,EAAI,GAAM,EAGxB,IAAY,QACT,EAAM,MAAM,QAAQ,SAAS,EACpC;EAEF,SAAS,EAAmB,GAA2D;AAKrF,UAAO,EAHL,EAAK,SAAS,SACV;IAAE,MAAM;IAAQ,IAAI,EAAU,EAAK,KAAK;IAAC,GACzC;IAAE,MAAM;IAAU,IAAI,EAAK;IAAI,CACM;;EAG7C,IAAM,IAAQ,QACL,EAAM,QAAQ,KAAK,GAAK,MAAQ;GACrC,IAAM,IAAK,EAAmB,EAAI,EAC5B,IACJ,EAAe,EAAI,MAAM,EAAW,MAAM,EAAE,MAAM,IAAI,aAAa,EAAI,KAAK,GAAG,KAC3E,IACJ,EAAW,EAAI,MAAM,EAAO,SAAS,IAAI,EAAe,EAAI,MAAM,EAAW,SAAS;AACxF,UAAO;IACL;IACA;IACA,MAAM,EAAI;IACV,UAAU,KAAY,KAAA;IACvB;IACD,CACF,EAGI,IAAmB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;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terpriseModule as t, LicenseManager as n, ModuleRegistry as r } from "ag-grid-enterprise";
|
|
3
|
+
//#region src/composition/AgGrid/index.ts
|
|
3
4
|
function i() {
|
|
4
5
|
r.registerModules([t]);
|
|
5
6
|
let i = e("AGGRID_LICENSE");
|
|
6
7
|
i ? (n.setLicenseKey(i), console.log("AG Grid Activated")) : console.log("AG Grid License not found");
|
|
7
8
|
}
|
|
9
|
+
//#endregion
|
|
8
10
|
export { i as activateAgGrid };
|
|
9
11
|
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/composition/AgGrid/index.ts"],"sourcesContent":["import { AllEnterpriseModule, LicenseManager, ModuleRegistry } from \"ag-grid-enterprise\";\nimport { getEnvironmentValue } from \"@platforma-sdk/model\";\n\nexport function activateAgGrid() {\n ModuleRegistry.registerModules([AllEnterpriseModule]);\n const agGridLicense = getEnvironmentValue(\"AGGRID_LICENSE\");\n if (agGridLicense) {\n LicenseManager.setLicenseKey(agGridLicense);\n console.log(\"AG Grid Activated\");\n } else {\n console.log(\"AG Grid License not found\");\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/composition/AgGrid/index.ts"],"sourcesContent":["import { AllEnterpriseModule, LicenseManager, ModuleRegistry } from \"ag-grid-enterprise\";\nimport { getEnvironmentValue } from \"@platforma-sdk/model\";\n\nexport function activateAgGrid() {\n ModuleRegistry.registerModules([AllEnterpriseModule]);\n const agGridLicense = getEnvironmentValue(\"AGGRID_LICENSE\");\n if (agGridLicense) {\n LicenseManager.setLicenseKey(agGridLicense);\n console.log(\"AG Grid Activated\");\n } else {\n console.log(\"AG Grid License not found\");\n }\n}\n"],"mappings":";;;AAGA,SAAgB,IAAiB;AAC/B,GAAe,gBAAgB,CAAC,EAAoB,CAAC;CACrD,IAAM,IAAgB,EAAoB,iBAAiB;AAC3D,CAAI,KACF,EAAe,cAAc,EAAc,EAC3C,QAAQ,IAAI,oBAAoB,IAEhC,QAAQ,IAAI,4BAA4B"}
|
|
@@ -3,6 +3,7 @@ import "../lib/util/helpers/dist/index.js";
|
|
|
3
3
|
import { computed as t, effectScope as n, getCurrentScope as r, onScopeDispose as i, shallowRef as a } from "vue";
|
|
4
4
|
import { getRawPlatformaInstance as o } from "@platforma-sdk/model";
|
|
5
5
|
import { LRUCache as s } from "lru-cache";
|
|
6
|
+
//#region src/composition/fileContent.ts
|
|
6
7
|
var c = { cacheSize: 15e6 }, l = class {
|
|
7
8
|
_str = void 0;
|
|
8
9
|
_rawJson = void 0;
|
|
@@ -43,9 +44,6 @@ var f = new s({
|
|
|
43
44
|
sizeCalculation: (e) => e.bytes.length
|
|
44
45
|
}), this.fetcher = r.fetcher ?? new e();
|
|
45
46
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Experimental method to invalidate the refs map cache for a given key.
|
|
48
|
-
*/
|
|
49
47
|
withInvalidate(e, t) {
|
|
50
48
|
let n = this.ns.get(e);
|
|
51
49
|
this.ns.set(e, /* @__PURE__ */ new Set()), this.currentKey = e;
|
|
@@ -120,44 +118,9 @@ var f = new s({
|
|
|
120
118
|
u.delete(t);
|
|
121
119
|
}), t;
|
|
122
120
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Creates a ReactiveFileContent instance with isolated cache and fetcher.
|
|
125
|
-
* Use this when you need component-specific caching.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```ts
|
|
129
|
-
* import { ReactiveFileContent } from '@platforma-sdk/ui-vue';
|
|
130
|
-
* import { computed } from 'vue';
|
|
131
|
-
*
|
|
132
|
-
* const fileContent = ReactiveFileContent.use();
|
|
133
|
-
*
|
|
134
|
-
* const processedData = computed(() => {
|
|
135
|
-
* const content = fileContent.getContentString(fileHandle).value;
|
|
136
|
-
* return content?.split('\n').length ?? 0;
|
|
137
|
-
* });
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
121
|
static use(e, t) {
|
|
141
122
|
return new m(this.initScope(t), { ...e });
|
|
142
123
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Creates a ReactiveFileContent instance with globally shared cache and fetcher.
|
|
145
|
-
* Use this to share file content cache across multiple components.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```ts
|
|
149
|
-
* import { ReactiveFileContent } from '@platforma-sdk/ui-vue';
|
|
150
|
-
* import { computed } from 'vue';
|
|
151
|
-
*
|
|
152
|
-
* const fileContent = ReactiveFileContent.useGlobal();
|
|
153
|
-
*
|
|
154
|
-
* const combinedData = computed(() => {
|
|
155
|
-
* const data1 = fileContent.getContentJson(handle1).value;
|
|
156
|
-
* const data2 = fileContent.getContentJson(handle2).value;
|
|
157
|
-
* return { data1, data2 };
|
|
158
|
-
* });
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
124
|
static useGlobal(e, t) {
|
|
162
125
|
return new m(this.initScope(t), {
|
|
163
126
|
...e,
|
|
@@ -166,6 +129,7 @@ var f = new s({
|
|
|
166
129
|
});
|
|
167
130
|
}
|
|
168
131
|
};
|
|
132
|
+
//#endregion
|
|
169
133
|
export { m as ReactiveFileContent };
|
|
170
134
|
|
|
171
135
|
//# sourceMappingURL=fileContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileContent.js","names":[],"sources":["../../src/composition/fileContent.ts"],"sourcesContent":["import type { BlobHandleAndSize } from \"@platforma-sdk/model\";\nimport { getRawPlatformaInstance } from \"@platforma-sdk/model\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ComputedRef, ShallowRef, EffectScope } from \"vue\";\nimport { computed, shallowRef, getCurrentScope, onScopeDispose, effectScope } from \"vue\";\nimport type { ZodSchema, SafeParseReturnType } from \"zod\";\nimport { Fetcher } from \"@milaboratories/helpers\";\n\ntype FileHandle = BlobHandleAndSize[\"handle\"];\n\nexport type ReactiveFileContentOps = {\n /** Maximum size in bytes of file content to cache */\n cacheSize: number;\n lruCache?: LRUCache<FileHandle, FileContentData>;\n fetcher?: Fetcher<FileHandle, FileContentData>;\n};\n\nconst DefaultReactiveFileContentOps: ReactiveFileContentOps = {\n cacheSize: 15_000_000, // 15 Mb\n};\n\nclass FileContentData {\n private _str: string | undefined = undefined;\n private _rawJson: unknown | undefined = undefined;\n private _zodSchema: ZodSchema | undefined = undefined;\n private _validatedJson: SafeParseReturnType<unknown, unknown> | undefined = undefined;\n\n constructor(public readonly bytes: Uint8Array) {}\n\n public get str(): string {\n if (this._str === undefined) this._str = new TextDecoder().decode(this.bytes);\n return this._str;\n }\n\n public get rawJson(): unknown {\n if (this._rawJson === undefined) this._rawJson = JSON.parse(this.str);\n return this._rawJson;\n }\n\n public validatedJson<T>(schema: ZodSchema<T>): T | undefined {\n if (this._zodSchema !== schema) {\n this._validatedJson = schema.safeParse(this.rawJson);\n this._zodSchema = schema;\n }\n return this._validatedJson?.success ? (this._validatedJson.data as T) : undefined;\n }\n}\n\nconst scopes = new WeakMap<EffectScope, Map<FileHandle, ShallowRef<FileContentData | undefined>>>();\n\nfunction addScope(scope: EffectScope) {\n scopes.set(scope, new Map<FileHandle, ShallowRef<FileContentData | undefined>>());\n}\n\nconst globalCache = new LRUCache<FileHandle, FileContentData>({\n maxSize: DefaultReactiveFileContentOps.cacheSize,\n sizeCalculation: (value) => value.bytes.length,\n});\n\nconst globalFetcher = new Fetcher<FileHandle, FileContentData>();\n\nexport class ReactiveFileContent {\n private readonly fileDataCache: LRUCache<FileHandle, FileContentData>;\n private readonly fetcher: Fetcher<FileHandle, FileContentData>;\n private ns = new Map<string, Set<FileHandle>>();\n private currentKey: string | undefined;\n\n private constructor(\n private currentScope: EffectScope,\n _ops?: Partial<ReactiveFileContentOps>,\n ) {\n const ops: ReactiveFileContentOps = { ...DefaultReactiveFileContentOps, ..._ops };\n this.fileDataCache =\n ops.lruCache ??\n new LRUCache<FileHandle, FileContentData>({\n maxSize: ops.cacheSize,\n sizeCalculation: (value) => value.bytes.length,\n });\n this.fetcher = ops.fetcher ?? new Fetcher<FileHandle, FileContentData>();\n }\n\n /**\n * Experimental method to invalidate the refs map cache for a given key.\n */\n public withInvalidate<T>(key: string, cb: () => T) {\n const previous = this.ns.get(key);\n this.ns.set(key, new Set());\n this.currentKey = key;\n try {\n const res = cb();\n this.invalidate(key, previous);\n return res;\n } finally {\n this.currentKey = undefined;\n }\n }\n\n public stopScope() {\n scopes.delete(this.currentScope);\n this.currentScope.stop();\n }\n\n private async doFetch(handle: FileHandle) {\n if (!this.fileDataCache.has(handle)) {\n const fileContentData = await this.fetcher.fetch(\n handle,\n async () =>\n new FileContentData(await getRawPlatformaInstance().blobDriver.getContent(handle)),\n );\n this.fileDataCache.set(handle, fileContentData);\n }\n\n return this.fileDataCache.get(handle)!;\n }\n\n private getSize() {\n const refsMap = this.getRefsMap();\n return refsMap ? refsMap.size : 0;\n }\n\n private getRefsMap() {\n return scopes.get(this.currentScope);\n }\n\n private invalidate(key: string, previous: Set<FileHandle> | undefined) {\n if (!previous) {\n return;\n }\n\n const actual = this.ns.get(key)!;\n\n for (const handle of actual) {\n previous.delete(handle);\n }\n\n const map = this.getRefsMap();\n\n for (const handle of previous) {\n map?.delete(handle);\n }\n }\n\n private withHandle(handle: FileHandle) {\n if (this.currentKey) {\n this.ns.get(this.currentKey)?.add(handle);\n }\n }\n\n private getDataRef(handle: FileHandle): ShallowRef<FileContentData | undefined> {\n const refsMap = this.getRefsMap();\n\n if (!refsMap) {\n throw new Error(\"ReactiveFileContent must be used within a Vue component or effect scope.\");\n }\n\n this.withHandle(handle);\n\n const refFromMap = refsMap.get(handle);\n\n if (refFromMap !== undefined) {\n return refFromMap;\n }\n\n const newRef = shallowRef<FileContentData>();\n refsMap.set(handle, newRef);\n\n // Initiating actual fetch from the cache, that will in turn initiate upload\n (async () => {\n const maxRetries = 8;\n const retryDelay = 1000; // 1 second\n\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n try {\n const data = await this.doFetch(handle);\n newRef.value = data;\n return;\n } catch (err: unknown) {\n console.error(`File download attempt ${attempt + 1}/${maxRetries} failed:`, err);\n\n if (attempt < maxRetries - 1) {\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n } else {\n console.error(`Failed to download file after ${maxRetries} attempts`);\n }\n }\n }\n })();\n\n return newRef;\n }\n\n public getContentBytes(handle: FileHandle): ComputedRef<Uint8Array | undefined>;\n public getContentBytes(\n handle: FileHandle | undefined,\n ): ComputedRef<Uint8Array | undefined> | undefined;\n public getContentBytes(\n handle: FileHandle | undefined,\n ): ComputedRef<Uint8Array | undefined> | undefined {\n if (handle === undefined) return undefined;\n const dataRef = this.getDataRef(handle);\n return computed(() => dataRef.value?.bytes);\n }\n\n public getContentString(handle: FileHandle): ComputedRef<string | undefined>;\n public getContentString(\n handle: FileHandle | undefined,\n ): ComputedRef<string | undefined> | undefined;\n public getContentString(\n handle: FileHandle | undefined,\n ): ComputedRef<string | undefined> | undefined {\n if (handle === undefined) return undefined;\n const dataRef = this.getDataRef(handle);\n return computed(() => dataRef.value?.str);\n }\n\n public getContentJson<T>(handle: FileHandle, schema: ZodSchema<T>): ComputedRef<T | undefined>;\n public getContentJson<T>(\n handle: FileHandle | undefined,\n schema: ZodSchema<T>,\n ): ComputedRef<T | undefined> | undefined;\n public getContentJson<T = unknown>(handle: FileHandle): ComputedRef<T | undefined>;\n public getContentJson<T = unknown>(\n handle: FileHandle | undefined,\n ): ComputedRef<T | undefined> | undefined;\n public getContentJson<T>(\n handle: FileHandle | undefined,\n schema?: ZodSchema<T>,\n ): ComputedRef<T | undefined> | undefined;\n public getContentJson<T>(\n handle: FileHandle | undefined,\n schema?: ZodSchema<T>,\n ): ComputedRef<T | undefined> | undefined {\n if (handle === undefined) return undefined;\n const dataRef = this.getDataRef(handle);\n return computed(\n () =>\n (schema === undefined ? dataRef.value?.rawJson : dataRef.value?.validatedJson(schema)) as T,\n );\n }\n\n private static initScope(_scope: EffectScope | undefined) {\n let scope = getCurrentScope() ?? _scope;\n\n if (!scope) {\n console.warn(\"Current scope not found, using new detached scope...\");\n scope = effectScope(true);\n }\n\n addScope(scope);\n\n onScopeDispose(() => {\n scopes.delete(scope);\n });\n\n return scope;\n }\n\n /**\n * Creates a ReactiveFileContent instance with isolated cache and fetcher.\n * Use this when you need component-specific caching.\n *\n * @example\n * ```ts\n * import { ReactiveFileContent } from '@platforma-sdk/ui-vue';\n * import { computed } from 'vue';\n *\n * const fileContent = ReactiveFileContent.use();\n *\n * const processedData = computed(() => {\n * const content = fileContent.getContentString(fileHandle).value;\n * return content?.split('\\n').length ?? 0;\n * });\n * ```\n */\n public static use(_ops?: Partial<ReactiveFileContentOps>, _scope?: EffectScope) {\n const scope = this.initScope(_scope);\n\n return new ReactiveFileContent(scope, { ..._ops });\n }\n\n /**\n * Creates a ReactiveFileContent instance with globally shared cache and fetcher.\n * Use this to share file content cache across multiple components.\n *\n * @example\n * ```ts\n * import { ReactiveFileContent } from '@platforma-sdk/ui-vue';\n * import { computed } from 'vue';\n *\n * const fileContent = ReactiveFileContent.useGlobal();\n *\n * const combinedData = computed(() => {\n * const data1 = fileContent.getContentJson(handle1).value;\n * const data2 = fileContent.getContentJson(handle2).value;\n * return { data1, data2 };\n * });\n * ```\n */\n public static useGlobal(_ops?: Partial<ReactiveFileContentOps>, _scope?: EffectScope) {\n const scope = this.initScope(_scope);\n\n return new ReactiveFileContent(scope, {\n ..._ops,\n lruCache: globalCache,\n fetcher: globalFetcher,\n });\n }\n}\n"],"mappings":";;;;;AAiBA,IAAM,IAAwD,EAC5D,WAAW,MACZ,EAEK,IAAN,MAAsB;CACpB,OAAmC,KAAA;CACnC,WAAwC,KAAA;CACxC,aAA4C,KAAA;CAC5C,iBAA4E,KAAA;CAE5E,YAAY,GAAmC;AAAnB,OAAA,QAAA;;CAE5B,IAAW,MAAc;AAEvB,SADI,KAAK,SAAS,KAAA,MAAW,KAAK,OAAO,IAAI,aAAa,CAAC,OAAO,KAAK,MAAM,GACtE,KAAK;;CAGd,IAAW,UAAmB;AAE5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K,WAAW,EAAO;AACvC,SAAO,QAAe,EAAQ,OAAO,MAAM;;CAO7C,iBACE,GAC6C;AAC7C,MAAI,MAAW,KAAA,EAAW;EAC1B,IAAM,IAAU,KAAK,WAAW,EAAO;AACvC,SAAO,QAAe,EAAQ,OAAO,IAAI;;CAgB3C,eACE,GACA,GACwC;AACxC,MAAI,MAAW,KAAA,EAAW;EAC1B,IAAM,IAAU,KAAK,WAAW,EAAO;AACvC,SAAO,QAEF,MAAW,KAAA,IAAY,EAAQ,OAAO,UAAU,EAAQ,OAAO,cAAc,EAAO,CACxF;;CAGH,OAAe,UAAU,GAAiC;EACxD,IAAI,IAAQ,GAAiB,IAAI;AAajC,SAXA,AAEE,OADA,QAAQ,KAAK,uDAAuD,EAC5D,EAAY,GAAK,GAG3B,EAAS,EAAM,EAEf,QAAqB;AACnB,KAAO,OAAO,EAAM;IACpB,EAEK;;;;;;;;;;;;;;;;;;;CAoBT,OAAc,IAAI,GAAwC,GAAsB;AAG9E,SAAO,IAAI,EAFG,KAAK,UAAU,EAAO,EAEE,EAAE,GAAG,GAAM,CAAC;;;;;;;;;;;;;;;;;;;;CAqBpD,OAAc,UAAU,GAAwC,GAAsB;AAGpF,SAAO,IAAI,EAFG,KAAK,UAAU,EAAO,EAEE;GACpC,GAAG;GACH,UAAU;GACV,SAAS;GACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"fileContent.js","names":[],"sources":["../../src/composition/fileContent.ts"],"sourcesContent":["import type { BlobHandleAndSize } from \"@platforma-sdk/model\";\nimport { getRawPlatformaInstance } from \"@platforma-sdk/model\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ComputedRef, ShallowRef, EffectScope } from \"vue\";\nimport { computed, shallowRef, getCurrentScope, onScopeDispose, effectScope } from \"vue\";\nimport type { ZodSchema, SafeParseReturnType } from \"zod\";\nimport { Fetcher } from \"@milaboratories/helpers\";\n\ntype FileHandle = BlobHandleAndSize[\"handle\"];\n\nexport type ReactiveFileContentOps = {\n /** Maximum size in bytes of file content to cache */\n cacheSize: number;\n lruCache?: LRUCache<FileHandle, FileContentData>;\n fetcher?: Fetcher<FileHandle, FileContentData>;\n};\n\nconst DefaultReactiveFileContentOps: ReactiveFileContentOps = {\n cacheSize: 15_000_000, // 15 Mb\n};\n\nclass FileContentData {\n private _str: string | undefined = undefined;\n private _rawJson: unknown | undefined = undefined;\n private _zodSchema: ZodSchema | undefined = undefined;\n private _validatedJson: SafeParseReturnType<unknown, unknown> | undefined = undefined;\n\n constructor(public readonly bytes: Uint8Array) {}\n\n public get str(): string {\n if (this._str === undefined) this._str = new TextDecoder().decode(this.bytes);\n return this._str;\n }\n\n public get rawJson(): unknown {\n if (this._rawJson === undefined) this._rawJson = JSON.parse(this.str);\n return this._rawJson;\n }\n\n public validatedJson<T>(schema: ZodSchema<T>): T | undefined {\n if (this._zodSchema !== schema) {\n this._validatedJson = schema.safeParse(this.rawJson);\n this._zodSchema = schema;\n }\n return this._validatedJson?.success ? (this._validatedJson.data as T) : undefined;\n }\n}\n\nconst scopes = new WeakMap<EffectScope, Map<FileHandle, ShallowRef<FileContentData | undefined>>>();\n\nfunction addScope(scope: EffectScope) {\n scopes.set(scope, new Map<FileHandle, ShallowRef<FileContentData | undefined>>());\n}\n\nconst globalCache = new LRUCache<FileHandle, FileContentData>({\n maxSize: DefaultReactiveFileContentOps.cacheSize,\n sizeCalculation: (value) => value.bytes.length,\n});\n\nconst globalFetcher = new Fetcher<FileHandle, FileContentData>();\n\nexport class ReactiveFileContent {\n private readonly fileDataCache: LRUCache<FileHandle, FileContentData>;\n private readonly fetcher: Fetcher<FileHandle, FileContentData>;\n private ns = new Map<string, Set<FileHandle>>();\n private currentKey: string | undefined;\n\n private constructor(\n private currentScope: EffectScope,\n _ops?: Partial<ReactiveFileContentOps>,\n ) {\n const ops: ReactiveFileContentOps = { ...DefaultReactiveFileContentOps, ..._ops };\n this.fileDataCache =\n ops.lruCache ??\n new LRUCache<FileHandle, FileContentData>({\n maxSize: ops.cacheSize,\n sizeCalculation: (value) => value.bytes.length,\n });\n this.fetcher = ops.fetcher ?? new Fetcher<FileHandle, FileContentData>();\n }\n\n /**\n * Experimental method to invalidate the refs map cache for a given key.\n */\n public withInvalidate<T>(key: string, cb: () => T) {\n const previous = this.ns.get(key);\n this.ns.set(key, new Set());\n this.currentKey = key;\n try {\n const res = cb();\n this.invalidate(key, previous);\n return res;\n } finally {\n this.currentKey = undefined;\n }\n }\n\n public stopScope() {\n scopes.delete(this.currentScope);\n this.currentScope.stop();\n }\n\n private async doFetch(handle: FileHandle) {\n if (!this.fileDataCache.has(handle)) {\n const fileContentData = await this.fetcher.fetch(\n handle,\n async () =>\n new FileContentData(await getRawPlatformaInstance().blobDriver.getContent(handle)),\n );\n this.fileDataCache.set(handle, fileContentData);\n }\n\n return this.fileDataCache.get(handle)!;\n }\n\n private getSize() {\n const refsMap = this.getRefsMap();\n return refsMap ? refsMap.size : 0;\n }\n\n private getRefsMap() {\n return scopes.get(this.currentScope);\n }\n\n private invalidate(key: string, previous: Set<FileHandle> | undefined) {\n if (!previous) {\n return;\n }\n\n const actual = this.ns.get(key)!;\n\n for (const handle of actual) {\n previous.delete(handle);\n }\n\n const map = this.getRefsMap();\n\n for (const handle of previous) {\n map?.delete(handle);\n }\n }\n\n private withHandle(handle: FileHandle) {\n if (this.currentKey) {\n this.ns.get(this.currentKey)?.add(handle);\n }\n }\n\n private getDataRef(handle: FileHandle): ShallowRef<FileContentData | undefined> {\n const refsMap = this.getRefsMap();\n\n if (!refsMap) {\n throw new Error(\"ReactiveFileContent must be used within a Vue component or effect scope.\");\n }\n\n this.withHandle(handle);\n\n const refFromMap = refsMap.get(handle);\n\n if (refFromMap !== undefined) {\n return refFromMap;\n }\n\n const newRef = shallowRef<FileContentData>();\n refsMap.set(handle, newRef);\n\n // Initiating actual fetch from the cache, that will in turn initiate upload\n (async () => {\n const maxRetries = 8;\n const retryDelay = 1000; // 1 second\n\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n try {\n const data = await this.doFetch(handle);\n newRef.value = data;\n return;\n } catch (err: unknown) {\n console.error(`File download attempt ${attempt + 1}/${maxRetries} failed:`, err);\n\n if (attempt < maxRetries - 1) {\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n } else {\n console.error(`Failed to download file after ${maxRetries} attempts`);\n }\n }\n }\n })();\n\n return newRef;\n }\n\n public getContentBytes(handle: FileHandle): ComputedRef<Uint8Array | undefined>;\n public getContentBytes(\n handle: FileHandle | undefined,\n ): ComputedRef<Uint8Array | undefined> | undefined;\n public getContentBytes(\n handle: FileHandle | undefined,\n ): ComputedRef<Uint8Array | undefined> | undefined {\n if (handle === undefined) return undefined;\n const dataRef = this.getDataRef(handle);\n return computed(() => dataRef.value?.bytes);\n }\n\n public getContentString(handle: FileHandle): ComputedRef<string | undefined>;\n public getContentString(\n handle: FileHandle | undefined,\n ): ComputedRef<string | undefined> | undefined;\n public getContentString(\n handle: FileHandle | undefined,\n ): ComputedRef<string | undefined> | undefined {\n if (handle === undefined) return undefined;\n const dataRef = this.getDataRef(handle);\n return computed(() => dataRef.value?.str);\n }\n\n public getContentJson<T>(handle: FileHandle, schema: ZodSchema<T>): ComputedRef<T | undefined>;\n public getContentJson<T>(\n handle: FileHandle | undefined,\n schema: ZodSchema<T>,\n ): ComputedRef<T | undefined> | undefined;\n public getContentJson<T = unknown>(handle: FileHandle): ComputedRef<T | undefined>;\n public getContentJson<T = unknown>(\n handle: FileHandle | undefined,\n ): ComputedRef<T | undefined> | undefined;\n public getContentJson<T>(\n handle: FileHandle | undefined,\n schema?: ZodSchema<T>,\n ): ComputedRef<T | undefined> | undefined;\n public getContentJson<T>(\n handle: FileHandle | undefined,\n schema?: ZodSchema<T>,\n ): ComputedRef<T | undefined> | undefined {\n if (handle === undefined) return undefined;\n const dataRef = this.getDataRef(handle);\n return computed(\n () =>\n (schema === undefined ? dataRef.value?.rawJson : dataRef.value?.validatedJson(schema)) as T,\n );\n }\n\n private static initScope(_scope: EffectScope | undefined) {\n let scope = getCurrentScope() ?? _scope;\n\n if (!scope) {\n console.warn(\"Current scope not found, using new detached scope...\");\n scope = effectScope(true);\n }\n\n addScope(scope);\n\n onScopeDispose(() => {\n scopes.delete(scope);\n });\n\n return scope;\n }\n\n /**\n * Creates a ReactiveFileContent instance with isolated cache and fetcher.\n * Use this when you need component-specific caching.\n *\n * @example\n * ```ts\n * import { ReactiveFileContent } from '@platforma-sdk/ui-vue';\n * import { computed } from 'vue';\n *\n * const fileContent = ReactiveFileContent.use();\n *\n * const processedData = computed(() => {\n * const content = fileContent.getContentString(fileHandle).value;\n * return content?.split('\\n').length ?? 0;\n * });\n * ```\n */\n public static use(_ops?: Partial<ReactiveFileContentOps>, _scope?: EffectScope) {\n const scope = this.initScope(_scope);\n\n return new ReactiveFileContent(scope, { ..._ops });\n }\n\n /**\n * Creates a ReactiveFileContent instance with globally shared cache and fetcher.\n * Use this to share file content cache across multiple components.\n *\n * @example\n * ```ts\n * import { ReactiveFileContent } from '@platforma-sdk/ui-vue';\n * import { computed } from 'vue';\n *\n * const fileContent = ReactiveFileContent.useGlobal();\n *\n * const combinedData = computed(() => {\n * const data1 = fileContent.getContentJson(handle1).value;\n * const data2 = fileContent.getContentJson(handle2).value;\n * return { data1, data2 };\n * });\n * ```\n */\n public static useGlobal(_ops?: Partial<ReactiveFileContentOps>, _scope?: EffectScope) {\n const scope = this.initScope(_scope);\n\n return new ReactiveFileContent(scope, {\n ..._ops,\n lruCache: globalCache,\n fetcher: globalFetcher,\n });\n }\n}\n"],"mappings":";;;;;;AAiBA,IAAM,IAAwD,EAC5D,WAAW,MACZ,EAEK,IAAN,MAAsB;CACpB,OAAmC,KAAA;CACnC,WAAwC,KAAA;CACxC,aAA4C,KAAA;CAC5C,iBAA4E,KAAA;CAE5E,YAAY,GAAmC;AAAnB,OAAA,QAAA;;CAE5B,IAAW,MAAc;AAEvB,SADI,KAAK,SAAS,KAAA,MAAW,KAAK,OAAO,IAAI,aAAa,CAAC,OAAO,KAAK,MAAM,G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AA,EAAW;EAC1B,IAAM,IAAU,KAAK,WAAW,EAAO;AACvC,SAAO,QAAe,EAAQ,OAAO,MAAM;;CAO7C,iBACE,GAC6C;AAC7C,MAAI,MAAW,KAAA,EAAW;EAC1B,IAAM,IAAU,KAAK,WAAW,EAAO;AACvC,SAAO,QAAe,EAAQ,OAAO,IAAI;;CAgB3C,eACE,GACA,GACwC;AACxC,MAAI,MAAW,KAAA,EAAW;EAC1B,IAAM,IAAU,KAAK,WAAW,EAAO;AACvC,SAAO,QAEF,MAAW,KAAA,IAAY,EAAQ,OAAO,UAAU,EAAQ,OAAO,cAAc,EAAO,CACxF;;CAGH,OAAe,UAAU,GAAiC;EACxD,IAAI,IAAQ,GAAiB,IAAI;AAajC,SAXA,AAEE,OADA,QAAQ,KAAK,uDAAuD,EAC5D,EAAY,GAAK,GAG3B,EAAS,EAAM,EAEf,QAAqB;AACnB,KAAO,OAAO,EAAM;IACpB,EAEK;;CAoBT,OAAc,IAAI,GAAwC,GAAsB;AAG9E,SAAO,IAAI,EAFG,KAAK,UAAU,EAAO,EAEE,EAAE,GAAG,GAAM,CAAC;;CAqBpD,OAAc,UAAU,GAAwC,GAAsB;AAGpF,SAAO,IAAI,EAFG,KAAK,UAAU,EAAO,EAEE;GACpC,GAAG;GACH,UAAU;GACV,SAAS;GACV,CAAC"}
|
package/dist/computedResult.js
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
import { wrapOptionalResult as e } from "./utils.js";
|
|
2
2
|
import { computed as t } from "vue";
|
|
3
3
|
import { ensureErrorLike as n } from "@platforma-sdk/model";
|
|
4
|
-
|
|
5
|
-
* Creates a computed reference that wraps the result of a getter function in an `OptionalResult` object.
|
|
6
|
-
* This wrapper provides error handling, ensuring that if an error occurs during the computation of the result,
|
|
7
|
-
* the error is captured and included in the `OptionalResult` instead of throwing the error.
|
|
8
|
-
*
|
|
9
|
-
* @template V - The type of the value returned by the getter function.
|
|
10
|
-
*
|
|
11
|
-
* @param {ComputedGetter<V>} getter - A function that returns a value of type `V`. This function is executed inside
|
|
12
|
-
* the computed reference and its result is wrapped in an `OptionalResult`.
|
|
13
|
-
*
|
|
14
|
-
* @returns {ComputedRef<OptionalResult<V>>} - A computed reference containing the result of the getter function
|
|
15
|
-
* wrapped in an `OptionalResult`. If the getter function executes successfully, the `value` property of the `OptionalResult`
|
|
16
|
-
* will contain the result. If an error occurs, the `errors` property will contain the error message, and `value` will be `undefined`.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const myGetter = () => {
|
|
20
|
-
* if (someCondition) {
|
|
21
|
-
* throw new Error('An error occurred');
|
|
22
|
-
* }
|
|
23
|
-
* return 'Success';
|
|
24
|
-
* };
|
|
25
|
-
*
|
|
26
|
-
* const myComputedResult = computedResult(myGetter);
|
|
27
|
-
*
|
|
28
|
-
* // If someCondition is true:
|
|
29
|
-
* // myComputedResult.value will be { errors: ['An error occurred'], value: undefined }
|
|
30
|
-
*
|
|
31
|
-
* // If someCondition is false:
|
|
32
|
-
* // myComputedResult.value will be { errors: undefined, value: 'Success' }
|
|
33
|
-
*/
|
|
4
|
+
//#region src/computedResult.ts
|
|
34
5
|
function r(r) {
|
|
35
6
|
return t(() => {
|
|
36
7
|
try {
|
|
@@ -43,6 +14,7 @@ function r(r) {
|
|
|
43
14
|
}
|
|
44
15
|
});
|
|
45
16
|
}
|
|
17
|
+
//#endregion
|
|
46
18
|
export { r as computedResult };
|
|
47
19
|
|
|
48
20
|
//# sourceMappingURL=computedResult.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedResult.js","names":[],"sources":["../src/computedResult.ts"],"sourcesContent":["import type { ComputedRef } from \"vue\";\nimport { computed, type ComputedGetter } from \"vue\";\nimport type { OptionalResult } from \"./types\";\nimport { wrapOptionalResult } from \"./utils\";\nimport { ensureErrorLike } from \"@platforma-sdk/model\";\n\n/**\n * Creates a computed reference that wraps the result of a getter function in an `OptionalResult` object.\n * This wrapper provides error handling, ensuring that if an error occurs during the computation of the result,\n * the error is captured and included in the `OptionalResult` instead of throwing the error.\n *\n * @template V - The type of the value returned by the getter function.\n *\n * @param {ComputedGetter<V>} getter - A function that returns a value of type `V`. This function is executed inside\n * the computed reference and its result is wrapped in an `OptionalResult`.\n *\n * @returns {ComputedRef<OptionalResult<V>>} - A computed reference containing the result of the getter function\n * wrapped in an `OptionalResult`. If the getter function executes successfully, the `value` property of the `OptionalResult`\n * will contain the result. If an error occurs, the `errors` property will contain the error message, and `value` will be `undefined`.\n *\n * @example\n * const myGetter = () => {\n * if (someCondition) {\n * throw new Error('An error occurred');\n * }\n * return 'Success';\n * };\n *\n * const myComputedResult = computedResult(myGetter);\n *\n * // If someCondition is true:\n * // myComputedResult.value will be { errors: ['An error occurred'], value: undefined }\n *\n * // If someCondition is false:\n * // myComputedResult.value will be { errors: undefined, value: 'Success' }\n */\nexport function computedResult<V>(getter: ComputedGetter<V>): ComputedRef<OptionalResult<V>> {\n return computed(() => {\n try {\n return wrapOptionalResult(getter());\n } catch (err) {\n return {\n errors: [ensureErrorLike(err)],\n value: undefined,\n };\n }\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"computedResult.js","names":[],"sources":["../src/computedResult.ts"],"sourcesContent":["import type { ComputedRef } from \"vue\";\nimport { computed, type ComputedGetter } from \"vue\";\nimport type { OptionalResult } from \"./types\";\nimport { wrapOptionalResult } from \"./utils\";\nimport { ensureErrorLike } from \"@platforma-sdk/model\";\n\n/**\n * Creates a computed reference that wraps the result of a getter function in an `OptionalResult` object.\n * This wrapper provides error handling, ensuring that if an error occurs during the computation of the result,\n * the error is captured and included in the `OptionalResult` instead of throwing the error.\n *\n * @template V - The type of the value returned by the getter function.\n *\n * @param {ComputedGetter<V>} getter - A function that returns a value of type `V`. This function is executed inside\n * the computed reference and its result is wrapped in an `OptionalResult`.\n *\n * @returns {ComputedRef<OptionalResult<V>>} - A computed reference containing the result of the getter function\n * wrapped in an `OptionalResult`. If the getter function executes successfully, the `value` property of the `OptionalResult`\n * will contain the result. If an error occurs, the `errors` property will contain the error message, and `value` will be `undefined`.\n *\n * @example\n * const myGetter = () => {\n * if (someCondition) {\n * throw new Error('An error occurred');\n * }\n * return 'Success';\n * };\n *\n * const myComputedResult = computedResult(myGetter);\n *\n * // If someCondition is true:\n * // myComputedResult.value will be { errors: ['An error occurred'], value: undefined }\n *\n * // If someCondition is false:\n * // myComputedResult.value will be { errors: undefined, value: 'Success' }\n */\nexport function computedResult<V>(getter: ComputedGetter<V>): ComputedRef<OptionalResult<V>> {\n return computed(() => {\n try {\n return wrapOptionalResult(getter());\n } catch (err) {\n return {\n errors: [ensureErrorLike(err)],\n value: undefined,\n };\n }\n });\n}\n"],"mappings":";;;;AAoCA,SAAgB,EAAkB,GAA2D;AAC3F,QAAO,QAAe;AACpB,MAAI;AACF,UAAO,EAAmB,GAAQ,CAAC;WAC5B,GAAK;AACZ,UAAO;IACL,QAAQ,CAAC,EAAgB,EAAI,CAAC;IAC9B,OAAO,KAAA;IACR;;GAEH"}
|
package/dist/createModel.js
CHANGED
|
@@ -2,6 +2,7 @@ import { deepClone as e, isJsonEqual as t } from "./lib/util/helpers/dist/object
|
|
|
2
2
|
import "./lib/util/helpers/dist/index.js";
|
|
3
3
|
import { ensureError as n, formatZodError as r, identity as i, isZodError as a } from "./utils.js";
|
|
4
4
|
import { computed as o, reactive as s, ref as c, unref as l, watch as u } from "vue";
|
|
5
|
+
//#region src/createModel.ts
|
|
5
6
|
function d(d) {
|
|
6
7
|
let f = d.validate ?? i, { autoSave: p } = d, m = c(), h = c(), g = (t) => {
|
|
7
8
|
h.value = { model: e(t) };
|
|
@@ -40,6 +41,7 @@ function d(d) {
|
|
|
40
41
|
setError: y
|
|
41
42
|
});
|
|
42
43
|
}
|
|
44
|
+
//#endregion
|
|
43
45
|
export { d as createModel };
|
|
44
46
|
|
|
45
47
|
//# sourceMappingURL=createModel.js.map
|
package/dist/createModel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModel.js","names":[],"sources":["../src/createModel.ts"],"sourcesContent":["import { reactive, computed, ref, watch, unref } from \"vue\";\nimport type { ModelOptions, Model } from \"./types\";\nimport { deepClone, isJsonEqual } from \"@milaboratories/helpers\";\nimport { identity, ensureError, isZodError, formatZodError } from \"./utils\";\n\nexport function createModel<M, V = unknown>(options: ModelOptions<M, V>): Model<M> {\n const validate = options.validate ?? identity;\n\n const { autoSave } = options;\n\n const error = ref<Error | undefined>();\n\n const local = ref<{ model: M }>();\n\n const setSource = (v: M) => {\n local.value = {\n model: deepClone(v),\n };\n };\n\n watch(\n () => options.get(),\n (v) => setSource(v),\n { immediate: true },\n );\n\n const save = () => {\n options.onSave(validate(deepClone(local.value?.model)));\n };\n\n const revert = () => {\n setSource(options.get());\n error.value = undefined;\n };\n\n const setError = (cause: unknown) => {\n const err = ensureError(cause);\n if (isZodError(err)) {\n error.value = Error(formatZodError(err)); // @todo temp\n } else {\n error.value = err;\n }\n };\n\n const setValue = (v: M) => {\n error.value = undefined;\n try {\n validate(v);\n if (autoSave) {\n save();\n }\n } catch (cause: unknown) {\n setError(cause);\n }\n };\n\n const model = computed<M>({\n get: () => {\n return local.value?.model as M;\n },\n set(v) {\n setSource(v);\n setValue(v);\n },\n });\n\n watch(\n local,\n (n, o) => {\n if (n && n === o) {\n setValue(n.model);\n }\n },\n { deep: true },\n );\n\n const valid = computed(() => !error.value);\n\n const isChanged = computed(() => {\n return !isJsonEqual(options.get(), unref(local));\n });\n\n const errorString = computed(() => (error.value ? error.value.message : \"\"));\n\n return reactive({\n model,\n valid,\n isChanged,\n error,\n errorString,\n save,\n revert,\n setError,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createModel.js","names":[],"sources":["../src/createModel.ts"],"sourcesContent":["import { reactive, computed, ref, watch, unref } from \"vue\";\nimport type { ModelOptions, Model } from \"./types\";\nimport { deepClone, isJsonEqual } from \"@milaboratories/helpers\";\nimport { identity, ensureError, isZodError, formatZodError } from \"./utils\";\n\nexport function createModel<M, V = unknown>(options: ModelOptions<M, V>): Model<M> {\n const validate = options.validate ?? identity;\n\n const { autoSave } = options;\n\n const error = ref<Error | undefined>();\n\n const local = ref<{ model: M }>();\n\n const setSource = (v: M) => {\n local.value = {\n model: deepClone(v),\n };\n };\n\n watch(\n () => options.get(),\n (v) => setSource(v),\n { immediate: true },\n );\n\n const save = () => {\n options.onSave(validate(deepClone(local.value?.model)));\n };\n\n const revert = () => {\n setSource(options.get());\n error.value = undefined;\n };\n\n const setError = (cause: unknown) => {\n const err = ensureError(cause);\n if (isZodError(err)) {\n error.value = Error(formatZodError(err)); // @todo temp\n } else {\n error.value = err;\n }\n };\n\n const setValue = (v: M) => {\n error.value = undefined;\n try {\n validate(v);\n if (autoSave) {\n save();\n }\n } catch (cause: unknown) {\n setError(cause);\n }\n };\n\n const model = computed<M>({\n get: () => {\n return local.value?.model as M;\n },\n set(v) {\n setSource(v);\n setValue(v);\n },\n });\n\n watch(\n local,\n (n, o) => {\n if (n && n === o) {\n setValue(n.model);\n }\n },\n { deep: true },\n );\n\n const valid = computed(() => !error.value);\n\n const isChanged = computed(() => {\n return !isJsonEqual(options.get(), unref(local));\n });\n\n const errorString = computed(() => (error.value ? error.value.message : \"\"));\n\n return reactive({\n model,\n valid,\n isChanged,\n error,\n errorString,\n save,\n revert,\n setError,\n });\n}\n"],"mappings":";;;;;AAKA,SAAgB,EAA4B,GAAuC;CACjF,IAAM,IAAW,EAAQ,YAAY,GAE/B,EAAE,gBAAa,GAEf,IAAQ,GAAwB,EAEhC,IAAQ,GAAmB,EAE3B,KAAa,MAAS;AAC1B,IAAM,QAAQ,EACZ,OAAO,EAAU,EAAE,EACpB;;AAGH,SACQ,EAAQ,KAAK,GAClB,MAAM,EAAU,EAAE,EACnB,EAAE,WAAW,IAAM,CACpB;CAED,IAAM,UAAa;AACjB,IAAQ,OAAO,EAAS,EAAU,EAAM,OAAO,MAAM,CAAC,CAAC;IAGnD,UAAe;AAEnB,EADA,EAAU,EAAQ,KAAK,CAAC,EACxB,EAAM,QAAQ,KAAA;IAGV,KAAY,MAAmB;EACnC,IAAM,IAAM,EAAY,EAAM;AAC9B,EAAI,EAAW,EAAI,GACjB,EAAM,QAAQ,MAAM,EAAe,EAAI,CAAC,GAExC,EAAM,QAAQ;IAIZ,KAAY,MAAS;AACzB,IAAM,QAAQ,KAAA;AACd,MAAI;AAEF,GADA,EAAS,EAAE,EACP,KACF,GAAM;WAED,GAAgB;AACvB,KAAS,EAAM;;IAIb,IAAQ,EAAY;EACxB,WACS,EAAM,OAAO;EAEtB,IAAI,GAAG;AAEL,GADA,EAAU,EAAE,EACZ,EAAS,EAAE;;EAEd,CAAC;AAoBF,QAlBA,EACE,IACC,GAAG,MAAM;AACR,EAAI,KAAK,MAAM,KACb,EAAS,EAAE,MAAM;IAGrB,EAAE,MAAM,IAAM,CACf,EAUM,EAAS;EACd;EACA,OAVY,QAAe,CAAC,EAAM,MAAM;EAWxC,WATgB,QACT,CAAC,EAAY,EAAQ,KAAK,EAAE,EAAM,EAAM,CAAC,CAChD;EAQA;EACA,aAPkB,QAAgB,EAAM,QAAQ,EAAM,MAAM,UAAU,GAAI;EAQ1E;EACA;EACA;EACD,CAAC"}
|
package/dist/defineApp.js
CHANGED
|
@@ -5,8 +5,8 @@ import { createAppV2 as n } from "./internal/createAppV2.js";
|
|
|
5
5
|
import { createAppV3 as r } from "./internal/createAppV3.js";
|
|
6
6
|
import { inject as i, markRaw as a, reactive as o } from "vue";
|
|
7
7
|
import { getPlatformaApiVersion as s, unwrapResult as c } from "@platforma-sdk/model";
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
//#region src/defineApp.ts
|
|
9
|
+
var l = Symbol("sdk-vue"), u = Symbol("plugin-data-access");
|
|
10
10
|
function d() {
|
|
11
11
|
return i(l);
|
|
12
12
|
}
|
|
@@ -87,6 +87,7 @@ function m(t, n, i = {}) {
|
|
|
87
87
|
});
|
|
88
88
|
return h;
|
|
89
89
|
}
|
|
90
|
+
//#endregion
|
|
90
91
|
export { p as defineApp, m as defineAppV3, u as pluginDataKey, f as useFeatureFlags, d as useSdkPlugin };
|
|
91
92
|
|
|
92
93
|
//# sourceMappingURL=defineApp.js.map
|
package/dist/defineApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineApp.js","names":[],"sources":["../src/defineApp.ts"],"sourcesContent":["import { notEmpty } from \"@milaboratories/helpers\";\nimport type {\n PlatformaExtended,\n PlatformaV3,\n PlatformaV1,\n PlatformaV2,\n BlockCodeKnownFeatureFlags,\n UiServices as AllUiServices,\n} from \"@platforma-sdk/model\";\nimport {\n getPlatformaApiVersion,\n unwrapResult,\n type BlockOutputsBase,\n type BlockModelInfo,\n} from \"@platforma-sdk/model\";\nimport type { App as VueApp, Component, Reactive } from \"vue\";\nimport { inject, markRaw, reactive } from \"vue\";\nimport { createAppV1, type BaseAppV1 } from \"./internal/createAppV1\";\nimport { createAppV2, type BaseAppV2 } from \"./internal/createAppV2\";\nimport { createAppV3, type BaseAppV3 } from \"./internal/createAppV3\";\nimport type { AppSettings, ExtendSettings, Routes } from \"./types\";\n\nconst pluginKey = Symbol(\"sdk-vue\");\nexport const pluginDataKey = Symbol(\"plugin-data-access\");\n\nexport function useSdkPlugin(): SdkPlugin {\n return inject(pluginKey)!;\n}\n\nexport function useFeatureFlags() {\n const sdk = useSdkPlugin();\n return sdk.featureFlags;\n}\n\nexport function defineApp<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaV1<Args, Outputs, UiState, Href> & {\n blockModelInfo: BlockModelInfo;\n },\n extendApp: (app: BaseAppV1<Args, Outputs, UiState, Href>) => Extend,\n settings?: AppSettings,\n): SdkPluginV1<Args, Outputs, UiState, Href, Extend>;\n\nexport function defineApp<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaV2<Args, Outputs, UiState, Href> & {\n blockModelInfo: BlockModelInfo;\n },\n extendApp: (app: BaseAppV2<Args, Outputs, UiState, Href>) => Extend,\n settings?: AppSettings,\n): SdkPluginV2<Args, Outputs, UiState, Href, Extend>;\n\nexport function defineApp<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaExtended<\n PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href>\n >,\n\n //\n extendApp: (app: any) => Extend,\n settings: AppSettings = {},\n):\n | SdkPluginV1<Args, Outputs, UiState, Href, Extend>\n | SdkPluginV2<Args, Outputs, UiState, Href, Extend> {\n let app:\n | AppV1<Args, Outputs, UiState, Href, Extend>\n | AppV2<Args, Outputs, UiState, Href, Extend>\n | undefined = undefined;\n\n const runtimeApiVersion = platforma.apiVersion ?? 1; // undefined means 1 (backward compatibility)\n const blockRequestedApiVersion = getPlatformaApiVersion();\n\n const loadApp = async () => {\n if (blockRequestedApiVersion !== runtimeApiVersion) {\n throw new Error(`Block requested API version ${blockRequestedApiVersion} but runtime API version is ${runtimeApiVersion}.\n Please update the desktop app to use the latest API version.`);\n }\n\n if (platforma.apiVersion === undefined || platforma.apiVersion === 1) {\n await platforma.loadBlockState().then((state) => {\n plugin.loaded = true;\n const baseApp = createAppV1<Args, Outputs, UiState, Href>(state, platforma, settings);\n\n const localState = extendApp(baseApp);\n\n const routes = Object.fromEntries(\n Object.entries(localState.routes as Routes<Href>).map(([href, component]) => {\n const c = typeof component === \"function\" ? component() : component;\n return [href, markRaw(c as Component)];\n }),\n );\n\n app = Object.assign(baseApp, {\n ...localState,\n getRoute(href: Href): Component | undefined {\n return routes[href];\n },\n } as unknown as AppV1<Args, Outputs, UiState, Href, Extend>);\n });\n } else if (platforma.apiVersion === 2) {\n await platforma.loadBlockState().then((stateOrError) => {\n const state = unwrapResult(stateOrError);\n plugin.loaded = true;\n const baseApp = createAppV2<Args, Outputs, UiState, Href>(state, platforma, settings);\n\n const localState = extendApp(baseApp);\n\n const routes = Object.fromEntries(\n Object.entries(localState.routes as Routes<Href>).map(([href, component]) => {\n const c = typeof component === \"function\" ? component() : component;\n return [href, markRaw(c as Component)];\n }),\n );\n\n app = Object.assign(baseApp, {\n ...localState,\n getRoute(href: Href): Component | undefined {\n return routes[href];\n },\n } as unknown as AppV2<Args, Outputs, UiState, Href, Extend>);\n });\n }\n };\n\n const plugin = reactive({\n apiVersion: platforma.apiVersion ?? 1,\n featureFlags: platforma.blockModelInfo.featureFlags,\n loaded: false,\n error: undefined as unknown,\n useApp<PageHref extends Href = Href>() {\n return notEmpty(app, \"App is not loaded\") as\n | AppV1<Args, Outputs, UiState, PageHref, Extend>\n | AppV2<Args, Outputs, UiState, PageHref, Extend>;\n },\n install(app: VueApp) {\n app.provide(pluginKey, this);\n loadApp().catch((err) => {\n console.error(\"load initial state error\", err);\n plugin.error = err;\n });\n },\n });\n\n return plugin as\n | SdkPluginV1<Args, Outputs, UiState, Href, Extend>\n | SdkPluginV2<Args, Outputs, UiState, Href, Extend>;\n}\n\nexport function defineAppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n Plugins extends Record<string, unknown> = Record<string, unknown>,\n UiServices extends Partial<AllUiServices> = Partial<AllUiServices>,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaV3<Data, Args, Outputs, Href, Plugins, UiServices> & {\n blockModelInfo: BlockModelInfo;\n },\n extendApp: (app: BaseAppV3<Data, Args, Outputs, Href, Plugins, UiServices>) => Extend,\n settings: AppSettings = {},\n): SdkPluginV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices> {\n let app: AppV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices> | undefined = undefined;\n\n // Captured during install() so V3 can provide plugin data access after async load\n let vueAppInstance: VueApp | undefined;\n\n const runtimeApiVersion = 3;\n const blockRequestedApiVersion = getPlatformaApiVersion();\n\n const loadApp = async () => {\n if (blockRequestedApiVersion !== runtimeApiVersion) {\n throw new Error(`Block requested API version ${blockRequestedApiVersion} but runtime API version is ${runtimeApiVersion}.\n Please update the desktop app to use the latest API version.`);\n }\n\n await platforma.loadBlockState().then((stateOrError) => {\n const state = unwrapResult(stateOrError);\n plugin.loaded = true;\n const { app: baseApp, pluginAccess } = createAppV3<\n Data,\n Args,\n Outputs,\n Href,\n Plugins,\n UiServices\n >(state, platforma, settings);\n\n if (!vueAppInstance) {\n throw new Error(\n \"Plugin data injection failed: Vue app instance not captured during install()\",\n );\n }\n vueAppInstance.provide(pluginDataKey, pluginAccess);\n\n const localState = extendApp(baseApp);\n\n const routes = Object.fromEntries(\n Object.entries(localState.routes as Routes<Href>).map(([href, component]) => {\n const c = typeof component === \"function\" ? component() : component;\n return [href, markRaw(c as Component)];\n }),\n );\n\n app = Object.assign(baseApp, {\n ...localState,\n getRoute(href: Href): Component | undefined {\n return routes[href];\n },\n } as AppV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices>);\n });\n };\n\n const plugin = reactive({\n apiVersion: 3,\n featureFlags: platforma.blockModelInfo.featureFlags,\n loaded: false,\n error: undefined,\n useApp<PageHref extends Href = Href>() {\n return notEmpty(app, \"App is not loaded\") as AppV3<\n Data,\n Args,\n Outputs,\n PageHref,\n Plugins,\n Extend,\n UiServices\n >;\n },\n install(app: VueApp) {\n vueAppInstance = app;\n app.provide(pluginKey, this);\n loadApp().catch((err) => {\n console.error(\"load initial state error\", err);\n plugin.error = err;\n });\n },\n });\n\n return plugin as SdkPluginV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices>;\n}\n\nexport type AppV1<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = BaseAppV1<Args, Outputs, UiState, Href> &\n Reactive<Omit<Local, \"routes\">> & { getRoute(href: Href): Component | undefined };\n\nexport type AppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = BaseAppV2<Args, Outputs, UiState, Href> &\n Reactive<Omit<Local, \"routes\">> & { getRoute(href: Href): Component | undefined };\n\nexport type AppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = NonNullable<unknown>,\n Href extends `/${string}` = `/${string}`,\n Plugins extends Record<string, unknown> = Record<string, unknown>,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n UiServices extends Partial<AllUiServices> = Partial<AllUiServices>,\n> = BaseAppV3<Data, Args, Outputs, Href, Plugins, UiServices> &\n Reactive<Omit<Local, \"routes\">> & { getRoute(href: Href): Component | undefined };\n\n// ---------------------------------------------------------------------------\n// SdkPlugin types\n// ---------------------------------------------------------------------------\n\nexport type SdkPluginV1<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = {\n apiVersion: 1;\n featureFlags: BlockCodeKnownFeatureFlags;\n loaded: boolean;\n error: unknown;\n useApp<PageHref extends Href = Href>(): AppV1<Args, Outputs, UiState, PageHref, Local>;\n install(app: VueApp): void;\n};\n\nexport type SdkPluginV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = {\n apiVersion: 2;\n featureFlags: BlockCodeKnownFeatureFlags;\n loaded: boolean;\n error: unknown;\n useApp<PageHref extends Href = Href>(): AppV2<Args, Outputs, UiState, PageHref, Local>;\n install(app: VueApp): void;\n};\n\nexport type SdkPluginV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n Plugins extends Record<string, unknown> = Record<string, unknown>,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n UiServices extends Partial<AllUiServices> = Partial<AllUiServices>,\n> = {\n apiVersion: 3;\n featureFlags: BlockCodeKnownFeatureFlags;\n loaded: boolean;\n error: unknown;\n useApp<PageHref extends Href = Href>(): AppV3<\n Data,\n Args,\n Outputs,\n PageHref,\n Plugins,\n Local,\n UiServices\n >;\n install(app: VueApp): void;\n};\n\nexport type SdkPlugin = SdkPluginV1 | SdkPluginV2 | SdkPluginV3;\n"],"mappings":";;;;;;;AAsBA,IAAM,IAAY,OAAO,UAAU;AACnC,MAAa,IAAgB,OAAO,qBAAqB;AAEzD,SAAgB,IAA0B;AACxC,QAAO,EAAO,EAAU;;AAG1B,SAAgB,IAAkB;AAEhC,QADY,GAAc,CACf;;AA+Bb,SAAgB,EAOd,GAKA,GACA,IAAwB,EAAE,EAG0B;CACpD,IAAI,GAKE,IAAoB,EAAU,cAAc,GAC5C,IAA2B,GAAwB,EAEnD,IAAU,YAAY;AAC1B,MAAI,MAA6B,EAC/B,OAAU,MAAM,+BAA+B,EAAyB,8BAA8B,EAAkB;oEAC1D;AAGhE,EAAI,EAAU,eAAe,KAAA,KAAa,EAAU,eAAe,IACjE,MAAM,EAAU,gBAAgB,CAAC,MAAM,MAAU;AAC/C,KAAO,SAAS;GAChB,IAAM,IAAU,EAA0C,GAAO,GAAW,EAAS,EAE/E,IAAa,EAAU,EAAQ,EAE/B,IAAS,OAAO,YACpB,OAAO,QAAQ,EAAW,OAAuB,CAAC,KAAK,CAAC,GAAM,OAErD,CAAC,GAAM,EADJ,OAAO,KAAc,aAAa,GAAW,GAAG,EACrB,CAAC,CACtC,C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ACD;AAEH,KAAe,QAAQ,GAAe,EAAa;GAEnD,IAAM,IAAa,EAAU,EAAQ,EAE/B,IAAS,OAAO,YACpB,OAAO,QAAQ,EAAW,OAAuB,CAAC,KAAK,CAAC,GAAM,OAErD,CAAC,GAAM,EADJ,OAAO,KAAc,aAAa,GAAW,GAAG,EACrB,CAAC,CACtC,CACH;AAED,OAAM,OAAO,OAAO,GAAS;IAC3B,GAAG;IACH,SAAS,GAAmC;AAC1C,YAAO,EAAO;;IAEjB,CAAkE;IACnE;IAGE,IAAS,EAAS;EACtB,YAAY;EACZ,cAAc,EAAU,eAAe;EACvC,QAAQ;EACR,OAAO,KAAA;EACP,SAAuC;AACrC,UAAO,EAAS,GAAK,oBAAoB;;EAU3C,QAAQ,GAAa;AAGnB,GAFA,IAAiB,GACjB,EAAI,QAAQ,GAAW,KAAK,EAC5B,GAAS,CAAC,OAAO,MAAQ;AAEvB,IADA,QAAQ,MAAM,4BAA4B,EAAI,EAC9C,EAAO,QAAQ;KACf;;EAEL,CAAC;AAEF,QAAO"}
|
|
1
|
+
{"version":3,"file":"defineApp.js","names":[],"sources":["../src/defineApp.ts"],"sourcesContent":["import { notEmpty } from \"@milaboratories/helpers\";\nimport type {\n PlatformaExtended,\n PlatformaV3,\n PlatformaV1,\n PlatformaV2,\n BlockCodeKnownFeatureFlags,\n UiServices as AllUiServices,\n} from \"@platforma-sdk/model\";\nimport {\n getPlatformaApiVersion,\n unwrapResult,\n type BlockOutputsBase,\n type BlockModelInfo,\n} from \"@platforma-sdk/model\";\nimport type { App as VueApp, Component, Reactive } from \"vue\";\nimport { inject, markRaw, reactive } from \"vue\";\nimport { createAppV1, type BaseAppV1 } from \"./internal/createAppV1\";\nimport { createAppV2, type BaseAppV2 } from \"./internal/createAppV2\";\nimport { createAppV3, type BaseAppV3 } from \"./internal/createAppV3\";\nimport type { AppSettings, ExtendSettings, Routes } from \"./types\";\n\nconst pluginKey = Symbol(\"sdk-vue\");\nexport const pluginDataKey = Symbol(\"plugin-data-access\");\n\nexport function useSdkPlugin(): SdkPlugin {\n return inject(pluginKey)!;\n}\n\nexport function useFeatureFlags() {\n const sdk = useSdkPlugin();\n return sdk.featureFlags;\n}\n\nexport function defineApp<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaV1<Args, Outputs, UiState, Href> & {\n blockModelInfo: BlockModelInfo;\n },\n extendApp: (app: BaseAppV1<Args, Outputs, UiState, Href>) => Extend,\n settings?: AppSettings,\n): SdkPluginV1<Args, Outputs, UiState, Href, Extend>;\n\nexport function defineApp<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaV2<Args, Outputs, UiState, Href> & {\n blockModelInfo: BlockModelInfo;\n },\n extendApp: (app: BaseAppV2<Args, Outputs, UiState, Href>) => Extend,\n settings?: AppSettings,\n): SdkPluginV2<Args, Outputs, UiState, Href, Extend>;\n\nexport function defineApp<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaExtended<\n PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href>\n >,\n\n //\n extendApp: (app: any) => Extend,\n settings: AppSettings = {},\n):\n | SdkPluginV1<Args, Outputs, UiState, Href, Extend>\n | SdkPluginV2<Args, Outputs, UiState, Href, Extend> {\n let app:\n | AppV1<Args, Outputs, UiState, Href, Extend>\n | AppV2<Args, Outputs, UiState, Href, Extend>\n | undefined = undefined;\n\n const runtimeApiVersion = platforma.apiVersion ?? 1; // undefined means 1 (backward compatibility)\n const blockRequestedApiVersion = getPlatformaApiVersion();\n\n const loadApp = async () => {\n if (blockRequestedApiVersion !== runtimeApiVersion) {\n throw new Error(`Block requested API version ${blockRequestedApiVersion} but runtime API version is ${runtimeApiVersion}.\n Please update the desktop app to use the latest API version.`);\n }\n\n if (platforma.apiVersion === undefined || platforma.apiVersion === 1) {\n await platforma.loadBlockState().then((state) => {\n plugin.loaded = true;\n const baseApp = createAppV1<Args, Outputs, UiState, Href>(state, platforma, settings);\n\n const localState = extendApp(baseApp);\n\n const routes = Object.fromEntries(\n Object.entries(localState.routes as Routes<Href>).map(([href, component]) => {\n const c = typeof component === \"function\" ? component() : component;\n return [href, markRaw(c as Component)];\n }),\n );\n\n app = Object.assign(baseApp, {\n ...localState,\n getRoute(href: Href): Component | undefined {\n return routes[href];\n },\n } as unknown as AppV1<Args, Outputs, UiState, Href, Extend>);\n });\n } else if (platforma.apiVersion === 2) {\n await platforma.loadBlockState().then((stateOrError) => {\n const state = unwrapResult(stateOrError);\n plugin.loaded = true;\n const baseApp = createAppV2<Args, Outputs, UiState, Href>(state, platforma, settings);\n\n const localState = extendApp(baseApp);\n\n const routes = Object.fromEntries(\n Object.entries(localState.routes as Routes<Href>).map(([href, component]) => {\n const c = typeof component === \"function\" ? component() : component;\n return [href, markRaw(c as Component)];\n }),\n );\n\n app = Object.assign(baseApp, {\n ...localState,\n getRoute(href: Href): Component | undefined {\n return routes[href];\n },\n } as unknown as AppV2<Args, Outputs, UiState, Href, Extend>);\n });\n }\n };\n\n const plugin = reactive({\n apiVersion: platforma.apiVersion ?? 1,\n featureFlags: platforma.blockModelInfo.featureFlags,\n loaded: false,\n error: undefined as unknown,\n useApp<PageHref extends Href = Href>() {\n return notEmpty(app, \"App is not loaded\") as\n | AppV1<Args, Outputs, UiState, PageHref, Extend>\n | AppV2<Args, Outputs, UiState, PageHref, Extend>;\n },\n install(app: VueApp) {\n app.provide(pluginKey, this);\n loadApp().catch((err) => {\n console.error(\"load initial state error\", err);\n plugin.error = err;\n });\n },\n });\n\n return plugin as\n | SdkPluginV1<Args, Outputs, UiState, Href, Extend>\n | SdkPluginV2<Args, Outputs, UiState, Href, Extend>;\n}\n\nexport function defineAppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n Plugins extends Record<string, unknown> = Record<string, unknown>,\n UiServices extends Partial<AllUiServices> = Partial<AllUiServices>,\n Extend extends ExtendSettings<Href> = ExtendSettings<Href>,\n>(\n platforma: PlatformaV3<Data, Args, Outputs, Href, Plugins, UiServices> & {\n blockModelInfo: BlockModelInfo;\n },\n extendApp: (app: BaseAppV3<Data, Args, Outputs, Href, Plugins, UiServices>) => Extend,\n settings: AppSettings = {},\n): SdkPluginV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices> {\n let app: AppV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices> | undefined = undefined;\n\n // Captured during install() so V3 can provide plugin data access after async load\n let vueAppInstance: VueApp | undefined;\n\n const runtimeApiVersion = 3;\n const blockRequestedApiVersion = getPlatformaApiVersion();\n\n const loadApp = async () => {\n if (blockRequestedApiVersion !== runtimeApiVersion) {\n throw new Error(`Block requested API version ${blockRequestedApiVersion} but runtime API version is ${runtimeApiVersion}.\n Please update the desktop app to use the latest API version.`);\n }\n\n await platforma.loadBlockState().then((stateOrError) => {\n const state = unwrapResult(stateOrError);\n plugin.loaded = true;\n const { app: baseApp, pluginAccess } = createAppV3<\n Data,\n Args,\n Outputs,\n Href,\n Plugins,\n UiServices\n >(state, platforma, settings);\n\n if (!vueAppInstance) {\n throw new Error(\n \"Plugin data injection failed: Vue app instance not captured during install()\",\n );\n }\n vueAppInstance.provide(pluginDataKey, pluginAccess);\n\n const localState = extendApp(baseApp);\n\n const routes = Object.fromEntries(\n Object.entries(localState.routes as Routes<Href>).map(([href, component]) => {\n const c = typeof component === \"function\" ? component() : component;\n return [href, markRaw(c as Component)];\n }),\n );\n\n app = Object.assign(baseApp, {\n ...localState,\n getRoute(href: Href): Component | undefined {\n return routes[href];\n },\n } as AppV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices>);\n });\n };\n\n const plugin = reactive({\n apiVersion: 3,\n featureFlags: platforma.blockModelInfo.featureFlags,\n loaded: false,\n error: undefined,\n useApp<PageHref extends Href = Href>() {\n return notEmpty(app, \"App is not loaded\") as AppV3<\n Data,\n Args,\n Outputs,\n PageHref,\n Plugins,\n Extend,\n UiServices\n >;\n },\n install(app: VueApp) {\n vueAppInstance = app;\n app.provide(pluginKey, this);\n loadApp().catch((err) => {\n console.error(\"load initial state error\", err);\n plugin.error = err;\n });\n },\n });\n\n return plugin as SdkPluginV3<Data, Args, Outputs, Href, Plugins, Extend, UiServices>;\n}\n\nexport type AppV1<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = BaseAppV1<Args, Outputs, UiState, Href> &\n Reactive<Omit<Local, \"routes\">> & { getRoute(href: Href): Component | undefined };\n\nexport type AppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = BaseAppV2<Args, Outputs, UiState, Href> &\n Reactive<Omit<Local, \"routes\">> & { getRoute(href: Href): Component | undefined };\n\nexport type AppV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = NonNullable<unknown>,\n Href extends `/${string}` = `/${string}`,\n Plugins extends Record<string, unknown> = Record<string, unknown>,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n UiServices extends Partial<AllUiServices> = Partial<AllUiServices>,\n> = BaseAppV3<Data, Args, Outputs, Href, Plugins, UiServices> &\n Reactive<Omit<Local, \"routes\">> & { getRoute(href: Href): Component | undefined };\n\n// ---------------------------------------------------------------------------\n// SdkPlugin types\n// ---------------------------------------------------------------------------\n\nexport type SdkPluginV1<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = {\n apiVersion: 1;\n featureFlags: BlockCodeKnownFeatureFlags;\n loaded: boolean;\n error: unknown;\n useApp<PageHref extends Href = Href>(): AppV1<Args, Outputs, UiState, PageHref, Local>;\n install(app: VueApp): void;\n};\n\nexport type SdkPluginV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n> = {\n apiVersion: 2;\n featureFlags: BlockCodeKnownFeatureFlags;\n loaded: boolean;\n error: unknown;\n useApp<PageHref extends Href = Href>(): AppV2<Args, Outputs, UiState, PageHref, Local>;\n install(app: VueApp): void;\n};\n\nexport type SdkPluginV3<\n Data = unknown,\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n Href extends `/${string}` = `/${string}`,\n Plugins extends Record<string, unknown> = Record<string, unknown>,\n Local extends ExtendSettings<Href> = ExtendSettings<Href>,\n UiServices extends Partial<AllUiServices> = Partial<AllUiServices>,\n> = {\n apiVersion: 3;\n featureFlags: BlockCodeKnownFeatureFlags;\n loaded: boolean;\n error: unknown;\n useApp<PageHref extends Href = Href>(): AppV3<\n Data,\n Args,\n Outputs,\n PageHref,\n Plugins,\n Local,\n UiServices\n >;\n install(app: VueApp): void;\n};\n\nexport type SdkPlugin = SdkPluginV1 | SdkPluginV2 | SdkPluginV3;\n"],"mappings":";;;;;;;;AAsBA,IAAM,IAAY,OAAO,UAAU,EACtB,IAAgB,OAAO,qBAAqB;AAEzD,SAAgB,IAA0B;AACxC,QAAO,EAAO,EAAU;;AAG1B,SAAgB,IAAkB;AAEhC,QADY,GAAc,CACf;;AA+Bb,SAAgB,EAOd,GAKA,GACA,IAAwB,EAAE,EAG0B;CACpD,IAAI,GAKE,IAAoB,EAAU,c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/defineStore.ts
|
|
2
3
|
var i = /* @__PURE__ */ new Map();
|
|
3
4
|
function a(a, o) {
|
|
4
5
|
let s = t() ?? e(), c = s.run(() => (n(() => {
|
|
@@ -12,6 +13,7 @@ function o(e) {
|
|
|
12
13
|
let t = Symbol();
|
|
13
14
|
return () => (i.has(t) || i.set(t, a(t, e)), i.get(t));
|
|
14
15
|
}
|
|
16
|
+
//#endregion
|
|
15
17
|
export { o as defineStore };
|
|
16
18
|
|
|
17
19
|
//# sourceMappingURL=defineStore.js.map
|
package/dist/defineStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineStore.js","names":[],"sources":["../src/defineStore.ts"],"sourcesContent":["import { reactive, onScopeDispose, getCurrentScope, effectScope } from \"vue\";\n\nconst shelf = new Map<symbol, unknown>();\n\nfunction initStore<S extends object>(key: symbol, cb: () => S) {\n const scope = getCurrentScope() ?? effectScope();\n\n const store = scope.run(() => {\n onScopeDispose(() => {\n shelf.delete(key);\n });\n\n return reactive(cb());\n }) as S;\n\n (store as Disposable)[Symbol.dispose] = () => {\n scope.stop();\n };\n\n return store;\n}\n\nexport function defineStore<S extends object>(cb: () => S) {\n const key = Symbol();\n\n return () => {\n if (!shelf.has(key)) {\n shelf.set(key, initStore(key, cb));\n }\n return shelf.get(key) as S & Disposable;\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"defineStore.js","names":[],"sources":["../src/defineStore.ts"],"sourcesContent":["import { reactive, onScopeDispose, getCurrentScope, effectScope } from \"vue\";\n\nconst shelf = new Map<symbol, unknown>();\n\nfunction initStore<S extends object>(key: symbol, cb: () => S) {\n const scope = getCurrentScope() ?? effectScope();\n\n const store = scope.run(() => {\n onScopeDispose(() => {\n shelf.delete(key);\n });\n\n return reactive(cb());\n }) as S;\n\n (store as Disposable)[Symbol.dispose] = () => {\n scope.stop();\n };\n\n return store;\n}\n\nexport function defineStore<S extends object>(cb: () => S) {\n const key = Symbol();\n\n return () => {\n if (!shelf.has(key)) {\n shelf.set(key, initStore(key, cb));\n }\n return shelf.get(key) as S & Disposable;\n };\n}\n"],"mappings":";;AAEA,IAAM,oBAAQ,IAAI,KAAsB;AAExC,SAAS,EAA4B,GAAa,GAAa;CAC7D,IAAM,IAAQ,GAAiB,IAAI,GAAa,EAE1C,IAAQ,EAAM,WAClB,QAAqB;AACnB,IAAM,OAAO,EAAI;GACjB,EAEK,EAAS,GAAI,CAAC,EACrB;AAMF,QAJC,EAAqB,OAAO,iBAAiB;AAC5C,IAAM,MAAM;IAGP;;AAGT,SAAgB,EAA8B,GAAa;CACzD,IAAM,IAAM,QAAQ;AAEpB,eACO,EAAM,IAAI,EAAI,IACjB,EAAM,IAAI,GAAK,EAAU,GAAK,EAAG,CAAC,EAE7B,EAAM,IAAI,EAAI"}
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import { computedResult as $ } from "./computedResult.js";
|
|
|
37
37
|
import { ReactiveFileContent as te } from "./composition/fileContent.js";
|
|
38
38
|
import "./lib.js";
|
|
39
39
|
export * from "@milaboratories/uikit";
|
|
40
|
+
//#endregion
|
|
40
41
|
export { j as AgGridTheme, g as BlockLayout, T as DeferredCircular, e as MultiError, S as PlAdvancedFilterComponent, C as PlAdvancedFilterSupportedFilters, I as PlAgCellFile, P as PlAgCellProgress, z as PlAgCellStatusTag, R as PlAgChartHistogramCell, L as PlAgChartStackedBarCell, E as PlAgColumnHeader, _ as PlAgCsvExporter, v as PlAgDataTableRowNumberColId, M as PlAgDataTableV2, x as PlAgGridColumnManager, k as PlAgOverlayLoading, A as PlAgOverlayNoRows, D as PlAgTextAndButtonCell, K as PlAnnotations, q as PlAnnotationsModal, J as PlBtnExportArchive, M as PlDataTableV2, w as PlTableFiltersV2, te as ReactiveFileContent, t as UnresolvedError, Z as activateAgGrid, y as autoSizeRowNumberColumn, $ as computedResult, F as createAgGridColDef, u as createModel, O as defaultMainMenuItems, d as defineApp, f as defineAppV3, X as defineStore, V as deselectAll, n as ensureError, ee as ensureNodeVisible, r as ensureOutputHasStableFlag, i as formatZodError, H as getSelectedRowsCount, U as getTotalRowsCount, a as identity, o as isDefined, W as isSelectionEnabled, s as isZodError, b as makeRowNumberColDef, Q as objectHash, p as pluginDataKey, G as selectAll, c as unwrapOutput, B as useAgGridOptions, m as useFeatureFlags, N as usePlDataTableSettingsV2, Y as usePlugin, h as useSdkPlugin, l as wrapOptionalResult };
|
|
41
42
|
|
|
42
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { delay as e } from "../lib/util/helpers/dist/utils.js";
|
|
2
2
|
import "../lib/util/helpers/dist/index.js";
|
|
3
3
|
import { hasAbortError as t } from "@platforma-sdk/model";
|
|
4
|
+
//#region src/internal/UpdateSerializer.ts
|
|
4
5
|
var n = class {
|
|
5
6
|
ongoingRun = Promise.resolve(!0);
|
|
6
7
|
ongoingOperation = Promise.resolve();
|
|
@@ -25,15 +26,9 @@ var n = class {
|
|
|
25
26
|
await e(a);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
/**
|
|
29
|
-
* @returns true if operation succeeded, or false if operation was evicted by a more recent call
|
|
30
|
-
*/
|
|
31
29
|
async run(e) {
|
|
32
30
|
return this.ongoingRun = this._run(e);
|
|
33
31
|
}
|
|
34
|
-
/**
|
|
35
|
-
* @returns true if operation succeeded, or false if operation was evicted by a more recent call
|
|
36
|
-
*/
|
|
37
32
|
async _run(t) {
|
|
38
33
|
this.counter++;
|
|
39
34
|
let n = this.counter;
|
|
@@ -46,6 +41,7 @@ var n = class {
|
|
|
46
41
|
return this.ongoingOperation = r, await r, !0;
|
|
47
42
|
}
|
|
48
43
|
};
|
|
44
|
+
//#endregion
|
|
49
45
|
export { n as UpdateSerializer };
|
|
50
46
|
|
|
51
47
|
//# sourceMappingURL=UpdateSerializer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateSerializer.js","names":[],"sources":["../../src/internal/UpdateSerializer.ts"],"sourcesContent":["import { delay } from \"@milaboratories/helpers\";\nimport { hasAbortError } from \"@platforma-sdk/model\";\n\nexport type RetryState = {\n i: number;\n};\n\nexport type OnNext = (e: unknown, state: RetryState) => { delayMs: number };\n\nexport class UpdateSerializer {\n private ongoingRun: Promise<boolean> = Promise.resolve(true);\n private ongoingOperation: Promise<void> = Promise.resolve();\n private counter = 0;\n\n constructor(\n private readonly options: {\n debounceSpan?: number;\n } = {},\n ) {}\n\n async allSettled(): Promise<void> {\n await delay(this.options.debounceSpan ?? 0);\n let completed = false;\n do {\n await delay(0);\n completed = await this.ongoingRun\n .then(() => {\n return true;\n })\n .catch((e) => {\n console.log(\"ongoingRun error\", e);\n return false;\n });\n } while (!completed);\n }\n\n async retry<T>(op: () => Promise<T>, onNext: OnNext): Promise<T> {\n const state: RetryState = {\n i: 0,\n };\n\n while (true) {\n try {\n state.i++;\n return await op();\n } catch (e: unknown) {\n const { delayMs } = onNext(e, state);\n\n if (hasAbortError(e)) {\n throw e;\n }\n\n await delay(delayMs);\n }\n }\n }\n\n /**\n * @returns true if operation succeeded, or false if operation was evicted by a more recent call\n */\n public async run(op: () => Promise<void>): Promise<boolean> {\n return (this.ongoingRun = this._run(op));\n }\n\n /**\n * @returns true if operation succeeded, or false if operation was evicted by a more recent call\n */\n private async _run(op: () => Promise<void>): Promise<boolean> {\n // assigning a sequential update id to the call\n this.counter++;\n const myId = this.counter;\n\n if (this.options.debounceSpan) {\n await delay(this.options.debounceSpan);\n }\n\n // checking that this update is still the most recent\n if (this.counter !== myId) {\n // operation was canceled, because another operation was queued\n // after we started waiting for previous operation to finish\n return false;\n }\n\n // awaiting previous operation to finish\n try {\n await this.ongoingOperation;\n } catch {\n // ignoring the error here, original caller will receive any rejections\n }\n\n // checking that this update is still the most recent\n if (this.counter !== myId) {\n // operation was canceled, because another operation was queued\n // after we started waiting for previous operation to finish\n return false;\n }\n\n // asynchronously starting the operation\n const opPromise = this.retry(\n () => op(),\n (e) => {\n console.warn(\"UpdateSerializer.run error, retrying...\", e);\n return {\n delayMs: 100, // TODO: flexible delay\n };\n },\n );\n // publishing the promise for the next operation to await\n this.ongoingOperation = opPromise;\n // actually awaiting for the operation result, any rejections will be thrown here\n await opPromise;\n\n // operation was successfully called\n return true;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UpdateSerializer.js","names":[],"sources":["../../src/internal/UpdateSerializer.ts"],"sourcesContent":["import { delay } from \"@milaboratories/helpers\";\nimport { hasAbortError } from \"@platforma-sdk/model\";\n\nexport type RetryState = {\n i: number;\n};\n\nexport type OnNext = (e: unknown, state: RetryState) => { delayMs: number };\n\nexport class UpdateSerializer {\n private ongoingRun: Promise<boolean> = Promise.resolve(true);\n private ongoingOperation: Promise<void> = Promise.resolve();\n private counter = 0;\n\n constructor(\n private readonly options: {\n debounceSpan?: number;\n } = {},\n ) {}\n\n async allSettled(): Promise<void> {\n await delay(this.options.debounceSpan ?? 0);\n let completed = false;\n do {\n await delay(0);\n completed = await this.ongoingRun\n .then(() => {\n return true;\n })\n .catch((e) => {\n console.log(\"ongoingRun error\", e);\n return false;\n });\n } while (!completed);\n }\n\n async retry<T>(op: () => Promise<T>, onNext: OnNext): Promise<T> {\n const state: RetryState = {\n i: 0,\n };\n\n while (true) {\n try {\n state.i++;\n return await op();\n } catch (e: unknown) {\n const { delayMs } = onNext(e, state);\n\n if (hasAbortError(e)) {\n throw e;\n }\n\n await delay(delayMs);\n }\n }\n }\n\n /**\n * @returns true if operation succeeded, or false if operation was evicted by a more recent call\n */\n public async run(op: () => Promise<void>): Promise<boolean> {\n return (this.ongoingRun = this._run(op));\n }\n\n /**\n * @returns true if operation succeeded, or false if operation was evicted by a more recent call\n */\n private async _run(op: () => Promise<void>): Promise<boolean> {\n // assigning a sequential update id to the call\n this.counter++;\n const myId = this.counter;\n\n if (this.options.debounceSpan) {\n await delay(this.options.debounceSpan);\n }\n\n // checking that this update is still the most recent\n if (this.counter !== myId) {\n // operation was canceled, because another operation was queued\n // after we started waiting for previous operation to finish\n return false;\n }\n\n // awaiting previous operation to finish\n try {\n await this.ongoingOperation;\n } catch {\n // ignoring the error here, original caller will receive any rejections\n }\n\n // checking that this update is still the most recent\n if (this.counter !== myId) {\n // operation was canceled, because another operation was queued\n // after we started waiting for previous operation to finish\n return false;\n }\n\n // asynchronously starting the operation\n const opPromise = this.retry(\n () => op(),\n (e) => {\n console.warn(\"UpdateSerializer.run error, retrying...\", e);\n return {\n delayMs: 100, // TODO: flexible delay\n };\n },\n );\n // publishing the promise for the next operation to await\n this.ongoingOperation = opPromise;\n // actually awaiting for the operation result, any rejections will be thrown here\n await opPromise;\n\n // operation was successfully called\n return true;\n }\n}\n"],"mappings":";;;;AASA,IAAa,IAAb,MAA8B;CAC5B,aAAuC,QAAQ,QAAQ,GAAK;CAC5D,mBAA0C,QAAQ,SAAS;CAC3D,UAAkB;CAElB,YACE,IAEI,EAAE,EACN;AAHiB,OAAA,UAAA;;CAKnB,MAAM,aAA4B;AAChC,QAAM,EAAM,KAAK,QAAQ,gBAAgB,EAAE;EAC3C,IAAI,IAAY;AAChB;AAEE,GADA,MAAM,EAAM,EAAE,EACd,IAAY,MAAM,KAAK,WACpB,WACQ,GACP,CACD,OAAO,OACN,QAAQ,IAAI,oBAAoB,EAAE,EAC3B,IACP;SACG,CAAC;;CAGZ,MAAM,MAAS,GAAsB,GAA4B;EAC/D,IAAM,IAAoB,EACxB,GAAG,GACJ;AAED,UACE,KAAI;AAEF,UADA,EAAM,KACC,MAAM,GAAI;WACV,GAAY;GACnB,IAAM,EAAE,eAAY,EAAO,GAAG,EAAM;AAEpC,OAAI,EAAc,EAAE,CAClB,OAAM;AAGR,SAAM,EAAM,EAAQ;;;CAQ1B,MAAa,IAAI,GAA2C;AAC1D,SAAQ,KAAK,aAAa,KAAK,KAAK,EAAG;;CAMzC,MAAc,KAAK,GAA2C;AAE5D,OAAK;EACL,IAAM,IAAO,KAAK;AAOlB,MALI,KAAK,QAAQ,gBACf,MAAM,EAAM,KAAK,QAAQ,aAAa,EAIpC,KAAK,YAAY,EAGnB,QAAO;AAIT,MAAI;AACF,SAAM,KAAK;UACL;AAKR,MAAI,KAAK,YAAY,EAGnB,QAAO;EAIT,IAAM,IAAY,KAAK,YACf,GAAI,GACT,OACC,QAAQ,KAAK,2CAA2C,EAAE,EACnD,EACL,SAAS,KACV,EAEJ;AAOD,SALA,KAAK,mBAAmB,GAExB,MAAM,GAGC"}
|
|
@@ -2,6 +2,7 @@ import { deepClone as e, isJsonEqual as t } from "../lib/util/helpers/dist/objec
|
|
|
2
2
|
import "../lib/util/helpers/dist/index.js";
|
|
3
3
|
import { ensureError as n, formatZodError as r, identity as i, isZodError as a } from "../utils.js";
|
|
4
4
|
import { computed as o, reactive as s, ref as c, unref as l, watch as u } from "vue";
|
|
5
|
+
//#region src/internal/createAppModel.ts
|
|
5
6
|
function d(d, f, p) {
|
|
6
7
|
let m = d.validate ?? i, { autoSave: h } = d, g = c(), _ = c(), v = (t) => {
|
|
7
8
|
_.value = {
|
|
@@ -50,6 +51,7 @@ function d(d, f, p) {
|
|
|
50
51
|
setError: x
|
|
51
52
|
});
|
|
52
53
|
}
|
|
54
|
+
//#endregion
|
|
53
55
|
export { d as createAppModel };
|
|
54
56
|
|
|
55
57
|
//# sourceMappingURL=createAppModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAppModel.js","names":[],"sources":["../../src/internal/createAppModel.ts"],"sourcesContent":["import {\n reactive,\n computed,\n ref,\n watch,\n unref,\n type ComputedRef,\n type UnwrapNestedRefs,\n} from \"vue\";\nimport type { ModelOptions, Model, AppSettings } from \"../types\";\nimport { deepClone, isJsonEqual } from \"@milaboratories/helpers\";\nimport { identity, ensureError, isZodError, formatZodError } from \"../utils\";\n\nexport function createAppModel<\n M extends { args: unknown; ui: unknown },\n V = unknown,\n E extends Record<string, ComputedRef<unknown>> = Record<string, ComputedRef<unknown>>,\n>(\n options: ModelOptions<M, V>,\n extended: E,\n _settings: AppSettings,\n): Model<M & UnwrapNestedRefs<E>> {\n type R = M & UnwrapNestedRefs<E>;\n\n const validate = options.validate ?? identity;\n\n const { autoSave } = options;\n\n const error = ref<Error | undefined>();\n\n const local = ref<{ model: R; readonly stage: symbol }>();\n\n const setSource = (v: M) => {\n local.value = {\n model: Object.assign(deepClone(v), extended ?? {}) as R,\n stage: Symbol(),\n };\n };\n\n watch(\n () => options.get(),\n (v) => setSource(v),\n { immediate: true },\n );\n\n const save = () => options.onSave(validate(deepClone(local.value?.model)));\n\n const revert = () => {\n setSource(options.get());\n error.value = undefined;\n };\n\n const setError = (cause: unknown) => {\n const err = ensureError(cause);\n if (isZodError(err)) {\n error.value = Error(formatZodError(err)); // @todo temp\n } else {\n error.value = err;\n }\n };\n\n const setValue = (v: M) => {\n error.value = undefined;\n try {\n validate(v);\n if (autoSave) {\n save();\n }\n } catch (cause: unknown) {\n setError(cause);\n }\n };\n\n const model = computed<R>({\n get: () => {\n return local.value?.model as R;\n },\n set() {\n throw Error(\"Cannot replace base model\");\n },\n });\n\n watch(\n [() => ({ args: model.value.args, ui: model.value.ui }), () => local.value?.stage],\n ([n, newStage], [_, oldStage]) => {\n if (newStage === oldStage) {\n setValue(n as M);\n }\n },\n { deep: true },\n );\n\n const valid = computed(() => !error.value);\n\n const isChanged = computed(() => {\n const { args, ui } = unref(local)?.model ?? {};\n return !isJsonEqual(options.get(), { args, ui });\n });\n\n const errorString = computed(() => (error.value ? error.value.message : \"\"));\n\n return reactive({\n model,\n valid,\n isChanged,\n error,\n errorString,\n save,\n revert,\n setError,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createAppModel.js","names":[],"sources":["../../src/internal/createAppModel.ts"],"sourcesContent":["import {\n reactive,\n computed,\n ref,\n watch,\n unref,\n type ComputedRef,\n type UnwrapNestedRefs,\n} from \"vue\";\nimport type { ModelOptions, Model, AppSettings } from \"../types\";\nimport { deepClone, isJsonEqual } from \"@milaboratories/helpers\";\nimport { identity, ensureError, isZodError, formatZodError } from \"../utils\";\n\nexport function createAppModel<\n M extends { args: unknown; ui: unknown },\n V = unknown,\n E extends Record<string, ComputedRef<unknown>> = Record<string, ComputedRef<unknown>>,\n>(\n options: ModelOptions<M, V>,\n extended: E,\n _settings: AppSettings,\n): Model<M & UnwrapNestedRefs<E>> {\n type R = M & UnwrapNestedRefs<E>;\n\n const validate = options.validate ?? identity;\n\n const { autoSave } = options;\n\n const error = ref<Error | undefined>();\n\n const local = ref<{ model: R; readonly stage: symbol }>();\n\n const setSource = (v: M) => {\n local.value = {\n model: Object.assign(deepClone(v), extended ?? {}) as R,\n stage: Symbol(),\n };\n };\n\n watch(\n () => options.get(),\n (v) => setSource(v),\n { immediate: true },\n );\n\n const save = () => options.onSave(validate(deepClone(local.value?.model)));\n\n const revert = () => {\n setSource(options.get());\n error.value = undefined;\n };\n\n const setError = (cause: unknown) => {\n const err = ensureError(cause);\n if (isZodError(err)) {\n error.value = Error(formatZodError(err)); // @todo temp\n } else {\n error.value = err;\n }\n };\n\n const setValue = (v: M) => {\n error.value = undefined;\n try {\n validate(v);\n if (autoSave) {\n save();\n }\n } catch (cause: unknown) {\n setError(cause);\n }\n };\n\n const model = computed<R>({\n get: () => {\n return local.value?.model as R;\n },\n set() {\n throw Error(\"Cannot replace base model\");\n },\n });\n\n watch(\n [() => ({ args: model.value.args, ui: model.value.ui }), () => local.value?.stage],\n ([n, newStage], [_, oldStage]) => {\n if (newStage === oldStage) {\n setValue(n as M);\n }\n },\n { deep: true },\n );\n\n const valid = computed(() => !error.value);\n\n const isChanged = computed(() => {\n const { args, ui } = unref(local)?.model ?? {};\n return !isJsonEqual(options.get(), { args, ui });\n });\n\n const errorString = computed(() => (error.value ? error.value.message : \"\"));\n\n return reactive({\n model,\n valid,\n isChanged,\n error,\n errorString,\n save,\n revert,\n setError,\n });\n}\n"],"mappings":";;;;;AAaA,SAAgB,EAKd,GACA,GACA,GACgC;CAGhC,IAAM,IAAW,EAAQ,YAAY,GAE/B,E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AAM,UAAU,GAAI;EAQ1E;EACA;EACA;EACD,CAAC"}
|
|
@@ -7,20 +7,7 @@ import { createAppModel as s } from "./createAppModel.js";
|
|
|
7
7
|
import { parseQuery as c } from "../urls.js";
|
|
8
8
|
import { computed as l, nextTick as u, reactive as d, watch as f } from "vue";
|
|
9
9
|
import { useDebounceFn as p } from "@vueuse/core";
|
|
10
|
-
|
|
11
|
-
* Creates an application instance with reactive state management, outputs, and methods for state updates and navigation.
|
|
12
|
-
*
|
|
13
|
-
* @template Args - The type of arguments used in the application.
|
|
14
|
-
* @template Outputs - The type of block outputs extending `BlockOutputsBase`.
|
|
15
|
-
* @template UiState - The type of the UI state.
|
|
16
|
-
* @template Href - The type of navigation href, defaulting to a string starting with `/`.
|
|
17
|
-
*
|
|
18
|
-
* @param state - Initial state of the application, including args, outputs, UI state, and navigation state.
|
|
19
|
-
* @param platforma - A platform interface for interacting with block states.
|
|
20
|
-
* @param settings - Application settings, such as debug flags.
|
|
21
|
-
*
|
|
22
|
-
* @returns A reactive application object with methods, getters, and state.
|
|
23
|
-
*/
|
|
10
|
+
//#region src/internal/createAppV1.ts
|
|
24
11
|
function m(m, h, g) {
|
|
25
12
|
let _ = (e, ...t) => {
|
|
26
13
|
g.debug && console.log(`%c>>> %c${e}`, "color: orange; font-weight: bold", "color: orange", ...t);
|
|
@@ -136,6 +123,7 @@ function m(m, h, g) {
|
|
|
136
123
|
}, g);
|
|
137
124
|
return d(Object.assign(j, D, A));
|
|
138
125
|
}
|
|
126
|
+
//#endregion
|
|
139
127
|
export { m as createAppV1 };
|
|
140
128
|
|
|
141
129
|
//# sourceMappingURL=createAppV1.js.map
|