superapp-miniapp-invoke-native 1.3.3 → 1.3.4

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
@@ -18,7 +18,7 @@ var a = (r, e, t) => new Promise((n, o) => {
18
18
  i((t = t.apply(r, e)).next());
19
19
  });
20
20
  /*! Capacitor: https://capacitorjs.com/ - MIT License */
21
- const Pe = (r) => r.CapacitorPlatforms = ((e) => {
21
+ const be = (r) => r.CapacitorPlatforms = ((e) => {
22
22
  const t = /* @__PURE__ */ new Map();
23
23
  t.set("web", { name: "web" });
24
24
  const n = e.CapacitorPlatforms || { currentPlatform: { name: "web" }, platforms: t };
@@ -27,7 +27,7 @@ const Pe = (r) => r.CapacitorPlatforms = ((e) => {
27
27
  }, n.setPlatform = (o) => {
28
28
  n.platforms.has(o) && (n.currentPlatform = n.platforms.get(o));
29
29
  }, n;
30
- })(r), ae = Pe(typeof globalThis != "undefined" ? globalThis : typeof self != "undefined" ? self : typeof window != "undefined" ? window : typeof global != "undefined" ? global : {});
30
+ })(r), ae = be(typeof globalThis != "undefined" ? globalThis : typeof self != "undefined" ? self : typeof window != "undefined" ? window : typeof global != "undefined" ? global : {});
31
31
  var E;
32
32
  ae.addPlatform, ae.setPlatform, function(r) {
33
33
  r.Unimplemented = "UNIMPLEMENTED", r.Unavailable = "UNAVAILABLE";
@@ -37,22 +37,22 @@ class X extends Error {
37
37
  super(e), this.message = e, this.code = t, this.data = n;
38
38
  }
39
39
  }
40
- const be = (r) => {
40
+ const Pe = (r) => {
41
41
  var e, t, n, o, s;
42
- const c = r.CapacitorCustomPlatform || null, i = r.Capacitor || {}, w = i.Plugins = i.Plugins || {}, m = r.CapacitorPlatforms, P = ((e = m == null ? void 0 : m.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || (() => c !== null ? c.name : ((l) => {
42
+ const c = r.CapacitorCustomPlatform || null, i = r.Capacitor || {}, w = i.Plugins = i.Plugins || {}, m = r.CapacitorPlatforms, b = ((e = m == null ? void 0 : m.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || (() => c !== null ? c.name : ((l) => {
43
43
  var d, h;
44
44
  return l != null && l.androidBridge ? "android" : !((h = (d = l == null ? void 0 : l.webkit) === null || d === void 0 ? void 0 : d.messageHandlers) === null || h === void 0) && h.bridge ? "ios" : "web";
45
- })(r)), f = ((t = m == null ? void 0 : m.currentPlatform) === null || t === void 0 ? void 0 : t.isNativePlatform) || (() => P() !== "web"), g = ((n = m == null ? void 0 : m.currentPlatform) === null || n === void 0 ? void 0 : n.isPluginAvailable) || ((l) => {
46
- const d = b.get(l);
47
- return !!(d != null && d.platforms.has(P())) || !!B(l);
45
+ })(r)), f = ((t = m == null ? void 0 : m.currentPlatform) === null || t === void 0 ? void 0 : t.isNativePlatform) || (() => b() !== "web"), g = ((n = m == null ? void 0 : m.currentPlatform) === null || n === void 0 ? void 0 : n.isPluginAvailable) || ((l) => {
46
+ const d = P.get(l);
47
+ return !!(d != null && d.platforms.has(b())) || !!B(l);
48
48
  }), B = ((o = m == null ? void 0 : m.currentPlatform) === null || o === void 0 ? void 0 : o.getPluginHeader) || ((l) => {
49
49
  var d;
50
50
  return (d = i.PluginHeaders) === null || d === void 0 ? void 0 : d.find((h) => h.name === l);
51
- }), b = /* @__PURE__ */ new Map(), L = ((s = m == null ? void 0 : m.currentPlatform) === null || s === void 0 ? void 0 : s.registerPlugin) || ((l, d = {}) => {
52
- const h = b.get(l);
51
+ }), P = /* @__PURE__ */ new Map(), L = ((s = m == null ? void 0 : m.currentPlatform) === null || s === void 0 ? void 0 : s.registerPlugin) || ((l, d = {}) => {
52
+ const h = P.get(l);
53
53
  if (h)
54
54
  return console.warn(`Capacitor plugin "${l}" already registered. Cannot register plugins twice.`), h.proxy;
55
- const S = P(), _ = B(l);
55
+ const S = b(), _ = B(l);
56
56
  let M;
57
57
  const V = (k) => {
58
58
  let A;
@@ -108,10 +108,10 @@ const be = (r) => {
108
108
  return V(A);
109
109
  }
110
110
  } });
111
- return w[l] = G, b.set(l, { name: l, proxy: G, platforms: /* @__PURE__ */ new Set([...Object.keys(d), ..._ ? [S] : []]) }), G;
111
+ return w[l] = G, P.set(l, { name: l, proxy: G, platforms: /* @__PURE__ */ new Set([...Object.keys(d), ..._ ? [S] : []]) }), G;
112
112
  });
113
- return i.convertFileSrc || (i.convertFileSrc = (l) => l), i.getPlatform = P, i.handleError = (l) => r.console.error(l), i.isNativePlatform = f, i.isPluginAvailable = g, i.pluginMethodNoop = (l, d, h) => Promise.reject(`${h} does not have an implementation of "${d}".`), i.registerPlugin = L, i.Exception = X, i.DEBUG = !!i.DEBUG, i.isLoggingEnabled = !!i.isLoggingEnabled, i.platform = i.getPlatform(), i.isNative = i.isNativePlatform(), i;
114
- }, Le = (r) => r.Capacitor = be(r), u = Le(typeof globalThis != "undefined" ? globalThis : typeof self != "undefined" ? self : typeof window != "undefined" ? window : typeof global != "undefined" ? global : {}), ee = u.registerPlugin;
113
+ return i.convertFileSrc || (i.convertFileSrc = (l) => l), i.getPlatform = b, i.handleError = (l) => r.console.error(l), i.isNativePlatform = f, i.isPluginAvailable = g, i.pluginMethodNoop = (l, d, h) => Promise.reject(`${h} does not have an implementation of "${d}".`), i.registerPlugin = L, i.Exception = X, i.DEBUG = !!i.DEBUG, i.isLoggingEnabled = !!i.isLoggingEnabled, i.platform = i.getPlatform(), i.isNative = i.isNativePlatform(), i;
114
+ }, Le = (r) => r.Capacitor = Pe(r), u = Le(typeof globalThis != "undefined" ? globalThis : typeof self != "undefined" ? self : typeof window != "undefined" ? window : typeof global != "undefined" ? global : {}), ee = u.registerPlugin;
115
115
  u.Plugins;
116
116
  class y {
117
117
  constructor(e) {
@@ -255,8 +255,8 @@ const Ce = (r, e = {}) => {
255
255
  class ke extends y {
256
256
  request(e) {
257
257
  return a(this, null, function* () {
258
- const t = Ce(e, e.webFetchExtra), n = ((f, g = !0) => f ? Object.entries(f).reduce((B, b) => {
259
- const [L, l] = b;
258
+ const t = Ce(e, e.webFetchExtra), n = ((f, g = !0) => f ? Object.entries(f).reduce((B, P) => {
259
+ const [L, l] = P;
260
260
  let d, h;
261
261
  return Array.isArray(l) ? (h = "", l.forEach((S) => {
262
262
  d = g ? encodeURIComponent(S) : S, h += `${L}=${d}&`;
@@ -268,11 +268,11 @@ class ke extends y {
268
268
  case "blob":
269
269
  w = yield s.blob(), i = yield ((f) => a(this, null, function* () {
270
270
  return new Promise((g, B) => {
271
- const b = new FileReader();
272
- b.onload = () => {
273
- const L = b.result;
271
+ const P = new FileReader();
272
+ P.onload = () => {
273
+ const L = P.result;
274
274
  g(L.indexOf(",") >= 0 ? L.split(",")[1] : L);
275
- }, b.onerror = (L) => B(L), b.readAsDataURL(f);
275
+ }, P.onerror = (L) => B(L), P.readAsDataURL(f);
276
276
  });
277
277
  }))(w);
278
278
  break;
@@ -282,10 +282,10 @@ class ke extends y {
282
282
  default:
283
283
  i = yield s.text();
284
284
  }
285
- const P = {};
285
+ const b = {};
286
286
  return s.headers.forEach((f, g) => {
287
- P[g] = f;
288
- }), { data: i, headers: P, status: s.status, url: s.url };
287
+ b[g] = f;
288
+ }), { data: i, headers: b, status: s.status, url: s.url };
289
289
  });
290
290
  }
291
291
  get(e) {
@@ -432,8 +432,8 @@ const Oe = (r) => {
432
432
  if ((e = p.showFABMenu) == null || e.call(p, { fabMenu: n }), !r || !((t = Object.keys(r)) != null && t.length))
433
433
  return;
434
434
  Object.keys(r).forEach((o) => {
435
- var s, c, i, w, m, P, f, g;
436
- n.push({ disable: (c = (s = r == null ? void 0 : r[o]) == null ? void 0 : s.disable) != null ? c : !1, icon: (w = (i = r == null ? void 0 : r[o]) == null ? void 0 : i.icon) != null ? w : "", id: (P = (m = r == null ? void 0 : r[o]) == null ? void 0 : m.id) != null ? P : "", name: (g = (f = r == null ? void 0 : r[o]) == null ? void 0 : f.title) != null ? g : "" });
435
+ var s, c, i, w, m, b, f, g;
436
+ n.push({ disable: (c = (s = r == null ? void 0 : r[o]) == null ? void 0 : s.disable) != null ? c : !1, icon: (w = (i = r == null ? void 0 : r[o]) == null ? void 0 : i.icon) != null ? w : "", id: (b = (m = r == null ? void 0 : r[o]) == null ? void 0 : m.id) != null ? b : "", name: (g = (f = r == null ? void 0 : r[o]) == null ? void 0 : f.title) != null ? g : "" });
437
437
  }), queueMicrotask(() => {
438
438
  var o;
439
439
  (o = p.showFABMenu) == null || o.call(p, { fabMenu: n });
@@ -848,7 +848,6 @@ class De {
848
848
  }
849
849
  trace(e) {
850
850
  return a(this, null, function* () {
851
- console.info("clickStreamTraceParams===", e);
852
851
  try {
853
852
  return yield ue.trace(e);
854
853
  } catch (t) {
package/lib/main.umd.cjs CHANGED
@@ -1 +1 @@
1
- (function(g,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):y((g=typeof globalThis!="undefined"?globalThis:g||self).main={})})(this,function(g){"use strict";var Ke=Object.defineProperty;var Ve=(g,y,v)=>y in g?Ke(g,y,{enumerable:!0,configurable:!0,writable:!0,value:v}):g[y]=v;var S=(g,y,v)=>(Ve(g,typeof y!="symbol"?y+"":y,v),v);var a=(g,y,v)=>new Promise((B,H)=>{var Y=P=>{try{l(v.next(P))}catch(w){H(w)}},Z=P=>{try{l(v.throw(P))}catch(w){H(w)}},l=P=>P.done?B(P.value):Promise.resolve(P.value).then(Y,Z);l((v=v.apply(g,y)).next())});/*! Capacitor: https://capacitorjs.com/ - MIT License */const y=r=>r.CapacitorPlatforms=(e=>{const t=new Map;t.set("web",{name:"web"});const n=e.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:t};return n.addPlatform=(o,s)=>{n.platforms.set(o,s)},n.setPlatform=o=>{n.platforms.has(o)&&(n.currentPlatform=n.platforms.get(o))},n})(r),v=y(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{});var B;v.addPlatform,v.setPlatform,function(r){r.Unimplemented="UNIMPLEMENTED",r.Unavailable="UNAVAILABLE"}(B||(B={}));class H extends Error{constructor(e,t,n){super(e),this.message=e,this.code=t,this.data=n}}const Y=r=>{var e,t,n,o,s;const c=r.CapacitorCustomPlatform||null,i=r.Capacitor||{},f=i.Plugins=i.Plugins||{},m=r.CapacitorPlatforms,C=((e=m==null?void 0:m.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||(()=>c!==null?c.name:(d=>{var u,p;return d!=null&&d.androidBridge?"android":!((p=(u=d==null?void 0:d.webkit)===null||u===void 0?void 0:u.messageHandlers)===null||p===void 0)&&p.bridge?"ios":"web"})(r)),b=((t=m==null?void 0:m.currentPlatform)===null||t===void 0?void 0:t.isNativePlatform)||(()=>C()!=="web"),L=((n=m==null?void 0:m.currentPlatform)===null||n===void 0?void 0:n.isPluginAvailable)||(d=>{const u=k.get(d);return!!(u!=null&&u.platforms.has(C()))||!!j(d)}),j=((o=m==null?void 0:m.currentPlatform)===null||o===void 0?void 0:o.getPluginHeader)||(d=>{var u;return(u=i.PluginHeaders)===null||u===void 0?void 0:u.find(p=>p.name===d)}),k=new Map,A=((s=m==null?void 0:m.currentPlatform)===null||s===void 0?void 0:s.registerPlugin)||((d,u={})=>{const p=k.get(d);if(p)return console.warn(`Capacitor plugin "${d}" already registered. Cannot register plugins twice.`),p.proxy;const M=C(),R=j(d);let x;const re=O=>{let U;const T=(...X)=>{const D=(()=>a(this,null,function*(){return!x&&M in u?x=x=typeof u[M]=="function"?yield u[M]():u[M]:c!==null&&!x&&"web"in u&&(x=x=typeof u.web=="function"?yield u.web():u.web),x}))().then(W=>{const ve=((N,q)=>{var oe,ae;if(!R){if(N)return(ae=N[q])===null||ae===void 0?void 0:ae.bind(N);throw new H(`"${d}" plugin is not implemented on ${M}`,B.Unimplemented)}{const Pe=R==null?void 0:R.methods.find(z=>q===z.name);if(Pe)return Pe.rtype==="promise"?z=>i.nativePromise(d,q.toString(),z):(z,ze)=>i.nativeCallback(d,q.toString(),z,ze);if(N)return(oe=N[q])===null||oe===void 0?void 0:oe.bind(N)}})(W,O);if(ve){const N=ve(...X);return U=N==null?void 0:N.remove,N}throw new H(`"${d}.${O}()" is not implemented on ${M}`,B.Unimplemented)});return O==="addListener"&&(D.remove=()=>a(this,null,function*(){return U()})),D};return T.toString=()=>`${O.toString()}() { [capacitor code] }`,Object.defineProperty(T,"name",{value:O,writable:!1,configurable:!1}),T},fe=re("addListener"),ge=re("removeListener"),qe=(O,U)=>{const T=fe({eventName:O},U),X=()=>a(this,null,function*(){const W=yield T;ge({eventName:O,callbackId:W},U)}),D=new Promise(W=>T.then(()=>W({remove:X})));return D.remove=()=>a(this,null,function*(){console.warn("Using addListener() without 'await' is deprecated."),yield X()}),D},ne=new Proxy({},{get(O,U){switch(U){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return R?qe:fe;case"removeListener":return ge;default:return re(U)}}});return f[d]=ne,k.set(d,{name:d,proxy:ne,platforms:new Set([...Object.keys(u),...R?[M]:[]])}),ne});return i.convertFileSrc||(i.convertFileSrc=d=>d),i.getPlatform=C,i.handleError=d=>r.console.error(d),i.isNativePlatform=b,i.isPluginAvailable=L,i.pluginMethodNoop=(d,u,p)=>Promise.reject(`${p} does not have an implementation of "${u}".`),i.registerPlugin=A,i.Exception=H,i.DEBUG=!!i.DEBUG,i.isLoggingEnabled=!!i.isLoggingEnabled,i.platform=i.getPlatform(),i.isNative=i.isNativePlatform(),i},Z=r=>r.Capacitor=Y(r),l=Z(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{}),P=l.registerPlugin;l.Plugins;class w{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,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n);const o=()=>a(this,null,function*(){return this.removeListener(e,t)}),s=Promise.resolve({remove:o});return Object.defineProperty(s,"remove",{value:()=>a(this,null,function*(){console.warn("Using addListener() without 'await' is deprecated."),yield o()})}),s}removeAllListeners(){return a(this,null,function*(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}})}notifyListeners(e,t){const n=this.listeners[e];n&&n.forEach(o=>o(t))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:n=>{this.notifyListeners(t,n)}}}unimplemented(e="not implemented"){return new l.Exception(e,B.Unimplemented)}unavailable(e="not available"){return new l.Exception(e,B.Unavailable)}removeListener(e,t){return a(this,null,function*(){const n=this.listeners[e];if(!n)return;const o=n.indexOf(t);this.listeners[e].splice(o,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 se=r=>encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),ie=r=>r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class be extends w{getCookies(){return a(this,null,function*(){const e=document.cookie,t={};return e.split(";").forEach(n=>{if(n.length<=0)return;let[o,s]=n.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");o=ie(o).trim(),s=ie(s).trim(),t[o]=s}),t})}setCookie(e){return a(this,null,function*(){try{const t=se(e.key),n=se(e.value),o=`; expires=${(e.expires||"").replace("expires=","")}`,s=(e.path||"/").replace("path=",""),c=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${n||""}${o}; path=${s}; ${c};`}catch(t){return Promise.reject(t)}})}deleteCookie(e){return a(this,null,function*(){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}})}clearCookies(){return a(this,null,function*(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}})}clearAllCookies(){return a(this,null,function*(){try{yield this.clearCookies()}catch(e){return Promise.reject(e)}})}}P("CapacitorCookies",{web:()=>new be});const Le=(r,e={})=>{const t=Object.assign({method:r.method||"GET",headers:r.headers},e),n=((o={})=>{const s=Object.keys(o);return Object.keys(o).map(c=>c.toLocaleLowerCase()).reduce((c,i,f)=>(c[i]=o[s[f]],c),{})})(r.headers)["content-type"]||"";if(typeof r.data=="string")t.body=r.data;else if(n.includes("application/x-www-form-urlencoded")){const o=new URLSearchParams;for(const[s,c]of Object.entries(r.data||{}))o.set(s,c);t.body=o.toString()}else if(n.includes("multipart/form-data")){const o=new FormData;if(r.data instanceof FormData)r.data.forEach((c,i)=>{o.append(i,c)});else for(const c of Object.keys(r.data))o.append(c,r.data[c]);t.body=o;const s=new Headers(t.headers);s.delete("content-type"),t.headers=s}else(n.includes("application/json")||typeof r.data=="object")&&(t.body=JSON.stringify(r.data));return t};class Se extends w{request(e){return a(this,null,function*(){const t=Le(e,e.webFetchExtra),n=((b,L=!0)=>b?Object.entries(b).reduce((j,k)=>{const[A,d]=k;let u,p;return Array.isArray(d)?(p="",d.forEach(M=>{u=L?encodeURIComponent(M):M,p+=`${A}=${u}&`}),p.slice(0,-1)):(u=L?encodeURIComponent(d):d,p=`${A}=${u}`),`${j}&${p}`},"").substr(1):null)(e.params,e.shouldEncodeUrlParams),o=n?`${e.url}?${n}`:e.url,s=yield fetch(o,t),c=s.headers.get("content-type")||"";let i,f,{responseType:m="text"}=s.ok?e:{};switch(c.includes("application/json")&&(m="json"),m){case"arraybuffer":case"blob":f=yield s.blob(),i=yield(b=>a(this,null,function*(){return new Promise((L,j)=>{const k=new FileReader;k.onload=()=>{const A=k.result;L(A.indexOf(",")>=0?A.split(",")[1]:A)},k.onerror=A=>j(A),k.readAsDataURL(b)})}))(f);break;case"json":i=yield s.json();break;default:i=yield s.text()}const C={};return s.headers.forEach((b,L)=>{C[L]=b}),{data:i,headers:C,status:s.status,url:s.url}})}get(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))})}post(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))})}put(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))})}patch(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))})}delete(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))})}}function ee(){return l.getPlatform()==="android"?JSON.parse(AndroidInitialContext.initialContext()):window.portalInitialContext}P("CapacitorHttp",{web:()=>new Se}),P("Portals",{web:()=>Promise.resolve().then(function(){return Ce}).then(r=>new r.PortalsWeb)});const Ce=Object.freeze({__proto__:null,PortalsWeb:class extends w{publishNative(r){return a(this,null,function*(){})}}}),K=r=>{var e,t,n;try{if(typeof window=="undefined")return;if(ee&&((e=ee())!=null&&e.value)){const o=(n=(t=ee())==null?void 0:t.value)!=null?n:null;if(!o)return void console.error("native initialContext is undefine");if(!r)return void console.error("initialContext call back is undefine");r(o)}}catch(o){throw console.error("getInitialContextHandle error",o),o}};class ke{isNative(){try{return(()=>{try{let e=!1;return K(t=>{e=!!(t!=null&&t.isNative)}),e}catch(e){throw console.error("isNative error",e),e}})()}catch(e){throw console.error("isNative error",e),e}}redirectPage(e){try{(({callBack:t})=>{K(n=>{var o;try{if(!(n!=null&&n.params))return void console.info("initial context native params is undefine");const s=(o=n==null?void 0:n.params)!=null?o:null;if(!s)return;if(!t)return void console.error("initial context call back is undefine");t(s)}catch(s){throw console.error("redirectPageHandle error",s),s}})})(e)}catch(t){throw console.error("redirectPage error",t),t}}getNativeInfo(e){try{return this.isNative()?(()=>{try{let t=null;return K(n=>{t=n!=null?n:null}),t}catch(t){throw console.error("getNativeInfoHandle error",t),t}})():(t=>{var n;return(n=t==null?void 0:t.mockData)!=null?n:null})(e)}catch(t){throw console.error("getNativeInfo error",t),t}}}const I=()=>{try{let r={};return typeof window!="undefined"&&(r=window),r}catch(r){throw console.error("isWinHandle error",r),r}},F="CommunicatePlugin",h=l.registerPlugin(F,{web:()=>Promise.resolve().then(()=>We).then(r=>new r.PluginsWeb)}),Ae=l.registerPlugin("CountAssistPlugin",{web:new class extends w{setCountAssistState(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("setCountAssistState error",e),e}})}}}),V=I();V.removeAddListenerFab=()=>null;const Me=r=>{var e,t;try{V.removeAddListenerFab&&V.removeAddListenerFab();const n=[];if((e=h.showFABMenu)==null||e.call(h,{fabMenu:n}),!r||!((t=Object.keys(r))!=null&&t.length))return;Object.keys(r).forEach(o=>{var s,c,i,f,m,C,b,L;n.push({disable:(c=(s=r==null?void 0:r[o])==null?void 0:s.disable)!=null?c:!1,icon:(f=(i=r==null?void 0:r[o])==null?void 0:i.icon)!=null?f:"",id:(C=(m=r==null?void 0:r[o])==null?void 0:m.id)!=null?C:"",name:(L=(b=r==null?void 0:r[o])==null?void 0:b.title)!=null?L:""})}),queueMicrotask(()=>{var o;(o=h.showFABMenu)==null||o.call(h,{fabMenu:n})}),setTimeout(()=>{(o=>a(this,null,function*(){o&&(V.removeAddListenerFab=yield(s=>a(this,null,function*(){try{if(l.addListener){const c=yield l.addListener(F,"nativeSendFab",i=>s&&s(i));return c!=null&&c.remove?c.remove:()=>null}}catch(c){throw console.error("addListenerFabHandle error",c),c}}))(o))}))(o=>{let s;o!=null&&o.disable||o!=null&&o.id&&(Object.keys(r).forEach(c=>{var i,f,m;(i=r==null?void 0:r[c])!=null&&i.id&&o.id===r[c].id&&(s=(m=(f=r[c])==null?void 0:f.fn)!=null?m:()=>null)}),typeof s=="function"&&s())})})}catch(n){throw console.error("fabBtnHandle error",n),n}},E=I();E.addListenerBackRemoveHandle=()=>null;const ce=(r=()=>null)=>a(this,null,function*(){try{E!=null&&E.addListenerBackRemoveHandle&&typeof E.addListenerBackRemoveHandle=="function"&&E.addListenerBackRemoveHandle(),E.addListenerBackRemoveHandle=yield(e=>a(this,null,function*(){try{if(l.addListener){const t=yield l.addListener(F,"nativeSendBack",n=>e&&e(n));return t!=null&&t.remove?t.remove:()=>null}}catch(t){throw console.error("addListenerBackHandle error",t),t}}))(r)}catch(e){throw console.error("initBackBtnFn error",e),e}}),G=I();G.addListenerHomeHandle=()=>null;const Ne=r=>{try{G.addListenerHomeHandle&&G.addListenerHomeHandle(),setTimeout(()=>{(e=>a(this,null,function*(){e&&(G.addListenerHomeHandle=yield(t=>a(this,null,function*(){try{if(l.addListener){const n=yield l.addListener(F,"nativeSendHome",o=>t&&t(o));return n!=null&&n.remove?n.remove:()=>null}}catch(n){throw console.error("addListenerHomeHandle error",n),n}}))(e))}))(r)})}catch(e){throw console.error("homeFn error",e),e}};class Oe{constructor(){this.homeBtnSwitch({isClick:!0})}homeBtnSwitch(e){return a(this,null,function*(){var t;try{return yield(t=h.homeIsClick)==null?void 0:t.call(h,e)}catch(n){throw console.error("homeBtnSwitch error",n),n}})}setBackBtn(e){try{(t=>{try{const{mounted:n,beforeUnmount:o,callBack:s}=t;n(()=>{ce(s)}),o(()=>{ce()})}catch(n){throw console.error("backBtnHandle error",n),n}})(e)}catch(t){throw console.error("setBackBtn error",t),t}}setHomeBtn(e){try{Ne(e)}catch(t){throw console.error("setHomeBtn error",t),t}}setFabBtn(e){try{Me(e)}catch(t){throw console.error("setFabBtn error",t),t}}openMiniApp(e){return a(this,null,function*(){try{return yield h.openMiniApp(e)}catch(t){throw console.error("openMiniApp error",t),t}})}showTitle(e){return a(this,null,function*(){try{return yield h.showTitle(e)}catch(t){throw console.error("showTitle error",t),t}})}showSubMask(e){return a(this,null,function*(){try{return yield h.showSubMask(e)}catch(t){throw console.error("showSubMask error",t),t}})}setMiniAppVersion(e){return a(this,null,function*(){try{return yield h.setMiniAppVersion(e)}catch(t){throw console.error("setMiniAppVersion error",t),t}})}showNativeLoading(){return a(this,null,function*(){try{return yield h.showDialog()}catch(e){throw console.error("showNativeLoading error",e),e}})}cancelNativeLoading(){return a(this,null,function*(){try{return yield h.cancelDialog()}catch(e){throw console.error("cancelNativeLoading error",e),e}})}getMiniAppKong(e){return a(this,null,function*(){try{return yield h.getMiniAppKong(e)}catch(t){throw console.error("getMiniAppKong error",t),t}})}}const Be=l.registerPlugin("CameraScanPlugin",{web:new class extends w{pickCameraScan(r){return a(this,null,function*(){return new Promise(e=>{e(r)})})}}});window.removeAddListenerCameraScan=()=>null;class Ue{pickCameraScan(e){return a(this,null,function*(){try{return yield Be.pickCameraScan(e)}catch(t){throw console.error("pickCameraScan error",t),t}})}}const Ee=l.registerPlugin("CameraScanMultiplePlugin",{web:new class extends w{pickCameraScanMultiple(){return a(this,null,function*(){})}}});class _e{pickCameraScanMultiple(e){return a(this,null,function*(){try{return yield Ee.pickCameraScanMultiple(e)}catch(t){throw console.error("pickCameraScanMultiple error",t),t}})}}const xe=l.registerPlugin("CameraScanMultipleNoCountPlugin",{web:new class extends w{pickCameraScanMultipleNoCount(){return a(this,null,function*(){})}}});class He{pickCameraScanMultipleNoCount(e){return a(this,null,function*(){try{return yield xe.pickCameraScanMultipleNoCount(e)}catch(t){throw console.error("pickCameraScanMultipleNoCount error",t),t}})}}const Ie=l.registerPlugin("CameraScanSingleOrDualPlugin",{web:new class extends w{pickCameraScanSingleOrDual(){return a(this,null,function*(){})}}});class je{pickCameraScanSingleOrDual(e){return a(this,null,function*(){try{return yield Ie.pickCameraScanSingleOrDual(e)}catch(t){throw console.error("pickCameraScanSingleOrDual error",t),t}})}}const le="LaserScanPlugin",te=l.registerPlugin(le,{web:new class extends w{pickLaserScan(){return a(this,null,function*(){})}unPickLaserScan(){return a(this,null,function*(){})}setLaserState(){return a(this,null,function*(){})}}}),J=I();J.removeAddListenerLaserScan=()=>null;const de=(r=()=>null)=>{try{J.removeAddListenerLaserScan&&J.removeAddListenerLaserScan();const e=t=>a(this,null,function*(){t&&(J.removeAddListenerLaserScan=yield(n=>a(this,null,function*(){try{if(l.addListener){const o=yield l.addListener(le,"nativeSendLaser",s=>n&&n(s));return o!=null&&o.remove?o.remove:()=>null}}catch(o){throw console.error("addListenerLaserHandle error",o),o}}))(t))});setTimeout(()=>{e(r)})}catch(e){throw console.error("laserScanFn error",e),e}};class Te{constructor(){this.pickLaserScan()}pickLaserScan(){return a(this,null,function*(){try{return yield te.pickLaserScan({isContinue:!1})}catch(e){throw console.error("pickLaserScan error",e),e}})}unPickLaserScan(){return a(this,null,function*(){try{return yield te.unPickLaserScan()}catch(e){throw console.error("unPickLaserScan error",e),e}})}setLaserState(e){try{te.setLaserState(e)}catch(t){throw console.error("setLaserState error",t),t}}setLaserScan(e){(t=>{try{const{mounted:n,beforeUnmount:o,callBack:s}=t;n(()=>{de(s)}),o(()=>{de()})}catch(n){throw console.error("laserScanApiParams error",n),n}})(e)}}const _=I();_.addListenerCountAssistRemoveHandle=()=>null;const ue=(r=()=>null)=>a(this,null,function*(){try{_!=null&&_.addListenerCountAssistRemoveHandle&&typeof _.addListenerCountAssistRemoveHandle=="function"&&_.addListenerCountAssistRemoveHandle(),_.addListenerCountAssistRemoveHandle=yield(e=>a(this,null,function*(){try{if(l.addListener){const t=yield l.addListener(F,"nativeSendCountAssist",n=>e&&e(n));return t!=null&&t.remove?t.remove:()=>null}}catch(t){throw console.error("addListenerCountAssistHandle error",t),t}}))(r)}catch(e){throw console.error("initCountAssistFn error",e),e}});class Fe{setCountAssistState(e){return a(this,null,function*(){return yield Ae.setCountAssistState(e)})}getCountAssistState(e){return(t=>{try{let n=t!=null?t:!1;return K(o=>{n=!!(o!=null&&o.countAssistState)}),n}catch(n){throw console.error("getCountAssistStateHandle error",n),n}})(e)}setCountAssistBtn(e){(t=>{try{const{mounted:n,beforeUnmount:o,callBack:s}=t;n(()=>{ue(s)}),o(()=>{ue()})}catch(n){throw console.error("setCountAssistBtnHandle error",n),n}})(e)}}const me=l.registerPlugin("ClickStreamPlugin",{web:new class extends w{init(){return a(this,null,function*(){return new Promise(r=>{r(null)})})}trace(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("clickStreamTraceParams error",e),e}})}}});class $e{constructor(){this.init()}init(){return a(this,null,function*(){try{return yield me.init()}catch(e){throw console.error("clickStreamPlugin, init error",e),e}})}trace(e){return a(this,null,function*(){console.info("clickStreamTraceParams===",e);try{return yield me.trace(e)}catch(t){throw console.error("clickStreamPlugin, trace error",t),t}})}}const we="MiniAppLifecyclePlugin";var $=(r=>(r.MINI_APP_BEFORE_UNMOUNT_PERMISSION="mini_app_before_unmount_permission",r.MINI_APP_BEFORE_UNMOUNT_COMPLETION="mini_app_before_unmount_completion",r))($||{});const he=l.registerPlugin(we,{web:new class extends w{setNativeUsagePermission(){return a(this,null,function*(){})}authorizeWebCallback(){return a(this,null,function*(){})}}}),Q=I();Q.removeAddListenerLifecycleMiniAppBeforeUnmount=()=>null;const pe=(r=()=>null)=>{try{Q.removeAddListenerLifecycleMiniAppBeforeUnmount&&Q.removeAddListenerLifecycleMiniAppBeforeUnmount();const e=t=>a(this,null,function*(){t&&(Q.removeAddListenerLifecycleMiniAppBeforeUnmount=yield(n=>a(this,null,function*(){try{if(l.addListener){const o=yield l.addListener(we,"miniAppBeforeUnmount",s=>n&&n(s));return o!=null&&o.remove?o.remove:()=>null}}catch(o){throw console.error("miniAppBeforeUnmountHandle error",o),o}}))(t))});setTimeout(()=>a(this,null,function*(){yield e(r)}))}catch(e){throw console.error("laserScanFn error",e),e}};class Re{constructor(){}setNativeUsagePermission(e){return a(this,null,function*(){try{return yield he.setNativeUsagePermission(e)}catch(t){throw console.error("lifecyclePlugin.setNativeUsagePermission error",t),t}})}authorizeWebCallback(e){return a(this,null,function*(){try{return yield he.authorizeWebCallback(e)}catch(t){throw console.error("lifecyclePlugin.authorizeWebCallback error",t),t}})}miniAppBeforeUnmount(e){this.setNativeUsagePermission({action:$.MINI_APP_BEFORE_UNMOUNT_PERMISSION,value:!0}),((t,n)=>{try{const{mounted:o,beforeUnmount:s,callBack:c}=t;o(()=>{pe(i=>a(this,null,function*(){var f;if(c&&c instanceof Function)try{(f=c(i))==null||f.then(()=>a(this,null,function*(){yield n.setNativeUsagePermission({action:$.MINI_APP_BEFORE_UNMOUNT_PERMISSION,value:!1}),yield n.authorizeWebCallback({action:$.MINI_APP_BEFORE_UNMOUNT_COMPLETION})}))}catch(m){console.error("miniAppBeforeUnmount error callBack is not a function or promise")}else console.error("miniAppBeforeUnmount error callBack is not a function or promise")}))}),s(()=>a(this,null,function*(){pe(),n.setNativeUsagePermission({action:$.MINI_APP_BEFORE_UNMOUNT_PERMISSION,value:!1})}))}catch(o){throw console.error("miniAppBeforeUnmount error",o),o}})(e,this)}}class ye{constructor(){S(this,"initialContextPlugins",new ke);S(this,"communicatePlugins",new Oe);S(this,"cameraScanPlugins",new Ue);S(this,"cameraScanMultiplePlugins",new _e);S(this,"cameraScanMultipleNoCountPlugins",new He);S(this,"cameraScanSingleOrDualPlugins",new je);S(this,"laserScanPlugins",new Te);S(this,"countAssistPlugins",new Fe);S(this,"clickStreamPlugins",new $e);S(this,"lifecyclePlugins",new Re)}}const De=new ye,We=Object.freeze(Object.defineProperty({__proto__:null,PluginsWeb:class extends w{homeIsClick(){return a(this,null,function*(){})}openMiniApp(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("openMiniApp error",e),e}})}showTitle(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("showTitle error",e),e}})}showFABMenu(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("showFABMenu error",e),e}})}showSubMask(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("showSubMask error",e),e}})}setMiniAppVersion(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("setMiniAppVersion error",e),e}})}showDialog(){return a(this,null,function*(){})}cancelDialog(){return a(this,null,function*(){})}getMiniAppKong(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("getMiniAppKong error",e),e}})}}},Symbol.toStringTag,{value:"Module"}));g.NativeApi=ye,g.default=De,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(g,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):y((g=typeof globalThis!="undefined"?globalThis:g||self).main={})})(this,function(g){"use strict";var Ke=Object.defineProperty;var Ve=(g,y,v)=>y in g?Ke(g,y,{enumerable:!0,configurable:!0,writable:!0,value:v}):g[y]=v;var S=(g,y,v)=>(Ve(g,typeof y!="symbol"?y+"":y,v),v);var a=(g,y,v)=>new Promise((B,H)=>{var Y=P=>{try{l(v.next(P))}catch(w){H(w)}},Z=P=>{try{l(v.throw(P))}catch(w){H(w)}},l=P=>P.done?B(P.value):Promise.resolve(P.value).then(Y,Z);l((v=v.apply(g,y)).next())});/*! Capacitor: https://capacitorjs.com/ - MIT License */const y=r=>r.CapacitorPlatforms=(e=>{const t=new Map;t.set("web",{name:"web"});const n=e.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:t};return n.addPlatform=(o,s)=>{n.platforms.set(o,s)},n.setPlatform=o=>{n.platforms.has(o)&&(n.currentPlatform=n.platforms.get(o))},n})(r),v=y(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{});var B;v.addPlatform,v.setPlatform,function(r){r.Unimplemented="UNIMPLEMENTED",r.Unavailable="UNAVAILABLE"}(B||(B={}));class H extends Error{constructor(e,t,n){super(e),this.message=e,this.code=t,this.data=n}}const Y=r=>{var e,t,n,o,s;const c=r.CapacitorCustomPlatform||null,i=r.Capacitor||{},f=i.Plugins=i.Plugins||{},m=r.CapacitorPlatforms,C=((e=m==null?void 0:m.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||(()=>c!==null?c.name:(d=>{var u,p;return d!=null&&d.androidBridge?"android":!((p=(u=d==null?void 0:d.webkit)===null||u===void 0?void 0:u.messageHandlers)===null||p===void 0)&&p.bridge?"ios":"web"})(r)),b=((t=m==null?void 0:m.currentPlatform)===null||t===void 0?void 0:t.isNativePlatform)||(()=>C()!=="web"),L=((n=m==null?void 0:m.currentPlatform)===null||n===void 0?void 0:n.isPluginAvailable)||(d=>{const u=k.get(d);return!!(u!=null&&u.platforms.has(C()))||!!j(d)}),j=((o=m==null?void 0:m.currentPlatform)===null||o===void 0?void 0:o.getPluginHeader)||(d=>{var u;return(u=i.PluginHeaders)===null||u===void 0?void 0:u.find(p=>p.name===d)}),k=new Map,A=((s=m==null?void 0:m.currentPlatform)===null||s===void 0?void 0:s.registerPlugin)||((d,u={})=>{const p=k.get(d);if(p)return console.warn(`Capacitor plugin "${d}" already registered. Cannot register plugins twice.`),p.proxy;const M=C(),R=j(d);let x;const re=O=>{let U;const T=(...X)=>{const D=(()=>a(this,null,function*(){return!x&&M in u?x=x=typeof u[M]=="function"?yield u[M]():u[M]:c!==null&&!x&&"web"in u&&(x=x=typeof u.web=="function"?yield u.web():u.web),x}))().then(W=>{const ve=((N,q)=>{var oe,ae;if(!R){if(N)return(ae=N[q])===null||ae===void 0?void 0:ae.bind(N);throw new H(`"${d}" plugin is not implemented on ${M}`,B.Unimplemented)}{const Pe=R==null?void 0:R.methods.find(z=>q===z.name);if(Pe)return Pe.rtype==="promise"?z=>i.nativePromise(d,q.toString(),z):(z,ze)=>i.nativeCallback(d,q.toString(),z,ze);if(N)return(oe=N[q])===null||oe===void 0?void 0:oe.bind(N)}})(W,O);if(ve){const N=ve(...X);return U=N==null?void 0:N.remove,N}throw new H(`"${d}.${O}()" is not implemented on ${M}`,B.Unimplemented)});return O==="addListener"&&(D.remove=()=>a(this,null,function*(){return U()})),D};return T.toString=()=>`${O.toString()}() { [capacitor code] }`,Object.defineProperty(T,"name",{value:O,writable:!1,configurable:!1}),T},fe=re("addListener"),ge=re("removeListener"),qe=(O,U)=>{const T=fe({eventName:O},U),X=()=>a(this,null,function*(){const W=yield T;ge({eventName:O,callbackId:W},U)}),D=new Promise(W=>T.then(()=>W({remove:X})));return D.remove=()=>a(this,null,function*(){console.warn("Using addListener() without 'await' is deprecated."),yield X()}),D},ne=new Proxy({},{get(O,U){switch(U){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return R?qe:fe;case"removeListener":return ge;default:return re(U)}}});return f[d]=ne,k.set(d,{name:d,proxy:ne,platforms:new Set([...Object.keys(u),...R?[M]:[]])}),ne});return i.convertFileSrc||(i.convertFileSrc=d=>d),i.getPlatform=C,i.handleError=d=>r.console.error(d),i.isNativePlatform=b,i.isPluginAvailable=L,i.pluginMethodNoop=(d,u,p)=>Promise.reject(`${p} does not have an implementation of "${u}".`),i.registerPlugin=A,i.Exception=H,i.DEBUG=!!i.DEBUG,i.isLoggingEnabled=!!i.isLoggingEnabled,i.platform=i.getPlatform(),i.isNative=i.isNativePlatform(),i},Z=r=>r.Capacitor=Y(r),l=Z(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{}),P=l.registerPlugin;l.Plugins;class w{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,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n);const o=()=>a(this,null,function*(){return this.removeListener(e,t)}),s=Promise.resolve({remove:o});return Object.defineProperty(s,"remove",{value:()=>a(this,null,function*(){console.warn("Using addListener() without 'await' is deprecated."),yield o()})}),s}removeAllListeners(){return a(this,null,function*(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}})}notifyListeners(e,t){const n=this.listeners[e];n&&n.forEach(o=>o(t))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:n=>{this.notifyListeners(t,n)}}}unimplemented(e="not implemented"){return new l.Exception(e,B.Unimplemented)}unavailable(e="not available"){return new l.Exception(e,B.Unavailable)}removeListener(e,t){return a(this,null,function*(){const n=this.listeners[e];if(!n)return;const o=n.indexOf(t);this.listeners[e].splice(o,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 se=r=>encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),ie=r=>r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class be extends w{getCookies(){return a(this,null,function*(){const e=document.cookie,t={};return e.split(";").forEach(n=>{if(n.length<=0)return;let[o,s]=n.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");o=ie(o).trim(),s=ie(s).trim(),t[o]=s}),t})}setCookie(e){return a(this,null,function*(){try{const t=se(e.key),n=se(e.value),o=`; expires=${(e.expires||"").replace("expires=","")}`,s=(e.path||"/").replace("path=",""),c=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${n||""}${o}; path=${s}; ${c};`}catch(t){return Promise.reject(t)}})}deleteCookie(e){return a(this,null,function*(){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}})}clearCookies(){return a(this,null,function*(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}})}clearAllCookies(){return a(this,null,function*(){try{yield this.clearCookies()}catch(e){return Promise.reject(e)}})}}P("CapacitorCookies",{web:()=>new be});const Le=(r,e={})=>{const t=Object.assign({method:r.method||"GET",headers:r.headers},e),n=((o={})=>{const s=Object.keys(o);return Object.keys(o).map(c=>c.toLocaleLowerCase()).reduce((c,i,f)=>(c[i]=o[s[f]],c),{})})(r.headers)["content-type"]||"";if(typeof r.data=="string")t.body=r.data;else if(n.includes("application/x-www-form-urlencoded")){const o=new URLSearchParams;for(const[s,c]of Object.entries(r.data||{}))o.set(s,c);t.body=o.toString()}else if(n.includes("multipart/form-data")){const o=new FormData;if(r.data instanceof FormData)r.data.forEach((c,i)=>{o.append(i,c)});else for(const c of Object.keys(r.data))o.append(c,r.data[c]);t.body=o;const s=new Headers(t.headers);s.delete("content-type"),t.headers=s}else(n.includes("application/json")||typeof r.data=="object")&&(t.body=JSON.stringify(r.data));return t};class Se extends w{request(e){return a(this,null,function*(){const t=Le(e,e.webFetchExtra),n=((b,L=!0)=>b?Object.entries(b).reduce((j,k)=>{const[A,d]=k;let u,p;return Array.isArray(d)?(p="",d.forEach(M=>{u=L?encodeURIComponent(M):M,p+=`${A}=${u}&`}),p.slice(0,-1)):(u=L?encodeURIComponent(d):d,p=`${A}=${u}`),`${j}&${p}`},"").substr(1):null)(e.params,e.shouldEncodeUrlParams),o=n?`${e.url}?${n}`:e.url,s=yield fetch(o,t),c=s.headers.get("content-type")||"";let i,f,{responseType:m="text"}=s.ok?e:{};switch(c.includes("application/json")&&(m="json"),m){case"arraybuffer":case"blob":f=yield s.blob(),i=yield(b=>a(this,null,function*(){return new Promise((L,j)=>{const k=new FileReader;k.onload=()=>{const A=k.result;L(A.indexOf(",")>=0?A.split(",")[1]:A)},k.onerror=A=>j(A),k.readAsDataURL(b)})}))(f);break;case"json":i=yield s.json();break;default:i=yield s.text()}const C={};return s.headers.forEach((b,L)=>{C[L]=b}),{data:i,headers:C,status:s.status,url:s.url}})}get(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))})}post(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))})}put(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))})}patch(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))})}delete(e){return a(this,null,function*(){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))})}}function ee(){return l.getPlatform()==="android"?JSON.parse(AndroidInitialContext.initialContext()):window.portalInitialContext}P("CapacitorHttp",{web:()=>new Se}),P("Portals",{web:()=>Promise.resolve().then(function(){return Ce}).then(r=>new r.PortalsWeb)});const Ce=Object.freeze({__proto__:null,PortalsWeb:class extends w{publishNative(r){return a(this,null,function*(){})}}}),K=r=>{var e,t,n;try{if(typeof window=="undefined")return;if(ee&&((e=ee())!=null&&e.value)){const o=(n=(t=ee())==null?void 0:t.value)!=null?n:null;if(!o)return void console.error("native initialContext is undefine");if(!r)return void console.error("initialContext call back is undefine");r(o)}}catch(o){throw console.error("getInitialContextHandle error",o),o}};class ke{isNative(){try{return(()=>{try{let e=!1;return K(t=>{e=!!(t!=null&&t.isNative)}),e}catch(e){throw console.error("isNative error",e),e}})()}catch(e){throw console.error("isNative error",e),e}}redirectPage(e){try{(({callBack:t})=>{K(n=>{var o;try{if(!(n!=null&&n.params))return void console.info("initial context native params is undefine");const s=(o=n==null?void 0:n.params)!=null?o:null;if(!s)return;if(!t)return void console.error("initial context call back is undefine");t(s)}catch(s){throw console.error("redirectPageHandle error",s),s}})})(e)}catch(t){throw console.error("redirectPage error",t),t}}getNativeInfo(e){try{return this.isNative()?(()=>{try{let t=null;return K(n=>{t=n!=null?n:null}),t}catch(t){throw console.error("getNativeInfoHandle error",t),t}})():(t=>{var n;return(n=t==null?void 0:t.mockData)!=null?n:null})(e)}catch(t){throw console.error("getNativeInfo error",t),t}}}const I=()=>{try{let r={};return typeof window!="undefined"&&(r=window),r}catch(r){throw console.error("isWinHandle error",r),r}},F="CommunicatePlugin",h=l.registerPlugin(F,{web:()=>Promise.resolve().then(()=>We).then(r=>new r.PluginsWeb)}),Ae=l.registerPlugin("CountAssistPlugin",{web:new class extends w{setCountAssistState(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("setCountAssistState error",e),e}})}}}),V=I();V.removeAddListenerFab=()=>null;const Me=r=>{var e,t;try{V.removeAddListenerFab&&V.removeAddListenerFab();const n=[];if((e=h.showFABMenu)==null||e.call(h,{fabMenu:n}),!r||!((t=Object.keys(r))!=null&&t.length))return;Object.keys(r).forEach(o=>{var s,c,i,f,m,C,b,L;n.push({disable:(c=(s=r==null?void 0:r[o])==null?void 0:s.disable)!=null?c:!1,icon:(f=(i=r==null?void 0:r[o])==null?void 0:i.icon)!=null?f:"",id:(C=(m=r==null?void 0:r[o])==null?void 0:m.id)!=null?C:"",name:(L=(b=r==null?void 0:r[o])==null?void 0:b.title)!=null?L:""})}),queueMicrotask(()=>{var o;(o=h.showFABMenu)==null||o.call(h,{fabMenu:n})}),setTimeout(()=>{(o=>a(this,null,function*(){o&&(V.removeAddListenerFab=yield(s=>a(this,null,function*(){try{if(l.addListener){const c=yield l.addListener(F,"nativeSendFab",i=>s&&s(i));return c!=null&&c.remove?c.remove:()=>null}}catch(c){throw console.error("addListenerFabHandle error",c),c}}))(o))}))(o=>{let s;o!=null&&o.disable||o!=null&&o.id&&(Object.keys(r).forEach(c=>{var i,f,m;(i=r==null?void 0:r[c])!=null&&i.id&&o.id===r[c].id&&(s=(m=(f=r[c])==null?void 0:f.fn)!=null?m:()=>null)}),typeof s=="function"&&s())})})}catch(n){throw console.error("fabBtnHandle error",n),n}},E=I();E.addListenerBackRemoveHandle=()=>null;const ce=(r=()=>null)=>a(this,null,function*(){try{E!=null&&E.addListenerBackRemoveHandle&&typeof E.addListenerBackRemoveHandle=="function"&&E.addListenerBackRemoveHandle(),E.addListenerBackRemoveHandle=yield(e=>a(this,null,function*(){try{if(l.addListener){const t=yield l.addListener(F,"nativeSendBack",n=>e&&e(n));return t!=null&&t.remove?t.remove:()=>null}}catch(t){throw console.error("addListenerBackHandle error",t),t}}))(r)}catch(e){throw console.error("initBackBtnFn error",e),e}}),G=I();G.addListenerHomeHandle=()=>null;const Ne=r=>{try{G.addListenerHomeHandle&&G.addListenerHomeHandle(),setTimeout(()=>{(e=>a(this,null,function*(){e&&(G.addListenerHomeHandle=yield(t=>a(this,null,function*(){try{if(l.addListener){const n=yield l.addListener(F,"nativeSendHome",o=>t&&t(o));return n!=null&&n.remove?n.remove:()=>null}}catch(n){throw console.error("addListenerHomeHandle error",n),n}}))(e))}))(r)})}catch(e){throw console.error("homeFn error",e),e}};class Oe{constructor(){this.homeBtnSwitch({isClick:!0})}homeBtnSwitch(e){return a(this,null,function*(){var t;try{return yield(t=h.homeIsClick)==null?void 0:t.call(h,e)}catch(n){throw console.error("homeBtnSwitch error",n),n}})}setBackBtn(e){try{(t=>{try{const{mounted:n,beforeUnmount:o,callBack:s}=t;n(()=>{ce(s)}),o(()=>{ce()})}catch(n){throw console.error("backBtnHandle error",n),n}})(e)}catch(t){throw console.error("setBackBtn error",t),t}}setHomeBtn(e){try{Ne(e)}catch(t){throw console.error("setHomeBtn error",t),t}}setFabBtn(e){try{Me(e)}catch(t){throw console.error("setFabBtn error",t),t}}openMiniApp(e){return a(this,null,function*(){try{return yield h.openMiniApp(e)}catch(t){throw console.error("openMiniApp error",t),t}})}showTitle(e){return a(this,null,function*(){try{return yield h.showTitle(e)}catch(t){throw console.error("showTitle error",t),t}})}showSubMask(e){return a(this,null,function*(){try{return yield h.showSubMask(e)}catch(t){throw console.error("showSubMask error",t),t}})}setMiniAppVersion(e){return a(this,null,function*(){try{return yield h.setMiniAppVersion(e)}catch(t){throw console.error("setMiniAppVersion error",t),t}})}showNativeLoading(){return a(this,null,function*(){try{return yield h.showDialog()}catch(e){throw console.error("showNativeLoading error",e),e}})}cancelNativeLoading(){return a(this,null,function*(){try{return yield h.cancelDialog()}catch(e){throw console.error("cancelNativeLoading error",e),e}})}getMiniAppKong(e){return a(this,null,function*(){try{return yield h.getMiniAppKong(e)}catch(t){throw console.error("getMiniAppKong error",t),t}})}}const Be=l.registerPlugin("CameraScanPlugin",{web:new class extends w{pickCameraScan(r){return a(this,null,function*(){return new Promise(e=>{e(r)})})}}});window.removeAddListenerCameraScan=()=>null;class Ue{pickCameraScan(e){return a(this,null,function*(){try{return yield Be.pickCameraScan(e)}catch(t){throw console.error("pickCameraScan error",t),t}})}}const Ee=l.registerPlugin("CameraScanMultiplePlugin",{web:new class extends w{pickCameraScanMultiple(){return a(this,null,function*(){})}}});class _e{pickCameraScanMultiple(e){return a(this,null,function*(){try{return yield Ee.pickCameraScanMultiple(e)}catch(t){throw console.error("pickCameraScanMultiple error",t),t}})}}const xe=l.registerPlugin("CameraScanMultipleNoCountPlugin",{web:new class extends w{pickCameraScanMultipleNoCount(){return a(this,null,function*(){})}}});class He{pickCameraScanMultipleNoCount(e){return a(this,null,function*(){try{return yield xe.pickCameraScanMultipleNoCount(e)}catch(t){throw console.error("pickCameraScanMultipleNoCount error",t),t}})}}const Ie=l.registerPlugin("CameraScanSingleOrDualPlugin",{web:new class extends w{pickCameraScanSingleOrDual(){return a(this,null,function*(){})}}});class je{pickCameraScanSingleOrDual(e){return a(this,null,function*(){try{return yield Ie.pickCameraScanSingleOrDual(e)}catch(t){throw console.error("pickCameraScanSingleOrDual error",t),t}})}}const le="LaserScanPlugin",te=l.registerPlugin(le,{web:new class extends w{pickLaserScan(){return a(this,null,function*(){})}unPickLaserScan(){return a(this,null,function*(){})}setLaserState(){return a(this,null,function*(){})}}}),J=I();J.removeAddListenerLaserScan=()=>null;const de=(r=()=>null)=>{try{J.removeAddListenerLaserScan&&J.removeAddListenerLaserScan();const e=t=>a(this,null,function*(){t&&(J.removeAddListenerLaserScan=yield(n=>a(this,null,function*(){try{if(l.addListener){const o=yield l.addListener(le,"nativeSendLaser",s=>n&&n(s));return o!=null&&o.remove?o.remove:()=>null}}catch(o){throw console.error("addListenerLaserHandle error",o),o}}))(t))});setTimeout(()=>{e(r)})}catch(e){throw console.error("laserScanFn error",e),e}};class Te{constructor(){this.pickLaserScan()}pickLaserScan(){return a(this,null,function*(){try{return yield te.pickLaserScan({isContinue:!1})}catch(e){throw console.error("pickLaserScan error",e),e}})}unPickLaserScan(){return a(this,null,function*(){try{return yield te.unPickLaserScan()}catch(e){throw console.error("unPickLaserScan error",e),e}})}setLaserState(e){try{te.setLaserState(e)}catch(t){throw console.error("setLaserState error",t),t}}setLaserScan(e){(t=>{try{const{mounted:n,beforeUnmount:o,callBack:s}=t;n(()=>{de(s)}),o(()=>{de()})}catch(n){throw console.error("laserScanApiParams error",n),n}})(e)}}const _=I();_.addListenerCountAssistRemoveHandle=()=>null;const ue=(r=()=>null)=>a(this,null,function*(){try{_!=null&&_.addListenerCountAssistRemoveHandle&&typeof _.addListenerCountAssistRemoveHandle=="function"&&_.addListenerCountAssistRemoveHandle(),_.addListenerCountAssistRemoveHandle=yield(e=>a(this,null,function*(){try{if(l.addListener){const t=yield l.addListener(F,"nativeSendCountAssist",n=>e&&e(n));return t!=null&&t.remove?t.remove:()=>null}}catch(t){throw console.error("addListenerCountAssistHandle error",t),t}}))(r)}catch(e){throw console.error("initCountAssistFn error",e),e}});class Fe{setCountAssistState(e){return a(this,null,function*(){return yield Ae.setCountAssistState(e)})}getCountAssistState(e){return(t=>{try{let n=t!=null?t:!1;return K(o=>{n=!!(o!=null&&o.countAssistState)}),n}catch(n){throw console.error("getCountAssistStateHandle error",n),n}})(e)}setCountAssistBtn(e){(t=>{try{const{mounted:n,beforeUnmount:o,callBack:s}=t;n(()=>{ue(s)}),o(()=>{ue()})}catch(n){throw console.error("setCountAssistBtnHandle error",n),n}})(e)}}const me=l.registerPlugin("ClickStreamPlugin",{web:new class extends w{init(){return a(this,null,function*(){return new Promise(r=>{r(null)})})}trace(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("clickStreamTraceParams error",e),e}})}}});class $e{constructor(){this.init()}init(){return a(this,null,function*(){try{return yield me.init()}catch(e){throw console.error("clickStreamPlugin, init error",e),e}})}trace(e){return a(this,null,function*(){try{return yield me.trace(e)}catch(t){throw console.error("clickStreamPlugin, trace error",t),t}})}}const we="MiniAppLifecyclePlugin";var $=(r=>(r.MINI_APP_BEFORE_UNMOUNT_PERMISSION="mini_app_before_unmount_permission",r.MINI_APP_BEFORE_UNMOUNT_COMPLETION="mini_app_before_unmount_completion",r))($||{});const he=l.registerPlugin(we,{web:new class extends w{setNativeUsagePermission(){return a(this,null,function*(){})}authorizeWebCallback(){return a(this,null,function*(){})}}}),Q=I();Q.removeAddListenerLifecycleMiniAppBeforeUnmount=()=>null;const pe=(r=()=>null)=>{try{Q.removeAddListenerLifecycleMiniAppBeforeUnmount&&Q.removeAddListenerLifecycleMiniAppBeforeUnmount();const e=t=>a(this,null,function*(){t&&(Q.removeAddListenerLifecycleMiniAppBeforeUnmount=yield(n=>a(this,null,function*(){try{if(l.addListener){const o=yield l.addListener(we,"miniAppBeforeUnmount",s=>n&&n(s));return o!=null&&o.remove?o.remove:()=>null}}catch(o){throw console.error("miniAppBeforeUnmountHandle error",o),o}}))(t))});setTimeout(()=>a(this,null,function*(){yield e(r)}))}catch(e){throw console.error("laserScanFn error",e),e}};class Re{constructor(){}setNativeUsagePermission(e){return a(this,null,function*(){try{return yield he.setNativeUsagePermission(e)}catch(t){throw console.error("lifecyclePlugin.setNativeUsagePermission error",t),t}})}authorizeWebCallback(e){return a(this,null,function*(){try{return yield he.authorizeWebCallback(e)}catch(t){throw console.error("lifecyclePlugin.authorizeWebCallback error",t),t}})}miniAppBeforeUnmount(e){this.setNativeUsagePermission({action:$.MINI_APP_BEFORE_UNMOUNT_PERMISSION,value:!0}),((t,n)=>{try{const{mounted:o,beforeUnmount:s,callBack:c}=t;o(()=>{pe(i=>a(this,null,function*(){var f;if(c&&c instanceof Function)try{(f=c(i))==null||f.then(()=>a(this,null,function*(){yield n.setNativeUsagePermission({action:$.MINI_APP_BEFORE_UNMOUNT_PERMISSION,value:!1}),yield n.authorizeWebCallback({action:$.MINI_APP_BEFORE_UNMOUNT_COMPLETION})}))}catch(m){console.error("miniAppBeforeUnmount error callBack is not a function or promise")}else console.error("miniAppBeforeUnmount error callBack is not a function or promise")}))}),s(()=>a(this,null,function*(){pe(),n.setNativeUsagePermission({action:$.MINI_APP_BEFORE_UNMOUNT_PERMISSION,value:!1})}))}catch(o){throw console.error("miniAppBeforeUnmount error",o),o}})(e,this)}}class ye{constructor(){S(this,"initialContextPlugins",new ke);S(this,"communicatePlugins",new Oe);S(this,"cameraScanPlugins",new Ue);S(this,"cameraScanMultiplePlugins",new _e);S(this,"cameraScanMultipleNoCountPlugins",new He);S(this,"cameraScanSingleOrDualPlugins",new je);S(this,"laserScanPlugins",new Te);S(this,"countAssistPlugins",new Fe);S(this,"clickStreamPlugins",new $e);S(this,"lifecyclePlugins",new Re)}}const De=new ye,We=Object.freeze(Object.defineProperty({__proto__:null,PluginsWeb:class extends w{homeIsClick(){return a(this,null,function*(){})}openMiniApp(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("openMiniApp error",e),e}})}showTitle(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("showTitle error",e),e}})}showFABMenu(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("showFABMenu error",e),e}})}showSubMask(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("showSubMask error",e),e}})}setMiniAppVersion(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("setMiniAppVersion error",e),e}})}showDialog(){return a(this,null,function*(){})}cancelDialog(){return a(this,null,function*(){})}getMiniAppKong(r){return a(this,null,function*(){try{return new Promise(e=>{e(r)})}catch(e){throw console.error("getMiniAppKong error",e),e}})}}},Symbol.toStringTag,{value:"Module"}));g.NativeApi=ye,g.default=De,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "superapp-miniapp-invoke-native",
3
3
  "type": "module",
4
- "version": "1.3.3",
4
+ "version": "1.3.4",
5
5
  "description": "In Superapp, the encapsulation of calling Native interfaces by mini-programs.",
6
6
  "scripts": {
7
7
  "dev": "vite",