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

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