@widget-js/core 0.7.2 → 0.7.3
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/dist/index.cjs +2084 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1507 -0
- package/dist/index.js +1995 -0
- package/dist/index.js.map +1 -0
- package/package.json +15 -15
- package/dist/cjs/AppPermission.js +0 -8
- package/dist/cjs/api/ApiConstants.js +0 -11
- package/dist/cjs/api/AppApi.js +0 -51
- package/dist/cjs/api/BaseApi.js +0 -13
- package/dist/cjs/api/BroadcastApi.js +0 -22
- package/dist/cjs/api/BrowserWindowApi.js +0 -144
- package/dist/cjs/api/Channel.js +0 -22
- package/dist/cjs/api/ClipboardApi.js +0 -23
- package/dist/cjs/api/DeviceApi.js +0 -25
- package/dist/cjs/api/DialogApi.js +0 -22
- package/dist/cjs/api/ElectronApi.js +0 -15
- package/dist/cjs/api/FileApi.js +0 -21
- package/dist/cjs/api/HostedWidgetApi.js +0 -64
- package/dist/cjs/api/LogApi.js +0 -28
- package/dist/cjs/api/NotificationApi.js +0 -117
- package/dist/cjs/api/ShortcutApi.js +0 -23
- package/dist/cjs/api/StoreApi.js +0 -38
- package/dist/cjs/api/WidgetApi.js +0 -92
- package/dist/cjs/api/WidgetDataApi.js +0 -95
- package/dist/cjs/index.js +0 -51
- package/dist/cjs/lang/LanguageCode.js +0 -34
- package/dist/cjs/model/AppNotification.js +0 -33
- package/dist/cjs/model/BrowserWindowStatus.js +0 -11
- package/dist/cjs/model/HostedMode.js +0 -18
- package/dist/cjs/model/HostedWidget.js +0 -14
- package/dist/cjs/model/SocialInfo.js +0 -10
- package/dist/cjs/model/Widget.js +0 -118
- package/dist/cjs/model/WidgetData.js +0 -16
- package/dist/cjs/model/WidgetPackage.js +0 -98
- package/dist/cjs/model/WidgetParams.js +0 -151
- package/dist/cjs/model/event/AppMouseEvent.js +0 -2
- package/dist/cjs/model/event/BroadcastEvent.js +0 -11
- package/dist/cjs/model/event/NativeKeyboardEvent.js +0 -2
- package/dist/cjs/model/event/WebSocketEvent.js +0 -14
- package/dist/cjs/model/interface/IHostedWidget.js +0 -2
- package/dist/cjs/model/interface/Rectangle.js +0 -2
- package/dist/cjs/model/msic/graphics.js +0 -10
- package/dist/cjs/permission/permission.js +0 -2
- package/dist/cjs/router/encoding.js +0 -144
- package/dist/cjs/router/query.js +0 -84
- package/dist/cjs/utils/ElectronUtils.js +0 -32
- package/dist/cjs/utils/LanguageUtils.js +0 -36
- package/dist/cjs/utils/UrlUtils.js +0 -36
- package/dist/esm/AppPermission.js +0 -5
- package/dist/esm/api/ApiConstants.js +0 -7
- package/dist/esm/api/AppApi.js +0 -47
- package/dist/esm/api/BaseApi.js +0 -9
- package/dist/esm/api/BroadcastApi.js +0 -18
- package/dist/esm/api/BrowserWindowApi.js +0 -139
- package/dist/esm/api/Channel.js +0 -19
- package/dist/esm/api/ClipboardApi.js +0 -19
- package/dist/esm/api/DeviceApi.js +0 -21
- package/dist/esm/api/DialogApi.js +0 -19
- package/dist/esm/api/ElectronApi.js +0 -11
- package/dist/esm/api/FileApi.js +0 -18
- package/dist/esm/api/HostedWidgetApi.js +0 -60
- package/dist/esm/api/LogApi.js +0 -25
- package/dist/esm/api/NotificationApi.js +0 -113
- package/dist/esm/api/ShortcutApi.js +0 -19
- package/dist/esm/api/StoreApi.js +0 -35
- package/dist/esm/api/WidgetApi.js +0 -88
- package/dist/esm/api/WidgetDataApi.js +0 -88
- package/dist/esm/index.js +0 -35
- package/dist/esm/lang/LanguageCode.js +0 -33
- package/dist/esm/model/AppNotification.js +0 -29
- package/dist/esm/model/BrowserWindowStatus.js +0 -8
- package/dist/esm/model/HostedMode.js +0 -15
- package/dist/esm/model/HostedWidget.js +0 -10
- package/dist/esm/model/SocialInfo.js +0 -6
- package/dist/esm/model/Widget.js +0 -114
- package/dist/esm/model/WidgetData.js +0 -12
- package/dist/esm/model/WidgetPackage.js +0 -94
- package/dist/esm/model/WidgetParams.js +0 -147
- package/dist/esm/model/event/AppMouseEvent.js +0 -1
- package/dist/esm/model/event/BroadcastEvent.js +0 -7
- package/dist/esm/model/event/NativeKeyboardEvent.js +0 -1
- package/dist/esm/model/event/WebSocketEvent.js +0 -10
- package/dist/esm/model/interface/IHostedWidget.js +0 -1
- package/dist/esm/model/interface/Rectangle.js +0 -1
- package/dist/esm/model/msic/graphics.js +0 -7
- package/dist/esm/permission/permission.js +0 -1
- package/dist/esm/router/encoding.js +0 -135
- package/dist/esm/router/query.js +0 -79
- package/dist/esm/utils/ElectronUtils.js +0 -28
- package/dist/esm/utils/LanguageUtils.js +0 -32
- package/dist/esm/utils/UrlUtils.js +0 -32
- package/dist/types/AppPermission.d.ts +0 -4
- package/dist/types/api/ApiConstants.d.ts +0 -7
- package/dist/types/api/AppApi.d.ts +0 -29
- package/dist/types/api/BaseApi.d.ts +0 -5
- package/dist/types/api/BroadcastApi.d.ts +0 -21
- package/dist/types/api/BrowserWindowApi.d.ts +0 -111
- package/dist/types/api/Channel.d.ts +0 -18
- package/dist/types/api/ClipboardApi.d.ts +0 -10
- package/dist/types/api/DeviceApi.d.ts +0 -20
- package/dist/types/api/DialogApi.d.ts +0 -7
- package/dist/types/api/ElectronApi.d.ts +0 -4
- package/dist/types/api/FileApi.d.ts +0 -13
- package/dist/types/api/HostedWidgetApi.d.ts +0 -55
- package/dist/types/api/LogApi.d.ts +0 -9
- package/dist/types/api/NotificationApi.d.ts +0 -38
- package/dist/types/api/ShortcutApi.d.ts +0 -10
- package/dist/types/api/StoreApi.d.ts +0 -10
- package/dist/types/api/WidgetApi.d.ts +0 -48
- package/dist/types/api/WidgetDataApi.d.ts +0 -44
- package/dist/types/index.d.ts +0 -35
- package/dist/types/lang/LanguageCode.d.ts +0 -40
- package/dist/types/model/AppNotification.d.ts +0 -50
- package/dist/types/model/BrowserWindowStatus.d.ts +0 -9
- package/dist/types/model/HostedMode.d.ts +0 -14
- package/dist/types/model/HostedWidget.d.ts +0 -13
- package/dist/types/model/SocialInfo.d.ts +0 -6
- package/dist/types/model/Widget.d.ts +0 -136
- package/dist/types/model/WidgetData.d.ts +0 -35
- package/dist/types/model/WidgetPackage.d.ts +0 -101
- package/dist/types/model/WidgetParams.d.ts +0 -61
- package/dist/types/model/event/AppMouseEvent.d.ts +0 -14
- package/dist/types/model/event/BroadcastEvent.d.ts +0 -21
- package/dist/types/model/event/NativeKeyboardEvent.d.ts +0 -6
- package/dist/types/model/event/WebSocketEvent.d.ts +0 -8
- package/dist/types/model/interface/IHostedWidget.d.ts +0 -13
- package/dist/types/model/interface/Rectangle.d.ts +0 -18
- package/dist/types/model/msic/graphics.d.ts +0 -14
- package/dist/types/permission/permission.d.ts +0 -1
- package/dist/types/router/encoding.d.ts +0 -62
- package/dist/types/router/query.d.ts +0 -53
- package/dist/types/utils/ElectronUtils.d.ts +0 -10
- package/dist/types/utils/LanguageUtils.d.ts +0 -8
- package/dist/types/utils/UrlUtils.d.ts +0 -6
- package/dist/umd/index.js +0 -2
- package/dist/umd/index.js.LICENSE.txt +0 -6
package/dist/esm/model/Widget.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { HostedMode } from "./HostedMode";
|
|
2
|
-
import { getTextByLanguageCode } from "../utils/LanguageUtils";
|
|
3
|
-
export class Widget {
|
|
4
|
-
constructor(options) {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
6
|
-
/**
|
|
7
|
-
* 组件默认语言
|
|
8
|
-
*/
|
|
9
|
-
this.lang = "zh-CN";
|
|
10
|
-
this.name = options.name;
|
|
11
|
-
this.title = options.title;
|
|
12
|
-
this.description = options.description;
|
|
13
|
-
this.keywords = options.keywords;
|
|
14
|
-
this.lang = options.lang;
|
|
15
|
-
this.width = options.width;
|
|
16
|
-
this.height = options.height;
|
|
17
|
-
this.movable = (_a = options.movable) !== null && _a !== void 0 ? _a : true;
|
|
18
|
-
this.permissions = (_b = options.permissions) !== null && _b !== void 0 ? _b : [];
|
|
19
|
-
this.maxWidth = (_c = options.maxWidth) !== null && _c !== void 0 ? _c : options.width;
|
|
20
|
-
this.maxHeight = (_d = options.maxHeight) !== null && _d !== void 0 ? _d : options.height;
|
|
21
|
-
this.minWidth = (_e = options.minWidth) !== null && _e !== void 0 ? _e : options.width;
|
|
22
|
-
this.minHeight = (_f = options.minHeight) !== null && _f !== void 0 ? _f : options.height;
|
|
23
|
-
this.backgroundThrottling = (_g = options.backgroundThrottling) !== null && _g !== void 0 ? _g : true;
|
|
24
|
-
this.packageName = options.packageName;
|
|
25
|
-
this.previewImage = options.previewImage;
|
|
26
|
-
this.shortcut = options.shortcut;
|
|
27
|
-
this.refreshWhenResided = (_h = options.refreshWhenResided) !== null && _h !== void 0 ? _h : false;
|
|
28
|
-
this.hideWhenBlur = options.hideWhenBlur == null ? false : options.hideWhenBlur;
|
|
29
|
-
this.supportHostedMode = (_j = options.supportHostedMode) !== null && _j !== void 0 ? _j : HostedMode.NORMAL | HostedMode.OVERLAP;
|
|
30
|
-
this.routes = options.routes;
|
|
31
|
-
}
|
|
32
|
-
getIndexRoute() {
|
|
33
|
-
const result = this.routes.find((it) => it.name.toLowerCase() == 'index');
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
getConfigRoute() {
|
|
37
|
-
return this.routes.find((it) => it.name.toLowerCase() == 'config');
|
|
38
|
-
}
|
|
39
|
-
isConfigurable() {
|
|
40
|
-
return this.getConfigRoute() != null;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 获取组件标题
|
|
44
|
-
* @param lang 语言环境,不传则获取默认语言
|
|
45
|
-
*/
|
|
46
|
-
getTitle(lang) {
|
|
47
|
-
return getTextByLanguageCode(this.title, lang);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 获取组件描述
|
|
51
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
52
|
-
*/
|
|
53
|
-
getDescription(lang) {
|
|
54
|
-
return getTextByLanguageCode(this.description, lang);
|
|
55
|
-
}
|
|
56
|
-
static parseJSON(json) {
|
|
57
|
-
const object = JSON.parse(json);
|
|
58
|
-
return this.parseObject(object);
|
|
59
|
-
}
|
|
60
|
-
static parseObject(obj) {
|
|
61
|
-
let widget = new Widget({
|
|
62
|
-
description: {},
|
|
63
|
-
height: 0,
|
|
64
|
-
keywords: [],
|
|
65
|
-
lang: "zh-CN",
|
|
66
|
-
name: "",
|
|
67
|
-
routes: [],
|
|
68
|
-
title: {},
|
|
69
|
-
width: 0
|
|
70
|
-
});
|
|
71
|
-
Object.assign(widget, obj);
|
|
72
|
-
return widget;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* 是否支持悬浮窗
|
|
76
|
-
*/
|
|
77
|
-
isSupportOverlap() {
|
|
78
|
-
return (this.supportHostedMode & HostedMode.OVERLAP) > 0;
|
|
79
|
-
}
|
|
80
|
-
isResizable() {
|
|
81
|
-
return !(this.minWidth == this.width &&
|
|
82
|
-
this.maxWidth == this.width &&
|
|
83
|
-
this.minHeight == this.height &&
|
|
84
|
-
this.maxHeight == this.height);
|
|
85
|
-
}
|
|
86
|
-
isSupportBackground() {
|
|
87
|
-
return (this.supportHostedMode & HostedMode.BACKGROUND) > 0;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 是否支持普通模式
|
|
91
|
-
*/
|
|
92
|
-
isSupportNormal() {
|
|
93
|
-
return (this.supportHostedMode & HostedMode.NORMAL) > 0;
|
|
94
|
-
}
|
|
95
|
-
isSupportWallpaper() {
|
|
96
|
-
return (this.supportHostedMode & HostedMode.WALLPAPER) > 0;
|
|
97
|
-
}
|
|
98
|
-
isSupportScreen() {
|
|
99
|
-
return (this.supportHostedMode & HostedMode.SCREEN) > 0;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export var WidgetKeyword;
|
|
103
|
-
(function (WidgetKeyword) {
|
|
104
|
-
WidgetKeyword["RECOMMEND"] = "recommend";
|
|
105
|
-
WidgetKeyword["TOOLS"] = "tools";
|
|
106
|
-
WidgetKeyword["EFFICIENCY"] = "efficiency";
|
|
107
|
-
WidgetKeyword["PICTURE"] = "picture";
|
|
108
|
-
WidgetKeyword["LIFE"] = "life";
|
|
109
|
-
WidgetKeyword["SHORTCUT"] = "shortcut";
|
|
110
|
-
WidgetKeyword["COUNTDOWN"] = "countdown";
|
|
111
|
-
WidgetKeyword["TIMER"] = "timer";
|
|
112
|
-
WidgetKeyword["INFO"] = "info";
|
|
113
|
-
WidgetKeyword["DASHBOARD"] = "dashboard";
|
|
114
|
-
})(WidgetKeyword || (WidgetKeyword = {}));
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { Widget } from "./Widget";
|
|
2
|
-
import { UrlUtils } from "../utils/UrlUtils";
|
|
3
|
-
import { getTextByLanguageCode } from "../utils/LanguageUtils";
|
|
4
|
-
export class WidgetPackage {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
/**
|
|
7
|
-
* Hash路由模式,默认为true
|
|
8
|
-
*/
|
|
9
|
-
this.hash = true;
|
|
10
|
-
this.widgets = [];
|
|
11
|
-
this.name = options.name;
|
|
12
|
-
this.version = options.version;
|
|
13
|
-
this.author = options.author;
|
|
14
|
-
this.homepage = options.homepage;
|
|
15
|
-
this.title = options.title;
|
|
16
|
-
this.description = options.description;
|
|
17
|
-
this.entry = options.entry;
|
|
18
|
-
this.remoteEntry = options.remoteEntry;
|
|
19
|
-
this.remotePackage = options.remotePackage;
|
|
20
|
-
this.hash = options.hash;
|
|
21
|
-
this.url = options.url;
|
|
22
|
-
this.icon = options.icon;
|
|
23
|
-
this.devOptions = options.devOptions;
|
|
24
|
-
if (options.widgets) {
|
|
25
|
-
for (let widget of options.widgets) {
|
|
26
|
-
this.widgets.push(widget);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
static parseJSON(json) {
|
|
31
|
-
const object = JSON.parse(json);
|
|
32
|
-
return this.parseObject(object);
|
|
33
|
-
}
|
|
34
|
-
static parseObject(obj) {
|
|
35
|
-
let widgetPackage = new WidgetPackage({
|
|
36
|
-
author: "",
|
|
37
|
-
description: {
|
|
38
|
-
"zh-CN": "",
|
|
39
|
-
},
|
|
40
|
-
entry: "",
|
|
41
|
-
hash: false,
|
|
42
|
-
homepage: "",
|
|
43
|
-
name: "",
|
|
44
|
-
title: {
|
|
45
|
-
"zh-CN": "",
|
|
46
|
-
},
|
|
47
|
-
url: "",
|
|
48
|
-
version: ""
|
|
49
|
-
});
|
|
50
|
-
Object.assign(widgetPackage, obj);
|
|
51
|
-
const widgets = [];
|
|
52
|
-
if (widgetPackage.widgets) {
|
|
53
|
-
for (let jsonWidget of widgetPackage.widgets) {
|
|
54
|
-
let widget = new Widget({
|
|
55
|
-
description: { "zh-CN": "" },
|
|
56
|
-
height: 0,
|
|
57
|
-
keywords: [],
|
|
58
|
-
lang: "zh-CN",
|
|
59
|
-
name: '',
|
|
60
|
-
routes: [],
|
|
61
|
-
title: { "zh-CN": "" },
|
|
62
|
-
width: 0
|
|
63
|
-
});
|
|
64
|
-
Object.assign(widget, jsonWidget);
|
|
65
|
-
widgets.push(widget);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
widgetPackage.widgets.splice(0, widgetPackage.widgets.length);
|
|
69
|
-
widgetPackage.widgets.push(...widgets);
|
|
70
|
-
return widgetPackage;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* 获取组件包标题
|
|
74
|
-
* @param lang 语言环境,不传则获取默认语言
|
|
75
|
-
*/
|
|
76
|
-
getTitle(lang) {
|
|
77
|
-
return getTextByLanguageCode(this.title, lang);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 获取组件包描述
|
|
81
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
82
|
-
*/
|
|
83
|
-
getDescription(lang) {
|
|
84
|
-
return getTextByLanguageCode(this.description, lang);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 获取组件完整路径
|
|
88
|
-
* 如果url是http链接,直接返回链接
|
|
89
|
-
* 如果是本地组件:file://链接,则返回 url+entry,e.g. file://C:\users\neo\desktop\index.html#
|
|
90
|
-
*/
|
|
91
|
-
getIndexUrl(hash) {
|
|
92
|
-
return UrlUtils.getWidgetPackageIndexUrl(this.url, this.entry, hash == null ? this.hash : hash);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 组件参数,如宽,高,id,语言等环境参数
|
|
3
|
-
*/
|
|
4
|
-
import { parseQuery } from "../router/query";
|
|
5
|
-
import { snakeCase } from "change-case";
|
|
6
|
-
export class WidgetParams {
|
|
7
|
-
/**
|
|
8
|
-
* 将组件参数转为url参数
|
|
9
|
-
* @param object
|
|
10
|
-
* @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
|
|
11
|
-
*/
|
|
12
|
-
toUrlParams() {
|
|
13
|
-
const urlParams = new URLSearchParams();
|
|
14
|
-
const ownPropertyNames = Object.getOwnPropertyNames(this);
|
|
15
|
-
for (let ownPropertyName of ownPropertyNames) {
|
|
16
|
-
const key = ownPropertyName;
|
|
17
|
-
const value = this[key];
|
|
18
|
-
if (value) {
|
|
19
|
-
urlParams.append(WidgetParams.PARAM_PREFIX + snakeCase(ownPropertyName), value.toString());
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return urlParams;
|
|
23
|
-
}
|
|
24
|
-
getPersistKey() {
|
|
25
|
-
return `${this.name}-${this.id}`;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* 从当前地址解析组件参数:
|
|
29
|
-
* http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
|
|
30
|
-
* =>
|
|
31
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
32
|
-
*/
|
|
33
|
-
static fromCurrentLocation() {
|
|
34
|
-
const href = window.location.href;
|
|
35
|
-
let strings = href.split("?");
|
|
36
|
-
if (strings.length > 1) {
|
|
37
|
-
let queryString = strings[1];
|
|
38
|
-
return this.fromObject(parseQuery(queryString));
|
|
39
|
-
}
|
|
40
|
-
return new WidgetParams();
|
|
41
|
-
}
|
|
42
|
-
static fromLocation(url) {
|
|
43
|
-
let strings = url.split("?");
|
|
44
|
-
if (strings.length > 1) {
|
|
45
|
-
let queryString = strings[1];
|
|
46
|
-
return this.fromObject(parseQuery(queryString));
|
|
47
|
-
}
|
|
48
|
-
return new WidgetParams();
|
|
49
|
-
}
|
|
50
|
-
static setValue(widgetEnv, key, value) {
|
|
51
|
-
const keyWithoutPrefix = key.replace(this.PARAM_PREFIX, "");
|
|
52
|
-
if (keyWithoutPrefix == WidgetParams.PARAM_ID) {
|
|
53
|
-
widgetEnv.id = value;
|
|
54
|
-
}
|
|
55
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_X) {
|
|
56
|
-
widgetEnv.x = parseInt(value);
|
|
57
|
-
}
|
|
58
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_Y) {
|
|
59
|
-
widgetEnv.y = parseInt(value);
|
|
60
|
-
}
|
|
61
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT) {
|
|
62
|
-
widgetEnv.height = parseInt(value);
|
|
63
|
-
}
|
|
64
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH) {
|
|
65
|
-
widgetEnv.width = parseInt(value);
|
|
66
|
-
}
|
|
67
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_LANG) {
|
|
68
|
-
widgetEnv.lang = value;
|
|
69
|
-
}
|
|
70
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_THEME) {
|
|
71
|
-
widgetEnv.theme = value;
|
|
72
|
-
}
|
|
73
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_MODE) {
|
|
74
|
-
widgetEnv.mode = parseInt(value);
|
|
75
|
-
}
|
|
76
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_RADIUS) {
|
|
77
|
-
widgetEnv.radius = parseInt(value);
|
|
78
|
-
}
|
|
79
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH_PX) {
|
|
80
|
-
widgetEnv.widthPx = parseInt(value);
|
|
81
|
-
}
|
|
82
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT_PX) {
|
|
83
|
-
widgetEnv.heightPx = parseInt(value);
|
|
84
|
-
}
|
|
85
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_NAME) {
|
|
86
|
-
widgetEnv.name = value;
|
|
87
|
-
}
|
|
88
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_TITLE) {
|
|
89
|
-
widgetEnv.title = value;
|
|
90
|
-
}
|
|
91
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_PREVIEW) {
|
|
92
|
-
widgetEnv.preview = (value === 'true');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* 从对象键值对中初始化组件参数
|
|
97
|
-
* {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
|
|
98
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
99
|
-
* @param object
|
|
100
|
-
*/
|
|
101
|
-
static fromObject(object) {
|
|
102
|
-
const widgetEnv = new WidgetParams();
|
|
103
|
-
const ownPropertyNames = Object.getOwnPropertyNames(object);
|
|
104
|
-
for (let ownPropertyName of ownPropertyNames) {
|
|
105
|
-
const key = ownPropertyName;
|
|
106
|
-
const value = object[key];
|
|
107
|
-
this.setValue(widgetEnv, key, value);
|
|
108
|
-
}
|
|
109
|
-
return widgetEnv;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
WidgetParams.PARAM_PREFIX = "w_";
|
|
113
|
-
WidgetParams.PARAM_ID = "id";
|
|
114
|
-
WidgetParams.PARAM_WIDTH = "width";
|
|
115
|
-
WidgetParams.PARAM_HEIGHT = "height";
|
|
116
|
-
WidgetParams.PARAM_WIDTH_PX = "width_px";
|
|
117
|
-
WidgetParams.PARAM_HEIGHT_PX = "height_px";
|
|
118
|
-
WidgetParams.PARAM_X = "x";
|
|
119
|
-
WidgetParams.PARAM_Y = "y";
|
|
120
|
-
WidgetParams.PARAM_LANG = "lang";
|
|
121
|
-
WidgetParams.PARAM_THEME = "theme";
|
|
122
|
-
WidgetParams.PARAM_MODE = "mode";
|
|
123
|
-
WidgetParams.PARAM_RADIUS = "radius";
|
|
124
|
-
WidgetParams.PARAM_NAME = "name";
|
|
125
|
-
WidgetParams.PARAM_TITLE = "title";
|
|
126
|
-
WidgetParams.PARAM_PREVIEW = "preview";
|
|
127
|
-
WidgetParams.PARAMS = [
|
|
128
|
-
WidgetParams.PARAM_ID,
|
|
129
|
-
WidgetParams.PARAM_WIDTH,
|
|
130
|
-
WidgetParams.PARAM_HEIGHT,
|
|
131
|
-
WidgetParams.PARAM_X,
|
|
132
|
-
WidgetParams.PARAM_Y,
|
|
133
|
-
WidgetParams.PARAM_LANG,
|
|
134
|
-
WidgetParams.PARAM_THEME,
|
|
135
|
-
WidgetParams.PARAM_MODE,
|
|
136
|
-
WidgetParams.PARAM_WIDTH_PX,
|
|
137
|
-
WidgetParams.PARAM_HEIGHT_PX,
|
|
138
|
-
WidgetParams.PARAM_NAME,
|
|
139
|
-
WidgetParams.PARAM_TITLE,
|
|
140
|
-
WidgetParams.PARAM_PREVIEW,
|
|
141
|
-
];
|
|
142
|
-
export var ThemeMode;
|
|
143
|
-
(function (ThemeMode) {
|
|
144
|
-
ThemeMode["AUTO"] = "auto";
|
|
145
|
-
ThemeMode["LIGHT"] = "LIGHT";
|
|
146
|
-
ThemeMode["DARK"] = "DARK";
|
|
147
|
-
})(ThemeMode || (ThemeMode = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export var WebSocketEventType;
|
|
2
|
-
(function (WebSocketEventType) {
|
|
3
|
-
WebSocketEventType["RESISTER_WIDGETS"] = "ws::cn.widgetjs.core.resister_widgets";
|
|
4
|
-
})(WebSocketEventType || (WebSocketEventType = {}));
|
|
5
|
-
export class WebSocketEvent {
|
|
6
|
-
constructor(type, payload) {
|
|
7
|
-
this.type = type;
|
|
8
|
-
this.payload = payload;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Encoding Rules ␣ = Space Path: ␣ " < > # ? { } Query: ␣ " < > # & = Hash: ␣ "
|
|
3
|
-
* < > `
|
|
4
|
-
*
|
|
5
|
-
* On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
|
|
6
|
-
* defines some extra characters to be encoded. Most browsers do not encode them
|
|
7
|
-
* in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
|
|
8
|
-
* also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
|
|
9
|
-
* plus `-._~`. This extra safety should be applied to query by patching the
|
|
10
|
-
* string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
|
|
11
|
-
* should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
|
|
12
|
-
* into a `/` if directly typed in. The _backtick_ (`````) should also be
|
|
13
|
-
* encoded everywhere because some browsers like FF encode it when directly
|
|
14
|
-
* written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
|
|
15
|
-
*/
|
|
16
|
-
// const EXTRA_RESERVED_RE = /[!'()*]/g
|
|
17
|
-
// const encodeReservedReplacer = (c: string) => '%' + c.charCodeAt(0).toString(16)
|
|
18
|
-
const HASH_RE = /#/g; // %23
|
|
19
|
-
const AMPERSAND_RE = /&/g; // %26
|
|
20
|
-
const SLASH_RE = /\//g; // %2F
|
|
21
|
-
const EQUAL_RE = /=/g; // %3D
|
|
22
|
-
const IM_RE = /\?/g; // %3F
|
|
23
|
-
export const PLUS_RE = /\+/g; // %2B
|
|
24
|
-
/**
|
|
25
|
-
* NOTE: It's not clear to me if we should encode the + symbol in queries, it
|
|
26
|
-
* seems to be less flexible than not doing so and I can't find out the legacy
|
|
27
|
-
* systems requiring this for regular requests like text/html. In the standard,
|
|
28
|
-
* the encoding of the plus character is only mentioned for
|
|
29
|
-
* application/x-www-form-urlencoded
|
|
30
|
-
* (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
|
|
31
|
-
* leave the plus character as is in queries. To be more flexible, we allow the
|
|
32
|
-
* plus character on the query, but it can also be manually encoded by the user.
|
|
33
|
-
*
|
|
34
|
-
* Resources:
|
|
35
|
-
* - https://url.spec.whatwg.org/#urlencoded-parsing
|
|
36
|
-
* - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
|
|
37
|
-
*/
|
|
38
|
-
const ENC_BRACKET_OPEN_RE = /%5B/g; // [
|
|
39
|
-
const ENC_BRACKET_CLOSE_RE = /%5D/g; // ]
|
|
40
|
-
const ENC_CARET_RE = /%5E/g; // ^
|
|
41
|
-
const ENC_BACKTICK_RE = /%60/g; // `
|
|
42
|
-
const ENC_CURLY_OPEN_RE = /%7B/g; // {
|
|
43
|
-
const ENC_PIPE_RE = /%7C/g; // |
|
|
44
|
-
const ENC_CURLY_CLOSE_RE = /%7D/g; // }
|
|
45
|
-
const ENC_SPACE_RE = /%20/g; // }
|
|
46
|
-
/**
|
|
47
|
-
* Encode characters that need to be encoded on the path, search and hash
|
|
48
|
-
* sections of the URL.
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
* @param text - string to encode
|
|
52
|
-
* @returns encoded string
|
|
53
|
-
*/
|
|
54
|
-
function commonEncode(text) {
|
|
55
|
-
return encodeURI('' + text)
|
|
56
|
-
.replace(ENC_PIPE_RE, '|')
|
|
57
|
-
.replace(ENC_BRACKET_OPEN_RE, '[')
|
|
58
|
-
.replace(ENC_BRACKET_CLOSE_RE, ']');
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Encode characters that need to be encoded on the hash section of the URL.
|
|
62
|
-
*
|
|
63
|
-
* @param text - string to encode
|
|
64
|
-
* @returns encoded string
|
|
65
|
-
*/
|
|
66
|
-
export function encodeHash(text) {
|
|
67
|
-
return commonEncode(text)
|
|
68
|
-
.replace(ENC_CURLY_OPEN_RE, '{')
|
|
69
|
-
.replace(ENC_CURLY_CLOSE_RE, '}')
|
|
70
|
-
.replace(ENC_CARET_RE, '^');
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Encode characters that need to be encoded query values on the query
|
|
74
|
-
* section of the URL.
|
|
75
|
-
*
|
|
76
|
-
* @param text - string to encode
|
|
77
|
-
* @returns encoded string
|
|
78
|
-
*/
|
|
79
|
-
export function encodeQueryValue(text) {
|
|
80
|
-
return (commonEncode(text)
|
|
81
|
-
// Encode the space as +, encode the + to differentiate it from the space
|
|
82
|
-
.replace(PLUS_RE, '%2B')
|
|
83
|
-
.replace(ENC_SPACE_RE, '+')
|
|
84
|
-
.replace(HASH_RE, '%23')
|
|
85
|
-
.replace(AMPERSAND_RE, '%26')
|
|
86
|
-
.replace(ENC_BACKTICK_RE, '`')
|
|
87
|
-
.replace(ENC_CURLY_OPEN_RE, '{')
|
|
88
|
-
.replace(ENC_CURLY_CLOSE_RE, '}')
|
|
89
|
-
.replace(ENC_CARET_RE, '^'));
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Like `encodeQueryValue` but also encodes the `=` character.
|
|
93
|
-
*
|
|
94
|
-
* @param text - string to encode
|
|
95
|
-
*/
|
|
96
|
-
export function encodeQueryKey(text) {
|
|
97
|
-
return encodeQueryValue(text).replace(EQUAL_RE, '%3D');
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Encode characters that need to be encoded on the path section of the URL.
|
|
101
|
-
*
|
|
102
|
-
* @param text - string to encode
|
|
103
|
-
* @returns encoded string
|
|
104
|
-
*/
|
|
105
|
-
export function encodePath(text) {
|
|
106
|
-
return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F');
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Encode characters that need to be encoded on the path section of the URL as a
|
|
110
|
-
* param. This function encodes everything {@link encodePath} does plus the
|
|
111
|
-
* slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
|
|
112
|
-
* string instead.
|
|
113
|
-
*
|
|
114
|
-
* @param text - string to encode
|
|
115
|
-
* @returns encoded string
|
|
116
|
-
*/
|
|
117
|
-
export function encodeParam(text) {
|
|
118
|
-
return text == null ? '' : encodePath(text).replace(SLASH_RE, '%2F');
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Decode text using `decodeURIComponent`. Returns the original text if it
|
|
122
|
-
* fails.
|
|
123
|
-
*
|
|
124
|
-
* @param text - string to decode
|
|
125
|
-
* @returns decoded string
|
|
126
|
-
*/
|
|
127
|
-
export function decode(text) {
|
|
128
|
-
try {
|
|
129
|
-
return decodeURIComponent('' + text);
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
// __DEV__ && warn(`Error decoding "${text}". Using original value`)
|
|
133
|
-
}
|
|
134
|
-
return '' + text;
|
|
135
|
-
}
|
package/dist/esm/router/query.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { decode, encodeQueryKey, encodeQueryValue, PLUS_RE } from './encoding';
|
|
2
|
-
const isArray = Array.isArray;
|
|
3
|
-
/**
|
|
4
|
-
* Transforms a queryString into a {@link LocationQuery} object. Accept both, a
|
|
5
|
-
* version with the leading `?` and without Should work as URLSearchParams
|
|
6
|
-
* @internal
|
|
7
|
-
*
|
|
8
|
-
* @param search - search string to parse
|
|
9
|
-
* @returns a query object
|
|
10
|
-
*/
|
|
11
|
-
export function parseQuery(search) {
|
|
12
|
-
const query = {};
|
|
13
|
-
// avoid creating an object with an empty key and empty value
|
|
14
|
-
// because of split('&')
|
|
15
|
-
if (search === '' || search === '?')
|
|
16
|
-
return query;
|
|
17
|
-
const hasLeadingIM = search[0] === '?';
|
|
18
|
-
const searchParams = (hasLeadingIM ? search.slice(1) : search).split('&');
|
|
19
|
-
for (let i = 0; i < searchParams.length; ++i) {
|
|
20
|
-
// pre decode the + into space
|
|
21
|
-
const searchParam = searchParams[i].replace(PLUS_RE, ' ');
|
|
22
|
-
// allow the = character
|
|
23
|
-
const eqPos = searchParam.indexOf('=');
|
|
24
|
-
const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
|
|
25
|
-
const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
|
|
26
|
-
if (key in query) {
|
|
27
|
-
// an extra variable for ts types
|
|
28
|
-
let currentValue = query[key];
|
|
29
|
-
if (!isArray(currentValue)) {
|
|
30
|
-
currentValue = query[key] = [currentValue];
|
|
31
|
-
}
|
|
32
|
-
// we force the modification
|
|
33
|
-
;
|
|
34
|
-
currentValue.push(value);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
query[key] = value;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return query;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
|
|
44
|
-
* doesn't prepend a `?`
|
|
45
|
-
*
|
|
46
|
-
* @internal
|
|
47
|
-
*
|
|
48
|
-
* @param query - query object to stringify
|
|
49
|
-
* @returns string version of the query without the leading `?`
|
|
50
|
-
*/
|
|
51
|
-
export function stringifyQuery(query) {
|
|
52
|
-
let search = '';
|
|
53
|
-
for (let key in query) {
|
|
54
|
-
const value = query[key];
|
|
55
|
-
key = encodeQueryKey(key);
|
|
56
|
-
if (value == null) {
|
|
57
|
-
// only null adds the value
|
|
58
|
-
if (value !== undefined) {
|
|
59
|
-
search += (search.length ? '&' : '') + key;
|
|
60
|
-
}
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
// keep null values
|
|
64
|
-
const values = isArray(value)
|
|
65
|
-
? value.map(v => v && encodeQueryValue(v))
|
|
66
|
-
: [value && encodeQueryValue(value)];
|
|
67
|
-
values.forEach(value => {
|
|
68
|
-
// skip undefined values in arrays as if they were not present
|
|
69
|
-
// smaller code than using filter
|
|
70
|
-
if (value !== undefined) {
|
|
71
|
-
// only append & with non-empty search
|
|
72
|
-
search += (search.length ? '&' : '') + key;
|
|
73
|
-
if (value != null)
|
|
74
|
-
search += '=' + value;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return search;
|
|
79
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export class ElectronUtils {
|
|
2
|
-
static hasElectronApi() {
|
|
3
|
-
return this.getAPI() != null;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* 获取ElectronAPI
|
|
7
|
-
* windows api
|
|
8
|
-
*/
|
|
9
|
-
static getAPI() {
|
|
10
|
-
if (Reflect.has(window, "electronAPI")) {
|
|
11
|
-
//@ts-ignore
|
|
12
|
-
return window.electronAPI;
|
|
13
|
-
}
|
|
14
|
-
else if (Reflect.has(window.parent, "electronAPI")) {
|
|
15
|
-
//@ts-ignore
|
|
16
|
-
return window.parent.electronAPI;
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
static async invokeMethod(channel, method, ...args) {
|
|
21
|
-
var _a;
|
|
22
|
-
return (_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(channel, method, ...args);
|
|
23
|
-
}
|
|
24
|
-
static async invoke(channel, ...args) {
|
|
25
|
-
var _a;
|
|
26
|
-
return (_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(channel, ...args);
|
|
27
|
-
}
|
|
28
|
-
}
|