@hylid/call 3.3.0-alpha.0 → 3.3.0-alpha.10
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 +1 -0
- package/lib/index.js +13 -0
- package/lib/mpCall.js +4 -0
- package/lib/webviewBridge/index.js +1 -1
- package/lib/webviewBridge/internal/getCurrentPages.d.ts +3 -1
- package/lib/webviewBridge/internal/getCurrentPages.js +6 -1
- package/lib/webviewBridge/webview-bridge-component/index.axml +1 -0
- package/lib/webviewBridge/webview-bridge-component/index.d.ts +1 -0
- package/lib/webviewBridge/webview-bridge-component/index.js +40 -0
- package/lib/webviewBridge/webview-bridge-component/index.json +3 -0
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { webCall } from './webCall';
|
|
|
6
6
|
import { notFound } from './notFound';
|
|
7
7
|
import { Config } from './types';
|
|
8
8
|
export declare function call<T extends keyof MPApi>(name: T | ({} & string), options?: PickMPArgs<T> | Common | Callback<PickMpReturns<T>>, config?: Config): any;
|
|
9
|
+
export declare function createWebviewSrc(url: string): string;
|
|
9
10
|
export { WebViewBridge } from './webviewBridge';
|
|
10
11
|
export { mpCall, mpWebCall, webCall, notFound };
|
|
11
12
|
export { promisify } from './promisify';
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,19 @@ export function call(name, options, config) {
|
|
|
12
12
|
return notFound(options, config);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
export function createWebviewSrc(url) {
|
|
16
|
+
var app = my.getSystemInfoSync().app;
|
|
17
|
+
var hashIndex = url.indexOf('#');
|
|
18
|
+
var hash = '';
|
|
19
|
+
if (hashIndex !== -1) {
|
|
20
|
+
hash = url.slice(hashIndex);
|
|
21
|
+
url = url.slice(0, hashIndex);
|
|
22
|
+
}
|
|
23
|
+
var separator = url.includes('?') ? '&' : '?';
|
|
24
|
+
var newUrl = url + separator + '__app__=' + app + hash;
|
|
25
|
+
return newUrl;
|
|
26
|
+
}
|
|
27
|
+
;
|
|
15
28
|
export { WebViewBridge } from "./webviewBridge";
|
|
16
29
|
export { mpCall, mpWebCall, webCall, notFound };
|
|
17
30
|
export { promisify } from "./promisify";
|
package/lib/mpCall.js
CHANGED
|
@@ -103,7 +103,7 @@ var WebViewBridge = /** @class */function () {
|
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
} else {
|
|
106
|
-
console.info("[hylid-call]: context
|
|
106
|
+
console.info("[hylid-call]: context is null, broadcast and pageEvent cannot be used");
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
WebViewBridge.prototype.bindCtxEvent = function (event, callback) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<web-view id="{{id}}" src="{{webviewSrc}}" onMessage="onMessage" onError="onError" onLoad="onLoad" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Component({
|
|
4
|
+
data: {
|
|
5
|
+
webviewSrc: ''
|
|
6
|
+
},
|
|
7
|
+
onInit: function onInit() {
|
|
8
|
+
this.setData({
|
|
9
|
+
webviewSrc: this.createWebviewSrc(this.props.src)
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
deriveDataFromProps: function deriveDataFromProps(nextProps) {
|
|
13
|
+
this.setData({
|
|
14
|
+
webviewSrc: this.createWebviewSrc(nextProps.src)
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
methods: {
|
|
18
|
+
createWebviewSrc: function createWebviewSrc(url) {
|
|
19
|
+
var app = my.getSystemInfoSync().app;
|
|
20
|
+
var hashIndex = url.indexOf('#');
|
|
21
|
+
var hash = '';
|
|
22
|
+
if (hashIndex !== -1) {
|
|
23
|
+
hash = url.slice(hashIndex);
|
|
24
|
+
url = url.slice(0, hashIndex);
|
|
25
|
+
}
|
|
26
|
+
var separator = url.includes('?') ? '&' : '?';
|
|
27
|
+
var newUrl = url + separator + '__app__=' + app + hash;
|
|
28
|
+
return newUrl;
|
|
29
|
+
},
|
|
30
|
+
onMessage: function onMessage(params) {
|
|
31
|
+
this.props.onMessage && this.props.onMessage(params);
|
|
32
|
+
},
|
|
33
|
+
onLoad: function onLoad(params) {
|
|
34
|
+
this.props.onLoad && this.props.onLoad(params);
|
|
35
|
+
},
|
|
36
|
+
onError: function onError(params) {
|
|
37
|
+
this.props.onError && this.props.onError(params);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hylid/call",
|
|
3
|
-
"version": "3.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.10",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
7
7
|
],
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@hylid/env": "^3.3.0-alpha.
|
|
10
|
-
"@hylid/types": "^3.3.0-alpha.
|
|
9
|
+
"@hylid/env": "^3.3.0-alpha.10",
|
|
10
|
+
"@hylid/types": "^3.3.0-alpha.10"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|