@widget-js/core 24.1.1-beta.86 → 24.1.1-beta.87

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 CHANGED
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var cssTree = require('css-tree');
4
+ var merge = require('lodash/merge');
4
5
  var localforage = require('localforage');
5
6
 
6
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
8
 
9
+ var merge__default = /*#__PURE__*/_interopDefault(merge);
8
10
  var localforage__default = /*#__PURE__*/_interopDefault(localforage);
9
11
 
10
12
  var __create = Object.create;
@@ -33,238 +35,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
35
  mod
34
36
  ));
35
37
 
36
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayReduce.js
37
- var require_arrayReduce = __commonJS({
38
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayReduce.js"(exports$1, module) {
39
- function arrayReduce(array, iteratee, accumulator, initAccum) {
40
- var index = -1, length = array == null ? 0 : array.length;
41
- if (initAccum && length) {
42
- accumulator = array[++index];
43
- }
44
- while (++index < length) {
45
- accumulator = iteratee(accumulator, array[index], index, array);
46
- }
47
- return accumulator;
48
- }
49
- module.exports = arrayReduce;
50
- }
51
- });
52
-
53
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_basePropertyOf.js
54
- var require_basePropertyOf = __commonJS({
55
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_basePropertyOf.js"(exports$1, module) {
56
- function basePropertyOf(object) {
57
- return function(key) {
58
- return object == null ? void 0 : object[key];
59
- };
60
- }
61
- module.exports = basePropertyOf;
62
- }
63
- });
64
-
65
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_deburrLetter.js
66
- var require_deburrLetter = __commonJS({
67
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_deburrLetter.js"(exports$1, module) {
68
- var basePropertyOf = require_basePropertyOf();
69
- var deburredLetters = {
70
- // Latin-1 Supplement block.
71
- "\xC0": "A",
72
- "\xC1": "A",
73
- "\xC2": "A",
74
- "\xC3": "A",
75
- "\xC4": "A",
76
- "\xC5": "A",
77
- "\xE0": "a",
78
- "\xE1": "a",
79
- "\xE2": "a",
80
- "\xE3": "a",
81
- "\xE4": "a",
82
- "\xE5": "a",
83
- "\xC7": "C",
84
- "\xE7": "c",
85
- "\xD0": "D",
86
- "\xF0": "d",
87
- "\xC8": "E",
88
- "\xC9": "E",
89
- "\xCA": "E",
90
- "\xCB": "E",
91
- "\xE8": "e",
92
- "\xE9": "e",
93
- "\xEA": "e",
94
- "\xEB": "e",
95
- "\xCC": "I",
96
- "\xCD": "I",
97
- "\xCE": "I",
98
- "\xCF": "I",
99
- "\xEC": "i",
100
- "\xED": "i",
101
- "\xEE": "i",
102
- "\xEF": "i",
103
- "\xD1": "N",
104
- "\xF1": "n",
105
- "\xD2": "O",
106
- "\xD3": "O",
107
- "\xD4": "O",
108
- "\xD5": "O",
109
- "\xD6": "O",
110
- "\xD8": "O",
111
- "\xF2": "o",
112
- "\xF3": "o",
113
- "\xF4": "o",
114
- "\xF5": "o",
115
- "\xF6": "o",
116
- "\xF8": "o",
117
- "\xD9": "U",
118
- "\xDA": "U",
119
- "\xDB": "U",
120
- "\xDC": "U",
121
- "\xF9": "u",
122
- "\xFA": "u",
123
- "\xFB": "u",
124
- "\xFC": "u",
125
- "\xDD": "Y",
126
- "\xFD": "y",
127
- "\xFF": "y",
128
- "\xC6": "Ae",
129
- "\xE6": "ae",
130
- "\xDE": "Th",
131
- "\xFE": "th",
132
- "\xDF": "ss",
133
- // Latin Extended-A block.
134
- "\u0100": "A",
135
- "\u0102": "A",
136
- "\u0104": "A",
137
- "\u0101": "a",
138
- "\u0103": "a",
139
- "\u0105": "a",
140
- "\u0106": "C",
141
- "\u0108": "C",
142
- "\u010A": "C",
143
- "\u010C": "C",
144
- "\u0107": "c",
145
- "\u0109": "c",
146
- "\u010B": "c",
147
- "\u010D": "c",
148
- "\u010E": "D",
149
- "\u0110": "D",
150
- "\u010F": "d",
151
- "\u0111": "d",
152
- "\u0112": "E",
153
- "\u0114": "E",
154
- "\u0116": "E",
155
- "\u0118": "E",
156
- "\u011A": "E",
157
- "\u0113": "e",
158
- "\u0115": "e",
159
- "\u0117": "e",
160
- "\u0119": "e",
161
- "\u011B": "e",
162
- "\u011C": "G",
163
- "\u011E": "G",
164
- "\u0120": "G",
165
- "\u0122": "G",
166
- "\u011D": "g",
167
- "\u011F": "g",
168
- "\u0121": "g",
169
- "\u0123": "g",
170
- "\u0124": "H",
171
- "\u0126": "H",
172
- "\u0125": "h",
173
- "\u0127": "h",
174
- "\u0128": "I",
175
- "\u012A": "I",
176
- "\u012C": "I",
177
- "\u012E": "I",
178
- "\u0130": "I",
179
- "\u0129": "i",
180
- "\u012B": "i",
181
- "\u012D": "i",
182
- "\u012F": "i",
183
- "\u0131": "i",
184
- "\u0134": "J",
185
- "\u0135": "j",
186
- "\u0136": "K",
187
- "\u0137": "k",
188
- "\u0138": "k",
189
- "\u0139": "L",
190
- "\u013B": "L",
191
- "\u013D": "L",
192
- "\u013F": "L",
193
- "\u0141": "L",
194
- "\u013A": "l",
195
- "\u013C": "l",
196
- "\u013E": "l",
197
- "\u0140": "l",
198
- "\u0142": "l",
199
- "\u0143": "N",
200
- "\u0145": "N",
201
- "\u0147": "N",
202
- "\u014A": "N",
203
- "\u0144": "n",
204
- "\u0146": "n",
205
- "\u0148": "n",
206
- "\u014B": "n",
207
- "\u014C": "O",
208
- "\u014E": "O",
209
- "\u0150": "O",
210
- "\u014D": "o",
211
- "\u014F": "o",
212
- "\u0151": "o",
213
- "\u0154": "R",
214
- "\u0156": "R",
215
- "\u0158": "R",
216
- "\u0155": "r",
217
- "\u0157": "r",
218
- "\u0159": "r",
219
- "\u015A": "S",
220
- "\u015C": "S",
221
- "\u015E": "S",
222
- "\u0160": "S",
223
- "\u015B": "s",
224
- "\u015D": "s",
225
- "\u015F": "s",
226
- "\u0161": "s",
227
- "\u0162": "T",
228
- "\u0164": "T",
229
- "\u0166": "T",
230
- "\u0163": "t",
231
- "\u0165": "t",
232
- "\u0167": "t",
233
- "\u0168": "U",
234
- "\u016A": "U",
235
- "\u016C": "U",
236
- "\u016E": "U",
237
- "\u0170": "U",
238
- "\u0172": "U",
239
- "\u0169": "u",
240
- "\u016B": "u",
241
- "\u016D": "u",
242
- "\u016F": "u",
243
- "\u0171": "u",
244
- "\u0173": "u",
245
- "\u0174": "W",
246
- "\u0175": "w",
247
- "\u0176": "Y",
248
- "\u0177": "y",
249
- "\u0178": "Y",
250
- "\u0179": "Z",
251
- "\u017B": "Z",
252
- "\u017D": "Z",
253
- "\u017A": "z",
254
- "\u017C": "z",
255
- "\u017E": "z",
256
- "\u0132": "IJ",
257
- "\u0133": "ij",
258
- "\u0152": "Oe",
259
- "\u0153": "oe",
260
- "\u0149": "'n",
261
- "\u017F": "s"
262
- };
263
- var deburrLetter = basePropertyOf(deburredLetters);
264
- module.exports = deburrLetter;
265
- }
266
- });
267
-
268
38
  // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_freeGlobal.js
269
39
  var require_freeGlobal = __commonJS({
270
40
  "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_freeGlobal.js"(exports$1, module) {
@@ -434,154 +204,6 @@ var require_toString = __commonJS({
434
204
  }
435
205
  });
436
206
 
437
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/deburr.js
438
- var require_deburr = __commonJS({
439
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/deburr.js"(exports$1, module) {
440
- var deburrLetter = require_deburrLetter();
441
- var toString = require_toString();
442
- var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
443
- var rsComboMarksRange = "\\u0300-\\u036f";
444
- var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
445
- var rsComboSymbolsRange = "\\u20d0-\\u20ff";
446
- var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
447
- var rsCombo = "[" + rsComboRange + "]";
448
- var reComboMark = RegExp(rsCombo, "g");
449
- function deburr(string) {
450
- string = toString(string);
451
- return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
452
- }
453
- module.exports = deburr;
454
- }
455
- });
456
-
457
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_asciiWords.js
458
- var require_asciiWords = __commonJS({
459
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_asciiWords.js"(exports$1, module) {
460
- var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
461
- function asciiWords(string) {
462
- return string.match(reAsciiWord) || [];
463
- }
464
- module.exports = asciiWords;
465
- }
466
- });
467
-
468
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hasUnicodeWord.js
469
- var require_hasUnicodeWord = __commonJS({
470
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hasUnicodeWord.js"(exports$1, module) {
471
- var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
472
- function hasUnicodeWord(string) {
473
- return reHasUnicodeWord.test(string);
474
- }
475
- module.exports = hasUnicodeWord;
476
- }
477
- });
478
-
479
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_unicodeWords.js
480
- var require_unicodeWords = __commonJS({
481
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_unicodeWords.js"(exports$1, module) {
482
- var rsAstralRange = "\\ud800-\\udfff";
483
- var rsComboMarksRange = "\\u0300-\\u036f";
484
- var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
485
- var rsComboSymbolsRange = "\\u20d0-\\u20ff";
486
- var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
487
- var rsDingbatRange = "\\u2700-\\u27bf";
488
- var rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff";
489
- var rsMathOpRange = "\\xac\\xb1\\xd7\\xf7";
490
- var rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf";
491
- var rsPunctuationRange = "\\u2000-\\u206f";
492
- var rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000";
493
- var rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde";
494
- var rsVarRange = "\\ufe0e\\ufe0f";
495
- var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
496
- var rsApos = "['\u2019]";
497
- var rsBreak = "[" + rsBreakRange + "]";
498
- var rsCombo = "[" + rsComboRange + "]";
499
- var rsDigits = "\\d+";
500
- var rsDingbat = "[" + rsDingbatRange + "]";
501
- var rsLower = "[" + rsLowerRange + "]";
502
- var rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]";
503
- var rsFitz = "\\ud83c[\\udffb-\\udfff]";
504
- var rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")";
505
- var rsNonAstral = "[^" + rsAstralRange + "]";
506
- var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
507
- var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
508
- var rsUpper = "[" + rsUpperRange + "]";
509
- var rsZWJ = "\\u200d";
510
- var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")";
511
- var rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")";
512
- var rsOptContrLower = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?";
513
- var rsOptContrUpper = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?";
514
- var reOptMod = rsModifier + "?";
515
- var rsOptVar = "[" + rsVarRange + "]?";
516
- var rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*";
517
- var rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])";
518
- var rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])";
519
- var rsSeq = rsOptVar + reOptMod + rsOptJoin;
520
- var rsEmoji = "(?:" + [rsDingbat, rsRegional, rsSurrPair].join("|") + ")" + rsSeq;
521
- var reUnicodeWord = RegExp([
522
- rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
523
- rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
524
- rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
525
- rsUpper + "+" + rsOptContrUpper,
526
- rsOrdUpper,
527
- rsOrdLower,
528
- rsDigits,
529
- rsEmoji
530
- ].join("|"), "g");
531
- function unicodeWords(string) {
532
- return string.match(reUnicodeWord) || [];
533
- }
534
- module.exports = unicodeWords;
535
- }
536
- });
537
-
538
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/words.js
539
- var require_words = __commonJS({
540
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/words.js"(exports$1, module) {
541
- var asciiWords = require_asciiWords();
542
- var hasUnicodeWord = require_hasUnicodeWord();
543
- var toString = require_toString();
544
- var unicodeWords = require_unicodeWords();
545
- function words(string, pattern, guard) {
546
- string = toString(string);
547
- pattern = guard ? void 0 : pattern;
548
- if (pattern === void 0) {
549
- return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
550
- }
551
- return string.match(pattern) || [];
552
- }
553
- module.exports = words;
554
- }
555
- });
556
-
557
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_createCompounder.js
558
- var require_createCompounder = __commonJS({
559
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_createCompounder.js"(exports$1, module) {
560
- var arrayReduce = require_arrayReduce();
561
- var deburr = require_deburr();
562
- var words = require_words();
563
- var rsApos = "['\u2019]";
564
- var reApos = RegExp(rsApos, "g");
565
- function createCompounder(callback) {
566
- return function(string) {
567
- return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
568
- };
569
- }
570
- module.exports = createCompounder;
571
- }
572
- });
573
-
574
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/kebabCase.js
575
- var require_kebabCase = __commonJS({
576
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/kebabCase.js"(exports$1, module) {
577
- var createCompounder = require_createCompounder();
578
- var kebabCase3 = createCompounder(function(result, word, index) {
579
- return result + (index ? "-" : "") + word.toLowerCase();
580
- });
581
- module.exports = kebabCase3;
582
- }
583
- });
584
-
585
207
  // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseSlice.js
586
208
  var require_baseSlice = __commonJS({
587
209
  "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseSlice.js"(exports$1, module) {
@@ -731,135 +353,875 @@ var require_capitalize = __commonJS({
731
353
  }
732
354
  });
733
355
 
734
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/camelCase.js
735
- var require_camelCase = __commonJS({
736
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/camelCase.js"(exports$1, module) {
737
- var capitalize = require_capitalize();
738
- var createCompounder = require_createCompounder();
739
- var camelCase2 = createCompounder(function(result, word, index) {
740
- word = word.toLowerCase();
741
- return result + (index ? capitalize(word) : word);
742
- });
743
- module.exports = camelCase2;
744
- }
745
- });
746
-
747
- // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/snakeCase.js
748
- var require_snakeCase = __commonJS({
749
- "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/snakeCase.js"(exports$1, module) {
750
- var createCompounder = require_createCompounder();
751
- var snakeCase2 = createCompounder(function(result, word, index) {
752
- return result + (index ? "_" : "") + word.toLowerCase();
753
- });
754
- module.exports = snakeCase2;
755
- }
756
- });
757
-
758
- // src/model/DeployMode.ts
759
- var HostedMode = /* @__PURE__ */ ((HostedMode2) => {
760
- HostedMode2[HostedMode2["NORMAL"] = 1] = "NORMAL";
761
- HostedMode2[HostedMode2["OVERLAP"] = 16] = "OVERLAP";
762
- HostedMode2[HostedMode2["WALLPAPER"] = 256] = "WALLPAPER";
763
- HostedMode2[HostedMode2["SCREEN"] = 4096] = "SCREEN";
764
- HostedMode2[HostedMode2["BACKGROUND"] = 65536] = "BACKGROUND";
765
- HostedMode2[HostedMode2["PAGE"] = 1048576] = "PAGE";
766
- HostedMode2[HostedMode2["ALL"] = 1118481] = "ALL";
767
- return HostedMode2;
768
- })(HostedMode || {});
769
- var DeployMode = /* @__PURE__ */ ((DeployMode2) => {
770
- DeployMode2[DeployMode2["NORMAL"] = 1] = "NORMAL";
771
- DeployMode2[DeployMode2["OVERLAP"] = 16] = "OVERLAP";
772
- DeployMode2[DeployMode2["BACKGROUND"] = 65536] = "BACKGROUND";
773
- DeployMode2[DeployMode2["TRAY"] = 256] = "TRAY";
774
- DeployMode2[DeployMode2["ALL"] = 1118481] = "ALL";
775
- return DeployMode2;
776
- })(DeployMode || {});
777
-
778
- // src/utils/ElectronUtils.ts
779
- var ElectronUtils = class {
780
- static hasElectronApi() {
781
- return this.getAPI() != null;
782
- }
783
- /**
784
- * 获取ElectronAPI
785
- * windows api
786
- */
787
- static getAPI() {
788
- if (Reflect.has(window, "electronAPI")) {
789
- return window.electronAPI;
790
- } else if (Reflect.has(window.parent, "electronAPI")) {
791
- return window.parent.electronAPI;
792
- }
793
- return null;
794
- }
795
- static async invokeMethod(channel, method, ...args) {
796
- return this.getAPI()?.invoke(channel, method, ...args);
797
- }
798
- static async invoke(channel, ...args) {
799
- return this.getAPI()?.invoke(channel, ...args);
800
- }
801
- };
802
-
803
- // src/utils/LanguageUtils.ts
804
- var LanguageUtils = class {
805
- static findText(langMap, localeCode) {
806
- const locales = Object.keys(langMap).map((key) => new Intl.Locale(key));
807
- const targetLocale = new Intl.Locale(localeCode);
808
- let find2 = locales.find((locale) => locale.baseName == targetLocale.baseName);
809
- if (!find2) {
810
- find2 = locales.find((locale) => locale.language == targetLocale.language);
811
- }
812
- return find2;
813
- }
814
- /**
815
- * Get text from `LanguageTextMap` by Unicode locale identifier.
816
- * `localeCode` > `localeCode` without region > browser default language > English > first language
817
- * @param langMap 对象
818
- * @param {LanguageCode} localeCode `zh-CN`、`en-US`、 `zh`、`en`
819
- * @param fallbackToBrowser
820
- */
821
- static getTextByLocate(langMap, localeCode, fallbackToBrowser = true) {
822
- let result;
823
- if (localeCode) {
824
- if (localeCode in langMap) {
825
- return langMap[localeCode];
826
- }
827
- }
828
- if (localeCode) {
829
- const find2 = this.findText(langMap, localeCode);
830
- if (find2) {
831
- return langMap[find2.baseName];
832
- }
833
- }
834
- if (result == void 0 && fallbackToBrowser) {
835
- if (typeof navigator != "undefined" && navigator.languages) {
836
- const langCode = navigator.language;
837
- result = this.getTextByLocate(langMap, langCode, false);
838
- if (result != void 0) {
839
- return result;
840
- }
356
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayReduce.js
357
+ var require_arrayReduce = __commonJS({
358
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayReduce.js"(exports$1, module) {
359
+ function arrayReduce(array, iteratee, accumulator, initAccum) {
360
+ var index = -1, length = array == null ? 0 : array.length;
361
+ if (initAccum && length) {
362
+ accumulator = array[++index];
841
363
  }
842
- }
843
- if (result == void 0) {
844
- const find2 = this.findText(langMap, "en");
845
- if (find2) {
846
- return langMap[find2.baseName];
364
+ while (++index < length) {
365
+ accumulator = iteratee(accumulator, array[index], index, array);
847
366
  }
367
+ return accumulator;
848
368
  }
849
- if (result == void 0) {
850
- const langCode = Object.keys(langMap);
851
- if (langCode.length > 0) {
852
- return langMap[langCode[0]];
853
- }
369
+ module.exports = arrayReduce;
370
+ }
371
+ });
372
+
373
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_basePropertyOf.js
374
+ var require_basePropertyOf = __commonJS({
375
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_basePropertyOf.js"(exports$1, module) {
376
+ function basePropertyOf(object) {
377
+ return function(key) {
378
+ return object == null ? void 0 : object[key];
379
+ };
854
380
  }
855
- return void 0;
381
+ module.exports = basePropertyOf;
856
382
  }
857
- };
383
+ });
858
384
 
859
- // src/utils/WidgetUtils.ts
860
- var WidgetUtils = class {
861
- /**
862
- * 是否支持悬浮窗
385
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_deburrLetter.js
386
+ var require_deburrLetter = __commonJS({
387
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_deburrLetter.js"(exports$1, module) {
388
+ var basePropertyOf = require_basePropertyOf();
389
+ var deburredLetters = {
390
+ // Latin-1 Supplement block.
391
+ "\xC0": "A",
392
+ "\xC1": "A",
393
+ "\xC2": "A",
394
+ "\xC3": "A",
395
+ "\xC4": "A",
396
+ "\xC5": "A",
397
+ "\xE0": "a",
398
+ "\xE1": "a",
399
+ "\xE2": "a",
400
+ "\xE3": "a",
401
+ "\xE4": "a",
402
+ "\xE5": "a",
403
+ "\xC7": "C",
404
+ "\xE7": "c",
405
+ "\xD0": "D",
406
+ "\xF0": "d",
407
+ "\xC8": "E",
408
+ "\xC9": "E",
409
+ "\xCA": "E",
410
+ "\xCB": "E",
411
+ "\xE8": "e",
412
+ "\xE9": "e",
413
+ "\xEA": "e",
414
+ "\xEB": "e",
415
+ "\xCC": "I",
416
+ "\xCD": "I",
417
+ "\xCE": "I",
418
+ "\xCF": "I",
419
+ "\xEC": "i",
420
+ "\xED": "i",
421
+ "\xEE": "i",
422
+ "\xEF": "i",
423
+ "\xD1": "N",
424
+ "\xF1": "n",
425
+ "\xD2": "O",
426
+ "\xD3": "O",
427
+ "\xD4": "O",
428
+ "\xD5": "O",
429
+ "\xD6": "O",
430
+ "\xD8": "O",
431
+ "\xF2": "o",
432
+ "\xF3": "o",
433
+ "\xF4": "o",
434
+ "\xF5": "o",
435
+ "\xF6": "o",
436
+ "\xF8": "o",
437
+ "\xD9": "U",
438
+ "\xDA": "U",
439
+ "\xDB": "U",
440
+ "\xDC": "U",
441
+ "\xF9": "u",
442
+ "\xFA": "u",
443
+ "\xFB": "u",
444
+ "\xFC": "u",
445
+ "\xDD": "Y",
446
+ "\xFD": "y",
447
+ "\xFF": "y",
448
+ "\xC6": "Ae",
449
+ "\xE6": "ae",
450
+ "\xDE": "Th",
451
+ "\xFE": "th",
452
+ "\xDF": "ss",
453
+ // Latin Extended-A block.
454
+ "\u0100": "A",
455
+ "\u0102": "A",
456
+ "\u0104": "A",
457
+ "\u0101": "a",
458
+ "\u0103": "a",
459
+ "\u0105": "a",
460
+ "\u0106": "C",
461
+ "\u0108": "C",
462
+ "\u010A": "C",
463
+ "\u010C": "C",
464
+ "\u0107": "c",
465
+ "\u0109": "c",
466
+ "\u010B": "c",
467
+ "\u010D": "c",
468
+ "\u010E": "D",
469
+ "\u0110": "D",
470
+ "\u010F": "d",
471
+ "\u0111": "d",
472
+ "\u0112": "E",
473
+ "\u0114": "E",
474
+ "\u0116": "E",
475
+ "\u0118": "E",
476
+ "\u011A": "E",
477
+ "\u0113": "e",
478
+ "\u0115": "e",
479
+ "\u0117": "e",
480
+ "\u0119": "e",
481
+ "\u011B": "e",
482
+ "\u011C": "G",
483
+ "\u011E": "G",
484
+ "\u0120": "G",
485
+ "\u0122": "G",
486
+ "\u011D": "g",
487
+ "\u011F": "g",
488
+ "\u0121": "g",
489
+ "\u0123": "g",
490
+ "\u0124": "H",
491
+ "\u0126": "H",
492
+ "\u0125": "h",
493
+ "\u0127": "h",
494
+ "\u0128": "I",
495
+ "\u012A": "I",
496
+ "\u012C": "I",
497
+ "\u012E": "I",
498
+ "\u0130": "I",
499
+ "\u0129": "i",
500
+ "\u012B": "i",
501
+ "\u012D": "i",
502
+ "\u012F": "i",
503
+ "\u0131": "i",
504
+ "\u0134": "J",
505
+ "\u0135": "j",
506
+ "\u0136": "K",
507
+ "\u0137": "k",
508
+ "\u0138": "k",
509
+ "\u0139": "L",
510
+ "\u013B": "L",
511
+ "\u013D": "L",
512
+ "\u013F": "L",
513
+ "\u0141": "L",
514
+ "\u013A": "l",
515
+ "\u013C": "l",
516
+ "\u013E": "l",
517
+ "\u0140": "l",
518
+ "\u0142": "l",
519
+ "\u0143": "N",
520
+ "\u0145": "N",
521
+ "\u0147": "N",
522
+ "\u014A": "N",
523
+ "\u0144": "n",
524
+ "\u0146": "n",
525
+ "\u0148": "n",
526
+ "\u014B": "n",
527
+ "\u014C": "O",
528
+ "\u014E": "O",
529
+ "\u0150": "O",
530
+ "\u014D": "o",
531
+ "\u014F": "o",
532
+ "\u0151": "o",
533
+ "\u0154": "R",
534
+ "\u0156": "R",
535
+ "\u0158": "R",
536
+ "\u0155": "r",
537
+ "\u0157": "r",
538
+ "\u0159": "r",
539
+ "\u015A": "S",
540
+ "\u015C": "S",
541
+ "\u015E": "S",
542
+ "\u0160": "S",
543
+ "\u015B": "s",
544
+ "\u015D": "s",
545
+ "\u015F": "s",
546
+ "\u0161": "s",
547
+ "\u0162": "T",
548
+ "\u0164": "T",
549
+ "\u0166": "T",
550
+ "\u0163": "t",
551
+ "\u0165": "t",
552
+ "\u0167": "t",
553
+ "\u0168": "U",
554
+ "\u016A": "U",
555
+ "\u016C": "U",
556
+ "\u016E": "U",
557
+ "\u0170": "U",
558
+ "\u0172": "U",
559
+ "\u0169": "u",
560
+ "\u016B": "u",
561
+ "\u016D": "u",
562
+ "\u016F": "u",
563
+ "\u0171": "u",
564
+ "\u0173": "u",
565
+ "\u0174": "W",
566
+ "\u0175": "w",
567
+ "\u0176": "Y",
568
+ "\u0177": "y",
569
+ "\u0178": "Y",
570
+ "\u0179": "Z",
571
+ "\u017B": "Z",
572
+ "\u017D": "Z",
573
+ "\u017A": "z",
574
+ "\u017C": "z",
575
+ "\u017E": "z",
576
+ "\u0132": "IJ",
577
+ "\u0133": "ij",
578
+ "\u0152": "Oe",
579
+ "\u0153": "oe",
580
+ "\u0149": "'n",
581
+ "\u017F": "s"
582
+ };
583
+ var deburrLetter = basePropertyOf(deburredLetters);
584
+ module.exports = deburrLetter;
585
+ }
586
+ });
587
+
588
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/deburr.js
589
+ var require_deburr = __commonJS({
590
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/deburr.js"(exports$1, module) {
591
+ var deburrLetter = require_deburrLetter();
592
+ var toString = require_toString();
593
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
594
+ var rsComboMarksRange = "\\u0300-\\u036f";
595
+ var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
596
+ var rsComboSymbolsRange = "\\u20d0-\\u20ff";
597
+ var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
598
+ var rsCombo = "[" + rsComboRange + "]";
599
+ var reComboMark = RegExp(rsCombo, "g");
600
+ function deburr(string) {
601
+ string = toString(string);
602
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
603
+ }
604
+ module.exports = deburr;
605
+ }
606
+ });
607
+
608
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_asciiWords.js
609
+ var require_asciiWords = __commonJS({
610
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_asciiWords.js"(exports$1, module) {
611
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
612
+ function asciiWords(string) {
613
+ return string.match(reAsciiWord) || [];
614
+ }
615
+ module.exports = asciiWords;
616
+ }
617
+ });
618
+
619
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hasUnicodeWord.js
620
+ var require_hasUnicodeWord = __commonJS({
621
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hasUnicodeWord.js"(exports$1, module) {
622
+ var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
623
+ function hasUnicodeWord(string) {
624
+ return reHasUnicodeWord.test(string);
625
+ }
626
+ module.exports = hasUnicodeWord;
627
+ }
628
+ });
629
+
630
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_unicodeWords.js
631
+ var require_unicodeWords = __commonJS({
632
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_unicodeWords.js"(exports$1, module) {
633
+ var rsAstralRange = "\\ud800-\\udfff";
634
+ var rsComboMarksRange = "\\u0300-\\u036f";
635
+ var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
636
+ var rsComboSymbolsRange = "\\u20d0-\\u20ff";
637
+ var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
638
+ var rsDingbatRange = "\\u2700-\\u27bf";
639
+ var rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff";
640
+ var rsMathOpRange = "\\xac\\xb1\\xd7\\xf7";
641
+ var rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf";
642
+ var rsPunctuationRange = "\\u2000-\\u206f";
643
+ var rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000";
644
+ var rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde";
645
+ var rsVarRange = "\\ufe0e\\ufe0f";
646
+ var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
647
+ var rsApos = "['\u2019]";
648
+ var rsBreak = "[" + rsBreakRange + "]";
649
+ var rsCombo = "[" + rsComboRange + "]";
650
+ var rsDigits = "\\d+";
651
+ var rsDingbat = "[" + rsDingbatRange + "]";
652
+ var rsLower = "[" + rsLowerRange + "]";
653
+ var rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]";
654
+ var rsFitz = "\\ud83c[\\udffb-\\udfff]";
655
+ var rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")";
656
+ var rsNonAstral = "[^" + rsAstralRange + "]";
657
+ var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
658
+ var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
659
+ var rsUpper = "[" + rsUpperRange + "]";
660
+ var rsZWJ = "\\u200d";
661
+ var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")";
662
+ var rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")";
663
+ var rsOptContrLower = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?";
664
+ var rsOptContrUpper = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?";
665
+ var reOptMod = rsModifier + "?";
666
+ var rsOptVar = "[" + rsVarRange + "]?";
667
+ var rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*";
668
+ var rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])";
669
+ var rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])";
670
+ var rsSeq = rsOptVar + reOptMod + rsOptJoin;
671
+ var rsEmoji = "(?:" + [rsDingbat, rsRegional, rsSurrPair].join("|") + ")" + rsSeq;
672
+ var reUnicodeWord = RegExp([
673
+ rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
674
+ rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
675
+ rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
676
+ rsUpper + "+" + rsOptContrUpper,
677
+ rsOrdUpper,
678
+ rsOrdLower,
679
+ rsDigits,
680
+ rsEmoji
681
+ ].join("|"), "g");
682
+ function unicodeWords(string) {
683
+ return string.match(reUnicodeWord) || [];
684
+ }
685
+ module.exports = unicodeWords;
686
+ }
687
+ });
688
+
689
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/words.js
690
+ var require_words = __commonJS({
691
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/words.js"(exports$1, module) {
692
+ var asciiWords = require_asciiWords();
693
+ var hasUnicodeWord = require_hasUnicodeWord();
694
+ var toString = require_toString();
695
+ var unicodeWords = require_unicodeWords();
696
+ function words(string, pattern, guard) {
697
+ string = toString(string);
698
+ pattern = guard ? void 0 : pattern;
699
+ if (pattern === void 0) {
700
+ return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
701
+ }
702
+ return string.match(pattern) || [];
703
+ }
704
+ module.exports = words;
705
+ }
706
+ });
707
+
708
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_createCompounder.js
709
+ var require_createCompounder = __commonJS({
710
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_createCompounder.js"(exports$1, module) {
711
+ var arrayReduce = require_arrayReduce();
712
+ var deburr = require_deburr();
713
+ var words = require_words();
714
+ var rsApos = "['\u2019]";
715
+ var reApos = RegExp(rsApos, "g");
716
+ function createCompounder(callback) {
717
+ return function(string) {
718
+ return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
719
+ };
720
+ }
721
+ module.exports = createCompounder;
722
+ }
723
+ });
724
+
725
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/camelCase.js
726
+ var require_camelCase = __commonJS({
727
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/camelCase.js"(exports$1, module) {
728
+ var capitalize = require_capitalize();
729
+ var createCompounder = require_createCompounder();
730
+ var camelCase3 = createCompounder(function(result, word, index) {
731
+ word = word.toLowerCase();
732
+ return result + (index ? capitalize(word) : word);
733
+ });
734
+ module.exports = camelCase3;
735
+ }
736
+ });
737
+
738
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/kebabCase.js
739
+ var require_kebabCase = __commonJS({
740
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/kebabCase.js"(exports$1, module) {
741
+ var createCompounder = require_createCompounder();
742
+ var kebabCase4 = createCompounder(function(result, word, index) {
743
+ return result + (index ? "-" : "") + word.toLowerCase();
744
+ });
745
+ module.exports = kebabCase4;
746
+ }
747
+ });
748
+
749
+ // ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/snakeCase.js
750
+ var require_snakeCase = __commonJS({
751
+ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/snakeCase.js"(exports$1, module) {
752
+ var createCompounder = require_createCompounder();
753
+ var snakeCase2 = createCompounder(function(result, word, index) {
754
+ return result + (index ? "_" : "") + word.toLowerCase();
755
+ });
756
+ module.exports = snakeCase2;
757
+ }
758
+ });
759
+
760
+ // src/model/AppNotification.ts
761
+ var NotificationSize = /* @__PURE__ */ ((NotificationSize2) => {
762
+ NotificationSize2["SMALL"] = "small";
763
+ NotificationSize2["NORMAL"] = "normal";
764
+ NotificationSize2["LARGE"] = "large";
765
+ return NotificationSize2;
766
+ })(NotificationSize || {});
767
+ var AppNotification = class {
768
+ type = "info";
769
+ message;
770
+ title;
771
+ targetTime;
772
+ /**
773
+ * 持续时间,单位毫秒
774
+ */
775
+ duration;
776
+ /**
777
+ * IconPark图标
778
+ * @example close-one
779
+ * @see [IconPark](https://iconpark.oceanengine.com/official)
780
+ */
781
+ icon;
782
+ color;
783
+ backgroundColor;
784
+ confirmButtonText;
785
+ cancelButtonText;
786
+ cancelBroadcast;
787
+ confirmBroadcast;
788
+ size;
789
+ url;
790
+ avatar;
791
+ audio;
792
+ lyric;
793
+ createdAt;
794
+ constructor(option) {
795
+ this.createdAt = (/* @__PURE__ */ new Date()).toISOString();
796
+ this.type = option.type ?? "info";
797
+ this.title = option.title;
798
+ this.message = option.message;
799
+ this.targetTime = option.targetTime;
800
+ this.duration = option.duration ?? 5e3;
801
+ this.icon = option.icon;
802
+ this.color = option.color ?? "#5D8AC8";
803
+ this.confirmButtonText = option.confirmButtonText;
804
+ this.cancelButtonText = option.cancelButtonText;
805
+ this.cancelBroadcast = option.cancelBroadcast;
806
+ this.confirmBroadcast = option.confirmBroadcast;
807
+ this.size = option.size ?? "normal" /* NORMAL */;
808
+ this.audio = option.audio;
809
+ this.avatar = option.avatar;
810
+ this.lyric = option.lyric;
811
+ this.backgroundColor = option.backgroundColor ?? "#000000";
812
+ }
813
+ };
814
+ var AppReminderNotification = class extends AppNotification {
815
+ constructor(option) {
816
+ super(option);
817
+ this.type = "reminder";
818
+ this.size = "large" /* LARGE */;
819
+ }
820
+ };
821
+
822
+ // src/model/AppTheme.ts
823
+ var import_camelCase = __toESM(require_camelCase());
824
+ var import_kebabCase = __toESM(require_kebabCase());
825
+ var DefaultThemeDark = {
826
+ useGlobalTheme: true,
827
+ mode: "dark",
828
+ colors: {
829
+ background: "hsl(0 0% 10%)",
830
+ foreground: "hsl(0 0% 98%)",
831
+ card: "hsl(0 0% 12%)",
832
+ cardForeground: "hsl(0 0% 98%)",
833
+ popover: "hsl(0 0% 12%)",
834
+ popoverForeground: "hsl(0 0% 98%)",
835
+ primary: "hsl(210 100% 56%)",
836
+ primaryForeground: "#fff",
837
+ secondary: "hsl(0 0% 20%)",
838
+ secondaryForeground: "#fff",
839
+ muted: "hsl(0 0% 30%)",
840
+ mutedForeground: "hsl(0 0% 70%)",
841
+ accent: "hsl(210 100% 60%)",
842
+ accentForeground: "#fff",
843
+ destructive: "hsl(0 84% 60%)",
844
+ destructiveForeground: "#fff",
845
+ border: "hsl(0 0% 30%)",
846
+ input: "hsl(0 0% 25%)",
847
+ ring: "hsl(210 100% 60%)"
848
+ },
849
+ radius: {
850
+ sm: "6px",
851
+ md: "10px",
852
+ lg: "16px",
853
+ full: "9999px"
854
+ },
855
+ typography: {
856
+ fontFamily: "system-ui, sans-serif",
857
+ fontSize: "14px"
858
+ },
859
+ shadow: {
860
+ sm: "0 1px 2px rgba(0,0,0,0.2)",
861
+ md: "0 4px 6px rgba(0,0,0,0.3)",
862
+ lg: "0 10px 20px rgba(0,0,0,0.4)"
863
+ },
864
+ spacing: "0.5rem"
865
+ };
866
+ var DefaultThemeLight = {
867
+ ...DefaultThemeDark,
868
+ mode: "light",
869
+ colors: {
870
+ background: "#ffffff",
871
+ foreground: "hsl(0 0% 10%)",
872
+ card: "#ffffff",
873
+ cardForeground: "hsl(0 0% 10%)",
874
+ popover: "#ffffff",
875
+ popoverForeground: "hsl(0 0% 10%)",
876
+ primary: "hsl(210 100% 56%)",
877
+ primaryForeground: "#fff",
878
+ secondary: "hsl(0 0% 90%)",
879
+ secondaryForeground: "hsl(0 0% 10%)",
880
+ muted: "hsl(0 0% 95%)",
881
+ mutedForeground: "hsl(0 0% 40%)",
882
+ accent: "hsl(210 100% 90%)",
883
+ accentForeground: "hsl(210 100% 40%)",
884
+ destructive: "hsl(0 84% 60%)",
885
+ destructiveForeground: "#fff",
886
+ border: "hsl(0 0% 90%)",
887
+ input: "hsl(0 0% 85%)",
888
+ ring: "hsl(210 100% 56%)"
889
+ },
890
+ shadow: {
891
+ sm: "0 1px 2px rgba(0,0,0,0.05)",
892
+ md: "0 4px 6px rgba(0,0,0,0.1)",
893
+ lg: "0 10px 20px rgba(0,0,0,0.15)"
894
+ }
895
+ };
896
+ var DefaultTheme = DefaultThemeDark;
897
+ var AppTheme = class _AppTheme {
898
+ useGlobalTheme;
899
+ mode;
900
+ colors;
901
+ radius;
902
+ typography;
903
+ shadow;
904
+ spacing;
905
+ constructor(options) {
906
+ let parsedOptions = {};
907
+ if (typeof options === "string") {
908
+ try {
909
+ parsedOptions = JSON.parse(options);
910
+ } catch (e) {
911
+ console.error("Failed to parse AppTheme options", e);
912
+ }
913
+ } else if (options) {
914
+ parsedOptions = options;
915
+ }
916
+ const baseTheme = parsedOptions.mode === "light" ? DefaultThemeLight : DefaultThemeDark;
917
+ merge__default.default(this, structuredClone(baseTheme), parsedOptions);
918
+ if (this.useGlobalTheme === void 0) {
919
+ this.useGlobalTheme = true;
920
+ }
921
+ }
922
+ static fromJSON(json) {
923
+ return new _AppTheme(json);
924
+ }
925
+ /**
926
+ * 兼容 V1 版本的 CSS 变量
927
+ */
928
+ toLegacyCSSVariables(prefix = "--widget") {
929
+ const result = {};
930
+ if (this.colors) {
931
+ if (this.colors.background) {
932
+ result[`${prefix}-background-color`] = this.colors.background;
933
+ }
934
+ if (this.colors.foreground) {
935
+ result[`${prefix}-color`] = this.colors.foreground;
936
+ }
937
+ if (this.colors.primary) {
938
+ result[`${prefix}-primary-color`] = this.colors.primary;
939
+ }
940
+ if (this.colors.border) {
941
+ result[`${prefix}-border-color`] = this.colors.border;
942
+ result[`${prefix}-divider-color`] = this.colors.border;
943
+ result[`${prefix}-background-border-color`] = this.colors.border;
944
+ }
945
+ if (this.colors.ring) {
946
+ result[`${prefix}-shadow-color`] = this.colors.ring;
947
+ result[`${prefix}-background-box-shadow-color`] = this.colors.ring;
948
+ }
949
+ }
950
+ if (this.typography) {
951
+ if (this.typography.fontSize) {
952
+ result[`${prefix}-font-size`] = this.typography.fontSize;
953
+ }
954
+ if (this.typography.fontFamily) {
955
+ result[`${prefix}-font-family`] = this.typography.fontFamily;
956
+ }
957
+ }
958
+ if (this.radius) {
959
+ if (this.radius.lg) {
960
+ result[`${prefix}-border-radius`] = this.radius.lg;
961
+ }
962
+ }
963
+ if (this.spacing) {
964
+ result[`${prefix}-padding`] = this.spacing;
965
+ }
966
+ return result;
967
+ }
968
+ /**
969
+ * flatten tokens → CSS variables
970
+ */
971
+ toCSSVariables(prefix = "--widget") {
972
+ const result = {};
973
+ const tokensToWalk = {
974
+ colors: this.colors,
975
+ radius: this.radius,
976
+ typography: this.typography,
977
+ shadow: this.shadow,
978
+ spacing: this.spacing
979
+ };
980
+ const walk = (obj, path = []) => {
981
+ Object.entries(obj).forEach(([key, value]) => {
982
+ if (value === void 0 || value === null) {
983
+ return;
984
+ }
985
+ const newPath = [...path, key];
986
+ if (typeof value === "object") {
987
+ walk(value, newPath);
988
+ } else {
989
+ const varName = `${prefix}-${newPath.map(import_kebabCase.default).join("-")}`;
990
+ result[varName] = String(value);
991
+ }
992
+ });
993
+ };
994
+ walk(tokensToWalk);
995
+ Object.assign(result, this.toLegacyCSSVariables(prefix));
996
+ return result;
997
+ }
998
+ toCSS(selector = ":root") {
999
+ const vars = this.toCSSVariables();
1000
+ const body = Object.entries(vars).map(([k, v]) => ` ${k}: ${v};`).join("\n");
1001
+ return `${selector} {
1002
+ ${body}
1003
+ }`;
1004
+ }
1005
+ injectCSS(el = document.documentElement) {
1006
+ const vars = this.toCSSVariables();
1007
+ Object.entries(vars).forEach(([k, v]) => {
1008
+ el.style.setProperty(k, v);
1009
+ });
1010
+ }
1011
+ removeCSS(el = document.documentElement) {
1012
+ const vars = this.toCSSVariables();
1013
+ Object.keys(vars).forEach((k) => el.style.removeProperty(k));
1014
+ }
1015
+ /**
1016
+ * 支持主题切换(light/dark)
1017
+ */
1018
+ setMode(mode) {
1019
+ if (this.mode === mode) {
1020
+ return;
1021
+ }
1022
+ this.mode = mode;
1023
+ const baseTheme = mode === "light" ? DefaultThemeLight : DefaultThemeDark;
1024
+ this.colors = structuredClone(baseTheme.colors);
1025
+ this.shadow = structuredClone(baseTheme.shadow);
1026
+ }
1027
+ copy(partial) {
1028
+ return new _AppTheme(merge__default.default({}, structuredClone(this), partial));
1029
+ }
1030
+ static fromCSS(css) {
1031
+ const ast = cssTree.parse(css);
1032
+ const rootRule = cssTree.find(ast, (node, _item, _list) => {
1033
+ if (node.type == "Rule") {
1034
+ const prelude = node.prelude;
1035
+ if (prelude.type == "SelectorList") {
1036
+ const isRoot = prelude.children.some((it) => {
1037
+ return it.type == "Selector" && it.children.some((child) => child.type == "PseudoClassSelector" && child.name == "root");
1038
+ });
1039
+ if (isRoot) {
1040
+ return true;
1041
+ }
1042
+ }
1043
+ }
1044
+ return false;
1045
+ });
1046
+ if (rootRule == null) {
1047
+ return new _AppTheme();
1048
+ }
1049
+ const widgetVariables = rootRule.block.children.filter((it) => it.type == "Declaration" && it.property.startsWith("--widget-"));
1050
+ const themeOptions = {};
1051
+ for (const cssNode of widgetVariables) {
1052
+ const propStr = cssNode.property.replace("--widget-", "");
1053
+ const firstDashIndex = propStr.indexOf("-");
1054
+ const value = cssNode.value.value?.trim() || "";
1055
+ if (firstDashIndex !== -1) {
1056
+ const category = propStr.substring(0, firstDashIndex);
1057
+ const property = (0, import_camelCase.default)(propStr.substring(firstDashIndex + 1));
1058
+ if (!themeOptions[category]) {
1059
+ themeOptions[category] = {};
1060
+ }
1061
+ themeOptions[category][property] = value;
1062
+ } else {
1063
+ const category = (0, import_camelCase.default)(propStr);
1064
+ themeOptions[category] = value;
1065
+ }
1066
+ }
1067
+ return new _AppTheme(themeOptions);
1068
+ }
1069
+ };
1070
+
1071
+ // src/model/DeployedPage.ts
1072
+ var DeployedPage = class {
1073
+ name;
1074
+ packageName;
1075
+ x = 0;
1076
+ y = 0;
1077
+ height = 600;
1078
+ width = 800;
1079
+ proxy;
1080
+ id;
1081
+ isIgnoreMouseEvents;
1082
+ };
1083
+
1084
+ // src/model/DeployMode.ts
1085
+ var HostedMode = /* @__PURE__ */ ((HostedMode2) => {
1086
+ HostedMode2[HostedMode2["NORMAL"] = 1] = "NORMAL";
1087
+ HostedMode2[HostedMode2["OVERLAP"] = 16] = "OVERLAP";
1088
+ HostedMode2[HostedMode2["WALLPAPER"] = 256] = "WALLPAPER";
1089
+ HostedMode2[HostedMode2["SCREEN"] = 4096] = "SCREEN";
1090
+ HostedMode2[HostedMode2["BACKGROUND"] = 65536] = "BACKGROUND";
1091
+ HostedMode2[HostedMode2["PAGE"] = 1048576] = "PAGE";
1092
+ HostedMode2[HostedMode2["ALL"] = 1118481] = "ALL";
1093
+ return HostedMode2;
1094
+ })(HostedMode || {});
1095
+ var DeployMode = /* @__PURE__ */ ((DeployMode2) => {
1096
+ DeployMode2[DeployMode2["NORMAL"] = 1] = "NORMAL";
1097
+ DeployMode2[DeployMode2["OVERLAP"] = 16] = "OVERLAP";
1098
+ DeployMode2[DeployMode2["BACKGROUND"] = 65536] = "BACKGROUND";
1099
+ DeployMode2[DeployMode2["TRAY"] = 256] = "TRAY";
1100
+ DeployMode2[DeployMode2["ALL"] = 1118481] = "ALL";
1101
+ return DeployMode2;
1102
+ })(DeployMode || {});
1103
+
1104
+ // src/model/DeployedWidget.ts
1105
+ var DeployedWidget = class extends DeployedPage {
1106
+ shortcut;
1107
+ deployMode;
1108
+ isOverlap() {
1109
+ return (this.deployMode & 16 /* OVERLAP */) > 0;
1110
+ }
1111
+ };
1112
+
1113
+ // src/model/event/BroadcastEvent.ts
1114
+ var BroadcastEvent = class {
1115
+ event;
1116
+ sender;
1117
+ payload;
1118
+ constructor(options) {
1119
+ this.event = options.event;
1120
+ this.sender = options.sender;
1121
+ this.payload = options.payload;
1122
+ }
1123
+ };
1124
+
1125
+ // src/model/event/WebSocketEvent.ts
1126
+ var WebSocketEventType = /* @__PURE__ */ ((WebSocketEventType2) => {
1127
+ WebSocketEventType2["RESISTER_PACKAGE"] = "ws::cn.widgetjs.core.resister_package";
1128
+ return WebSocketEventType2;
1129
+ })(WebSocketEventType || {});
1130
+ var WebSocketEvent = class {
1131
+ // 类型
1132
+ type;
1133
+ payload;
1134
+ constructor(type, payload) {
1135
+ this.type = type;
1136
+ this.payload = payload;
1137
+ }
1138
+ };
1139
+
1140
+ // src/utils/ElectronUtils.ts
1141
+ var ElectronUtils = class {
1142
+ static hasElectronApi() {
1143
+ return this.getAPI() != null;
1144
+ }
1145
+ /**
1146
+ * 获取ElectronAPI
1147
+ * windows api
1148
+ */
1149
+ static getAPI() {
1150
+ if (Reflect.has(window, "electronAPI")) {
1151
+ return window.electronAPI;
1152
+ } else if (Reflect.has(window.parent, "electronAPI")) {
1153
+ return window.parent.electronAPI;
1154
+ }
1155
+ return null;
1156
+ }
1157
+ static async invokeMethod(channel, method, ...args) {
1158
+ return this.getAPI()?.invoke(channel, method, ...args);
1159
+ }
1160
+ static async invoke(channel, ...args) {
1161
+ return this.getAPI()?.invoke(channel, ...args);
1162
+ }
1163
+ };
1164
+
1165
+ // src/utils/LanguageUtils.ts
1166
+ var LanguageUtils = class {
1167
+ static findText(langMap, localeCode) {
1168
+ const locales = Object.keys(langMap).map((key) => new Intl.Locale(key));
1169
+ const targetLocale = new Intl.Locale(localeCode);
1170
+ let find3 = locales.find((locale) => locale.baseName == targetLocale.baseName);
1171
+ if (!find3) {
1172
+ find3 = locales.find((locale) => locale.language == targetLocale.language);
1173
+ }
1174
+ return find3;
1175
+ }
1176
+ /**
1177
+ * Get text from `LanguageTextMap` by Unicode locale identifier.
1178
+ * `localeCode` > `localeCode` without region > browser default language > English > first language
1179
+ * @param langMap 对象
1180
+ * @param {LanguageCode} localeCode `zh-CN`、`en-US`、 `zh`、`en`
1181
+ * @param fallbackToBrowser
1182
+ */
1183
+ static getTextByLocate(langMap, localeCode, fallbackToBrowser = true) {
1184
+ let result;
1185
+ if (localeCode) {
1186
+ if (localeCode in langMap) {
1187
+ return langMap[localeCode];
1188
+ }
1189
+ }
1190
+ if (localeCode) {
1191
+ const find3 = this.findText(langMap, localeCode);
1192
+ if (find3) {
1193
+ return langMap[find3.baseName];
1194
+ }
1195
+ }
1196
+ if (result == void 0 && fallbackToBrowser) {
1197
+ if (typeof navigator != "undefined" && navigator.languages) {
1198
+ const langCode = navigator.language;
1199
+ result = this.getTextByLocate(langMap, langCode, false);
1200
+ if (result != void 0) {
1201
+ return result;
1202
+ }
1203
+ }
1204
+ }
1205
+ if (result == void 0) {
1206
+ const find3 = this.findText(langMap, "en");
1207
+ if (find3) {
1208
+ return langMap[find3.baseName];
1209
+ }
1210
+ }
1211
+ if (result == void 0) {
1212
+ const langCode = Object.keys(langMap);
1213
+ if (langCode.length > 0) {
1214
+ return langMap[langCode[0]];
1215
+ }
1216
+ }
1217
+ return void 0;
1218
+ }
1219
+ };
1220
+
1221
+ // src/utils/WidgetUtils.ts
1222
+ var WidgetUtils = class {
1223
+ /**
1224
+ * 是否支持悬浮窗
863
1225
  */
864
1226
  static isSupportOverlap(supportDeployMode) {
865
1227
  return (supportDeployMode & 16 /* OVERLAP */) > 0;
@@ -1047,6 +1409,16 @@ var Page = class _Page {
1047
1409
  }
1048
1410
  };
1049
1411
 
1412
+ // src/model/SocialInfo.ts
1413
+ var SocialInfo = class {
1414
+ content;
1415
+ name;
1416
+ constructor(name, content) {
1417
+ this.name = name;
1418
+ this.content = content;
1419
+ }
1420
+ };
1421
+
1050
1422
  // src/model/Widget.ts
1051
1423
  var Widget = class _Widget extends Page {
1052
1424
  categories;
@@ -1148,39 +1520,12 @@ var WidgetKeyword = /* @__PURE__ */ ((WidgetKeyword2) => {
1148
1520
  return WidgetKeyword2;
1149
1521
  })(WidgetKeyword || {});
1150
1522
 
1151
- // src/model/event/BroadcastEvent.ts
1152
- var BroadcastEvent = class {
1153
- event;
1154
- sender;
1155
- payload;
1156
- constructor(options) {
1157
- this.event = options.event;
1158
- this.sender = options.sender;
1159
- this.payload = options.payload;
1160
- }
1161
- };
1162
-
1163
- // src/model/event/WebSocketEvent.ts
1164
- var WebSocketEventType = /* @__PURE__ */ ((WebSocketEventType2) => {
1165
- WebSocketEventType2["RESISTER_PACKAGE"] = "ws::cn.widgetjs.core.resister_package";
1166
- return WebSocketEventType2;
1167
- })(WebSocketEventType || {});
1168
- var WebSocketEvent = class {
1169
- // 类型
1170
- type;
1171
- payload;
1172
- constructor(type, payload) {
1173
- this.type = type;
1174
- this.payload = payload;
1175
- }
1176
- };
1177
-
1178
1523
  // src/model/WidgetData.ts
1179
- var import_kebabCase2 = __toESM(require_kebabCase());
1524
+ var import_kebabCase3 = __toESM(require_kebabCase());
1180
1525
 
1181
1526
  // src/model/WidgetTheme.ts
1182
- var import_kebabCase = __toESM(require_kebabCase());
1183
- var import_camelCase = __toESM(require_camelCase());
1527
+ var import_camelCase2 = __toESM(require_camelCase());
1528
+ var import_kebabCase2 = __toESM(require_kebabCase());
1184
1529
  var WidgetTheme = class _WidgetTheme {
1185
1530
  borderRadius;
1186
1531
  backgroundColor;
@@ -1254,7 +1599,7 @@ ${cssVariables}
1254
1599
  const prefix = "--widget-";
1255
1600
  const keys = Object.keys(this);
1256
1601
  keys.filter((key) => this[key] != void 0).forEach((key) => {
1257
- variables[`${prefix}${(0, import_kebabCase.default)(key)}`] = `${this[key]}`;
1602
+ variables[`${prefix}${(0, import_kebabCase2.default)(key)}`] = `${this[key]}`;
1258
1603
  });
1259
1604
  return variables;
1260
1605
  }
@@ -1262,7 +1607,7 @@ ${cssVariables}
1262
1607
  const properties = {};
1263
1608
  const keys = Object.keys(this);
1264
1609
  keys.filter((key) => this[key] != void 0).forEach((key) => {
1265
- properties[`${(0, import_kebabCase.default)(key)}`] = `${this[key]}`;
1610
+ properties[`${(0, import_kebabCase2.default)(key)}`] = `${this[key]}`;
1266
1611
  });
1267
1612
  return properties;
1268
1613
  }
@@ -1288,7 +1633,7 @@ ${cssVariables}
1288
1633
  const widgetVariables = rootRule.block.children.filter((it) => it.type == "Declaration" && it.property.startsWith("--widget-"));
1289
1634
  const themeOptions = {};
1290
1635
  for (const cssNode of widgetVariables) {
1291
- const prop = (0, import_camelCase.default)(cssNode.property.replace("--widget-", ""));
1636
+ const prop = (0, import_camelCase2.default)(cssNode.property.replace("--widget-", ""));
1292
1637
  themeOptions[prop] = cssNode.value.value.trim();
1293
1638
  }
1294
1639
  return new _WidgetTheme(themeOptions);
@@ -1367,7 +1712,7 @@ var WidgetData = class {
1367
1712
  const prefix = "--widget-";
1368
1713
  const keys = Object.keys(this.theme);
1369
1714
  keys.filter((key) => this.theme[key] != void 0).forEach((key) => {
1370
- properties[`${prefix}${(0, import_kebabCase2.default)(key)}`] = `${this.theme[key]}`;
1715
+ properties[`${prefix}${(0, import_kebabCase3.default)(key)}`] = `${this.theme[key]}`;
1371
1716
  });
1372
1717
  }
1373
1718
  return properties;
@@ -1384,6 +1729,159 @@ var WidgetData = class {
1384
1729
  }
1385
1730
  };
1386
1731
 
1732
+ // src/model/WidgetPackage.ts
1733
+ var WidgetPackage = class _WidgetPackage {
1734
+ /**
1735
+ * 组件包名,一般为域名倒写,e.g. com.example
1736
+ */
1737
+ name;
1738
+ /**
1739
+ * 组件包版本,可以为空,默认采用package.json里的版本
1740
+ * e.g. 1.0.2
1741
+ */
1742
+ version;
1743
+ /**
1744
+ * 组件包所需的App版本
1745
+ */
1746
+ requiredAppVersion;
1747
+ /**
1748
+ * 组件作者署名
1749
+ */
1750
+ author;
1751
+ development;
1752
+ /**
1753
+ * 组件首页
1754
+ */
1755
+ homepage;
1756
+ /**
1757
+ * 组件描述
1758
+ */
1759
+ title;
1760
+ /**
1761
+ * 组件描述
1762
+ */
1763
+ description;
1764
+ /**
1765
+ * 本地组件入口文件,通常为 index.html
1766
+ */
1767
+ entry;
1768
+ /**
1769
+ * 远程组件包入口文件
1770
+ * @deprecated
1771
+ */
1772
+ remoteEntry;
1773
+ /**
1774
+ * 组件包json文件路径
1775
+ * @deprecated
1776
+ * @example https://rtugeek.gitee.io/hotspot/widget.json
1777
+ */
1778
+ remotePackage;
1779
+ local;
1780
+ remote;
1781
+ /**
1782
+ * zip package url, used for downloading the package
1783
+ */
1784
+ zipUrl;
1785
+ /**
1786
+ * 组件包图标
1787
+ */
1788
+ icon;
1789
+ /**
1790
+ * Hash路由模式,默认为true
1791
+ */
1792
+ hash = true;
1793
+ /**
1794
+ * 可能是网络地址,或者本地路径(解压后的文件夹路径),
1795
+ * 网络地址:https://www.bilibili.com
1796
+ * 本地地址:file:///C:/Users/neo/Desktop
1797
+ * 在测试时。地址通常为: http://127.0.0.1:8080
1798
+ */
1799
+ url;
1800
+ widgets = [];
1801
+ pages = [];
1802
+ devOptions;
1803
+ constructor(options) {
1804
+ this.name = options.name;
1805
+ this.development = options.development;
1806
+ this.version = options.version;
1807
+ this.author = options.author;
1808
+ this.homepage = options.homepage;
1809
+ this.title = options.title;
1810
+ this.description = options.description;
1811
+ this.entry = options.entry ?? "index.html";
1812
+ this.remoteEntry = options.remoteEntry;
1813
+ this.requiredAppVersion = options.requiredAppVersion;
1814
+ this.remotePackage = options.remotePackage;
1815
+ this.hash = options.hash ?? false;
1816
+ this.url = "";
1817
+ this.icon = options.icon;
1818
+ this.devOptions = options.devOptions;
1819
+ this.zipUrl = options.zipUrl;
1820
+ this.remote = options.remote;
1821
+ if (options.widgets) {
1822
+ for (const widget of options.widgets) {
1823
+ this.widgets.push(widget);
1824
+ }
1825
+ }
1826
+ }
1827
+ static parseJSON(json) {
1828
+ const object = JSON.parse(json);
1829
+ return this.parseObject(object);
1830
+ }
1831
+ static parseObject(obj) {
1832
+ const widgetPackage = new _WidgetPackage({
1833
+ author: "",
1834
+ description: {
1835
+ "zh-CN": ""
1836
+ },
1837
+ entry: "",
1838
+ hash: false,
1839
+ homepage: "",
1840
+ name: "",
1841
+ title: {
1842
+ "zh-CN": ""
1843
+ },
1844
+ version: ""
1845
+ });
1846
+ Object.assign(widgetPackage, obj);
1847
+ const widgets = [];
1848
+ if (widgetPackage.widgets) {
1849
+ for (const jsonWidget of widgetPackage.widgets) {
1850
+ const widget = new Widget({
1851
+ previewImage: "",
1852
+ path: "",
1853
+ description: { "zh-CN": "" },
1854
+ height: 0,
1855
+ keywords: [],
1856
+ lang: "zh-CN",
1857
+ name: "",
1858
+ title: { "zh-CN": "" },
1859
+ width: 0
1860
+ });
1861
+ Object.assign(widget, jsonWidget);
1862
+ widgets.push(widget);
1863
+ }
1864
+ }
1865
+ widgetPackage.widgets.splice(0, widgetPackage.widgets.length);
1866
+ widgetPackage.widgets.push(...widgets);
1867
+ return widgetPackage;
1868
+ }
1869
+ /**
1870
+ * 获取组件包标题
1871
+ * @param lang 语言环境,不传则获取默认语言
1872
+ */
1873
+ getTitle(lang) {
1874
+ return LanguageUtils.getTextByLocate(this.title, lang);
1875
+ }
1876
+ /**
1877
+ * 获取组件包描述
1878
+ * @param lang 语言环境,不传则获取默认标题
1879
+ */
1880
+ getDescription(lang) {
1881
+ return LanguageUtils.getTextByLocate(this.description, lang);
1882
+ }
1883
+ };
1884
+
1387
1885
  // src/model/WidgetParams.ts
1388
1886
  var import_snakeCase = __toESM(require_snakeCase());
1389
1887
 
@@ -1596,1101 +2094,1162 @@ var ThemeMode = /* @__PURE__ */ ((ThemeMode2) => {
1596
2094
  return ThemeMode2;
1597
2095
  })(ThemeMode || {});
1598
2096
 
1599
- // src/model/AppNotification.ts
1600
- var NotificationSize = /* @__PURE__ */ ((NotificationSize2) => {
1601
- NotificationSize2["SMALL"] = "small";
1602
- NotificationSize2["NORMAL"] = "normal";
1603
- NotificationSize2["LARGE"] = "large";
1604
- return NotificationSize2;
1605
- })(NotificationSize || {});
1606
- var AppNotification = class {
1607
- type = "info";
1608
- message;
1609
- title;
1610
- targetTime;
1611
- /**
1612
- * 持续时间,单位毫秒
1613
- */
1614
- duration;
1615
- /**
1616
- * IconPark图标
1617
- * @example close-one
1618
- * @see [IconPark](https://iconpark.oceanengine.com/official)
1619
- */
1620
- icon;
1621
- color;
1622
- backgroundColor;
1623
- confirmButtonText;
1624
- cancelButtonText;
1625
- cancelBroadcast;
1626
- confirmBroadcast;
1627
- size;
1628
- url;
1629
- avatar;
1630
- audio;
1631
- lyric;
1632
- createdAt;
1633
- constructor(option) {
1634
- this.createdAt = (/* @__PURE__ */ new Date()).toISOString();
1635
- this.type = option.type ?? "info";
1636
- this.title = option.title;
1637
- this.message = option.message;
1638
- this.targetTime = option.targetTime;
1639
- this.duration = option.duration ?? 5e3;
1640
- this.icon = option.icon;
1641
- this.color = option.color ?? "#5D8AC8";
1642
- this.confirmButtonText = option.confirmButtonText;
1643
- this.cancelButtonText = option.cancelButtonText;
1644
- this.cancelBroadcast = option.cancelBroadcast;
1645
- this.confirmBroadcast = option.confirmBroadcast;
1646
- this.size = option.size ?? "normal" /* NORMAL */;
1647
- this.audio = option.audio;
1648
- this.avatar = option.avatar;
1649
- this.lyric = option.lyric;
1650
- this.backgroundColor = option.backgroundColor ?? "#000000";
2097
+ // src/lang/LanguageCode.ts
2098
+ var LanguageMap = class {
2099
+ "ar-SA" = { baseName: "ar-SA", language: "ar", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" };
2100
+ "bn-BD" = { baseName: "bn-BD", language: "bn", nativeName: "\u09AC\u09BE\u0982\u09B2\u09BE" };
2101
+ "en-US" = { baseName: "en-US", language: "en", nativeName: "English" };
2102
+ "de-DE" = { baseName: "de-DE", language: "de", nativeName: "Deutsch" };
2103
+ "el-GR" = { baseName: "el-GR", language: "el", nativeName: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC" };
2104
+ "es-ES" = { baseName: "es-ES", language: "es", nativeName: "Espa\xF1ol", region: "ES" };
2105
+ "fi-FI" = { baseName: "fi-FI", language: "fi", nativeName: "Suomalainen" };
2106
+ "fil-PH" = { baseName: "fil-PH", language: "fil", nativeName: "Filipino" };
2107
+ "fr-FR" = { baseName: "fr-FR", language: "fr", nativeName: "Fran\xE7ais" };
2108
+ "hi-IN" = { baseName: "hi-IN", language: "hi", nativeName: "\u0939\u093F\u0902\u0926\u0940" };
2109
+ "hu-HU" = { baseName: "hu-HU", language: "hu", nativeName: "Magyar" };
2110
+ "id-ID" = { baseName: "id-ID", language: "id", nativeName: "Bahasa Indonesia" };
2111
+ "it-IT" = { baseName: "it-IT", language: "it", nativeName: "Italiano" };
2112
+ "ja-JP" = { baseName: "ja-JP", language: "ja", nativeName: "\u65E5\u672C\u8A9E" };
2113
+ "ko-KR" = { baseName: "ko-KR", language: "ko", nativeName: "\uD55C\uAD6D\uC5B4" };
2114
+ "nl-NL" = { baseName: "nl-NL", language: "nl", nativeName: "Nederlands" };
2115
+ "pl-PL" = { baseName: "pl-PL", language: "pl", nativeName: "Polski" };
2116
+ "pt-BR" = { baseName: "pt-BR", language: "pt", nativeName: "Portugu\xEAs (Brazil)", region: "BR" };
2117
+ "pt-PT" = { baseName: "pt-PT", language: "pt", nativeName: "Portugu\xEAs" };
2118
+ "ro-RO" = { baseName: "ro-RO", language: "ro", nativeName: "Rom\xE2n\u0103" };
2119
+ "ru-RU" = { baseName: "ru-RU", language: "ru", nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439" };
2120
+ "sv-SE" = { baseName: "sv-SE", language: "sv", nativeName: "Svenska" };
2121
+ "ta-IN" = { baseName: "ta-IN", language: "ta", nativeName: "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD" };
2122
+ "tr-TR" = { baseName: "tr-TR", language: "tr", nativeName: "T\xFCrk\xE7e" };
2123
+ "uk-UA" = { baseName: "uk-UA", language: "uk", nativeName: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430" };
2124
+ "vi-VN" = { baseName: "vi-VN", language: "vi", nativeName: "Ti\u1EBFng Vi\u1EC7t" };
2125
+ "zh-CN" = { baseName: "zh-CN", language: "zh", nativeName: "\u7B80\u4F53\u4E2D\u6587", region: "CN" };
2126
+ "zh-TW" = { baseName: "zh-TW", language: "zh", nativeName: "\u7E41\u9AD4\u4E2D\u6587", region: "TW" };
2127
+ };
2128
+
2129
+ // src/utils/normalizeUrl.ts
2130
+ var DATA_URL_DEFAULT_MIME_TYPE = "text/plain";
2131
+ var DATA_URL_DEFAULT_CHARSET = "us-ascii";
2132
+ var testParameter = (name, filters) => filters.some((filter) => filter instanceof RegExp ? filter.test(name) : filter === name);
2133
+ var supportedProtocols = /* @__PURE__ */ new Set([
2134
+ "https:",
2135
+ "http:",
2136
+ "file:"
2137
+ ]);
2138
+ function hasCustomProtocol(urlString) {
2139
+ try {
2140
+ const { protocol } = new URL(urlString);
2141
+ return protocol.endsWith(":") && !supportedProtocols.has(protocol);
2142
+ } catch {
2143
+ return false;
2144
+ }
2145
+ }
2146
+ function normalizeDataURL(urlString, option) {
2147
+ const match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString);
2148
+ if (!match) {
2149
+ throw new Error(`Invalid URL: ${urlString}`);
2150
+ }
2151
+ let { type, data, hash } = match.groups;
2152
+ const mediaType = type.split(";");
2153
+ hash = option.stripHash ? "" : hash;
2154
+ let isBase64 = false;
2155
+ if (mediaType[mediaType.length - 1] === "base64") {
2156
+ mediaType.pop();
2157
+ isBase64 = true;
2158
+ }
2159
+ const mimeType = mediaType.shift()?.toLowerCase() ?? "";
2160
+ const attributes = mediaType.map((attribute) => {
2161
+ let [key, value = ""] = attribute.split("=").map((item) => item.trim());
2162
+ if (key === "charset") {
2163
+ value = value.toLowerCase();
2164
+ if (value === DATA_URL_DEFAULT_CHARSET) {
2165
+ return "";
2166
+ }
2167
+ }
2168
+ return `${key}${value ? `=${value}` : ""}`;
2169
+ }).filter(Boolean);
2170
+ const normalizedMediaType = [
2171
+ ...attributes
2172
+ ];
2173
+ if (isBase64) {
2174
+ normalizedMediaType.push("base64");
2175
+ }
2176
+ if (normalizedMediaType.length > 0 || mimeType && mimeType !== DATA_URL_DEFAULT_MIME_TYPE) {
2177
+ normalizedMediaType.unshift(mimeType);
2178
+ }
2179
+ return `data:${normalizedMediaType.join(";")},${isBase64 ? data.trim() : data}${hash ? `#${hash}` : ""}`;
2180
+ }
2181
+ function normalizeUrl(urlString, options) {
2182
+ options = {
2183
+ defaultProtocol: "http",
2184
+ normalizeProtocol: true,
2185
+ forceHttp: false,
2186
+ forceHttps: false,
2187
+ stripAuthentication: true,
2188
+ stripHash: false,
2189
+ stripTextFragment: true,
2190
+ stripWWW: true,
2191
+ removeQueryParameters: [/^utm_\w+/i],
2192
+ removeTrailingSlash: true,
2193
+ removeSingleSlash: true,
2194
+ removeDirectoryIndex: false,
2195
+ removeExplicitPort: false,
2196
+ sortQueryParameters: true,
2197
+ ...options
2198
+ };
2199
+ urlString = urlString.replace("\\\\", "//");
2200
+ if (typeof options.defaultProtocol === "string" && !options.defaultProtocol.endsWith(":")) {
2201
+ options.defaultProtocol = `${options.defaultProtocol}:`;
2202
+ }
2203
+ urlString = urlString.trim();
2204
+ if (/^data:/i.test(urlString)) {
2205
+ return normalizeDataURL(urlString, { stripHash: options.stripHash ?? false });
2206
+ }
2207
+ if (hasCustomProtocol(urlString)) {
2208
+ return urlString;
2209
+ }
2210
+ const hasRelativeProtocol = urlString.startsWith("//");
2211
+ const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString);
2212
+ if (!isRelativeUrl) {
2213
+ urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol);
2214
+ }
2215
+ const urlObject = new URL(urlString);
2216
+ if (options.forceHttp && options.forceHttps) {
2217
+ throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");
2218
+ }
2219
+ if (options.forceHttp && urlObject.protocol === "https:") {
2220
+ urlObject.protocol = "http:";
2221
+ }
2222
+ if (options.forceHttps && urlObject.protocol === "http:") {
2223
+ urlObject.protocol = "https:";
2224
+ }
2225
+ if (options.stripAuthentication) {
2226
+ urlObject.username = "";
2227
+ urlObject.password = "";
2228
+ }
2229
+ if (options.stripHash) {
2230
+ urlObject.hash = "";
2231
+ } else if (options.stripTextFragment) {
2232
+ urlObject.hash = urlObject.hash.replace(/#?:~:text.*?$/i, "");
2233
+ }
2234
+ if (urlObject.pathname) {
2235
+ const protocolRegex = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g;
2236
+ let lastIndex = 0;
2237
+ let result = "";
2238
+ for (; ; ) {
2239
+ const match = protocolRegex.exec(urlObject.pathname);
2240
+ if (!match) {
2241
+ break;
2242
+ }
2243
+ const protocol = match[0];
2244
+ const protocolAtIndex = match.index;
2245
+ const intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex);
2246
+ result += intermediate.replace(/\/{2,}/g, "/");
2247
+ result += protocol;
2248
+ lastIndex = protocolAtIndex + protocol.length;
2249
+ }
2250
+ const remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length);
2251
+ result += remnant.replace(/\/{2,}/g, "/");
2252
+ urlObject.pathname = result;
2253
+ }
2254
+ if (urlObject.pathname) {
2255
+ try {
2256
+ urlObject.pathname = decodeURI(urlObject.pathname);
2257
+ } catch {
2258
+ }
2259
+ }
2260
+ if (options.removeDirectoryIndex === true) {
2261
+ options.removeDirectoryIndex = [/^index\.[a-z]+$/];
2262
+ }
2263
+ if (Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) {
2264
+ let pathComponents = urlObject.pathname.split("/");
2265
+ const lastComponent = pathComponents[pathComponents.length - 1];
2266
+ if (testParameter(lastComponent, options.removeDirectoryIndex)) {
2267
+ pathComponents = pathComponents.slice(0, -1);
2268
+ urlObject.pathname = `${pathComponents.slice(1).join("/")}/`;
2269
+ }
2270
+ }
2271
+ if (urlObject.hostname) {
2272
+ urlObject.hostname = urlObject.hostname.replace(/\.$/, "");
2273
+ if (options.stripWWW && /^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(urlObject.hostname)) {
2274
+ urlObject.hostname = urlObject.hostname.replace(/^www\./, "");
2275
+ }
2276
+ }
2277
+ if (Array.isArray(options.removeQueryParameters)) {
2278
+ for (const key of [...urlObject.searchParams.keys()]) {
2279
+ if (testParameter(key, options.removeQueryParameters)) {
2280
+ urlObject.searchParams.delete(key);
2281
+ }
2282
+ }
2283
+ }
2284
+ if (!Array.isArray(options.keepQueryParameters) && options.removeQueryParameters === true) {
2285
+ urlObject.search = "";
2286
+ }
2287
+ if (Array.isArray(options.keepQueryParameters) && options.keepQueryParameters.length > 0) {
2288
+ for (const key of [...urlObject.searchParams.keys()]) {
2289
+ if (!testParameter(key, options.keepQueryParameters)) {
2290
+ urlObject.searchParams.delete(key);
2291
+ }
2292
+ }
2293
+ }
2294
+ if (options.sortQueryParameters) {
2295
+ urlObject.searchParams.sort();
2296
+ try {
2297
+ urlObject.search = decodeURIComponent(urlObject.search);
2298
+ } catch {
2299
+ }
1651
2300
  }
1652
- };
1653
- var AppReminderNotification = class extends AppNotification {
1654
- constructor(option) {
1655
- super(option);
1656
- this.type = "reminder";
1657
- this.size = "large" /* LARGE */;
2301
+ if (options.removeTrailingSlash) {
2302
+ urlObject.pathname = urlObject.pathname.replace(/\/$/, "");
1658
2303
  }
1659
- };
1660
-
1661
- // src/model/DeployedPage.ts
1662
- var DeployedPage = class {
1663
- name;
1664
- packageName;
1665
- x = 0;
1666
- y = 0;
1667
- height = 600;
1668
- width = 800;
1669
- proxy;
1670
- id;
1671
- isIgnoreMouseEvents;
1672
- };
1673
-
1674
- // src/model/SocialInfo.ts
1675
- var SocialInfo = class {
1676
- content;
1677
- name;
1678
- constructor(name, content) {
1679
- this.name = name;
1680
- this.content = content;
2304
+ if (options.removeExplicitPort && urlObject.port) {
2305
+ urlObject.port = "";
1681
2306
  }
1682
- };
2307
+ const oldUrlString = urlString;
2308
+ urlString = urlObject.toString();
2309
+ if (!options.removeSingleSlash && urlObject.pathname === "/" && !oldUrlString.endsWith("/") && urlObject.hash === "") {
2310
+ urlString = urlString.replace(/\/$/, "");
2311
+ }
2312
+ if ((options.removeTrailingSlash || urlObject.pathname === "/") && urlObject.hash === "" && options.removeSingleSlash) {
2313
+ urlString = urlString.replace(/\/$/, "");
2314
+ }
2315
+ if (hasRelativeProtocol && !options.normalizeProtocol) {
2316
+ urlString = urlString.replace(/^http:\/\//, "//");
2317
+ }
2318
+ if (options.stripProtocol) {
2319
+ urlString = urlString.replace(/^(?:https?:)?\/\//, "");
2320
+ }
2321
+ return urlString;
2322
+ }
1683
2323
 
1684
- // src/model/DeployedWidget.ts
1685
- var DeployedWidget = class extends DeployedPage {
1686
- shortcut;
1687
- deployMode;
1688
- isOverlap() {
1689
- return (this.deployMode & 16 /* OVERLAP */) > 0;
2324
+ // src/grid/GridSystem.ts
2325
+ var GridRect = class {
2326
+ top;
2327
+ left;
2328
+ width;
2329
+ height;
2330
+ constructor(left, top, width, height) {
2331
+ this.top = top;
2332
+ this.left = left;
2333
+ this.width = width;
2334
+ this.height = height;
2335
+ }
2336
+ get right() {
2337
+ return this.left + this.width;
2338
+ }
2339
+ get bottom() {
2340
+ return this.top + this.height;
1690
2341
  }
1691
2342
  };
1692
-
1693
- // src/model/WidgetPackage.ts
1694
- var WidgetPackage = class _WidgetPackage {
1695
- /**
1696
- * 组件包名,一般为域名倒写,e.g. com.example
1697
- */
1698
- name;
1699
- /**
1700
- * 组件包版本,可以为空,默认采用package.json里的版本
1701
- * e.g. 1.0.2
1702
- */
1703
- version;
1704
- /**
1705
- * 组件包所需的App版本
1706
- */
1707
- requiredAppVersion;
1708
- /**
1709
- * 组件作者署名
1710
- */
1711
- author;
1712
- development;
1713
- /**
1714
- * 组件首页
1715
- */
1716
- homepage;
1717
- /**
1718
- * 组件描述
1719
- */
1720
- title;
1721
- /**
1722
- * 组件描述
1723
- */
1724
- description;
1725
- /**
1726
- * 本地组件入口文件,通常为 index.html
1727
- */
1728
- entry;
1729
- /**
1730
- * 远程组件包入口文件
1731
- * @deprecated
1732
- */
1733
- remoteEntry;
1734
- /**
1735
- * 组件包json文件路径
1736
- * @deprecated
1737
- * @example https://rtugeek.gitee.io/hotspot/widget.json
1738
- */
1739
- remotePackage;
1740
- local;
1741
- remote;
2343
+ var GridSystem = class extends GridRect {
2344
+ cellSize;
2345
+ horizontalCellCount;
2346
+ verticalCellCount;
2347
+ screenWidth;
2348
+ screenHeight;
1742
2349
  /**
1743
- * zip package url, used for downloading the package
2350
+ * 屏幕x坐标,用于解决多块屏幕坐标计算问题
1744
2351
  */
1745
- zipUrl;
2352
+ screenLeft;
1746
2353
  /**
1747
- * 组件包图标
2354
+ * 屏幕y坐标,用于解决多块屏幕坐标计算问题
1748
2355
  */
1749
- icon;
2356
+ screenTop;
2357
+ canvasScreenTop;
2358
+ canvasScreenLeft;
1750
2359
  /**
1751
- * Hash路由模式,默认为true
2360
+ *
2361
+ * @param cellSize
2362
+ * @param padding 至少保留的边距
2363
+ * @param screenWidth
2364
+ * @param screenHeight
2365
+ * @param screenX
2366
+ * @param screenY
1752
2367
  */
1753
- hash = true;
2368
+ constructor(cellSize, padding, screenWidth, screenHeight, screenX, screenY) {
2369
+ const gridMaxWidth = screenWidth - padding * 2;
2370
+ const gridMaxHeight = screenHeight - padding * 2;
2371
+ const horizontalPadding = gridMaxWidth % cellSize / 2 + padding;
2372
+ const verticalPadding = gridMaxHeight % cellSize / 2 + padding;
2373
+ const horizontalCellCount = Math.floor(gridMaxWidth / cellSize);
2374
+ const verticalCellCount = Math.floor(gridMaxHeight / cellSize);
2375
+ super(horizontalPadding, verticalPadding, horizontalCellCount * cellSize, verticalCellCount * cellSize);
2376
+ this.canvasScreenLeft = horizontalPadding + (screenX ?? 0);
2377
+ this.canvasScreenTop = verticalPadding + (screenY ?? 0);
2378
+ this.cellSize = cellSize;
2379
+ this.screenWidth = screenWidth;
2380
+ this.screenHeight = screenHeight;
2381
+ this.horizontalCellCount = horizontalCellCount;
2382
+ this.verticalCellCount = verticalCellCount;
2383
+ this.screenLeft = screenX;
2384
+ this.screenTop = screenY;
2385
+ }
1754
2386
  /**
1755
- * 可能是网络地址,或者本地路径(解压后的文件夹路径),
1756
- * 网络地址:https://www.bilibili.com
1757
- * 本地地址:file:///C:/Users/neo/Desktop
1758
- * 在测试时。地址通常为: http://127.0.0.1:8080
2387
+ * 将坐标对齐到网格上
2388
+ * @param x
2389
+ * @param y
2390
+ * @param gridSystem
1759
2391
  */
1760
- url;
1761
- widgets = [];
1762
- pages = [];
1763
- devOptions;
1764
- constructor(options) {
1765
- this.name = options.name;
1766
- this.development = options.development;
1767
- this.version = options.version;
1768
- this.author = options.author;
1769
- this.homepage = options.homepage;
1770
- this.title = options.title;
1771
- this.description = options.description;
1772
- this.entry = options.entry ?? "index.html";
1773
- this.remoteEntry = options.remoteEntry;
1774
- this.requiredAppVersion = options.requiredAppVersion;
1775
- this.remotePackage = options.remotePackage;
1776
- this.hash = options.hash ?? false;
1777
- this.url = "";
1778
- this.icon = options.icon;
1779
- this.devOptions = options.devOptions;
1780
- this.zipUrl = options.zipUrl;
1781
- this.remote = options.remote;
1782
- if (options.widgets) {
1783
- for (const widget of options.widgets) {
1784
- this.widgets.push(widget);
1785
- }
1786
- }
1787
- }
1788
- static parseJSON(json) {
1789
- const object = JSON.parse(json);
1790
- return this.parseObject(object);
2392
+ snapCanvasPosition(x, y) {
2393
+ const newX = this.getRangeValue(x - this.left, 0, this.right);
2394
+ const newY = this.getRangeValue(y - this.top, 0, this.bottom);
2395
+ return this.snapPosition(newX, newY);
1791
2396
  }
1792
- static parseObject(obj) {
1793
- const widgetPackage = new _WidgetPackage({
1794
- author: "",
1795
- description: {
1796
- "zh-CN": ""
1797
- },
1798
- entry: "",
1799
- hash: false,
1800
- homepage: "",
1801
- name: "",
1802
- title: {
1803
- "zh-CN": ""
1804
- },
1805
- version: ""
1806
- });
1807
- Object.assign(widgetPackage, obj);
1808
- const widgets = [];
1809
- if (widgetPackage.widgets) {
1810
- for (const jsonWidget of widgetPackage.widgets) {
1811
- const widget = new Widget({
1812
- previewImage: "",
1813
- path: "",
1814
- description: { "zh-CN": "" },
1815
- height: 0,
1816
- keywords: [],
1817
- lang: "zh-CN",
1818
- name: "",
1819
- title: { "zh-CN": "" },
1820
- width: 0
1821
- });
1822
- Object.assign(widget, jsonWidget);
1823
- widgets.push(widget);
1824
- }
2397
+ snapPosition(newX, newY) {
2398
+ const diffX = newX % this.cellSize;
2399
+ if (diffX >= this.cellSize / 2) {
2400
+ newX = newX + this.cellSize - diffX;
2401
+ } else {
2402
+ newX = newX - diffX;
2403
+ }
2404
+ const diffY = newY % this.cellSize;
2405
+ if (diffY >= this.cellSize / 2) {
2406
+ newY = newY + this.cellSize - diffY;
2407
+ } else {
2408
+ newY = newY - diffY;
2409
+ }
2410
+ return [newX + this.left, newY + this.top];
2411
+ }
2412
+ snapSize(width, height) {
2413
+ let newWidth = Math.floor(width);
2414
+ let newHeight = Math.floor(height);
2415
+ const diffWidth = newWidth % this.cellSize;
2416
+ const diffHeight = newHeight % this.cellSize;
2417
+ if (diffWidth > this.cellSize / 2) {
2418
+ newWidth = width + this.cellSize - diffWidth;
2419
+ } else {
2420
+ newWidth = width - diffWidth;
1825
2421
  }
1826
- widgetPackage.widgets.splice(0, widgetPackage.widgets.length);
1827
- widgetPackage.widgets.push(...widgets);
1828
- return widgetPackage;
2422
+ if (diffHeight > this.cellSize / 2) {
2423
+ newHeight = height + this.cellSize - diffHeight;
2424
+ } else {
2425
+ newHeight = height - diffHeight;
2426
+ }
2427
+ return [newWidth, newHeight];
1829
2428
  }
1830
2429
  /**
1831
- * 获取组件包标题
1832
- * @param lang 语言环境,不传则获取默认语言
2430
+ * 将矩形对齐到网格上
2431
+ * @param rect
2432
+ * @param minWidth
2433
+ * @param maxWidth
2434
+ * @param minHeight
2435
+ * @param maxHeight
1833
2436
  */
1834
- getTitle(lang) {
1835
- return LanguageUtils.getTextByLocate(this.title, lang);
2437
+ snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight) {
2438
+ const [newX, newY] = this.snapCanvasPosition(rect.left, rect.top);
2439
+ return this.snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY);
2440
+ }
2441
+ snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY) {
2442
+ let [newWidth, newHeight] = this.snapSize(rect.width, rect.height);
2443
+ newWidth = this.getRangeValue(newWidth, minWidth, maxWidth);
2444
+ newHeight = this.getRangeValue(newHeight, minHeight, maxHeight);
2445
+ if (newX + newWidth > this.right) {
2446
+ newX = this.right - newWidth;
2447
+ }
2448
+ if (newY + newHeight > this.bottom) {
2449
+ newY = this.bottom - newHeight;
2450
+ }
2451
+ return new GridRect(newX, newY, newWidth, newHeight);
1836
2452
  }
1837
2453
  /**
1838
- * 获取组件包描述
1839
- * @param lang 语言环境,不传则获取默认标题
2454
+ * 将矩形对齐到网格上,与snapRect的区别是,这个会加上屏幕x和y坐标,用于适配多个显示器
2455
+ * @param rect
2456
+ * @param minWidth
2457
+ * @param maxWidth
2458
+ * @param minHeight
2459
+ * @param maxHeight
1840
2460
  */
1841
- getDescription(lang) {
1842
- return LanguageUtils.getTextByLocate(this.description, lang);
2461
+ snapWindow(rect, minWidth, maxWidth, minHeight, maxHeight) {
2462
+ rect.left = rect.left - (this.screenLeft ?? 0);
2463
+ rect.top = rect.top - (this.screenTop ?? 0);
2464
+ const result = this.snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight);
2465
+ return new GridRect(
2466
+ result.left + (this.screenLeft ?? 0),
2467
+ result.top + (this.screenTop ?? 0),
2468
+ result.width,
2469
+ result.height
2470
+ );
2471
+ }
2472
+ /**
2473
+ * 限制值不超出屏幕
2474
+ * @param value
2475
+ * @param min
2476
+ * @param max
2477
+ * @private
2478
+ */
2479
+ getRangeValue(value, min, max) {
2480
+ if (value < min) {
2481
+ return min;
2482
+ }
2483
+ if (value > max) {
2484
+ return max;
2485
+ }
2486
+ return value;
2487
+ }
2488
+ getWidth() {
2489
+ return this.width;
2490
+ }
2491
+ getHeight() {
2492
+ return this.height;
1843
2493
  }
1844
2494
  };
1845
2495
 
1846
- // src/lang/LanguageCode.ts
1847
- var LanguageMap = class {
1848
- "ar-SA" = { baseName: "ar-SA", language: "ar", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" };
1849
- "bn-BD" = { baseName: "bn-BD", language: "bn", nativeName: "\u09AC\u09BE\u0982\u09B2\u09BE" };
1850
- "en-US" = { baseName: "en-US", language: "en", nativeName: "English" };
1851
- "de-DE" = { baseName: "de-DE", language: "de", nativeName: "Deutsch" };
1852
- "el-GR" = { baseName: "el-GR", language: "el", nativeName: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC" };
1853
- "es-ES" = { baseName: "es-ES", language: "es", nativeName: "Espa\xF1ol", region: "ES" };
1854
- "fi-FI" = { baseName: "fi-FI", language: "fi", nativeName: "Suomalainen" };
1855
- "fil-PH" = { baseName: "fil-PH", language: "fil", nativeName: "Filipino" };
1856
- "fr-FR" = { baseName: "fr-FR", language: "fr", nativeName: "Fran\xE7ais" };
1857
- "hi-IN" = { baseName: "hi-IN", language: "hi", nativeName: "\u0939\u093F\u0902\u0926\u0940" };
1858
- "hu-HU" = { baseName: "hu-HU", language: "hu", nativeName: "Magyar" };
1859
- "id-ID" = { baseName: "id-ID", language: "id", nativeName: "Bahasa Indonesia" };
1860
- "it-IT" = { baseName: "it-IT", language: "it", nativeName: "Italiano" };
1861
- "ja-JP" = { baseName: "ja-JP", language: "ja", nativeName: "\u65E5\u672C\u8A9E" };
1862
- "ko-KR" = { baseName: "ko-KR", language: "ko", nativeName: "\uD55C\uAD6D\uC5B4" };
1863
- "nl-NL" = { baseName: "nl-NL", language: "nl", nativeName: "Nederlands" };
1864
- "pl-PL" = { baseName: "pl-PL", language: "pl", nativeName: "Polski" };
1865
- "pt-BR" = { baseName: "pt-BR", language: "pt", nativeName: "Portugu\xEAs (Brazil)", region: "BR" };
1866
- "pt-PT" = { baseName: "pt-PT", language: "pt", nativeName: "Portugu\xEAs" };
1867
- "ro-RO" = { baseName: "ro-RO", language: "ro", nativeName: "Rom\xE2n\u0103" };
1868
- "ru-RU" = { baseName: "ru-RU", language: "ru", nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439" };
1869
- "sv-SE" = { baseName: "sv-SE", language: "sv", nativeName: "Svenska" };
1870
- "ta-IN" = { baseName: "ta-IN", language: "ta", nativeName: "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD" };
1871
- "tr-TR" = { baseName: "tr-TR", language: "tr", nativeName: "T\xFCrk\xE7e" };
1872
- "uk-UA" = { baseName: "uk-UA", language: "uk", nativeName: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430" };
1873
- "vi-VN" = { baseName: "vi-VN", language: "vi", nativeName: "Ti\u1EBFng Vi\u1EC7t" };
1874
- "zh-CN" = { baseName: "zh-CN", language: "zh", nativeName: "\u7B80\u4F53\u4E2D\u6587", region: "CN" };
1875
- "zh-TW" = { baseName: "zh-TW", language: "zh", nativeName: "\u7E41\u9AD4\u4E2D\u6587", region: "TW" };
2496
+ // src/api/ApiConstants.ts
2497
+ var ApiConstants = class {
2498
+ static CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
2499
+ static CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
2500
+ static CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
2501
+ static CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size";
2502
+ static SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
2503
+ };
2504
+ var AppEvent = class {
2505
+ static LANGUAGE_CHANGED = "event::cn.widgetjs.core.app.language.changed";
2506
+ };
2507
+ var AppConfig = class {
2508
+ static LANGUAGE = "cn.widgetjs.config.app.language";
2509
+ static LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
1876
2510
  };
1877
2511
 
1878
- // src/utils/normalizeUrl.ts
1879
- var DATA_URL_DEFAULT_MIME_TYPE = "text/plain";
1880
- var DATA_URL_DEFAULT_CHARSET = "us-ascii";
1881
- var testParameter = (name, filters) => filters.some((filter) => filter instanceof RegExp ? filter.test(name) : filter === name);
1882
- var supportedProtocols = /* @__PURE__ */ new Set([
1883
- "https:",
1884
- "http:",
1885
- "file:"
1886
- ]);
1887
- function hasCustomProtocol(urlString) {
1888
- try {
1889
- const { protocol } = new URL(urlString);
1890
- return protocol.endsWith(":") && !supportedProtocols.has(protocol);
1891
- } catch {
1892
- return false;
2512
+ // src/api/BaseApi.ts
2513
+ var BaseApi = class {
2514
+ async invokeMethod(method, ...args) {
2515
+ return await ElectronUtils.invokeMethod(this.getChannel(), method, ...args);
1893
2516
  }
1894
- }
1895
- function normalizeDataURL(urlString, option) {
1896
- const match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString);
1897
- if (!match) {
1898
- throw new Error(`Invalid URL: ${urlString}`);
2517
+ async invoke(...args) {
2518
+ return await ElectronUtils.invoke(this.getChannel(), ...args);
1899
2519
  }
1900
- let { type, data, hash } = match.groups;
1901
- const mediaType = type.split(";");
1902
- hash = option.stripHash ? "" : hash;
1903
- let isBase64 = false;
1904
- if (mediaType[mediaType.length - 1] === "base64") {
1905
- mediaType.pop();
1906
- isBase64 = true;
2520
+ };
2521
+
2522
+ // src/api/Channel.ts
2523
+ var Channel = /* @__PURE__ */ ((Channel2) => {
2524
+ Channel2["NOTIFICATION"] = "channel::cn.widgetjs.core.notification";
2525
+ Channel2["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
2526
+ Channel2["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
2527
+ Channel2["WIDGET"] = "channel::cn.widgetjs.core.widget";
2528
+ Channel2["WIDGET_PACKAGE"] = "channel::cn.widgetjs.core.widget.package";
2529
+ Channel2["DEPLOYED_WIDGET"] = "channel::cn.widgetjs.core.deployed_widget";
2530
+ Channel2["APP"] = "channel::cn.widgetjs.core.app";
2531
+ Channel2["SYSTEM"] = "channel::cn.widgetjs.core.system";
2532
+ Channel2["DIALOG"] = "channel::cn.widgetjs.core.dialog";
2533
+ Channel2["HTTP"] = "channel::cn.widgetjs.core.http";
2534
+ Channel2["CLIPBOARD"] = "channel::cn.widgetjs.core.clipboard";
2535
+ Channel2["FILE"] = "channel::cn.widgetjs.core.file";
2536
+ Channel2["SCREEN"] = "channel::cn.widgetjs.core.screen";
2537
+ Channel2["MENU"] = "channel::cn.widgetjs.core.menu";
2538
+ Channel2["SHORTCUT"] = "channel::cn.widgetjs.core.shortcut";
2539
+ Channel2["LOG"] = "channel::cn.widgetjs.core.log";
2540
+ Channel2["DEVICE"] = "channel::cn.widgetjs.core.device";
2541
+ Channel2["MOUSE"] = "channel::cn.widgetjs.core.mouse";
2542
+ Channel2["KEYBOARD"] = "channel::cn.widgetjs.core.keyboard";
2543
+ Channel2["STORE"] = "channel::cn.widgetjs.core.store";
2544
+ Channel2["STORAGE"] = "channel::cn.widgetjs.core.storage";
2545
+ Channel2["PROCESS"] = "channel::cn.widgetjs.core.process";
2546
+ Channel2["USER"] = "channel::cn.widgetjs.core.user";
2547
+ Channel2["TRAY"] = "channel::cn.widgetjs.core.tray";
2548
+ Channel2["AI"] = "channel::cn.widgetjs.core.ai";
2549
+ return Channel2;
2550
+ })(Channel || {});
2551
+
2552
+ // src/api/AppApi.ts
2553
+ var AppApiImpl = class extends BaseApi {
2554
+ showAppWindow(route, options) {
2555
+ return this.invokeMethod("showAppWindow", route, options);
1907
2556
  }
1908
- const mimeType = mediaType.shift()?.toLowerCase() ?? "";
1909
- const attributes = mediaType.map((attribute) => {
1910
- let [key, value = ""] = attribute.split("=").map((item) => item.trim());
1911
- if (key === "charset") {
1912
- value = value.toLowerCase();
1913
- if (value === DATA_URL_DEFAULT_CHARSET) {
1914
- return "";
1915
- }
1916
- }
1917
- return `${key}${value ? `=${value}` : ""}`;
1918
- }).filter(Boolean);
1919
- const normalizedMediaType = [
1920
- ...attributes
1921
- ];
1922
- if (isBase64) {
1923
- normalizedMediaType.push("base64");
2557
+ openWidgetPackageManagerWindow() {
2558
+ return this.invokeMethod("openWidgetPackageManagerWindow");
1924
2559
  }
1925
- if (normalizedMediaType.length > 0 || mimeType && mimeType !== DATA_URL_DEFAULT_MIME_TYPE) {
1926
- normalizedMediaType.unshift(mimeType);
2560
+ getRuntimeInfo() {
2561
+ return this.invokeMethod("getRuntimeInfo");
1927
2562
  }
1928
- return `data:${normalizedMediaType.join(";")},${isBase64 ? data.trim() : data}${hash ? `#${hash}` : ""}`;
1929
- }
1930
- function normalizeUrl(urlString, options) {
1931
- options = {
1932
- defaultProtocol: "http",
1933
- normalizeProtocol: true,
1934
- forceHttp: false,
1935
- forceHttps: false,
1936
- stripAuthentication: true,
1937
- stripHash: false,
1938
- stripTextFragment: true,
1939
- stripWWW: true,
1940
- removeQueryParameters: [/^utm_\w+/i],
1941
- removeTrailingSlash: true,
1942
- removeSingleSlash: true,
1943
- removeDirectoryIndex: false,
1944
- removeExplicitPort: false,
1945
- sortQueryParameters: true,
1946
- ...options
1947
- };
1948
- urlString = urlString.replace("\\\\", "//");
1949
- if (typeof options.defaultProtocol === "string" && !options.defaultProtocol.endsWith(":")) {
1950
- options.defaultProtocol = `${options.defaultProtocol}:`;
2563
+ setProxy(config) {
2564
+ return this.invokeMethod("setProxy", config);
2565
+ }
2566
+ getProxy() {
2567
+ return this.invokeMethod("getProxy");
2568
+ }
2569
+ isWindowsStore() {
2570
+ return this.invokeMethod("isWindowsStore");
2571
+ }
2572
+ getAppPath() {
2573
+ return this.invokeMethod("getAppPath");
2574
+ }
2575
+ async getIconFile() {
2576
+ return this.invokeMethod("getIconFile");
1951
2577
  }
1952
- urlString = urlString.trim();
1953
- if (/^data:/i.test(urlString)) {
1954
- return normalizeDataURL(urlString, { stripHash: options.stripHash ?? false });
2578
+ getChannel() {
2579
+ return "channel::cn.widgetjs.core.app" /* APP */;
1955
2580
  }
1956
- if (hasCustomProtocol(urlString)) {
1957
- return urlString;
2581
+ async setConfig(key, value) {
2582
+ return await this.invokeMethod("setConfig", key, value);
1958
2583
  }
1959
- const hasRelativeProtocol = urlString.startsWith("//");
1960
- const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString);
1961
- if (!isRelativeUrl) {
1962
- urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol);
2584
+ async getConfig(key, defaultValue) {
2585
+ const value = await this.invokeMethod("getConfig", key);
2586
+ if (value === null || value === void 0) {
2587
+ return defaultValue;
2588
+ }
2589
+ if (typeof defaultValue == "boolean") {
2590
+ return value === "true";
2591
+ }
2592
+ if (typeof defaultValue == "number") {
2593
+ return Number(value);
2594
+ }
2595
+ return value;
1963
2596
  }
1964
- const urlObject = new URL(urlString);
1965
- if (options.forceHttp && options.forceHttps) {
1966
- throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");
2597
+ async openAddWidgetWindow() {
2598
+ return this.invokeMethod("openAddWidgetWindow");
1967
2599
  }
1968
- if (options.forceHttp && urlObject.protocol === "https:") {
1969
- urlObject.protocol = "http:";
2600
+ async getVersion(type) {
2601
+ return this.invokeMethod("getVersion", type);
1970
2602
  }
1971
- if (options.forceHttps && urlObject.protocol === "http:") {
1972
- urlObject.protocol = "https:";
2603
+ async getPreloadPath() {
2604
+ return this.invokeMethod("getPreloadPath");
1973
2605
  }
1974
- if (options.stripAuthentication) {
1975
- urlObject.username = "";
1976
- urlObject.password = "";
2606
+ async openSettingWindow() {
2607
+ return this.invokeMethod("openSettingWindow");
1977
2608
  }
1978
- if (options.stripHash) {
1979
- urlObject.hash = "";
1980
- } else if (options.stripTextFragment) {
1981
- urlObject.hash = urlObject.hash.replace(/#?:~:text.*?$/i, "");
2609
+ getThemeCSS() {
2610
+ return this.invokeMethod("getThemeCSS");
1982
2611
  }
1983
- if (urlObject.pathname) {
1984
- const protocolRegex = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g;
1985
- let lastIndex = 0;
1986
- let result = "";
1987
- for (; ; ) {
1988
- const match = protocolRegex.exec(urlObject.pathname);
1989
- if (!match) {
1990
- break;
1991
- }
1992
- const protocol = match[0];
1993
- const protocolAtIndex = match.index;
1994
- const intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex);
1995
- result += intermediate.replace(/\/{2,}/g, "/");
1996
- result += protocol;
1997
- lastIndex = protocolAtIndex + protocol.length;
1998
- }
1999
- const remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length);
2000
- result += remnant.replace(/\/{2,}/g, "/");
2001
- urlObject.pathname = result;
2612
+ setThemeCSS(css) {
2613
+ return this.invokeMethod("setThemeCSS", css);
2002
2614
  }
2003
- if (urlObject.pathname) {
2004
- try {
2005
- urlObject.pathname = decodeURI(urlObject.pathname);
2006
- } catch {
2007
- }
2615
+ getDevMode() {
2616
+ return this.invokeMethod("getDevMode");
2008
2617
  }
2009
- if (options.removeDirectoryIndex === true) {
2010
- options.removeDirectoryIndex = [/^index\.[a-z]+$/];
2618
+ setDevMode(enable) {
2619
+ return this.invokeMethod("setDevMode", enable);
2011
2620
  }
2012
- if (Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) {
2013
- let pathComponents = urlObject.pathname.split("/");
2014
- const lastComponent = pathComponents[pathComponents.length - 1];
2015
- if (testParameter(lastComponent, options.removeDirectoryIndex)) {
2016
- pathComponents = pathComponents.slice(0, -1);
2017
- urlObject.pathname = `${pathComponents.slice(1).join("/")}/`;
2621
+ getLanguageCode() {
2622
+ if (ElectronUtils.hasElectronApi()) {
2623
+ return this.invokeMethod("getLanguageCode");
2018
2624
  }
2625
+ return Promise.resolve(navigator.language);
2019
2626
  }
2020
- if (urlObject.hostname) {
2021
- urlObject.hostname = urlObject.hostname.replace(/\.$/, "");
2022
- if (options.stripWWW && /^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(urlObject.hostname)) {
2023
- urlObject.hostname = urlObject.hostname.replace(/^www\./, "");
2024
- }
2627
+ async setLanguageCode(code) {
2628
+ await this.invokeMethod("setLanguageCode", code);
2025
2629
  }
2026
- if (Array.isArray(options.removeQueryParameters)) {
2027
- for (const key of [...urlObject.searchParams.keys()]) {
2028
- if (testParameter(key, options.removeQueryParameters)) {
2029
- urlObject.searchParams.delete(key);
2030
- }
2031
- }
2630
+ getGridCellSize() {
2631
+ return this.invokeMethod("getGridCellSize");
2032
2632
  }
2033
- if (!Array.isArray(options.keepQueryParameters) && options.removeQueryParameters === true) {
2034
- urlObject.search = "";
2633
+ setGridCellSize(size) {
2634
+ return this.invokeMethod("setGridCellSize", size);
2035
2635
  }
2036
- if (Array.isArray(options.keepQueryParameters) && options.keepQueryParameters.length > 0) {
2037
- for (const key of [...urlObject.searchParams.keys()]) {
2038
- if (!testParameter(key, options.keepQueryParameters)) {
2039
- urlObject.searchParams.delete(key);
2040
- }
2041
- }
2636
+ exit() {
2637
+ return this.invokeMethod("exit");
2042
2638
  }
2043
- if (options.sortQueryParameters) {
2044
- urlObject.searchParams.sort();
2045
- try {
2046
- urlObject.search = decodeURIComponent(urlObject.search);
2047
- } catch {
2048
- }
2639
+ openCheckUpdateWindow() {
2640
+ return this.invokeMethod(`openCheckUpdateWindow`);
2049
2641
  }
2050
- if (options.removeTrailingSlash) {
2051
- urlObject.pathname = urlObject.pathname.replace(/\/$/, "");
2642
+ openWidgetManagerWindow() {
2643
+ return this.invokeMethod(`openWidgetManagerWindow`);
2052
2644
  }
2053
- if (options.removeExplicitPort && urlObject.port) {
2054
- urlObject.port = "";
2645
+ openRuntimeInfoWindow() {
2646
+ return this.invokeMethod(`openRuntimeInfoWindow`);
2055
2647
  }
2056
- const oldUrlString = urlString;
2057
- urlString = urlObject.toString();
2058
- if (!options.removeSingleSlash && urlObject.pathname === "/" && !oldUrlString.endsWith("/") && urlObject.hash === "") {
2059
- urlString = urlString.replace(/\/$/, "");
2648
+ };
2649
+ var AppApi = new AppApiImpl();
2650
+
2651
+ // src/api/BroadcastApi.ts
2652
+ var BroadcastApiImpl = class extends BaseApi {
2653
+ async send(event) {
2654
+ await this.invokeMethod("send", event);
2060
2655
  }
2061
- if ((options.removeTrailingSlash || urlObject.pathname === "/") && urlObject.hash === "" && options.removeSingleSlash) {
2062
- urlString = urlString.replace(/\/$/, "");
2656
+ async register(...event) {
2657
+ await this.invokeMethod("register", event);
2063
2658
  }
2064
- if (hasRelativeProtocol && !options.normalizeProtocol) {
2065
- urlString = urlString.replace(/^http:\/\//, "//");
2659
+ async unregister(...event) {
2660
+ await this.invokeMethod("unregister", event);
2066
2661
  }
2067
- if (options.stripProtocol) {
2068
- urlString = urlString.replace(/^(?:https?:)?\/\//, "");
2662
+ getChannel() {
2663
+ return "channel::cn.widgetjs.core.broadcast" /* BROADCAST */;
2069
2664
  }
2070
- return urlString;
2071
- }
2665
+ };
2666
+ var BroadcastApi = new BroadcastApiImpl();
2072
2667
 
2073
- // src/grid/GridSystem.ts
2074
- var GridRect = class {
2075
- top;
2076
- left;
2077
- width;
2078
- height;
2079
- constructor(left, top, width, height) {
2080
- this.top = top;
2081
- this.left = left;
2082
- this.width = width;
2083
- this.height = height;
2668
+ // src/api/BrowserWindowApi.ts
2669
+ var BrowserWindowApiEvent = /* @__PURE__ */ ((BrowserWindowApiEvent2) => {
2670
+ BrowserWindowApiEvent2["BLUR"] = "event::cn.widgetjs.core.browser-window.blur";
2671
+ BrowserWindowApiEvent2["MOVED"] = "event::cn.widgetjs.core.browser-window.moved";
2672
+ BrowserWindowApiEvent2["FOCUS"] = "event::cn.widgetjs.core.browser-window.focus";
2673
+ BrowserWindowApiEvent2["CLOSE"] = "event::cn.widgetjs.core.browser-window.close";
2674
+ BrowserWindowApiEvent2["SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.snap_to_edge";
2675
+ BrowserWindowApiEvent2["RESIZED"] = "event::cn.widgetjs.core.browser-window.resized";
2676
+ BrowserWindowApiEvent2["CANCEL_SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge";
2677
+ return BrowserWindowApiEvent2;
2678
+ })(BrowserWindowApiEvent || {});
2679
+ var BrowserWindowApiImpl = class extends BaseApi {
2680
+ getProxy() {
2681
+ return this.invokeMethod("getProxy");
2084
2682
  }
2085
- get right() {
2086
- return this.left + this.width;
2683
+ setBackgroundThrottling(enabled) {
2684
+ return this.invokeMethod("setBackgroundThrottling", enabled);
2087
2685
  }
2088
- get bottom() {
2089
- return this.top + this.height;
2686
+ getBackgroundThrottling() {
2687
+ return this.invokeMethod("getBackgroundThrottling");
2090
2688
  }
2091
- };
2092
- var GridSystem = class extends GridRect {
2093
- cellSize;
2094
- horizontalCellCount;
2095
- verticalCellCount;
2096
- screenWidth;
2097
- screenHeight;
2098
- /**
2099
- * 屏幕x坐标,用于解决多块屏幕坐标计算问题
2100
- */
2101
- screenLeft;
2102
- /**
2103
- * 屏幕y坐标,用于解决多块屏幕坐标计算问题
2104
- */
2105
- screenTop;
2106
- canvasScreenTop;
2107
- canvasScreenLeft;
2108
- /**
2109
- *
2110
- * @param cellSize
2111
- * @param padding 至少保留的边距
2112
- * @param screenWidth
2113
- * @param screenHeight
2114
- * @param screenX
2115
- * @param screenY
2116
- */
2117
- constructor(cellSize, padding, screenWidth, screenHeight, screenX, screenY) {
2118
- const gridMaxWidth = screenWidth - padding * 2;
2119
- const gridMaxHeight = screenHeight - padding * 2;
2120
- const horizontalPadding = gridMaxWidth % cellSize / 2 + padding;
2121
- const verticalPadding = gridMaxHeight % cellSize / 2 + padding;
2122
- const horizontalCellCount = Math.floor(gridMaxWidth / cellSize);
2123
- const verticalCellCount = Math.floor(gridMaxHeight / cellSize);
2124
- super(horizontalPadding, verticalPadding, horizontalCellCount * cellSize, verticalCellCount * cellSize);
2125
- this.canvasScreenLeft = horizontalPadding + (screenX ?? 0);
2126
- this.canvasScreenTop = verticalPadding + (screenY ?? 0);
2127
- this.cellSize = cellSize;
2128
- this.screenWidth = screenWidth;
2129
- this.screenHeight = screenHeight;
2130
- this.horizontalCellCount = horizontalCellCount;
2131
- this.verticalCellCount = verticalCellCount;
2132
- this.screenLeft = screenX;
2133
- this.screenTop = screenY;
2689
+ isResizable() {
2690
+ return this.invokeMethod("isResizable");
2691
+ }
2692
+ setHasShadow(hasShadow) {
2693
+ return this.invokeMethod("setHasShadow", hasShadow);
2694
+ }
2695
+ isDraggingWindow() {
2696
+ return this.invokeMethod("isDraggingWindow");
2697
+ }
2698
+ setNoActivate() {
2699
+ return this.invokeMethod("setNoActivate");
2700
+ }
2701
+ async isVisible() {
2702
+ return await this.invokeMethod("isVisible");
2703
+ }
2704
+ getChannel() {
2705
+ return "channel::cn.widgetjs.core.browser_window" /* BROWSER_WINDOW */;
2134
2706
  }
2135
- /**
2136
- * 将坐标对齐到网格上
2137
- * @param x
2138
- * @param y
2139
- * @param gridSystem
2140
- */
2141
- snapCanvasPosition(x, y) {
2142
- const newX = this.getRangeValue(x - this.left, 0, this.right);
2143
- const newY = this.getRangeValue(y - this.top, 0, this.bottom);
2144
- return this.snapPosition(newX, newY);
2707
+ async setIgnoreMouseEvent(ignore) {
2708
+ await this.invokeMethod("setIgnoreMouseEvent", ignore);
2145
2709
  }
2146
- snapPosition(newX, newY) {
2147
- const diffX = newX % this.cellSize;
2148
- if (diffX >= this.cellSize / 2) {
2149
- newX = newX + this.cellSize - diffX;
2150
- } else {
2151
- newX = newX - diffX;
2152
- }
2153
- const diffY = newY % this.cellSize;
2154
- if (diffY >= this.cellSize / 2) {
2155
- newY = newY + this.cellSize - diffY;
2156
- } else {
2157
- newY = newY - diffY;
2158
- }
2159
- return [newX + this.left, newY + this.top];
2710
+ async show() {
2711
+ await this.invokeMethod("show", true);
2160
2712
  }
2161
- snapSize(width, height) {
2162
- let newWidth = Math.floor(width);
2163
- let newHeight = Math.floor(height);
2164
- const diffWidth = newWidth % this.cellSize;
2165
- const diffHeight = newHeight % this.cellSize;
2166
- if (diffWidth > this.cellSize / 2) {
2167
- newWidth = width + this.cellSize - diffWidth;
2168
- } else {
2169
- newWidth = width - diffWidth;
2170
- }
2171
- if (diffHeight > this.cellSize / 2) {
2172
- newHeight = height + this.cellSize - diffHeight;
2713
+ async showInactive() {
2714
+ await this.invokeMethod("showInactive", true);
2715
+ }
2716
+ async hide() {
2717
+ await this.invokeMethod("hide", false);
2718
+ }
2719
+ async center() {
2720
+ await this.invokeMethod("center", false);
2721
+ }
2722
+ async setAlwaysOnTop(alwaysOnTop) {
2723
+ await this.invokeMethod("setAlwaysOnTop", alwaysOnTop);
2724
+ }
2725
+ async isAlwaysOnTop() {
2726
+ return await this.invokeMethod("isAlwaysOnTop");
2727
+ }
2728
+ async openUrl(url, option) {
2729
+ if (ElectronUtils.hasElectronApi()) {
2730
+ await this.invokeMethod("openUrl", url, option);
2173
2731
  } else {
2174
- newHeight = height - diffHeight;
2732
+ window.open(url, "_blank");
2175
2733
  }
2176
- return [newWidth, newHeight];
2177
2734
  }
2178
- /**
2179
- * 将矩形对齐到网格上
2180
- * @param rect
2181
- * @param minWidth
2182
- * @param maxWidth
2183
- * @param minHeight
2184
- * @param maxHeight
2185
- */
2186
- snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight) {
2187
- const [newX, newY] = this.snapCanvasPosition(rect.left, rect.top);
2188
- return this.snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY);
2735
+ async moveTop() {
2736
+ await this.invokeMethod("moveTop");
2189
2737
  }
2190
- snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY) {
2191
- let [newWidth, newHeight] = this.snapSize(rect.width, rect.height);
2192
- newWidth = this.getRangeValue(newWidth, minWidth, maxWidth);
2193
- newHeight = this.getRangeValue(newHeight, minHeight, maxHeight);
2194
- if (newX + newWidth > this.right) {
2195
- newX = this.right - newWidth;
2196
- }
2197
- if (newY + newHeight > this.bottom) {
2198
- newY = this.bottom - newHeight;
2199
- }
2200
- return new GridRect(newX, newY, newWidth, newHeight);
2738
+ async openDevTools() {
2739
+ await this.invokeMethod("openDevTools");
2740
+ }
2741
+ async setPosition(options) {
2742
+ await this.invokeMethod("setPosition", options);
2743
+ }
2744
+ async getPosition() {
2745
+ return await this.invokeMethod("getPosition");
2746
+ }
2747
+ async blur() {
2748
+ return await this.invokeMethod("blur");
2749
+ }
2750
+ async focus() {
2751
+ return await this.invokeMethod("focus");
2201
2752
  }
2202
2753
  /**
2203
- * 将矩形对齐到网格上,与snapRect的区别是,这个会加上屏幕x和y坐标,用于适配多个显示器
2204
- * @param rect
2205
- * @param minWidth
2206
- * @param maxWidth
2207
- * @param minHeight
2208
- * @param maxHeight
2754
+ * 设置窗口是否可以拉伸
2755
+ * @param resizable
2209
2756
  */
2210
- snapWindow(rect, minWidth, maxWidth, minHeight, maxHeight) {
2211
- rect.left = rect.left - (this.screenLeft ?? 0);
2212
- rect.top = rect.top - (this.screenTop ?? 0);
2213
- const result = this.snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight);
2214
- return new GridRect(
2215
- result.left + (this.screenLeft ?? 0),
2216
- result.top + (this.screenTop ?? 0),
2217
- result.width,
2218
- result.height
2219
- );
2757
+ async setResizable(resizable) {
2758
+ return await this.invokeMethod("setResizable", resizable);
2759
+ }
2760
+ async getBounds() {
2761
+ return await this.invokeMethod("getBounds");
2762
+ }
2763
+ async setBounds(bounds, animate) {
2764
+ return await this.invokeMethod("setBounds", bounds, animate);
2765
+ }
2766
+ async alignToScreen(align) {
2767
+ return await this.invokeMethod("alignToScreen", align);
2768
+ }
2769
+ async startDraggingWindow() {
2770
+ return await this.invokeMethod("startDraggingWindow");
2771
+ }
2772
+ async stopDraggingWindow() {
2773
+ return await this.invokeMethod("stopDraggingWindow");
2220
2774
  }
2221
2775
  /**
2222
- * 限制值不超出屏幕
2223
- * @param value
2224
- * @param min
2225
- * @param max
2226
- * @private
2776
+ * 通过url检测窗口是否存在
2777
+ * @param url
2227
2778
  */
2228
- getRangeValue(value, min, max) {
2229
- if (value < min) {
2230
- return min;
2231
- }
2232
- if (value > max) {
2233
- return max;
2234
- }
2235
- return value;
2779
+ async existsByUrl(url) {
2780
+ return await this.invokeMethod("existsByUrl", url);
2236
2781
  }
2237
- getWidth() {
2238
- return this.width;
2782
+ async getMaximumSize() {
2783
+ return await this.invokeMethod("getMaximumSize");
2239
2784
  }
2240
- getHeight() {
2241
- return this.height;
2785
+ async minimize() {
2786
+ return await this.invokeMethod("minimize");
2242
2787
  }
2243
- };
2244
-
2245
- // src/api/ElectronApi.ts
2246
- var ElectronApi = class {
2247
- static async addIpcListener(key, f) {
2248
- await ElectronUtils.getAPI()?.addIpcListener(key, f);
2788
+ async maximize() {
2789
+ return await this.invokeMethod("maximize");
2249
2790
  }
2250
- static async removeIpcListener(key) {
2251
- await ElectronUtils.getAPI()?.removeIpcListener(key);
2791
+ async isMaximized() {
2792
+ return await this.invokeMethod("isMaximized");
2252
2793
  }
2253
- };
2254
-
2255
- // src/api/Channel.ts
2256
- var Channel = /* @__PURE__ */ ((Channel2) => {
2257
- Channel2["NOTIFICATION"] = "channel::cn.widgetjs.core.notification";
2258
- Channel2["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
2259
- Channel2["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
2260
- Channel2["WIDGET"] = "channel::cn.widgetjs.core.widget";
2261
- Channel2["WIDGET_PACKAGE"] = "channel::cn.widgetjs.core.widget.package";
2262
- Channel2["DEPLOYED_WIDGET"] = "channel::cn.widgetjs.core.deployed_widget";
2263
- Channel2["APP"] = "channel::cn.widgetjs.core.app";
2264
- Channel2["SYSTEM"] = "channel::cn.widgetjs.core.system";
2265
- Channel2["DIALOG"] = "channel::cn.widgetjs.core.dialog";
2266
- Channel2["HTTP"] = "channel::cn.widgetjs.core.http";
2267
- Channel2["CLIPBOARD"] = "channel::cn.widgetjs.core.clipboard";
2268
- Channel2["FILE"] = "channel::cn.widgetjs.core.file";
2269
- Channel2["SCREEN"] = "channel::cn.widgetjs.core.screen";
2270
- Channel2["MENU"] = "channel::cn.widgetjs.core.menu";
2271
- Channel2["SHORTCUT"] = "channel::cn.widgetjs.core.shortcut";
2272
- Channel2["LOG"] = "channel::cn.widgetjs.core.log";
2273
- Channel2["DEVICE"] = "channel::cn.widgetjs.core.device";
2274
- Channel2["MOUSE"] = "channel::cn.widgetjs.core.mouse";
2275
- Channel2["KEYBOARD"] = "channel::cn.widgetjs.core.keyboard";
2276
- Channel2["STORE"] = "channel::cn.widgetjs.core.store";
2277
- Channel2["STORAGE"] = "channel::cn.widgetjs.core.storage";
2278
- Channel2["PROCESS"] = "channel::cn.widgetjs.core.process";
2279
- Channel2["USER"] = "channel::cn.widgetjs.core.user";
2280
- Channel2["TRAY"] = "channel::cn.widgetjs.core.tray";
2281
- Channel2["AI"] = "channel::cn.widgetjs.core.ai";
2282
- return Channel2;
2283
- })(Channel || {});
2284
-
2285
- // src/api/BaseApi.ts
2286
- var BaseApi = class {
2287
- async invokeMethod(method, ...args) {
2288
- return await ElectronUtils.invokeMethod(this.getChannel(), method, ...args);
2794
+ async isMinimized() {
2795
+ return await this.invokeMethod("isMinimized");
2289
2796
  }
2290
- async invoke(...args) {
2291
- return await ElectronUtils.invoke(this.getChannel(), ...args);
2797
+ async restore() {
2798
+ return await this.invokeMethod("restore");
2292
2799
  }
2293
- };
2294
-
2295
- // src/api/BroadcastApi.ts
2296
- var BroadcastApiImpl = class extends BaseApi {
2297
- async send(event) {
2298
- await this.invokeMethod("send", event);
2800
+ async unmaximize() {
2801
+ return await this.invokeMethod("unmaximize");
2802
+ }
2803
+ async setZoomLevel(level) {
2804
+ return await this.invokeMethod("setZoomLevel", level);
2805
+ }
2806
+ async reload() {
2807
+ return await this.invokeMethod("reload");
2808
+ }
2809
+ async setMovable(movable) {
2810
+ return await this.invokeMethod("setMovable", movable);
2811
+ }
2812
+ async setSize(width, height, animate) {
2813
+ return this.invokeMethod("setSize", width, height, animate);
2814
+ }
2815
+ async isFocused() {
2816
+ return this.invokeMethod("isFocused");
2817
+ }
2818
+ async setMaximumSize(width, height) {
2819
+ return this.invokeMethod("setMaximumSize", width, height);
2820
+ }
2821
+ async setMinimumSize(width, height) {
2822
+ return this.invokeMethod("setMinimumSize", width, height);
2823
+ }
2824
+ getMinimumSize() {
2825
+ return this.invokeMethod("getMinimumSize");
2826
+ }
2827
+ close() {
2828
+ return this.invokeMethod("close");
2829
+ }
2830
+ setZoomFactor(factor) {
2831
+ return this.invokeMethod("setZoomFactor", factor);
2832
+ }
2833
+ async setup(options) {
2834
+ if (options.alwaysOnTop) {
2835
+ await this.setAlwaysOnTop(true);
2836
+ }
2837
+ await this.setResizable(!!options.resizable);
2838
+ await this.setMovable(!!options.movable);
2839
+ if (options.width && options.height) {
2840
+ await this.setSize(options.width, options.height);
2841
+ }
2842
+ if (options.minWidth && options.minHeight) {
2843
+ await this.setMinimumSize(options.minWidth, options.minHeight);
2844
+ }
2845
+ if (options.maxWidth && options.maxHeight) {
2846
+ await this.setMaximumSize(options.maxWidth, options.maxHeight);
2847
+ }
2848
+ if (options.center) {
2849
+ await this.center();
2850
+ }
2851
+ if (options.x != void 0 || options.y != void 0) {
2852
+ await this.setPosition({ x: options.x, y: options.y });
2853
+ }
2854
+ if (options.skipTaskbar) {
2855
+ await this.setSkipTaskbar(true);
2856
+ } else if (options.skipTaskbar === false) {
2857
+ await this.setSkipTaskbar(false);
2858
+ }
2299
2859
  }
2300
- async register(...event) {
2301
- await this.invokeMethod("register", event);
2860
+ async setProxy(config) {
2861
+ return await this.invokeMethod("setProxy", config);
2302
2862
  }
2303
- async unregister(...event) {
2304
- await this.invokeMethod("unregister", event);
2863
+ getSize() {
2864
+ return this.invokeMethod("getSize");
2305
2865
  }
2306
- getChannel() {
2307
- return "channel::cn.widgetjs.core.broadcast" /* BROADCAST */;
2866
+ setSkipTaskbar(skip) {
2867
+ return this.invokeMethod("setSkipTaskbar", skip);
2308
2868
  }
2309
2869
  };
2310
- var BroadcastApi = new BroadcastApiImpl();
2870
+ var BrowserWindowApi = new BrowserWindowApiImpl();
2311
2871
 
2312
- // src/api/WidgetApi.ts
2313
- var WidgetApiEvent = /* @__PURE__ */ ((WidgetApiEvent2) => {
2314
- WidgetApiEvent2["DATA_CHANGED"] = "event::cn.widgetjs.core.widget.data-changed";
2315
- WidgetApiEvent2["EDIT_DESKTOP_WIDGETS"] = "event::cn.widgetjs.core.widget.desktop.edit";
2316
- WidgetApiEvent2["PACKAGE_UPGRADE"] = "event::cn.widgetjs.core.widget.package.upgraded";
2317
- WidgetApiEvent2["PACKAGE_INSTALLED"] = "event::cn.widgetjs.core.widget.package.installed";
2318
- return WidgetApiEvent2;
2319
- })(WidgetApiEvent || {});
2320
- var WidgetApiImpl = class extends BaseApi {
2321
- getSyncInfo(widgetName) {
2322
- return this.invokeMethod("getSyncInfo", widgetName);
2872
+ // src/api/ClipboardApi.ts
2873
+ var ClipboardApiEvent = /* @__PURE__ */ ((ClipboardApiEvent2) => {
2874
+ ClipboardApiEvent2["CHANGED"] = "clipboard-changed";
2875
+ return ClipboardApiEvent2;
2876
+ })(ClipboardApiEvent || {});
2877
+ var ClipboardApiImpl = class extends BaseApi {
2878
+ writeText(text) {
2879
+ return this.invokeMethod("writeText", text);
2323
2880
  }
2324
- updateSyncInfo() {
2325
- return this.invokeMethod("updateSyncInfo");
2881
+ async getSelectedText() {
2882
+ return this.invokeMethod("getSelectedText");
2326
2883
  }
2327
- reload(id) {
2328
- return this.invokeMethod("reload", id);
2884
+ async getText() {
2885
+ return this.invokeMethod("getText");
2329
2886
  }
2330
2887
  getChannel() {
2331
- return "channel::cn.widgetjs.core.widget" /* WIDGET */;
2332
- }
2333
- async registerWidgets(widgets) {
2334
- return this.invokeMethod("registerWidgets", JSON.stringify(widgets));
2888
+ return "channel::cn.widgetjs.core.clipboard" /* CLIPBOARD */;
2335
2889
  }
2336
- async registerWidgetPackage(widgetPackage) {
2337
- return this.invokeMethod("registerWidgetPackage", JSON.stringify(widgetPackage));
2890
+ };
2891
+ var ClipboardApi = new ClipboardApiImpl();
2892
+
2893
+ // src/utils/AppProtocolUtils.ts
2894
+ var AppProtocolUtils = class {
2895
+ static getBaseURL() {
2896
+ return new URL("widget://widgetjs.cn");
2338
2897
  }
2339
- async getWidgets() {
2340
- const data = await this.invokeMethod("getWidgets");
2341
- const widgets = [];
2342
- if (data) {
2343
- for (const item of data) {
2344
- widgets.push(Widget.parseObject(item));
2345
- }
2898
+ static getAddWidgetUrl(options) {
2899
+ const url = this.getBaseURL();
2900
+ url.pathname = "/widget/add";
2901
+ if (options.packageJsonUrl) {
2902
+ url.searchParams.set("packageJsonUrl", options.packageJsonUrl);
2346
2903
  }
2347
- return widgets;
2348
- }
2349
- async openConfigPage(widgetId) {
2350
- return this.invokeMethod("openConfigPage", widgetId);
2904
+ if (options.hostname) {
2905
+ url.searchParams.set("hostname", options.hostname);
2906
+ }
2907
+ if (options.widgetTitle) {
2908
+ url.searchParams.set("widgetTitle", options.widgetTitle);
2909
+ }
2910
+ url.searchParams.set("widgetName", options.widgetName);
2911
+ url.searchParams.set("deployMode", options.deployMode.toString());
2912
+ return url.toString();
2351
2913
  }
2352
- async openConfigPageByName(widgetName) {
2353
- return this.invokeMethod("openConfigPageByName", widgetName);
2914
+ };
2915
+
2916
+ // src/api/DeployedWidgetApi.ts
2917
+ var DeployedWidgetApiImpl = class extends BaseApi {
2918
+ getChannel() {
2919
+ return "channel::cn.widgetjs.core.deployed_widget" /* DEPLOYED_WIDGET */;
2354
2920
  }
2355
2921
  /**
2356
- * @deprecated
2922
+ * 移除组件
2923
+ * @param id
2357
2924
  */
2358
- async getWidgetPackages() {
2359
- return await this.invokeMethod("getWidgetPackages");
2925
+ async removeDeployedWidget(id) {
2926
+ return this.invokeMethod("removeDeployedWidget", id);
2360
2927
  }
2361
- /**
2362
- *
2363
- * @param name package name
2364
- */
2365
- async getWidget(name) {
2366
- return Widget.parseObject(await this.invokeMethod("getWidget", name));
2928
+ addWidget(options) {
2929
+ if (ElectronUtils.hasElectronApi()) {
2930
+ return this.invokeMethod("addWidget", options);
2931
+ } else {
2932
+ window.location.href = AppProtocolUtils.getAddWidgetUrl(options);
2933
+ return Promise.resolve([]);
2934
+ }
2367
2935
  }
2368
2936
  /**
2369
- * @param name package name
2370
- * @deprecated
2937
+ * 通过组件名移除已添加的组件
2938
+ * @param name 组件名
2371
2939
  */
2372
- async getWidgetPackage(name) {
2373
- const result = await this.invokeMethod("getWidgetPackage", name);
2374
- if (result) {
2375
- return WidgetPackage.parseObject(result);
2376
- }
2377
- return void 0;
2378
- }
2379
- async getWidgetPackageUrl(packageName) {
2380
- const widgetPackage = await this.getWidgetPackage(packageName);
2381
- if (!widgetPackage) {
2382
- return null;
2383
- }
2384
- return widgetPackage.url;
2385
- }
2386
- async upgradePackage(packageName) {
2387
- return await this.invokeMethod("upgradePackage", packageName);
2940
+ async removeDeployedWidgetByName(name) {
2941
+ return this.invokeMethod("removeDeployedWidgetByName", name);
2388
2942
  }
2389
2943
  /**
2390
- * 阻止拖动窗口,只能用于悬浮窗口 DeployMode.OVERLAP
2391
- * @param draggable
2944
+ * 获取已添加的组件
2945
+ * @param name 组件名,可以不传
2392
2946
  */
2393
- setMouseDraggable(draggable) {
2394
- return this.invokeMethod("setMouseDraggable", draggable);
2395
- }
2396
- isIgnoreMouseEvents(widgetId) {
2397
- return this.invokeMethod("isIgnoreMouseEvents", widgetId);
2398
- }
2399
- setIgnoreMouseEvents(widgetId, ignore) {
2400
- return this.invokeMethod("setIgnoreMouseEvents", widgetId, ignore);
2947
+ async getDeployedWidgets(name) {
2948
+ return this.invokeMethod("getDeployedWidgets", name);
2401
2949
  }
2402
- restartWidgets(mode) {
2403
- return this.invokeMethod("restartWidgets", mode);
2950
+ async getDeployedWidget(id) {
2951
+ return this.invokeMethod("getDeployedWidget", id);
2404
2952
  }
2405
- };
2406
- var WidgetApi = new WidgetApiImpl();
2407
-
2408
- // src/api/WidgetDataApi.ts
2409
- var WidgetDataApiImpl = class {
2410
- stores = /* @__PURE__ */ new Map();
2411
2953
  /**
2412
- * 保存组件数据
2413
- * @param data
2414
- * @param options
2954
+ * Opens the dev tools for a widget with the specified ID.
2955
+ *
2956
+ * @param {string} widgetId - The ID of the widget to open the dev tools for.
2957
+ * @return {Promise} A Promise that resolves when the dev tools are opened.
2415
2958
  */
2416
- async save(data, options = { sendBroadcast: true }) {
2417
- const store = this.getStore(data.name, options.storeName);
2418
- const json = JSON.stringify(data);
2419
- const result = await store.setItem(this.getKey(data.name, data.id), json);
2420
- if (options.sendBroadcast) {
2421
- const broadcastEvent = new BroadcastEvent({
2422
- event: "event::cn.widgetjs.core.widget.data-changed" /* DATA_CHANGED */,
2423
- payload: { name: data.name, json }
2424
- });
2425
- await BroadcastApi.send(broadcastEvent);
2426
- }
2427
- return result;
2959
+ async openDevTools(widgetId) {
2960
+ return this.invokeMethod("openDevTools", widgetId);
2428
2961
  }
2429
- getStore(widgetName, storeName) {
2430
- if (this.stores.has(widgetName)) {
2431
- return this.stores.get(widgetName);
2432
- }
2433
- const store = localforage__default.default.createInstance({ name: widgetName, storeName });
2434
- this.stores.set(widgetName, store);
2435
- return store;
2962
+ async openConfigPage(widgetId, params) {
2963
+ return this.invokeMethod("openConfigPage", widgetId, params);
2436
2964
  }
2437
2965
  /**
2438
- * 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
2439
- * @param data
2440
- * @param options
2966
+ * 注册激活、呼出、置顶组件快捷键
2967
+ * @param widgetId 组件id
2968
+ * @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
2969
+ * https://www.electronjs.org/docs/latest/api/accelerator
2441
2970
  */
2442
- async saveByName(data, options = { sendBroadcast: true }) {
2443
- const store = this.getStore(data.name);
2444
- const json = JSON.stringify(data);
2445
- const result = await store.setItem(data.name, json);
2446
- if (options?.sendBroadcast) {
2447
- const broadcastEvent = new BroadcastEvent({
2448
- event: "event::cn.widgetjs.core.widget.data-changed" /* DATA_CHANGED */,
2449
- payload: { name: data.name, json }
2450
- });
2451
- await BroadcastApi.send(broadcastEvent);
2452
- }
2453
- return result;
2454
- }
2455
- async findByName(...args) {
2456
- let name = "";
2457
- let dbStr = "";
2458
- let data;
2459
- if (args.length === 2) {
2460
- name = args[0];
2461
- const Type = args[1];
2462
- data = new Type(name);
2463
- } else {
2464
- data = args[0];
2465
- name = data.name;
2466
- }
2467
- const store = this.getStore(name);
2468
- dbStr = await store.getItem(name);
2469
- if (dbStr) {
2470
- data.parseJSON(JSON.parse(dbStr));
2471
- return data;
2472
- }
2473
- return void 0;
2474
- }
2475
- async find(name, id, Type) {
2476
- const store = this.getStore(name);
2477
- const result = await store.getItem(this.getKey(name, id));
2478
- if (result) {
2479
- const widgetData = new Type(name, id);
2480
- widgetData.parseJSON(JSON.parse(result));
2481
- return widgetData;
2482
- }
2483
- return void 0;
2971
+ async registerActiveShortcut(widgetId, shortcut) {
2972
+ return this.invokeMethod("registerActiveShortcut", widgetId, shortcut);
2484
2973
  }
2485
- getKey(name, id) {
2486
- return `${name}@${id}`;
2974
+ async setProxy(widgetId, proxy) {
2975
+ return this.invokeMethod("setProxy", widgetId, proxy);
2487
2976
  }
2488
2977
  };
2489
- var WidgetDataApi = new WidgetDataApiImpl();
2978
+ var DeployedWidgetApi = new DeployedWidgetApiImpl();
2490
2979
 
2491
- // src/api/BrowserWindowApi.ts
2492
- var BrowserWindowApiEvent = /* @__PURE__ */ ((BrowserWindowApiEvent2) => {
2493
- BrowserWindowApiEvent2["BLUR"] = "event::cn.widgetjs.core.browser-window.blur";
2494
- BrowserWindowApiEvent2["MOVED"] = "event::cn.widgetjs.core.browser-window.moved";
2495
- BrowserWindowApiEvent2["FOCUS"] = "event::cn.widgetjs.core.browser-window.focus";
2496
- BrowserWindowApiEvent2["CLOSE"] = "event::cn.widgetjs.core.browser-window.close";
2497
- BrowserWindowApiEvent2["SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.snap_to_edge";
2498
- BrowserWindowApiEvent2["RESIZED"] = "event::cn.widgetjs.core.browser-window.resized";
2499
- BrowserWindowApiEvent2["CANCEL_SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge";
2500
- return BrowserWindowApiEvent2;
2501
- })(BrowserWindowApiEvent || {});
2502
- var BrowserWindowApiImpl = class extends BaseApi {
2503
- getProxy() {
2504
- return this.invokeMethod("getProxy");
2505
- }
2506
- setBackgroundThrottling(enabled) {
2507
- return this.invokeMethod("setBackgroundThrottling", enabled);
2508
- }
2509
- getBackgroundThrottling() {
2510
- return this.invokeMethod("getBackgroundThrottling");
2980
+ // src/api/DeviceApi.ts
2981
+ var DeviceApiImpl = class extends BaseApi {
2982
+ getDisplayNearestPoint(point) {
2983
+ return this.invokeMethod("getDisplayNearestPoint", point);
2511
2984
  }
2512
- isResizable() {
2513
- return this.invokeMethod("isResizable");
2985
+ getAllDisplays() {
2986
+ return this.invokeMethod("getAllDisplays");
2514
2987
  }
2515
- setHasShadow(hasShadow) {
2516
- return this.invokeMethod("setHasShadow", hasShadow);
2988
+ getPrimaryDisplay() {
2989
+ return this.invokeMethod("getPrimaryDisplay");
2517
2990
  }
2518
- isDraggingWindow() {
2519
- return this.invokeMethod("isDraggingWindow");
2991
+ /**
2992
+ * 获取当前鼠标位置
2993
+ */
2994
+ async getCursorScreenPoint() {
2995
+ return this.invokeMethod("getCursorScreenPoint");
2520
2996
  }
2521
- setNoActivate() {
2522
- return this.invokeMethod("setNoActivate");
2997
+ async sendCtrlV() {
2998
+ return this.invokeMethod("sendCtrlV");
2523
2999
  }
2524
- async isVisible() {
2525
- return await this.invokeMethod("isVisible");
3000
+ /**
3001
+ * 判断是否所有按键都已经释放
3002
+ */
3003
+ async isAllKeyReleased() {
3004
+ return this.invokeMethod("isAllKeyReleased");
2526
3005
  }
2527
3006
  getChannel() {
2528
- return "channel::cn.widgetjs.core.browser_window" /* BROWSER_WINDOW */;
2529
- }
2530
- async setIgnoreMouseEvent(ignore) {
2531
- await this.invokeMethod("setIgnoreMouseEvent", ignore);
3007
+ return "channel::cn.widgetjs.core.device" /* DEVICE */;
2532
3008
  }
2533
- async show() {
2534
- await this.invokeMethod("show", true);
3009
+ isCapsLockOn() {
3010
+ return this.invokeMethod("isCapsLockOn");
2535
3011
  }
2536
- async showInactive() {
2537
- await this.invokeMethod("showInactive", true);
3012
+ };
3013
+ var DeviceApi = new DeviceApiImpl();
3014
+
3015
+ // src/api/DialogApi.ts
3016
+ var DialogApiImpl = class extends BaseApi {
3017
+ getChannel() {
3018
+ return "channel::cn.widgetjs.core.dialog" /* DIALOG */;
2538
3019
  }
2539
- async hide() {
2540
- await this.invokeMethod("hide", false);
3020
+ pickFile(extensions) {
3021
+ return this.invokeMethod("pickFile", extensions);
2541
3022
  }
2542
- async center() {
2543
- await this.invokeMethod("center", false);
3023
+ pickFolder() {
3024
+ return this.invokeMethod("pickFolder");
2544
3025
  }
2545
- async setAlwaysOnTop(alwaysOnTop) {
2546
- await this.invokeMethod("setAlwaysOnTop", alwaysOnTop);
3026
+ };
3027
+ var DialogApi = new DialogApiImpl();
3028
+
3029
+ // src/api/ElectronApi.ts
3030
+ var ElectronApi = class {
3031
+ static async addIpcListener(key, f) {
3032
+ await ElectronUtils.getAPI()?.addIpcListener(key, f);
2547
3033
  }
2548
- async isAlwaysOnTop() {
2549
- return await this.invokeMethod("isAlwaysOnTop");
3034
+ static async removeIpcListener(key) {
3035
+ await ElectronUtils.getAPI()?.removeIpcListener(key);
2550
3036
  }
2551
- async openUrl(url, option) {
2552
- if (ElectronUtils.hasElectronApi()) {
2553
- await this.invokeMethod("openUrl", url, option);
2554
- } else {
2555
- window.open(url, "_blank");
2556
- }
3037
+ };
3038
+
3039
+ // src/api/FileApi.ts
3040
+ var FileApiImpl = class extends BaseApi {
3041
+ async readShortcutLink(shortcutPath) {
3042
+ return this.invokeMethod("readShortcutLink", shortcutPath);
2557
3043
  }
2558
- async moveTop() {
2559
- await this.invokeMethod("moveTop");
3044
+ async extractIcon(path, size) {
3045
+ return this.invokeMethod("extractIcon", path, size);
2560
3046
  }
2561
- async openDevTools() {
2562
- await this.invokeMethod("openDevTools");
3047
+ async delete(filePath) {
3048
+ return this.invokeMethod("delete", filePath);
2563
3049
  }
2564
- async setPosition(options) {
2565
- await this.invokeMethod("setPosition", options);
3050
+ async getPictureMetadata(filePath) {
3051
+ return this.invokeMethod("getPictureMetadata", filePath);
2566
3052
  }
2567
- async getPosition() {
2568
- return await this.invokeMethod("getPosition");
3053
+ async move(form, to) {
3054
+ return this.invokeMethod("move", form, to);
2569
3055
  }
2570
- async blur() {
2571
- return await this.invokeMethod("blur");
3056
+ async isDirectory(filePath) {
3057
+ return this.invokeMethod("isDirectory", filePath);
2572
3058
  }
2573
- async focus() {
2574
- return await this.invokeMethod("focus");
3059
+ getChannel() {
3060
+ return "channel::cn.widgetjs.core.file" /* FILE */;
2575
3061
  }
2576
- /**
2577
- * 设置窗口是否可以拉伸
2578
- * @param resizable
2579
- */
2580
- async setResizable(resizable) {
2581
- return await this.invokeMethod("setResizable", resizable);
3062
+ async readDirectory(path, options) {
3063
+ return this.invokeMethod("readDirectory", path, options);
2582
3064
  }
2583
- async getBounds() {
2584
- return await this.invokeMethod("getBounds");
3065
+ async downloadUrl(options) {
3066
+ return this.invokeMethod("downloadUrl", options);
2585
3067
  }
2586
- async setBounds(bounds, animate) {
2587
- return await this.invokeMethod("setBounds", bounds, animate);
3068
+ async exists(filePath) {
3069
+ return this.invokeMethod("exists", filePath);
2588
3070
  }
2589
- async alignToScreen(align) {
2590
- return await this.invokeMethod("alignToScreen", align);
3071
+ async readFile(filePath) {
3072
+ return this.invokeMethod("readFile", filePath);
2591
3073
  }
2592
- async startDraggingWindow() {
2593
- return await this.invokeMethod("startDraggingWindow");
3074
+ async getDocumentFolder(filePath) {
3075
+ return this.invokeMethod("getDocumentFolder", filePath);
2594
3076
  }
2595
- async stopDraggingWindow() {
2596
- return await this.invokeMethod("stopDraggingWindow");
3077
+ async getMimeType(absoluteFilePath) {
3078
+ return this.invokeMethod("getMimeType", absoluteFilePath);
2597
3079
  }
2598
- /**
2599
- * 通过url检测窗口是否存在
2600
- * @param url
2601
- */
2602
- async existsByUrl(url) {
2603
- return await this.invokeMethod("existsByUrl", url);
3080
+ async getFileInfo(absoluteFilePath) {
3081
+ return this.invokeMethod("getFileInfo", absoluteFilePath);
2604
3082
  }
2605
- async getMaximumSize() {
2606
- return await this.invokeMethod("getMaximumSize");
3083
+ async showItemInFolder(fullPath) {
3084
+ return this.invokeMethod("showItemInFolder", fullPath);
2607
3085
  }
2608
- async minimize() {
2609
- return await this.invokeMethod("minimize");
3086
+ async openPath(path) {
3087
+ return this.invokeMethod("openPath", path);
2610
3088
  }
2611
- async maximize() {
2612
- return await this.invokeMethod("maximize");
3089
+ async trashItem(path) {
3090
+ return this.invokeMethod("trashItem", path);
2613
3091
  }
2614
- async isMaximized() {
2615
- return await this.invokeMethod("isMaximized");
3092
+ };
3093
+ var FileApi = new FileApiImpl();
3094
+
3095
+ // src/api/HttpApi.ts
3096
+ var HttpApiImpl = class extends BaseApi {
3097
+ getChannel() {
3098
+ return "channel::cn.widgetjs.core.http" /* HTTP */;
2616
3099
  }
2617
- async isMinimized() {
2618
- return await this.invokeMethod("isMinimized");
3100
+ get(url, params) {
3101
+ return this.invokeMethod("get", url, params);
2619
3102
  }
2620
- async restore() {
2621
- return await this.invokeMethod("restore");
3103
+ post(url, data) {
3104
+ return this.invokeMethod("post", url, data);
2622
3105
  }
2623
- async unmaximize() {
2624
- return await this.invokeMethod("unmaximize");
3106
+ };
3107
+ var HttpApi = new HttpApiImpl();
3108
+
3109
+ // src/api/interface/IAppApi.ts
3110
+ var AppApiEvent = /* @__PURE__ */ ((AppApiEvent2) => {
3111
+ AppApiEvent2["CONFIG_CHANGED"] = "event::cn.widgetjs.core.app.config.changed";
3112
+ AppApiEvent2["MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window";
3113
+ AppApiEvent2["STOP_MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window.stop";
3114
+ AppApiEvent2["PROXY_CHANGED"] = "event::cn.widgetjs.core.app.proxy.changed";
3115
+ AppApiEvent2["LANGUAGE_CHANGED"] = "event::cn.widgetjs.core.app.language.changed";
3116
+ return AppApiEvent2;
3117
+ })(AppApiEvent || {});
3118
+ var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
3119
+ AppApiConstants2["CONFIG_GRID_CELL_SIZE"] = "cn.widgetjs.config.grid.size";
3120
+ AppApiConstants2["CONFIG_WIDGET_THEME_CSS"] = "cn.widgetjs.config.widget.theme.css";
3121
+ AppApiConstants2["CONFIG_PROXY"] = "cn.widgetjs.config.app.proxy";
3122
+ AppApiConstants2["CONFIG_DEV_MODE"] = "cn.widgetjs.config.app.dev.mode";
3123
+ AppApiConstants2["CONFIG_LANGUAGE"] = "cn.widgetjs.config.app.language";
3124
+ return AppApiConstants2;
3125
+ })(AppApiConstants || {});
3126
+
3127
+ // src/api/interface/IWidgetPackageApi.ts
3128
+ var WidgetPackageApiEvent = /* @__PURE__ */ ((WidgetPackageApiEvent2) => {
3129
+ WidgetPackageApiEvent2["PACKAGE_UPGRADE"] = "event::cn.widgetjs.core.widget.package.upgraded";
3130
+ WidgetPackageApiEvent2["PACKAGE_INSTALLED"] = "event::cn.widgetjs.core.widget.package.installed";
3131
+ return WidgetPackageApiEvent2;
3132
+ })(WidgetPackageApiEvent || {});
3133
+
3134
+ // src/api/interface/IMouseApi.ts
3135
+ var MouseApiEvent = /* @__PURE__ */ ((MouseApiEvent2) => {
3136
+ MouseApiEvent2["HOTSPOT_ACTIVE"] = "event::cn.widgetjs.core.mouse.hotspot.active";
3137
+ return MouseApiEvent2;
3138
+ })(MouseApiEvent || {});
3139
+
3140
+ // src/api/interface/ITrayApi.ts
3141
+ var TrayApiEvent = /* @__PURE__ */ ((TrayApiEvent2) => {
3142
+ TrayApiEvent2["CLICK"] = "channel::cn.widgetjs.core.tray.click";
3143
+ TrayApiEvent2["RIGHT_CLICK"] = "channel::cn.widgetjs.core.tray.right-click";
3144
+ TrayApiEvent2["MIDDLE_CLICK"] = "channel::cn.widgetjs.core.tray.middle-click";
3145
+ TrayApiEvent2["MOUSE_ENTER"] = "channel::cn.widgetjs.core.tray.mouse-enter";
3146
+ TrayApiEvent2["MOUSE_LEAVE"] = "channel::cn.widgetjs.core.tray.mouse-leave";
3147
+ return TrayApiEvent2;
3148
+ })(TrayApiEvent || {});
3149
+
3150
+ // src/api/interface/IUserApi.ts
3151
+ var UserApiEvent = /* @__PURE__ */ ((UserApiEvent2) => {
3152
+ UserApiEvent2["USER_UPDATED"] = `channel::cn.widgetjs.core.user.updated`;
3153
+ UserApiEvent2["SIGNED_OUT"] = `channel::cn.widgetjs.core.user.signed.out`;
3154
+ UserApiEvent2["SIGNED_IN"] = `channel::cn.widgetjs.core.user.signed.in`;
3155
+ UserApiEvent2["TOKEN_REFRESHED"] = `channel::cn.widgetjs.core.user.token.refreshed`;
3156
+ return UserApiEvent2;
3157
+ })(UserApiEvent || {});
3158
+
3159
+ // src/api/interface/IAiApi.ts
3160
+ var AiApiEvent = /* @__PURE__ */ ((AiApiEvent2) => {
3161
+ AiApiEvent2["CONFIG_UPDATED"] = `channel::cn.widgetjs.core.ai.config.updated`;
3162
+ return AiApiEvent2;
3163
+ })(AiApiEvent || {});
3164
+
3165
+ // src/api/LogApi.ts
3166
+ var LogApiImpl = class extends BaseApi {
3167
+ getChannel() {
3168
+ return "channel::cn.widgetjs.core.log" /* LOG */;
2625
3169
  }
2626
- async setZoomLevel(level) {
2627
- return await this.invokeMethod("setZoomLevel", level);
3170
+ info(...data) {
3171
+ console.log(...data);
3172
+ this.invokeMethod("info", ...data);
2628
3173
  }
2629
- async reload() {
2630
- return await this.invokeMethod("reload");
3174
+ error(...data) {
3175
+ console.error(...data);
3176
+ this.invokeMethod("error", ...data);
2631
3177
  }
2632
- async setMovable(movable) {
2633
- return await this.invokeMethod("setMovable", movable);
3178
+ warn(...data) {
3179
+ console.warn(...data);
3180
+ this.invokeMethod("warn", ...data);
2634
3181
  }
2635
- async setSize(width, height, animate) {
2636
- return this.invokeMethod("setSize", width, height, animate);
3182
+ log(...data) {
3183
+ console.log(...data);
3184
+ this.invokeMethod("log", ...data);
2637
3185
  }
2638
- async isFocused() {
2639
- return this.invokeMethod("isFocused");
3186
+ json(data) {
3187
+ const json = JSON.stringify(data, null, 2);
3188
+ this.log(json);
2640
3189
  }
2641
- async setMaximumSize(width, height) {
2642
- return this.invokeMethod("setMaximumSize", width, height);
3190
+ };
3191
+ var LogApi = new LogApiImpl();
3192
+
3193
+ // src/api/MenuApi.ts
3194
+ var MenuApiEvent = /* @__PURE__ */ ((MenuApiEvent2) => {
3195
+ MenuApiEvent2["ITEM_CLICK"] = "event::cn.widgetjs.core.menu.item.click";
3196
+ return MenuApiEvent2;
3197
+ })(MenuApiEvent || {});
3198
+ var MenuApiImpl = class extends BaseApi {
3199
+ getChannel() {
3200
+ return "channel::cn.widgetjs.core.menu" /* MENU */;
2643
3201
  }
2644
- async setMinimumSize(width, height) {
2645
- return this.invokeMethod("setMinimumSize", width, height);
3202
+ /**
3203
+ * Add items to the context menu
3204
+ * @param menuItems The menu items to add
3205
+ */
3206
+ addContextMenuItem(menuItems) {
3207
+ return this.invokeMethod("addContextMenuItem", menuItems);
2646
3208
  }
2647
- getMinimumSize() {
2648
- return this.invokeMethod("getMinimumSize");
3209
+ /**
3210
+ * Add items to the application menu
3211
+ * @param menuItems The menu items to add
3212
+ */
3213
+ addMenuItem(menuItems) {
3214
+ return this.invokeMethod("addMenuItem", menuItems);
2649
3215
  }
2650
- close() {
2651
- return this.invokeMethod("close");
3216
+ /**
3217
+ * Show a menu programmatically
3218
+ * @param options The options for showing the menu
3219
+ */
3220
+ showMenu(options) {
3221
+ return this.invokeMethod("showMenu", options);
2652
3222
  }
2653
- setZoomFactor(factor) {
2654
- return this.invokeMethod("setZoomFactor", factor);
3223
+ /**
3224
+ * Remove items from the application menu
3225
+ * @param menuItemIds The IDs of the menu items to remove
3226
+ */
3227
+ removeMenuItem(menuItemIds) {
3228
+ return this.invokeMethod("removeMenuItem", menuItemIds);
2655
3229
  }
2656
- async setup(options) {
2657
- if (options.alwaysOnTop) {
2658
- await this.setAlwaysOnTop(true);
2659
- }
2660
- await this.setResizable(!!options.resizable);
2661
- await this.setMovable(!!options.movable);
2662
- if (options.width && options.height) {
2663
- await this.setSize(options.width, options.height);
2664
- }
2665
- if (options.minWidth && options.minHeight) {
2666
- await this.setMinimumSize(options.minWidth, options.minHeight);
2667
- }
2668
- if (options.maxWidth && options.maxHeight) {
2669
- await this.setMaximumSize(options.maxWidth, options.maxHeight);
2670
- }
2671
- if (options.center) {
2672
- await this.center();
2673
- }
2674
- if (options.x != void 0 || options.y != void 0) {
2675
- await this.setPosition({ x: options.x, y: options.y });
2676
- }
2677
- if (options.skipTaskbar) {
2678
- await this.setSkipTaskbar(true);
2679
- } else if (options.skipTaskbar === false) {
2680
- await this.setSkipTaskbar(false);
2681
- }
3230
+ /**
3231
+ * Remove items from the context menu
3232
+ * @param menuItemIds The IDs of the menu items to remove
3233
+ */
3234
+ removeContextMenuItem(menuItemIds) {
3235
+ return this.invokeMethod("removeContextMenuItem", menuItemIds);
2682
3236
  }
2683
- async setProxy(config) {
2684
- return await this.invokeMethod("setProxy", config);
3237
+ };
3238
+ var MenuApi = new MenuApiImpl();
3239
+
3240
+ // src/api/MouseApi.ts
3241
+ var MouseApiImpl = class extends BaseApi {
3242
+ getChannel() {
3243
+ return "channel::cn.widgetjs.core.mouse" /* MOUSE */;
2685
3244
  }
2686
- getSize() {
2687
- return this.invokeMethod("getSize");
3245
+ removeHotspot() {
3246
+ return this.invokeMethod("removeHotspot");
2688
3247
  }
2689
- setSkipTaskbar(skip) {
2690
- return this.invokeMethod("setSkipTaskbar", skip);
3248
+ createHotspot(rect) {
3249
+ return this.invokeMethod("createHotspot", rect);
2691
3250
  }
2692
3251
  };
2693
- var BrowserWindowApi = new BrowserWindowApiImpl();
3252
+ var MouseApi = new MouseApiImpl();
2694
3253
 
2695
3254
  // src/api/NotificationApi.ts
2696
3255
  var NotificationApiEvent = /* @__PURE__ */ ((NotificationApiEvent2) => {
@@ -2766,191 +3325,52 @@ var NotificationApiImpl = class extends BaseApi {
2766
3325
  }));
2767
3326
  }
2768
3327
  async warning(message, duration = 5e3) {
2769
- await this.send(new AppNotification({
2770
- message,
2771
- type: "warning",
2772
- icon: "attention",
2773
- duration
2774
- }));
2775
- }
2776
- async info(message, duration = 5e3) {
2777
- await this.send(new AppNotification({
2778
- message,
2779
- type: "info",
2780
- icon: "info",
2781
- duration
2782
- }));
2783
- }
2784
- /**
2785
- * 隐藏通知
2786
- */
2787
- async hide() {
2788
- await this.invokeMethod("hide");
2789
- }
2790
- getChannel() {
2791
- return "channel::cn.widgetjs.core.notification" /* NOTIFICATION */;
2792
- }
2793
- };
2794
- var NotificationApi = new NotificationApiImpl();
2795
-
2796
- // src/utils/AppProtocolUtils.ts
2797
- var AppProtocolUtils = class {
2798
- static getBaseURL() {
2799
- return new URL("widget://widgetjs.cn");
2800
- }
2801
- static getAddWidgetUrl(options) {
2802
- const url = this.getBaseURL();
2803
- url.pathname = "/widget/add";
2804
- if (options.packageJsonUrl) {
2805
- url.searchParams.set("packageJsonUrl", options.packageJsonUrl);
2806
- }
2807
- if (options.hostname) {
2808
- url.searchParams.set("hostname", options.hostname);
2809
- }
2810
- if (options.widgetTitle) {
2811
- url.searchParams.set("widgetTitle", options.widgetTitle);
2812
- }
2813
- url.searchParams.set("widgetName", options.widgetName);
2814
- url.searchParams.set("deployMode", options.deployMode.toString());
2815
- return url.toString();
2816
- }
2817
- };
2818
-
2819
- // src/api/DeployedWidgetApi.ts
2820
- var DeployedWidgetApiImpl = class extends BaseApi {
2821
- getChannel() {
2822
- return "channel::cn.widgetjs.core.deployed_widget" /* DEPLOYED_WIDGET */;
2823
- }
2824
- /**
2825
- * 移除组件
2826
- * @param id
2827
- */
2828
- async removeDeployedWidget(id) {
2829
- return this.invokeMethod("removeDeployedWidget", id);
2830
- }
2831
- addWidget(options) {
2832
- if (ElectronUtils.hasElectronApi()) {
2833
- return this.invokeMethod("addWidget", options);
2834
- } else {
2835
- window.location.href = AppProtocolUtils.getAddWidgetUrl(options);
2836
- return Promise.resolve([]);
2837
- }
2838
- }
2839
- /**
2840
- * 通过组件名移除已添加的组件
2841
- * @param name 组件名
2842
- */
2843
- async removeDeployedWidgetByName(name) {
2844
- return this.invokeMethod("removeDeployedWidgetByName", name);
2845
- }
2846
- /**
2847
- * 获取已添加的组件
2848
- * @param name 组件名,可以不传
2849
- */
2850
- async getDeployedWidgets(name) {
2851
- return this.invokeMethod("getDeployedWidgets", name);
2852
- }
2853
- async getDeployedWidget(id) {
2854
- return this.invokeMethod("getDeployedWidget", id);
2855
- }
2856
- /**
2857
- * Opens the dev tools for a widget with the specified ID.
2858
- *
2859
- * @param {string} widgetId - The ID of the widget to open the dev tools for.
2860
- * @return {Promise} A Promise that resolves when the dev tools are opened.
2861
- */
2862
- async openDevTools(widgetId) {
2863
- return this.invokeMethod("openDevTools", widgetId);
2864
- }
2865
- async openConfigPage(widgetId, params) {
2866
- return this.invokeMethod("openConfigPage", widgetId, params);
2867
- }
2868
- /**
2869
- * 注册激活、呼出、置顶组件快捷键
2870
- * @param widgetId 组件id
2871
- * @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
2872
- * https://www.electronjs.org/docs/latest/api/accelerator
2873
- */
2874
- async registerActiveShortcut(widgetId, shortcut) {
2875
- return this.invokeMethod("registerActiveShortcut", widgetId, shortcut);
2876
- }
2877
- async setProxy(widgetId, proxy) {
2878
- return this.invokeMethod("setProxy", widgetId, proxy);
2879
- }
2880
- };
2881
- var DeployedWidgetApi = new DeployedWidgetApiImpl();
2882
-
2883
- // src/api/DeviceApi.ts
2884
- var DeviceApiImpl = class extends BaseApi {
2885
- getDisplayNearestPoint(point) {
2886
- return this.invokeMethod("getDisplayNearestPoint", point);
2887
- }
2888
- getAllDisplays() {
2889
- return this.invokeMethod("getAllDisplays");
2890
- }
2891
- getPrimaryDisplay() {
2892
- return this.invokeMethod("getPrimaryDisplay");
2893
- }
2894
- /**
2895
- * 获取当前鼠标位置
2896
- */
2897
- async getCursorScreenPoint() {
2898
- return this.invokeMethod("getCursorScreenPoint");
3328
+ await this.send(new AppNotification({
3329
+ message,
3330
+ type: "warning",
3331
+ icon: "attention",
3332
+ duration
3333
+ }));
2899
3334
  }
2900
- async sendCtrlV() {
2901
- return this.invokeMethod("sendCtrlV");
3335
+ async info(message, duration = 5e3) {
3336
+ await this.send(new AppNotification({
3337
+ message,
3338
+ type: "info",
3339
+ icon: "info",
3340
+ duration
3341
+ }));
2902
3342
  }
2903
3343
  /**
2904
- * 判断是否所有按键都已经释放
3344
+ * 隐藏通知
2905
3345
  */
2906
- async isAllKeyReleased() {
2907
- return this.invokeMethod("isAllKeyReleased");
3346
+ async hide() {
3347
+ await this.invokeMethod("hide");
2908
3348
  }
2909
3349
  getChannel() {
2910
- return "channel::cn.widgetjs.core.device" /* DEVICE */;
2911
- }
2912
- isCapsLockOn() {
2913
- return this.invokeMethod("isCapsLockOn");
3350
+ return "channel::cn.widgetjs.core.notification" /* NOTIFICATION */;
2914
3351
  }
2915
3352
  };
2916
- var DeviceApi = new DeviceApiImpl();
3353
+ var NotificationApi = new NotificationApiImpl();
2917
3354
 
2918
- // src/api/ClipboardApi.ts
2919
- var ClipboardApiEvent = /* @__PURE__ */ ((ClipboardApiEvent2) => {
2920
- ClipboardApiEvent2["CHANGED"] = "clipboard-changed";
2921
- return ClipboardApiEvent2;
2922
- })(ClipboardApiEvent || {});
2923
- var ClipboardApiImpl = class extends BaseApi {
2924
- writeText(text) {
2925
- return this.invokeMethod("writeText", text);
3355
+ // src/api/ProcessApi.ts
3356
+ var ProcessApiImpl = class extends BaseApi {
3357
+ getChannel() {
3358
+ return "channel::cn.widgetjs.core.process" /* PROCESS */;
2926
3359
  }
2927
- async getSelectedText() {
2928
- return this.invokeMethod("getSelectedText");
3360
+ getBlinkMemoryInfo() {
3361
+ return this.invokeMethod("getBlinkMemoryInfo");
2929
3362
  }
2930
- async getText() {
2931
- return this.invokeMethod("getText");
3363
+ getHeapStatistics() {
3364
+ return this.invokeMethod("getHeapStatistics");
2932
3365
  }
2933
- getChannel() {
2934
- return "channel::cn.widgetjs.core.clipboard" /* CLIPBOARD */;
3366
+ getProcessMemoryInfo() {
3367
+ return this.invokeMethod("getProcessMemoryInfo");
3368
+ }
3369
+ getSystemVersion() {
3370
+ return this.invokeMethod("getSystemVersion");
2935
3371
  }
2936
3372
  };
2937
- var ClipboardApi = new ClipboardApiImpl();
2938
-
2939
- // src/api/ApiConstants.ts
2940
- var ApiConstants = class {
2941
- static CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
2942
- static CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
2943
- static CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
2944
- static CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size";
2945
- static SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
2946
- };
2947
- var AppEvent = class {
2948
- static LANGUAGE_CHANGED = "event::cn.widgetjs.core.app.language.changed";
2949
- };
2950
- var AppConfig = class {
2951
- static LANGUAGE = "cn.widgetjs.config.app.language";
2952
- static LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
2953
- };
3373
+ var ProcessApi = new ProcessApiImpl();
2954
3374
 
2955
3375
  // src/api/interface/IShortcutApi.ts
2956
3376
  var ShortcutApiEvent = /* @__PURE__ */ ((ShortcutApiEvent2) => {
@@ -2972,363 +3392,331 @@ var ShortcutApiImpl = class extends BaseApi {
2972
3392
  };
2973
3393
  var ShortcutApi = new ShortcutApiImpl();
2974
3394
 
2975
- // src/api/ProcessApi.ts
2976
- var ProcessApiImpl = class extends BaseApi {
2977
- getChannel() {
2978
- return "channel::cn.widgetjs.core.process" /* PROCESS */;
2979
- }
2980
- getBlinkMemoryInfo() {
2981
- return this.invokeMethod("getBlinkMemoryInfo");
2982
- }
2983
- getHeapStatistics() {
2984
- return this.invokeMethod("getHeapStatistics");
2985
- }
2986
- getProcessMemoryInfo() {
2987
- return this.invokeMethod("getProcessMemoryInfo");
2988
- }
2989
- getSystemVersion() {
2990
- return this.invokeMethod("getSystemVersion");
2991
- }
2992
- };
2993
- var ProcessApi = new ProcessApiImpl();
2994
-
2995
- // src/api/AppApi.ts
2996
- var AppApiImpl = class extends BaseApi {
2997
- showAppWindow(route, options) {
2998
- return this.invokeMethod("showAppWindow", route, options);
2999
- }
3000
- openWidgetPackageManagerWindow() {
3001
- return this.invokeMethod("openWidgetPackageManagerWindow");
3002
- }
3003
- getRuntimeInfo() {
3004
- return this.invokeMethod("getRuntimeInfo");
3005
- }
3006
- setProxy(config) {
3007
- return this.invokeMethod("setProxy", config);
3008
- }
3009
- getProxy() {
3010
- return this.invokeMethod("getProxy");
3011
- }
3012
- isWindowsStore() {
3013
- return this.invokeMethod("isWindowsStore");
3014
- }
3015
- getAppPath() {
3016
- return this.invokeMethod("getAppPath");
3017
- }
3018
- async getIconFile() {
3019
- return this.invokeMethod("getIconFile");
3020
- }
3395
+ // src/api/StorageApi.ts
3396
+ var StorageApiImpl = class extends BaseApi {
3021
3397
  getChannel() {
3022
- return "channel::cn.widgetjs.core.app" /* APP */;
3398
+ return "channel::cn.widgetjs.core.store" /* STORE */;
3023
3399
  }
3024
- async setConfig(key, value) {
3025
- return await this.invokeMethod("setConfig", key, value);
3400
+ async delete(key) {
3401
+ return this.invokeMethod("delete", key);
3026
3402
  }
3027
- async getConfig(key, defaultValue) {
3028
- const value = await this.invokeMethod("getConfig", key);
3029
- if (value === null || value === void 0) {
3403
+ async get(key, defaultValue) {
3404
+ const result = await this.invokeMethod("get", key);
3405
+ if (result == null && defaultValue != void 0) {
3030
3406
  return defaultValue;
3031
3407
  }
3032
- if (typeof defaultValue == "boolean") {
3033
- return value === "true";
3408
+ return result;
3409
+ }
3410
+ async getObject(key, defaultValue) {
3411
+ const result = await this.invokeMethod("get", key);
3412
+ if (result) {
3413
+ return JSON.parse(result);
3034
3414
  }
3035
- if (typeof defaultValue == "number") {
3036
- return Number(value);
3415
+ if (defaultValue != void 0) {
3416
+ return defaultValue;
3037
3417
  }
3038
- return value;
3039
- }
3040
- async openAddWidgetWindow() {
3041
- return this.invokeMethod("openAddWidgetWindow");
3042
- }
3043
- async getVersion(type) {
3044
- return this.invokeMethod("getVersion", type);
3045
- }
3046
- async getPreloadPath() {
3047
- return this.invokeMethod("getPreloadPath");
3048
- }
3049
- async openSettingWindow() {
3050
- return this.invokeMethod("openSettingWindow");
3051
- }
3052
- getThemeCSS() {
3053
- return this.invokeMethod("getThemeCSS");
3418
+ return void 0;
3054
3419
  }
3055
- setThemeCSS(css) {
3056
- return this.invokeMethod("setThemeCSS", css);
3420
+ async set(key, value) {
3421
+ if (typeof value == "object") {
3422
+ return this.invokeMethod("set", key, JSON.stringify(value));
3423
+ }
3424
+ return this.invokeMethod("set", key, value);
3057
3425
  }
3058
- getDevMode() {
3059
- return this.invokeMethod("getDevMode");
3426
+ decryptString(value) {
3427
+ return this.invokeMethod("decryptString", value);
3060
3428
  }
3061
- setDevMode(enable) {
3062
- return this.invokeMethod("setDevMode", enable);
3429
+ decryptGet(key, defaultValue) {
3430
+ return this.invokeMethod("decryptGet", key, defaultValue);
3063
3431
  }
3064
- getLanguageCode() {
3065
- if (ElectronUtils.hasElectronApi()) {
3066
- return this.invokeMethod("getLanguageCode");
3067
- }
3068
- return Promise.resolve(navigator.language);
3432
+ encryptSet(key, value) {
3433
+ return this.invokeMethod("encryptSet", key, value);
3069
3434
  }
3070
- async setLanguageCode(code) {
3071
- await this.invokeMethod("setLanguageCode", code);
3435
+ encryptString(value) {
3436
+ return this.invokeMethod("encryptString", value);
3072
3437
  }
3073
- getGridCellSize() {
3074
- return this.invokeMethod("getGridCellSize");
3438
+ };
3439
+ var StorageApi = new StorageApiImpl();
3440
+ var StoreApi = new StorageApiImpl();
3441
+
3442
+ // src/api/structures/Gravity.ts
3443
+ var Gravity = /* @__PURE__ */ ((Gravity2) => {
3444
+ Gravity2["TOP"] = "TOP";
3445
+ Gravity2["LEFT"] = "LEFT";
3446
+ Gravity2["RIGHT"] = "RIGHT";
3447
+ Gravity2["BOTTOM"] = "BOTTOM";
3448
+ return Gravity2;
3449
+ })(Gravity || {});
3450
+
3451
+ // src/api/interface/ISystemApi.ts
3452
+ var SystemApiEvent = /* @__PURE__ */ ((SystemApiEvent2) => {
3453
+ SystemApiEvent2["DATE_CHANGED"] = "event::cn.widgetjs.core.sys.date.changed";
3454
+ return SystemApiEvent2;
3455
+ })(SystemApiEvent || {});
3456
+
3457
+ // src/api/SystemApi.ts
3458
+ var SystemApiImpl = class extends BaseApi {
3459
+ launchWindowsSettings(uri) {
3460
+ return this.invokeMethod("launchWindowsSettings", uri);
3075
3461
  }
3076
- setGridCellSize(size) {
3077
- return this.invokeMethod("setGridCellSize", size);
3462
+ launchStoreDetailsPage(storeId) {
3463
+ return this.invokeMethod("launchStoreDetailsPage", storeId ?? "9NPR50GQ7T53");
3078
3464
  }
3079
- exit() {
3080
- return this.invokeMethod("exit");
3465
+ getChannel() {
3466
+ return "channel::cn.widgetjs.core.system" /* SYSTEM */;
3081
3467
  }
3082
- openCheckUpdateWindow() {
3083
- return this.invokeMethod(`openCheckUpdateWindow`);
3468
+ getWallpaper() {
3469
+ return this.invokeMethod("getWallpaper");
3084
3470
  }
3085
- openWidgetManagerWindow() {
3086
- return this.invokeMethod(`openWidgetManagerWindow`);
3471
+ getInfo(valuesObject) {
3472
+ return this.invokeMethod("getInfo", valuesObject);
3087
3473
  }
3088
- openRuntimeInfoWindow() {
3089
- return this.invokeMethod(`openRuntimeInfoWindow`);
3474
+ getUptime() {
3475
+ return this.invokeMethod("getUptime");
3090
3476
  }
3091
3477
  };
3092
- var AppApi = new AppApiImpl();
3478
+ var SystemApi = new SystemApiImpl();
3093
3479
 
3094
- // src/api/DialogApi.ts
3095
- var DialogApiImpl = class extends BaseApi {
3480
+ // src/api/TrayApi.ts
3481
+ var TrayApiImpl = class extends BaseApi {
3096
3482
  getChannel() {
3097
- return "channel::cn.widgetjs.core.dialog" /* DIALOG */;
3098
- }
3099
- pickFile(extensions) {
3100
- return this.invokeMethod("pickFile", extensions);
3483
+ return "channel::cn.widgetjs.core.tray" /* TRAY */;
3101
3484
  }
3102
- pickFolder() {
3103
- return this.invokeMethod("pickFolder");
3485
+ setTray(options) {
3486
+ return this.invokeMethod("setTray", options);
3104
3487
  }
3105
- };
3106
- var DialogApi = new DialogApiImpl();
3107
-
3108
- // src/api/StorageApi.ts
3109
- var StorageApiImpl = class extends BaseApi {
3110
- getChannel() {
3111
- return "channel::cn.widgetjs.core.store" /* STORE */;
3488
+ removeTray() {
3489
+ return this.invokeMethod("removeTray");
3112
3490
  }
3113
- async delete(key) {
3114
- return this.invokeMethod("delete", key);
3491
+ displayBalloon(options) {
3492
+ return this.invokeMethod("displayBalloon", options);
3115
3493
  }
3116
- async get(key, defaultValue) {
3117
- const result = await this.invokeMethod("get", key);
3118
- if (result == null && defaultValue != void 0) {
3119
- return defaultValue;
3120
- }
3121
- return result;
3494
+ removeBalloon() {
3495
+ return this.invokeMethod("removeBalloon");
3122
3496
  }
3123
- async getObject(key, defaultValue) {
3124
- const result = await this.invokeMethod("get", key);
3125
- if (result) {
3126
- return JSON.parse(result);
3127
- }
3128
- if (defaultValue != void 0) {
3129
- return defaultValue;
3130
- }
3131
- return void 0;
3497
+ setContextMenu(menus) {
3498
+ return this.invokeMethod("setContextMenu", menus);
3132
3499
  }
3133
- async set(key, value) {
3134
- if (typeof value == "object") {
3135
- return this.invokeMethod("set", key, JSON.stringify(value));
3136
- }
3137
- return this.invokeMethod("set", key, value);
3500
+ closeContextMenu() {
3501
+ return this.invokeMethod("closeContextMenu");
3138
3502
  }
3139
- decryptString(value) {
3140
- return this.invokeMethod("decryptString", value);
3503
+ popUpContextMenu(menus, position) {
3504
+ return this.invokeMethod("popUpContextMenu", menus, position);
3141
3505
  }
3142
- decryptGet(key, defaultValue) {
3143
- return this.invokeMethod("decryptGet", key, defaultValue);
3506
+ isDestroyed() {
3507
+ return this.invokeMethod("isDestroyed");
3144
3508
  }
3145
- encryptSet(key, value) {
3146
- return this.invokeMethod("encryptSet", key, value);
3509
+ getBounds() {
3510
+ return this.invokeMethod("getBounds");
3147
3511
  }
3148
- encryptString(value) {
3149
- return this.invokeMethod("encryptString", value);
3512
+ focus() {
3513
+ return this.invokeMethod("focus");
3150
3514
  }
3151
3515
  };
3152
- var StorageApi = new StorageApiImpl();
3153
- var StoreApi = new StorageApiImpl();
3516
+ var TrayApi = new TrayApiImpl();
3154
3517
 
3155
- // src/api/LogApi.ts
3156
- var LogApiImpl = class extends BaseApi {
3157
- getChannel() {
3158
- return "channel::cn.widgetjs.core.log" /* LOG */;
3518
+ // src/api/UserApi.ts
3519
+ var UserApiImpl = class extends BaseApi {
3520
+ async getSession() {
3521
+ return await this.invokeMethod("getSession");
3159
3522
  }
3160
- info(...data) {
3161
- console.log(...data);
3162
- this.invokeMethod("info", ...data);
3523
+ async updateSession(session) {
3524
+ await this.invokeMethod("updateSession", session);
3163
3525
  }
3164
- error(...data) {
3165
- console.error(...data);
3166
- this.invokeMethod("error", ...data);
3526
+ async updateUser(user) {
3527
+ await this.invokeMethod("updateUser", user);
3167
3528
  }
3168
- warn(...data) {
3169
- console.warn(...data);
3170
- this.invokeMethod("warn", ...data);
3529
+ async login(session) {
3530
+ await this.invokeMethod("login", session);
3171
3531
  }
3172
- log(...data) {
3173
- console.log(...data);
3174
- this.invokeMethod("log", ...data);
3532
+ async logout() {
3533
+ await this.invokeMethod("logout");
3175
3534
  }
3176
- json(data) {
3177
- const json = JSON.stringify(data, null, 2);
3178
- this.log(json);
3535
+ async getUser() {
3536
+ return await this.invokeMethod("getUser");
3537
+ }
3538
+ getChannel() {
3539
+ return "channel::cn.widgetjs.core.user" /* USER */;
3179
3540
  }
3180
3541
  };
3181
- var LogApi = new LogApiImpl();
3542
+ var UserApi = new UserApiImpl();
3182
3543
 
3183
- // src/api/FileApi.ts
3184
- var FileApiImpl = class extends BaseApi {
3185
- async readShortcutLink(shortcutPath) {
3186
- return this.invokeMethod("readShortcutLink", shortcutPath);
3544
+ // src/api/WidgetApi.ts
3545
+ var WidgetApiEvent = /* @__PURE__ */ ((WidgetApiEvent2) => {
3546
+ WidgetApiEvent2["DATA_CHANGED"] = "event::cn.widgetjs.core.widget.data-changed";
3547
+ WidgetApiEvent2["EDIT_DESKTOP_WIDGETS"] = "event::cn.widgetjs.core.widget.desktop.edit";
3548
+ WidgetApiEvent2["PACKAGE_UPGRADE"] = "event::cn.widgetjs.core.widget.package.upgraded";
3549
+ WidgetApiEvent2["PACKAGE_INSTALLED"] = "event::cn.widgetjs.core.widget.package.installed";
3550
+ return WidgetApiEvent2;
3551
+ })(WidgetApiEvent || {});
3552
+ var WidgetApiImpl = class extends BaseApi {
3553
+ getSyncInfo(widgetName) {
3554
+ return this.invokeMethod("getSyncInfo", widgetName);
3187
3555
  }
3188
- async extractIcon(path, size) {
3189
- return this.invokeMethod("extractIcon", path, size);
3556
+ updateSyncInfo() {
3557
+ return this.invokeMethod("updateSyncInfo");
3190
3558
  }
3191
- async delete(filePath) {
3192
- return this.invokeMethod("delete", filePath);
3559
+ reload(id) {
3560
+ return this.invokeMethod("reload", id);
3193
3561
  }
3194
- async getPictureMetadata(filePath) {
3195
- return this.invokeMethod("getPictureMetadata", filePath);
3562
+ getChannel() {
3563
+ return "channel::cn.widgetjs.core.widget" /* WIDGET */;
3196
3564
  }
3197
- async move(form, to) {
3198
- return this.invokeMethod("move", form, to);
3565
+ async registerWidgets(widgets) {
3566
+ return this.invokeMethod("registerWidgets", JSON.stringify(widgets));
3199
3567
  }
3200
- async isDirectory(filePath) {
3201
- return this.invokeMethod("isDirectory", filePath);
3568
+ async registerWidgetPackage(widgetPackage) {
3569
+ return this.invokeMethod("registerWidgetPackage", JSON.stringify(widgetPackage));
3202
3570
  }
3203
- getChannel() {
3204
- return "channel::cn.widgetjs.core.file" /* FILE */;
3571
+ async getWidgets() {
3572
+ const data = await this.invokeMethod("getWidgets");
3573
+ const widgets = [];
3574
+ if (data) {
3575
+ for (const item of data) {
3576
+ widgets.push(Widget.parseObject(item));
3577
+ }
3578
+ }
3579
+ return widgets;
3205
3580
  }
3206
- async readDirectory(path, options) {
3207
- return this.invokeMethod("readDirectory", path, options);
3581
+ async openConfigPage(widgetId) {
3582
+ return this.invokeMethod("openConfigPage", widgetId);
3208
3583
  }
3209
- async downloadUrl(options) {
3210
- return this.invokeMethod("downloadUrl", options);
3584
+ async openConfigPageByName(widgetName) {
3585
+ return this.invokeMethod("openConfigPageByName", widgetName);
3211
3586
  }
3212
- async exists(filePath) {
3213
- return this.invokeMethod("exists", filePath);
3587
+ /**
3588
+ * @deprecated
3589
+ */
3590
+ async getWidgetPackages() {
3591
+ return await this.invokeMethod("getWidgetPackages");
3214
3592
  }
3215
- async readFile(filePath) {
3216
- return this.invokeMethod("readFile", filePath);
3593
+ /**
3594
+ *
3595
+ * @param name package name
3596
+ */
3597
+ async getWidget(name) {
3598
+ return Widget.parseObject(await this.invokeMethod("getWidget", name));
3217
3599
  }
3218
- async getDocumentFolder(filePath) {
3219
- return this.invokeMethod("getDocumentFolder", filePath);
3600
+ /**
3601
+ * @param name package name
3602
+ * @deprecated
3603
+ */
3604
+ async getWidgetPackage(name) {
3605
+ const result = await this.invokeMethod("getWidgetPackage", name);
3606
+ if (result) {
3607
+ return WidgetPackage.parseObject(result);
3608
+ }
3609
+ return void 0;
3220
3610
  }
3221
- async getMimeType(absoluteFilePath) {
3222
- return this.invokeMethod("getMimeType", absoluteFilePath);
3611
+ async getWidgetPackageUrl(packageName) {
3612
+ const widgetPackage = await this.getWidgetPackage(packageName);
3613
+ if (!widgetPackage) {
3614
+ return null;
3615
+ }
3616
+ return widgetPackage.url;
3223
3617
  }
3224
- async getFileInfo(absoluteFilePath) {
3225
- return this.invokeMethod("getFileInfo", absoluteFilePath);
3618
+ async upgradePackage(packageName) {
3619
+ return await this.invokeMethod("upgradePackage", packageName);
3226
3620
  }
3227
- async showItemInFolder(fullPath) {
3228
- return this.invokeMethod("showItemInFolder", fullPath);
3621
+ /**
3622
+ * 阻止拖动窗口,只能用于悬浮窗口 DeployMode.OVERLAP
3623
+ * @param draggable
3624
+ */
3625
+ setMouseDraggable(draggable) {
3626
+ return this.invokeMethod("setMouseDraggable", draggable);
3229
3627
  }
3230
- async openPath(path) {
3231
- return this.invokeMethod("openPath", path);
3628
+ isIgnoreMouseEvents(widgetId) {
3629
+ return this.invokeMethod("isIgnoreMouseEvents", widgetId);
3232
3630
  }
3233
- async trashItem(path) {
3234
- return this.invokeMethod("trashItem", path);
3631
+ setIgnoreMouseEvents(widgetId, ignore) {
3632
+ return this.invokeMethod("setIgnoreMouseEvents", widgetId, ignore);
3633
+ }
3634
+ restartWidgets(mode) {
3635
+ return this.invokeMethod("restartWidgets", mode);
3235
3636
  }
3236
3637
  };
3237
- var FileApi = new FileApiImpl();
3238
-
3239
- // src/api/structures/Gravity.ts
3240
- var Gravity = /* @__PURE__ */ ((Gravity2) => {
3241
- Gravity2["TOP"] = "TOP";
3242
- Gravity2["LEFT"] = "LEFT";
3243
- Gravity2["RIGHT"] = "RIGHT";
3244
- Gravity2["BOTTOM"] = "BOTTOM";
3245
- return Gravity2;
3246
- })(Gravity || {});
3247
-
3248
- // src/api/interface/ISystemApi.ts
3249
- var SystemApiEvent = /* @__PURE__ */ ((SystemApiEvent2) => {
3250
- SystemApiEvent2["DATE_CHANGED"] = "event::cn.widgetjs.core.sys.date.changed";
3251
- return SystemApiEvent2;
3252
- })(SystemApiEvent || {});
3253
-
3254
- // src/api/SystemApi.ts
3255
- var SystemApiImpl = class extends BaseApi {
3256
- launchWindowsSettings(uri) {
3257
- return this.invokeMethod("launchWindowsSettings", uri);
3638
+ var WidgetApi = new WidgetApiImpl();
3639
+ var WidgetDataApiImpl = class {
3640
+ stores = /* @__PURE__ */ new Map();
3641
+ /**
3642
+ * 保存组件数据
3643
+ * @param data
3644
+ * @param options
3645
+ */
3646
+ async save(data, options = { sendBroadcast: true }) {
3647
+ const store = this.getStore(data.name, options.storeName);
3648
+ const json = JSON.stringify(data);
3649
+ const result = await store.setItem(this.getKey(data.name, data.id), json);
3650
+ if (options.sendBroadcast) {
3651
+ const broadcastEvent = new BroadcastEvent({
3652
+ event: "event::cn.widgetjs.core.widget.data-changed" /* DATA_CHANGED */,
3653
+ payload: { name: data.name, json }
3654
+ });
3655
+ await BroadcastApi.send(broadcastEvent);
3656
+ }
3657
+ return result;
3258
3658
  }
3259
- launchStoreDetailsPage(storeId) {
3260
- return this.invokeMethod("launchStoreDetailsPage", storeId ?? "9NPR50GQ7T53");
3659
+ getStore(widgetName, storeName) {
3660
+ if (this.stores.has(widgetName)) {
3661
+ return this.stores.get(widgetName);
3662
+ }
3663
+ const store = localforage__default.default.createInstance({ name: widgetName, storeName });
3664
+ this.stores.set(widgetName, store);
3665
+ return store;
3261
3666
  }
3262
- getChannel() {
3263
- return "channel::cn.widgetjs.core.system" /* SYSTEM */;
3667
+ /**
3668
+ * 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
3669
+ * @param data
3670
+ * @param options
3671
+ */
3672
+ async saveByName(data, options = { sendBroadcast: true }) {
3673
+ const store = this.getStore(data.name);
3674
+ const json = JSON.stringify(data);
3675
+ const result = await store.setItem(data.name, json);
3676
+ if (options?.sendBroadcast) {
3677
+ const broadcastEvent = new BroadcastEvent({
3678
+ event: "event::cn.widgetjs.core.widget.data-changed" /* DATA_CHANGED */,
3679
+ payload: { name: data.name, json }
3680
+ });
3681
+ await BroadcastApi.send(broadcastEvent);
3682
+ }
3683
+ return result;
3264
3684
  }
3265
- getWallpaper() {
3266
- return this.invokeMethod("getWallpaper");
3685
+ async findByName(...args) {
3686
+ let name = "";
3687
+ let dbStr = "";
3688
+ let data;
3689
+ if (args.length === 2) {
3690
+ name = args[0];
3691
+ const Type = args[1];
3692
+ data = new Type(name);
3693
+ } else {
3694
+ data = args[0];
3695
+ name = data.name;
3696
+ }
3697
+ const store = this.getStore(name);
3698
+ dbStr = await store.getItem(name);
3699
+ if (dbStr) {
3700
+ data.parseJSON(JSON.parse(dbStr));
3701
+ return data;
3702
+ }
3703
+ return void 0;
3267
3704
  }
3268
- getInfo(valuesObject) {
3269
- return this.invokeMethod("getInfo", valuesObject);
3705
+ async find(name, id, Type) {
3706
+ const store = this.getStore(name);
3707
+ const result = await store.getItem(this.getKey(name, id));
3708
+ if (result) {
3709
+ const widgetData = new Type(name, id);
3710
+ widgetData.parseJSON(JSON.parse(result));
3711
+ return widgetData;
3712
+ }
3713
+ return void 0;
3270
3714
  }
3271
- getUptime() {
3272
- return this.invokeMethod("getUptime");
3715
+ getKey(name, id) {
3716
+ return `${name}@${id}`;
3273
3717
  }
3274
3718
  };
3275
- var SystemApi = new SystemApiImpl();
3276
-
3277
- // src/api/interface/IAppApi.ts
3278
- var AppApiEvent = /* @__PURE__ */ ((AppApiEvent2) => {
3279
- AppApiEvent2["CONFIG_CHANGED"] = "event::cn.widgetjs.core.app.config.changed";
3280
- AppApiEvent2["MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window";
3281
- AppApiEvent2["STOP_MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window.stop";
3282
- AppApiEvent2["PROXY_CHANGED"] = "event::cn.widgetjs.core.app.proxy.changed";
3283
- AppApiEvent2["LANGUAGE_CHANGED"] = "event::cn.widgetjs.core.app.language.changed";
3284
- return AppApiEvent2;
3285
- })(AppApiEvent || {});
3286
- var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
3287
- AppApiConstants2["CONFIG_GRID_CELL_SIZE"] = "cn.widgetjs.config.grid.size";
3288
- AppApiConstants2["CONFIG_WIDGET_THEME_CSS"] = "cn.widgetjs.config.widget.theme.css";
3289
- AppApiConstants2["CONFIG_PROXY"] = "cn.widgetjs.config.app.proxy";
3290
- AppApiConstants2["CONFIG_DEV_MODE"] = "cn.widgetjs.config.app.dev.mode";
3291
- AppApiConstants2["CONFIG_LANGUAGE"] = "cn.widgetjs.config.app.language";
3292
- return AppApiConstants2;
3293
- })(AppApiConstants || {});
3294
-
3295
- // src/api/interface/IWidgetPackageApi.ts
3296
- var WidgetPackageApiEvent = /* @__PURE__ */ ((WidgetPackageApiEvent2) => {
3297
- WidgetPackageApiEvent2["PACKAGE_UPGRADE"] = "event::cn.widgetjs.core.widget.package.upgraded";
3298
- WidgetPackageApiEvent2["PACKAGE_INSTALLED"] = "event::cn.widgetjs.core.widget.package.installed";
3299
- return WidgetPackageApiEvent2;
3300
- })(WidgetPackageApiEvent || {});
3301
-
3302
- // src/api/interface/IMouseApi.ts
3303
- var MouseApiEvent = /* @__PURE__ */ ((MouseApiEvent2) => {
3304
- MouseApiEvent2["HOTSPOT_ACTIVE"] = "event::cn.widgetjs.core.mouse.hotspot.active";
3305
- return MouseApiEvent2;
3306
- })(MouseApiEvent || {});
3307
-
3308
- // src/api/interface/ITrayApi.ts
3309
- var TrayApiEvent = /* @__PURE__ */ ((TrayApiEvent2) => {
3310
- TrayApiEvent2["CLICK"] = "channel::cn.widgetjs.core.tray.click";
3311
- TrayApiEvent2["RIGHT_CLICK"] = "channel::cn.widgetjs.core.tray.right-click";
3312
- TrayApiEvent2["MIDDLE_CLICK"] = "channel::cn.widgetjs.core.tray.middle-click";
3313
- TrayApiEvent2["MOUSE_ENTER"] = "channel::cn.widgetjs.core.tray.mouse-enter";
3314
- TrayApiEvent2["MOUSE_LEAVE"] = "channel::cn.widgetjs.core.tray.mouse-leave";
3315
- return TrayApiEvent2;
3316
- })(TrayApiEvent || {});
3317
-
3318
- // src/api/interface/IUserApi.ts
3319
- var UserApiEvent = /* @__PURE__ */ ((UserApiEvent2) => {
3320
- UserApiEvent2["USER_UPDATED"] = `channel::cn.widgetjs.core.user.updated`;
3321
- UserApiEvent2["SIGNED_OUT"] = `channel::cn.widgetjs.core.user.signed.out`;
3322
- UserApiEvent2["SIGNED_IN"] = `channel::cn.widgetjs.core.user.signed.in`;
3323
- UserApiEvent2["TOKEN_REFRESHED"] = `channel::cn.widgetjs.core.user.token.refreshed`;
3324
- return UserApiEvent2;
3325
- })(UserApiEvent || {});
3326
-
3327
- // src/api/interface/IAiApi.ts
3328
- var AiApiEvent = /* @__PURE__ */ ((AiApiEvent2) => {
3329
- AiApiEvent2["CONFIG_UPDATED"] = `channel::cn.widgetjs.core.ai.config.updated`;
3330
- return AiApiEvent2;
3331
- })(AiApiEvent || {});
3719
+ var WidgetDataApi = new WidgetDataApiImpl();
3332
3720
 
3333
3721
  // src/api/WidgetPackageApi.ts
3334
3722
  var WidgetPackageApiImpl = class extends BaseApi {
@@ -3389,172 +3777,6 @@ var WidgetPackageApiImpl = class extends BaseApi {
3389
3777
  };
3390
3778
  var WidgetPackageApi = new WidgetPackageApiImpl();
3391
3779
 
3392
- // src/api/MenuApi.ts
3393
- var MenuApiEvent = /* @__PURE__ */ ((MenuApiEvent2) => {
3394
- MenuApiEvent2["ITEM_CLICK"] = "event::cn.widgetjs.core.menu.item.click";
3395
- return MenuApiEvent2;
3396
- })(MenuApiEvent || {});
3397
- var MenuApiImpl = class extends BaseApi {
3398
- getChannel() {
3399
- return "channel::cn.widgetjs.core.menu" /* MENU */;
3400
- }
3401
- /**
3402
- * Add items to the context menu
3403
- * @param menuItems The menu items to add
3404
- */
3405
- addContextMenuItem(menuItems) {
3406
- return this.invokeMethod("addContextMenuItem", menuItems);
3407
- }
3408
- /**
3409
- * Add items to the application menu
3410
- * @param menuItems The menu items to add
3411
- */
3412
- addMenuItem(menuItems) {
3413
- return this.invokeMethod("addMenuItem", menuItems);
3414
- }
3415
- /**
3416
- * Show a menu programmatically
3417
- * @param options The options for showing the menu
3418
- */
3419
- showMenu(options) {
3420
- return this.invokeMethod("showMenu", options);
3421
- }
3422
- /**
3423
- * Remove items from the application menu
3424
- * @param menuItemIds The IDs of the menu items to remove
3425
- */
3426
- removeMenuItem(menuItemIds) {
3427
- return this.invokeMethod("removeMenuItem", menuItemIds);
3428
- }
3429
- /**
3430
- * Remove items from the context menu
3431
- * @param menuItemIds The IDs of the menu items to remove
3432
- */
3433
- removeContextMenuItem(menuItemIds) {
3434
- return this.invokeMethod("removeContextMenuItem", menuItemIds);
3435
- }
3436
- };
3437
- var MenuApi = new MenuApiImpl();
3438
-
3439
- // src/api/MouseApi.ts
3440
- var MouseApiImpl = class extends BaseApi {
3441
- getChannel() {
3442
- return "channel::cn.widgetjs.core.mouse" /* MOUSE */;
3443
- }
3444
- removeHotspot() {
3445
- return this.invokeMethod("removeHotspot");
3446
- }
3447
- createHotspot(rect) {
3448
- return this.invokeMethod("createHotspot", rect);
3449
- }
3450
- };
3451
- var MouseApi = new MouseApiImpl();
3452
-
3453
- // src/api/HttpApi.ts
3454
- var HttpApiImpl = class extends BaseApi {
3455
- getChannel() {
3456
- return "channel::cn.widgetjs.core.http" /* HTTP */;
3457
- }
3458
- get(url, params) {
3459
- return this.invokeMethod("get", url, params);
3460
- }
3461
- post(url, data) {
3462
- return this.invokeMethod("post", url, data);
3463
- }
3464
- };
3465
- var HttpApi = new HttpApiImpl();
3466
-
3467
- // src/api/UserApi.ts
3468
- var UserApiImpl = class extends BaseApi {
3469
- async getSession() {
3470
- return await this.invokeMethod("getSession");
3471
- }
3472
- async updateSession(session) {
3473
- await this.invokeMethod("updateSession", session);
3474
- }
3475
- async updateUser(user) {
3476
- await this.invokeMethod("updateUser", user);
3477
- }
3478
- async login(session) {
3479
- await this.invokeMethod("login", session);
3480
- }
3481
- async logout() {
3482
- await this.invokeMethod("logout");
3483
- }
3484
- async getUser() {
3485
- return await this.invokeMethod("getUser");
3486
- }
3487
- getChannel() {
3488
- return "channel::cn.widgetjs.core.user" /* USER */;
3489
- }
3490
- };
3491
- var UserApi = new UserApiImpl();
3492
-
3493
- // src/api/TrayApi.ts
3494
- var TrayApiImpl = class extends BaseApi {
3495
- getChannel() {
3496
- return "channel::cn.widgetjs.core.tray" /* TRAY */;
3497
- }
3498
- setTray(options) {
3499
- return this.invokeMethod("setTray", options);
3500
- }
3501
- removeTray() {
3502
- return this.invokeMethod("removeTray");
3503
- }
3504
- displayBalloon(options) {
3505
- return this.invokeMethod("displayBalloon", options);
3506
- }
3507
- removeBalloon() {
3508
- return this.invokeMethod("removeBalloon");
3509
- }
3510
- setContextMenu(menus) {
3511
- return this.invokeMethod("setContextMenu", menus);
3512
- }
3513
- closeContextMenu() {
3514
- return this.invokeMethod("closeContextMenu");
3515
- }
3516
- popUpContextMenu(menus, position) {
3517
- return this.invokeMethod("popUpContextMenu", menus, position);
3518
- }
3519
- isDestroyed() {
3520
- return this.invokeMethod("isDestroyed");
3521
- }
3522
- getBounds() {
3523
- return this.invokeMethod("getBounds");
3524
- }
3525
- focus() {
3526
- return this.invokeMethod("focus");
3527
- }
3528
- };
3529
- var TrayApi = new TrayApiImpl();
3530
-
3531
- // src/api/AiApi.ts
3532
- var AiApiImpl = class extends BaseApi {
3533
- addConfig(config) {
3534
- return this.invokeMethod("addConfig", config);
3535
- }
3536
- deleteConfig(id) {
3537
- return this.invokeMethod("deleteConfig", id);
3538
- }
3539
- updateConfig(config) {
3540
- return this.invokeMethod("updateConfig", config);
3541
- }
3542
- getConfigList() {
3543
- return this.invokeMethod("getConfigList");
3544
- }
3545
- setConfigList(configs) {
3546
- return this.invokeMethod("setConfigList", configs);
3547
- }
3548
- getConfig(id) {
3549
- return this.invokeMethod("getConfig", id);
3550
- }
3551
- getChannel() {
3552
- return "channel::cn.widgetjs.core.ai" /* AI */;
3553
- }
3554
- };
3555
- var AiApi = new AiApiImpl();
3556
-
3557
- exports.AiApi = AiApi;
3558
3780
  exports.AiApiEvent = AiApiEvent;
3559
3781
  exports.ApiConstants = ApiConstants;
3560
3782
  exports.AppApi = AppApi;
@@ -3564,6 +3786,7 @@ exports.AppConfig = AppConfig;
3564
3786
  exports.AppEvent = AppEvent;
3565
3787
  exports.AppNotification = AppNotification;
3566
3788
  exports.AppReminderNotification = AppReminderNotification;
3789
+ exports.AppTheme = AppTheme;
3567
3790
  exports.BackgroundWidget = BackgroundWidget;
3568
3791
  exports.BaseApi = BaseApi;
3569
3792
  exports.BroadcastApi = BroadcastApi;
@@ -3573,6 +3796,9 @@ exports.BrowserWindowApiEvent = BrowserWindowApiEvent;
3573
3796
  exports.Channel = Channel;
3574
3797
  exports.ClipboardApi = ClipboardApi;
3575
3798
  exports.ClipboardApiEvent = ClipboardApiEvent;
3799
+ exports.DefaultTheme = DefaultTheme;
3800
+ exports.DefaultThemeDark = DefaultThemeDark;
3801
+ exports.DefaultThemeLight = DefaultThemeLight;
3576
3802
  exports.DefaultWidgetTheme = DefaultWidgetTheme;
3577
3803
  exports.DeployMode = DeployMode;
3578
3804
  exports.DeployedPage = DeployedPage;