@plitzi/sdk-interactions 0.39.1 → 0.39.2

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/CHANGELOG.md +11 -0
  2. package/dist/InteractionsContext.mjs +1 -2
  3. package/dist/InteractionsContextProvider.mjs +5 -6
  4. package/dist/InteractionsHelper.mjs +40 -42
  5. package/dist/InteractionsManager.d.ts +13 -0
  6. package/dist/InteractionsManager.mjs +79 -37
  7. package/dist/InteractionsSourcesProvider.mjs +1 -2
  8. package/dist/declarations/index.mjs +9 -9
  9. package/dist/helpers/coerceDeclaredParams.mjs +1 -2
  10. package/dist/hooks/useInteractions.mjs +1 -2
  11. package/dist/index.mjs +6 -6
  12. package/dist/sources/ActionsSource/ActionInteractions.mjs +205 -196
  13. package/dist/sources/ActionsSource/ServerActionContext.mjs +2 -3
  14. package/dist/sources/ActionsSource/callbacks.mjs +1 -2
  15. package/dist/sources/ActionsSource/deliverCall.d.ts +45 -0
  16. package/dist/sources/ActionsSource/deliverCall.mjs +80 -0
  17. package/dist/sources/ActionsSource/index.mjs +3 -3
  18. package/dist/sources/AuthSource/AuthInteractions.mjs +5 -6
  19. package/dist/sources/AuthSource/callbacks.mjs +1 -2
  20. package/dist/sources/HostSource/HostInteractions.mjs +5 -6
  21. package/dist/sources/HostSource/callbacks.mjs +1 -2
  22. package/dist/sources/HostSource/index.mjs +3 -3
  23. package/dist/sources/NavigationSource/NavigationInteractions.mjs +9 -10
  24. package/dist/sources/NavigationSource/callbacks.mjs +1 -2
  25. package/dist/sources/NavigationSource/navigateHow.mjs +1 -2
  26. package/dist/sources/QueriesSource/QueriesInteractions.mjs +5 -6
  27. package/dist/sources/QueriesSource/callbacks.mjs +1 -2
  28. package/dist/sources/QueriesSource/writeParams.mjs +1 -2
  29. package/dist/sources/StateSource/StateInteractions.mjs +5 -6
  30. package/dist/sources/StateSource/callbacks.mjs +1 -2
  31. package/dist/utility/copyToClipboard.mjs +1 -2
  32. package/dist/utility/copyToClipboardSpec.mjs +1 -2
  33. package/dist/utility/delayTime.mjs +1 -2
  34. package/dist/utility/index.mjs +1 -2
  35. package/dist/utility/twigTemplate.mjs +1 -2
  36. package/dist/utility/webHook.mjs +1 -2
  37. package/dist/utility/webHookSpec.mjs +1 -2
  38. package/package.json +14 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @plitzi/sdk-interactions
2
2
 
3
+ ## 0.39.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fad1264: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
8
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
9
+ - Updated dependencies [fad1264]
10
+ - @plitzi/sdk-auth@0.39.2
11
+ - @plitzi/sdk-event-bridge@0.39.2
12
+ - @plitzi/sdk-shared@0.39.2
13
+
3
14
  ## 0.39.1
4
15
 
5
16
  ### Patch Changes
@@ -1,4 +1,3 @@
1
- import { sharedContext as e } from "@plitzi/sdk-shared/helpers";
1
+ import { sharedContext as e } from "@plitzi/sdk-shared/react";
2
2
  var t = e("InteractionsContext", {});
3
- //#endregion
4
3
  export { t as default };
@@ -1,9 +1,9 @@
1
- import e from "./InteractionsContext.mjs";
2
- import t from "./hooks/useInteractions.mjs";
1
+ import e from "./hooks/useInteractions.mjs";
2
+ import t from "./InteractionsContext.mjs";
3
3
  import n from "./InteractionsManager.mjs";
4
4
  import { useMemo as r, useState as i } from "react";
5
5
  import { jsx as a } from "react/jsx-runtime";
6
- //#region src/InteractionsContextProvider.tsx
6
+ // src/InteractionsContextProvider.tsx
7
7
  var o = ({ children: o, currentPageId: s, routeParams: c, queryParams: l }) => {
8
8
  let [u] = i(() => new n(s, c, l));
9
9
  u.interactionsData = r(() => ({
@@ -17,12 +17,11 @@ var o = ({ children: o, currentPageId: s, routeParams: c, queryParams: l }) => {
17
17
  ]);
18
18
  let d = r(() => ({
19
19
  interactionsManager: u,
20
- useInteractions: t
20
+ useInteractions: e
21
21
  }), [u]);
22
- return /* @__PURE__ */ a(e, {
22
+ return /* @__PURE__ */ a(t, {
23
23
  value: d,
24
24
  children: o
25
25
  });
26
26
  };
27
- //#endregion
28
27
  export { o as default };
@@ -1,21 +1,20 @@
1
1
  import { coerceDeclaredParams as e } from "./helpers/coerceDeclaredParams.mjs";
2
2
  import t from "./utility/index.mjs";
3
- import { ruleValuesOf as n } from "@plitzi/sdk-shared/helpers";
4
- import { get as r, omit as i } from "@plitzi/plitzi-ui/helpers";
5
- import { QueryBuilderEvaluator as a } from "@plitzi/plitzi-ui/QueryBuilder/evaluator";
6
- import { pConsole as o } from "@plitzi/sdk-shared/devTools";
3
+ import { get as n, omit as r } from "@plitzi/plitzi-ui/helpers";
4
+ import { pConsole as i } from "@plitzi/sdk-shared/devTools";
5
+ import { evaluateRuleGroup as a, ruleValuesOf as o } from "@plitzi/sdk-shared/conditions";
7
6
  import { MAX_PARAM_PASSES as s, resolveStepParam as c } from "@plitzi/sdk-shared/helpers/twigWrapper";
8
7
  import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
9
- //#region src/InteractionsHelper.tsx
10
- var f = 5, p = (e, t, n, r, i) => {
11
- if (e === "utility" && i === "twigTemplate") return t;
12
- let a = {
8
+ // src/InteractionsHelper.tsx
9
+ var f = 5, p = (e, t, n, r, a) => {
10
+ if (e === "utility" && a === "twigTemplate") return t;
11
+ let o = {
13
12
  ...n,
14
13
  ...r
15
14
  }, l = (e, t, n) => {
16
15
  if (typeof e == "string") {
17
- let { value: n, unresolved: r } = c(e, a);
18
- return r && o.warning("interactions", /* @__PURE__ */ d("span", { children: [
16
+ let { value: n, unresolved: r } = c(e, o);
17
+ return r && i.warning("interactions", /* @__PURE__ */ d("span", { children: [
19
18
  "Twig token resolution exceeded ",
20
19
  s,
21
20
  " passes for ",
@@ -35,14 +34,14 @@ var f = 5, p = (e, t, n, r, i) => {
35
34
  [r]: i
36
35
  };
37
36
  }, {});
38
- }, m = (e) => typeof e == "object" && !!e && "then" in e && typeof e.then == "function", h = (i, s = {}, c = {}, l = {}, f = {}) => {
39
- let h = [], { id: g, action: _, enabled: v, params: y, elementId: b, type: x, when: S } = i;
37
+ }, m = (e) => typeof e == "object" && !!e && "then" in e && typeof e.then == "function", h = (r, s = {}, c = {}, l = {}, f = {}) => {
38
+ let h = [], { id: g, action: _, enabled: v, params: y, elementId: b, type: x, when: S } = r;
40
39
  if (!_ || !v) return {
41
40
  status: "disabled",
42
41
  result: {},
43
42
  postCallbacks: h
44
43
  };
45
- let C = n({
44
+ let C = o({
46
45
  ...l,
47
46
  ...c,
48
47
  [g]: y
@@ -53,9 +52,9 @@ var f = 5, p = (e, t, n, r, i) => {
53
52
  postCallbacks: h,
54
53
  whenParams: C
55
54
  };
56
- let w = (e) => (o.danger("interactions", /* @__PURE__ */ d("span", { children: ["Interaction node failed ", /* @__PURE__ */ u("b", { children: _ })] }), {
55
+ let w = (e) => (i.danger("interactions", /* @__PURE__ */ d("span", { children: ["Interaction node failed ", /* @__PURE__ */ u("b", { children: _ })] }), {
57
56
  error: e instanceof Error ? e.message : String(e),
58
- node: i
57
+ node: r
59
58
  }), {
60
59
  status: "failed",
61
60
  result: {},
@@ -65,23 +64,23 @@ var f = 5, p = (e, t, n, r, i) => {
65
64
  switch (x) {
66
65
  case "callback":
67
66
  case "globalCallback":
68
- if (!b) return o.warning("interactions", /* @__PURE__ */ d("span", { children: [
67
+ if (!b) return i.warning("interactions", /* @__PURE__ */ d("span", { children: [
69
68
  "Step ",
70
69
  /* @__PURE__ */ u("b", { children: _ }),
71
70
  " names no element, so there is nothing to run it on"
72
- ] }), { node: i }), {
71
+ ] }), { node: r }), {
73
72
  status: "failed",
74
73
  result: {},
75
74
  postCallbacks: h,
76
75
  whenParams: C
77
76
  };
78
- if (T = r(s, `${b}.${_}`), !T) return o.warning("interactions", /* @__PURE__ */ d("span", { children: [
77
+ if (T = n(s, `${b}.${_}`), !T) return i.warning("interactions", /* @__PURE__ */ d("span", { children: [
79
78
  "Nothing is registered as ",
80
79
  /* @__PURE__ */ u("b", { children: `${b}.${_}` }),
81
80
  ", so this step did nothing"
82
81
  ] }), {
83
- node: i,
84
- available: Object.keys(r(s, b, {}))
82
+ node: r,
83
+ available: Object.keys(n(s, b, {}))
85
84
  }), {
86
85
  status: "failed",
87
86
  result: {},
@@ -90,7 +89,7 @@ var f = 5, p = (e, t, n, r, i) => {
90
89
  };
91
90
  break;
92
91
  case "utility":
93
- T = r(t, _, {});
92
+ T = n(t, _, {});
94
93
  break;
95
94
  default: return {
96
95
  status: "success",
@@ -123,40 +122,40 @@ var f = 5, p = (e, t, n, r, i) => {
123
122
  }
124
123
  }, g = async (e = []) => {
125
124
  let t = {};
126
- return await Promise.all(e.reverse().map(async ({ id: e, callback: n, params: r }) => {
127
- t[e] = await n?.(i(r, [e]), r[e]);
125
+ return await Promise.all(e.reverse().map(async ({ id: e, callback: n, params: i }) => {
126
+ t[e] = await n?.(r(i, [e]), i[e]);
128
127
  })), t;
129
- }, _ = () => ({}), v = async (e, t = {}, n = {}, i = {}, a = _, s = [], c = {}, l = {}) => {
130
- let u = e, d = i;
128
+ }, _ = () => ({}), v = async (e, t = {}, r = {}, a = {}, o = _, s = [], c = {}, l = {}) => {
129
+ let u = e, d = a;
131
130
  for (; u;) {
132
131
  if (l.signal?.aborted) return c;
133
- let e = r(t, u.afterNode);
132
+ let e = n(t, u.afterNode);
134
133
  if (!e) return s.length > 0 && await g(s), c;
135
- let i = o.getTime().valueOf(), f = h(e, n, d, a(), l), p = m(f) ? await f : f, { result: _, postCallbacks: v, whenParams: y } = p, b = p.status === "failed" && l.signal?.aborted ? "skipped" : p.status;
134
+ let a = i.getTime().valueOf(), f = h(e, r, d, o(), l), p = m(f) ? await f : f, { result: _, postCallbacks: v, whenParams: y } = p, b = p.status === "failed" && l.signal?.aborted ? "skipped" : p.status;
136
135
  c[e.id] = {
137
136
  node: e,
138
137
  status: b,
139
138
  result: _,
140
139
  postCallbacks: v,
141
140
  whenParams: y,
142
- startTime: i,
143
- endTime: o.getTime().valueOf()
141
+ startTime: a,
142
+ endTime: i.getTime().valueOf()
144
143
  }, s.push(...v), d = {
145
144
  ...d,
146
145
  [e.id]: _
147
146
  }, u = e;
148
147
  }
149
148
  return c;
150
- }, y = (e, t, n = {}, r, i) => {
151
- let a = o.getTime().valueOf(), s = r === "skipped" ? "skipped" : "success", c = /* @__PURE__ */ d("span", { children: [
149
+ }, y = (e, t, n = {}, r, a) => {
150
+ let o = i.getTime().valueOf(), s = r === "skipped" ? "skipped" : "success", c = /* @__PURE__ */ d("span", { children: [
152
151
  "Interaction triggered ",
153
152
  /* @__PURE__ */ u("b", { children: `${e.title} [${e.action}]` }),
154
- i ? /* @__PURE__ */ d(l, { children: [" on ", /* @__PURE__ */ u("b", { children: i })] }) : null
153
+ a ? /* @__PURE__ */ d(l, { children: [" on ", /* @__PURE__ */ u("b", { children: a })] }) : null
155
154
  ] }), f = {
156
155
  status: r,
157
156
  node: e,
158
157
  elementId: e.elementId,
159
- hostElementId: i,
158
+ hostElementId: a,
160
159
  nodes: {
161
160
  ...n,
162
161
  [e.id]: {
@@ -165,27 +164,26 @@ var f = 5, p = (e, t, n, r, i) => {
165
164
  result: void 0,
166
165
  postCallbacks: [],
167
166
  startTime: t,
168
- endTime: a
167
+ endTime: o
169
168
  }
170
169
  },
171
170
  startTime: t,
172
- endTime: a
171
+ endTime: o
173
172
  };
174
- r === "failed" ? o.danger("interactions", c, f) : o.info("interactions", c, f);
175
- }, b = (e) => Object.values(e).some(({ status: e }) => e === "failed") ? "failed" : "completed", x = async (e, t = {}, r = {}, i = {}, s = _, c, l, u = []) => {
176
- let d = o.getTime().valueOf(), { action: f, enabled: p, when: m } = e;
177
- if (!f || !p || m && !a(m, n({
173
+ r === "failed" ? i.danger("interactions", c, f) : i.info("interactions", c, f);
174
+ }, b = (e) => Object.values(e).some(({ status: e }) => e === "failed") ? "failed" : "completed", x = async (e, t = {}, n = {}, r = {}, s = _, c, l, u = []) => {
175
+ let d = i.getTime().valueOf(), { action: f, enabled: p, when: m } = e;
176
+ if (!f || !p || m && !a(m, o({
178
177
  ...s(),
179
- ...i
178
+ ...r
180
179
  }))) {
181
180
  y(e, d, {}, "skipped", c);
182
181
  return;
183
182
  }
184
- let h = await v(e, t, r, i, s, u, {}, {
183
+ let h = await v(e, t, n, r, s, u, {}, {
185
184
  hostElementId: c,
186
185
  ...l ? { signal: l } : {}
187
186
  });
188
187
  y(e, d, h, b(h), c);
189
188
  }, S = { flowTrigger: x };
190
- //#endregion
191
189
  export { S as default, x as flowTrigger };
@@ -17,6 +17,14 @@ declare class InteractionsManager implements InteractionsManagerApi {
17
17
  private latestRuns;
18
18
  lastUpdate: number;
19
19
  private listeners;
20
+ /**
21
+ * Triggers fired at an element that has not subscribed yet, by element: fired once it wires its flows (`update`).
22
+ *
23
+ * An element's handlers are React's from the commit, its flows are wired from an effect React runs after it: a tap in
24
+ * between — on a page that has just hydrated, before its effects have run — fired a trigger no flow answered, and
25
+ * the tap did nothing, with nothing said. Kept a few seconds, a few per element.
26
+ */
27
+ private parked;
20
28
  constructor(currentPageId?: string, routeParams?: RouteParams, queryParams?: QueryParams);
21
29
  eventBridgeCallback: (interactions?: Record<string, ElementInteraction>) => (subscriptorId: string, eventName: string, params: Record<string, unknown>) => Promise<void>;
22
30
  /** One firing of one flow, as its trigger's `whileRunning` says — see {@link WhileRunning}. */
@@ -48,6 +56,11 @@ declare class InteractionsManager implements InteractionsManagerApi {
48
56
  [x: string]: Record<string, InteractionCallback> | Record<string, InteractionCallback<any>>;
49
57
  };
50
58
  interactionTrigger(subscriptorId: string | undefined, eventName: string, params?: Record<string, unknown>): Promise<unknown[]> | undefined;
59
+ private park;
60
+ private replayParked;
61
+ private dropParked;
62
+ /** A trigger no element took up: said, so a tap that did nothing is not silent. */
63
+ private settleUnanswered;
51
64
  createChildManager: (routeParams?: Record<string, string>, queryParams?: Record<string, string>) => InteractionsManager;
52
65
  removeChildManager: (childManager: InteractionsManagerApi) => void;
53
66
  onUpdate(listener: InteractionUpdateListener): () => void;
@@ -1,15 +1,16 @@
1
1
  import { flowTrigger as e } from "./InteractionsHelper.mjs";
2
- import { INTERVAL_TRIGGER as t, KEY_TRIGGER as n, intervalOf as r } from "@plitzi/sdk-shared/helpers";
3
- import { get as i, set as a } from "@plitzi/plitzi-ui/helpers";
4
- import o from "@plitzi/sdk-event-bridge";
5
- //#region src/InteractionsManager.ts
6
- var s = (e, i) => {
7
- if (e.action === n) {
8
- let { shortcuts: t } = i;
9
- return Array.isArray(t) && t.includes(e.params.keys);
10
- }
11
- return e.action !== t || r(e.params.interval) === i.interval;
12
- }, c = class t {
2
+ import { get as t, set as n } from "@plitzi/plitzi-ui/helpers";
3
+ import r from "@plitzi/sdk-event-bridge";
4
+ import { pConsole as i } from "@plitzi/sdk-shared/devTools";
5
+ import { INTERVAL_TRIGGER as a, KEY_TRIGGER as o, intervalOf as s } from "@plitzi/sdk-shared/helpers";
6
+ // src/InteractionsManager.ts
7
+ var c = (e, t) => {
8
+ if (e.action === o) {
9
+ let { shortcuts: n } = t;
10
+ return Array.isArray(n) && n.includes(e.params.keys);
11
+ }
12
+ return e.action !== a || s(e.params.interval) === t.interval;
13
+ }, l = 5e3, u = 20, d = class a {
13
14
  eventBridge;
14
15
  parentManager;
15
16
  childManagers;
@@ -20,22 +21,23 @@ var s = (e, i) => {
20
21
  latestRuns = /* @__PURE__ */ new Map();
21
22
  lastUpdate;
22
23
  listeners = /* @__PURE__ */ new Set();
24
+ parked = /* @__PURE__ */ new Map();
23
25
  constructor(e = "", t = {}, n = {}) {
24
- this.eventBridge = new o(), this.parentManager = void 0, this.childManagers = [], this.subscriptors = {}, this.callbacksAvailables = {}, this.interactionsData = {
26
+ this.eventBridge = new r(), this.parentManager = void 0, this.childManagers = [], this.subscriptors = {}, this.callbacksAvailables = {}, this.interactionsData = {
25
27
  currentPageId: e,
26
28
  ...t,
27
29
  ...n
28
30
  }, this.lastUpdate = Date.now();
29
31
  }
30
- eventBridgeCallback = (t) => async (n, r, a) => {
31
- if (!t || !r || !n) return;
32
- let o = this.subscriptors[n];
33
- if (await Promise.resolve(), !o || this.subscriptors[n] !== o) return;
34
- let c = i(this.subscriptors, `${n}.getAdditionalParams`, void 0), l = () => ({
32
+ eventBridgeCallback = (n) => async (r, i, a) => {
33
+ if (!n || !i || !r) return;
34
+ let o = this.subscriptors[r];
35
+ if (await Promise.resolve(), !o || this.subscriptors[r] !== o) return;
36
+ let s = t(this.subscriptors, `${r}.getAdditionalParams`, void 0), l = () => ({
35
37
  ...this.interactionsData,
36
- ...typeof c == "function" ? c().dataSource : void 0
37
- }), u = Object.values(t).filter((e) => e.type === "trigger" && e.action === r && e.enabled && s(e, a));
38
- await Promise.all(u.map((r) => this.runFlow(`${n}.${r.id}`, r.whileRunning ?? "skip", (i) => e(r, t, this.getCallbacksAvailables(), { [r.id]: a }, l, n, i))));
38
+ ...typeof s == "function" ? s().dataSource : void 0
39
+ }), u = Object.values(n).filter((e) => e.type === "trigger" && e.action === i && e.enabled && c(e, a));
40
+ await Promise.all(u.map((t) => this.runFlow(`${r}.${t.id}`, t.whileRunning ?? "skip", (i) => e(t, n, this.getCallbacksAvailables(), { [t.id]: a }, l, r, i))));
39
41
  };
40
42
  runFlow(e, t, n) {
41
43
  if (t === "latest") {
@@ -53,16 +55,16 @@ var s = (e, i) => {
53
55
  });
54
56
  return this.flowsRunning.set(e, i), i;
55
57
  }
56
- subscribe(e, t = {}, n = {}, r = {}, i) {
57
- return !e || this.subscriptors[e] ? !1 : (a(this.subscriptors, e, {
58
+ subscribe(e, t = {}, r = {}, i = {}, a) {
59
+ return !e || this.subscriptors[e] ? !1 : (n(this.subscriptors, e, {
58
60
  id: e,
59
- triggers: n,
60
- getAdditionalParams: i
61
- }), this.wire(e, t, n, r), this.touch(), !0);
61
+ triggers: r,
62
+ getAdditionalParams: a
63
+ }), this.wire(e, t, r, i), this.touch(), !0);
62
64
  }
63
65
  update(e, t = {}, n = {}, r = {}, i) {
64
66
  let a = this.subscriptors[e];
65
- return a ? (a.triggers = n, a.getAdditionalParams = i, this.wire(e, t, n, r), this.touch(), !0) : !1;
67
+ return a ? (a.triggers = n, a.getAdditionalParams = i, this.wire(e, t, n, r), this.touch(), this.replayParked(e), !0) : !1;
66
68
  }
67
69
  wire(e, t, n, r) {
68
70
  let i = Object.keys(r);
@@ -84,17 +86,17 @@ var s = (e, i) => {
84
86
  }, {}) : delete this.callbacksAvailables[e], Object.keys(n).length > 0 ? this.eventBridge.on("interaction", e, this.eventBridgeCallback(t), { override: !0 }) : this.eventBridge.off("interaction", e);
85
87
  }
86
88
  unsubscribe(e) {
87
- return this.subscriptors[e] ? (this.eventBridge.off("interaction", e), delete this.subscriptors[e], this.callbacksAvailables[e] && delete this.callbacksAvailables[e], this.touch(), !0) : !1;
89
+ return this.subscriptors[e] ? (this.eventBridge.off("interaction", e), delete this.subscriptors[e], this.dropParked(e), this.callbacksAvailables[e] && delete this.callbacksAvailables[e], this.touch(), !0) : !1;
88
90
  }
89
91
  getRootManager() {
90
92
  return this.parentManager ? this.parentManager.getRootManager() : this;
91
93
  }
92
94
  getSubscriptorInternal(e) {
93
- let t = i(this.subscriptors, e);
94
- if (!t && this.childManagers.length > 0) {
95
- for (let n of this.childManagers) if (t = n.getSubscriptorInternal(e), t) break;
95
+ let n = t(this.subscriptors, e);
96
+ if (!n && this.childManagers.length > 0) {
97
+ for (let t of this.childManagers) if (n = t.getSubscriptorInternal(e), n) break;
96
98
  }
97
- return t;
99
+ return n;
98
100
  }
99
101
  getSubscriptor(e) {
100
102
  return this.parentManager ? this.getRootManager()?.getSubscriptorInternal(e) : this.getSubscriptorInternal(e);
@@ -125,11 +127,52 @@ var s = (e, i) => {
125
127
  };
126
128
  }
127
129
  interactionTrigger(e, t, n = {}) {
128
- if (e) return this.eventBridge.emit("interaction", e, e, t, n);
130
+ if (e) return this.subscriptors[e] ? this.eventBridge.emit("interaction", e, e, t, n) : this.park(e, t, n);
131
+ }
132
+ park(e, t, n) {
133
+ let r = Date.now(), i = (this.parked.get(e) ?? []).filter((t) => r - t.at <= l || (this.settleUnanswered(e, t), !1));
134
+ if (i.length >= u) {
135
+ let t = i.shift();
136
+ t && this.settleUnanswered(e, t);
137
+ }
138
+ return new Promise((a) => {
139
+ i.push({
140
+ eventName: t,
141
+ params: n,
142
+ at: r,
143
+ settle: a
144
+ }), this.parked.set(e, i);
145
+ });
146
+ }
147
+ replayParked(e) {
148
+ let t = this.parked.get(e);
149
+ if (!t) return;
150
+ this.parked.delete(e);
151
+ let n = Date.now();
152
+ t.forEach((t) => {
153
+ n - t.at > l ? this.settleUnanswered(e, t) : this.eventBridge.emit("interaction", e, e, t.eventName, t.params).then(t.settle, (n) => {
154
+ i.danger("interactions", `${t.eventName} on "${e}" failed once its flows were wired`, {
155
+ id: e,
156
+ eventName: t.eventName,
157
+ error: n
158
+ }), t.settle([]);
159
+ });
160
+ });
161
+ }
162
+ dropParked(e) {
163
+ this.parked.get(e)?.forEach((t) => {
164
+ this.settleUnanswered(e, t);
165
+ }), this.parked.delete(e);
166
+ }
167
+ settleUnanswered(e, t) {
168
+ i.warning("interactions", `${t.eventName} on "${e}" was not run: the element never wired its flows (unmounted, or not on this page)`, {
169
+ id: e,
170
+ eventName: t.eventName
171
+ }), t.settle([]);
129
172
  }
130
- createChildManager = (e = {}, n = {}) => {
131
- let r = new t(this.interactionsData.currentPageId, e, n);
132
- return r.parentManager = this, this.childManagers.push(r), r;
173
+ createChildManager = (e = {}, t = {}) => {
174
+ let n = new a(this.interactionsData.currentPageId, e, t);
175
+ return n.parentManager = this, this.childManagers.push(n), n;
133
176
  };
134
177
  removeChildManager = (e) => {
135
178
  this.childManagers = this.childManagers.filter((t) => t !== e);
@@ -145,5 +188,4 @@ var s = (e, i) => {
145
188
  for (let t of this.listeners) t(e);
146
189
  }
147
190
  };
148
- //#endregion
149
- export { c as default };
191
+ export { d as default };
@@ -7,7 +7,7 @@ import a from "./sources/QueriesSource/QueriesInteractions.mjs";
7
7
  import o from "./sources/StateSource/StateInteractions.mjs";
8
8
  import { jsx as s } from "react/jsx-runtime";
9
9
  import { useRenderSettings as c, useSdkStore as l } from "@plitzi/sdk-shared/store";
10
- //#region src/InteractionsSourcesProvider.tsx
10
+ // src/InteractionsSourcesProvider.tsx
11
11
  var u = ({ children: u, hostActions: d }) => {
12
12
  let [[f, p, m]] = l([
13
13
  "navigation.routeParams",
@@ -27,5 +27,4 @@ var u = ({ children: u, hostActions: d }) => {
27
27
  }) }) }) }) })
28
28
  });
29
29
  };
30
- //#endregion
31
30
  export { u as default };
@@ -1,9 +1,9 @@
1
- import { copyToClipboardSpec as e } from "../utility/copyToClipboardSpec.mjs";
2
- import { webHookSpec as t } from "../utility/webHookSpec.mjs";
3
- import { actionsCallbacks as n } from "../sources/ActionsSource/callbacks.mjs";
4
- import { authCallbacks as r } from "../sources/AuthSource/callbacks.mjs";
5
- import i from "../sources/HostSource/callbacks.mjs";
6
- import { navigationCallbacks as a } from "../sources/NavigationSource/callbacks.mjs";
7
- import { queriesCallbacks as o } from "../sources/QueriesSource/callbacks.mjs";
8
- import { stateCallbacks as s } from "../sources/StateSource/callbacks.mjs";
9
- export { n as actionsCallbacks, r as authCallbacks, e as copyToClipboardSpec, i as hostCallbacks, a as navigationCallbacks, o as queriesCallbacks, s as stateCallbacks, t as webHookSpec };
1
+ import { actionsCallbacks as e } from "../sources/ActionsSource/callbacks.mjs";
2
+ import { authCallbacks as t } from "../sources/AuthSource/callbacks.mjs";
3
+ import n from "../sources/HostSource/callbacks.mjs";
4
+ import { navigationCallbacks as r } from "../sources/NavigationSource/callbacks.mjs";
5
+ import { queriesCallbacks as i } from "../sources/QueriesSource/callbacks.mjs";
6
+ import { stateCallbacks as a } from "../sources/StateSource/callbacks.mjs";
7
+ import { copyToClipboardSpec as o } from "../utility/copyToClipboardSpec.mjs";
8
+ import { webHookSpec as s } from "../utility/webHookSpec.mjs";
9
+ export { e as actionsCallbacks, t as authCallbacks, o as copyToClipboardSpec, n as hostCallbacks, r as navigationCallbacks, i as queriesCallbacks, a as stateCallbacks, s as webHookSpec };
@@ -1,4 +1,4 @@
1
- //#region src/helpers/coerceDeclaredParams.ts
1
+ // src/helpers/coerceDeclaredParams.ts
2
2
  var e = (e, t) => typeof e.type == "function" ? e.type(t) : e.type, t = (e, t) => {
3
3
  if (typeof t != "string") return t;
4
4
  if (e === "number") {
@@ -14,5 +14,4 @@ var e = (e, t) => typeof e.type == "function" ? e.type(t) : e.type, t = (e, t) =
14
14
  for (let [n, o] of Object.entries(i)) Object.hasOwn(r, n) && (a[n] = t(e(o, r), r[n]));
15
15
  return a;
16
16
  };
17
- //#endregion
18
17
  export { n as coerceDeclaredParams };
@@ -1,6 +1,6 @@
1
1
  import e from "../InteractionsContext.mjs";
2
2
  import { use as t, useEffect as n } from "react";
3
- //#region src/hooks/useInteractions.ts
3
+ // src/hooks/useInteractions.ts
4
4
  var r = ({ id: r, interactions: i, triggers: a, callbacks: o, getAdditionalParams: s }) => {
5
5
  let { interactionsManager: c } = t(e);
6
6
  n(() => {
@@ -18,5 +18,4 @@ var r = ({ id: r, interactions: i, triggers: a, callbacks: o, getAdditionalParam
18
18
  c
19
19
  ]);
20
20
  };
21
- //#endregion
22
21
  export { r as default };
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import e from "./InteractionsContext.mjs";
2
- import t from "./hooks/useInteractions.mjs";
3
- import n from "./utility/index.mjs";
1
+ import e from "./hooks/useInteractions.mjs";
2
+ import t from "./InteractionsContext.mjs";
3
+ import n from "./InteractionsContextProvider.mjs";
4
4
  import r, { flowTrigger as i } from "./InteractionsHelper.mjs";
5
5
  import a from "./InteractionsManager.mjs";
6
- import o from "./InteractionsContextProvider.mjs";
6
+ import o from "./InteractionsSourcesProvider.mjs";
7
7
  import { ServerActionContext as s } from "./sources/ActionsSource/ServerActionContext.mjs";
8
8
  import c from "./sources/ActionsSource/ActionInteractions.mjs";
9
9
  import l from "./sources/AuthSource/AuthInteractions.mjs";
@@ -12,5 +12,5 @@ import d from "./sources/HostSource/HostInteractions.mjs";
12
12
  import f from "./sources/NavigationSource/NavigationInteractions.mjs";
13
13
  import p from "./sources/QueriesSource/QueriesInteractions.mjs";
14
14
  import m from "./sources/StateSource/StateInteractions.mjs";
15
- import h from "./InteractionsSourcesProvider.mjs";
16
- export { c as ActionInteractions, l as AuthInteractions, d as HostInteractions, e as InteractionsContext, o as InteractionsContextProvider, r as InteractionsHelper, a as InteractionsManager, h as InteractionsSourcesProvider, f as NavigationInteractions, p as QueriesInteractions, s as ServerActionContext, m as StateInteractions, i as flowTrigger, u as hostCallbacks, t as useInteractions, n as utility };
15
+ import h from "./utility/index.mjs";
16
+ export { c as ActionInteractions, l as AuthInteractions, d as HostInteractions, t as InteractionsContext, n as InteractionsContextProvider, r as InteractionsHelper, a as InteractionsManager, o as InteractionsSourcesProvider, f as NavigationInteractions, p as QueriesInteractions, s as ServerActionContext, m as StateInteractions, i as flowTrigger, u as hostCallbacks, e as useInteractions, h as utility };