@widget-js/core 0.0.2
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/LICENSE +21 -0
- package/dist/cjs/api/ElectronApi.js +73 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/model/Widget.js +60 -0
- package/dist/esm/api/ElectronApi.js +70 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/model/Widget.js +57 -0
- package/dist/types/api/ElectronApi.d.ts +6 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/model/Widget.d.ts +50 -0
- package/dist/umd/index.js +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Widget-App
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,73 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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);
|
|
@@ -0,0 +1,60 @@
|
|
|
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 = {}));
|
|
@@ -0,0 +1,70 @@
|
|
|
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 };
|
|
@@ -0,0 +1,57 @@
|
|
|
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 = {}));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare class Widget {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
/**
|
|
4
|
+
* 组件标题,显示在界面上的,
|
|
5
|
+
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
6
|
+
*/
|
|
7
|
+
readonly title: Map<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* 组件介绍
|
|
10
|
+
*/
|
|
11
|
+
readonly desc: Map<string, string>;
|
|
12
|
+
readonly keywords: WidgetKeyword[];
|
|
13
|
+
/**
|
|
14
|
+
* 组件默认语言
|
|
15
|
+
*/
|
|
16
|
+
readonly lang: string;
|
|
17
|
+
readonly w: number;
|
|
18
|
+
readonly h: number;
|
|
19
|
+
readonly maxW: number;
|
|
20
|
+
readonly maxH: number;
|
|
21
|
+
readonly minW: number;
|
|
22
|
+
readonly minH: number;
|
|
23
|
+
readonly url: string;
|
|
24
|
+
readonly configUrl?: string | null;
|
|
25
|
+
readonly debugUrl?: string;
|
|
26
|
+
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);
|
|
27
|
+
/**
|
|
28
|
+
* 获取组件标题
|
|
29
|
+
* @param lang 语言环境,不传则获取默认语言
|
|
30
|
+
*/
|
|
31
|
+
getTitle(lang?: string): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* 获取组件标描述
|
|
34
|
+
* @param lang 语言环境,不传则获取默认标题
|
|
35
|
+
*/
|
|
36
|
+
getDesc(lang?: string): string | undefined;
|
|
37
|
+
stringify(): string;
|
|
38
|
+
}
|
|
39
|
+
export declare enum WidgetKeyword {
|
|
40
|
+
RECOMMEND = "recommend",
|
|
41
|
+
TOOLS = "tools",
|
|
42
|
+
EFFICIENCY = "efficiency",
|
|
43
|
+
PICTURE = "picture",
|
|
44
|
+
LIFE = "life",
|
|
45
|
+
SHORTCUT = "shortcut",
|
|
46
|
+
COUNTDOWN = "countdown",
|
|
47
|
+
TIMER = "timer",
|
|
48
|
+
INFO = "info",
|
|
49
|
+
DASHBOARD = "dashboard"
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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)})()));
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@widget-js/core",
|
|
3
|
+
"version": "0.0.2",
|
|
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
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"_postinstall": "husky install",
|
|
14
|
+
"prepublishOnly": "pinst --disable",
|
|
15
|
+
"test": "jest --no-cache --runInBand",
|
|
16
|
+
"test:cov": "jest --coverage --no-cache --runInBand",
|
|
17
|
+
"build": "npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types",
|
|
18
|
+
"build:cjs": "node tools/cleanup cjs && tsc -p config/tsconfig.cjs.json",
|
|
19
|
+
"build:esm": "node tools/cleanup esm && tsc -p config/tsconfig.esm.json",
|
|
20
|
+
"build:umd": "node tools/cleanup umd && webpack --config config/webpack.config.js",
|
|
21
|
+
"build:types": "node tools/cleanup types && tsc -p config/tsconfig.types.json",
|
|
22
|
+
"package": "npm run build && npm pack",
|
|
23
|
+
"addscope": "node tools/packagejson name @widget-js/core"
|
|
24
|
+
},
|
|
25
|
+
"author": "Neo Fu <rtugeek@gmail.com>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"homepage": "https://github.com/widom-widget/core",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/widom-widget/core.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/widom-widget/core/issues"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/cli": "^7.19.3",
|
|
40
|
+
"@babel/core": "^7.20.2",
|
|
41
|
+
"@babel/node": "^7.20.2",
|
|
42
|
+
"@babel/preset-env": "^7.20.2",
|
|
43
|
+
"@types/jest": "^29.2.3",
|
|
44
|
+
"babel-core": "^6.26.3",
|
|
45
|
+
"husky": "^8.0.2",
|
|
46
|
+
"jest": "^29.3.1",
|
|
47
|
+
"pinst": "^3.0.0",
|
|
48
|
+
"ts-jest": "^29.0.3",
|
|
49
|
+
"ts-loader": "^9.4.1",
|
|
50
|
+
"typescript": "^4.9.3",
|
|
51
|
+
"webpack": "^5.75.0",
|
|
52
|
+
"webpack-cli": "^5.0.0"
|
|
53
|
+
}
|
|
54
|
+
}
|