@hylid/call 0.0.90011511756-dev.2 → 0.0.90011511756-dev.22

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/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { mpWebCall, mpWebCallAsync } from './mpWebCall';
5
5
  import { webCall, webCallAsync } from './webCall';
6
6
  import { notFound } from './notFound';
7
7
  import { Config } from './types';
8
+ import './windvaneBridge/windvane';
8
9
  export declare function call<T extends keyof MPApi>(name: T | ({} & string), options?: PickMPArgs<T> | Common | Callback<PickMpReturns<T>>, config?: Config): any;
9
10
  export declare function callAsync<T = any>(apiName: string, options?: AsyncCallback<T> & any, config?: {
10
11
  timeout: number;
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@ import { mpCall } from "./mpCall";
4
4
  import { mpWebCall, mpWebCallAsync } from "./mpWebCall";
5
5
  import { webCall, webCallAsync } from "./webCall";
6
6
  import { notFound } from "./notFound";
7
+ import "./windvaneBridge/windvane";
7
8
  var callMap = (_a = {}, _a[PLATFORM.MP] = mpCall, _a[PLATFORM.MPWEB] = mpWebCall, _a[PLATFORM.WEB] = webCall, _a);
8
9
  var callMapAsync = (_b = {}, _b[PLATFORM.MPWEB] = mpWebCallAsync, _b[PLATFORM.WEB] = webCallAsync, _b);
9
10
  export function call(name, options, config) {
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+
3
+ // @ts-nocheck
4
+ /* eslint-disable */
5
+ // This file was original https://g.alicdn.com/superapp-cloud/js-library-windvane/3.1.3/windvane.js.
6
+ import _typeof from "@babel/runtime/helpers/typeof";
7
+ !function (a, b) {
8
+ function c(a, b) {
9
+ a = a.toString().split("."), b = b.toString().split(".");
10
+ for (var c = 0; c < a.length || c < b.length; c++) {
11
+ var d = parseInt(a[c], 10),
12
+ e = parseInt(b[c], 10);
13
+ if (window.isNaN(d) && (d = 0), window.isNaN(e) && (e = 0), e > d) return -1;
14
+ if (d > e) return 1;
15
+ }
16
+ return 0;
17
+ }
18
+ try {
19
+ var d = a.__SUPERAPP_NAMESPACE__ ? a.__SUPERAPP_NAMESPACE__ instanceof Array ? a.__SUPERAPP_NAMESPACE__ : [a.__SUPERAPP_NAMESPACE__] : ["WindVane"],
20
+ e = "windvane",
21
+ f = a.__SUPERAPP_CALL_NAMESPACE__ ? a.__SUPERAPP_CALL_NAMESPACE__ : "__windvane__",
22
+ g = a.Promise,
23
+ h = a.document,
24
+ i = a.navigator.userAgent,
25
+ j = /Windows\sPhone\s(?:OS\s)?[\d\.]+/i.test(i) || /Windows\sNT\s[\d\.]+/i.test(i),
26
+ k = j && a.WindVane_Win_Private && a.WindVane_Win_Private.call,
27
+ l = /iPhone|iPad|iPod/i.test(i),
28
+ m = /Android/i.test(i),
29
+ n = i.match(/WindVane[\/\s](\d+[._]\d+[._]\d+)/),
30
+ o = Object.prototype.hasOwnProperty,
31
+ p = b[e];
32
+ p || d.forEach(function (b) {
33
+ a[b] || (a[b] = {
34
+ version: "3.0.7"
35
+ }), p ? a[b] = p : p = a[b];
36
+ });
37
+ var q = Math.floor(65536 * Math.random()),
38
+ r = 1,
39
+ s = [],
40
+ t = 3,
41
+ u = "hybrid",
42
+ v = "wv_hybrid",
43
+ w = "iframe_",
44
+ x = "param_",
45
+ y = 6e5,
46
+ z = 6e4;
47
+ n = n ? (n[1] || "0.0.0").replace(/\_/g, ".") : "0.0.0";
48
+ var A = {
49
+ isAvailable: 1 === c(n, "0"),
50
+ isNewBridgeAvailable: 1 === c(n, m ? "8.3.0" : "8.2.0"),
51
+ call2: function call2(a, b, c, d, e) {
52
+ var f = a.indexOf(".");
53
+ return A.call(a.substr(0, f), a.substr(f + 1), b, c, d, e);
54
+ },
55
+ call: function call(b, c, d, e, h, i) {
56
+ var j, k;
57
+ "number" == typeof arguments[arguments.length - 1] && (i = arguments[arguments.length - 1]), "function" != typeof e && (e = null), "function" != typeof h && (h = null), !g || e || h || (k = new g(function (a, b) {
58
+ e = a, h = b;
59
+ }));
60
+ var l = ("" + c).indexOf(".") > -1;
61
+ if ((!m || !l) && A.isNewBridgeAvailable && a[f] && (!a[f].call && a[f].windVaneCoreJs && new Function(a[f].windVaneCoreJs())(), a[f].call)) return a[f].call(b + "." + c, d, e, h, i), k;
62
+ j = B.getSid();
63
+ var n = {
64
+ success: e,
65
+ failure: h
66
+ };
67
+ return i > 0 && (n.timeout = setTimeout(function () {
68
+ A.onFailure(j, {
69
+ ret: "HY_TIMEOUT"
70
+ });
71
+ }, i)), B.registerCall(j, n), B.registerGC(j, i), A.isAvailable ? B.callMethod(b, c, d, j) : A.onFailure(j, {
72
+ ret: "HY_NOT_IN_WINDVANE"
73
+ }), k;
74
+ },
75
+ fireEvent: function fireEvent(a, b, c) {
76
+ var d = h.createEvent("HTMLEvents");
77
+ d.initEvent(a, !1, !0), d.param = B.parseData(b), h.dispatchEvent(d);
78
+ },
79
+ getParam: function getParam(a) {
80
+ return B.getParam(a);
81
+ },
82
+ setData: function setData(a, b) {},
83
+ find: function find(a, b) {
84
+ b || B.unregisterCall(a, !1);
85
+ },
86
+ onSuccess: function onSuccess(a, b, c) {
87
+ B.onComplete(a, b, "success", c);
88
+ },
89
+ onFailure: function onFailure(a, b) {
90
+ B.onComplete(a, b, "failure");
91
+ }
92
+ };
93
+ A.isNewBridgeAvailable && a[f] && a[f].callSync && (A.callSync = function (b, c) {
94
+ if (l) return a[f].callSync(b, c);
95
+ if (m) {
96
+ var d = {
97
+ name: b
98
+ };
99
+ c && (d.params = JSON.stringify(c));
100
+ var e = a[f].callSync(d);
101
+ if (e) try {
102
+ return JSON.parse(e);
103
+ } catch (g) {}
104
+ }
105
+ });
106
+ var B = {
107
+ params: {},
108
+ calls: {},
109
+ getSid: function getSid() {
110
+ return (q + r++) % 65536 + "";
111
+ },
112
+ buildParam: function buildParam(a) {
113
+ return a && "object" == _typeof(a) ? JSON.stringify(a) : a || "";
114
+ },
115
+ getParam: function getParam(a) {
116
+ return this.params[x + a] || "";
117
+ },
118
+ setParam: function setParam(a, b) {
119
+ this.params[x + a] = b;
120
+ },
121
+ parseData: function parseData(a) {
122
+ var b;
123
+ if (a && "string" == typeof a) try {
124
+ b = JSON.parse(a);
125
+ } catch (c) {
126
+ b = {
127
+ ret: "HY_RESULT_PARSE_ERROR",
128
+ originValue: a
129
+ };
130
+ } else b = a || {};
131
+ return b;
132
+ },
133
+ registerCall: function registerCall(a, b) {
134
+ this.calls[a] = b;
135
+ },
136
+ unregisterCall: function unregisterCall(a, b) {
137
+ var c = this.calls[a] || {},
138
+ d = c.timeout;
139
+ return d && clearTimeout(d), b || delete this.calls[a], c;
140
+ },
141
+ useIframe: function useIframe(a, b) {
142
+ var c = w + a,
143
+ d = s.pop();
144
+ d || (d = h.createElement("iframe"), d.setAttribute("frameborder", "0"), d.style.cssText = "width:0;height:0;border:0;display:none;"), d.setAttribute("id", c), d.setAttribute("src", b), d.parentNode || setTimeout(function () {
145
+ h.body.appendChild(d);
146
+ }, 5);
147
+ },
148
+ retrieveIframe: function retrieveIframe(a) {
149
+ var b = w + a,
150
+ c = h.querySelector("#" + b);
151
+ if (c) if (s.length >= t) try {
152
+ h.body.removeChild(c);
153
+ } catch (d) {} else s.indexOf(c) < 0 && s.push(c);
154
+ },
155
+ callMethod: function callMethod(b, c, d, e) {
156
+ var f = B.buildParam(d);
157
+ if (j) k ? a.WindVane_Win_Private.call(b, c, e, f) : this.onComplete(e, {
158
+ ret: "HY_NO_HANDLER_ON_WP"
159
+ }, "failure");else if (l) {
160
+ this.setParam(e, f);
161
+ var g = u + "://" + b + ":" + e + "/" + c + "?" + encodeURIComponent(f);
162
+ this.useIframe(e, g);
163
+ } else if (m) {
164
+ this.setParam(e, d);
165
+ var g = u + "://" + b + ":" + e + "/" + c + "?" + f,
166
+ h = v + ":";
167
+ window.prompt(g, h);
168
+ } else this.onComplete(e, {
169
+ ret: "HY_NOT_SUPPORT_DEVICE"
170
+ }, "failure");
171
+ },
172
+ registerGC: function registerGC(a, b) {
173
+ var c = this,
174
+ d = Math.max(b || 0, y),
175
+ e = Math.max(b || 0, z);
176
+ setTimeout(function () {
177
+ c.unregisterCall(a);
178
+ }, d), l && setTimeout(function () {
179
+ c.params[x + a] && delete c.params[x + a];
180
+ }, e);
181
+ },
182
+ onComplete: function onComplete(a, b, c, d) {
183
+ var e = this.unregisterCall(a, d),
184
+ f = e.success,
185
+ g = e.failure;
186
+ b = this.parseData(b);
187
+ var h = b.ret;
188
+ "string" == typeof h && (b = b.value || b, b.ret || (b.ret = [h])), "success" === c ? f && f(b) : "failure" === c && g && g(b), l && (this.retrieveIframe(a), this.params[x + a] && delete this.params[x + a]);
189
+ }
190
+ };
191
+ for (var C in A) o.call(p, C) || (p[C] = A[C]);
192
+ } catch (D) {
193
+ console.error("SuperApp JSAPI init error:", D);
194
+ }
195
+ }(window, window.lib || (window.lib = {}));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@hylid/call",
3
- "version": "0.0.90011511756-dev.2",
3
+ "version": "0.0.90011511756-dev.22",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "lib"
7
7
  ],
8
8
  "dependencies": {
9
- "@hylid/env": "^0.0.90011511756-dev.2",
10
- "@hylid/types": "^0.0.90011511756-dev.2"
9
+ "@hylid/env": "^0.0.90011511756-dev.22",
10
+ "@hylid/types": "^0.0.90011511756-dev.22"
11
11
  },
12
12
  "publishConfig": {
13
13
  "access": "public"