@floegence/floe-webapp-core 0.36.75 → 0.36.76

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.
@@ -13,6 +13,8 @@ export interface CreateUIFirstSelectionOptions<T, M = undefined> {
13
13
  committed: Accessor<T>;
14
14
  commit: (value: T, metadata: M | undefined) => void;
15
15
  equals?: (left: T, right: T) => boolean;
16
+ /** Run the deferred commit even when the requested value already equals canonical state. */
17
+ commitEqualRequests?: boolean;
16
18
  onEvent?: (event: UIFirstSelectionEvent<T, M>) => void;
17
19
  scheduleAfterPaint?: (callback: () => void) => void;
18
20
  }
@@ -1,66 +1,70 @@
1
- import { createSignal as w, untrack as q, createEffect as h, onCleanup as x } from "solid-js";
2
- import { deferAfterPaint as I } from "./defer.js";
3
- function g() {
1
+ import { untrack as p, createSignal as v, createEffect as x, onCleanup as C } from "solid-js";
2
+ import { deferAfterPaint as E } from "./defer.js";
3
+ function w() {
4
4
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
5
5
  }
6
- function E(n) {
7
- const f = n.equals ?? Object.is, o = n.scheduleAfterPaint ?? I, [v, i] = w(q(n.committed), { equals: f }), [A, d] = w(!1);
8
- let r = null, u = 1, c = !1, m = !1;
9
- const s = (e, t) => {
10
- const a = g();
11
- n.onEvent?.({
12
- phase: e,
13
- value: t.value,
14
- metadata: t.metadata,
15
- transactionId: t.id,
16
- startedAt: t.startedAt,
17
- timestamp: a,
18
- elapsedMs: Math.max(0, a - t.startedAt)
6
+ function b(a) {
7
+ const m = a.equals ?? Object.is, u = a.scheduleAfterPaint ?? E;
8
+ let o = p(a.committed);
9
+ const [A, i] = v(o, { equals: m }), [q, d] = v(!1);
10
+ let c = null, g = 1, r = !1, f = !1;
11
+ const s = (t, n) => {
12
+ const e = w();
13
+ a.onEvent?.({
14
+ phase: t,
15
+ value: n.value,
16
+ metadata: n.metadata,
17
+ transactionId: n.id,
18
+ startedAt: n.startedAt,
19
+ timestamp: e,
20
+ elapsedMs: Math.max(0, e - n.startedAt)
19
21
  });
20
- }, l = (e) => {
21
- const t = r;
22
- r = null, m = !1, d(!1), t && s("cancelled", t), e && !c && i(() => n.committed());
23
- }, P = (e, t) => {
24
- if (c) return;
25
- if (r && l(!1), m = !1, i(() => e), f(e, n.committed())) {
22
+ }, l = (t) => {
23
+ const n = c;
24
+ c = null, f = !1, d(!1), n && s("cancelled", n), t && !r && i(() => a.committed());
25
+ }, P = (t, n) => {
26
+ if (r) return;
27
+ if (c && l(!1), f = !1, i(() => t), m(t, a.committed()) && !a.commitEqualRequests) {
26
28
  d(!1);
27
29
  return;
28
30
  }
29
- const a = {
30
- id: u,
31
- value: e,
32
- metadata: t,
33
- startedAt: g(),
31
+ const e = {
32
+ id: g,
33
+ value: t,
34
+ metadata: n,
35
+ startedAt: w(),
34
36
  committing: !1
35
37
  };
36
- u += 1, r = a, d(!0), s("requested", a), o(() => {
37
- c || r !== a || (s("intent_presented", a), s("commit_started", a), a.committing = !0, n.commit(a.value, a.metadata), a.committing = !1, !(c || r !== a) && (s("committed", a), o(() => {
38
- c || r !== a || (s("content_presented", a), r = null, d(!1), i(() => n.committed()));
38
+ g += 1, c = e, d(!0), s("requested", e), u(() => {
39
+ r || c !== e || (s("intent_presented", e), s("commit_started", e), e.committing = !0, a.commit(e.value, e.metadata), e.committing = !1, !(r || c !== e) && (s("committed", e), u(() => {
40
+ r || c !== e || (s("content_presented", e), c = null, d(!1), i(() => a.committed()));
39
41
  })));
40
42
  });
41
- }, p = (e, t) => {
42
- c || (l(!1), m = !1, i(() => e), f(e, n.committed()) || n.commit(e, t), i(() => n.committed()));
43
+ }, h = (t, n) => {
44
+ r || (l(!1), f = !1, i(() => t), m(t, a.committed()) || a.commit(t, n), i(() => a.committed()));
43
45
  };
44
- return h(() => {
45
- const e = n.committed(), t = r;
46
- t && t.committing && f(e, t.value) || (t && !f(e, t.value) && l(!1), (!r || !f(e, r.value)) && (m = !1, i(() => e)));
47
- }), x(() => {
48
- c = !0, l(!1);
46
+ return x(() => {
47
+ const t = a.committed(), n = !m(t, o);
48
+ o = t;
49
+ const e = c;
50
+ e && e.committing && m(t, e.value) || (e && n && !m(t, e.value) && l(!1), (!c || !m(t, c.value)) && (f = !1, i(() => t)));
51
+ }), C(() => {
52
+ r = !0, l(!1);
49
53
  }), {
50
- visual: v,
51
- committed: n.committed,
52
- pending: A,
53
- preview: (e) => {
54
- c || r || (m = !0, i(() => e));
54
+ visual: A,
55
+ committed: a.committed,
56
+ pending: q,
57
+ preview: (t) => {
58
+ r || c || (f = !0, i(() => t));
55
59
  },
56
60
  resetPreview: () => {
57
- c || !m || r || (m = !1, i(() => n.committed()));
61
+ r || !f || c || (f = !1, i(() => a.committed()));
58
62
  },
59
63
  request: P,
60
- commitNow: p,
64
+ commitNow: h,
61
65
  cancel: () => l(!0)
62
66
  };
63
67
  }
64
68
  export {
65
- E as createUIFirstSelection
69
+ b as createUIFirstSelection
66
70
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.75",
3
+ "version": "0.36.76",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",