@plitzi/sdk-interactions 0.33.2 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/InteractionsHelper.d.ts +3 -3
  3. package/dist/InteractionsHelper.mjs +92 -86
  4. package/dist/InteractionsManager.mjs +1 -1
  5. package/dist/InteractionsSourcesProvider.d.ts +4 -1
  6. package/dist/InteractionsSourcesProvider.mjs +24 -19
  7. package/dist/hooks/useInteractions.d.ts +1 -1
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.mjs +8 -5
  10. package/dist/sources/ActionsSource/ActionInteractions.d.ts +13 -0
  11. package/dist/sources/ActionsSource/ActionInteractions.mjs +409 -0
  12. package/dist/sources/ActionsSource/callbacks.d.ts +12 -0
  13. package/dist/sources/ActionsSource/callbacks.mjs +63 -0
  14. package/dist/sources/ActionsSource/index.d.ts +3 -0
  15. package/dist/sources/ActionsSource/index.mjs +2 -0
  16. package/dist/sources/AuthSource/AuthInteractions.mjs +17 -94
  17. package/dist/sources/AuthSource/callbacks.d.ts +32 -0
  18. package/dist/sources/AuthSource/callbacks.mjs +71 -0
  19. package/dist/sources/HostSource/HostInteractions.d.ts +16 -0
  20. package/dist/sources/HostSource/HostInteractions.mjs +20 -0
  21. package/dist/sources/HostSource/callbacks.d.ts +15 -0
  22. package/dist/sources/HostSource/callbacks.mjs +20 -0
  23. package/dist/sources/HostSource/index.d.ts +3 -0
  24. package/dist/sources/HostSource/index.mjs +3 -0
  25. package/dist/sources/NavigationSource/NavigationInteractions.mjs +27 -48
  26. package/dist/sources/NavigationSource/callbacks.d.ts +9 -0
  27. package/dist/sources/NavigationSource/callbacks.mjs +30 -0
  28. package/dist/sources/StateSource/StateInteractions.mjs +69 -64
  29. package/dist/sources/StateSource/callbacks.d.ts +3 -0
  30. package/dist/sources/StateSource/callbacks.mjs +151 -0
  31. package/dist/sources/index.d.ts +5 -1
  32. package/dist/sources/index.mjs +7 -4
  33. package/dist/utility/transformer.mjs +0 -0
  34. package/dist/utility/webHook.mjs +15 -11
  35. package/package.json +54 -9
@@ -0,0 +1,71 @@
1
+ //#region src/sources/AuthSource/callbacks.ts
2
+ var e = {
3
+ login: {
4
+ source: "auth",
5
+ title: "Auth Login",
6
+ strictParams: !0,
7
+ params: {
8
+ mode: {
9
+ type: "select",
10
+ description: "Credentials to sign in with: a username and password, or a token obtained elsewhere.",
11
+ default: "normal",
12
+ options: ["normal", "token"],
13
+ optionLabels: {
14
+ normal: "User and Password",
15
+ token: "Token"
16
+ },
17
+ canBind: !1
18
+ },
19
+ username: {
20
+ type: "text",
21
+ description: "Username.",
22
+ default: "",
23
+ when: (e) => e.mode === "normal"
24
+ },
25
+ password: {
26
+ type: "text",
27
+ description: "Password.",
28
+ default: "",
29
+ when: (e) => e.mode === "normal"
30
+ },
31
+ token: {
32
+ type: "text",
33
+ description: "A token to exchange for a session.",
34
+ default: "",
35
+ when: (e) => e.mode === "token"
36
+ }
37
+ },
38
+ preview: {
39
+ ok: "",
40
+ reason: "",
41
+ errors: {
42
+ username: "",
43
+ password: "",
44
+ token: ""
45
+ },
46
+ accessToken: "",
47
+ expiresAt: "",
48
+ refreshToken: ""
49
+ }
50
+ },
51
+ refreshDetails: {
52
+ source: "auth",
53
+ title: "Auth Refresh Details",
54
+ strictParams: !0,
55
+ params: {},
56
+ preview: {
57
+ errors: "",
58
+ accessToken: "",
59
+ expiresAt: "",
60
+ refreshToken: ""
61
+ }
62
+ },
63
+ logout: {
64
+ source: "auth",
65
+ title: "Auth Logout",
66
+ strictParams: !0,
67
+ params: {}
68
+ }
69
+ };
70
+ //#endregion
71
+ export { e as authCallbacks };
@@ -0,0 +1,16 @@
1
+ import { HostActions } from '@plitzi/sdk-shared';
2
+ import { ReactNode } from 'react';
3
+ export type HostInteractionsProps = {
4
+ children?: ReactNode;
5
+ /** What the embedding application is willing to be asked to do. Absent means it offers nothing. */
6
+ actions?: HostActions;
7
+ };
8
+ /**
9
+ * The bridge out of a space and into the application rendering it.
10
+ *
11
+ * It is registered whether or not the host offers anything, so a space authored against a host that has not been
12
+ * updated yet fails the way every other unresolved callback does — by doing nothing — rather than by throwing in
13
+ * the middle of a flow somebody is watching.
14
+ */
15
+ declare const HostInteractions: ({ children, actions }: HostInteractionsProps) => ReactNode;
16
+ export default HostInteractions;
@@ -0,0 +1,20 @@
1
+ import e from "../../InteractionsContext.mjs";
2
+ import t from "./callbacks.mjs";
3
+ import { use as n, useCallback as r, useMemo as i } from "react";
4
+ import { toInteractionCallbacks as a } from "@plitzi/sdk-shared/authoring/builder";
5
+ //#region src/sources/HostSource/HostInteractions.tsx
6
+ var o = ({ children: o, actions: s }) => {
7
+ let { useInteractions: c } = n(e), l = r((e) => {
8
+ let { action: t, value: n } = e, r = t ? s?.[t] : void 0;
9
+ r && r({
10
+ ...e,
11
+ value: n
12
+ });
13
+ }, [s]);
14
+ return c({
15
+ id: "host",
16
+ callbacks: i(() => a(t, { hostAction: l }), [l])
17
+ }), o;
18
+ };
19
+ //#endregion
20
+ export { o as default };
@@ -0,0 +1,15 @@
1
+ import { BuiltinGlobalCallback } from '@plitzi/sdk-shared/authoring/builder';
2
+ /**
3
+ * The one way a rendered space can ask the application AROUND it to do something.
4
+ *
5
+ * Every other source acts on things the space owns — its own state, its own router, its own session. A space
6
+ * embedded in an application does not own the window: opening one of the host's screens, signing out of the host's
7
+ * keyring, quitting. Without this, anything shaped like an application shell had to be written in the host's own
8
+ * code, which is the one part of a product that then cannot be authored, themed or changed without a release.
9
+ *
10
+ * ONE declared action rather than one per verb, because what a host offers is the host's business and no catalog
11
+ * here can know it. `action` names the handler the host registered; a name it did not register does nothing, which
12
+ * is the same answer a space gets for every other callback that resolves to nothing.
13
+ */
14
+ export declare const hostCallbacks: Record<string, BuiltinGlobalCallback>;
15
+ export default hostCallbacks;
@@ -0,0 +1,20 @@
1
+ //#region src/sources/HostSource/callbacks.ts
2
+ var e = { hostAction: {
3
+ source: "host",
4
+ title: "Host Action",
5
+ strictParams: !0,
6
+ params: {
7
+ action: {
8
+ type: "text",
9
+ description: "The name the host registered the handler under — `openSpace`, `signOut`, whatever it offers.",
10
+ default: ""
11
+ },
12
+ value: {
13
+ type: "scalar",
14
+ description: "What the action is about: the space to open, the workspace to switch to. Optional.",
15
+ default: ""
16
+ }
17
+ }
18
+ } };
19
+ //#endregion
20
+ export { e as default, e as hostCallbacks };
@@ -0,0 +1,3 @@
1
+ export { default } from './HostInteractions';
2
+ export { default as HostInteractions } from './HostInteractions';
3
+ export * from './callbacks';
@@ -0,0 +1,3 @@
1
+ import e from "./callbacks.mjs";
2
+ import t from "./HostInteractions.mjs";
3
+ export { t as HostInteractions, t as default, e as hostCallbacks };
@@ -1,68 +1,47 @@
1
1
  import e from "../../InteractionsContext.mjs";
2
- import { use as t, useCallback as n, useMemo as r } from "react";
3
- import { get as i, pick as a } from "@plitzi/plitzi-ui/helpers";
4
- import { useSdkStore as o } from "@plitzi/sdk-shared/store";
2
+ import { navigationCallbacks as t } from "./callbacks.mjs";
3
+ import { use as n, useCallback as r, useMemo as i } from "react";
4
+ import { get as a, pick as o } from "@plitzi/plitzi-ui/helpers";
5
+ import { useSdkStore as s } from "@plitzi/sdk-shared/store";
6
+ import { toBuilderParams as c, toInteractionCallbacks as l } from "@plitzi/sdk-shared/authoring/builder";
5
7
  //#region src/sources/NavigationSource/NavigationInteractions.tsx
6
- var s = ({ children: s, previewMode: c = !1 }) => {
7
- let { useInteractions: l } = t(e), [[u, d, f]] = o([
8
+ var u = ({ children: u, previewMode: d = !1 }) => {
9
+ let { useInteractions: f } = n(e), [[p, m, h]] = s([
8
10
  "schema.pages",
9
11
  "pageDefinitions",
10
12
  "navigation.navigate"
11
- ]), p = r(() => {
12
- let e = a(d, u);
13
+ ]), g = i(() => {
14
+ let e = o(m, p);
13
15
  return Object.keys(e).reduce((t, n) => {
14
- let r = e[n], a = i(r, "attributes.name", n), o = i(r, "attributes.default", !1);
16
+ let r = e[n], i = a(r, "attributes.name", n), o = a(r, "attributes.default", !1);
15
17
  return [...t, {
16
18
  key: n,
17
- label: a,
19
+ label: i,
18
20
  defaultPage: o
19
21
  }];
20
22
  }, []);
21
- }, [d, u]), m = n((e) => {
22
- if (!c) return;
23
+ }, [m, p]), _ = r((e) => {
24
+ if (!d) return;
23
25
  let { url: t, urlType: n } = e;
24
- n === "page" || n === "internal" ? f(t) : f(t, !0);
25
- }, [f, c]);
26
- return l({
26
+ n === "page" || n === "internal" ? h(t) : h(t, !0);
27
+ }, [h, d]);
28
+ return f({
27
29
  id: "navigation",
28
- callbacks: r(() => ({ navigate: {
29
- action: "navigate",
30
- title: "Navigate",
31
- type: "globalCallback",
32
- callback: m,
33
- preview: {},
34
- params: {
35
- urlType: {
36
- label: "Url Type",
37
- defaultValue: void 0,
38
- type: "select",
39
- options: [
40
- {
41
- value: "page",
42
- label: "Space Page"
43
- },
44
- {
45
- value: "internal",
46
- label: "Inside Space"
47
- },
48
- {
49
- value: "external",
50
- label: "Outside Space"
51
- }
52
- ]
53
- },
30
+ callbacks: i(() => {
31
+ let { urlType: e, url: n } = c(t.navigate.params);
32
+ return l(t, { navigate: _ }, { navigate: { params: {
33
+ urlType: e,
54
34
  url: {
55
- defaultValue: p.find((e) => e.defaultPage)?.key ?? "",
56
- type: (e) => e.urlType === "page" ? "select" : "text",
57
- when: (e) => !!e.urlType,
58
- options: p.map((e) => ({
35
+ ...n,
36
+ defaultValue: g.find((e) => e.defaultPage)?.key ?? "",
37
+ options: g.map((e) => ({
59
38
  value: e.key,
60
39
  label: e.label
61
40
  }))
62
41
  }
63
- }
64
- } }), [m, p])
65
- }), s;
42
+ } } });
43
+ }, [_, g])
44
+ }), u;
66
45
  };
67
46
  //#endregion
68
- export { s as default };
47
+ export { u as default };
@@ -0,0 +1,9 @@
1
+ import { BuiltinGlobalCallback } from '@plitzi/sdk-shared/authoring/builder';
2
+ /**
3
+ * Navigation's one action.
4
+ *
5
+ * `url` is the param whose control depends on the one above it: a page is picked from the space's own pages, and
6
+ * anything else is typed. The list of pages is the editor's to supply — it is a fact about the space being edited,
7
+ * not about the action — so the source adds it to what is declared here.
8
+ */
9
+ export declare const navigationCallbacks: Record<string, BuiltinGlobalCallback>;
@@ -0,0 +1,30 @@
1
+ //#region src/sources/NavigationSource/callbacks.ts
2
+ var e = { navigate: {
3
+ source: "navigation",
4
+ title: "Navigate",
5
+ strictParams: !0,
6
+ params: {
7
+ urlType: {
8
+ type: "select",
9
+ description: "Target kind: a space page, an internal space path, or an external URL.",
10
+ options: [
11
+ "page",
12
+ "internal",
13
+ "external"
14
+ ],
15
+ optionLabels: {
16
+ page: "Space Page",
17
+ internal: "Inside Space",
18
+ external: "Outside Space"
19
+ }
20
+ },
21
+ url: {
22
+ type: "text",
23
+ description: "Destination — a page id when urlType is \"page\", otherwise a URL/path.",
24
+ when: (e) => !!e.urlType,
25
+ builderType: (e) => e.urlType === "page" ? "select" : "text"
26
+ }
27
+ }
28
+ } };
29
+ //#endregion
30
+ export { e as navigationCallbacks };
@@ -1,70 +1,75 @@
1
1
  import e from "../../InteractionsContext.mjs";
2
- import { use as t, useCallback as n, useMemo as r } from "react";
3
- import { useCommonStoreSetter as i } from "@plitzi/sdk-shared/store";
2
+ import { stateCallbacks as t } from "./callbacks.mjs";
3
+ import { use as n, useCallback as r, useMemo as i } from "react";
4
+ import { useCommonStoreSetter as a } from "@plitzi/sdk-shared/store";
5
+ import { toInteractionCallbacks as o } from "@plitzi/sdk-shared/authoring/builder";
4
6
  //#region src/sources/StateSource/StateInteractions.tsx
5
- var a = ({ children: a }) => {
6
- let { useInteractions: o } = t(e), s = i(), c = n((e) => {
7
+ var s = 0, c = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `e${++s}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`, l = ({ children: s }) => {
8
+ let { useInteractions: l } = n(e), u = a(), d = r((e) => {
7
9
  let { key: t, type: n } = e, { value: r } = e;
8
- n === "boolean" ? r = r === "true" : n === "number" && (r = parseInt(r, 10)), s(`runtime.state.${t}`, r);
9
- }, [s]), l = n(() => {
10
- s("runtime.state", {});
11
- }, [s]);
12
- return o({
10
+ n === "boolean" ? r = r === !0 || r === "true" : n === "number" && (r = parseInt(r, 10)), u(`runtime.state.${t}`, r);
11
+ }, [u]), f = r((e) => {
12
+ let { key: t } = e;
13
+ t && u(`runtime.state.${t}`, (e) => e !== !0 && e !== "true");
14
+ }, [u]), p = (e) => e === !0 || e === "true", m = r((e) => {
15
+ let { key: t, value: n, unique: r, withId: i } = e;
16
+ t && u(`runtime.state.${t}`, (e) => {
17
+ let t = Array.isArray(e) ? e : [];
18
+ return p(i) ? [...t, {
19
+ id: c(),
20
+ value: n
21
+ }] : p(r) && t.includes(n) ? t : [...t, n];
22
+ });
23
+ }, [u]), h = r((e) => {
24
+ let { key: t, index: n, value: r, by: i } = e;
25
+ if (!t) return;
26
+ if (r !== void 0 && r !== "") {
27
+ u(`runtime.state.${t}`, (e) => Array.isArray(e) ? e.filter((e) => i ? e?.[i] !== r : e !== r) : []);
28
+ return;
29
+ }
30
+ let a = typeof n == "number" ? n : parseInt(n ?? "", 10);
31
+ Number.isNaN(a) || u(`runtime.state.${t}`, (e) => Array.isArray(e) ? e.filter((e, t) => t !== a) : []);
32
+ }, [u]), g = r((e) => {
33
+ let { from: t, to: n, value: r } = e;
34
+ if (!t || !n || r === void 0 || r === "") return;
35
+ let i = { moved: !1 };
36
+ u(`runtime.state.${t}`, (e) => {
37
+ let t = Array.isArray(e) ? e : [];
38
+ return i.moved = t.includes(r), i.moved ? t.filter((e) => e !== r) : t;
39
+ }), i.moved && u(`runtime.state.${n}`, (e) => {
40
+ let t = Array.isArray(e) ? e : [];
41
+ return t.includes(r) ? t : [...t, r];
42
+ });
43
+ }, [u]), _ = r((e) => {
44
+ let { key: t, value: n } = e;
45
+ t && n !== void 0 && n !== "" && u(`runtime.state.${t}`, (e) => {
46
+ let t = Array.isArray(e) ? e : [];
47
+ return t.includes(n) ? t.filter((e) => e !== n) : [...t, n];
48
+ });
49
+ }, [u]), v = r((e) => {
50
+ let { key: t } = e;
51
+ u(t ? `runtime.state.${t}` : "runtime.state", t ? [] : {});
52
+ }, [u]);
53
+ return l({
13
54
  id: "state",
14
- callbacks: r(() => ({
15
- setState: {
16
- action: "setState",
17
- title: "Set State",
18
- type: "globalCallback",
19
- callback: c,
20
- preview: {},
21
- params: {
22
- key: {
23
- defaultValue: "",
24
- type: "text"
25
- },
26
- type: {
27
- defaultValue: void 0,
28
- type: "select",
29
- options: [
30
- {
31
- value: "boolean",
32
- label: "True / False"
33
- },
34
- {
35
- value: "number",
36
- label: "Numeric"
37
- },
38
- {
39
- value: "text",
40
- label: "Text"
41
- }
42
- ]
43
- },
44
- value: {
45
- defaultValue: void 0,
46
- type: (e) => e.type === "boolean" ? "select" : "text",
47
- when: (e) => !!e.type,
48
- options: [{
49
- value: "true",
50
- label: "True"
51
- }, {
52
- value: "false",
53
- label: "False"
54
- }]
55
- }
56
- }
57
- },
58
- clearState: {
59
- action: "clearState",
60
- title: "Clear State",
61
- type: "globalCallback",
62
- callback: l,
63
- preview: {},
64
- params: {}
65
- }
66
- }), [c, l])
67
- }), a;
55
+ callbacks: i(() => o(t, {
56
+ setState: d,
57
+ toggleState: f,
58
+ appendState: m,
59
+ removeState: h,
60
+ moveState: g,
61
+ toggleInState: _,
62
+ clearState: v
63
+ }), [
64
+ d,
65
+ f,
66
+ m,
67
+ h,
68
+ g,
69
+ _,
70
+ v
71
+ ])
72
+ }), s;
68
73
  };
69
74
  //#endregion
70
- export { a as default };
75
+ export { l as default };
@@ -0,0 +1,3 @@
1
+ import { BuiltinGlobalCallback } from '@plitzi/sdk-shared/authoring/builder';
2
+ /** What this source's actions are, for the editor that fills them in and for anything authoring one offline. */
3
+ export declare const stateCallbacks: Record<string, BuiltinGlobalCallback>;
@@ -0,0 +1,151 @@
1
+ //#region src/sources/StateSource/callbacks.ts
2
+ var e = {
3
+ setState: {
4
+ source: "state",
5
+ title: "Set State",
6
+ strictParams: !0,
7
+ params: {
8
+ key: {
9
+ type: "text",
10
+ description: "The state key/path to set. Stored under `runtime.state.<key>`.",
11
+ default: ""
12
+ },
13
+ type: {
14
+ type: "select",
15
+ description: "The value type. What is stored is coerced to it — a boolean is a real boolean, not \"true\".",
16
+ options: [
17
+ "boolean",
18
+ "number",
19
+ "text"
20
+ ],
21
+ optionLabels: {
22
+ boolean: "True / False",
23
+ number: "Numeric",
24
+ text: "Text"
25
+ }
26
+ },
27
+ value: {
28
+ type: "scalar",
29
+ description: "The value to store — its type follows the `type` param (a real boolean/number, or text).",
30
+ when: (e) => !!e.type,
31
+ builderType: (e) => e.type === "boolean" ? "select" : "text",
32
+ options: ["true", "false"]
33
+ }
34
+ }
35
+ },
36
+ toggleState: {
37
+ source: "state",
38
+ title: "Toggle State",
39
+ strictParams: !0,
40
+ params: { key: {
41
+ type: "text",
42
+ description: "The state key/path to flip, under `runtime.state.<key>`. Anything not already true is treated as false, so a key that has never been set toggles to true.",
43
+ default: ""
44
+ } }
45
+ },
46
+ appendState: {
47
+ source: "state",
48
+ title: "Append To State",
49
+ strictParams: !0,
50
+ params: {
51
+ key: {
52
+ type: "text",
53
+ description: "The state key/path holding the list, under `runtime.state.<key>`. Created if it is not there.",
54
+ default: ""
55
+ },
56
+ value: {
57
+ type: "scalar",
58
+ description: "What to add to the end of the list.",
59
+ default: ""
60
+ },
61
+ unique: {
62
+ type: "boolean",
63
+ description: "Skip the append when the list already holds this value. For a list whose entries are their own identity — anything referring to one refers to it by value, so a second copy is indistinguishable.",
64
+ default: !1
65
+ },
66
+ withId: {
67
+ type: "boolean",
68
+ description: "Store the entry as `{ id, value }` with an id of its own, so two entries that read the same are still two entries. Anything reading one back names `.value`; anything referring to one names `.id`.",
69
+ default: !1
70
+ }
71
+ }
72
+ },
73
+ removeState: {
74
+ source: "state",
75
+ title: "Remove From State",
76
+ strictParams: !0,
77
+ params: {
78
+ key: {
79
+ type: "text",
80
+ description: "The state key/path holding the list, under `runtime.state.<key>`.",
81
+ default: ""
82
+ },
83
+ value: {
84
+ type: "scalar",
85
+ description: "The entry to drop, by value — every copy of it. Prefer this wherever the list can change under the person: a position is only true until something before it moves.",
86
+ default: ""
87
+ },
88
+ by: {
89
+ type: "text",
90
+ description: "The FIELD carrying the identity, for a list of records rather than of scalars — `id` for entries appended with `withId`. Without it the whole entry is compared, which never matches a record.",
91
+ default: ""
92
+ },
93
+ index: {
94
+ type: "text",
95
+ description: "Which entry to drop, by position, when there is no value to go on. Inside a controlled list, `{{ <listSource>.index }}` is the row own position. An index that resolves to nothing removes nothing.",
96
+ default: ""
97
+ }
98
+ }
99
+ },
100
+ moveState: {
101
+ source: "state",
102
+ title: "Move Between Lists",
103
+ strictParams: !0,
104
+ params: {
105
+ from: {
106
+ type: "text",
107
+ description: "The list to take it out of, under `runtime.state.<key>`.",
108
+ default: ""
109
+ },
110
+ to: {
111
+ type: "text",
112
+ description: "The list to put it into. It is not added twice.",
113
+ default: ""
114
+ },
115
+ value: {
116
+ type: "scalar",
117
+ description: "The entry to move. Absent from `from` means nothing happens.",
118
+ default: ""
119
+ }
120
+ }
121
+ },
122
+ toggleInState: {
123
+ source: "state",
124
+ title: "Toggle In List",
125
+ strictParams: !0,
126
+ params: {
127
+ key: {
128
+ type: "text",
129
+ description: "The list to add to or drop from, under `runtime.state.<key>`.",
130
+ default: ""
131
+ },
132
+ value: {
133
+ type: "scalar",
134
+ description: "The entry the box stands for.",
135
+ default: ""
136
+ }
137
+ }
138
+ },
139
+ clearState: {
140
+ source: "state",
141
+ title: "Clear State",
142
+ strictParams: !0,
143
+ params: { key: {
144
+ type: "text",
145
+ description: "The list to empty, under `runtime.state.<key>`. Left blank it empties EVERYTHING the space is keeping — which on a page that holds notes beside a list means losing the notes to clear the list.",
146
+ default: ""
147
+ } }
148
+ }
149
+ };
150
+ //#endregion
151
+ export { e as stateCallbacks };
@@ -1,7 +1,11 @@
1
+ import { ActionInteractions } from './ActionsSource';
1
2
  import { AuthInteractions } from './AuthSource';
3
+ import { HostInteractions } from './HostSource';
2
4
  import { NavigationInteractions } from './NavigationSource';
3
5
  import { StateInteractions } from './StateSource';
6
+ export * from './ActionsSource';
4
7
  export * from './AuthSource';
8
+ export * from './HostSource';
5
9
  export * from './NavigationSource';
6
10
  export * from './StateSource';
7
- export { AuthInteractions, NavigationInteractions, StateInteractions };
11
+ export { ActionInteractions, AuthInteractions, HostInteractions, NavigationInteractions, StateInteractions };
@@ -1,4 +1,7 @@
1
- import e from "./AuthSource/AuthInteractions.mjs";
2
- import t from "./NavigationSource/NavigationInteractions.mjs";
3
- import n from "./StateSource/StateInteractions.mjs";
4
- export { e as AuthInteractions, t as NavigationInteractions, n as StateInteractions };
1
+ import e from "./ActionsSource/ActionInteractions.mjs";
2
+ import t from "./AuthSource/AuthInteractions.mjs";
3
+ import n from "./HostSource/callbacks.mjs";
4
+ import r from "./HostSource/HostInteractions.mjs";
5
+ import i from "./NavigationSource/NavigationInteractions.mjs";
6
+ import a from "./StateSource/StateInteractions.mjs";
7
+ export { e as ActionInteractions, t as AuthInteractions, r as HostInteractions, i as NavigationInteractions, a as StateInteractions, n as hostCallbacks };
File without changes
@@ -82,30 +82,34 @@ var e = {
82
82
  let { url: t, authorizationToken: n, body: r, credentials: i } = e, { method: a } = e, o = {};
83
83
  try {
84
84
  a = a.toUpperCase();
85
- let e = {};
85
+ let e = { "Content-Type": "application/json" };
86
86
  n && (e.Authorization = `Bearer ${n}`), Object.values(r).forEach((t) => {
87
87
  if (t instanceof Blob && e["Content-Type"] !== "multipart/form-data") {
88
88
  e["Content-Type"] = "multipart/form-data";
89
89
  return;
90
90
  }
91
91
  });
92
- let s = new FormData();
93
- Object.entries(r).forEach(([e, t]) => {
94
- s?.append(e, t);
95
- });
96
- let c = {
92
+ let s = {
97
93
  method: a,
98
94
  headers: e,
99
95
  credentials: i
100
96
  };
101
- (!a || a.toLowerCase() !== "get") && (c.body = s);
102
- let l = await fetch(t, c), u = "";
97
+ if (a && !["get", "delete"].includes(a.toLowerCase())) {
98
+ if (e["Content-Type"] === "application/json") s.body = JSON.stringify(r);
99
+ else if (e["Content-Type"] === "multipart/form-data") {
100
+ let e = new FormData();
101
+ Object.entries(r).forEach(([t, n]) => {
102
+ e?.append(t, n);
103
+ }), s.body = e;
104
+ }
105
+ }
106
+ let c = await fetch(t, s), l = "";
103
107
  try {
104
- u = await l.json();
108
+ l = await c.json();
105
109
  } catch {}
106
110
  o = {
107
- status: l.status,
108
- data: u
111
+ status: c.status,
112
+ data: l
109
113
  };
110
114
  } catch (e) {
111
115
  console.error(e);