@platforma-sdk/ui-vue 1.42.2 → 1.42.4

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.
Files changed (38) hide show
  1. package/.turbo/turbo-build.log +15 -15
  2. package/.turbo/turbo-type-check.log +1 -1
  3. package/CHANGELOG.md +15 -0
  4. package/dist/aggrid.js +4 -4
  5. package/dist/components/PlAgDataTable/PlAgDataTableSheets.vue2.js +7 -7
  6. package/dist/components/PlAgDataTable/PlAgDataTableV2.vue2.js +13 -13
  7. package/dist/components/PlAgDataTable/sources/table-source-v2.d.ts.map +1 -1
  8. package/dist/components/PlAgDataTable/sources/table-source-v2.js +88 -85
  9. package/dist/components/PlAgDataTable/sources/table-source-v2.js.map +1 -1
  10. package/dist/components/PlAgDataTable/sources/table-state-v2.js +6 -6
  11. package/dist/components/PlAnnotations/components/DynamicForm.vue2.js +10 -10
  12. package/dist/components/PlAnnotations/components/FilterSidebar.vue2.js +2 -2
  13. package/dist/components/PlMultiSequenceAlignment/data.js +26 -26
  14. package/dist/components/PlTableFilters/filters-state.js +2 -2
  15. package/dist/defineApp.js +16 -16
  16. package/dist/internal/createAppV2.d.ts.map +1 -1
  17. package/dist/internal/createAppV2.js +61 -52
  18. package/dist/internal/createAppV2.js.map +1 -1
  19. package/dist/lib/model/common/dist/index.js +329 -317
  20. package/dist/lib/model/common/dist/index.js.map +1 -1
  21. package/dist/lib/ui/uikit/dist/components/PlAccordion/{ExpandTransition.vue2.js → ExpandTransition.vue.js} +1 -1
  22. package/dist/lib/ui/uikit/dist/components/PlAccordion/ExpandTransition.vue.js.map +1 -0
  23. package/dist/lib/ui/uikit/dist/components/PlAccordion/PlAccordionSection.vue2.js +1 -1
  24. package/dist/lib/ui/uikit/dist/components/PlFileInput/PlFileInput.vue.js +16 -16
  25. package/dist/lib/ui/uikit/dist/components/PlFileInput/PlFileInput.vue.js.map +1 -1
  26. package/dist/lib/ui/uikit/dist/lib/model/common/dist/index.js +8 -8
  27. package/dist/lib/ui/uikit/dist/lib/model/common/dist/index.js.map +1 -1
  28. package/dist/lib/ui/uikit/dist/sdk/model/dist/index.js +18 -18
  29. package/dist/lib/ui/uikit/dist/sdk/model/dist/index.js.map +1 -1
  30. package/dist/node_modules/.pnpm/@vueuse_core@13.3.0_vue@3.5.13_typescript@5.6.3_/node_modules/@vueuse/core/index.js +44 -41
  31. package/dist/node_modules/.pnpm/@vueuse_shared@13.3.0_vue@3.5.13_typescript@5.6.3_/node_modules/@vueuse/shared/index.js +122 -67
  32. package/dist/node_modules/.pnpm/@vueuse_shared@13.3.0_vue@3.5.13_typescript@5.6.3_/node_modules/@vueuse/shared/index.js.map +1 -1
  33. package/dist/sdk/model/dist/index.js +198 -206
  34. package/dist/sdk/model/dist/index.js.map +1 -1
  35. package/package.json +7 -7
  36. package/src/components/PlAgDataTable/sources/table-source-v2.ts +9 -6
  37. package/src/internal/createAppV2.ts +22 -13
  38. package/dist/lib/ui/uikit/dist/components/PlAccordion/ExpandTransition.vue2.js.map +0 -1
@@ -1,18 +1,18 @@
1
1
  import { isJsonEqual as J } from "../../lib/util/helpers/dist/index.js";
2
- import { getRawPlatformaInstance as z, isLabelColumn as N, isLinkerColumn as W, createRowSelectionColumn as X } from "../../sdk/model/dist/index.js";
2
+ import { getRawPlatformaInstance as V, isLabelColumn as N, isLinkerColumn as W, createRowSelectionColumn as X } from "../../sdk/model/dist/index.js";
3
3
  import { ref as M, watch as G } from "vue";
4
4
  import { highlightByChemicalProperties as H } from "./chemical-properties.js";
5
5
  import { parseMarkup as K, markupAlignedSequence as Q, highlightByMarkup as Y } from "./markup.js";
6
6
  import { multiSequenceAlignment as Z } from "./multi-sequence-alignment.js";
7
7
  import { getResidueCounts as nn } from "./residue-counts.js";
8
- import { ensureError as tn, canonicalizeJson as A, getAxisId as E, parseJson as D, matchAxisId as en, pTableValue as q } from "../../lib/model/common/dist/index.js";
9
- const S = () => z().pFrameDriver, O = 1e3, gn = k(
8
+ import { ensureError as tn, canonicalizeJson as A, getAxisId as E, parseJson as D, matchAxisId as en, pTableValue as O } from "../../lib/model/common/dist/index.js";
9
+ const S = () => V().pFrameDriver, q = 1e3, gn = C(
10
10
  an
11
- ), hn = k(
11
+ ), hn = C(
12
12
  on
13
- ), wn = k(
13
+ ), wn = C(
14
14
  rn
15
- ), bn = k(
15
+ ), bn = C(
16
16
  sn
17
17
  );
18
18
  async function an({
@@ -163,11 +163,11 @@ async function sn({
163
163
  {
164
164
  offset: 0,
165
165
  // +1 is a hack to check whether the selection is over the limit
166
- length: O + 1
166
+ length: q + 1
167
167
  }
168
168
  );
169
169
  let g = (a == null ? void 0 : a[0].data.data.length) ?? 0, v = !1;
170
- g > O && (g = O, v = !0);
170
+ g > q && (g = q, v = !0);
171
171
  const L = e.map((n) => {
172
172
  const r = a.find(({ spec: s }) => s.id === n);
173
173
  if (!r)
@@ -190,39 +190,39 @@ async function sn({
190
190
  { length: g },
191
191
  (r, s) => {
192
192
  var w;
193
- return ((w = q(n.data, s, { na: "", absent: "" })) == null ? void 0 : w.toString()) ?? "";
193
+ return ((w = O(n.data, s, { na: "", absent: "" })) == null ? void 0 : w.toString()) ?? "";
194
194
  }
195
195
  ),
196
196
  l
197
197
  )
198
198
  )
199
- ), R = Array.from(
199
+ ), $ = Array.from(
200
200
  { length: g },
201
201
  (n, r) => j.map((s) => s[r])
202
- ), B = L.map(
202
+ ), z = L.map(
203
203
  (n) => {
204
204
  var r;
205
205
  return ((r = n.spec.spec.annotations) == null ? void 0 : r["pl7.app/label"]) ?? "Unlabelled column";
206
206
  }
207
- ), T = Array.from(
207
+ ), B = Array.from(
208
208
  { length: g },
209
209
  (n, r) => _.map(
210
210
  (s) => {
211
211
  var w;
212
- return ((w = q(s.data, r, { na: "", absent: "" })) == null ? void 0 : w.toString()) ?? "";
212
+ return ((w = O(s.data, r, { na: "", absent: "" })) == null ? void 0 : w.toString()) ?? "";
213
213
  }
214
214
  )
215
- ), x = R.map((n) => n.join(" ")), $ = nn(x), C = {
215
+ ), x = $.map((n) => n.join(" ")), R = nn(x), k = {
216
216
  sequences: x,
217
- sequenceNames: B,
218
- labelRows: T,
217
+ sequenceNames: z,
218
+ labelRows: B,
219
219
  exceedsLimit: v,
220
- residueCounts: $
220
+ residueCounts: R
221
221
  };
222
222
  if (t.type === "chemical-properties")
223
- C.highlightImage = H({
223
+ k.highlightImage = H({
224
224
  sequences: x,
225
- residueCounts: $
225
+ residueCounts: R
226
226
  });
227
227
  else if (t.type === "markup") {
228
228
  const n = a.find(
@@ -236,23 +236,23 @@ async function sn({
236
236
  { length: g },
237
237
  (w, P) => {
238
238
  var U;
239
- const V = K(
240
- ((U = q(n.data, P, { na: "", absent: "" })) == null ? void 0 : U.toString()) ?? ""
239
+ const T = K(
240
+ ((U = O(n.data, P, { na: "", absent: "" })) == null ? void 0 : U.toString()) ?? ""
241
241
  );
242
- return Q(R[P][0], V);
242
+ return Q($[P][0], T);
243
243
  }
244
244
  ), s = JSON.parse(
245
245
  ((F = n.spec.spec.annotations) == null ? void 0 : F["pl7.app/sequence/annotation/mapping"]) ?? "{}"
246
246
  );
247
- C.highlightImage = Y({
247
+ k.highlightImage = Y({
248
248
  markupRows: r,
249
249
  columnCount: ((I = x.at(0)) == null ? void 0 : I.length) ?? 0,
250
250
  labels: s
251
251
  });
252
252
  }
253
- return C;
253
+ return k;
254
254
  }
255
- function k(c) {
255
+ function C(c) {
256
256
  const e = M(), y = M(!0), p = M();
257
257
  let t;
258
258
  return (l) => (G(l, async (o, u) => {
@@ -270,7 +270,7 @@ function k(c) {
270
270
  }, { immediate: !0 }), { data: e, isLoading: y, error: p });
271
271
  }
272
272
  export {
273
- O as sequenceLimit,
273
+ q as sequenceLimit,
274
274
  hn as useLabelColumnsOptions,
275
275
  wn as useMarkupColumnsOptions,
276
276
  bn as useMultipleAlignmentData,
@@ -3,7 +3,7 @@ import "../../sdk/model/dist/index.js";
3
3
  import { isJsonEqual as b } from "../../lib/util/helpers/dist/index.js";
4
4
  import { getFilterOptions as g, makeDiscreteOptions as k, isFilterValid as F, isAlphabetic as q, getColumnName as x } from "./filters_logic.js";
5
5
  import { getPTableColumnId as z, canonicalizeJson as f } from "../../lib/model/common/dist/index.js";
6
- function K(M, m) {
6
+ function N(M, m) {
7
7
  const w = J(/* @__PURE__ */ new Map()), o = V({
8
8
  value: []
9
9
  });
@@ -73,6 +73,6 @@ function K(M, m) {
73
73
  ), o;
74
74
  }
75
75
  export {
76
- K as useFilters
76
+ N as useFilters
77
77
  };
78
78
  //# sourceMappingURL=filters-state.js.map
package/dist/defineApp.js CHANGED
@@ -1,5 +1,5 @@
1
- import { notEmpty as V } from "./lib/util/helpers/dist/index.js";
2
- import { getPlatformaApiVersion as g } from "./sdk/model/dist/index.js";
1
+ import { notEmpty as g } from "./lib/util/helpers/dist/index.js";
2
+ import { getPlatformaApiVersion as V } from "./sdk/model/dist/index.js";
3
3
  import { inject as k, reactive as h, markRaw as A } from "vue";
4
4
  import { createAppV1 as j } from "./internal/createAppV1.js";
5
5
  import { createAppV2 as w } from "./internal/createAppV2.js";
@@ -12,15 +12,15 @@ function $() {
12
12
  function C(e, p, l = {}) {
13
13
  let u;
14
14
  y();
15
- const d = e.apiVersion ?? 1, f = g(), b = async () => {
15
+ const d = e.apiVersion ?? 1, f = V(), b = async () => {
16
16
  if (f !== d)
17
17
  throw new Error(`Block requested API version ${f} but runtime API version is ${d}.
18
18
  Please update the desktop app to use the latest API version.`);
19
- e.apiVersion === void 0 || e.apiVersion === 1 ? await e.loadBlockState().then((r) => {
19
+ e.apiVersion === void 0 || e.apiVersion === 1 ? await e.loadBlockState().then((o) => {
20
20
  a.loaded = !0;
21
- const t = j(r, e, l), i = p(t), c = Object.fromEntries(
22
- Object.entries(i.routes).map(([s, o]) => {
23
- const n = typeof o == "function" ? o() : o;
21
+ const t = j(o, e, l), i = p(t), c = Object.fromEntries(
22
+ Object.entries(i.routes).map(([s, r]) => {
23
+ const n = typeof r == "function" ? r() : r;
24
24
  return [s, A(n)];
25
25
  })
26
26
  );
@@ -30,19 +30,19 @@ function C(e, p, l = {}) {
30
30
  return c[s];
31
31
  }
32
32
  });
33
- }) : e.apiVersion === 2 && await e.loadBlockState().then((r) => {
34
- const t = O(r);
33
+ }) : e.apiVersion === 2 && await e.loadBlockState().then((o) => {
34
+ const t = O(o);
35
35
  a.loaded = !0;
36
36
  const i = w(t, e, l), c = p(i), s = Object.fromEntries(
37
- Object.entries(c.routes).map(([o, n]) => {
37
+ Object.entries(c.routes).map(([r, n]) => {
38
38
  const v = typeof n == "function" ? n() : n;
39
- return [o, A(v)];
39
+ return [r, A(v)];
40
40
  })
41
41
  );
42
42
  u = Object.assign(i, {
43
43
  ...c,
44
- getRoute(o) {
45
- return s[o];
44
+ getRoute(r) {
45
+ return s[r];
46
46
  }
47
47
  });
48
48
  });
@@ -51,12 +51,12 @@ function C(e, p, l = {}) {
51
51
  error: void 0,
52
52
  // Href to get typed query parameters for a specific route
53
53
  useApp() {
54
- return V(u, "App is not loaded");
54
+ return g(u, "App is not loaded");
55
55
  },
56
56
  // @todo type portability issue with Vue
57
57
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
- install(r) {
59
- r.provide(m, this), b().catch((t) => {
58
+ install(o) {
59
+ o.provide(m, this), b().catch((t) => {
60
60
  console.error("load initial state error", t), a.error = t;
61
61
  });
62
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createAppV2.d.ts","sourceRoot":"","sources":["../../src/internal/createAppV2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpI,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAO1G,eAAO,MAAM,iBAAiB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,EAAE,CAAC,CAAC,8BAAuB,MAAM,OAAO;oBAwBvG,CAAC,SAAS,MAAM,OAAO,WAAW,CAAC,EAAE,KAAG,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;qBAWhE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,KAAG,OAAO,CAAC,OAAO,CAAC;wBAcpC,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC;uBAY9C,IAAI;;;;cAlNf,IAAI;iBACD,OAAO,CAAC,OAAO,CAAC;YACrB,OAAO;yBACM,eAAe,CAAC,IAAI,CAAC;;;;;EAmOzC;AAED,MAAM,MAAM,SAAS,CACnB,IAAI,GAAG,OAAO,EACd,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,OAAO,GAAG,OAAO,EACjB,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IACtC,UAAU,CAAC,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC"}
@@ -1,75 +1,84 @@
1
- import { deepClone as l, uniqueId as V, delay as L } from "../lib/util/helpers/dist/index.js";
1
+ import { deepClone as i, uniqueId as V, delay as L } from "../lib/util/helpers/dist/index.js";
2
2
  import "../sdk/model/dist/index.js";
3
- import { ref as A, computed as p, reactive as P, watch as W } from "vue";
3
+ import { ref as w, computed as g, reactive as P } from "vue";
4
4
  import { createModel as B } from "../createModel.js";
5
- import { parseQuery as F } from "../urls.js";
5
+ import { parseQuery as W } from "../urls.js";
6
6
  import { MultiError as G, unwrapValueOrErrors as H } from "../utils.js";
7
7
  import "../node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.js";
8
- import { UpdateSerializer as m } from "./UpdateSerializer.js";
9
- import { unwrapResult as c, hasAbortError as K } from "../lib/model/common/dist/index.js";
10
- import { applyPatch as O } from "../node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js";
11
- const Q = 100, X = (n) => ({
8
+ import { UpdateSerializer as v } from "./UpdateSerializer.js";
9
+ import { ignorableWatch as K } from "../node_modules/.pnpm/@vueuse_shared@13.3.0_vue@3.5.13_typescript@5.6.3_/node_modules/@vueuse/shared/index.js";
10
+ import { unwrapResult as c, hasAbortError as X } from "../lib/model/common/dist/index.js";
11
+ import { applyPatch as N } from "../node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js";
12
+ const O = 100, Y = (n) => ({
12
13
  authorId: (n == null ? void 0 : n.authorId) ?? V(),
13
14
  localVersion: ((n == null ? void 0 : n.localVersion) ?? 0) + 1
14
- });
15
- function se(n, d, h) {
15
+ }), Q = (n) => {
16
+ try {
17
+ return JSON.stringify(n, null, 2);
18
+ } catch (u) {
19
+ return u instanceof Error ? u.message : String(u);
20
+ }
21
+ };
22
+ function ie(n, u, A) {
16
23
  const r = (e, ...t) => {
17
- h.debug && console.log(`%c>>> %c${e}`, "color: orange; font-weight: bold", "color: orange", h.appId, ...t);
24
+ A.debug && console.log(`%c>>> %c${e}`, "color: orange; font-weight: bold", "color: orange", ...t.map((a) => Q(a)));
18
25
  }, b = (e, ...t) => {
19
- console.error(`%c>>> %c${e}`, "color: red; font-weight: bold", "color: red", h.appId, ...t);
20
- }, u = {
26
+ console.error(`%c>>> %c${e}`, "color: red; font-weight: bold", "color: red", ...t.map((a) => Q(a)));
27
+ }, s = {
21
28
  isExternalSnapshot: !1,
22
29
  author: {
23
30
  authorId: V(),
24
31
  localVersion: 0
25
32
  }
26
- }, f = () => (u.author = X(u.author), r("nextAuthorMarker", u.author), u.author), g = A(!1), S = A(n.uTag), v = h.debounceSpan ?? 200, y = new m({ debounceSpan: v }), M = new m({ debounceSpan: v }), U = new m({ debounceSpan: v }), R = new m({ debounceSpan: v }), o = A(n.value), T = async (e) => d.setBlockArgs(e, f()), x = async (e) => d.setBlockUiState(e, f()), k = async (e, t) => d.setBlockArgsAndUiState(e, t, f()), q = async (e) => d.setNavigationState(e), C = p(() => {
33
+ }, m = () => (s.author = Y(s.author), r("nextAuthorMarker", s.author), s.author), h = w(!1), f = w(n.uTag), p = A.debounceSpan ?? 200, y = new v({ debounceSpan: p }), U = new v({ debounceSpan: p }), M = new v({ debounceSpan: p }), R = new v({ debounceSpan: p }), o = w(n.value), T = async (e) => u.setBlockArgs(e, m()), E = async (e) => u.setBlockUiState(e, m()), D = async (e, t) => u.setBlockArgsAndUiState(e, t, m()), k = async (e) => u.setNavigationState(e), q = g(() => {
27
34
  const e = Object.entries(o.value.outputs).map(([t, a]) => [t, a.ok && a.value !== void 0 ? a.value : void 0]);
28
35
  return Object.fromEntries(e);
29
- }), D = p(() => {
36
+ }), C = g(() => {
30
37
  const e = Object.entries(o.value.outputs).map(([t, a]) => [t, a && !a.ok ? new G(a.errors) : void 0]);
31
38
  return Object.fromEntries(e);
32
- }), s = P({
39
+ }), l = P({
33
40
  error: "",
34
41
  model: {
35
- args: l(o.value.args),
36
- ui: l(o.value.ui),
37
- outputs: C,
38
- outputErrors: D
42
+ args: i(o.value.args),
43
+ ui: i(o.value.ui),
44
+ outputs: q,
45
+ outputErrors: C
39
46
  }
40
- }), E = W(
41
- () => s.model,
47
+ }), { ignoreUpdates: $ } = K(
48
+ () => l.model,
42
49
  (e) => {
43
- const t = l(e);
44
- r("appModel.model", t), U.run(() => k(t.args, t.ui).then(c));
50
+ const t = i(e);
51
+ r("setArgsAndUiStateQueue appModel.model", t), M.run(() => D(t.args, t.ui).then(c));
45
52
  },
46
53
  { deep: !0 }
47
- ), $ = (e) => {
48
- r("updateAppModelSilently", e), E.pause(), s.model.args = l(e.args), s.model.ui = l(e.ui), E.resume();
54
+ ), z = (e) => {
55
+ r("updateAppModel", e), l.model.args = i(e.args), l.model.ui = i(e.ui);
49
56
  };
50
57
  (async () => {
51
58
  var e, t;
52
59
  for (window.addEventListener("beforeunload", () => {
53
- g.value = !0, d.dispose().then(c).catch((a) => {
60
+ h.value = !0, u.dispose().then(c).catch((a) => {
54
61
  b("error in dispose", a);
55
62
  });
56
- }); !g.value; )
63
+ }); !h.value; )
57
64
  try {
58
- const a = await d.getPatches(S.value).then(c);
59
- if (r("patches.length", a.value.length), r("uTagRef.value", S.value), r("patches.uTag", a.uTag), r("patches.author", a.author), r("data.author", u.author), S.value = a.uTag, a.value.length === 0) {
60
- await new Promise((w) => setTimeout(w, Q));
65
+ const a = await u.getPatches(f.value).then(c);
66
+ if (r("patches.length", a.value.length), r("uTagRef.value", f.value), r("patches.uTag", a.uTag), r("patches.author", a.author), r("data.author", s.author), f.value = a.uTag, a.value.length === 0) {
67
+ await new Promise((S) => setTimeout(S, O));
61
68
  continue;
62
69
  }
63
- const i = ((e = u.author) == null ? void 0 : e.authorId) !== ((t = a.author) == null ? void 0 : t.authorId);
64
- i || u.isExternalSnapshot ? (r("got external changes, applying them to the snapshot", JSON.stringify(o.value, null, 2)), o.value = O(o.value, a.value, !1, !1).newDocument, $(o.value), u.isExternalSnapshot = i) : o.value = O(o.value, a.value).newDocument, await new Promise((w) => setTimeout(w, Q));
70
+ const d = ((e = s.author) == null ? void 0 : e.authorId) !== ((t = a.author) == null ? void 0 : t.authorId);
71
+ d || s.isExternalSnapshot ? (r("got external changes, applying them to the snapshot", o.value), $(() => {
72
+ o.value = N(o.value, a.value, !1, !1).newDocument, z({ args: o.value.args, ui: o.value.ui }), s.isExternalSnapshot = d;
73
+ })) : o.value = N(o.value, a.value).newDocument, await new Promise((S) => setTimeout(S, O));
65
74
  } catch (a) {
66
- K(a) ? (r("patches loop aborted"), g.value = !0) : (b("error in patches loop", a), await new Promise((i) => setTimeout(i, 1e3)));
75
+ X(a) ? (r("patches loop aborted"), h.value = !0) : (b("error in patches loop", a), await new Promise((d) => setTimeout(d, 1e3)));
67
76
  }
68
77
  })();
69
- const I = () => l(s.model.args), j = () => l(s.model.ui), N = () => l(o.value.navigationState), z = {
70
- cloneArgs: I,
78
+ const x = () => i(l.model.args), j = () => i(l.model.ui), I = () => i(o.value.navigationState), F = {
79
+ cloneArgs: x,
71
80
  cloneUiState: j,
72
- cloneNavigationState: N,
81
+ cloneNavigationState: I,
73
82
  createArgsModel(e = {}) {
74
83
  return B({
75
84
  get() {
@@ -93,7 +102,7 @@ function se(n, d, h) {
93
102
  validate: e.validate,
94
103
  autoSave: !0,
95
104
  onSave(a) {
96
- M.run(() => x(a).then(c));
105
+ U.run(() => E(a).then(c));
97
106
  }
98
107
  });
99
108
  },
@@ -106,7 +115,7 @@ function se(n, d, h) {
106
115
  * @returns An object with unwrapped output values.
107
116
  */
108
117
  unwrapOutputs(...e) {
109
- const t = o.value.outputs, a = e.map((i) => [i, H(t[i])]);
118
+ const t = o.value.outputs, a = e.map((d) => [d, H(t[d])]);
110
119
  return Object.fromEntries(a);
111
120
  },
112
121
  /**
@@ -116,8 +125,8 @@ function se(n, d, h) {
116
125
  * @returns A promise resolving after the update is applied.
117
126
  */
118
127
  updateArgs(e) {
119
- const t = I();
120
- return e(t), r("updateArgs", t), s.model.args = t, y.run(() => T(t).then(c));
128
+ const t = x();
129
+ return e(t), r("updateArgs", t), l.model.args = t, y.run(() => T(t).then(c));
121
130
  },
122
131
  /**
123
132
  * Updates the UI state by applying a callback.
@@ -128,7 +137,7 @@ function se(n, d, h) {
128
137
  */
129
138
  updateUiState(e) {
130
139
  const t = e(j());
131
- return r("updateUiState", t), s.model.ui = t, M.run(() => x(t).then(c));
140
+ return r("updateUiState", t), l.model.ui = t, U.run(() => E(t).then(c));
132
141
  },
133
142
  /**
134
143
  * Navigates to a specific href by updating the navigation state.
@@ -137,24 +146,24 @@ function se(n, d, h) {
137
146
  * @returns A promise resolving after the navigation state is updated.
138
147
  */
139
148
  navigateTo(e) {
140
- const t = N();
141
- return t.href = e, R.run(() => q(t).then(c));
149
+ const t = I();
150
+ return t.href = e, R.run(() => k(t).then(c));
142
151
  },
143
152
  async allSettled() {
144
- return await L(0), U.allSettled();
153
+ return await L(0), M.allSettled();
145
154
  }
146
155
  }, J = {
147
- closedRef: g,
156
+ closedRef: h,
148
157
  snapshot: o,
149
- queryParams: p(() => F(o.value.navigationState.href)),
150
- href: p(() => o.value.navigationState.href),
151
- hasErrors: p(() => Object.values(o.value.outputs).some((e) => !(e != null && e.ok)))
158
+ queryParams: g(() => W(o.value.navigationState.href)),
159
+ href: g(() => o.value.navigationState.href),
160
+ hasErrors: g(() => Object.values(o.value.outputs).some((e) => !(e != null && e.ok)))
152
161
  };
153
- return P(Object.assign(s, z, J));
162
+ return P(Object.assign(l, F, J));
154
163
  }
155
164
  export {
156
- se as createAppV2,
157
- X as createNextAuthorMarker,
158
- Q as patchPoolingDelay
165
+ ie as createAppV2,
166
+ Y as createNextAuthorMarker,
167
+ O as patchPoolingDelay
159
168
  };
160
169
  //# sourceMappingURL=createAppV2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAppV2.js","sources":["../../src/internal/createAppV2.ts"],"sourcesContent":["import { deepClone, delay, uniqueId } from '@milaboratories/helpers';\nimport type { Mutable } from '@milaboratories/helpers';\nimport type { NavigationState, BlockOutputsBase, BlockState, PlatformaV2, ValueWithUTag, AuthorMarker } from '@platforma-sdk/model';\nimport { hasAbortError, unwrapResult } from '@platforma-sdk/model';\nimport type { Ref } from 'vue';\nimport { reactive, computed, ref, watch } from 'vue';\nimport type { StateModelOptions, UnwrapOutputs, OutputValues, OutputErrors, AppSettings } from '../types';\nimport { createModel } from '../createModel';\nimport { parseQuery } from '../urls';\nimport { MultiError, unwrapValueOrErrors } from '../utils';\nimport { applyPatch } from 'fast-json-patch';\nimport { UpdateSerializer } from './UpdateSerializer';\n\nexport const patchPoolingDelay = 100;\n\nexport const createNextAuthorMarker = (marker: AuthorMarker | undefined): AuthorMarker => ({\n authorId: marker?.authorId ?? uniqueId(),\n localVersion: (marker?.localVersion ?? 0) + 1,\n});\n\n/**\n * Creates an application instance with reactive state management, outputs, and methods for state updates and navigation.\n *\n * @template Args - The type of arguments used in the application.\n * @template Outputs - The type of block outputs extending `BlockOutputsBase`.\n * @template UiState - The type of the UI state.\n * @template Href - The type of navigation href, defaulting to a string starting with `/`.\n *\n * @param state - Initial state of the application, including args, outputs, UI state, and navigation state.\n * @param platforma - A platform interface for interacting with block states.\n * @param settings - Application settings, such as debug flags.\n *\n * @returns A reactive application object with methods, getters, and state.\n */\nexport function createAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n>(\n state: ValueWithUTag<BlockState<Args, Outputs, UiState, Href>>,\n platforma: PlatformaV2<Args, Outputs, UiState, Href>,\n settings: AppSettings,\n) {\n const debug = (msg: string, ...rest: unknown[]) => {\n if (settings.debug) {\n console.log(`%c>>> %c${msg}`, 'color: orange; font-weight: bold', 'color: orange', settings.appId, ...rest);\n }\n };\n\n const error = (msg: string, ...rest: unknown[]) => {\n console.error(`%c>>> %c${msg}`, 'color: red; font-weight: bold', 'color: red', settings.appId, ...rest);\n };\n\n const data = {\n isExternalSnapshot: false,\n author: {\n authorId: uniqueId(),\n localVersion: 0,\n },\n };\n\n const nextAuthorMarker = () => {\n data.author = createNextAuthorMarker(data.author);\n debug('nextAuthorMarker', data.author);\n return data.author;\n };\n\n const closedRef = ref(false);\n\n const uTagRef = ref(state.uTag);\n\n const debounceSpan = settings.debounceSpan ?? 200;\n\n const setArgsQueue = new UpdateSerializer({ debounceSpan });\n const setUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setArgsAndUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setNavigationStateQueue = new UpdateSerializer({ debounceSpan });\n /**\n * Reactive snapshot of the application state, including args, outputs, UI state, and navigation state.\n */\n const snapshot = ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>(state.value) as Ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>;\n\n const setBlockArgs = async (args: Args) => {\n return platforma.setBlockArgs(args, nextAuthorMarker());\n };\n\n const setBlockUiState = async (ui: UiState) => {\n return platforma.setBlockUiState(ui, nextAuthorMarker());\n };\n\n const setBlockArgsAndUiState = async (args: Args, ui: UiState) => {\n return platforma.setBlockArgsAndUiState(args, ui, nextAuthorMarker());\n };\n\n const setNavigationState = async (state: NavigationState<Href>) => {\n return platforma.setNavigationState(state);\n };\n\n const outputs = computed<OutputValues<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr.ok && vOrErr.value !== undefined ? vOrErr.value : undefined]);\n return Object.fromEntries(entries);\n });\n\n const outputErrors = computed<OutputErrors<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr && !vOrErr.ok ? new MultiError(vOrErr.errors) : undefined]);\n return Object.fromEntries(entries);\n });\n\n const appModel = reactive({\n error: '',\n model: {\n args: deepClone(snapshot.value.args) as Args,\n ui: deepClone(snapshot.value.ui) as UiState,\n outputs,\n outputErrors,\n },\n }) as {\n error: string;\n model: {\n args: Args;\n ui: UiState;\n outputs: OutputValues<Outputs>;\n outputErrors: OutputErrors<Outputs>;\n };\n };\n\n const appModelWatch = watch(\n () => appModel.model,\n (_newData) => {\n const newData = deepClone(_newData);\n debug('appModel.model', newData);\n setArgsAndUiStateQueue.run(() => setBlockArgsAndUiState(newData.args, newData.ui).then(unwrapResult));\n },\n { deep: true },\n );\n\n const updateAppModelSilently = (newData: {\n args: Args;\n ui: UiState;\n }) => {\n debug('updateAppModelSilently', newData);\n appModelWatch.pause();\n appModel.model.args = deepClone(newData.args) as Args;\n appModel.model.ui = deepClone(newData.ui) as UiState;\n appModelWatch.resume();\n };\n\n (async () => {\n window.addEventListener('beforeunload', () => {\n closedRef.value = true;\n platforma.dispose().then(unwrapResult).catch((err) => {\n error('error in dispose', err);\n });\n });\n\n while (!closedRef.value) {\n try {\n const patches = await platforma.getPatches(uTagRef.value).then(unwrapResult);\n\n debug('patches.length', patches.value.length);\n debug('uTagRef.value', uTagRef.value);\n debug('patches.uTag', patches.uTag);\n debug('patches.author', patches.author);\n debug('data.author', data.author);\n\n uTagRef.value = patches.uTag;\n\n if (patches.value.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n continue;\n }\n\n const isAuthorChanged = data.author?.authorId !== patches.author?.authorId;\n\n // Immutable behavior, apply external changes to the snapshot\n if (isAuthorChanged || data.isExternalSnapshot) {\n debug('got external changes, applying them to the snapshot', JSON.stringify(snapshot.value, null, 2));\n snapshot.value = applyPatch(snapshot.value, patches.value, false, false).newDocument;\n updateAppModelSilently(snapshot.value);\n data.isExternalSnapshot = isAuthorChanged;\n } else {\n // Mutable behavior\n snapshot.value = applyPatch(snapshot.value, patches.value).newDocument;\n }\n\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n } catch (err) {\n if (hasAbortError(err)) {\n debug('patches loop aborted');\n closedRef.value = true;\n } else {\n error('error in patches loop', err);\n await new Promise((resolve) => setTimeout(resolve, 1000));\n }\n }\n }\n })();\n\n const cloneArgs = () => deepClone(appModel.model.args) as Args;\n const cloneUiState = () => deepClone(appModel.model.ui) as UiState;\n const cloneNavigationState = () => deepClone(snapshot.value.navigationState) as Mutable<NavigationState<Href>>;\n\n const methods = {\n cloneArgs,\n cloneUiState,\n cloneNavigationState,\n createArgsModel<T extends Args = Args>(options: StateModelOptions<Args, T> = {}) {\n return createModel<T, Args>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.args as Args);\n }\n\n return snapshot.value.args as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newArgs) {\n setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n });\n },\n /**\n * defaultUiState is temporarily here, remove it after implementing initialUiState\n */\n createUiModel<T extends UiState = UiState>(options: StateModelOptions<UiState, T> = {}, defaultUiState: () => UiState) {\n return createModel<T, UiState>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.ui as UiState);\n }\n\n return (snapshot.value.ui ?? defaultUiState()) as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newData) {\n setUiStateQueue.run(() => setBlockUiState(newData).then(unwrapResult));\n },\n });\n },\n /**\n * Retrieves the unwrapped values of outputs for the given keys.\n *\n * @template K - Keys of the outputs to unwrap.\n * @param keys - List of output names.\n * @throws Error if the outputs contain errors.\n * @returns An object with unwrapped output values.\n */\n unwrapOutputs<K extends keyof Outputs>(...keys: K[]): UnwrapOutputs<Outputs, K> {\n const outputs = snapshot.value.outputs as Partial<Readonly<Outputs>>;\n const entries = keys.map((key) => [key, unwrapValueOrErrors(outputs[key])]);\n return Object.fromEntries(entries);\n },\n /**\n * Updates the arguments state by applying a callback.\n *\n * @param cb - Callback to modify the current arguments.\n * @returns A promise resolving after the update is applied.\n */\n updateArgs(cb: (args: Args) => void): Promise<boolean> {\n const newArgs = cloneArgs();\n cb(newArgs);\n debug('updateArgs', newArgs);\n appModel.model.args = newArgs;\n return setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n /**\n * Updates the UI state by applying a callback.\n *\n * @param cb - Callback to modify the current UI state.\n * @returns A promise resolving after the update is applied.\n * @todo Make it mutable since there is already an initial one\n */\n updateUiState(cb: (args: UiState) => UiState): Promise<boolean> {\n const newUiState = cb(cloneUiState());\n debug('updateUiState', newUiState);\n appModel.model.ui = newUiState;\n return setUiStateQueue.run(() => setBlockUiState(newUiState).then(unwrapResult));\n },\n /**\n * Navigates to a specific href by updating the navigation state.\n *\n * @param href - The target href to navigate to.\n * @returns A promise resolving after the navigation state is updated.\n */\n navigateTo(href: Href) {\n const newState = cloneNavigationState();\n newState.href = href;\n return setNavigationStateQueue.run(() => setNavigationState(newState).then(unwrapResult));\n },\n async allSettled() {\n await delay(0);\n return setArgsAndUiStateQueue.allSettled();\n },\n };\n\n const getters = {\n closedRef,\n snapshot,\n queryParams: computed(() => parseQuery<Href>(snapshot.value.navigationState.href as Href)),\n href: computed(() => snapshot.value.navigationState.href),\n hasErrors: computed(() => Object.values(snapshot.value.outputs as Partial<Readonly<Outputs>>).some((v) => !v?.ok)),\n };\n\n return reactive(Object.assign(appModel, methods, getters));\n}\n\nexport type BaseAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n> = ReturnType<typeof createAppV2<Args, Outputs, UiState, Href>>;\n"],"names":["patchPoolingDelay","createNextAuthorMarker","marker","uniqueId","createAppV2","state","platforma","settings","debug","msg","rest","error","data","nextAuthorMarker","closedRef","ref","uTagRef","debounceSpan","setArgsQueue","UpdateSerializer","setUiStateQueue","setArgsAndUiStateQueue","setNavigationStateQueue","snapshot","setBlockArgs","args","setBlockUiState","ui","setBlockArgsAndUiState","setNavigationState","outputs","computed","entries","k","vOrErr","outputErrors","MultiError","appModel","reactive","deepClone","appModelWatch","watch","_newData","newData","unwrapResult","updateAppModelSilently","err","patches","resolve","isAuthorChanged","_a","_b","applyPatch","hasAbortError","cloneArgs","cloneUiState","cloneNavigationState","methods","options","createModel","newArgs","defaultUiState","keys","key","unwrapValueOrErrors","cb","newUiState","href","newState","delay","getters","parseQuery","v"],"mappings":";;;;;;;;;;AAaO,MAAMA,IAAoB,KAEpBC,IAAyB,CAACC,OAAoD;AAAA,EACzF,WAAUA,KAAA,gBAAAA,EAAQ,aAAYC,EAAS;AAAA,EACvC,gBAAeD,KAAA,gBAAAA,EAAQ,iBAAgB,KAAK;AAC9C;AAgBgB,SAAAE,GAMdC,GACAC,GACAC,GACA;AACM,QAAAC,IAAQ,CAACC,MAAgBC,MAAoB;AACjD,IAAIH,EAAS,SACH,QAAA,IAAI,WAAWE,CAAG,IAAI,oCAAoC,iBAAiBF,EAAS,OAAO,GAAGG,CAAI;AAAA,EAE9G,GAEMC,IAAQ,CAACF,MAAgBC,MAAoB;AACzC,YAAA,MAAM,WAAWD,CAAG,IAAI,iCAAiC,cAAcF,EAAS,OAAO,GAAGG,CAAI;A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AAC,IAAaD,EAAGV,GAAc;AACpC,aAAA/C,EAAM,iBAAiB0D,CAAU,GACjC7B,EAAS,MAAM,KAAK6B,GACb9C,EAAgB,IAAI,MAAMM,EAAgBwC,CAAU,EAAE,KAAKtB,CAAY,CAAC;AAAA,IACjF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,WAAWuB,GAAY;AACrB,YAAMC,IAAWZ,EAAqB;AACtC,aAAAY,EAAS,OAAOD,GACT7C,EAAwB,IAAI,MAAMO,EAAmBuC,CAAQ,EAAE,KAAKxB,CAAY,CAAC;AAAA,IAC1F;AAAA,IACA,MAAM,aAAa;AACjB,mBAAMyB,EAAM,CAAC,GACNhD,EAAuB,WAAW;AAAA,IAAA;AAAA,EAE7C,GAEMiD,IAAU;AAAA,IACd,WAAAxD;AAAA,IACA,UAAAS;AAAA,IACA,aAAaQ,EAAS,MAAMwC,EAAiBhD,EAAS,MAAM,gBAAgB,IAAY,CAAC;AAAA,IACzF,MAAMQ,EAAS,MAAMR,EAAS,MAAM,gBAAgB,IAAI;AAAA,IACxD,WAAWQ,EAAS,MAAM,OAAO,OAAOR,EAAS,MAAM,OAAqC,EAAE,KAAK,CAACiD,MAAM,EAACA,KAAA,QAAAA,EAAG,GAAE,CAAC;AAAA,EACnH;AAEA,SAAOlC,EAAS,OAAO,OAAOD,GAAUoB,GAASa,CAAO,CAAC;AAC3D;"}
1
+ {"version":3,"file":"createAppV2.js","sources":["../../src/internal/createAppV2.ts"],"sourcesContent":["import { deepClone, delay, uniqueId } from '@milaboratories/helpers';\nimport type { Mutable } from '@milaboratories/helpers';\nimport type { NavigationState, BlockOutputsBase, BlockState, PlatformaV2, ValueWithUTag, AuthorMarker } from '@platforma-sdk/model';\nimport { hasAbortError, unwrapResult } from '@platforma-sdk/model';\nimport type { Ref } from 'vue';\nimport { reactive, computed, ref } from 'vue';\nimport type { StateModelOptions, UnwrapOutputs, OutputValues, OutputErrors, AppSettings } from '../types';\nimport { createModel } from '../createModel';\nimport { parseQuery } from '../urls';\nimport { MultiError, unwrapValueOrErrors } from '../utils';\nimport { applyPatch } from 'fast-json-patch';\nimport { UpdateSerializer } from './UpdateSerializer';\nimport { watchIgnorable } from '@vueuse/core';\n\nexport const patchPoolingDelay = 100;\n\nexport const createNextAuthorMarker = (marker: AuthorMarker | undefined): AuthorMarker => ({\n authorId: marker?.authorId ?? uniqueId(),\n localVersion: (marker?.localVersion ?? 0) + 1,\n});\n\nconst stringifyForDebug = (v: unknown) => {\n try {\n return JSON.stringify(v, null, 2);\n } catch (err) {\n return err instanceof Error ? err.message : String(err);\n }\n};\n\n/**\n * Creates an application instance with reactive state management, outputs, and methods for state updates and navigation.\n *\n * @template Args - The type of arguments used in the application.\n * @template Outputs - The type of block outputs extending `BlockOutputsBase`.\n * @template UiState - The type of the UI state.\n * @template Href - The type of navigation href, defaulting to a string starting with `/`.\n *\n * @param state - Initial state of the application, including args, outputs, UI state, and navigation state.\n * @param platforma - A platform interface for interacting with block states.\n * @param settings - Application settings, such as debug flags.\n *\n * @returns A reactive application object with methods, getters, and state.\n */\nexport function createAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n>(\n state: ValueWithUTag<BlockState<Args, Outputs, UiState, Href>>,\n platforma: PlatformaV2<Args, Outputs, UiState, Href>,\n settings: AppSettings,\n) {\n const debug = (msg: string, ...rest: unknown[]) => {\n if (settings.debug) {\n console.log(`%c>>> %c${msg}`, 'color: orange; font-weight: bold', 'color: orange', ...rest.map((r) => stringifyForDebug(r)));\n }\n };\n\n const error = (msg: string, ...rest: unknown[]) => {\n console.error(`%c>>> %c${msg}`, 'color: red; font-weight: bold', 'color: red', ...rest.map((r) => stringifyForDebug(r)));\n };\n\n const data = {\n isExternalSnapshot: false,\n author: {\n authorId: uniqueId(),\n localVersion: 0,\n },\n };\n\n const nextAuthorMarker = () => {\n data.author = createNextAuthorMarker(data.author);\n debug('nextAuthorMarker', data.author);\n return data.author;\n };\n\n const closedRef = ref(false);\n\n const uTagRef = ref(state.uTag);\n\n const debounceSpan = settings.debounceSpan ?? 200;\n\n const setArgsQueue = new UpdateSerializer({ debounceSpan });\n const setUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setArgsAndUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setNavigationStateQueue = new UpdateSerializer({ debounceSpan });\n /**\n * Reactive snapshot of the application state, including args, outputs, UI state, and navigation state.\n */\n const snapshot = ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>(state.value) as Ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>;\n\n const setBlockArgs = async (args: Args) => {\n return platforma.setBlockArgs(args, nextAuthorMarker());\n };\n\n const setBlockUiState = async (ui: UiState) => {\n return platforma.setBlockUiState(ui, nextAuthorMarker());\n };\n\n const setBlockArgsAndUiState = async (args: Args, ui: UiState) => {\n return platforma.setBlockArgsAndUiState(args, ui, nextAuthorMarker());\n };\n\n const setNavigationState = async (state: NavigationState<Href>) => {\n return platforma.setNavigationState(state);\n };\n\n const outputs = computed<OutputValues<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr.ok && vOrErr.value !== undefined ? vOrErr.value : undefined]);\n return Object.fromEntries(entries);\n });\n\n const outputErrors = computed<OutputErrors<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr && !vOrErr.ok ? new MultiError(vOrErr.errors) : undefined]);\n return Object.fromEntries(entries);\n });\n\n const appModel = reactive({\n error: '',\n model: {\n args: deepClone(snapshot.value.args) as Args,\n ui: deepClone(snapshot.value.ui) as UiState,\n outputs,\n outputErrors,\n },\n }) as {\n error: string;\n model: {\n args: Args;\n ui: UiState;\n outputs: OutputValues<Outputs>;\n outputErrors: OutputErrors<Outputs>;\n };\n };\n\n const { ignoreUpdates } = watchIgnorable(\n () => appModel.model,\n (_newData) => {\n const newData = deepClone(_newData);\n debug('setArgsAndUiStateQueue appModel.model', newData);\n setArgsAndUiStateQueue.run(() => setBlockArgsAndUiState(newData.args, newData.ui).then(unwrapResult));\n },\n { deep: true },\n );\n\n const updateAppModel = (newData: {\n args: Args;\n ui: UiState;\n }) => {\n debug('updateAppModel', newData);\n appModel.model.args = deepClone(newData.args) as Args;\n appModel.model.ui = deepClone(newData.ui) as UiState;\n };\n\n (async () => {\n window.addEventListener('beforeunload', () => {\n closedRef.value = true;\n platforma.dispose().then(unwrapResult).catch((err) => {\n error('error in dispose', err);\n });\n });\n\n while (!closedRef.value) {\n try {\n const patches = await platforma.getPatches(uTagRef.value).then(unwrapResult);\n\n debug('patches.length', patches.value.length);\n debug('uTagRef.value', uTagRef.value);\n debug('patches.uTag', patches.uTag);\n debug('patches.author', patches.author);\n debug('data.author', data.author);\n\n uTagRef.value = patches.uTag;\n\n if (patches.value.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n continue;\n }\n\n const isAuthorChanged = data.author?.authorId !== patches.author?.authorId;\n\n // Immutable behavior, apply external changes to the snapshot\n if (isAuthorChanged || data.isExternalSnapshot) {\n debug('got external changes, applying them to the snapshot', snapshot.value);\n ignoreUpdates(() => {\n snapshot.value = applyPatch(snapshot.value, patches.value, false, false).newDocument;\n updateAppModel({ args: snapshot.value.args, ui: snapshot.value.ui });\n data.isExternalSnapshot = isAuthorChanged;\n });\n } else {\n // Mutable behavior\n snapshot.value = applyPatch(snapshot.value, patches.value).newDocument;\n }\n\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n } catch (err) {\n if (hasAbortError(err)) {\n debug('patches loop aborted');\n closedRef.value = true;\n } else {\n error('error in patches loop', err);\n await new Promise((resolve) => setTimeout(resolve, 1000));\n }\n }\n }\n })();\n\n const cloneArgs = () => deepClone(appModel.model.args) as Args;\n const cloneUiState = () => deepClone(appModel.model.ui) as UiState;\n const cloneNavigationState = () => deepClone(snapshot.value.navigationState) as Mutable<NavigationState<Href>>;\n\n const methods = {\n cloneArgs,\n cloneUiState,\n cloneNavigationState,\n createArgsModel<T extends Args = Args>(options: StateModelOptions<Args, T> = {}) {\n return createModel<T, Args>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.args as Args);\n }\n\n return snapshot.value.args as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newArgs) {\n setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n });\n },\n /**\n * defaultUiState is temporarily here, remove it after implementing initialUiState\n */\n createUiModel<T extends UiState = UiState>(options: StateModelOptions<UiState, T> = {}, defaultUiState: () => UiState) {\n return createModel<T, UiState>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.ui as UiState);\n }\n\n return (snapshot.value.ui ?? defaultUiState()) as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newData) {\n setUiStateQueue.run(() => setBlockUiState(newData).then(unwrapResult));\n },\n });\n },\n /**\n * Retrieves the unwrapped values of outputs for the given keys.\n *\n * @template K - Keys of the outputs to unwrap.\n * @param keys - List of output names.\n * @throws Error if the outputs contain errors.\n * @returns An object with unwrapped output values.\n */\n unwrapOutputs<K extends keyof Outputs>(...keys: K[]): UnwrapOutputs<Outputs, K> {\n const outputs = snapshot.value.outputs as Partial<Readonly<Outputs>>;\n const entries = keys.map((key) => [key, unwrapValueOrErrors(outputs[key])]);\n return Object.fromEntries(entries);\n },\n /**\n * Updates the arguments state by applying a callback.\n *\n * @param cb - Callback to modify the current arguments.\n * @returns A promise resolving after the update is applied.\n */\n updateArgs(cb: (args: Args) => void): Promise<boolean> {\n const newArgs = cloneArgs();\n cb(newArgs);\n debug('updateArgs', newArgs);\n appModel.model.args = newArgs;\n return setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n /**\n * Updates the UI state by applying a callback.\n *\n * @param cb - Callback to modify the current UI state.\n * @returns A promise resolving after the update is applied.\n * @todo Make it mutable since there is already an initial one\n */\n updateUiState(cb: (args: UiState) => UiState): Promise<boolean> {\n const newUiState = cb(cloneUiState());\n debug('updateUiState', newUiState);\n appModel.model.ui = newUiState;\n return setUiStateQueue.run(() => setBlockUiState(newUiState).then(unwrapResult));\n },\n /**\n * Navigates to a specific href by updating the navigation state.\n *\n * @param href - The target href to navigate to.\n * @returns A promise resolving after the navigation state is updated.\n */\n navigateTo(href: Href) {\n const newState = cloneNavigationState();\n newState.href = href;\n return setNavigationStateQueue.run(() => setNavigationState(newState).then(unwrapResult));\n },\n async allSettled() {\n await delay(0);\n return setArgsAndUiStateQueue.allSettled();\n },\n };\n\n const getters = {\n closedRef,\n snapshot,\n queryParams: computed(() => parseQuery<Href>(snapshot.value.navigationState.href as Href)),\n href: computed(() => snapshot.value.navigationState.href),\n hasErrors: computed(() => Object.values(snapshot.value.outputs as Partial<Readonly<Outputs>>).some((v) => !v?.ok)),\n };\n\n return reactive(Object.assign(appModel, methods, getters));\n}\n\nexport type BaseAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n> = ReturnType<typeof createAppV2<Args, Outputs, UiState, Href>>;\n"],"names":["patchPoolingDelay","createNextAuthorMarker","marker","uniqueId","stringifyForDebug","v","err","createAppV2","state","platforma","settings","debug","msg","rest","r","error","data","nextAuthorMarker","closedRef","ref","uTagRef","debounceSpan","setArgsQueue","UpdateSerializer","setUiStateQueue","setArgsAndUiStateQueue","setNavigationStateQueue","snapshot","setBlockArgs","args","setBlockUiState","ui","setBlockArgsAndUiState","setNavigationState","outputs","computed","entries","k","vOrErr","outputErrors","MultiError","appModel","reactive","deepClone","ignoreUpdates","watchIgnorable","_newData","newData","unwrapResult","updateAppModel","patches","resolve","isAuthorChanged","_a","_b","applyPatch","hasAbortError","cloneArgs","cloneUiState","cloneNavigationState","methods","options","createModel","newArgs","defaultUiState","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