@widget-js/core 0.0.2 → 0.0.5
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/package.json +6 -8
- package/src/api/ElectronApi.ts +22 -0
- package/{dist/esm/index.js → src/index.ts} +1 -0
- package/{dist/types/model/Widget.d.ts → src/model/Widget.ts} +43 -8
- package/dist/cjs/api/ElectronApi.js +0 -73
- package/dist/cjs/index.js +0 -18
- package/dist/cjs/model/Widget.js +0 -60
- package/dist/esm/api/ElectronApi.js +0 -70
- package/dist/esm/model/Widget.js +0 -57
- package/dist/types/api/ElectronApi.d.ts +0 -6
- package/dist/types/index.d.ts +0 -2
- package/dist/umd/index.js +0 -1
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widget-js/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/cjs/index.js",
|
|
6
|
-
"module": "dist/esm/index.js",
|
|
7
|
-
"umd:main": "dist/umd/index.js",
|
|
8
|
-
"types": "dist/types/index.d.js",
|
|
9
5
|
"publishConfig": {
|
|
10
6
|
"access": "public"
|
|
11
7
|
},
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": "./dist/esm",
|
|
12
10
|
"scripts": {
|
|
13
|
-
"_postinstall": "husky install",
|
|
14
11
|
"prepublishOnly": "pinst --disable",
|
|
15
12
|
"test": "jest --no-cache --runInBand",
|
|
16
13
|
"test:cov": "jest --coverage --no-cache --runInBand",
|
|
@@ -33,7 +30,7 @@
|
|
|
33
30
|
"url": "https://github.com/widom-widget/core/issues"
|
|
34
31
|
},
|
|
35
32
|
"files": [
|
|
36
|
-
"
|
|
33
|
+
"src"
|
|
37
34
|
],
|
|
38
35
|
"devDependencies": {
|
|
39
36
|
"@babel/cli": "^7.19.3",
|
|
@@ -50,5 +47,6 @@
|
|
|
50
47
|
"typescript": "^4.9.3",
|
|
51
48
|
"webpack": "^5.75.0",
|
|
52
49
|
"webpack-cli": "^5.0.0"
|
|
53
|
-
}
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {}
|
|
54
52
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Widget} from "../model/Widget"
|
|
2
|
+
|
|
3
|
+
export class ElectronApi {
|
|
4
|
+
static openAddWidgetWindow() {
|
|
5
|
+
if (this.hasElectronApi()) {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
window.electronAPI.invokeIpc("openAddWidgetWindow");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static async registerWidgets(widgets: Widget[]) {
|
|
12
|
+
if (this.hasElectronApi()) {
|
|
13
|
+
const data = JSON.parse(JSON.stringify(widgets.map(item => item.stringify())));
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
await window.electronAPI.invokeIpc("registerWidgets", data);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static hasElectronApi(): boolean {
|
|
20
|
+
return Reflect.has(window, "electronAPI")
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export class Widget {
|
|
2
|
+
//组件名称,名称与包名类似,e.g. com.example.countdown
|
|
2
3
|
readonly name: string;
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* 组件标题,显示在界面上的,
|
|
5
7
|
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
@@ -13,7 +15,7 @@ export declare class Widget {
|
|
|
13
15
|
/**
|
|
14
16
|
* 组件默认语言
|
|
15
17
|
*/
|
|
16
|
-
readonly lang: string;
|
|
18
|
+
readonly lang: string = "zh";
|
|
17
19
|
readonly w: number;
|
|
18
20
|
readonly h: number;
|
|
19
21
|
readonly maxW: number;
|
|
@@ -21,22 +23,53 @@ export declare class Widget {
|
|
|
21
23
|
readonly minW: number;
|
|
22
24
|
readonly minH: number;
|
|
23
25
|
readonly url: string;
|
|
26
|
+
//组件配置url
|
|
24
27
|
readonly configUrl?: string | null;
|
|
25
28
|
readonly debugUrl?: string;
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
constructor(name: string, title: Map<string, string>, desc: Map<string, string>, keywords: WidgetKeyword[], lang: string, w: number, h: number, maxW: number, maxH: number, minW: number, minH: number, url: string, configUrl?: string | null, debugUrl?: string) {
|
|
31
|
+
this.name = name;
|
|
32
|
+
this.title = title;
|
|
33
|
+
this.desc = desc;
|
|
34
|
+
this.keywords = keywords;
|
|
35
|
+
this.lang = lang;
|
|
36
|
+
this.w = w;
|
|
37
|
+
this.h = h;
|
|
38
|
+
this.maxW = maxW;
|
|
39
|
+
this.maxH = maxH;
|
|
40
|
+
this.minW = minW;
|
|
41
|
+
this.minH = minH;
|
|
42
|
+
this.url = url;
|
|
43
|
+
this.configUrl = configUrl;
|
|
44
|
+
this.debugUrl = debugUrl;
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
/**
|
|
28
48
|
* 获取组件标题
|
|
29
49
|
* @param lang 语言环境,不传则获取默认语言
|
|
30
50
|
*/
|
|
31
|
-
getTitle(lang?: string): string | undefined
|
|
51
|
+
getTitle(lang?: string): string | undefined {
|
|
52
|
+
return lang ? this.title.get(lang) : this.title.get(this.lang);
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
/**
|
|
33
56
|
* 获取组件标描述
|
|
34
57
|
* @param lang 语言环境,不传则获取默认标题
|
|
35
58
|
*/
|
|
36
|
-
getDesc(lang?: string): string | undefined
|
|
37
|
-
|
|
59
|
+
getDesc(lang?: string): string | undefined {
|
|
60
|
+
return lang ? this.desc.get(lang) : this.desc.get(this.lang);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
stringify(): string {
|
|
64
|
+
const jsonObject = JSON.parse(JSON.stringify(this));
|
|
65
|
+
jsonObject["title"] = Object.fromEntries(this.title);
|
|
66
|
+
jsonObject["desc"] = Object.fromEntries(this.desc);
|
|
67
|
+
return JSON.stringify(jsonObject);
|
|
68
|
+
}
|
|
38
69
|
}
|
|
39
|
-
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
export enum WidgetKeyword {
|
|
40
73
|
RECOMMEND = "recommend",
|
|
41
74
|
TOOLS = "tools",
|
|
42
75
|
EFFICIENCY = "efficiency",
|
|
@@ -46,5 +79,7 @@ export declare enum WidgetKeyword {
|
|
|
46
79
|
COUNTDOWN = "countdown",
|
|
47
80
|
TIMER = "timer",
|
|
48
81
|
INFO = "info",
|
|
49
|
-
DASHBOARD = "dashboard"
|
|
82
|
+
DASHBOARD = "dashboard",
|
|
50
83
|
}
|
|
84
|
+
|
|
85
|
+
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ElectronApi = void 0;
|
|
40
|
-
var ElectronApi = /** @class */ (function () {
|
|
41
|
-
function ElectronApi() {
|
|
42
|
-
}
|
|
43
|
-
ElectronApi.openAddWidgetWindow = function () {
|
|
44
|
-
if (this.hasElectronApi()) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
window.electronAPI.invokeIpc("openAddWidgetWindow");
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
ElectronApi.registerWidgets = function (widgets) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
var data;
|
|
52
|
-
return __generator(this, function (_a) {
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0:
|
|
55
|
-
if (!this.hasElectronApi()) return [3 /*break*/, 2];
|
|
56
|
-
data = JSON.parse(JSON.stringify(widgets.map(function (item) { return item.stringify(); })));
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
return [4 /*yield*/, window.electronAPI.invokeIpc("registerWidgets", data)];
|
|
59
|
-
case 1:
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
_a.sent();
|
|
62
|
-
_a.label = 2;
|
|
63
|
-
case 2: return [2 /*return*/];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
ElectronApi.hasElectronApi = function () {
|
|
69
|
-
return Reflect.has(window, "electronAPI");
|
|
70
|
-
};
|
|
71
|
-
return ElectronApi;
|
|
72
|
-
}());
|
|
73
|
-
exports.ElectronApi = ElectronApi;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./model/Widget"), exports);
|
|
18
|
-
__exportStar(require("./api/ElectronApi"), exports);
|
package/dist/cjs/model/Widget.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WidgetKeyword = exports.Widget = void 0;
|
|
4
|
-
var Widget = /** @class */ (function () {
|
|
5
|
-
function Widget(name, title, desc, keywords, lang, w, h, maxW, maxH, minW, minH, url, configUrl, debugUrl) {
|
|
6
|
-
/**
|
|
7
|
-
* 组件默认语言
|
|
8
|
-
*/
|
|
9
|
-
this.lang = "zh";
|
|
10
|
-
this.name = name;
|
|
11
|
-
this.title = title;
|
|
12
|
-
this.desc = desc;
|
|
13
|
-
this.keywords = keywords;
|
|
14
|
-
this.lang = lang;
|
|
15
|
-
this.w = w;
|
|
16
|
-
this.h = h;
|
|
17
|
-
this.maxW = maxW;
|
|
18
|
-
this.maxH = maxH;
|
|
19
|
-
this.minW = minW;
|
|
20
|
-
this.minH = minH;
|
|
21
|
-
this.url = url;
|
|
22
|
-
this.configUrl = configUrl;
|
|
23
|
-
this.debugUrl = debugUrl;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 获取组件标题
|
|
27
|
-
* @param lang 语言环境,不传则获取默认语言
|
|
28
|
-
*/
|
|
29
|
-
Widget.prototype.getTitle = function (lang) {
|
|
30
|
-
return lang ? this.title.get(lang) : this.title.get(this.lang);
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* 获取组件标描述
|
|
34
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
35
|
-
*/
|
|
36
|
-
Widget.prototype.getDesc = function (lang) {
|
|
37
|
-
return lang ? this.desc.get(lang) : this.desc.get(this.lang);
|
|
38
|
-
};
|
|
39
|
-
Widget.prototype.stringify = function () {
|
|
40
|
-
var jsonObject = JSON.parse(JSON.stringify(this));
|
|
41
|
-
jsonObject["title"] = Object.fromEntries(this.title);
|
|
42
|
-
jsonObject["desc"] = Object.fromEntries(this.desc);
|
|
43
|
-
return JSON.stringify(jsonObject);
|
|
44
|
-
};
|
|
45
|
-
return Widget;
|
|
46
|
-
}());
|
|
47
|
-
exports.Widget = Widget;
|
|
48
|
-
var WidgetKeyword;
|
|
49
|
-
(function (WidgetKeyword) {
|
|
50
|
-
WidgetKeyword["RECOMMEND"] = "recommend";
|
|
51
|
-
WidgetKeyword["TOOLS"] = "tools";
|
|
52
|
-
WidgetKeyword["EFFICIENCY"] = "efficiency";
|
|
53
|
-
WidgetKeyword["PICTURE"] = "picture";
|
|
54
|
-
WidgetKeyword["LIFE"] = "life";
|
|
55
|
-
WidgetKeyword["SHORTCUT"] = "shortcut";
|
|
56
|
-
WidgetKeyword["COUNTDOWN"] = "countdown";
|
|
57
|
-
WidgetKeyword["TIMER"] = "timer";
|
|
58
|
-
WidgetKeyword["INFO"] = "info";
|
|
59
|
-
WidgetKeyword["DASHBOARD"] = "dashboard";
|
|
60
|
-
})(WidgetKeyword = exports.WidgetKeyword || (exports.WidgetKeyword = {}));
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var ElectronApi = /** @class */ (function () {
|
|
38
|
-
function ElectronApi() {
|
|
39
|
-
}
|
|
40
|
-
ElectronApi.openAddWidgetWindow = function () {
|
|
41
|
-
if (this.hasElectronApi()) {
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
window.electronAPI.invokeIpc("openAddWidgetWindow");
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
ElectronApi.registerWidgets = function (widgets) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var data;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
if (!this.hasElectronApi()) return [3 /*break*/, 2];
|
|
53
|
-
data = JSON.parse(JSON.stringify(widgets.map(function (item) { return item.stringify(); })));
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
return [4 /*yield*/, window.electronAPI.invokeIpc("registerWidgets", data)];
|
|
56
|
-
case 1:
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
_a.sent();
|
|
59
|
-
_a.label = 2;
|
|
60
|
-
case 2: return [2 /*return*/];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
ElectronApi.hasElectronApi = function () {
|
|
66
|
-
return Reflect.has(window, "electronAPI");
|
|
67
|
-
};
|
|
68
|
-
return ElectronApi;
|
|
69
|
-
}());
|
|
70
|
-
export { ElectronApi };
|
package/dist/esm/model/Widget.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
var Widget = /** @class */ (function () {
|
|
2
|
-
function Widget(name, title, desc, keywords, lang, w, h, maxW, maxH, minW, minH, url, configUrl, debugUrl) {
|
|
3
|
-
/**
|
|
4
|
-
* 组件默认语言
|
|
5
|
-
*/
|
|
6
|
-
this.lang = "zh";
|
|
7
|
-
this.name = name;
|
|
8
|
-
this.title = title;
|
|
9
|
-
this.desc = desc;
|
|
10
|
-
this.keywords = keywords;
|
|
11
|
-
this.lang = lang;
|
|
12
|
-
this.w = w;
|
|
13
|
-
this.h = h;
|
|
14
|
-
this.maxW = maxW;
|
|
15
|
-
this.maxH = maxH;
|
|
16
|
-
this.minW = minW;
|
|
17
|
-
this.minH = minH;
|
|
18
|
-
this.url = url;
|
|
19
|
-
this.configUrl = configUrl;
|
|
20
|
-
this.debugUrl = debugUrl;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 获取组件标题
|
|
24
|
-
* @param lang 语言环境,不传则获取默认语言
|
|
25
|
-
*/
|
|
26
|
-
Widget.prototype.getTitle = function (lang) {
|
|
27
|
-
return lang ? this.title.get(lang) : this.title.get(this.lang);
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 获取组件标描述
|
|
31
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
32
|
-
*/
|
|
33
|
-
Widget.prototype.getDesc = function (lang) {
|
|
34
|
-
return lang ? this.desc.get(lang) : this.desc.get(this.lang);
|
|
35
|
-
};
|
|
36
|
-
Widget.prototype.stringify = function () {
|
|
37
|
-
var jsonObject = JSON.parse(JSON.stringify(this));
|
|
38
|
-
jsonObject["title"] = Object.fromEntries(this.title);
|
|
39
|
-
jsonObject["desc"] = Object.fromEntries(this.desc);
|
|
40
|
-
return JSON.stringify(jsonObject);
|
|
41
|
-
};
|
|
42
|
-
return Widget;
|
|
43
|
-
}());
|
|
44
|
-
export { Widget };
|
|
45
|
-
export var WidgetKeyword;
|
|
46
|
-
(function (WidgetKeyword) {
|
|
47
|
-
WidgetKeyword["RECOMMEND"] = "recommend";
|
|
48
|
-
WidgetKeyword["TOOLS"] = "tools";
|
|
49
|
-
WidgetKeyword["EFFICIENCY"] = "efficiency";
|
|
50
|
-
WidgetKeyword["PICTURE"] = "picture";
|
|
51
|
-
WidgetKeyword["LIFE"] = "life";
|
|
52
|
-
WidgetKeyword["SHORTCUT"] = "shortcut";
|
|
53
|
-
WidgetKeyword["COUNTDOWN"] = "countdown";
|
|
54
|
-
WidgetKeyword["TIMER"] = "timer";
|
|
55
|
-
WidgetKeyword["INFO"] = "info";
|
|
56
|
-
WidgetKeyword["DASHBOARD"] = "dashboard";
|
|
57
|
-
})(WidgetKeyword || (WidgetKeyword = {}));
|
package/dist/types/index.d.ts
DELETED
package/dist/umd/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.exampleTypescriptPackage=e():t.exampleTypescriptPackage=e()}(this,(()=>(()=>{"use strict";var t={991:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{a(i.next(t))}catch(t){o(t)}}function c(t){try{a(i.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,c)}a((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&c[0]?i.return:c[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,c[1])).done)return r;switch(i=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,i=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){s.label=c[1];break}if(6===c[0]&&s.label<r[1]){s.label=r[1],r=c;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(c);break}r[2]&&s.ops.pop(),s.trys.pop();continue}c=e.call(t,s)}catch(t){c=[6,t],i=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ElectronApi=void 0;var r=function(){function t(){}return t.openAddWidgetWindow=function(){this.hasElectronApi()&&window.electronAPI.invokeIpc("openAddWidgetWindow")},t.registerWidgets=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return this.hasElectronApi()?(e=JSON.parse(JSON.stringify(t.map((function(t){return t.stringify()})))),[4,window.electronAPI.invokeIpc("registerWidgets",e)]):[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.hasElectronApi=function(){return Reflect.has(window,"electronAPI")},t}();e.ElectronApi=r},432:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(n(203),e),r(n(991),e)},203:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetKeyword=e.Widget=void 0;var n,i=function(){function t(t,e,n,i,r,o,s,c,a,u,l,f,p,d){this.lang="zh",this.name=t,this.title=e,this.desc=n,this.keywords=i,this.lang=r,this.w=o,this.h=s,this.maxW=c,this.maxH=a,this.minW=u,this.minH=l,this.url=f,this.configUrl=p,this.debugUrl=d}return t.prototype.getTitle=function(t){return t?this.title.get(t):this.title.get(this.lang)},t.prototype.getDesc=function(t){return t?this.desc.get(t):this.desc.get(this.lang)},t.prototype.stringify=function(){var t=JSON.parse(JSON.stringify(this));return t.title=Object.fromEntries(this.title),t.desc=Object.fromEntries(this.desc),JSON.stringify(t)},t}();e.Widget=i,(n=e.WidgetKeyword||(e.WidgetKeyword={})).RECOMMEND="recommend",n.TOOLS="tools",n.EFFICIENCY="efficiency",n.PICTURE="picture",n.LIFE="life",n.SHORTCUT="shortcut",n.COUNTDOWN="countdown",n.TIMER="timer",n.INFO="info",n.DASHBOARD="dashboard"}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(432)})()));
|