superapp-miniapp-invoke-native 1.0.31 → 1.0.33

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/lib/main.d.ts CHANGED
@@ -1,2 +1,4 @@
1
+ export type * from './src/type';
1
2
  import NativeApi from './src/init';
2
- export default NativeApi;
3
+ declare const _default: NativeApi;
4
+ export default _default;
package/lib/main.js CHANGED
@@ -1,89 +1,89 @@
1
- var de = Object.defineProperty;
2
- var ue = (t, e, n) => e in t ? de(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var O = (t, e, n) => (ue(t, typeof e != "symbol" ? e + "" : e, n), n);
1
+ var se = Object.defineProperty;
2
+ var ie = (t, e, r) => e in t ? se(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var _ = (t, e, r) => (ie(t, typeof e != "symbol" ? e + "" : e, r), r);
4
4
  /*! Capacitor: https://capacitorjs.com/ - MIT License */
5
- const fe = (t) => {
5
+ const oe = (t) => {
6
6
  const e = /* @__PURE__ */ new Map();
7
7
  e.set("web", { name: "web" });
8
- const n = t.CapacitorPlatforms || {
8
+ const r = t.CapacitorPlatforms || {
9
9
  currentPlatform: { name: "web" },
10
10
  platforms: e
11
11
  }, s = (a, o) => {
12
- n.platforms.set(a, o);
13
- }, r = (a) => {
14
- n.platforms.has(a) && (n.currentPlatform = n.platforms.get(a));
12
+ r.platforms.set(a, o);
13
+ }, n = (a) => {
14
+ r.platforms.has(a) && (r.currentPlatform = r.platforms.get(a));
15
15
  };
16
- return n.addPlatform = s, n.setPlatform = r, n;
17
- }, pe = (t) => t.CapacitorPlatforms = fe(t), Y = /* @__PURE__ */ pe(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
18
- Y.addPlatform;
19
- Y.setPlatform;
20
- var A;
16
+ return r.addPlatform = s, r.setPlatform = n, r;
17
+ }, le = (t) => t.CapacitorPlatforms = oe(t), R = /* @__PURE__ */ le(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
18
+ R.addPlatform;
19
+ R.setPlatform;
20
+ var L;
21
21
  (function(t) {
22
22
  t.Unimplemented = "UNIMPLEMENTED", t.Unavailable = "UNAVAILABLE";
23
- })(A || (A = {}));
24
- class _ extends Error {
25
- constructor(e, n, s) {
26
- super(e), this.message = e, this.code = n, this.data = s;
23
+ })(L || (L = {}));
24
+ class E extends Error {
25
+ constructor(e, r, s) {
26
+ super(e), this.message = e, this.code = r, this.data = s;
27
27
  }
28
28
  }
29
- const ge = (t) => {
30
- var e, n;
31
- return t != null && t.androidBridge ? "android" : !((n = (e = t == null ? void 0 : t.webkit) === null || e === void 0 ? void 0 : e.messageHandlers) === null || n === void 0) && n.bridge ? "ios" : "web";
32
- }, ve = (t) => {
33
- var e, n, s, r, a;
34
- const o = t.CapacitorCustomPlatform || null, i = t.Capacitor || {}, f = i.Plugins = i.Plugins || {}, l = t.CapacitorPlatforms, x = () => o !== null ? o.name : ge(t), y = ((e = l == null ? void 0 : l.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || x, j = () => y() !== "web", V = ((n = l == null ? void 0 : l.currentPlatform) === null || n === void 0 ? void 0 : n.isNativePlatform) || j, ee = (c) => {
35
- const d = E.get(c);
36
- return !!(d != null && d.platforms.has(y()) || B(c));
37
- }, te = ((s = l == null ? void 0 : l.currentPlatform) === null || s === void 0 ? void 0 : s.isPluginAvailable) || ee, ne = (c) => {
29
+ const ce = (t) => {
30
+ var e, r;
31
+ return t != null && t.androidBridge ? "android" : !((r = (e = t == null ? void 0 : t.webkit) === null || e === void 0 ? void 0 : e.messageHandlers) === null || r === void 0) && r.bridge ? "ios" : "web";
32
+ }, de = (t) => {
33
+ var e, r, s, n, a;
34
+ const o = t.CapacitorCustomPlatform || null, i = t.Capacitor || {}, f = i.Plugins = i.Plugins || {}, l = t.CapacitorPlatforms, k = () => o !== null ? o.name : ce(t), b = ((e = l == null ? void 0 : l.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || k, j = () => b() !== "web", z = ((r = l == null ? void 0 : l.currentPlatform) === null || r === void 0 ? void 0 : r.isNativePlatform) || j, Q = (c) => {
35
+ const d = H.get(c);
36
+ return !!(d != null && d.platforms.has(b()) || B(c));
37
+ }, X = ((s = l == null ? void 0 : l.currentPlatform) === null || s === void 0 ? void 0 : s.isPluginAvailable) || Q, Y = (c) => {
38
38
  var d;
39
- return (d = i.PluginHeaders) === null || d === void 0 ? void 0 : d.find((C) => C.name === c);
40
- }, B = ((r = l == null ? void 0 : l.currentPlatform) === null || r === void 0 ? void 0 : r.getPluginHeader) || ne, re = (c) => t.console.error(c), ae = (c, d, C) => Promise.reject(`${C} does not have an implementation of "${d}".`), E = /* @__PURE__ */ new Map(), se = (c, d = {}) => {
41
- const C = E.get(c);
42
- if (C)
43
- return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`), C.proxy;
44
- const P = y(), L = B(c);
39
+ return (d = i.PluginHeaders) === null || d === void 0 ? void 0 : d.find((y) => y.name === c);
40
+ }, B = ((n = l == null ? void 0 : l.currentPlatform) === null || n === void 0 ? void 0 : n.getPluginHeader) || Y, Z = (c) => t.console.error(c), V = (c, d, y) => Promise.reject(`${y} does not have an implementation of "${d}".`), H = /* @__PURE__ */ new Map(), ee = (c, d = {}) => {
41
+ const y = H.get(c);
42
+ if (y)
43
+ return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`), y.proxy;
44
+ const P = b(), C = B(c);
45
45
  let w;
46
- const oe = async () => (!w && P in d ? w = typeof d[P] == "function" ? w = await d[P]() : w = d[P] : o !== null && !w && "web" in d && (w = typeof d.web == "function" ? w = await d.web() : w = d.web), w), le = (u, p) => {
47
- var v, m;
48
- if (L) {
49
- const h = L == null ? void 0 : L.methods.find((g) => p === g.name);
46
+ const re = async () => (!w && P in d ? w = typeof d[P] == "function" ? w = await d[P]() : w = d[P] : o !== null && !w && "web" in d && (w = typeof d.web == "function" ? w = await d.web() : w = d.web), w), ne = (u, p) => {
47
+ var m, v;
48
+ if (C) {
49
+ const h = C == null ? void 0 : C.methods.find((g) => p === g.name);
50
50
  if (h)
51
- return h.rtype === "promise" ? (g) => i.nativePromise(c, p.toString(), g) : (g, H) => i.nativeCallback(c, p.toString(), g, H);
51
+ return h.rtype === "promise" ? (g) => i.nativePromise(c, p.toString(), g) : (g, x) => i.nativeCallback(c, p.toString(), g, x);
52
52
  if (u)
53
- return (v = u[p]) === null || v === void 0 ? void 0 : v.bind(u);
53
+ return (m = u[p]) === null || m === void 0 ? void 0 : m.bind(u);
54
54
  } else {
55
55
  if (u)
56
- return (m = u[p]) === null || m === void 0 ? void 0 : m.bind(u);
57
- throw new _(`"${c}" plugin is not implemented on ${P}`, A.Unimplemented);
56
+ return (v = u[p]) === null || v === void 0 ? void 0 : v.bind(u);
57
+ throw new E(`"${c}" plugin is not implemented on ${P}`, L.Unimplemented);
58
58
  }
59
59
  }, T = (u) => {
60
60
  let p;
61
- const v = (...m) => {
62
- const h = oe().then((g) => {
63
- const H = le(g, u);
64
- if (H) {
65
- const U = H(...m);
61
+ const m = (...v) => {
62
+ const h = re().then((g) => {
63
+ const x = ne(g, u);
64
+ if (x) {
65
+ const U = x(...v);
66
66
  return p = U == null ? void 0 : U.remove, U;
67
67
  } else
68
- throw new _(`"${c}.${u}()" is not implemented on ${P}`, A.Unimplemented);
68
+ throw new E(`"${c}.${u}()" is not implemented on ${P}`, L.Unimplemented);
69
69
  });
70
70
  return u === "addListener" && (h.remove = async () => p()), h;
71
71
  };
72
- return v.toString = () => `${u.toString()}() { [capacitor code] }`, Object.defineProperty(v, "name", {
72
+ return m.toString = () => `${u.toString()}() { [capacitor code] }`, Object.defineProperty(m, "name", {
73
73
  value: u,
74
74
  writable: !1,
75
75
  configurable: !1
76
- }), v;
77
- }, G = T("addListener"), J = T("removeListener"), ce = (u, p) => {
78
- const v = G({ eventName: u }, p), m = async () => {
79
- const g = await v;
76
+ }), m;
77
+ }, G = T("addListener"), J = T("removeListener"), ae = (u, p) => {
78
+ const m = G({ eventName: u }, p), v = async () => {
79
+ const g = await m;
80
80
  J({
81
81
  eventName: u,
82
82
  callbackId: g
83
83
  }, p);
84
- }, h = new Promise((g) => v.then(() => g({ remove: m })));
84
+ }, h = new Promise((g) => m.then(() => g({ remove: v })));
85
85
  return h.remove = async () => {
86
- console.warn("Using addListener() without 'await' is deprecated."), await m();
86
+ console.warn("Using addListener() without 'await' is deprecated."), await v();
87
87
  }, h;
88
88
  }, S = new Proxy({}, {
89
89
  get(u, p) {
@@ -93,7 +93,7 @@ const ge = (t) => {
93
93
  case "toJSON":
94
94
  return () => ({});
95
95
  case "addListener":
96
- return L ? ce : G;
96
+ return C ? ae : G;
97
97
  case "removeListener":
98
98
  return J;
99
99
  default:
@@ -101,27 +101,27 @@ const ge = (t) => {
101
101
  }
102
102
  }
103
103
  });
104
- return f[c] = S, E.set(c, {
104
+ return f[c] = S, H.set(c, {
105
105
  name: c,
106
106
  proxy: S,
107
107
  platforms: /* @__PURE__ */ new Set([
108
108
  ...Object.keys(d),
109
- ...L ? [P] : []
109
+ ...C ? [P] : []
110
110
  ])
111
111
  }), S;
112
- }, ie = ((a = l == null ? void 0 : l.currentPlatform) === null || a === void 0 ? void 0 : a.registerPlugin) || se;
113
- return i.convertFileSrc || (i.convertFileSrc = (c) => c), i.getPlatform = y, i.handleError = re, i.isNativePlatform = V, i.isPluginAvailable = te, i.pluginMethodNoop = ae, i.registerPlugin = ie, i.Exception = _, i.DEBUG = !!i.DEBUG, i.isLoggingEnabled = !!i.isLoggingEnabled, i.platform = i.getPlatform(), i.isNative = i.isNativePlatform(), i;
114
- }, we = (t) => t.Capacitor = ve(t), I = /* @__PURE__ */ we(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {}), W = I.registerPlugin;
115
- I.Plugins;
112
+ }, te = ((a = l == null ? void 0 : l.currentPlatform) === null || a === void 0 ? void 0 : a.registerPlugin) || ee;
113
+ return i.convertFileSrc || (i.convertFileSrc = (c) => c), i.getPlatform = b, i.handleError = Z, i.isNativePlatform = z, i.isPluginAvailable = X, i.pluginMethodNoop = V, i.registerPlugin = te, i.Exception = E, i.DEBUG = !!i.DEBUG, i.isLoggingEnabled = !!i.isLoggingEnabled, i.platform = i.getPlatform(), i.isNative = i.isNativePlatform(), i;
114
+ }, ue = (t) => t.Capacitor = de(t), O = /* @__PURE__ */ ue(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {}), N = O.registerPlugin;
115
+ O.Plugins;
116
116
  class M {
117
117
  constructor(e) {
118
118
  this.listeners = {}, this.windowListeners = {}, e && (console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`), this.config = e);
119
119
  }
120
- addListener(e, n) {
121
- this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(n);
122
- const r = this.windowListeners[e];
123
- r && !r.registered && this.addWindowListener(r);
124
- const a = async () => this.removeListener(e, n), o = Promise.resolve({ remove: a });
120
+ addListener(e, r) {
121
+ this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(r);
122
+ const n = this.windowListeners[e];
123
+ n && !n.registered && this.addWindowListener(n);
124
+ const a = async () => this.removeListener(e, r), o = Promise.resolve({ remove: a });
125
125
  return Object.defineProperty(o, "remove", {
126
126
  value: async () => {
127
127
  console.warn("Using addListener() without 'await' is deprecated."), await a();
@@ -134,35 +134,35 @@ class M {
134
134
  this.removeWindowListener(this.windowListeners[e]);
135
135
  this.windowListeners = {};
136
136
  }
137
- notifyListeners(e, n) {
137
+ notifyListeners(e, r) {
138
138
  const s = this.listeners[e];
139
- s && s.forEach((r) => r(n));
139
+ s && s.forEach((n) => n(r));
140
140
  }
141
141
  hasListeners(e) {
142
142
  return !!this.listeners[e].length;
143
143
  }
144
- registerWindowListener(e, n) {
145
- this.windowListeners[n] = {
144
+ registerWindowListener(e, r) {
145
+ this.windowListeners[r] = {
146
146
  registered: !1,
147
147
  windowEventName: e,
148
- pluginEventName: n,
148
+ pluginEventName: r,
149
149
  handler: (s) => {
150
- this.notifyListeners(n, s);
150
+ this.notifyListeners(r, s);
151
151
  }
152
152
  };
153
153
  }
154
154
  unimplemented(e = "not implemented") {
155
- return new I.Exception(e, A.Unimplemented);
155
+ return new O.Exception(e, L.Unimplemented);
156
156
  }
157
157
  unavailable(e = "not available") {
158
- return new I.Exception(e, A.Unavailable);
158
+ return new O.Exception(e, L.Unavailable);
159
159
  }
160
- async removeListener(e, n) {
160
+ async removeListener(e, r) {
161
161
  const s = this.listeners[e];
162
162
  if (!s)
163
163
  return;
164
- const r = s.indexOf(n);
165
- this.listeners[e].splice(r, 1), this.listeners[e].length || this.removeWindowListener(this.windowListeners[e]);
164
+ const n = s.indexOf(r);
165
+ this.listeners[e].splice(n, 1), this.listeners[e].length || this.removeWindowListener(this.windowListeners[e]);
166
166
  }
167
167
  addWindowListener(e) {
168
168
  window.addEventListener(e.windowEventName, e.handler), e.registered = !0;
@@ -172,36 +172,36 @@ class M {
172
172
  }
173
173
  }
174
174
  const F = (t) => encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape), K = (t) => t.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
175
- class me extends M {
175
+ class fe extends M {
176
176
  async getCookies() {
177
- const e = document.cookie, n = {};
177
+ const e = document.cookie, r = {};
178
178
  return e.split(";").forEach((s) => {
179
179
  if (s.length <= 0)
180
180
  return;
181
- let [r, a] = s.replace(/=/, "CAP_COOKIE").split("CAP_COOKIE");
182
- r = K(r).trim(), a = K(a).trim(), n[r] = a;
183
- }), n;
181
+ let [n, a] = s.replace(/=/, "CAP_COOKIE").split("CAP_COOKIE");
182
+ n = K(n).trim(), a = K(a).trim(), r[n] = a;
183
+ }), r;
184
184
  }
185
185
  async setCookie(e) {
186
186
  try {
187
- const n = F(e.key), s = F(e.value), r = `; expires=${(e.expires || "").replace("expires=", "")}`, a = (e.path || "/").replace("path=", ""), o = e.url != null && e.url.length > 0 ? `domain=${e.url}` : "";
188
- document.cookie = `${n}=${s || ""}${r}; path=${a}; ${o};`;
189
- } catch (n) {
190
- return Promise.reject(n);
187
+ const r = F(e.key), s = F(e.value), n = `; expires=${(e.expires || "").replace("expires=", "")}`, a = (e.path || "/").replace("path=", ""), o = e.url != null && e.url.length > 0 ? `domain=${e.url}` : "";
188
+ document.cookie = `${r}=${s || ""}${n}; path=${a}; ${o};`;
189
+ } catch (r) {
190
+ return Promise.reject(r);
191
191
  }
192
192
  }
193
193
  async deleteCookie(e) {
194
194
  try {
195
195
  document.cookie = `${e.key}=; Max-Age=0`;
196
- } catch (n) {
197
- return Promise.reject(n);
196
+ } catch (r) {
197
+ return Promise.reject(r);
198
198
  }
199
199
  }
200
200
  async clearCookies() {
201
201
  try {
202
202
  const e = document.cookie.split(";") || [];
203
- for (const n of e)
204
- document.cookie = n.replace(/^ +/, "").replace(/=.*/, `=;expires=${(/* @__PURE__ */ new Date()).toUTCString()};path=/`);
203
+ for (const r of e)
204
+ document.cookie = r.replace(/^ +/, "").replace(/=.*/, `=;expires=${(/* @__PURE__ */ new Date()).toUTCString()};path=/`);
205
205
  } catch (e) {
206
206
  return Promise.reject(e);
207
207
  }
@@ -214,34 +214,34 @@ class me extends M {
214
214
  }
215
215
  }
216
216
  }
217
- W("CapacitorCookies", {
218
- web: () => new me()
217
+ N("CapacitorCookies", {
218
+ web: () => new fe()
219
219
  });
220
- const he = async (t) => new Promise((e, n) => {
220
+ const pe = async (t) => new Promise((e, r) => {
221
221
  const s = new FileReader();
222
222
  s.onload = () => {
223
- const r = s.result;
224
- e(r.indexOf(",") >= 0 ? r.split(",")[1] : r);
225
- }, s.onerror = (r) => n(r), s.readAsDataURL(t);
226
- }), Pe = (t = {}) => {
223
+ const n = s.result;
224
+ e(n.indexOf(",") >= 0 ? n.split(",")[1] : n);
225
+ }, s.onerror = (n) => r(n), s.readAsDataURL(t);
226
+ }), ge = (t = {}) => {
227
227
  const e = Object.keys(t);
228
- return Object.keys(t).map((r) => r.toLocaleLowerCase()).reduce((r, a, o) => (r[a] = t[e[o]], r), {});
229
- }, be = (t, e = !0) => t ? Object.entries(t).reduce((s, r) => {
230
- const [a, o] = r;
228
+ return Object.keys(t).map((n) => n.toLocaleLowerCase()).reduce((n, a, o) => (n[a] = t[e[o]], n), {});
229
+ }, me = (t, e = !0) => t ? Object.entries(t).reduce((s, n) => {
230
+ const [a, o] = n;
231
231
  let i, f;
232
232
  return Array.isArray(o) ? (f = "", o.forEach((l) => {
233
233
  i = e ? encodeURIComponent(l) : l, f += `${a}=${i}&`;
234
234
  }), f.slice(0, -1)) : (i = e ? encodeURIComponent(o) : o, f = `${a}=${i}`), `${s}&${f}`;
235
- }, "").substr(1) : null, ye = (t, e = {}) => {
236
- const n = Object.assign({ method: t.method || "GET", headers: t.headers }, e), r = Pe(t.headers)["content-type"] || "";
235
+ }, "").substr(1) : null, we = (t, e = {}) => {
236
+ const r = Object.assign({ method: t.method || "GET", headers: t.headers }, e), n = ge(t.headers)["content-type"] || "";
237
237
  if (typeof t.data == "string")
238
- n.body = t.data;
239
- else if (r.includes("application/x-www-form-urlencoded")) {
238
+ r.body = t.data;
239
+ else if (n.includes("application/x-www-form-urlencoded")) {
240
240
  const a = new URLSearchParams();
241
241
  for (const [o, i] of Object.entries(t.data || {}))
242
242
  a.set(o, i);
243
- n.body = a.toString();
244
- } else if (r.includes("multipart/form-data")) {
243
+ r.body = a.toString();
244
+ } else if (n.includes("multipart/form-data")) {
245
245
  const a = new FormData();
246
246
  if (t.data instanceof FormData)
247
247
  t.data.forEach((i, f) => {
@@ -250,27 +250,27 @@ const he = async (t) => new Promise((e, n) => {
250
250
  else
251
251
  for (const i of Object.keys(t.data))
252
252
  a.append(i, t.data[i]);
253
- n.body = a;
254
- const o = new Headers(n.headers);
255
- o.delete("content-type"), n.headers = o;
253
+ r.body = a;
254
+ const o = new Headers(r.headers);
255
+ o.delete("content-type"), r.headers = o;
256
256
  } else
257
- (r.includes("application/json") || typeof t.data == "object") && (n.body = JSON.stringify(t.data));
258
- return n;
257
+ (n.includes("application/json") || typeof t.data == "object") && (r.body = JSON.stringify(t.data));
258
+ return r;
259
259
  };
260
- class Ce extends M {
260
+ class ve extends M {
261
261
  /**
262
262
  * Perform an Http request given a set of options
263
263
  * @param options Options to build the HTTP request
264
264
  */
265
265
  async request(e) {
266
- const n = ye(e, e.webFetchExtra), s = be(e.params, e.shouldEncodeUrlParams), r = s ? `${e.url}?${s}` : e.url, a = await fetch(r, n), o = a.headers.get("content-type") || "";
266
+ const r = we(e, e.webFetchExtra), s = me(e.params, e.shouldEncodeUrlParams), n = s ? `${e.url}?${s}` : e.url, a = await fetch(n, r), o = a.headers.get("content-type") || "";
267
267
  let { responseType: i = "text" } = a.ok ? e : {};
268
268
  o.includes("application/json") && (i = "json");
269
269
  let f, l;
270
270
  switch (i) {
271
271
  case "arraybuffer":
272
272
  case "blob":
273
- l = await a.blob(), f = await he(l);
273
+ l = await a.blob(), f = await pe(l);
274
274
  break;
275
275
  case "json":
276
276
  f = await a.json();
@@ -280,12 +280,12 @@ class Ce extends M {
280
280
  default:
281
281
  f = await a.text();
282
282
  }
283
- const x = {};
284
- return a.headers.forEach((y, j) => {
285
- x[j] = y;
283
+ const k = {};
284
+ return a.headers.forEach((b, j) => {
285
+ k[j] = b;
286
286
  }), {
287
287
  data: f,
288
- headers: x,
288
+ headers: k,
289
289
  status: a.status,
290
290
  url: a.url
291
291
  };
@@ -326,128 +326,111 @@ class Ce extends M {
326
326
  return this.request(Object.assign(Object.assign({}, e), { method: "DELETE" }));
327
327
  }
328
328
  }
329
- W("CapacitorHttp", {
330
- web: () => new Ce()
329
+ N("CapacitorHttp", {
330
+ web: () => new ve()
331
331
  });
332
332
  /*! Ionic Portals: https://ionic.io/portals - Commercial License */
333
- W("Portals", {
333
+ N("Portals", {
334
334
  web: () => Promise.resolve().then(function() {
335
- return Ae;
335
+ return Pe;
336
336
  }).then((t) => new t.PortalsWeb())
337
337
  });
338
- function N() {
339
- return I.getPlatform() === "android" ? JSON.parse(AndroidInitialContext.initialContext()) : window.portalInitialContext;
338
+ function D() {
339
+ return O.getPlatform() === "android" ? JSON.parse(AndroidInitialContext.initialContext()) : window.portalInitialContext;
340
340
  }
341
- class Le extends M {
341
+ class he extends M {
342
342
  // eslint-disable-next-line
343
343
  async publishNative(e) {
344
344
  }
345
345
  }
346
- const Ae = /* @__PURE__ */ Object.freeze({
346
+ const Pe = /* @__PURE__ */ Object.freeze({
347
347
  __proto__: null,
348
- PortalsWeb: Le
348
+ PortalsWeb: he
349
349
  });
350
- var $ = /* @__PURE__ */ ((t) => (t.DEV = "dev", t.SIT = "sit", t.UAT = "uat", t.PROD = "prod", t.TEST = "test", t))($ || {}), D = /* @__PURE__ */ ((t) => (t.EU = "eu", t.ASIA = "asia", t))(D || {});
350
+ var A = /* @__PURE__ */ ((t) => (t.DEV = "dev", t.SIT = "sit", t.UAT = "uat", t.PROD = "prod", t.TEST = "test", t))(A || {}), I = /* @__PURE__ */ ((t) => (t.EU = "eu", t.ASIA = "asia", t))(I || {});
351
351
  const q = (t) => {
352
- var e, n;
353
- if (!(typeof window > "u") && N && (e = N()) != null && e.value) {
354
- const s = ((n = N()) == null ? void 0 : n.value) ?? null;
352
+ var e, r;
353
+ if (!(typeof window > "u") && D && (e = D()) != null && e.value) {
354
+ const s = ((r = D()) == null ? void 0 : r.value) ?? null;
355
355
  s && t && t(s);
356
356
  }
357
- }, Oe = (t, { asiaUatData: e, euSitData: n, euUatData: s }) => {
358
- const r = t.env.serveEnv, a = t.env.areaEnv;
357
+ }, be = (t, { asiaUatData: e, euSitData: r, euUatData: s }) => {
358
+ const n = t.serverInfo.env, a = t.serverInfo.area;
359
359
  let o = null;
360
- return D.ASIA === a ? $.UAT === r && (o = e) : D.EU === a && ($.SIT === r ? o = n : $.UAT === r && (o = s)), o;
361
- }, R = (t) => new Promise(async (e) => {
362
- let n = Oe(t, {
363
- asiaUatData: await import("./chunk/1b5f5213.js"),
364
- euSitData: await import("./chunk/02340160.js"),
365
- euUatData: await import("./chunk/7615ea07.js")
366
- });
367
- e((n == null ? void 0 : n.default) ?? "");
368
- }), z = () => {
369
- let t = null;
370
- return q((e) => {
371
- e ? t = {
372
- data_info: e.data_info ? JSON.parse(e.data_info) : null,
373
- data_store: e.data_store ? JSON.parse(e.data_store) : null,
374
- data_language: e.data_language ? JSON.parse(e.data_language) : null
375
- } : t = null;
376
- }), t;
377
- }, Q = ({ cb: t }) => {
360
+ return I.ASIA === a ? A.UAT === n && (o = e) : I.EU === a && (A.SIT === n ? o = r : A.UAT === n && (o = s)), o;
361
+ }, ye = ({ cb: t }) => {
378
362
  setTimeout(() => {
379
363
  q((e) => {
380
364
  if (!(e != null && e.params))
381
365
  return;
382
- const n = JSON.parse(e.params) ?? null;
383
- if (!n)
366
+ const r = JSON.parse(e.params) ?? null;
367
+ if (!r)
384
368
  return;
385
- const { params: s, routeName: r } = n;
386
- !s || !r || t && t();
369
+ const { params: s, routeName: n } = r;
370
+ !s || !n || t && t(r);
387
371
  });
388
372
  });
389
- }, X = () => {
373
+ }, Ce = () => {
390
374
  let t = !1;
391
375
  return q((e) => {
392
376
  t = !!(e != null && e.isNative);
393
377
  }), t;
394
- }, k = class k {
395
- constructor(e) {
396
- O(this, "nativeApiConfig");
397
- this.nativeApiConfig = e, k.nativeApiConfig = e;
378
+ }, Le = (t) => new Promise(async (e) => {
379
+ let r = be(t, {
380
+ asiaUatData: await import("./chunk/1b5f5213.js"),
381
+ euSitData: await import("./chunk/7615ea07.js"),
382
+ euUatData: await import("./chunk/02340160.js")
383
+ });
384
+ e((r == null ? void 0 : r.default) ?? null);
385
+ }), Ae = () => {
386
+ let t = null;
387
+ return q((e) => {
388
+ e ? t = {
389
+ data_info: e.data_info ? JSON.parse(e.data_info) : null,
390
+ data_store: e.data_store ? JSON.parse(e.data_store) : null,
391
+ data_language: e.data_language ? JSON.parse(e.data_language) : null
392
+ } : t = null;
393
+ }), t;
394
+ }, $ = class $ {
395
+ constructor() {
396
+ _(this, "nativeApiConfig");
397
+ this.nativeApiConfig = $.defaultNativeApiConfig;
398
398
  }
399
399
  // getIsNativeHandle
400
400
  async getIsNativeHandle() {
401
- return await X();
402
- }
403
- static async getIsNativeHandle() {
404
- return await X();
401
+ return await Ce();
405
402
  }
406
403
  // specifiedPageHandle
407
404
  async specifiedPageHandle({ cb: e }) {
408
- await Q({ cb: e });
409
- }
410
- static async specifiedPageHandle({ cb: e }) {
411
- await Q({ cb: e });
405
+ await ye({ cb: e });
412
406
  }
413
407
  // nativeAppInfo
414
- async nativeAppInfo() {
415
- return await this.getIsNativeHandle() ? await z() : await R(this.nativeApiConfig);
416
- }
417
- static async nativeAppInfo() {
418
- return await this.getIsNativeHandle() ? await z() : await R(k.nativeApiConfig);
408
+ async nativeAppInfo(e) {
409
+ return e && (this.nativeApiConfig = e), await this.getIsNativeHandle() ? await Ae() : await Le(this.nativeApiConfig);
419
410
  }
420
411
  };
421
- O(k, "nativeApiConfig");
422
- let b = k;
423
- class Z extends b {
424
- constructor(n) {
425
- super(n);
426
- O(this, "nativeApiConfig");
427
- this.nativeApiConfig = n, b.nativeApiConfig = n;
412
+ _($, "defaultNativeApiConfig", {
413
+ serverInfo: {
414
+ area: I.ASIA,
415
+ env: A.UAT
416
+ }
417
+ });
418
+ let W = $;
419
+ class Oe extends W {
420
+ constructor() {
421
+ super();
428
422
  }
429
423
  async getIsNativeHandle() {
430
424
  return await super.getIsNativeHandle();
431
425
  }
432
- static async getIsNativeHandle() {
433
- return await b.getIsNativeHandle();
434
- }
435
- async specifiedPageHandle({ cb: n }) {
436
- return await super.specifiedPageHandle({ cb: n });
437
- }
438
- static async specifiedPageHandle({ cb: n }) {
439
- return await b.specifiedPageHandle({ cb: n });
440
- }
441
- async nativeAppInfo() {
442
- await super.nativeAppInfo();
426
+ async specifiedPageHandle({ cb: e }) {
427
+ return await super.specifiedPageHandle({ cb: e });
443
428
  }
444
- static async nativeAppInfo() {
445
- await b.nativeAppInfo();
429
+ async nativeAppInfo(e) {
430
+ return await super.nativeAppInfo(e);
446
431
  }
447
432
  }
448
- O(Z, "nativeApiConfig");
449
- class Ie extends Z {
450
- }
433
+ const xe = new Oe();
451
434
  export {
452
- Ie as default
435
+ xe as default
453
436
  };
package/lib/main.umd.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var de=Object.defineProperty;var ue=(t,e,n)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var O=(t,e,n)=>(ue(t,typeof e!="symbol"?e+"":e,n),n);/*! Capacitor: https://capacitorjs.com/ - MIT License */const fe=t=>{const e=new Map;e.set("web",{name:"web"});const n=t.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:e},s=(a,o)=>{n.platforms.set(a,o)},r=a=>{n.platforms.has(a)&&(n.currentPlatform=n.platforms.get(a))};return n.addPlatform=s,n.setPlatform=r,n},pe=t=>t.CapacitorPlatforms=fe(t),Y=pe(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});Y.addPlatform;Y.setPlatform;var A;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(A||(A={}));class _ extends Error{constructor(e,n,s){super(e),this.message=e,this.code=n,this.data=s}}const ge=t=>{var e,n;return t!=null&&t.androidBridge?"android":!((n=(e=t==null?void 0:t.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},ve=t=>{var e,n,s,r,a;const o=t.CapacitorCustomPlatform||null,i=t.Capacitor||{},f=i.Plugins=i.Plugins||{},l=t.CapacitorPlatforms,x=()=>o!==null?o.name:ge(t),y=((e=l==null?void 0:l.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||x,j=()=>y()!=="web",V=((n=l==null?void 0:l.currentPlatform)===null||n===void 0?void 0:n.isNativePlatform)||j,ee=c=>{const d=E.get(c);return!!(d!=null&&d.platforms.has(y())||B(c))},te=((s=l==null?void 0:l.currentPlatform)===null||s===void 0?void 0:s.isPluginAvailable)||ee,ne=c=>{var d;return(d=i.PluginHeaders)===null||d===void 0?void 0:d.find(C=>C.name===c)},B=((r=l==null?void 0:l.currentPlatform)===null||r===void 0?void 0:r.getPluginHeader)||ne,re=c=>t.console.error(c),ae=(c,d,C)=>Promise.reject(`${C} does not have an implementation of "${d}".`),E=new Map,se=(c,d={})=>{const C=E.get(c);if(C)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),C.proxy;const P=y(),L=B(c);let w;const oe=async()=>(!w&&P in d?w=typeof d[P]=="function"?w=await d[P]():w=d[P]:o!==null&&!w&&"web"in d&&(w=typeof d.web=="function"?w=await d.web():w=d.web),w),le=(u,p)=>{var v,m;if(L){const h=L==null?void 0:L.methods.find(g=>p===g.name);if(h)return h.rtype==="promise"?g=>i.nativePromise(c,p.toString(),g):(g,H)=>i.nativeCallback(c,p.toString(),g,H);if(u)return(v=u[p])===null||v===void 0?void 0:v.bind(u)}else{if(u)return(m=u[p])===null||m===void 0?void 0:m.bind(u);throw new _(`"${c}" plugin is not implemented on ${P}`,A.Unimplemented)}},T=u=>{let p;const v=(...m)=>{const h=oe().then(g=>{const H=le(g,u);if(H){const U=H(...m);return p=U==null?void 0:U.remove,U}else throw new _(`"${c}.${u}()" is not implemented on ${P}`,A.Unimplemented)});return u==="addListener"&&(h.remove=async()=>p()),h};return v.toString=()=>`${u.toString()}() { [capacitor code] }`,Object.defineProperty(v,"name",{value:u,writable:!1,configurable:!1}),v},G=T("addListener"),J=T("removeListener"),ce=(u,p)=>{const v=G({eventName:u},p),m=async()=>{const g=await v;J({eventName:u,callbackId:g},p)},h=new Promise(g=>v.then(()=>g({remove:m})));return h.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await m()},h},S=new Proxy({},{get(u,p){switch(p){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return L?ce:G;case"removeListener":return J;default:return T(p)}}});return f[c]=S,E.set(c,{name:c,proxy:S,platforms:new Set([...Object.keys(d),...L?[P]:[]])}),S},ie=((a=l==null?void 0:l.currentPlatform)===null||a===void 0?void 0:a.registerPlugin)||se;return i.convertFileSrc||(i.convertFileSrc=c=>c),i.getPlatform=y,i.handleError=re,i.isNativePlatform=V,i.isPluginAvailable=te,i.pluginMethodNoop=ae,i.registerPlugin=ie,i.Exception=_,i.DEBUG=!!i.DEBUG,i.isLoggingEnabled=!!i.isLoggingEnabled,i.platform=i.getPlatform(),i.isNative=i.isNativePlatform(),i},we=t=>t.Capacitor=ve(t),I=we(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),W=I.registerPlugin;I.Plugins;class M{constructor(e){this.listeners={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,n){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(n);const r=this.windowListeners[e];r&&!r.registered&&this.addWindowListener(r);const a=async()=>this.removeListener(e,n),o=Promise.resolve({remove:a});return Object.defineProperty(o,"remove",{value:async()=>{console.warn("Using addListener() without 'await' is deprecated."),await a()}}),o}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,n){const s=this.listeners[e];s&&s.forEach(r=>r(n))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,n){this.windowListeners[n]={registered:!1,windowEventName:e,pluginEventName:n,handler:s=>{this.notifyListeners(n,s)}}}unimplemented(e="not implemented"){return new I.Exception(e,A.Unimplemented)}unavailable(e="not available"){return new I.Exception(e,A.Unavailable)}async removeListener(e,n){const s=this.listeners[e];if(!s)return;const r=s.indexOf(n);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}}const F=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),K=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class me extends M{async getCookies(){const e=document.cookie,n={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[r,a]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=K(r).trim(),a=K(a).trim(),n[r]=a}),n}async setCookie(e){try{const n=F(e.key),s=F(e.value),r=`; expires=${(e.expires||"").replace("expires=","")}`,a=(e.path||"/").replace("path=",""),o=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${n}=${s||""}${r}; path=${a}; ${o};`}catch(n){return Promise.reject(n)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const n of e)document.cookie=n.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}W("CapacitorCookies",{web:()=>new me});const he=async t=>new Promise((e,n)=>{const s=new FileReader;s.onload=()=>{const r=s.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},s.onerror=r=>n(r),s.readAsDataURL(t)}),Pe=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(r=>r.toLocaleLowerCase()).reduce((r,a,o)=>(r[a]=t[e[o]],r),{})},be=(t,e=!0)=>t?Object.entries(t).reduce((s,r)=>{const[a,o]=r;let i,f;return Array.isArray(o)?(f="",o.forEach(l=>{i=e?encodeURIComponent(l):l,f+=`${a}=${i}&`}),f.slice(0,-1)):(i=e?encodeURIComponent(o):o,f=`${a}=${i}`),`${s}&${f}`},"").substr(1):null,ye=(t,e={})=>{const n=Object.assign({method:t.method||"GET",headers:t.headers},e),r=Pe(t.headers)["content-type"]||"";if(typeof t.data=="string")n.body=t.data;else if(r.includes("application/x-www-form-urlencoded")){const a=new URLSearchParams;for(const[o,i]of Object.entries(t.data||{}))a.set(o,i);n.body=a.toString()}else if(r.includes("multipart/form-data")){const a=new FormData;if(t.data instanceof FormData)t.data.forEach((i,f)=>{a.append(f,i)});else for(const i of Object.keys(t.data))a.append(i,t.data[i]);n.body=a;const o=new Headers(n.headers);o.delete("content-type"),n.headers=o}else(r.includes("application/json")||typeof t.data=="object")&&(n.body=JSON.stringify(t.data));return n};class Ce extends M{async request(e){const n=ye(e,e.webFetchExtra),s=be(e.params,e.shouldEncodeUrlParams),r=s?`${e.url}?${s}`:e.url,a=await fetch(r,n),o=a.headers.get("content-type")||"";let{responseType:i="text"}=a.ok?e:{};o.includes("application/json")&&(i="json");let f,l;switch(i){case"arraybuffer":case"blob":l=await a.blob(),f=await he(l);break;case"json":f=await a.json();break;case"document":case"text":default:f=await a.text()}const x={};return a.headers.forEach((y,j)=>{x[j]=y}),{data:f,headers:x,status:a.status,url:a.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}W("CapacitorHttp",{web:()=>new Ce});/*! Ionic Portals: https://ionic.io/portals - Commercial License */W("Portals",{web:()=>Promise.resolve().then(function(){return Ae}).then(t=>new t.PortalsWeb)});function N(){return I.getPlatform()==="android"?JSON.parse(AndroidInitialContext.initialContext()):window.portalInitialContext}class Le extends M{async publishNative(e){}}const Ae=Object.freeze({__proto__:null,PortalsWeb:Le});var $=(t=>(t.DEV="dev",t.SIT="sit",t.UAT="uat",t.PROD="prod",t.TEST="test",t))($||{}),D=(t=>(t.EU="eu",t.ASIA="asia",t))(D||{});const q=t=>{var e,n;if(!(typeof window>"u")&&N&&(e=N())!=null&&e.value){const s=((n=N())==null?void 0:n.value)??null;s&&t&&t(s)}},Oe=(t,{asiaUatData:e,euSitData:n,euUatData:s})=>{const r=t.env.serveEnv,a=t.env.areaEnv;let o=null;return D.ASIA===a?$.UAT===r&&(o=e):D.EU===a&&($.SIT===r?o=n:$.UAT===r&&(o=s)),o},R=t=>new Promise(async e=>{let n=Oe(t,{asiaUatData:await Promise.resolve().then(()=>require("./umd/fbb879ae.umd.cjs")),euSitData:await Promise.resolve().then(()=>require("./umd/7c40191f.umd.cjs")),euUatData:await Promise.resolve().then(()=>require("./umd/5ca52608.umd.cjs"))});e((n==null?void 0:n.default)??"")}),z=()=>{let t=null;return q(e=>{e?t={data_info:e.data_info?JSON.parse(e.data_info):null,data_store:e.data_store?JSON.parse(e.data_store):null,data_language:e.data_language?JSON.parse(e.data_language):null}:t=null}),t},Q=({cb:t})=>{setTimeout(()=>{q(e=>{if(!(e!=null&&e.params))return;const n=JSON.parse(e.params)??null;if(!n)return;const{params:s,routeName:r}=n;!s||!r||t&&t()})})},X=()=>{let t=!1;return q(e=>{t=!!(e!=null&&e.isNative)}),t},k=class k{constructor(e){O(this,"nativeApiConfig");this.nativeApiConfig=e,k.nativeApiConfig=e}async getIsNativeHandle(){return await X()}static async getIsNativeHandle(){return await X()}async specifiedPageHandle({cb:e}){await Q({cb:e})}static async specifiedPageHandle({cb:e}){await Q({cb:e})}async nativeAppInfo(){return await this.getIsNativeHandle()?await z():await R(this.nativeApiConfig)}static async nativeAppInfo(){return await this.getIsNativeHandle()?await z():await R(k.nativeApiConfig)}};O(k,"nativeApiConfig");let b=k;class Z extends b{constructor(n){super(n);O(this,"nativeApiConfig");this.nativeApiConfig=n,b.nativeApiConfig=n}async getIsNativeHandle(){return await super.getIsNativeHandle()}static async getIsNativeHandle(){return await b.getIsNativeHandle()}async specifiedPageHandle({cb:n}){return await super.specifiedPageHandle({cb:n})}static async specifiedPageHandle({cb:n}){return await b.specifiedPageHandle({cb:n})}async nativeAppInfo(){await super.nativeAppInfo()}static async nativeAppInfo(){await b.nativeAppInfo()}}O(Z,"nativeApiConfig");class ke extends Z{}module.exports=ke;
1
+ "use strict";var ae=Object.defineProperty;var ie=(t,e,r)=>e in t?ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var _=(t,e,r)=>(ie(t,typeof e!="symbol"?e+"":e,r),r);/*! Capacitor: https://capacitorjs.com/ - MIT License */const oe=t=>{const e=new Map;e.set("web",{name:"web"});const r=t.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:e},a=(s,o)=>{r.platforms.set(s,o)},n=s=>{r.platforms.has(s)&&(r.currentPlatform=r.platforms.get(s))};return r.addPlatform=a,r.setPlatform=n,r},le=t=>t.CapacitorPlatforms=oe(t),R=le(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});R.addPlatform;R.setPlatform;var L;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(L||(L={}));class E extends Error{constructor(e,r,a){super(e),this.message=e,this.code=r,this.data=a}}const ce=t=>{var e,r;return t!=null&&t.androidBridge?"android":!((r=(e=t==null?void 0:t.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||r===void 0)&&r.bridge?"ios":"web"},de=t=>{var e,r,a,n,s;const o=t.CapacitorCustomPlatform||null,i=t.Capacitor||{},f=i.Plugins=i.Plugins||{},l=t.CapacitorPlatforms,k=()=>o!==null?o.name:ce(t),b=((e=l==null?void 0:l.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||k,j=()=>b()!=="web",z=((r=l==null?void 0:l.currentPlatform)===null||r===void 0?void 0:r.isNativePlatform)||j,Q=c=>{const d=H.get(c);return!!(d!=null&&d.platforms.has(b())||B(c))},X=((a=l==null?void 0:l.currentPlatform)===null||a===void 0?void 0:a.isPluginAvailable)||Q,Y=c=>{var d;return(d=i.PluginHeaders)===null||d===void 0?void 0:d.find(y=>y.name===c)},B=((n=l==null?void 0:l.currentPlatform)===null||n===void 0?void 0:n.getPluginHeader)||Y,Z=c=>t.console.error(c),V=(c,d,y)=>Promise.reject(`${y} does not have an implementation of "${d}".`),H=new Map,ee=(c,d={})=>{const y=H.get(c);if(y)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),y.proxy;const P=b(),C=B(c);let w;const re=async()=>(!w&&P in d?w=typeof d[P]=="function"?w=await d[P]():w=d[P]:o!==null&&!w&&"web"in d&&(w=typeof d.web=="function"?w=await d.web():w=d.web),w),ne=(u,g)=>{var m,v;if(C){const h=C==null?void 0:C.methods.find(p=>g===p.name);if(h)return h.rtype==="promise"?p=>i.nativePromise(c,g.toString(),p):(p,x)=>i.nativeCallback(c,g.toString(),p,x);if(u)return(m=u[g])===null||m===void 0?void 0:m.bind(u)}else{if(u)return(v=u[g])===null||v===void 0?void 0:v.bind(u);throw new E(`"${c}" plugin is not implemented on ${P}`,L.Unimplemented)}},T=u=>{let g;const m=(...v)=>{const h=re().then(p=>{const x=ne(p,u);if(x){const U=x(...v);return g=U==null?void 0:U.remove,U}else throw new E(`"${c}.${u}()" is not implemented on ${P}`,L.Unimplemented)});return u==="addListener"&&(h.remove=async()=>g()),h};return m.toString=()=>`${u.toString()}() { [capacitor code] }`,Object.defineProperty(m,"name",{value:u,writable:!1,configurable:!1}),m},G=T("addListener"),J=T("removeListener"),se=(u,g)=>{const m=G({eventName:u},g),v=async()=>{const p=await m;J({eventName:u,callbackId:p},g)},h=new Promise(p=>m.then(()=>p({remove:v})));return h.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await v()},h},S=new Proxy({},{get(u,g){switch(g){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return C?se:G;case"removeListener":return J;default:return T(g)}}});return f[c]=S,H.set(c,{name:c,proxy:S,platforms:new Set([...Object.keys(d),...C?[P]:[]])}),S},te=((s=l==null?void 0:l.currentPlatform)===null||s===void 0?void 0:s.registerPlugin)||ee;return i.convertFileSrc||(i.convertFileSrc=c=>c),i.getPlatform=b,i.handleError=Z,i.isNativePlatform=z,i.isPluginAvailable=X,i.pluginMethodNoop=V,i.registerPlugin=te,i.Exception=E,i.DEBUG=!!i.DEBUG,i.isLoggingEnabled=!!i.isLoggingEnabled,i.platform=i.getPlatform(),i.isNative=i.isNativePlatform(),i},ue=t=>t.Capacitor=de(t),O=ue(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),N=O.registerPlugin;O.Plugins;class M{constructor(e){this.listeners={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,r){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(r);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n);const s=async()=>this.removeListener(e,r),o=Promise.resolve({remove:s});return Object.defineProperty(o,"remove",{value:async()=>{console.warn("Using addListener() without 'await' is deprecated."),await s()}}),o}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,r){const a=this.listeners[e];a&&a.forEach(n=>n(r))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,r){this.windowListeners[r]={registered:!1,windowEventName:e,pluginEventName:r,handler:a=>{this.notifyListeners(r,a)}}}unimplemented(e="not implemented"){return new O.Exception(e,L.Unimplemented)}unavailable(e="not available"){return new O.Exception(e,L.Unavailable)}async removeListener(e,r){const a=this.listeners[e];if(!a)return;const n=a.indexOf(r);this.listeners[e].splice(n,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}}const F=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),K=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class fe extends M{async getCookies(){const e=document.cookie,r={};return e.split(";").forEach(a=>{if(a.length<=0)return;let[n,s]=a.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");n=K(n).trim(),s=K(s).trim(),r[n]=s}),r}async setCookie(e){try{const r=F(e.key),a=F(e.value),n=`; expires=${(e.expires||"").replace("expires=","")}`,s=(e.path||"/").replace("path=",""),o=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${r}=${a||""}${n}; path=${s}; ${o};`}catch(r){return Promise.reject(r)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(r){return Promise.reject(r)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const r of e)document.cookie=r.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}N("CapacitorCookies",{web:()=>new fe});const ge=async t=>new Promise((e,r)=>{const a=new FileReader;a.onload=()=>{const n=a.result;e(n.indexOf(",")>=0?n.split(",")[1]:n)},a.onerror=n=>r(n),a.readAsDataURL(t)}),pe=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(n=>n.toLocaleLowerCase()).reduce((n,s,o)=>(n[s]=t[e[o]],n),{})},me=(t,e=!0)=>t?Object.entries(t).reduce((a,n)=>{const[s,o]=n;let i,f;return Array.isArray(o)?(f="",o.forEach(l=>{i=e?encodeURIComponent(l):l,f+=`${s}=${i}&`}),f.slice(0,-1)):(i=e?encodeURIComponent(o):o,f=`${s}=${i}`),`${a}&${f}`},"").substr(1):null,we=(t,e={})=>{const r=Object.assign({method:t.method||"GET",headers:t.headers},e),n=pe(t.headers)["content-type"]||"";if(typeof t.data=="string")r.body=t.data;else if(n.includes("application/x-www-form-urlencoded")){const s=new URLSearchParams;for(const[o,i]of Object.entries(t.data||{}))s.set(o,i);r.body=s.toString()}else if(n.includes("multipart/form-data")){const s=new FormData;if(t.data instanceof FormData)t.data.forEach((i,f)=>{s.append(f,i)});else for(const i of Object.keys(t.data))s.append(i,t.data[i]);r.body=s;const o=new Headers(r.headers);o.delete("content-type"),r.headers=o}else(n.includes("application/json")||typeof t.data=="object")&&(r.body=JSON.stringify(t.data));return r};class ve extends M{async request(e){const r=we(e,e.webFetchExtra),a=me(e.params,e.shouldEncodeUrlParams),n=a?`${e.url}?${a}`:e.url,s=await fetch(n,r),o=s.headers.get("content-type")||"";let{responseType:i="text"}=s.ok?e:{};o.includes("application/json")&&(i="json");let f,l;switch(i){case"arraybuffer":case"blob":l=await s.blob(),f=await ge(l);break;case"json":f=await s.json();break;case"document":case"text":default:f=await s.text()}const k={};return s.headers.forEach((b,j)=>{k[j]=b}),{data:f,headers:k,status:s.status,url:s.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}N("CapacitorHttp",{web:()=>new ve});/*! Ionic Portals: https://ionic.io/portals - Commercial License */N("Portals",{web:()=>Promise.resolve().then(function(){return Pe}).then(t=>new t.PortalsWeb)});function D(){return O.getPlatform()==="android"?JSON.parse(AndroidInitialContext.initialContext()):window.portalInitialContext}class he extends M{async publishNative(e){}}const Pe=Object.freeze({__proto__:null,PortalsWeb:he});var A=(t=>(t.DEV="dev",t.SIT="sit",t.UAT="uat",t.PROD="prod",t.TEST="test",t))(A||{}),I=(t=>(t.EU="eu",t.ASIA="asia",t))(I||{});const q=t=>{var e,r;if(!(typeof window>"u")&&D&&(e=D())!=null&&e.value){const a=((r=D())==null?void 0:r.value)??null;a&&t&&t(a)}},be=(t,{asiaUatData:e,euSitData:r,euUatData:a})=>{const n=t.serverInfo.env,s=t.serverInfo.area;let o=null;return I.ASIA===s?A.UAT===n&&(o=e):I.EU===s&&(A.SIT===n?o=r:A.UAT===n&&(o=a)),o},ye=({cb:t})=>{setTimeout(()=>{q(e=>{if(!(e!=null&&e.params))return;const r=JSON.parse(e.params)??null;if(!r)return;const{params:a,routeName:n}=r;!a||!n||t&&t(r)})})},Ce=()=>{let t=!1;return q(e=>{t=!!(e!=null&&e.isNative)}),t},Le=t=>new Promise(async e=>{let r=be(t,{asiaUatData:await Promise.resolve().then(()=>require("./umd/fbb879ae.umd.cjs")),euSitData:await Promise.resolve().then(()=>require("./umd/5ca52608.umd.cjs")),euUatData:await Promise.resolve().then(()=>require("./umd/7c40191f.umd.cjs"))});e((r==null?void 0:r.default)??null)}),Ae=()=>{let t=null;return q(e=>{e?t={data_info:e.data_info?JSON.parse(e.data_info):null,data_store:e.data_store?JSON.parse(e.data_store):null,data_language:e.data_language?JSON.parse(e.data_language):null}:t=null}),t},$=class ${constructor(){_(this,"nativeApiConfig");this.nativeApiConfig=$.defaultNativeApiConfig}async getIsNativeHandle(){return await Ce()}async specifiedPageHandle({cb:e}){await ye({cb:e})}async nativeAppInfo(e){return e&&(this.nativeApiConfig=e),await this.getIsNativeHandle()?await Ae():await Le(this.nativeApiConfig)}};_($,"defaultNativeApiConfig",{serverInfo:{area:I.ASIA,env:A.UAT}});let W=$;class Oe extends W{constructor(){super()}async getIsNativeHandle(){return await super.getIsNativeHandle()}async specifiedPageHandle({cb:e}){return await super.specifiedPageHandle({cb:e})}async nativeAppInfo(e){return await super.nativeAppInfo(e)}}const ke=new Oe;module.exports=ke;
@@ -1,2 +1,3 @@
1
- export declare const getNativeAppInfoDev: (nativeApiConfig: any) => Promise<unknown>;
1
+ import type { NativeApiConfigType } from '../../../type';
2
+ export declare const getNativeAppInfoDev: (nativeApiConfig: NativeApiConfigType) => Promise<unknown>;
2
3
  export declare const getNativeAppInfo: () => any;
@@ -1,3 +1,4 @@
1
1
  import { PluginCallback } from '@capacitor/core';
2
+ import type { NativeApiConfigType } from '../../../type';
2
3
  export declare const getInitialContextHandle: (cb: PluginCallback) => void;
3
- export declare const getLocationMockDataHandle: (globalConfig: any, { asiaUatData, euSitData, euUatData }: any) => any;
4
+ export declare const getLocationMockDataHandle: (globalConfig: NativeApiConfigType, { asiaUatData, euSitData, euUatData }: any) => any;
@@ -1,17 +1,15 @@
1
- import { specifiedPageType } from './specifiedPage';
1
+ import type { NativeApiConfigType } from '../../type';
2
+ import type { SpecifiedPageType } from './specifiedPage';
2
3
  export interface InitialContextPluginsType {
3
4
  getIsNativeHandle: () => Promise<boolean>;
4
- specifiedPageHandle: ({ cb }: specifiedPageType) => void;
5
- nativeAppInfo: () => Promise<any>;
5
+ specifiedPageHandle: ({ cb }: SpecifiedPageType) => void;
6
+ nativeAppInfo: (nativeApiConfig: NativeApiConfigType) => Promise<any>;
6
7
  }
7
8
  export default class InitialContextPlugins implements InitialContextPluginsType {
8
- nativeApiConfig?: any;
9
- static nativeApiConfig?: any;
10
- constructor(nativeApiConfig?: any);
9
+ nativeApiConfig: NativeApiConfigType;
10
+ static defaultNativeApiConfig: NativeApiConfigType;
11
+ constructor();
11
12
  getIsNativeHandle(): Promise<boolean>;
12
- static getIsNativeHandle(): Promise<boolean>;
13
- specifiedPageHandle({ cb }: specifiedPageType): Promise<void>;
14
- static specifiedPageHandle({ cb }: specifiedPageType): Promise<void>;
15
- nativeAppInfo(): Promise<any>;
16
- static nativeAppInfo(): Promise<any>;
13
+ specifiedPageHandle({ cb }: SpecifiedPageType): Promise<void>;
14
+ nativeAppInfo(nativeApiConfig: NativeApiConfigType | undefined): Promise<any>;
17
15
  }
@@ -1,5 +1,5 @@
1
- export interface specifiedPageType {
1
+ export interface SpecifiedPageType {
2
2
  cb: (params?: any) => void;
3
3
  }
4
- declare const _default: ({ cb }: specifiedPageType) => void;
4
+ declare const _default: ({ cb }: SpecifiedPageType) => void;
5
5
  export default _default;
@@ -1,19 +1,3 @@
1
- export declare enum ENV {
2
- DEV = "development",
3
- PRO = "production"
4
- }
5
- export declare enum COMMAND {
6
- DEV = "serve",
7
- PRO = "build"
8
- }
9
- export declare enum APP_ENV {
10
- DEV = "location",
11
- NATIVE = "native"
12
- }
13
- export declare enum BUILD_ENV {
14
- DEV = "dev",
15
- PRO = "pro"
16
- }
17
1
  export declare enum SERVE_ENV {
18
2
  DEV = "dev",
19
3
  SIT = "sit",
@@ -21,49 +5,7 @@ export declare enum SERVE_ENV {
21
5
  PROD = "prod",
22
6
  TEST = "test"
23
7
  }
24
- export declare enum EQUIPMENT_ENV {
25
- IOS = "ios",
26
- IPAD = "iPad",
27
- ANDROID = "Android"
28
- }
29
- export declare enum TIP_STATUS_ENUM {
30
- SUCCESS = "success",
31
- WARNING = "warning"
32
- }
33
- export declare enum AIP_TYPE_ENUM {
34
- KONG = "kong",
35
- EVC = "evc",
36
- PICK_PACK = "pickPack"
37
- }
38
- export declare enum CACHE_ENUM {
39
- USER_ID = "userId",
40
- USERNAME = "userName",
41
- DEFAULT_BU = "defaultBu",
42
- DEFAULT_STORE = "defaultStore"
43
- }
44
8
  export declare enum SERVE_AREA {
45
9
  EU = "eu",
46
10
  ASIA = "asia"
47
11
  }
48
- export declare enum X_COUNT_KONG {
49
- X_ASW_API_KEY = "X-ASW-APIKey",
50
- X_ASW_BUSINESS_UNIT = "X-ASW-BusinessUnit",
51
- EVC_X_ASW_API_KEY = "EVC-X-ASW-API-KEY"
52
- }
53
- export declare enum MIN_APP_NAME {
54
- PORTAL = "osp-superapp-portal",
55
- EVENT_COUNT = "osp-superapp-event-count",
56
- SHELF_FULFILLMENT = "osp-superapp-shelf-fulfillment",
57
- PICK_PACK_ORDERS = "osp-superapp-pick-pack-orders",
58
- UNPACK_ORDERS = "osp-superapp-unpack-orders",
59
- COLLECT_ORDERS = "osp-superapp-collect-orders"
60
- }
61
- export declare enum POPUP_TYPE {
62
- SUCCESS = "success",
63
- SUCCESS_SELECT = "successSelect",
64
- ERROR = "error",
65
- ERROR_SELECT = "errorSelect",
66
- HELP = "help",
67
- SORT = "sort",
68
- SPECIALTY_SERVICES = "SpecialtyServices"
69
- }
@@ -1,4 +1,10 @@
1
- import type { NativeApiType } from '../init/type';
2
- import NativeMainApi from '../init/NativeApi';
3
- export default class NativeApi extends NativeMainApi implements NativeApiType {
1
+ import { NativeApiType } from './type';
2
+ import InitialContextPlugins from '../apiHandle/initialContext';
3
+ import type { NativeApiConfigType } from '../type';
4
+ import type { SpecifiedPageType } from '../apiHandle/initialContext/specifiedPage';
5
+ export default class NativeApi extends InitialContextPlugins implements NativeApiType {
6
+ constructor();
7
+ getIsNativeHandle(): Promise<boolean>;
8
+ specifiedPageHandle({ cb }: SpecifiedPageType): Promise<void>;
9
+ nativeAppInfo(nativeApiConfig: NativeApiConfigType | undefined): Promise<any>;
4
10
  }
@@ -1,9 +1,3 @@
1
1
  import type { InitialContextPluginsType } from '../apiHandle/initialContext';
2
- export interface NativeApiConfigType {
3
- serverInfo: {
4
- area: string;
5
- env: string;
6
- };
7
- }
8
2
  export interface NativeApiType extends InitialContextPluginsType {
9
3
  }
@@ -0,0 +1,9 @@
1
+ export interface NativeApiConfigType {
2
+ serverInfo: {
3
+ area: string;
4
+ env: string;
5
+ };
6
+ }
7
+ export type ContextType = {
8
+ params: string;
9
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "superapp-miniapp-invoke-native",
3
3
  "type": "module",
4
- "version": "1.0.31",
4
+ "version": "1.0.33",
5
5
  "description": "Superapp中,小程序调用Native 接口的封装,如OSP项目中,需要调用Native的相机扫描,镭射扫描,获取RBAC的数据等",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -1,3 +0,0 @@
1
- export type ContextType = {
2
- params: string;
3
- };
@@ -1,14 +0,0 @@
1
- import InitialContextPlugins from '../apiHandle/initialContext';
2
- import type { NativeApiType } from './type';
3
- import type { specifiedPageType } from '../apiHandle/initialContext/specifiedPage';
4
- export default class NativeMainApi extends InitialContextPlugins implements NativeApiType {
5
- nativeApiConfig?: any;
6
- static nativeApiConfig?: any;
7
- constructor(nativeApiConfig?: any);
8
- getIsNativeHandle(): Promise<boolean>;
9
- static getIsNativeHandle(): Promise<boolean>;
10
- specifiedPageHandle({ cb }: specifiedPageType): Promise<void>;
11
- static specifiedPageHandle({ cb }: specifiedPageType): Promise<void>;
12
- nativeAppInfo(): Promise<void>;
13
- static nativeAppInfo(): Promise<void>;
14
- }