@shopify/ui-extensions-server-kit 0.0.0-experimental-20260902222805
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +157 -0
- package/README.md +75 -0
- package/dist/ExtensionServerClient/ExtensionServerClient.d.ts +27 -0
- package/dist/ExtensionServerClient/ExtensionServerClient.test.d.ts +9 -0
- package/dist/ExtensionServerClient/index.d.ts +2 -0
- package/dist/ExtensionServerClient/server-types.d.ts +66 -0
- package/dist/ExtensionServerClient/types.d.ts +124 -0
- package/dist/_virtual/jsx-runtime.cjs.js +1 -0
- package/dist/_virtual/jsx-runtime.cjs2.js +1 -0
- package/dist/_virtual/jsx-runtime.es.js +5 -0
- package/dist/_virtual/jsx-runtime.es2.js +4 -0
- package/dist/_virtual/react-jsx-runtime.development.cjs.js +1 -0
- package/dist/_virtual/react-jsx-runtime.development.es.js +4 -0
- package/dist/_virtual/react-jsx-runtime.production.min.cjs.js +1 -0
- package/dist/_virtual/react-jsx-runtime.production.min.es.js +4 -0
- package/dist/context/ExtensionServerProvider.d.ts +3 -0
- package/dist/context/ExtensionServerProvider.test.d.ts +1 -0
- package/dist/context/constants.d.ts +2 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/types.d.ts +12 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useExtensionServerContext.d.ts +1 -0
- package/dist/hooks/useExtensionServerState.d.ts +1 -0
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
- package/dist/i18n.d.ts +68 -0
- package/dist/i18n.test.d.ts +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.cjs2.js +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +46 -0
- package/dist/index.es2.js +8 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.cjs.js +22 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.es.js +604 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.cjs.js +9 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.es.js +28 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.cjs.js +1 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.es.js +10 -0
- package/dist/packages/ui-extensions-server-kit/src/ExtensionServerClient/ExtensionServerClient.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/ExtensionServerClient/ExtensionServerClient.es.js +136 -0
- package/dist/packages/ui-extensions-server-kit/src/ExtensionServerClient/types.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/ExtensionServerClient/types.es.js +4 -0
- package/dist/packages/ui-extensions-server-kit/src/context/ExtensionServerProvider.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/context/ExtensionServerProvider.es.js +30 -0
- package/dist/packages/ui-extensions-server-kit/src/context/constants.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/context/constants.es.js +13 -0
- package/dist/packages/ui-extensions-server-kit/src/hooks/useExtensionServerContext.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/hooks/useExtensionServerContext.es.js +7 -0
- package/dist/packages/ui-extensions-server-kit/src/hooks/useExtensionServerState.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/hooks/useExtensionServerState.es.js +9 -0
- package/dist/packages/ui-extensions-server-kit/src/hooks/useIsomorphicLayoutEffect.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/hooks/useIsomorphicLayoutEffect.es.js +5 -0
- package/dist/packages/ui-extensions-server-kit/src/i18n.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/i18n.es.js +60 -0
- package/dist/packages/ui-extensions-server-kit/src/state/actions/actions.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/state/actions/actions.es.js +37 -0
- package/dist/packages/ui-extensions-server-kit/src/state/reducers/constants.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/state/reducers/constants.es.js +7 -0
- package/dist/packages/ui-extensions-server-kit/src/state/reducers/extensionServerReducer.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/state/reducers/extensionServerReducer.es.js +57 -0
- package/dist/packages/ui-extensions-server-kit/src/testing/MockExtensionServerProvider.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/testing/MockExtensionServerProvider.es.js +25 -0
- package/dist/packages/ui-extensions-server-kit/src/testing/app.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/testing/app.es.js +16 -0
- package/dist/packages/ui-extensions-server-kit/src/testing/extensions.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/testing/extensions.es.js +66 -0
- package/dist/packages/ui-extensions-server-kit/src/types.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/types.es.js +4 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/assetToString.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/assetToString.es.js +7 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/isUIExtension.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/isUIExtension.es.js +7 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/isValidSurface.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/isValidSurface.es.js +7 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/noop.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/noop.es.js +5 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/replaceUpdated.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/replaceUpdated.es.js +14 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/set.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/set.es.js +18 -0
- package/dist/state/actions/actions.d.ts +6 -0
- package/dist/state/actions/index.d.ts +2 -0
- package/dist/state/actions/types.d.ts +21 -0
- package/dist/state/index.d.ts +2 -0
- package/dist/state/reducers/constants.d.ts +2 -0
- package/dist/state/reducers/extensionServerReducer.d.ts +3 -0
- package/dist/state/reducers/extensionServerReducer.test.d.ts +1 -0
- package/dist/state/reducers/index.d.ts +3 -0
- package/dist/state/reducers/types.d.ts +6 -0
- package/dist/testing/MockExtensionServerProvider.d.ts +8 -0
- package/dist/testing/app.d.ts +2 -0
- package/dist/testing/extensions.d.ts +6 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/types.d.ts +196 -0
- package/dist/utilities/assetToString.d.ts +2 -0
- package/dist/utilities/assetToString.test.d.ts +1 -0
- package/dist/utilities/index.d.ts +6 -0
- package/dist/utilities/isUIExtension.d.ts +1 -0
- package/dist/utilities/isValidSurface.d.ts +2 -0
- package/dist/utilities/noop.d.ts +1 -0
- package/dist/utilities/replaceUpdated.d.ts +1 -0
- package/dist/utilities/replaceUpdated.test.d.ts +1 -0
- package/dist/utilities/set.d.ts +4 -0
- package/dist/utilities/set.test.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/node_modules/@testing-library/react/LICENSE +20 -0
- package/node_modules/@testing-library/react/README.md +692 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.cjs.js +537 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.esm.js +497 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.cjs.js +501 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.esm.js +461 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.js +502 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.js.map +1 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.min.js +2 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.min.js.map +1 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.js +538 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.js.map +1 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.min.js +2 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.min.js.map +1 -0
- package/node_modules/@testing-library/react/dist/act-compat.js +80 -0
- package/node_modules/@testing-library/react/dist/config.js +33 -0
- package/node_modules/@testing-library/react/dist/fire-event.js +70 -0
- package/node_modules/@testing-library/react/dist/index.js +52 -0
- package/node_modules/@testing-library/react/dist/pure.js +356 -0
- package/node_modules/@testing-library/react/dont-cleanup-after-each.js +1 -0
- package/node_modules/@testing-library/react/package.json +116 -0
- package/node_modules/@testing-library/react/pure.d.ts +1 -0
- package/node_modules/@testing-library/react/pure.js +2 -0
- package/node_modules/@testing-library/react/types/index.d.ts +287 -0
- package/node_modules/@testing-library/react/types/pure.d.ts +1 -0
- package/node_modules/@types/react/LICENSE +21 -0
- package/node_modules/@types/react/README.md +15 -0
- package/node_modules/@types/react/canary.d.ts +166 -0
- package/node_modules/@types/react/experimental.d.ts +127 -0
- package/node_modules/@types/react/global.d.ts +160 -0
- package/node_modules/@types/react/index.d.ts +4543 -0
- package/node_modules/@types/react/jsx-dev-runtime.d.ts +45 -0
- package/node_modules/@types/react/jsx-runtime.d.ts +36 -0
- package/node_modules/@types/react/package.json +206 -0
- package/node_modules/@types/react/ts5.0/canary.d.ts +166 -0
- package/node_modules/@types/react/ts5.0/experimental.d.ts +127 -0
- package/node_modules/@types/react/ts5.0/global.d.ts +160 -0
- package/node_modules/@types/react/ts5.0/index.d.ts +4530 -0
- package/node_modules/@types/react/ts5.0/jsx-dev-runtime.d.ts +44 -0
- package/node_modules/@types/react/ts5.0/jsx-runtime.d.ts +35 -0
- package/node_modules/@vitejs/plugin-react/LICENSE +21 -0
- package/node_modules/@vitejs/plugin-react/README.md +159 -0
- package/node_modules/@vitejs/plugin-react/dist/index.d.ts +75 -0
- package/node_modules/@vitejs/plugin-react/dist/index.js +401 -0
- package/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js +663 -0
- package/node_modules/@vitejs/plugin-react/package.json +77 -0
- package/node_modules/@vitejs/plugin-react/types/preamble.d.ts +1 -0
- package/package.json +64 -0
- package/project.json +40 -0
- package/scripts/create-entry-files.ts +44 -0
- package/src/ExtensionServerClient/ExtensionServerClient.test.ts +1238 -0
- package/src/ExtensionServerClient/ExtensionServerClient.ts +320 -0
- package/src/ExtensionServerClient/index.ts +2 -0
- package/src/ExtensionServerClient/server-types.ts +65 -0
- package/src/ExtensionServerClient/types.ts +159 -0
- package/src/context/ExtensionServerProvider.test.tsx +318 -0
- package/src/context/ExtensionServerProvider.tsx +48 -0
- package/src/context/constants.ts +16 -0
- package/src/context/index.ts +3 -0
- package/src/context/types.ts +14 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useExtensionServerContext.ts +4 -0
- package/src/hooks/useExtensionServerState.ts +6 -0
- package/src/hooks/useIsomorphicLayoutEffect.ts +6 -0
- package/src/i18n.test.ts +417 -0
- package/src/i18n.ts +205 -0
- package/src/index.ts +7 -0
- package/src/state/actions/actions.ts +36 -0
- package/src/state/actions/index.ts +2 -0
- package/src/state/actions/types.ts +26 -0
- package/src/state/index.ts +2 -0
- package/src/state/reducers/constants.ts +6 -0
- package/src/state/reducers/extensionServerReducer.test.ts +165 -0
- package/src/state/reducers/extensionServerReducer.ts +87 -0
- package/src/state/reducers/index.ts +3 -0
- package/src/state/reducers/types.ts +7 -0
- package/src/testing/MockExtensionServerProvider.tsx +36 -0
- package/src/testing/app.ts +15 -0
- package/src/testing/extensions.ts +71 -0
- package/src/testing/index.ts +3 -0
- package/src/types.ts +204 -0
- package/src/utilities/assetToString.test.ts +16 -0
- package/src/utilities/assetToString.ts +7 -0
- package/src/utilities/index.ts +6 -0
- package/src/utilities/isUIExtension.ts +8 -0
- package/src/utilities/isValidSurface.ts +6 -0
- package/src/utilities/noop.ts +1 -0
- package/src/utilities/replaceUpdated.test.ts +26 -0
- package/src/utilities/replaceUpdated.ts +15 -0
- package/src/utilities/set.test.ts +19 -0
- package/src/utilities/set.ts +35 -0
- package/testing.d.ts +1 -0
- package/testing.js +1 -0
- package/testing.mjs +1 -0
- package/tests/setup.ts +3 -0
- package/vite.config.mts +57 -0
package/dist/packages/ui-extensions-server-kit/src/ExtensionServerClient/ExtensionServerClient.es.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { TRANSLATED_KEYS as E, getFlattenedLocalization as g, isFlattenedTranslations as d } from "../i18n.es.js";
|
|
2
|
+
import { isValidSurface as m } from "../utilities/isValidSurface.es.js";
|
|
3
|
+
import { isUIExtension as f } from "../utilities/isUIExtension.es.js";
|
|
4
|
+
class z {
|
|
5
|
+
constructor(n = {}) {
|
|
6
|
+
this.EVENT_THAT_WILL_MUTATE_THE_SERVER = ["update"], this.listeners = {}, this.connectionListeners = {
|
|
7
|
+
close: /* @__PURE__ */ new Set(),
|
|
8
|
+
open: /* @__PURE__ */ new Set()
|
|
9
|
+
}, this.connected = !1, this.uiExtensionsByUuid = {}, this.id = (Math.random() + 1).toString(36).substring(7), this.options = p({
|
|
10
|
+
...n,
|
|
11
|
+
connection: {
|
|
12
|
+
automaticConnect: !0,
|
|
13
|
+
protocols: [],
|
|
14
|
+
...n.connection ?? {}
|
|
15
|
+
}
|
|
16
|
+
}), this.setupConnection(this.options.connection.automaticConnect);
|
|
17
|
+
}
|
|
18
|
+
connect(n = { connection: {} }) {
|
|
19
|
+
const t = S(this.options, n);
|
|
20
|
+
return JSON.stringify(t) !== JSON.stringify(this.options) && (this.options = t, this.setupConnection(!0)), () => {
|
|
21
|
+
this.closeConnection();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
on(n, t) {
|
|
25
|
+
return this.listeners[n] || (this.listeners[n] = /* @__PURE__ */ new Set()), this.listeners[n].add(t), () => this.listeners[n].delete(t);
|
|
26
|
+
}
|
|
27
|
+
persist(n, t) {
|
|
28
|
+
var s, e, i;
|
|
29
|
+
if (this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(n))
|
|
30
|
+
return this.options.locales ? ((e = t.extensions) == null || e.forEach((c) => {
|
|
31
|
+
E.forEach((o) => {
|
|
32
|
+
var h;
|
|
33
|
+
f(c) && ((h = c.extensionPoints) == null || h.forEach((a) => {
|
|
34
|
+
delete a[o];
|
|
35
|
+
})), delete c[o];
|
|
36
|
+
});
|
|
37
|
+
}), (i = this.connection) == null ? void 0 : i.send(JSON.stringify({ event: n, data: t }))) : (s = this.connection) == null ? void 0 : s.send(JSON.stringify({ event: n, data: t }));
|
|
38
|
+
console.warn('You tried to use "persist" with a dispatch event. Please use the "emit" method instead.');
|
|
39
|
+
}
|
|
40
|
+
emit(...n) {
|
|
41
|
+
var e;
|
|
42
|
+
const t = n[0], s = n.length > 1 ? n[1] : void 0;
|
|
43
|
+
if (this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(t))
|
|
44
|
+
return console.warn(
|
|
45
|
+
`You tried to use "emit" with a the "${t}" event. Please use the "persist" method instead to persist changes to the server.`
|
|
46
|
+
);
|
|
47
|
+
(e = this.connection) == null || e.send(JSON.stringify({ event: "dispatch", data: { type: t, payload: s } }));
|
|
48
|
+
}
|
|
49
|
+
onConnection(n, t) {
|
|
50
|
+
return this.connectionListeners[n].add(t), () => this.connectionListeners[n].delete(t);
|
|
51
|
+
}
|
|
52
|
+
initializeConnection() {
|
|
53
|
+
var n;
|
|
54
|
+
this.connection && (this.connection.addEventListener("open", (t) => {
|
|
55
|
+
this.connected = !0, this.connectionListeners.open.forEach((s) => s(t));
|
|
56
|
+
}), this.connection.addEventListener("close", (t) => {
|
|
57
|
+
this.connected = !1, this.connectionListeners.close.forEach((s) => s(t));
|
|
58
|
+
}), (n = this.connection) == null || n.addEventListener("message", (t) => {
|
|
59
|
+
var s, e;
|
|
60
|
+
try {
|
|
61
|
+
const { event: i, data: c } = JSON.parse(t.data), o = c;
|
|
62
|
+
if (i === "dispatch") {
|
|
63
|
+
const { type: a, payload: l } = o;
|
|
64
|
+
(s = this.listeners[a]) == null || s.forEach((u) => u(l));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const h = o.extensions ? T(o.extensions, this.options.surface) : o.extensions;
|
|
68
|
+
(e = this.listeners[i]) == null || e.forEach((a) => {
|
|
69
|
+
a({ ...o, extensions: this._getLocalizedExtensions(h) });
|
|
70
|
+
});
|
|
71
|
+
} catch (i) {
|
|
72
|
+
console.error(
|
|
73
|
+
"[ExtensionServer] Something went wrong while parsing a server message:",
|
|
74
|
+
i instanceof Error ? i.message : i
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
setupConnection(n = !0) {
|
|
80
|
+
this.options.connection.url && n && (this.closeConnection(), this.connection = new WebSocket(this.options.connection.url, this.options.connection.protocols), this.initializeConnection());
|
|
81
|
+
}
|
|
82
|
+
closeConnection() {
|
|
83
|
+
var n;
|
|
84
|
+
this.connected && ((n = this.connection) == null || n.close());
|
|
85
|
+
}
|
|
86
|
+
_getLocalizedExtensions(n) {
|
|
87
|
+
return n == null ? void 0 : n.map((t) => {
|
|
88
|
+
var o, h, a, l, u;
|
|
89
|
+
if (!this.options.locales || !f(t))
|
|
90
|
+
return t;
|
|
91
|
+
const e = ((h = (o = this.uiExtensionsByUuid[t.uuid]) == null ? void 0 : o.localization) == null ? void 0 : h.lastUpdated) !== ((a = t.localization) == null ? void 0 : a.lastUpdated) ? g(t.localization, this.options.locales) : ((l = this.uiExtensionsByUuid[t.uuid]) == null ? void 0 : l.localization) ?? t.localization, i = e && d(e) ? JSON.parse(e.translations) : e, c = {
|
|
92
|
+
...t,
|
|
93
|
+
localization: e,
|
|
94
|
+
name: i && t.name.startsWith("t:") ? this._getLocalizedValue(i, t.name) : t.name,
|
|
95
|
+
...t.description && {
|
|
96
|
+
description: i && ((u = t.description) != null && u.startsWith("t:")) ? this._getLocalizedValue(i, t.description) : t.description
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return this.uiExtensionsByUuid[t.uuid] = {
|
|
100
|
+
...c,
|
|
101
|
+
extensionPoints: this._getLocalizedExtensionPoints(e, c)
|
|
102
|
+
}, this.uiExtensionsByUuid[t.uuid];
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
_getLocalizedExtensionPoints(n, { extensionPoints: t, name: s, description: e }) {
|
|
106
|
+
return !n || !d(n) ? t : t == null ? void 0 : t.map((i) => ({
|
|
107
|
+
...i,
|
|
108
|
+
localization: n,
|
|
109
|
+
name: s,
|
|
110
|
+
...e && { description: e }
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
_getLocalizedValue(n, t) {
|
|
114
|
+
const s = t.replace("t:", "");
|
|
115
|
+
return n[s] || t;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function S(r, n) {
|
|
119
|
+
return p({
|
|
120
|
+
...r,
|
|
121
|
+
...n,
|
|
122
|
+
connection: {
|
|
123
|
+
...r.connection,
|
|
124
|
+
...n.connection
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function p(r) {
|
|
129
|
+
return m(r.surface) || delete r.surface, r;
|
|
130
|
+
}
|
|
131
|
+
function T(r, n) {
|
|
132
|
+
return n ? r.filter((t) => t.surface === n ? !0 : Array.isArray(t.extensionPoints) ? t.extensionPoints.filter((i) => typeof i == "string" ? !1 : i.surface === n).length > 0 : !1) : r;
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
z as ExtensionServerClient
|
|
136
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=["admin","checkout","post_purchase","point_of_sale","customer-accounts"];exports.AVAILABLE_SURFACES=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../../../_virtual/jsx-runtime.cjs.js"),E=require("./constants.cjs.js"),o=require("../state/actions/actions.cjs.js"),d=require("../ExtensionServerClient/ExtensionServerClient.cjs.js"),a=require("../hooks/useIsomorphicLayoutEffect.cjs.js"),l=require("../hooks/useExtensionServerState.cjs.js"),s=require("react");function q({children:f,options:x}){const[i,n]=l.useExtensionServerState(),[r,S]=s.useState(x),[t]=s.useState(()=>new d.ExtensionServerClient),u=s.useCallback((c=r)=>{S(c)},[r]);a.useIsomorphicLayoutEffect(()=>t.connect(r),[t,r]),a.useIsomorphicLayoutEffect(()=>{const c=[t.on("update",e=>n(o.createUpdateAction(e))),t.on("connected",e=>n(o.createConnectedAction(e))),t.on("refresh",e=>n(o.createRefreshAction(e))),t.on("focus",e=>n(o.createFocusAction(e))),t.on("unfocus",e=>n(o.createUnfocusAction(e)))];return()=>c.forEach(e=>e())},[n]);const v=s.useMemo(()=>({dispatch:n,state:i,connect:u,client:t}),[n,u,i,t]);return p.jsxRuntimeExports.jsx(E.extensionServerContext.Provider,{value:v,children:f})}exports.ExtensionServerProvider=q;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { j as x } from "../../../../_virtual/jsx-runtime.es.js";
|
|
2
|
+
import { extensionServerContext as d } from "./constants.es.js";
|
|
3
|
+
import { createUpdateAction as v, createConnectedAction as l, createRefreshAction as E, createFocusAction as S, createUnfocusAction as h } from "../state/actions/actions.es.js";
|
|
4
|
+
import { ExtensionServerClient as A } from "../ExtensionServerClient/ExtensionServerClient.es.js";
|
|
5
|
+
import { useIsomorphicLayoutEffect as i } from "../hooks/useIsomorphicLayoutEffect.es.js";
|
|
6
|
+
import { useExtensionServerState as C } from "../hooks/useExtensionServerState.es.js";
|
|
7
|
+
import { useState as a, useCallback as j, useMemo as P } from "react";
|
|
8
|
+
function I({ children: m, options: u }) {
|
|
9
|
+
const [c, t] = C(), [n, f] = a(u), [o] = a(() => new A()), s = j(
|
|
10
|
+
(r = n) => {
|
|
11
|
+
f(r);
|
|
12
|
+
},
|
|
13
|
+
[n]
|
|
14
|
+
);
|
|
15
|
+
i(() => o.connect(n), [o, n]), i(() => {
|
|
16
|
+
const r = [
|
|
17
|
+
o.on("update", (e) => t(v(e))),
|
|
18
|
+
o.on("connected", (e) => t(l(e))),
|
|
19
|
+
o.on("refresh", (e) => t(E(e))),
|
|
20
|
+
o.on("focus", (e) => t(S(e))),
|
|
21
|
+
o.on("unfocus", (e) => t(h(e)))
|
|
22
|
+
];
|
|
23
|
+
return () => r.forEach((e) => e());
|
|
24
|
+
}, [t]);
|
|
25
|
+
const p = P(() => ({ dispatch: t, state: c, connect: s, client: o }), [t, s, c, o]);
|
|
26
|
+
return /* @__PURE__ */ x.jsx(d.Provider, { value: p, children: m });
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
I as ExtensionServerProvider
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../ExtensionServerClient/ExtensionServerClient.cjs.js"),n=require("../state/reducers/constants.cjs.js"),e=require("../utilities/noop.cjs.js"),o=require("react"),r={connect:e.noop,dispatch:e.noop,state:n.INITIAL_STATE,client:new t.ExtensionServerClient},i=o.createContext(r);exports.extensionServerContext=i;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExtensionServerClient as o } from "../ExtensionServerClient/ExtensionServerClient.es.js";
|
|
2
|
+
import { INITIAL_STATE as e } from "../state/reducers/constants.es.js";
|
|
3
|
+
import { noop as t } from "../utilities/noop.es.js";
|
|
4
|
+
import { createContext as n } from "react";
|
|
5
|
+
const r = {
|
|
6
|
+
connect: t,
|
|
7
|
+
dispatch: t,
|
|
8
|
+
state: e,
|
|
9
|
+
client: new o()
|
|
10
|
+
}, s = n(r);
|
|
11
|
+
export {
|
|
12
|
+
s as extensionServerContext
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../../_virtual/jsx-runtime.cjs.js");const e=require("../context/constants.cjs.js"),t=require("react"),r=()=>t.useContext(e.extensionServerContext);exports.useExtensionServerContext=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../state/reducers/constants.cjs.js"),r=require("../state/reducers/extensionServerReducer.cjs.js"),t=require("react");function n(){return t.useReducer(r.extensionServerReducer,e.INITIAL_STATE)}exports.useExtensionServerState=n;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { INITIAL_STATE as e } from "../state/reducers/constants.es.js";
|
|
2
|
+
import { extensionServerReducer as r } from "../state/reducers/extensionServerReducer.es.js";
|
|
3
|
+
import { useReducer as o } from "react";
|
|
4
|
+
function m() {
|
|
5
|
+
return o(r, e);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
m as useExtensionServerState
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),o=t?e.useEffect:e.useLayoutEffect;exports.useIsomorphicLayoutEffect=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=["localization","name","description"];function L(n){const t=new Map;return u(n,(e,s)=>t.set(e,s)),t}function u(n,t,e){Object.keys(n).forEach(s=>{const o=n[s],r=e?`${e}.${s}`:s;o!=null&&(typeof o=="string"?t(r,o):u(o,t,r))})}function f(n,t){const e=a(n.translations[n.defaultLocale]),s=i(t),o=a(n.translations[s]),r=a(n.translations[t]);return d(new Map([...e,...o,...r]))}function a(n){return n?L(n):new Map}function c(n,t){const e=new Set(Object.keys(n.translations));if(e.size===0||e.has(t.user))return t.user;const s=i(t.user);if(e.has(s))return s;if(t.shop&&e.has(t.shop))return t.shop;const o=t.shop&&i(t.shop);return o&&e.has(o)?o:n.defaultLocale}function d(n){const t={};for(const[e,s]of n)t[e]=s;return t}function i(n){return n.split("-")[0]}function T(n,t){if(!n||!t)return;if(p(n))return n;const e=c(n,t),s=JSON.stringify(f(n,e));return{extensionLocale:e,translations:s,lastUpdated:n.lastUpdated}}function p(n){return typeof n.translations=="string"&&Object.prototype.hasOwnProperty.call(n,"extensionLocale")}exports.TRANSLATED_KEYS=l;exports.flattenDevExtensionTranslations=f;exports.getFlattenedLocalization=T;exports.isFlattenedTranslations=p;exports.resolveDevExtensionLocale=c;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const h = ["localization", "name", "description"];
|
|
2
|
+
function f(n) {
|
|
3
|
+
const t = /* @__PURE__ */ new Map();
|
|
4
|
+
return u(n, (e, s) => t.set(e, s)), t;
|
|
5
|
+
}
|
|
6
|
+
function u(n, t, e) {
|
|
7
|
+
Object.keys(n).forEach((s) => {
|
|
8
|
+
const r = n[s], o = e ? `${e}.${s}` : s;
|
|
9
|
+
r != null && (typeof r == "string" ? t(o, r) : u(r, t, o));
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function c(n, t) {
|
|
13
|
+
const e = a(n.translations[n.defaultLocale]), s = i(t), r = a(n.translations[s]), o = a(n.translations[t]);
|
|
14
|
+
return L(
|
|
15
|
+
new Map([...e, ...r, ...o])
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function a(n) {
|
|
19
|
+
return n ? f(n) : /* @__PURE__ */ new Map();
|
|
20
|
+
}
|
|
21
|
+
function p(n, t) {
|
|
22
|
+
const e = new Set(Object.keys(n.translations));
|
|
23
|
+
if (e.size === 0 || e.has(t.user)) return t.user;
|
|
24
|
+
const s = i(t.user);
|
|
25
|
+
if (e.has(s)) return s;
|
|
26
|
+
if (t.shop && e.has(t.shop)) return t.shop;
|
|
27
|
+
const r = t.shop && i(t.shop);
|
|
28
|
+
return r && e.has(r) ? r : n.defaultLocale;
|
|
29
|
+
}
|
|
30
|
+
function L(n) {
|
|
31
|
+
const t = {};
|
|
32
|
+
for (const [e, s] of n)
|
|
33
|
+
t[e] = s;
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
function i(n) {
|
|
37
|
+
return n.split("-")[0];
|
|
38
|
+
}
|
|
39
|
+
function l(n, t) {
|
|
40
|
+
if (!n || !t)
|
|
41
|
+
return;
|
|
42
|
+
if (d(n))
|
|
43
|
+
return n;
|
|
44
|
+
const e = p(n, t), s = JSON.stringify(c(n, e));
|
|
45
|
+
return {
|
|
46
|
+
extensionLocale: e,
|
|
47
|
+
translations: s,
|
|
48
|
+
lastUpdated: n.lastUpdated
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function d(n) {
|
|
52
|
+
return typeof n.translations == "string" && Object.prototype.hasOwnProperty.call(n, "extensionLocale");
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
h as TRANSLATED_KEYS,
|
|
56
|
+
c as flattenDevExtensionTranslations,
|
|
57
|
+
l as getFlattenedLocalization,
|
|
58
|
+
d as isFlattenedTranslations,
|
|
59
|
+
p as resolveDevExtensionLocale
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e){return{type:"connected",payload:e}}function c(e){return{type:"update",payload:e}}function n(e){return{type:"refresh",payload:e}}function o(e){return{type:"focus",payload:e}}function r(e){return{type:"unfocus",payload:e}}exports.createConnectedAction=t;exports.createFocusAction=o;exports.createRefreshAction=n;exports.createUnfocusAction=r;exports.createUpdateAction=c;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function t(e) {
|
|
2
|
+
return {
|
|
3
|
+
type: "connected",
|
|
4
|
+
payload: e
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function n(e) {
|
|
8
|
+
return {
|
|
9
|
+
type: "update",
|
|
10
|
+
payload: e
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function c(e) {
|
|
14
|
+
return {
|
|
15
|
+
type: "refresh",
|
|
16
|
+
payload: e
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function r(e) {
|
|
20
|
+
return {
|
|
21
|
+
type: "focus",
|
|
22
|
+
payload: e
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function o(e) {
|
|
26
|
+
return {
|
|
27
|
+
type: "unfocus",
|
|
28
|
+
payload: e
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
t as createConnectedAction,
|
|
33
|
+
r as createFocusAction,
|
|
34
|
+
c as createRefreshAction,
|
|
35
|
+
o as createUnfocusAction,
|
|
36
|
+
n as createUpdateAction
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={extensions:[],store:""};exports.INITIAL_STATE=e;
|
package/dist/packages/ui-extensions-server-kit/src/state/reducers/extensionServerReducer.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../utilities/replaceUpdated.cjs.js"),o=require("../../utilities/set.cjs.js"),p=require("../../utilities/assetToString.cjs.js");function c(r,t){switch(t.type){case"connected":{const s=(t.payload.extensions??[]).map(e=>(Object.keys(e.assets).forEach(u=>e.assets[u].url=p.assetToString(e.assets[u])),e));return{...r,store:t.payload.store,app:t.payload.app,extensions:s}}case"update":{const s=(t.payload.extensions??[]).map(e=>(Object.keys(e.assets).forEach(u=>e.assets[u].url=p.assetToString(e.assets[u])),e));return{...r,app:{...r.app??{},...t.payload.app??{}},extensions:d.replaceUpdated(r.extensions,s,({uuid:e})=>e)}}case"refresh":return{...r,extensions:r.extensions.map(s=>{if(t.payload.some(({uuid:e})=>s.uuid===e)){const e={};return Object.keys(s.assets).forEach(u=>{const a={...s.assets[u]};a.lastUpdated=Date.now(),a.url=p.assetToString(a),e[u]=a}),o.set(s,u=>u.assets,e)}return s})};case"focus":return{...r,extensions:r.extensions.map(s=>t.payload.some(({uuid:e})=>s.uuid===e)?o.set(s,e=>e.development.focused,!0):s.development.focused?o.set(s,e=>e.development.focused,!1):s)};case"unfocus":return{...r,extensions:r.extensions.map(s=>s.development.focused?o.set(s,e=>e.development.focused,!1):s)};default:return r}}exports.extensionServerReducer=c;
|
package/dist/packages/ui-extensions-server-kit/src/state/reducers/extensionServerReducer.es.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { replaceUpdated as t } from "../../utilities/replaceUpdated.es.js";
|
|
2
|
+
import { set as o } from "../../utilities/set.es.js";
|
|
3
|
+
import { assetToString as d } from "../../utilities/assetToString.es.js";
|
|
4
|
+
function m(r, u) {
|
|
5
|
+
switch (u.type) {
|
|
6
|
+
case "connected": {
|
|
7
|
+
const s = (u.payload.extensions ?? []).map((e) => (Object.keys(e.assets).forEach(
|
|
8
|
+
(p) => e.assets[p].url = d(e.assets[p])
|
|
9
|
+
), e));
|
|
10
|
+
return {
|
|
11
|
+
...r,
|
|
12
|
+
store: u.payload.store,
|
|
13
|
+
app: u.payload.app,
|
|
14
|
+
extensions: s
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
case "update": {
|
|
18
|
+
const s = (u.payload.extensions ?? []).map((e) => (Object.keys(e.assets).forEach(
|
|
19
|
+
(p) => e.assets[p].url = d(e.assets[p])
|
|
20
|
+
), e));
|
|
21
|
+
return {
|
|
22
|
+
...r,
|
|
23
|
+
app: { ...r.app ?? {}, ...u.payload.app ?? {} },
|
|
24
|
+
extensions: t(r.extensions, s, ({ uuid: e }) => e)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
case "refresh":
|
|
28
|
+
return {
|
|
29
|
+
...r,
|
|
30
|
+
extensions: r.extensions.map((s) => {
|
|
31
|
+
if (u.payload.some(({ uuid: e }) => s.uuid === e)) {
|
|
32
|
+
const e = {};
|
|
33
|
+
return Object.keys(s.assets).forEach((p) => {
|
|
34
|
+
const a = { ...s.assets[p] };
|
|
35
|
+
a.lastUpdated = Date.now(), a.url = d(a), e[p] = a;
|
|
36
|
+
}), o(s, (p) => p.assets, e);
|
|
37
|
+
}
|
|
38
|
+
return s;
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
case "focus":
|
|
42
|
+
return {
|
|
43
|
+
...r,
|
|
44
|
+
extensions: r.extensions.map((s) => u.payload.some(({ uuid: e }) => s.uuid === e) ? o(s, (e) => e.development.focused, !0) : s.development.focused ? o(s, (e) => e.development.focused, !1) : s)
|
|
45
|
+
};
|
|
46
|
+
case "unfocus":
|
|
47
|
+
return {
|
|
48
|
+
...r,
|
|
49
|
+
extensions: r.extensions.map((s) => s.development.focused ? o(s, (e) => e.development.focused, !1) : s)
|
|
50
|
+
};
|
|
51
|
+
default:
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
m as extensionServerReducer
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../../_virtual/jsx-runtime.cjs.js"),i=require("../context/ExtensionServerProvider.cjs.js"),s=require("../context/constants.cjs.js"),u=require("../hooks/useExtensionServerContext.cjs.js"),x=require("react");function c({children:n,...e}){const r=u.useExtensionServerContext(),o=x.useMemo(()=>({...r,...e}),[r,e]);return t.jsxRuntimeExports.jsx(s.extensionServerContext.Provider,{value:o,children:n})}function v({children:n,options:e={connection:{}},...r}){return t.jsxRuntimeExports.jsx(i.ExtensionServerProvider,{options:e,children:t.jsxRuntimeExports.jsx(c,{...r,children:n})})}exports.MockExtensionServerProvider=v;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { j as t } from "../../../../_virtual/jsx-runtime.es.js";
|
|
2
|
+
import { ExtensionServerProvider as i } from "../context/ExtensionServerProvider.es.js";
|
|
3
|
+
import { extensionServerContext as s } from "../context/constants.es.js";
|
|
4
|
+
import { useExtensionServerContext as x } from "../hooks/useExtensionServerContext.es.js";
|
|
5
|
+
import { useMemo as m } from "react";
|
|
6
|
+
function c({ children: o, ...r }) {
|
|
7
|
+
const e = x(), n = m(
|
|
8
|
+
() => ({
|
|
9
|
+
...e,
|
|
10
|
+
...r
|
|
11
|
+
}),
|
|
12
|
+
[e, r]
|
|
13
|
+
);
|
|
14
|
+
return /* @__PURE__ */ t.jsx(s.Provider, { value: n, children: o });
|
|
15
|
+
}
|
|
16
|
+
function d({
|
|
17
|
+
children: o,
|
|
18
|
+
options: r = { connection: {} },
|
|
19
|
+
...e
|
|
20
|
+
}) {
|
|
21
|
+
return /* @__PURE__ */ t.jsx(i, { options: r, children: /* @__PURE__ */ t.jsx(c, { ...e, children: o }) });
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
d as MockExtensionServerProvider
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(){return{id:"id-1",apiKey:"12345",applicationUrl:"www.applicationUrl.com",title:"App title",url:"mock url",mobileUrl:"mock mobile url",icon:{transformedSrc:"www.transformed-src.com"}}}exports.mockApp=o;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function r() {
|
|
2
|
+
return {
|
|
3
|
+
id: "id-1",
|
|
4
|
+
apiKey: "12345",
|
|
5
|
+
applicationUrl: "www.applicationUrl.com",
|
|
6
|
+
title: "App title",
|
|
7
|
+
url: "mock url",
|
|
8
|
+
mobileUrl: "mock mobile url",
|
|
9
|
+
icon: {
|
|
10
|
+
transformedSrc: "www.transformed-src.com"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
r as mockApp
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../types.cjs.js");let i=0;function a(e){return`00000000000${e}`.slice(-12)}function r(e={}){const t=`00000000-0000-0000-0000-${a(i++)}`,n=Date.now();return{handle:"my-extension",name:"My extension",description:"My extension description",surface:"admin",type:"purchase_option",externalType:"external_type",uuid:t,version:"extension version",...e,assets:{main:{name:"main",url:`https://secure-link.com/extensions/${t}/assets/handle.js?lastUpdated=${n}`,lastUpdated:n},...e.assets??{}},development:{hidden:!1,status:s.Status.Success,resource:{url:"resourceUrl"},root:{url:`https://secure-link.com/extensions/${t}`},renderer:{name:"render name",version:"1.0.0"},...e.development??{}},extensionPoints:e.extensionPoints,capabilities:e.capabilities,supportedFeatures:e.supportedFeatures,localization:e.localization,authenticatedRedirectStartUrl:e.authenticatedRedirectStartUrl,authenticatedRedirectRedirectUrls:e.authenticatedRedirectRedirectUrls,settings:{fields:[{key:"sample-key",name:"sample_name",type:"sample_type"}]}}}exports.mockExtension=r;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Status as s } from "../types.es.js";
|
|
2
|
+
let i = 0;
|
|
3
|
+
function a(e) {
|
|
4
|
+
return `00000000000${e}`.slice(-12);
|
|
5
|
+
}
|
|
6
|
+
function o(e = {}) {
|
|
7
|
+
const t = `00000000-0000-0000-0000-${a(i++)}`, n = Date.now();
|
|
8
|
+
return {
|
|
9
|
+
handle: "my-extension",
|
|
10
|
+
name: "My extension",
|
|
11
|
+
description: "My extension description",
|
|
12
|
+
surface: "admin",
|
|
13
|
+
type: "purchase_option",
|
|
14
|
+
externalType: "external_type",
|
|
15
|
+
uuid: t,
|
|
16
|
+
version: "extension version",
|
|
17
|
+
...e,
|
|
18
|
+
assets: {
|
|
19
|
+
main: {
|
|
20
|
+
name: "main",
|
|
21
|
+
url: `https://secure-link.com/extensions/${t}/assets/handle.js?lastUpdated=${n}`,
|
|
22
|
+
lastUpdated: n
|
|
23
|
+
},
|
|
24
|
+
...e.assets ?? {}
|
|
25
|
+
},
|
|
26
|
+
development: {
|
|
27
|
+
hidden: !1,
|
|
28
|
+
status: s.Success,
|
|
29
|
+
resource: {
|
|
30
|
+
url: "resourceUrl"
|
|
31
|
+
},
|
|
32
|
+
root: {
|
|
33
|
+
url: `https://secure-link.com/extensions/${t}`
|
|
34
|
+
},
|
|
35
|
+
renderer: {
|
|
36
|
+
name: "render name",
|
|
37
|
+
version: "1.0.0"
|
|
38
|
+
},
|
|
39
|
+
...e.development ?? {}
|
|
40
|
+
},
|
|
41
|
+
// this is due to the naive DeepPartial but also more complex ones
|
|
42
|
+
// [see stackoverflow](https://stackoverflow.com/a/68699273) assume that
|
|
43
|
+
// `DeepPartial<Array<T>> === Array<T | undefined>` while we are looking for
|
|
44
|
+
// `DeepPartial<Array<T>> === Array<T> | undefined`.
|
|
45
|
+
// This is the case for extension points and seems hard to fix
|
|
46
|
+
// in a generalized, non-surprising way
|
|
47
|
+
extensionPoints: e.extensionPoints,
|
|
48
|
+
capabilities: e.capabilities,
|
|
49
|
+
supportedFeatures: e.supportedFeatures,
|
|
50
|
+
localization: e.localization,
|
|
51
|
+
authenticatedRedirectStartUrl: e.authenticatedRedirectStartUrl,
|
|
52
|
+
authenticatedRedirectRedirectUrls: e.authenticatedRedirectRedirectUrls,
|
|
53
|
+
settings: {
|
|
54
|
+
fields: [
|
|
55
|
+
{
|
|
56
|
+
key: "sample-key",
|
|
57
|
+
name: "sample_name",
|
|
58
|
+
type: "sample_type"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
o as mockExtension
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.Success="success",e))(t||{});exports.Status=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t){const e=new URL(t.url);return e.searchParams.set("lastUpdated",String(t.lastUpdated)),e.toString()}exports.assetToString=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(t){const e=t;return e.type==="ui_extension"&&Array.isArray(e.extensionPoints)&&e.extensionPoints.every(n=>typeof n=="object")}exports.isUIExtension=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../ExtensionServerClient/types.cjs.js");function t(e){return!!e&&i.AVAILABLE_SURFACES.includes(e)}exports.isValidSurface=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=()=>{};exports.noop=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(n,p,d){const t=new Map(p.map(e=>[d(e),e]));return[...n.map(e=>{const a=d(e);if(t.has(a)){const r=t.get(a);return t.delete(a),r}else return e}),...t.values()]}exports.replaceUpdated=u;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function u(p, d, n) {
|
|
2
|
+
const t = new Map(d.map((e) => [n(e), e]));
|
|
3
|
+
return [...p.map((e) => {
|
|
4
|
+
const a = n(e);
|
|
5
|
+
if (t.has(a)) {
|
|
6
|
+
const r = t.get(a);
|
|
7
|
+
return t.delete(a), r;
|
|
8
|
+
} else
|
|
9
|
+
return e;
|
|
10
|
+
}), ...t.values()];
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
u as replaceUpdated
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(s,c,u){const o=[],n=new Proxy({},{get:(e,y)=>(o.push(y),n)});c(n);const r={...s};let t=r;const p=o.pop();for(const e of o)t[e]={...t[e]},t=t[e];return t[p]=u,r}exports.set=l;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function f(s, c, p) {
|
|
2
|
+
const o = [], e = new Proxy(
|
|
3
|
+
{},
|
|
4
|
+
{
|
|
5
|
+
get: (n, y) => (o.push(y), e)
|
|
6
|
+
}
|
|
7
|
+
);
|
|
8
|
+
c(e);
|
|
9
|
+
const r = { ...s };
|
|
10
|
+
let t = r;
|
|
11
|
+
const u = o.pop();
|
|
12
|
+
for (const n of o)
|
|
13
|
+
t[n] = { ...t[n] }, t = t[n];
|
|
14
|
+
return t[u] = p, r;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
f as set
|
|
18
|
+
};
|