superapp-miniapp-invoke-native 1.0.33 → 1.0.34
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 +22 -22
- package/lib/main.umd.cjs +1 -1
- package/lib/src/init/index.d.ts +1 -2
- package/lib/src/type/index.d.ts +1 -1
- package/package.json +1 -1
package/lib/main.js
CHANGED
|
@@ -31,7 +31,7 @@ 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,
|
|
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) => {
|
|
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) => {
|
|
@@ -56,7 +56,7 @@ const ce = (t) => {
|
|
|
56
56
|
return (v = u[p]) === null || v === void 0 ? void 0 : v.bind(u);
|
|
57
57
|
throw new E(`"${c}" plugin is not implemented on ${P}`, L.Unimplemented);
|
|
58
58
|
}
|
|
59
|
-
},
|
|
59
|
+
}, S = (u) => {
|
|
60
60
|
let p;
|
|
61
61
|
const m = (...v) => {
|
|
62
62
|
const h = re().then((g) => {
|
|
@@ -74,7 +74,7 @@ const ce = (t) => {
|
|
|
74
74
|
writable: !1,
|
|
75
75
|
configurable: !1
|
|
76
76
|
}), m;
|
|
77
|
-
}, G =
|
|
77
|
+
}, G = S("addListener"), J = S("removeListener"), ae = (u, p) => {
|
|
78
78
|
const m = G({ eventName: u }, p), v = async () => {
|
|
79
79
|
const g = await m;
|
|
80
80
|
J({
|
|
@@ -85,7 +85,7 @@ const ce = (t) => {
|
|
|
85
85
|
return h.remove = async () => {
|
|
86
86
|
console.warn("Using addListener() without 'await' is deprecated."), await v();
|
|
87
87
|
}, h;
|
|
88
|
-
},
|
|
88
|
+
}, T = new Proxy({}, {
|
|
89
89
|
get(u, p) {
|
|
90
90
|
switch (p) {
|
|
91
91
|
case "$$typeof":
|
|
@@ -97,22 +97,22 @@ const ce = (t) => {
|
|
|
97
97
|
case "removeListener":
|
|
98
98
|
return J;
|
|
99
99
|
default:
|
|
100
|
-
return
|
|
100
|
+
return S(p);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
-
return f[c] =
|
|
104
|
+
return f[c] = T, H.set(c, {
|
|
105
105
|
name: c,
|
|
106
|
-
proxy:
|
|
106
|
+
proxy: T,
|
|
107
107
|
platforms: /* @__PURE__ */ new Set([
|
|
108
108
|
...Object.keys(d),
|
|
109
109
|
...C ? [P] : []
|
|
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
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),
|
|
115
|
-
|
|
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;
|
|
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);
|
|
@@ -152,10 +152,10 @@ class M {
|
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
unimplemented(e = "not implemented") {
|
|
155
|
-
return new
|
|
155
|
+
return new k.Exception(e, L.Unimplemented);
|
|
156
156
|
}
|
|
157
157
|
unavailable(e = "not available") {
|
|
158
|
-
return new
|
|
158
|
+
return new k.Exception(e, L.Unavailable);
|
|
159
159
|
}
|
|
160
160
|
async removeListener(e, r) {
|
|
161
161
|
const s = this.listeners[e];
|
|
@@ -280,12 +280,12 @@ class ve extends M {
|
|
|
280
280
|
default:
|
|
281
281
|
f = await a.text();
|
|
282
282
|
}
|
|
283
|
-
const
|
|
283
|
+
const O = {};
|
|
284
284
|
return a.headers.forEach((b, j) => {
|
|
285
|
-
|
|
285
|
+
O[j] = b;
|
|
286
286
|
}), {
|
|
287
287
|
data: f,
|
|
288
|
-
headers:
|
|
288
|
+
headers: O,
|
|
289
289
|
status: a.status,
|
|
290
290
|
url: a.url
|
|
291
291
|
};
|
|
@@ -336,7 +336,7 @@ N("Portals", {
|
|
|
336
336
|
}).then((t) => new t.PortalsWeb())
|
|
337
337
|
});
|
|
338
338
|
function D() {
|
|
339
|
-
return
|
|
339
|
+
return k.getPlatform() === "android" ? JSON.parse(AndroidInitialContext.initialContext()) : window.portalInitialContext;
|
|
340
340
|
}
|
|
341
341
|
class he extends M {
|
|
342
342
|
// eslint-disable-next-line
|
|
@@ -355,7 +355,7 @@ const q = (t) => {
|
|
|
355
355
|
s && t && t(s);
|
|
356
356
|
}
|
|
357
357
|
}, be = (t, { asiaUatData: e, euSitData: r, euUatData: s }) => {
|
|
358
|
-
const n = t.
|
|
358
|
+
const n = t.mockServerInfo.env, a = t.mockServerInfo.area;
|
|
359
359
|
let o = null;
|
|
360
360
|
return I.ASIA === a ? A.UAT === n && (o = e) : I.EU === a && (A.SIT === n ? o = r : A.UAT === n && (o = s)), o;
|
|
361
361
|
}, ye = ({ cb: t }) => {
|
|
@@ -378,8 +378,8 @@ const q = (t) => {
|
|
|
378
378
|
}, Le = (t) => new Promise(async (e) => {
|
|
379
379
|
let r = be(t, {
|
|
380
380
|
asiaUatData: await import("./chunk/1b5f5213.js"),
|
|
381
|
-
euSitData: await import("./chunk/
|
|
382
|
-
euUatData: await import("./chunk/
|
|
381
|
+
euSitData: await import("./chunk/02340160.js"),
|
|
382
|
+
euUatData: await import("./chunk/7615ea07.js")
|
|
383
383
|
});
|
|
384
384
|
e((r == null ? void 0 : r.default) ?? null);
|
|
385
385
|
}), Ae = () => {
|
|
@@ -410,13 +410,13 @@ const q = (t) => {
|
|
|
410
410
|
}
|
|
411
411
|
};
|
|
412
412
|
_($, "defaultNativeApiConfig", {
|
|
413
|
-
|
|
413
|
+
mockServerInfo: {
|
|
414
414
|
area: I.ASIA,
|
|
415
415
|
env: A.UAT
|
|
416
416
|
}
|
|
417
417
|
});
|
|
418
418
|
let W = $;
|
|
419
|
-
class
|
|
419
|
+
class ke extends W {
|
|
420
420
|
constructor() {
|
|
421
421
|
super();
|
|
422
422
|
}
|
|
@@ -430,7 +430,7 @@ class Oe extends W {
|
|
|
430
430
|
return await super.nativeAppInfo(e);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
const xe = new
|
|
433
|
+
const xe = new ke();
|
|
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,k=()=>o!==null?o.name:ce(t),b=((e=l==null?void 0:l.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||k,j=()=>b()!=="web",z=((r=l==null?void 0:l.currentPlatform)===null||r===void 0?void 0:r.isNativePlatform)||j,Q=c=>{const d=H.get(c);return!!(d!=null&&d.platforms.has(b())||B(c))},X=((a=l==null?void 0:l.currentPlatform)===null||a===void 0?void 0:a.isPluginAvailable)||Q,Y=c=>{var d;return(d=i.PluginHeaders)===null||d===void 0?void 0:d.find(y=>y.name===c)},B=((n=l==null?void 0:l.currentPlatform)===null||n===void 0?void 0:n.getPluginHeader)||Y,Z=c=>t.console.error(c),V=(c,d,y)=>Promise.reject(`${y} does not have an implementation of "${d}".`),H=new Map,ee=(c,d={})=>{const y=H.get(c);if(y)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),y.proxy;const P=b(),C=B(c);let w;const re=async()=>(!w&&P in d?w=typeof d[P]=="function"?w=await d[P]():w=d[P]:o!==null&&!w&&"web"in d&&(w=typeof d.web=="function"?w=await d.web():w=d.web),w),ne=(u,g)=>{var m,v;if(C){const h=C==null?void 0:C.methods.find(p=>g===p.name);if(h)return h.rtype==="promise"?p=>i.nativePromise(c,g.toString(),p):(p,x)=>i.nativeCallback(c,g.toString(),p,x);if(u)return(m=u[g])===null||m===void 0?void 0:m.bind(u)}else{if(u)return(v=u[g])===null||v===void 0?void 0:v.bind(u);throw new E(`"${c}" plugin is not implemented on ${P}`,L.Unimplemented)}},T=u=>{let g;const m=(...v)=>{const h=re().then(p=>{const x=ne(p,u);if(x){const U=x(...v);return g=U==null?void 0:U.remove,U}else throw new E(`"${c}.${u}()" is not implemented on ${P}`,L.Unimplemented)});return u==="addListener"&&(h.remove=async()=>g()),h};return m.toString=()=>`${u.toString()}() { [capacitor code] }`,Object.defineProperty(m,"name",{value:u,writable:!1,configurable:!1}),m},G=T("addListener"),J=T("removeListener"),se=(u,g)=>{const m=G({eventName:u},g),v=async()=>{const p=await m;J({eventName:u,callbackId:p},g)},h=new Promise(p=>m.then(()=>p({remove:v})));return h.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await v()},h},S=new Proxy({},{get(u,g){switch(g){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return C?se:G;case"removeListener":return J;default:return T(g)}}});return f[c]=S,H.set(c,{name:c,proxy:S,platforms:new Set([...Object.keys(d),...C?[P]:[]])}),S},te=((s=l==null?void 0:l.currentPlatform)===null||s===void 0?void 0:s.registerPlugin)||ee;return i.convertFileSrc||(i.convertFileSrc=c=>c),i.getPlatform=b,i.handleError=Z,i.isNativePlatform=z,i.isPluginAvailable=X,i.pluginMethodNoop=V,i.registerPlugin=te,i.Exception=E,i.DEBUG=!!i.DEBUG,i.isLoggingEnabled=!!i.isLoggingEnabled,i.platform=i.getPlatform(),i.isNative=i.isNativePlatform(),i},ue=t=>t.Capacitor=de(t),O=ue(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),N=O.registerPlugin;O.Plugins;class M{constructor(e){this.listeners={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,r){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(r);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n);const s=async()=>this.removeListener(e,r),o=Promise.resolve({remove:s});return Object.defineProperty(o,"remove",{value:async()=>{console.warn("Using addListener() without 'await' is deprecated."),await s()}}),o}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,r){const a=this.listeners[e];a&&a.forEach(n=>n(r))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,r){this.windowListeners[r]={registered:!1,windowEventName:e,pluginEventName:r,handler:a=>{this.notifyListeners(r,a)}}}unimplemented(e="not implemented"){return new O.Exception(e,L.Unimplemented)}unavailable(e="not available"){return new O.Exception(e,L.Unavailable)}async removeListener(e,r){const a=this.listeners[e];if(!a)return;const n=a.indexOf(r);this.listeners[e].splice(n,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}}const F=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),K=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class fe extends M{async getCookies(){const e=document.cookie,r={};return e.split(";").forEach(a=>{if(a.length<=0)return;let[n,s]=a.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");n=K(n).trim(),s=K(s).trim(),r[n]=s}),r}async setCookie(e){try{const r=F(e.key),a=F(e.value),n=`; expires=${(e.expires||"").replace("expires=","")}`,s=(e.path||"/").replace("path=",""),o=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${r}=${a||""}${n}; path=${s}; ${o};`}catch(r){return Promise.reject(r)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(r){return Promise.reject(r)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const r of e)document.cookie=r.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}N("CapacitorCookies",{web:()=>new fe});const ge=async t=>new Promise((e,r)=>{const a=new FileReader;a.onload=()=>{const n=a.result;e(n.indexOf(",")>=0?n.split(",")[1]:n)},a.onerror=n=>r(n),a.readAsDataURL(t)}),pe=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(n=>n.toLocaleLowerCase()).reduce((n,s,o)=>(n[s]=t[e[o]],n),{})},me=(t,e=!0)=>t?Object.entries(t).reduce((a,n)=>{const[s,o]=n;let i,f;return Array.isArray(o)?(f="",o.forEach(l=>{i=e?encodeURIComponent(l):l,f+=`${s}=${i}&`}),f.slice(0,-1)):(i=e?encodeURIComponent(o):o,f=`${s}=${i}`),`${a}&${f}`},"").substr(1):null,we=(t,e={})=>{const r=Object.assign({method:t.method||"GET",headers:t.headers},e),n=pe(t.headers)["content-type"]||"";if(typeof t.data=="string")r.body=t.data;else if(n.includes("application/x-www-form-urlencoded")){const s=new URLSearchParams;for(const[o,i]of Object.entries(t.data||{}))s.set(o,i);r.body=s.toString()}else if(n.includes("multipart/form-data")){const s=new FormData;if(t.data instanceof FormData)t.data.forEach((i,f)=>{s.append(f,i)});else for(const i of Object.keys(t.data))s.append(i,t.data[i]);r.body=s;const o=new Headers(r.headers);o.delete("content-type"),r.headers=o}else(n.includes("application/json")||typeof t.data=="object")&&(r.body=JSON.stringify(t.data));return r};class ve extends M{async request(e){const r=we(e,e.webFetchExtra),a=me(e.params,e.shouldEncodeUrlParams),n=a?`${e.url}?${a}`:e.url,s=await fetch(n,r),o=s.headers.get("content-type")||"";let{responseType:i="text"}=s.ok?e:{};o.includes("application/json")&&(i="json");let f,l;switch(i){case"arraybuffer":case"blob":l=await s.blob(),f=await ge(l);break;case"json":f=await s.json();break;case"document":case"text":default:f=await s.text()}const k={};return s.headers.forEach((b,j)=>{k[j]=b}),{data:f,headers:k,status:s.status,url:s.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}N("CapacitorHttp",{web:()=>new ve});/*! Ionic Portals: https://ionic.io/portals - Commercial License */N("Portals",{web:()=>Promise.resolve().then(function(){return Pe}).then(t=>new t.PortalsWeb)});function D(){return O.getPlatform()==="android"?JSON.parse(AndroidInitialContext.initialContext()):window.portalInitialContext}class he extends M{async publishNative(e){}}const Pe=Object.freeze({__proto__:null,PortalsWeb:he});var A=(t=>(t.DEV="dev",t.SIT="sit",t.UAT="uat",t.PROD="prod",t.TEST="test",t))(A||{}),I=(t=>(t.EU="eu",t.ASIA="asia",t))(I||{});const q=t=>{var e,r;if(!(typeof window>"u")&&D&&(e=D())!=null&&e.value){const a=((r=D())==null?void 0:r.value)??null;a&&t&&t(a)}},be=(t,{asiaUatData:e,euSitData:r,euUatData:a})=>{const n=t.serverInfo.env,s=t.serverInfo.area;let o=null;return I.ASIA===s?A.UAT===n&&(o=e):I.EU===s&&(A.SIT===n?o=r:A.UAT===n&&(o=a)),o},ye=({cb:t})=>{setTimeout(()=>{q(e=>{if(!(e!=null&&e.params))return;const r=JSON.parse(e.params)??null;if(!r)return;const{params:a,routeName:n}=r;!a||!n||t&&t(r)})})},Ce=()=>{let t=!1;return q(e=>{t=!!(e!=null&&e.isNative)}),t},Le=t=>new Promise(async e=>{let r=be(t,{asiaUatData:await Promise.resolve().then(()=>require("./umd/fbb879ae.umd.cjs")),euSitData:await Promise.resolve().then(()=>require("./umd/5ca52608.umd.cjs")),euUatData:await Promise.resolve().then(()=>require("./umd/7c40191f.umd.cjs"))});e((r==null?void 0:r.default)??null)}),Ae=()=>{let t=null;return q(e=>{e?t={data_info:e.data_info?JSON.parse(e.data_info):null,data_store:e.data_store?JSON.parse(e.data_store):null,data_language:e.data_language?JSON.parse(e.data_language):null}:t=null}),t},$=class ${constructor(){_(this,"nativeApiConfig");this.nativeApiConfig=$.defaultNativeApiConfig}async getIsNativeHandle(){return await Ce()}async specifiedPageHandle({cb:e}){await ye({cb:e})}async nativeAppInfo(e){return e&&(this.nativeApiConfig=e),await this.getIsNativeHandle()?await Ae():await Le(this.nativeApiConfig)}};_($,"defaultNativeApiConfig",{serverInfo:{area:I.ASIA,env:A.UAT}});let W=$;class Oe extends W{constructor(){super()}async getIsNativeHandle(){return await super.getIsNativeHandle()}async specifiedPageHandle({cb:e}){return await super.specifiedPageHandle({cb:e})}async nativeAppInfo(e){return await super.nativeAppInfo(e)}}const ke=new Oe;module.exports=ke;
|
|
1
|
+
"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;
|
package/lib/src/init/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { NativeApiType } from './type';
|
|
2
1
|
import InitialContextPlugins from '../apiHandle/initialContext';
|
|
3
2
|
import type { NativeApiConfigType } from '../type';
|
|
4
3
|
import type { SpecifiedPageType } from '../apiHandle/initialContext/specifiedPage';
|
|
5
|
-
export default class NativeApi extends InitialContextPlugins
|
|
4
|
+
export default class NativeApi extends InitialContextPlugins {
|
|
6
5
|
constructor();
|
|
7
6
|
getIsNativeHandle(): Promise<boolean>;
|
|
8
7
|
specifiedPageHandle({ cb }: SpecifiedPageType): Promise<void>;
|
package/lib/src/type/index.d.ts
CHANGED