superapp-miniapp-invoke-native 1.0.34 → 1.0.35

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.js CHANGED
@@ -1,20 +1,20 @@
1
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);
2
+ var oe = (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) => (oe(t, typeof e != "symbol" ? e + "" : e, r), r);
4
4
  /*! Capacitor: https://capacitorjs.com/ - MIT License */
5
- const oe = (t) => {
5
+ const ie = (t) => {
6
6
  const e = /* @__PURE__ */ new Map();
7
7
  e.set("web", { name: "web" });
8
8
  const r = t.CapacitorPlatforms || {
9
9
  currentPlatform: { name: "web" },
10
10
  platforms: e
11
- }, s = (a, o) => {
12
- r.platforms.set(a, o);
11
+ }, s = (a, i) => {
12
+ r.platforms.set(a, i);
13
13
  }, n = (a) => {
14
14
  r.platforms.has(a) && (r.currentPlatform = r.platforms.get(a));
15
15
  };
16
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 : {});
17
+ }, le = (t) => t.CapacitorPlatforms = ie(t), R = /* @__PURE__ */ le(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
18
18
  R.addPlatform;
19
19
  R.setPlatform;
20
20
  var L;
@@ -31,24 +31,24 @@ const ce = (t) => {
31
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
32
  }, de = (t) => {
33
33
  var e, r, s, n, a;
34
- const o = t.CapacitorCustomPlatform || null, i = t.Capacitor || {}, f = i.Plugins = i.Plugins || {}, l = t.CapacitorPlatforms, O = () => o !== null ? o.name : ce(t), b = ((e = l == null ? void 0 : l.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || O, j = () => b() !== "web", z = ((r = l == null ? void 0 : l.currentPlatform) === null || r === void 0 ? void 0 : r.isNativePlatform) || j, Q = (c) => {
34
+ const i = t.CapacitorCustomPlatform || null, o = t.Capacitor || {}, f = o.Plugins = o.Plugins || {}, l = t.CapacitorPlatforms, O = () => i !== null ? i.name : ce(t), b = ((e = l == null ? void 0 : l.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || O, j = () => b() !== "web", z = ((r = l == null ? void 0 : l.currentPlatform) === null || r === void 0 ? void 0 : r.isNativePlatform) || j, Q = (c) => {
35
35
  const d = H.get(c);
36
36
  return !!(d != null && d.platforms.has(b()) || B(c));
37
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((y) => y.name === c);
39
+ return (d = o.PluginHeaders) === null || d === void 0 ? void 0 : d.find((y) => y.name === c);
40
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
41
  const y = H.get(c);
42
42
  if (y)
43
43
  return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`), y.proxy;
44
44
  const P = b(), C = B(c);
45
45
  let w;
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) => {
46
+ const re = async () => (!w && P in d ? w = typeof d[P] == "function" ? w = await d[P]() : w = d[P] : i !== null && !w && "web" in d && (w = typeof d.web == "function" ? w = await d.web() : w = d.web), w), ne = (u, p) => {
47
47
  var m, v;
48
48
  if (C) {
49
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, x) => i.nativeCallback(c, p.toString(), g, x);
51
+ return h.rtype === "promise" ? (g) => o.nativePromise(c, p.toString(), g) : (g, x) => o.nativeCallback(c, p.toString(), g, x);
52
52
  if (u)
53
53
  return (m = u[p]) === null || m === void 0 ? void 0 : m.bind(u);
54
54
  } else {
@@ -110,9 +110,9 @@ const ce = (t) => {
110
110
  ])
111
111
  }), T;
112
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), k = /* @__PURE__ */ ue(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {}), N = k.registerPlugin;
115
- k.Plugins;
113
+ return o.convertFileSrc || (o.convertFileSrc = (c) => c), o.getPlatform = b, o.handleError = Z, o.isNativePlatform = z, o.isPluginAvailable = X, o.pluginMethodNoop = V, o.registerPlugin = te, o.Exception = E, o.DEBUG = !!o.DEBUG, o.isLoggingEnabled = !!o.isLoggingEnabled, o.platform = o.getPlatform(), o.isNative = o.isNativePlatform(), o;
114
+ }, ue = (t) => t.Capacitor = de(t), A = /* @__PURE__ */ ue(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {}), N = A.registerPlugin;
115
+ A.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);
@@ -121,12 +121,12 @@ class M {
121
121
  this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(r);
122
122
  const n = this.windowListeners[e];
123
123
  n && !n.registered && this.addWindowListener(n);
124
- const a = async () => this.removeListener(e, r), o = Promise.resolve({ remove: a });
125
- return Object.defineProperty(o, "remove", {
124
+ const a = async () => this.removeListener(e, r), i = Promise.resolve({ remove: a });
125
+ return Object.defineProperty(i, "remove", {
126
126
  value: async () => {
127
127
  console.warn("Using addListener() without 'await' is deprecated."), await a();
128
128
  }
129
- }), o;
129
+ }), i;
130
130
  }
131
131
  async removeAllListeners() {
132
132
  this.listeners = {};
@@ -152,10 +152,10 @@ class M {
152
152
  };
153
153
  }
154
154
  unimplemented(e = "not implemented") {
155
- return new k.Exception(e, L.Unimplemented);
155
+ return new A.Exception(e, L.Unimplemented);
156
156
  }
157
157
  unavailable(e = "not available") {
158
- return new k.Exception(e, L.Unavailable);
158
+ return new A.Exception(e, L.Unavailable);
159
159
  }
160
160
  async removeListener(e, r) {
161
161
  const s = this.listeners[e];
@@ -184,8 +184,8 @@ class fe extends M {
184
184
  }
185
185
  async setCookie(e) {
186
186
  try {
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};`;
187
+ const r = F(e.key), s = F(e.value), n = `; expires=${(e.expires || "").replace("expires=", "")}`, a = (e.path || "/").replace("path=", ""), i = e.url != null && e.url.length > 0 ? `domain=${e.url}` : "";
188
+ document.cookie = `${r}=${s || ""}${n}; path=${a}; ${i};`;
189
189
  } catch (r) {
190
190
  return Promise.reject(r);
191
191
  }
@@ -225,34 +225,34 @@ const pe = async (t) => new Promise((e, r) => {
225
225
  }, s.onerror = (n) => r(n), s.readAsDataURL(t);
226
226
  }), ge = (t = {}) => {
227
227
  const e = Object.keys(t);
228
- return Object.keys(t).map((n) => n.toLocaleLowerCase()).reduce((n, a, o) => (n[a] = t[e[o]], n), {});
228
+ return Object.keys(t).map((n) => n.toLocaleLowerCase()).reduce((n, a, i) => (n[a] = t[e[i]], n), {});
229
229
  }, me = (t, e = !0) => t ? Object.entries(t).reduce((s, n) => {
230
- const [a, o] = n;
231
- let i, f;
232
- return Array.isArray(o) ? (f = "", o.forEach((l) => {
233
- i = e ? encodeURIComponent(l) : l, f += `${a}=${i}&`;
234
- }), f.slice(0, -1)) : (i = e ? encodeURIComponent(o) : o, f = `${a}=${i}`), `${s}&${f}`;
230
+ const [a, i] = n;
231
+ let o, f;
232
+ return Array.isArray(i) ? (f = "", i.forEach((l) => {
233
+ o = e ? encodeURIComponent(l) : l, f += `${a}=${o}&`;
234
+ }), f.slice(0, -1)) : (o = e ? encodeURIComponent(i) : i, f = `${a}=${o}`), `${s}&${f}`;
235
235
  }, "").substr(1) : null, we = (t, e = {}) => {
236
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
238
  r.body = t.data;
239
239
  else if (n.includes("application/x-www-form-urlencoded")) {
240
240
  const a = new URLSearchParams();
241
- for (const [o, i] of Object.entries(t.data || {}))
242
- a.set(o, i);
241
+ for (const [i, o] of Object.entries(t.data || {}))
242
+ a.set(i, o);
243
243
  r.body = a.toString();
244
244
  } else if (n.includes("multipart/form-data")) {
245
245
  const a = new FormData();
246
246
  if (t.data instanceof FormData)
247
- t.data.forEach((i, f) => {
248
- a.append(f, i);
247
+ t.data.forEach((o, f) => {
248
+ a.append(f, o);
249
249
  });
250
250
  else
251
- for (const i of Object.keys(t.data))
252
- a.append(i, t.data[i]);
251
+ for (const o of Object.keys(t.data))
252
+ a.append(o, t.data[o]);
253
253
  r.body = a;
254
- const o = new Headers(r.headers);
255
- o.delete("content-type"), r.headers = o;
254
+ const i = new Headers(r.headers);
255
+ i.delete("content-type"), r.headers = i;
256
256
  } else
257
257
  (n.includes("application/json") || typeof t.data == "object") && (r.body = JSON.stringify(t.data));
258
258
  return r;
@@ -263,11 +263,11 @@ class ve extends M {
263
263
  * @param options Options to build the HTTP request
264
264
  */
265
265
  async request(e) {
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
- let { responseType: i = "text" } = a.ok ? e : {};
268
- o.includes("application/json") && (i = "json");
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), i = a.headers.get("content-type") || "";
267
+ let { responseType: o = "text" } = a.ok ? e : {};
268
+ i.includes("application/json") && (o = "json");
269
269
  let f, l;
270
- switch (i) {
270
+ switch (o) {
271
271
  case "arraybuffer":
272
272
  case "blob":
273
273
  l = await a.blob(), f = await pe(l);
@@ -336,7 +336,7 @@ N("Portals", {
336
336
  }).then((t) => new t.PortalsWeb())
337
337
  });
338
338
  function D() {
339
- return k.getPlatform() === "android" ? JSON.parse(AndroidInitialContext.initialContext()) : window.portalInitialContext;
339
+ return A.getPlatform() === "android" ? JSON.parse(AndroidInitialContext.initialContext()) : window.portalInitialContext;
340
340
  }
341
341
  class he extends M {
342
342
  // eslint-disable-next-line
@@ -347,7 +347,7 @@ const Pe = /* @__PURE__ */ Object.freeze({
347
347
  __proto__: null,
348
348
  PortalsWeb: he
349
349
  });
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 || {});
350
+ var k = /* @__PURE__ */ ((t) => (t.DEV = "dev", t.SIT = "sit", t.UAT = "uat", t.PROD = "prod", t.TEST = "test", t))(k || {}), I = /* @__PURE__ */ ((t) => (t.EU = "eu", t.ASIA = "asia", t))(I || {});
351
351
  const q = (t) => {
352
352
  var e, r;
353
353
  if (!(typeof window > "u") && D && (e = D()) != null && e.value) {
@@ -356,8 +356,8 @@ const q = (t) => {
356
356
  }
357
357
  }, be = (t, { asiaUatData: e, euSitData: r, euUatData: s }) => {
358
358
  const n = t.mockServerInfo.env, a = t.mockServerInfo.area;
359
- let o = null;
360
- return I.ASIA === a ? A.UAT === n && (o = e) : I.EU === a && (A.SIT === n ? o = r : A.UAT === n && (o = s)), o;
359
+ let i = null;
360
+ return I.ASIA === a ? k.UAT === n && (i = e) : I.EU === a && (k.SIT === n ? i = r : k.UAT === n && (i = s)), i;
361
361
  }, ye = ({ cb: t }) => {
362
362
  setTimeout(() => {
363
363
  q((e) => {
@@ -376,13 +376,13 @@ const q = (t) => {
376
376
  t = !!(e != null && e.isNative);
377
377
  }), t;
378
378
  }, Le = (t) => new Promise(async (e) => {
379
- let r = be(t, {
379
+ let r = null;
380
+ t.mockData ? r = t.mockData : r = be(t, {
380
381
  asiaUatData: await import("./chunk/1b5f5213.js"),
381
382
  euSitData: await import("./chunk/02340160.js"),
382
383
  euUatData: await import("./chunk/7615ea07.js")
383
- });
384
- e((r == null ? void 0 : r.default) ?? null);
385
- }), Ae = () => {
384
+ }), e((r == null ? void 0 : r.default) ?? null);
385
+ }), ke = () => {
386
386
  let t = null;
387
387
  return q((e) => {
388
388
  e ? t = {
@@ -406,17 +406,17 @@ const q = (t) => {
406
406
  }
407
407
  // nativeAppInfo
408
408
  async nativeAppInfo(e) {
409
- return e && (this.nativeApiConfig = e), await this.getIsNativeHandle() ? await Ae() : await Le(this.nativeApiConfig);
409
+ return e && (this.nativeApiConfig = e), await this.getIsNativeHandle() ? await ke() : await Le(this.nativeApiConfig);
410
410
  }
411
411
  };
412
412
  _($, "defaultNativeApiConfig", {
413
413
  mockServerInfo: {
414
414
  area: I.ASIA,
415
- env: A.UAT
415
+ env: k.UAT
416
416
  }
417
417
  });
418
418
  let W = $;
419
- class ke extends W {
419
+ class Ae extends W {
420
420
  constructor() {
421
421
  super();
422
422
  }
@@ -430,7 +430,7 @@ class ke extends W {
430
430
  return await super.nativeAppInfo(e);
431
431
  }
432
432
  }
433
- const xe = new ke();
433
+ const xe = new Ae();
434
434
  export {
435
435
  xe as default
436
436
  };
package/lib/main.umd.cjs CHANGED
@@ -1 +1 @@
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,O=()=>o!==null?o.name:ce(t),b=((e=l==null?void 0:l.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||O,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)}},S=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=S("addListener"),J=S("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},T=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 S(g)}}});return f[c]=T,H.set(c,{name:c,proxy:T,platforms:new Set([...Object.keys(d),...C?[P]:[]])}),T},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),k=ue(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),N=k.registerPlugin;k.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 k.Exception(e,L.Unimplemented)}unavailable(e="not available"){return new k.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 O={};return s.headers.forEach((b,j)=>{O[j]=b}),{data:f,headers:O,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 k.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.mockServerInfo.env,s=t.mockServerInfo.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/7c40191f.umd.cjs")),euUatData:await Promise.resolve().then(()=>require("./umd/5ca52608.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",{mockServerInfo:{area:I.ASIA,env:A.UAT}});let W=$;class ke 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 Oe=new ke;module.exports=Oe;
1
+ "use strict";var ae=Object.defineProperty;var oe=(t,e,r)=>e in t?ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var _=(t,e,r)=>(oe(t,typeof e!="symbol"?e+"":e,r),r);/*! Capacitor: https://capacitorjs.com/ - MIT License */const ie=t=>{const e=new Map;e.set("web",{name:"web"});const r=t.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:e},a=(s,i)=>{r.platforms.set(s,i)},n=s=>{r.platforms.has(s)&&(r.currentPlatform=r.platforms.get(s))};return r.addPlatform=a,r.setPlatform=n,r},le=t=>t.CapacitorPlatforms=ie(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 i=t.CapacitorCustomPlatform||null,o=t.Capacitor||{},f=o.Plugins=o.Plugins||{},l=t.CapacitorPlatforms,O=()=>i!==null?i.name:ce(t),b=((e=l==null?void 0:l.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||O,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=o.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]:i!==null&&!w&&"web"in d&&(w=typeof d.web=="function"?w=await d.web():w=d.web),w),ne=(u,g)=>{var p,v;if(C){const h=C==null?void 0:C.methods.find(m=>g===m.name);if(h)return h.rtype==="promise"?m=>o.nativePromise(c,g.toString(),m):(m,x)=>o.nativeCallback(c,g.toString(),m,x);if(u)return(p=u[g])===null||p===void 0?void 0:p.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)}},S=u=>{let g;const p=(...v)=>{const h=re().then(m=>{const x=ne(m,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 p.toString=()=>`${u.toString()}() { [capacitor code] }`,Object.defineProperty(p,"name",{value:u,writable:!1,configurable:!1}),p},G=S("addListener"),J=S("removeListener"),se=(u,g)=>{const p=G({eventName:u},g),v=async()=>{const m=await p;J({eventName:u,callbackId:m},g)},h=new Promise(m=>p.then(()=>m({remove:v})));return h.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await v()},h},T=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 S(g)}}});return f[c]=T,H.set(c,{name:c,proxy:T,platforms:new Set([...Object.keys(d),...C?[P]:[]])}),T},te=((s=l==null?void 0:l.currentPlatform)===null||s===void 0?void 0:s.registerPlugin)||ee;return o.convertFileSrc||(o.convertFileSrc=c=>c),o.getPlatform=b,o.handleError=Z,o.isNativePlatform=z,o.isPluginAvailable=X,o.pluginMethodNoop=V,o.registerPlugin=te,o.Exception=E,o.DEBUG=!!o.DEBUG,o.isLoggingEnabled=!!o.isLoggingEnabled,o.platform=o.getPlatform(),o.isNative=o.isNativePlatform(),o},ue=t=>t.Capacitor=de(t),A=ue(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),N=A.registerPlugin;A.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),i=Promise.resolve({remove:s});return Object.defineProperty(i,"remove",{value:async()=>{console.warn("Using addListener() without 'await' is deprecated."),await s()}}),i}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 A.Exception(e,L.Unimplemented)}unavailable(e="not available"){return new A.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=",""),i=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${r}=${a||""}${n}; path=${s}; ${i};`}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)}),me=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(n=>n.toLocaleLowerCase()).reduce((n,s,i)=>(n[s]=t[e[i]],n),{})},pe=(t,e=!0)=>t?Object.entries(t).reduce((a,n)=>{const[s,i]=n;let o,f;return Array.isArray(i)?(f="",i.forEach(l=>{o=e?encodeURIComponent(l):l,f+=`${s}=${o}&`}),f.slice(0,-1)):(o=e?encodeURIComponent(i):i,f=`${s}=${o}`),`${a}&${f}`},"").substr(1):null,we=(t,e={})=>{const r=Object.assign({method:t.method||"GET",headers:t.headers},e),n=me(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[i,o]of Object.entries(t.data||{}))s.set(i,o);r.body=s.toString()}else if(n.includes("multipart/form-data")){const s=new FormData;if(t.data instanceof FormData)t.data.forEach((o,f)=>{s.append(f,o)});else for(const o of Object.keys(t.data))s.append(o,t.data[o]);r.body=s;const i=new Headers(r.headers);i.delete("content-type"),r.headers=i}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=pe(e.params,e.shouldEncodeUrlParams),n=a?`${e.url}?${a}`:e.url,s=await fetch(n,r),i=s.headers.get("content-type")||"";let{responseType:o="text"}=s.ok?e:{};i.includes("application/json")&&(o="json");let f,l;switch(o){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 O={};return s.headers.forEach((b,j)=>{O[j]=b}),{data:f,headers:O,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 A.getPlatform()==="android"?JSON.parse(AndroidInitialContext.initialContext()):window.portalInitialContext}class he extends M{async publishNative(e){}}const Pe=Object.freeze({__proto__:null,PortalsWeb:he});var k=(t=>(t.DEV="dev",t.SIT="sit",t.UAT="uat",t.PROD="prod",t.TEST="test",t))(k||{}),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.mockServerInfo.env,s=t.mockServerInfo.area;let i=null;return I.ASIA===s?k.UAT===n&&(i=e):I.EU===s&&(k.SIT===n?i=r:k.UAT===n&&(i=a)),i},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=null;t.mockData?r=t.mockData: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)}),ke=()=>{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 ke():await Le(this.nativeApiConfig)}};_($,"defaultNativeApiConfig",{mockServerInfo:{area:I.ASIA,env:k.UAT}});let W=$;class Ae 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 Oe=new Ae;module.exports=Oe;
@@ -3,6 +3,19 @@ export interface NativeApiConfigType {
3
3
  area: string;
4
4
  env: string;
5
5
  };
6
+ mockData?: {
7
+ data_info: any;
8
+ data_store: {
9
+ name: string;
10
+ code: string;
11
+ };
12
+ data_language: {
13
+ [key: string]: string;
14
+ code: string;
15
+ id: string;
16
+ name: string;
17
+ };
18
+ };
6
19
  }
7
20
  export type ContextType = {
8
21
  params: string;
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.34",
4
+ "version": "1.0.35",
5
5
  "description": "Superapp中,小程序调用Native 接口的封装,如OSP项目中,需要调用Native的相机扫描,镭射扫描,获取RBAC的数据等",
6
6
  "scripts": {
7
7
  "dev": "vite",