@mantou/gem 1.6.4 → 1.6.10
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/README.md +6 -38
- package/dist/gem.es.js +3260 -0
- package/dist/gem.umd.js +229 -0
- package/elements/{dialog-base.d.ts → base/dialog.d.ts} +4 -4
- package/elements/base/dialog.d.ts.map +1 -0
- package/elements/{dialog-base.js → base/dialog.js} +26 -28
- package/elements/base/dialog.js.map +1 -0
- package/elements/base/gesture.d.ts +66 -0
- package/elements/base/gesture.d.ts.map +1 -0
- package/elements/base/gesture.js +214 -0
- package/elements/base/gesture.js.map +1 -0
- package/elements/base/link.d.ts +44 -0
- package/elements/base/link.d.ts.map +1 -0
- package/elements/base/link.js +206 -0
- package/elements/base/link.js.map +1 -0
- package/elements/{modal-base.d.ts → base/modal-factory.d.ts} +20 -20
- package/elements/base/modal-factory.d.ts.map +1 -0
- package/elements/{modal-base.js → base/modal-factory.js} +10 -7
- package/elements/base/modal-factory.js.map +1 -0
- package/elements/base/reflect.d.ts +6 -0
- package/elements/base/reflect.d.ts.map +1 -0
- package/elements/base/reflect.js +33 -0
- package/elements/base/reflect.js.map +1 -0
- package/elements/base/route.d.ts +78 -0
- package/elements/base/route.d.ts.map +1 -0
- package/elements/base/route.js +220 -0
- package/elements/base/route.js.map +1 -0
- package/elements/base/title.d.ts +30 -0
- package/elements/base/title.d.ts.map +1 -0
- package/elements/base/title.js +74 -0
- package/elements/base/title.js.map +1 -0
- package/elements/base/unsafe.d.ts +14 -0
- package/elements/base/unsafe.d.ts.map +1 -0
- package/elements/base/unsafe.js +42 -0
- package/elements/base/unsafe.js.map +1 -0
- package/elements/base/use.d.ts +19 -0
- package/elements/base/use.d.ts.map +1 -0
- package/elements/base/use.js +70 -0
- package/elements/base/use.js.map +1 -0
- package/elements/gesture.d.ts +1 -67
- package/elements/gesture.d.ts.map +1 -1
- package/elements/gesture.js +3 -219
- package/elements/gesture.js.map +1 -1
- package/elements/link.d.ts +1 -45
- package/elements/link.d.ts.map +1 -1
- package/elements/link.js +4 -215
- package/elements/link.js.map +1 -1
- package/elements/reflect.d.ts +1 -8
- package/elements/reflect.d.ts.map +1 -1
- package/elements/reflect.js +3 -39
- package/elements/reflect.js.map +1 -1
- package/elements/route.d.ts +1 -81
- package/elements/route.d.ts.map +1 -1
- package/elements/route.js +4 -225
- package/elements/route.js.map +1 -1
- package/elements/title.d.ts +1 -30
- package/elements/title.d.ts.map +1 -1
- package/elements/title.js +3 -75
- package/elements/title.js.map +1 -1
- package/elements/unsafe.d.ts +1 -14
- package/elements/unsafe.d.ts.map +1 -1
- package/elements/unsafe.js +3 -46
- package/elements/unsafe.js.map +1 -1
- package/elements/use.d.ts +1 -19
- package/elements/use.d.ts.map +1 -1
- package/elements/use.js +3 -74
- package/elements/use.js.map +1 -1
- package/helper/i18n.js +47 -58
- package/helper/i18n.js.map +1 -1
- package/helper/request.js +11 -19
- package/helper/request.js.map +1 -1
- package/index.d.ts +5 -4
- package/index.d.ts.map +1 -1
- package/index.js +4 -2
- package/index.js.map +1 -1
- package/lib/element.d.ts.map +1 -1
- package/lib/element.js +1 -1
- package/lib/element.js.map +1 -1
- package/lib/history.d.ts +28 -16
- package/lib/history.d.ts.map +1 -1
- package/lib/history.js +179 -169
- package/lib/history.js.map +1 -1
- package/lib/utils.d.ts +3 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +7 -5
- package/lib/utils.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +25 -53
- package/src/{umd.ts → dist.ts} +4 -5
- package/src/elements/{dialog-base.ts → base/dialog.ts} +6 -7
- package/src/elements/base/gesture.ts +256 -0
- package/src/elements/base/link.ts +178 -0
- package/src/elements/{modal-base.ts → base/modal-factory.ts} +3 -3
- package/src/elements/base/reflect.ts +29 -0
- package/src/elements/base/route.ts +244 -0
- package/src/elements/base/title.ts +68 -0
- package/src/elements/base/unsafe.ts +37 -0
- package/src/elements/base/use.ts +57 -0
- package/src/elements/gesture.ts +3 -257
- package/src/elements/link.ts +4 -179
- package/src/elements/reflect.ts +3 -31
- package/src/elements/route.ts +4 -248
- package/src/elements/title.ts +3 -68
- package/src/elements/unsafe.ts +3 -37
- package/src/elements/use.ts +3 -57
- package/src/index.ts +4 -6
- package/src/lib/element.ts +2 -1
- package/src/lib/history.ts +183 -195
- package/src/lib/utils.ts +11 -5
- package/src/lib/version.ts +1 -1
- package/src/test/gem-element/advance.test.ts +1 -0
- package/src/test/gem-element/basic.test.ts +1 -0
- package/src/test/gem-element/decorators.test.ts +1 -0
- package/src/test/gem-element/multi.test.ts +1 -0
- package/src/test/history.test.ts +16 -10
- package/src/test/store.test.ts +1 -0
- package/src/test/utils.test.ts +1 -0
- package/elements/dialog-base.d.ts.map +0 -1
- package/elements/dialog-base.js.map +0 -1
- package/elements/modal-base.d.ts.map +0 -1
- package/elements/modal-base.js.map +0 -1
- package/src/examples/base-path/index.ts +0 -44
- package/src/examples/controlled/index.ts +0 -75
- package/src/examples/decorator/chidren.ts +0 -77
- package/src/examples/decorator/index.ts +0 -110
- package/src/examples/dialog/index.ts +0 -148
- package/src/examples/effect/index.ts +0 -45
- package/src/examples/elements/env.ts +0 -7
- package/src/examples/elements/layout.ts +0 -53
- package/src/examples/elements/nav.ts +0 -71
- package/src/examples/elements/source.ts +0 -68
- package/src/examples/gesture/canvas.ts +0 -69
- package/src/examples/gesture/index.ts +0 -97
- package/src/examples/gesture/manifest.json +0 -3
- package/src/examples/hash/index.ts +0 -55
- package/src/examples/i18n/index.ts +0 -63
- package/src/examples/index/index.ts +0 -33
- package/src/examples/index/manifest.json +0 -5
- package/src/examples/light-dom/index.ts +0 -31
- package/src/examples/multi-page/api.ts +0 -9
- package/src/examples/multi-page/index.ts +0 -78
- package/src/examples/multi-page/page-a.ts +0 -16
- package/src/examples/multi-page/page-b.ts +0 -12
- package/src/examples/multi-page/page-c.ts +0 -40
- package/src/examples/multi-page/store.ts +0 -10
- package/src/examples/perf-demo/index.ts +0 -136
- package/src/examples/ref-route/index.ts +0 -109
- package/src/examples/reflect/index.ts +0 -61
- package/src/examples/styled/index.ts +0 -39
- package/src/examples/svg-icon/index.ts +0 -31
- package/src/examples/theme/index.ts +0 -56
- package/src/examples/unsafe/index.ts +0 -29
- package/umd.d.ts +0 -18
- package/umd.d.ts.map +0 -1
- package/umd.js +0 -54
- package/umd.js.LICENSE.txt +0 -13
- package/umd.js.map +0 -1
package/dist/gem.es.js
ADDED
|
@@ -0,0 +1,3260 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __accessCheck = (obj, member, msg) => {
|
|
21
|
+
if (!member.has(obj))
|
|
22
|
+
throw TypeError("Cannot " + msg);
|
|
23
|
+
};
|
|
24
|
+
var __privateGet = (obj, member, getter) => {
|
|
25
|
+
__accessCheck(obj, member, "read from private field");
|
|
26
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
27
|
+
};
|
|
28
|
+
var __privateAdd = (obj, member, value) => {
|
|
29
|
+
if (member.has(obj))
|
|
30
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
31
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
32
|
+
};
|
|
33
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
34
|
+
__accessCheck(obj, member, "write to private field");
|
|
35
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
38
|
+
var __privateMethod = (obj, member, method) => {
|
|
39
|
+
__accessCheck(obj, member, "access private method");
|
|
40
|
+
return method;
|
|
41
|
+
};
|
|
42
|
+
var _map, _firstItem, _lastItem, _delete, delete_fn, _stringify, _parse, _nextSibling, _parentElement, _inertStore, _a, _cacheCurrentKey, cacheCurrentKey_get, _urlParamsLang, urlParamsLang_get, _cacheLang, cacheLang_get, _isMain, isMain_get, _lang, lang_set;
|
|
43
|
+
var Gem = /* @__PURE__ */ Object.freeze({
|
|
44
|
+
__proto__: null,
|
|
45
|
+
[Symbol.toStringTag]: "Module",
|
|
46
|
+
get StoreListenerMap() {
|
|
47
|
+
return StoreListenerMap;
|
|
48
|
+
},
|
|
49
|
+
get createStore() {
|
|
50
|
+
return createStore;
|
|
51
|
+
},
|
|
52
|
+
get createStoreSet() {
|
|
53
|
+
return createStoreSet;
|
|
54
|
+
},
|
|
55
|
+
get updateStore() {
|
|
56
|
+
return updateStore;
|
|
57
|
+
},
|
|
58
|
+
get connect() {
|
|
59
|
+
return connect;
|
|
60
|
+
},
|
|
61
|
+
get disconnect() {
|
|
62
|
+
return disconnect;
|
|
63
|
+
},
|
|
64
|
+
get history() {
|
|
65
|
+
return history;
|
|
66
|
+
},
|
|
67
|
+
get titleStore() {
|
|
68
|
+
return titleStore;
|
|
69
|
+
},
|
|
70
|
+
get basePathStore() {
|
|
71
|
+
return basePathStore;
|
|
72
|
+
},
|
|
73
|
+
get html() {
|
|
74
|
+
return html;
|
|
75
|
+
},
|
|
76
|
+
get svg() {
|
|
77
|
+
return svg;
|
|
78
|
+
},
|
|
79
|
+
get render() {
|
|
80
|
+
return render;
|
|
81
|
+
},
|
|
82
|
+
get directive() {
|
|
83
|
+
return directive;
|
|
84
|
+
},
|
|
85
|
+
get TemplateResult() {
|
|
86
|
+
return TemplateResult;
|
|
87
|
+
},
|
|
88
|
+
get SVGTemplateResult() {
|
|
89
|
+
return SVGTemplateResult;
|
|
90
|
+
},
|
|
91
|
+
get repeat() {
|
|
92
|
+
return repeat;
|
|
93
|
+
},
|
|
94
|
+
get guard() {
|
|
95
|
+
return guard;
|
|
96
|
+
},
|
|
97
|
+
get ifDefined() {
|
|
98
|
+
return ifDefined;
|
|
99
|
+
},
|
|
100
|
+
get GemElement() {
|
|
101
|
+
return GemElement;
|
|
102
|
+
},
|
|
103
|
+
get defineAttribute() {
|
|
104
|
+
return defineAttribute;
|
|
105
|
+
},
|
|
106
|
+
get defineProperty() {
|
|
107
|
+
return defineProperty;
|
|
108
|
+
},
|
|
109
|
+
get defineRef() {
|
|
110
|
+
return defineRef;
|
|
111
|
+
},
|
|
112
|
+
get defineCSSState() {
|
|
113
|
+
return defineCSSState;
|
|
114
|
+
},
|
|
115
|
+
get nativeDefineElement() {
|
|
116
|
+
return nativeDefineElement;
|
|
117
|
+
},
|
|
118
|
+
get refobject() {
|
|
119
|
+
return refobject;
|
|
120
|
+
},
|
|
121
|
+
get attribute() {
|
|
122
|
+
return attribute;
|
|
123
|
+
},
|
|
124
|
+
get boolattribute() {
|
|
125
|
+
return boolattribute;
|
|
126
|
+
},
|
|
127
|
+
get numattribute() {
|
|
128
|
+
return numattribute;
|
|
129
|
+
},
|
|
130
|
+
get property() {
|
|
131
|
+
return property;
|
|
132
|
+
},
|
|
133
|
+
get state() {
|
|
134
|
+
return state;
|
|
135
|
+
},
|
|
136
|
+
get slot() {
|
|
137
|
+
return slot;
|
|
138
|
+
},
|
|
139
|
+
get part() {
|
|
140
|
+
return part;
|
|
141
|
+
},
|
|
142
|
+
get emitter() {
|
|
143
|
+
return emitter;
|
|
144
|
+
},
|
|
145
|
+
get globalemitter() {
|
|
146
|
+
return globalemitter;
|
|
147
|
+
},
|
|
148
|
+
get adoptedStyle() {
|
|
149
|
+
return adoptedStyle;
|
|
150
|
+
},
|
|
151
|
+
get connectStore() {
|
|
152
|
+
return connectStore;
|
|
153
|
+
},
|
|
154
|
+
get rootElement() {
|
|
155
|
+
return rootElement;
|
|
156
|
+
},
|
|
157
|
+
get customElement() {
|
|
158
|
+
return customElement;
|
|
159
|
+
},
|
|
160
|
+
get addMicrotask() {
|
|
161
|
+
return addMicrotask;
|
|
162
|
+
},
|
|
163
|
+
get addMicrotaskToStack() {
|
|
164
|
+
return addMicrotaskToStack;
|
|
165
|
+
},
|
|
166
|
+
get absoluteLocation() {
|
|
167
|
+
return absoluteLocation;
|
|
168
|
+
},
|
|
169
|
+
get LinkedList() {
|
|
170
|
+
return LinkedList;
|
|
171
|
+
},
|
|
172
|
+
get PropProxyMap() {
|
|
173
|
+
return PropProxyMap;
|
|
174
|
+
},
|
|
175
|
+
get QueryString() {
|
|
176
|
+
return QueryString;
|
|
177
|
+
},
|
|
178
|
+
get raw() {
|
|
179
|
+
return raw;
|
|
180
|
+
},
|
|
181
|
+
get css() {
|
|
182
|
+
return css;
|
|
183
|
+
},
|
|
184
|
+
get SheetToken() {
|
|
185
|
+
return SheetToken;
|
|
186
|
+
},
|
|
187
|
+
get useNativeCSSStyleSheet() {
|
|
188
|
+
return useNativeCSSStyleSheet;
|
|
189
|
+
},
|
|
190
|
+
get createCSSSheet() {
|
|
191
|
+
return createCSSSheet;
|
|
192
|
+
},
|
|
193
|
+
get randomStr() {
|
|
194
|
+
return randomStr;
|
|
195
|
+
},
|
|
196
|
+
get styled() {
|
|
197
|
+
return styled;
|
|
198
|
+
},
|
|
199
|
+
get camelToKebabCase() {
|
|
200
|
+
return camelToKebabCase;
|
|
201
|
+
},
|
|
202
|
+
get kebabToCamelCase() {
|
|
203
|
+
return kebabToCamelCase;
|
|
204
|
+
},
|
|
205
|
+
get cleanObject() {
|
|
206
|
+
return cleanObject;
|
|
207
|
+
},
|
|
208
|
+
get GemError() {
|
|
209
|
+
return GemError;
|
|
210
|
+
},
|
|
211
|
+
get isArrayChange() {
|
|
212
|
+
return isArrayChange;
|
|
213
|
+
},
|
|
214
|
+
get removeItems() {
|
|
215
|
+
return removeItems;
|
|
216
|
+
},
|
|
217
|
+
get styleMap() {
|
|
218
|
+
return styleMap;
|
|
219
|
+
},
|
|
220
|
+
get classMap() {
|
|
221
|
+
return classMap;
|
|
222
|
+
},
|
|
223
|
+
get partMap() {
|
|
224
|
+
return partMap;
|
|
225
|
+
},
|
|
226
|
+
get version() {
|
|
227
|
+
return version;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* @license
|
|
232
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
233
|
+
* This code may only be used under the BSD style license found at
|
|
234
|
+
* http://polymer.github.io/LICENSE.txt
|
|
235
|
+
* The complete set of authors may be found at
|
|
236
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
237
|
+
* The complete set of contributors may be found at
|
|
238
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
239
|
+
* Code distributed by Google as part of the polymer project is also
|
|
240
|
+
* subject to an additional IP rights grant found at
|
|
241
|
+
* http://polymer.github.io/PATENTS.txt
|
|
242
|
+
*/
|
|
243
|
+
const directives = new WeakMap();
|
|
244
|
+
const directive = (f) => (...args) => {
|
|
245
|
+
const d = f(...args);
|
|
246
|
+
directives.set(d, true);
|
|
247
|
+
return d;
|
|
248
|
+
};
|
|
249
|
+
const isDirective = (o) => {
|
|
250
|
+
return typeof o === "function" && directives.has(o);
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* @license
|
|
254
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
255
|
+
* This code may only be used under the BSD style license found at
|
|
256
|
+
* http://polymer.github.io/LICENSE.txt
|
|
257
|
+
* The complete set of authors may be found at
|
|
258
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
259
|
+
* The complete set of contributors may be found at
|
|
260
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
261
|
+
* Code distributed by Google as part of the polymer project is also
|
|
262
|
+
* subject to an additional IP rights grant found at
|
|
263
|
+
* http://polymer.github.io/PATENTS.txt
|
|
264
|
+
*/
|
|
265
|
+
const isCEPolyfill = typeof window !== "undefined" && window.customElements != null && window.customElements.polyfillWrapFlushCallback !== void 0;
|
|
266
|
+
const reparentNodes = (container, start, end = null, before = null) => {
|
|
267
|
+
while (start !== end) {
|
|
268
|
+
const n = start.nextSibling;
|
|
269
|
+
container.insertBefore(start, before);
|
|
270
|
+
start = n;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const removeNodes = (container, start, end = null) => {
|
|
274
|
+
while (start !== end) {
|
|
275
|
+
const n = start.nextSibling;
|
|
276
|
+
container.removeChild(start);
|
|
277
|
+
start = n;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* @license
|
|
282
|
+
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
|
|
283
|
+
* This code may only be used under the BSD style license found at
|
|
284
|
+
* http://polymer.github.io/LICENSE.txt
|
|
285
|
+
* The complete set of authors may be found at
|
|
286
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
287
|
+
* The complete set of contributors may be found at
|
|
288
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
289
|
+
* Code distributed by Google as part of the polymer project is also
|
|
290
|
+
* subject to an additional IP rights grant found at
|
|
291
|
+
* http://polymer.github.io/PATENTS.txt
|
|
292
|
+
*/
|
|
293
|
+
const noChange = {};
|
|
294
|
+
const nothing = {};
|
|
295
|
+
/**
|
|
296
|
+
* @license
|
|
297
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
298
|
+
* This code may only be used under the BSD style license found at
|
|
299
|
+
* http://polymer.github.io/LICENSE.txt
|
|
300
|
+
* The complete set of authors may be found at
|
|
301
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
302
|
+
* The complete set of contributors may be found at
|
|
303
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
304
|
+
* Code distributed by Google as part of the polymer project is also
|
|
305
|
+
* subject to an additional IP rights grant found at
|
|
306
|
+
* http://polymer.github.io/PATENTS.txt
|
|
307
|
+
*/
|
|
308
|
+
const marker = `{{lit-${String(Math.random()).slice(2)}}}`;
|
|
309
|
+
const nodeMarker = `<!--${marker}-->`;
|
|
310
|
+
const markerRegex = new RegExp(`${marker}|${nodeMarker}`);
|
|
311
|
+
const boundAttributeSuffix = "$lit$";
|
|
312
|
+
class Template {
|
|
313
|
+
constructor(result, element) {
|
|
314
|
+
this.parts = [];
|
|
315
|
+
this.element = element;
|
|
316
|
+
const nodesToRemove = [];
|
|
317
|
+
const stack = [];
|
|
318
|
+
const walker = document.createTreeWalker(element.content, 133, null, false);
|
|
319
|
+
let lastPartIndex = 0;
|
|
320
|
+
let index = -1;
|
|
321
|
+
let partIndex = 0;
|
|
322
|
+
const { strings, values: { length } } = result;
|
|
323
|
+
while (partIndex < length) {
|
|
324
|
+
const node = walker.nextNode();
|
|
325
|
+
if (node === null) {
|
|
326
|
+
walker.currentNode = stack.pop();
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
index++;
|
|
330
|
+
if (node.nodeType === 1) {
|
|
331
|
+
if (node.hasAttributes()) {
|
|
332
|
+
const attributes = node.attributes;
|
|
333
|
+
const { length: length2 } = attributes;
|
|
334
|
+
let count = 0;
|
|
335
|
+
for (let i = 0; i < length2; i++) {
|
|
336
|
+
if (endsWith(attributes[i].name, boundAttributeSuffix)) {
|
|
337
|
+
count++;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
while (count-- > 0) {
|
|
341
|
+
const stringForPart = strings[partIndex];
|
|
342
|
+
const name = lastAttributeNameRegex.exec(stringForPart)[2];
|
|
343
|
+
const attributeLookupName = name.toLowerCase() + boundAttributeSuffix;
|
|
344
|
+
const attributeValue = node.getAttribute(attributeLookupName);
|
|
345
|
+
node.removeAttribute(attributeLookupName);
|
|
346
|
+
const statics = attributeValue.split(markerRegex);
|
|
347
|
+
this.parts.push({ type: "attribute", index, name, strings: statics });
|
|
348
|
+
partIndex += statics.length - 1;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (node.tagName === "TEMPLATE") {
|
|
352
|
+
stack.push(node);
|
|
353
|
+
walker.currentNode = node.content;
|
|
354
|
+
}
|
|
355
|
+
} else if (node.nodeType === 3) {
|
|
356
|
+
const data = node.data;
|
|
357
|
+
if (data.indexOf(marker) >= 0) {
|
|
358
|
+
const parent = node.parentNode;
|
|
359
|
+
const strings2 = data.split(markerRegex);
|
|
360
|
+
const lastIndex = strings2.length - 1;
|
|
361
|
+
for (let i = 0; i < lastIndex; i++) {
|
|
362
|
+
let insert;
|
|
363
|
+
let s = strings2[i];
|
|
364
|
+
if (s === "") {
|
|
365
|
+
insert = createMarker();
|
|
366
|
+
} else {
|
|
367
|
+
const match = lastAttributeNameRegex.exec(s);
|
|
368
|
+
if (match !== null && endsWith(match[2], boundAttributeSuffix)) {
|
|
369
|
+
s = s.slice(0, match.index) + match[1] + match[2].slice(0, -boundAttributeSuffix.length) + match[3];
|
|
370
|
+
}
|
|
371
|
+
insert = document.createTextNode(s);
|
|
372
|
+
}
|
|
373
|
+
parent.insertBefore(insert, node);
|
|
374
|
+
this.parts.push({ type: "node", index: ++index });
|
|
375
|
+
}
|
|
376
|
+
if (strings2[lastIndex] === "") {
|
|
377
|
+
parent.insertBefore(createMarker(), node);
|
|
378
|
+
nodesToRemove.push(node);
|
|
379
|
+
} else {
|
|
380
|
+
node.data = strings2[lastIndex];
|
|
381
|
+
}
|
|
382
|
+
partIndex += lastIndex;
|
|
383
|
+
}
|
|
384
|
+
} else if (node.nodeType === 8) {
|
|
385
|
+
if (node.data === marker) {
|
|
386
|
+
const parent = node.parentNode;
|
|
387
|
+
if (node.previousSibling === null || index === lastPartIndex) {
|
|
388
|
+
index++;
|
|
389
|
+
parent.insertBefore(createMarker(), node);
|
|
390
|
+
}
|
|
391
|
+
lastPartIndex = index;
|
|
392
|
+
this.parts.push({ type: "node", index });
|
|
393
|
+
if (node.nextSibling === null) {
|
|
394
|
+
node.data = "";
|
|
395
|
+
} else {
|
|
396
|
+
nodesToRemove.push(node);
|
|
397
|
+
index--;
|
|
398
|
+
}
|
|
399
|
+
partIndex++;
|
|
400
|
+
} else {
|
|
401
|
+
let i = -1;
|
|
402
|
+
while ((i = node.data.indexOf(marker, i + 1)) !== -1) {
|
|
403
|
+
this.parts.push({ type: "node", index: -1 });
|
|
404
|
+
partIndex++;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
for (const n of nodesToRemove) {
|
|
410
|
+
n.parentNode.removeChild(n);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
const endsWith = (str, suffix) => {
|
|
415
|
+
const index = str.length - suffix.length;
|
|
416
|
+
return index >= 0 && str.slice(index) === suffix;
|
|
417
|
+
};
|
|
418
|
+
const isTemplatePartActive = (part2) => part2.index !== -1;
|
|
419
|
+
const createMarker = () => document.createComment("");
|
|
420
|
+
const lastAttributeNameRegex = /([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
|
|
421
|
+
/**
|
|
422
|
+
* @license
|
|
423
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
424
|
+
* This code may only be used under the BSD style license found at
|
|
425
|
+
* http://polymer.github.io/LICENSE.txt
|
|
426
|
+
* The complete set of authors may be found at
|
|
427
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
428
|
+
* The complete set of contributors may be found at
|
|
429
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
430
|
+
* Code distributed by Google as part of the polymer project is also
|
|
431
|
+
* subject to an additional IP rights grant found at
|
|
432
|
+
* http://polymer.github.io/PATENTS.txt
|
|
433
|
+
*/
|
|
434
|
+
class TemplateInstance {
|
|
435
|
+
constructor(template, processor, options) {
|
|
436
|
+
this.__parts = [];
|
|
437
|
+
this.template = template;
|
|
438
|
+
this.processor = processor;
|
|
439
|
+
this.options = options;
|
|
440
|
+
}
|
|
441
|
+
update(values) {
|
|
442
|
+
let i = 0;
|
|
443
|
+
for (const part2 of this.__parts) {
|
|
444
|
+
if (part2 !== void 0) {
|
|
445
|
+
part2.setValue(values[i]);
|
|
446
|
+
}
|
|
447
|
+
i++;
|
|
448
|
+
}
|
|
449
|
+
for (const part2 of this.__parts) {
|
|
450
|
+
if (part2 !== void 0) {
|
|
451
|
+
part2.commit();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
_clone() {
|
|
456
|
+
const fragment = isCEPolyfill ? this.template.element.content.cloneNode(true) : document.importNode(this.template.element.content, true);
|
|
457
|
+
const stack = [];
|
|
458
|
+
const parts2 = this.template.parts;
|
|
459
|
+
const walker = document.createTreeWalker(fragment, 133, null, false);
|
|
460
|
+
let partIndex = 0;
|
|
461
|
+
let nodeIndex = 0;
|
|
462
|
+
let part2;
|
|
463
|
+
let node = walker.nextNode();
|
|
464
|
+
while (partIndex < parts2.length) {
|
|
465
|
+
part2 = parts2[partIndex];
|
|
466
|
+
if (!isTemplatePartActive(part2)) {
|
|
467
|
+
this.__parts.push(void 0);
|
|
468
|
+
partIndex++;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
while (nodeIndex < part2.index) {
|
|
472
|
+
nodeIndex++;
|
|
473
|
+
if (node.nodeName === "TEMPLATE") {
|
|
474
|
+
stack.push(node);
|
|
475
|
+
walker.currentNode = node.content;
|
|
476
|
+
}
|
|
477
|
+
if ((node = walker.nextNode()) === null) {
|
|
478
|
+
walker.currentNode = stack.pop();
|
|
479
|
+
node = walker.nextNode();
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (part2.type === "node") {
|
|
483
|
+
const part3 = this.processor.handleTextExpression(this.options);
|
|
484
|
+
part3.insertAfterNode(node.previousSibling);
|
|
485
|
+
this.__parts.push(part3);
|
|
486
|
+
} else {
|
|
487
|
+
this.__parts.push(...this.processor.handleAttributeExpressions(node, part2.name, part2.strings, this.options));
|
|
488
|
+
}
|
|
489
|
+
partIndex++;
|
|
490
|
+
}
|
|
491
|
+
if (isCEPolyfill) {
|
|
492
|
+
document.adoptNode(fragment);
|
|
493
|
+
customElements.upgrade(fragment);
|
|
494
|
+
}
|
|
495
|
+
return fragment;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* @license
|
|
500
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
501
|
+
* This code may only be used under the BSD style license found at
|
|
502
|
+
* http://polymer.github.io/LICENSE.txt
|
|
503
|
+
* The complete set of authors may be found at
|
|
504
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
505
|
+
* The complete set of contributors may be found at
|
|
506
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
507
|
+
* Code distributed by Google as part of the polymer project is also
|
|
508
|
+
* subject to an additional IP rights grant found at
|
|
509
|
+
* http://polymer.github.io/PATENTS.txt
|
|
510
|
+
*/
|
|
511
|
+
const policy = window.trustedTypes && trustedTypes.createPolicy("lit-html", { createHTML: (s) => s });
|
|
512
|
+
const commentMarker = ` ${marker} `;
|
|
513
|
+
class TemplateResult {
|
|
514
|
+
constructor(strings, values, type, processor) {
|
|
515
|
+
this.strings = strings;
|
|
516
|
+
this.values = values;
|
|
517
|
+
this.type = type;
|
|
518
|
+
this.processor = processor;
|
|
519
|
+
}
|
|
520
|
+
getHTML() {
|
|
521
|
+
const l = this.strings.length - 1;
|
|
522
|
+
let html2 = "";
|
|
523
|
+
let isCommentBinding = false;
|
|
524
|
+
for (let i = 0; i < l; i++) {
|
|
525
|
+
const s = this.strings[i];
|
|
526
|
+
const commentOpen = s.lastIndexOf("<!--");
|
|
527
|
+
isCommentBinding = (commentOpen > -1 || isCommentBinding) && s.indexOf("-->", commentOpen + 1) === -1;
|
|
528
|
+
const attributeMatch = lastAttributeNameRegex.exec(s);
|
|
529
|
+
if (attributeMatch === null) {
|
|
530
|
+
html2 += s + (isCommentBinding ? commentMarker : nodeMarker);
|
|
531
|
+
} else {
|
|
532
|
+
html2 += s.substr(0, attributeMatch.index) + attributeMatch[1] + attributeMatch[2] + boundAttributeSuffix + attributeMatch[3] + marker;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
html2 += this.strings[l];
|
|
536
|
+
return html2;
|
|
537
|
+
}
|
|
538
|
+
getTemplateElement() {
|
|
539
|
+
const template = document.createElement("template");
|
|
540
|
+
let value = this.getHTML();
|
|
541
|
+
if (policy !== void 0) {
|
|
542
|
+
value = policy.createHTML(value);
|
|
543
|
+
}
|
|
544
|
+
template.innerHTML = value;
|
|
545
|
+
return template;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
class SVGTemplateResult extends TemplateResult {
|
|
549
|
+
getHTML() {
|
|
550
|
+
return `<svg>${super.getHTML()}</svg>`;
|
|
551
|
+
}
|
|
552
|
+
getTemplateElement() {
|
|
553
|
+
const template = super.getTemplateElement();
|
|
554
|
+
const content = template.content;
|
|
555
|
+
const svgElement = content.firstChild;
|
|
556
|
+
content.removeChild(svgElement);
|
|
557
|
+
reparentNodes(content, svgElement.firstChild);
|
|
558
|
+
return template;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* @license
|
|
563
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
564
|
+
* This code may only be used under the BSD style license found at
|
|
565
|
+
* http://polymer.github.io/LICENSE.txt
|
|
566
|
+
* The complete set of authors may be found at
|
|
567
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
568
|
+
* The complete set of contributors may be found at
|
|
569
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
570
|
+
* Code distributed by Google as part of the polymer project is also
|
|
571
|
+
* subject to an additional IP rights grant found at
|
|
572
|
+
* http://polymer.github.io/PATENTS.txt
|
|
573
|
+
*/
|
|
574
|
+
const isPrimitive = (value) => {
|
|
575
|
+
return value === null || !(typeof value === "object" || typeof value === "function");
|
|
576
|
+
};
|
|
577
|
+
const isIterable = (value) => {
|
|
578
|
+
return Array.isArray(value) || !!(value && value[Symbol.iterator]);
|
|
579
|
+
};
|
|
580
|
+
class AttributeCommitter {
|
|
581
|
+
constructor(element, name, strings) {
|
|
582
|
+
this.dirty = true;
|
|
583
|
+
this.element = element;
|
|
584
|
+
this.name = name;
|
|
585
|
+
this.strings = strings;
|
|
586
|
+
this.parts = [];
|
|
587
|
+
for (let i = 0; i < strings.length - 1; i++) {
|
|
588
|
+
this.parts[i] = this._createPart();
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
_createPart() {
|
|
592
|
+
return new AttributePart(this);
|
|
593
|
+
}
|
|
594
|
+
_getValue() {
|
|
595
|
+
const strings = this.strings;
|
|
596
|
+
const l = strings.length - 1;
|
|
597
|
+
const parts2 = this.parts;
|
|
598
|
+
if (l === 1 && strings[0] === "" && strings[1] === "") {
|
|
599
|
+
const v = parts2[0].value;
|
|
600
|
+
if (typeof v === "symbol") {
|
|
601
|
+
return String(v);
|
|
602
|
+
}
|
|
603
|
+
if (typeof v === "string" || !isIterable(v)) {
|
|
604
|
+
return v;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
let text = "";
|
|
608
|
+
for (let i = 0; i < l; i++) {
|
|
609
|
+
text += strings[i];
|
|
610
|
+
const part2 = parts2[i];
|
|
611
|
+
if (part2 !== void 0) {
|
|
612
|
+
const v = part2.value;
|
|
613
|
+
if (isPrimitive(v) || !isIterable(v)) {
|
|
614
|
+
text += typeof v === "string" ? v : String(v);
|
|
615
|
+
} else {
|
|
616
|
+
for (const t of v) {
|
|
617
|
+
text += typeof t === "string" ? t : String(t);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
text += strings[l];
|
|
623
|
+
return text;
|
|
624
|
+
}
|
|
625
|
+
commit() {
|
|
626
|
+
if (this.dirty) {
|
|
627
|
+
this.dirty = false;
|
|
628
|
+
this.element.setAttribute(this.name, this._getValue());
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
class AttributePart {
|
|
633
|
+
constructor(committer) {
|
|
634
|
+
this.value = void 0;
|
|
635
|
+
this.committer = committer;
|
|
636
|
+
}
|
|
637
|
+
setValue(value) {
|
|
638
|
+
if (value !== noChange && (!isPrimitive(value) || value !== this.value)) {
|
|
639
|
+
this.value = value;
|
|
640
|
+
if (!isDirective(value)) {
|
|
641
|
+
this.committer.dirty = true;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
commit() {
|
|
646
|
+
while (isDirective(this.value)) {
|
|
647
|
+
const directive2 = this.value;
|
|
648
|
+
this.value = noChange;
|
|
649
|
+
directive2(this);
|
|
650
|
+
}
|
|
651
|
+
if (this.value === noChange) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
this.committer.commit();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
class NodePart {
|
|
658
|
+
constructor(options) {
|
|
659
|
+
this.value = void 0;
|
|
660
|
+
this.__pendingValue = void 0;
|
|
661
|
+
this.options = options;
|
|
662
|
+
}
|
|
663
|
+
appendInto(container) {
|
|
664
|
+
this.startNode = container.appendChild(createMarker());
|
|
665
|
+
this.endNode = container.appendChild(createMarker());
|
|
666
|
+
}
|
|
667
|
+
insertAfterNode(ref) {
|
|
668
|
+
this.startNode = ref;
|
|
669
|
+
this.endNode = ref.nextSibling;
|
|
670
|
+
}
|
|
671
|
+
appendIntoPart(part2) {
|
|
672
|
+
part2.__insert(this.startNode = createMarker());
|
|
673
|
+
part2.__insert(this.endNode = createMarker());
|
|
674
|
+
}
|
|
675
|
+
insertAfterPart(ref) {
|
|
676
|
+
ref.__insert(this.startNode = createMarker());
|
|
677
|
+
this.endNode = ref.endNode;
|
|
678
|
+
ref.endNode = this.startNode;
|
|
679
|
+
}
|
|
680
|
+
setValue(value) {
|
|
681
|
+
this.__pendingValue = value;
|
|
682
|
+
}
|
|
683
|
+
commit() {
|
|
684
|
+
if (this.startNode.parentNode === null) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
while (isDirective(this.__pendingValue)) {
|
|
688
|
+
const directive2 = this.__pendingValue;
|
|
689
|
+
this.__pendingValue = noChange;
|
|
690
|
+
directive2(this);
|
|
691
|
+
}
|
|
692
|
+
const value = this.__pendingValue;
|
|
693
|
+
if (value === noChange) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (isPrimitive(value)) {
|
|
697
|
+
if (value !== this.value) {
|
|
698
|
+
this.__commitText(value);
|
|
699
|
+
}
|
|
700
|
+
} else if (value instanceof TemplateResult) {
|
|
701
|
+
this.__commitTemplateResult(value);
|
|
702
|
+
} else if (value instanceof Node) {
|
|
703
|
+
this.__commitNode(value);
|
|
704
|
+
} else if (isIterable(value)) {
|
|
705
|
+
this.__commitIterable(value);
|
|
706
|
+
} else if (value === nothing) {
|
|
707
|
+
this.value = nothing;
|
|
708
|
+
this.clear();
|
|
709
|
+
} else {
|
|
710
|
+
this.__commitText(value);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
__insert(node) {
|
|
714
|
+
this.endNode.parentNode.insertBefore(node, this.endNode);
|
|
715
|
+
}
|
|
716
|
+
__commitNode(value) {
|
|
717
|
+
if (this.value === value) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
this.clear();
|
|
721
|
+
this.__insert(value);
|
|
722
|
+
this.value = value;
|
|
723
|
+
}
|
|
724
|
+
__commitText(value) {
|
|
725
|
+
const node = this.startNode.nextSibling;
|
|
726
|
+
value = value == null ? "" : value;
|
|
727
|
+
const valueAsString = typeof value === "string" ? value : String(value);
|
|
728
|
+
if (node === this.endNode.previousSibling && node.nodeType === 3) {
|
|
729
|
+
node.data = valueAsString;
|
|
730
|
+
} else {
|
|
731
|
+
this.__commitNode(document.createTextNode(valueAsString));
|
|
732
|
+
}
|
|
733
|
+
this.value = value;
|
|
734
|
+
}
|
|
735
|
+
__commitTemplateResult(value) {
|
|
736
|
+
const template = this.options.templateFactory(value);
|
|
737
|
+
if (this.value instanceof TemplateInstance && this.value.template === template) {
|
|
738
|
+
this.value.update(value.values);
|
|
739
|
+
} else {
|
|
740
|
+
const instance = new TemplateInstance(template, value.processor, this.options);
|
|
741
|
+
const fragment = instance._clone();
|
|
742
|
+
instance.update(value.values);
|
|
743
|
+
this.__commitNode(fragment);
|
|
744
|
+
this.value = instance;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
__commitIterable(value) {
|
|
748
|
+
if (!Array.isArray(this.value)) {
|
|
749
|
+
this.value = [];
|
|
750
|
+
this.clear();
|
|
751
|
+
}
|
|
752
|
+
const itemParts = this.value;
|
|
753
|
+
let partIndex = 0;
|
|
754
|
+
let itemPart;
|
|
755
|
+
for (const item of value) {
|
|
756
|
+
itemPart = itemParts[partIndex];
|
|
757
|
+
if (itemPart === void 0) {
|
|
758
|
+
itemPart = new NodePart(this.options);
|
|
759
|
+
itemParts.push(itemPart);
|
|
760
|
+
if (partIndex === 0) {
|
|
761
|
+
itemPart.appendIntoPart(this);
|
|
762
|
+
} else {
|
|
763
|
+
itemPart.insertAfterPart(itemParts[partIndex - 1]);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
itemPart.setValue(item);
|
|
767
|
+
itemPart.commit();
|
|
768
|
+
partIndex++;
|
|
769
|
+
}
|
|
770
|
+
if (partIndex < itemParts.length) {
|
|
771
|
+
itemParts.length = partIndex;
|
|
772
|
+
this.clear(itemPart && itemPart.endNode);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
clear(startNode = this.startNode) {
|
|
776
|
+
removeNodes(this.startNode.parentNode, startNode.nextSibling, this.endNode);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
class BooleanAttributePart {
|
|
780
|
+
constructor(element, name, strings) {
|
|
781
|
+
this.value = void 0;
|
|
782
|
+
this.__pendingValue = void 0;
|
|
783
|
+
if (strings.length !== 2 || strings[0] !== "" || strings[1] !== "") {
|
|
784
|
+
throw new Error("Boolean attributes can only contain a single expression");
|
|
785
|
+
}
|
|
786
|
+
this.element = element;
|
|
787
|
+
this.name = name;
|
|
788
|
+
this.strings = strings;
|
|
789
|
+
}
|
|
790
|
+
setValue(value) {
|
|
791
|
+
this.__pendingValue = value;
|
|
792
|
+
}
|
|
793
|
+
commit() {
|
|
794
|
+
while (isDirective(this.__pendingValue)) {
|
|
795
|
+
const directive2 = this.__pendingValue;
|
|
796
|
+
this.__pendingValue = noChange;
|
|
797
|
+
directive2(this);
|
|
798
|
+
}
|
|
799
|
+
if (this.__pendingValue === noChange) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const value = !!this.__pendingValue;
|
|
803
|
+
if (this.value !== value) {
|
|
804
|
+
if (value) {
|
|
805
|
+
this.element.setAttribute(this.name, "");
|
|
806
|
+
} else {
|
|
807
|
+
this.element.removeAttribute(this.name);
|
|
808
|
+
}
|
|
809
|
+
this.value = value;
|
|
810
|
+
}
|
|
811
|
+
this.__pendingValue = noChange;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
class PropertyCommitter extends AttributeCommitter {
|
|
815
|
+
constructor(element, name, strings) {
|
|
816
|
+
super(element, name, strings);
|
|
817
|
+
this.single = strings.length === 2 && strings[0] === "" && strings[1] === "";
|
|
818
|
+
}
|
|
819
|
+
_createPart() {
|
|
820
|
+
return new PropertyPart(this);
|
|
821
|
+
}
|
|
822
|
+
_getValue() {
|
|
823
|
+
if (this.single) {
|
|
824
|
+
return this.parts[0].value;
|
|
825
|
+
}
|
|
826
|
+
return super._getValue();
|
|
827
|
+
}
|
|
828
|
+
commit() {
|
|
829
|
+
if (this.dirty) {
|
|
830
|
+
this.dirty = false;
|
|
831
|
+
this.element[this.name] = this._getValue();
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
class PropertyPart extends AttributePart {
|
|
836
|
+
}
|
|
837
|
+
let eventOptionsSupported = false;
|
|
838
|
+
(() => {
|
|
839
|
+
try {
|
|
840
|
+
const options = {
|
|
841
|
+
get capture() {
|
|
842
|
+
eventOptionsSupported = true;
|
|
843
|
+
return false;
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
window.addEventListener("test", options, options);
|
|
847
|
+
window.removeEventListener("test", options, options);
|
|
848
|
+
} catch (_e) {
|
|
849
|
+
}
|
|
850
|
+
})();
|
|
851
|
+
class EventPart {
|
|
852
|
+
constructor(element, eventName, eventContext) {
|
|
853
|
+
this.value = void 0;
|
|
854
|
+
this.__pendingValue = void 0;
|
|
855
|
+
this.element = element;
|
|
856
|
+
this.eventName = eventName;
|
|
857
|
+
this.eventContext = eventContext;
|
|
858
|
+
this.__boundHandleEvent = (e) => this.handleEvent(e);
|
|
859
|
+
}
|
|
860
|
+
setValue(value) {
|
|
861
|
+
this.__pendingValue = value;
|
|
862
|
+
}
|
|
863
|
+
commit() {
|
|
864
|
+
while (isDirective(this.__pendingValue)) {
|
|
865
|
+
const directive2 = this.__pendingValue;
|
|
866
|
+
this.__pendingValue = noChange;
|
|
867
|
+
directive2(this);
|
|
868
|
+
}
|
|
869
|
+
if (this.__pendingValue === noChange) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
const newListener = this.__pendingValue;
|
|
873
|
+
const oldListener = this.value;
|
|
874
|
+
const shouldRemoveListener = newListener == null || oldListener != null && (newListener.capture !== oldListener.capture || newListener.once !== oldListener.once || newListener.passive !== oldListener.passive);
|
|
875
|
+
const shouldAddListener = newListener != null && (oldListener == null || shouldRemoveListener);
|
|
876
|
+
if (shouldRemoveListener) {
|
|
877
|
+
this.element.removeEventListener(this.eventName, this.__boundHandleEvent, this.__options);
|
|
878
|
+
}
|
|
879
|
+
if (shouldAddListener) {
|
|
880
|
+
this.__options = getOptions(newListener);
|
|
881
|
+
this.element.addEventListener(this.eventName, this.__boundHandleEvent, this.__options);
|
|
882
|
+
}
|
|
883
|
+
this.value = newListener;
|
|
884
|
+
this.__pendingValue = noChange;
|
|
885
|
+
}
|
|
886
|
+
handleEvent(event) {
|
|
887
|
+
if (typeof this.value === "function") {
|
|
888
|
+
this.value.call(this.eventContext || this.element, event);
|
|
889
|
+
} else {
|
|
890
|
+
this.value.handleEvent(event);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
const getOptions = (o) => o && (eventOptionsSupported ? { capture: o.capture, passive: o.passive, once: o.once } : o.capture);
|
|
895
|
+
/**
|
|
896
|
+
* @license
|
|
897
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
898
|
+
* This code may only be used under the BSD style license found at
|
|
899
|
+
* http://polymer.github.io/LICENSE.txt
|
|
900
|
+
* The complete set of authors may be found at
|
|
901
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
902
|
+
* The complete set of contributors may be found at
|
|
903
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
904
|
+
* Code distributed by Google as part of the polymer project is also
|
|
905
|
+
* subject to an additional IP rights grant found at
|
|
906
|
+
* http://polymer.github.io/PATENTS.txt
|
|
907
|
+
*/
|
|
908
|
+
class DefaultTemplateProcessor {
|
|
909
|
+
handleAttributeExpressions(element, name, strings, options) {
|
|
910
|
+
const prefix = name[0];
|
|
911
|
+
if (prefix === ".") {
|
|
912
|
+
const committer2 = new PropertyCommitter(element, name.slice(1), strings);
|
|
913
|
+
return committer2.parts;
|
|
914
|
+
}
|
|
915
|
+
if (prefix === "@") {
|
|
916
|
+
return [new EventPart(element, name.slice(1), options.eventContext)];
|
|
917
|
+
}
|
|
918
|
+
if (prefix === "?") {
|
|
919
|
+
return [new BooleanAttributePart(element, name.slice(1), strings)];
|
|
920
|
+
}
|
|
921
|
+
const committer = new AttributeCommitter(element, name, strings);
|
|
922
|
+
return committer.parts;
|
|
923
|
+
}
|
|
924
|
+
handleTextExpression(options) {
|
|
925
|
+
return new NodePart(options);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
const defaultTemplateProcessor = new DefaultTemplateProcessor();
|
|
929
|
+
/**
|
|
930
|
+
* @license
|
|
931
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
932
|
+
* This code may only be used under the BSD style license found at
|
|
933
|
+
* http://polymer.github.io/LICENSE.txt
|
|
934
|
+
* The complete set of authors may be found at
|
|
935
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
936
|
+
* The complete set of contributors may be found at
|
|
937
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
938
|
+
* Code distributed by Google as part of the polymer project is also
|
|
939
|
+
* subject to an additional IP rights grant found at
|
|
940
|
+
* http://polymer.github.io/PATENTS.txt
|
|
941
|
+
*/
|
|
942
|
+
function templateFactory(result) {
|
|
943
|
+
let templateCache = templateCaches.get(result.type);
|
|
944
|
+
if (templateCache === void 0) {
|
|
945
|
+
templateCache = {
|
|
946
|
+
stringsArray: new WeakMap(),
|
|
947
|
+
keyString: new Map()
|
|
948
|
+
};
|
|
949
|
+
templateCaches.set(result.type, templateCache);
|
|
950
|
+
}
|
|
951
|
+
let template = templateCache.stringsArray.get(result.strings);
|
|
952
|
+
if (template !== void 0) {
|
|
953
|
+
return template;
|
|
954
|
+
}
|
|
955
|
+
const key2 = result.strings.join(marker);
|
|
956
|
+
template = templateCache.keyString.get(key2);
|
|
957
|
+
if (template === void 0) {
|
|
958
|
+
template = new Template(result, result.getTemplateElement());
|
|
959
|
+
templateCache.keyString.set(key2, template);
|
|
960
|
+
}
|
|
961
|
+
templateCache.stringsArray.set(result.strings, template);
|
|
962
|
+
return template;
|
|
963
|
+
}
|
|
964
|
+
const templateCaches = new Map();
|
|
965
|
+
/**
|
|
966
|
+
* @license
|
|
967
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
968
|
+
* This code may only be used under the BSD style license found at
|
|
969
|
+
* http://polymer.github.io/LICENSE.txt
|
|
970
|
+
* The complete set of authors may be found at
|
|
971
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
972
|
+
* The complete set of contributors may be found at
|
|
973
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
974
|
+
* Code distributed by Google as part of the polymer project is also
|
|
975
|
+
* subject to an additional IP rights grant found at
|
|
976
|
+
* http://polymer.github.io/PATENTS.txt
|
|
977
|
+
*/
|
|
978
|
+
const parts = new WeakMap();
|
|
979
|
+
const render = (result, container, options) => {
|
|
980
|
+
let part2 = parts.get(container);
|
|
981
|
+
if (part2 === void 0) {
|
|
982
|
+
removeNodes(container, container.firstChild);
|
|
983
|
+
parts.set(container, part2 = new NodePart(Object.assign({ templateFactory }, options)));
|
|
984
|
+
part2.appendInto(container);
|
|
985
|
+
}
|
|
986
|
+
part2.setValue(result);
|
|
987
|
+
part2.commit();
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* @license
|
|
991
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
992
|
+
* This code may only be used under the BSD style license found at
|
|
993
|
+
* http://polymer.github.io/LICENSE.txt
|
|
994
|
+
* The complete set of authors may be found at
|
|
995
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
996
|
+
* The complete set of contributors may be found at
|
|
997
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
998
|
+
* Code distributed by Google as part of the polymer project is also
|
|
999
|
+
* subject to an additional IP rights grant found at
|
|
1000
|
+
* http://polymer.github.io/PATENTS.txt
|
|
1001
|
+
*/
|
|
1002
|
+
if (typeof window !== "undefined") {
|
|
1003
|
+
(window["litHtmlVersions"] || (window["litHtmlVersions"] = [])).push("1.4.1");
|
|
1004
|
+
}
|
|
1005
|
+
const html = (strings, ...values) => new TemplateResult(strings, values, "html", defaultTemplateProcessor);
|
|
1006
|
+
const svg = (strings, ...values) => new SVGTemplateResult(strings, values, "svg", defaultTemplateProcessor);
|
|
1007
|
+
const microtaskSet = new Set();
|
|
1008
|
+
function addMicrotask(func) {
|
|
1009
|
+
if (typeof func !== "function")
|
|
1010
|
+
return;
|
|
1011
|
+
if (!microtaskSet.size) {
|
|
1012
|
+
globalThis.queueMicrotask(() => {
|
|
1013
|
+
microtaskSet.forEach((func2) => func2());
|
|
1014
|
+
microtaskSet.clear();
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
microtaskSet.delete(func);
|
|
1018
|
+
microtaskSet.add(func);
|
|
1019
|
+
}
|
|
1020
|
+
const microtaskStack = [];
|
|
1021
|
+
function execMicrotaskStack() {
|
|
1022
|
+
for (let i = microtaskStack.length - 1; i >= 0; i--) {
|
|
1023
|
+
microtaskStack[i]();
|
|
1024
|
+
}
|
|
1025
|
+
microtaskStack.length = 0;
|
|
1026
|
+
}
|
|
1027
|
+
function addMicrotaskToStack(func) {
|
|
1028
|
+
if (!microtaskStack.length) {
|
|
1029
|
+
addMicrotask(execMicrotaskStack);
|
|
1030
|
+
}
|
|
1031
|
+
microtaskStack.push(func);
|
|
1032
|
+
}
|
|
1033
|
+
function absoluteLocation(currentPath = "", relativePath = "") {
|
|
1034
|
+
const { pathname, search, hash } = new URL(relativePath, location.origin + currentPath);
|
|
1035
|
+
return pathname + search + hash;
|
|
1036
|
+
}
|
|
1037
|
+
class LinkedList extends (globalThis.EventTarget || Object) {
|
|
1038
|
+
constructor() {
|
|
1039
|
+
super(...arguments);
|
|
1040
|
+
__privateAdd(this, _delete);
|
|
1041
|
+
__privateAdd(this, _map, void 0);
|
|
1042
|
+
__privateAdd(this, _firstItem, void 0);
|
|
1043
|
+
__privateAdd(this, _lastItem, void 0);
|
|
1044
|
+
__privateSet(this, _map, new Map());
|
|
1045
|
+
}
|
|
1046
|
+
get size() {
|
|
1047
|
+
return __privateGet(this, _map).size;
|
|
1048
|
+
}
|
|
1049
|
+
add(value) {
|
|
1050
|
+
if (!__privateGet(this, _lastItem)) {
|
|
1051
|
+
this.dispatchEvent(new CustomEvent("start"));
|
|
1052
|
+
}
|
|
1053
|
+
const item = __privateMethod(this, _delete, delete_fn).call(this, value) || { value };
|
|
1054
|
+
item.prev = __privateGet(this, _lastItem);
|
|
1055
|
+
if (item.prev) {
|
|
1056
|
+
item.prev.next = item;
|
|
1057
|
+
}
|
|
1058
|
+
item.next = void 0;
|
|
1059
|
+
__privateSet(this, _lastItem, item);
|
|
1060
|
+
if (!__privateGet(this, _firstItem)) {
|
|
1061
|
+
__privateSet(this, _firstItem, item);
|
|
1062
|
+
}
|
|
1063
|
+
__privateGet(this, _map).set(value, item);
|
|
1064
|
+
}
|
|
1065
|
+
delete(value) {
|
|
1066
|
+
const deleteItem = __privateMethod(this, _delete, delete_fn).call(this, value);
|
|
1067
|
+
if (!__privateGet(this, _firstItem)) {
|
|
1068
|
+
this.dispatchEvent(new CustomEvent("end"));
|
|
1069
|
+
}
|
|
1070
|
+
return deleteItem;
|
|
1071
|
+
}
|
|
1072
|
+
get() {
|
|
1073
|
+
const firstItem = __privateGet(this, _firstItem);
|
|
1074
|
+
if (!firstItem)
|
|
1075
|
+
return;
|
|
1076
|
+
__privateMethod(this, _delete, delete_fn).call(this, firstItem.value);
|
|
1077
|
+
return firstItem.value;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
_map = new WeakMap();
|
|
1081
|
+
_firstItem = new WeakMap();
|
|
1082
|
+
_lastItem = new WeakMap();
|
|
1083
|
+
_delete = new WeakSet();
|
|
1084
|
+
delete_fn = function(value) {
|
|
1085
|
+
const existItem = __privateGet(this, _map).get(value);
|
|
1086
|
+
if (existItem) {
|
|
1087
|
+
if (existItem.prev) {
|
|
1088
|
+
existItem.prev.next = existItem.next;
|
|
1089
|
+
} else {
|
|
1090
|
+
__privateSet(this, _firstItem, existItem.next);
|
|
1091
|
+
}
|
|
1092
|
+
if (existItem.next) {
|
|
1093
|
+
existItem.next.prev = existItem.prev;
|
|
1094
|
+
} else {
|
|
1095
|
+
__privateSet(this, _lastItem, existItem.prev);
|
|
1096
|
+
}
|
|
1097
|
+
__privateGet(this, _map).delete(value);
|
|
1098
|
+
}
|
|
1099
|
+
return existItem;
|
|
1100
|
+
};
|
|
1101
|
+
class PropProxyMap extends WeakMap {
|
|
1102
|
+
get(ele) {
|
|
1103
|
+
let proxy = super.get(ele);
|
|
1104
|
+
if (!proxy) {
|
|
1105
|
+
proxy = {};
|
|
1106
|
+
this.set(ele, proxy);
|
|
1107
|
+
}
|
|
1108
|
+
return proxy;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
class QueryString extends URLSearchParams {
|
|
1112
|
+
constructor(param) {
|
|
1113
|
+
super(param);
|
|
1114
|
+
__privateAdd(this, _stringify, (value) => typeof value === "string" ? value : JSON.stringify(value));
|
|
1115
|
+
__privateAdd(this, _parse, (value) => {
|
|
1116
|
+
if (!value)
|
|
1117
|
+
return null;
|
|
1118
|
+
try {
|
|
1119
|
+
return JSON.parse(value);
|
|
1120
|
+
} catch {
|
|
1121
|
+
return null;
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
concat(param) {
|
|
1126
|
+
let query;
|
|
1127
|
+
if (typeof param === "string") {
|
|
1128
|
+
query = Object.fromEntries(new URLSearchParams(param).entries());
|
|
1129
|
+
} else {
|
|
1130
|
+
query = param;
|
|
1131
|
+
}
|
|
1132
|
+
Object.entries(query).forEach(([key2, value]) => {
|
|
1133
|
+
this.append(key2, __privateGet(this, _stringify).call(this, value));
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
setAny(key2, value) {
|
|
1137
|
+
if (Array.isArray(value)) {
|
|
1138
|
+
this.delete(key2);
|
|
1139
|
+
value.forEach((e) => this.append(key2, __privateGet(this, _stringify).call(this, e)));
|
|
1140
|
+
} else {
|
|
1141
|
+
const v = __privateGet(this, _stringify).call(this, value);
|
|
1142
|
+
v ? this.set(key2, v) : this.delete(key2);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
getAny(key2) {
|
|
1146
|
+
return this.getAnyAll(key2)[0];
|
|
1147
|
+
}
|
|
1148
|
+
getAnyAll(key2) {
|
|
1149
|
+
return this.getAll(key2).filter((e) => e !== "").map((e) => __privateGet(this, _parse).call(this, e));
|
|
1150
|
+
}
|
|
1151
|
+
toString() {
|
|
1152
|
+
const string = super.toString();
|
|
1153
|
+
return string ? `?${string}` : "";
|
|
1154
|
+
}
|
|
1155
|
+
toJSON() {
|
|
1156
|
+
return this.toString();
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
_stringify = new WeakMap();
|
|
1160
|
+
_parse = new WeakMap();
|
|
1161
|
+
function raw(arr, ...args) {
|
|
1162
|
+
return arr.reduce((prev, current, index) => {
|
|
1163
|
+
var _a2;
|
|
1164
|
+
return prev + ((_a2 = args[index - 1]) != null ? _a2 : "") + current;
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
function css(arr, ...args) {
|
|
1168
|
+
return raw(arr, ...args);
|
|
1169
|
+
}
|
|
1170
|
+
const SheetToken = Symbol.for("gem@sheetToken");
|
|
1171
|
+
let useNativeCSSStyleSheet = true;
|
|
1172
|
+
let CSSStyleSheet = window.CSSStyleSheet;
|
|
1173
|
+
try {
|
|
1174
|
+
new CSSStyleSheet();
|
|
1175
|
+
} catch {
|
|
1176
|
+
useNativeCSSStyleSheet = false;
|
|
1177
|
+
CSSStyleSheet = class {
|
|
1178
|
+
constructor() {
|
|
1179
|
+
this.media = { mediaText: "" };
|
|
1180
|
+
this.style = "";
|
|
1181
|
+
this.replaceSync = (style) => this.style = style;
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
function createCSSSheet(rules, mediaQuery2 = "") {
|
|
1186
|
+
const styleSheet = new CSSStyleSheet();
|
|
1187
|
+
const sheet = {};
|
|
1188
|
+
styleSheet.media.mediaText = mediaQuery2;
|
|
1189
|
+
let style = "";
|
|
1190
|
+
if (typeof rules === "string") {
|
|
1191
|
+
style = rules;
|
|
1192
|
+
} else {
|
|
1193
|
+
Object.keys(rules).forEach((key2) => {
|
|
1194
|
+
sheet[key2] = `${key2}-${randomStr()}`;
|
|
1195
|
+
style += rules[key2].styledContent.replace(/&/g, sheet[key2]);
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
styleSheet.replaceSync(style);
|
|
1199
|
+
sheet[SheetToken] = styleSheet;
|
|
1200
|
+
return sheet;
|
|
1201
|
+
}
|
|
1202
|
+
function randomStr(number = 5, origin = "0123456789abcdefghijklmnopqrstuvwxyz") {
|
|
1203
|
+
const len = origin.length;
|
|
1204
|
+
let str = "";
|
|
1205
|
+
for (let i = 0; i < number; i++) {
|
|
1206
|
+
str += origin[Math.floor(Math.random() * len)];
|
|
1207
|
+
}
|
|
1208
|
+
return str;
|
|
1209
|
+
}
|
|
1210
|
+
const nestingRuleRegExp = new RegExp("&.*{((.|\n)*)}", "g");
|
|
1211
|
+
function flatStyled(style, type) {
|
|
1212
|
+
const nestingRules = [];
|
|
1213
|
+
let styledContent = `& {${style.replace(nestingRuleRegExp, (substr) => {
|
|
1214
|
+
nestingRules.push(substr);
|
|
1215
|
+
return "";
|
|
1216
|
+
})}}` + nestingRules.join("");
|
|
1217
|
+
styledContent = styledContent.replace(/&/g, type === "class" ? ".&" : "#&");
|
|
1218
|
+
return { styledContent, type };
|
|
1219
|
+
}
|
|
1220
|
+
const styled = {
|
|
1221
|
+
class: (arr, ...args) => {
|
|
1222
|
+
const style = raw(arr, ...args);
|
|
1223
|
+
return flatStyled(style, "class");
|
|
1224
|
+
},
|
|
1225
|
+
id: (arr, ...args) => {
|
|
1226
|
+
const style = raw(arr, ...args);
|
|
1227
|
+
return flatStyled(style, "id");
|
|
1228
|
+
},
|
|
1229
|
+
keyframes: (arr, ...args) => {
|
|
1230
|
+
const keyframesContent = raw(arr, ...args);
|
|
1231
|
+
const styledContent = `@keyframes & {${keyframesContent}}`;
|
|
1232
|
+
return { styledContent, type: "keyframes" };
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
function camelToKebabCase(str) {
|
|
1236
|
+
return str.replace(/[A-Z]/g, ($1) => "-" + $1.toLowerCase());
|
|
1237
|
+
}
|
|
1238
|
+
function kebabToCamelCase(str) {
|
|
1239
|
+
return str.replace(/-(.)/g, (_substr, $1) => $1.toUpperCase());
|
|
1240
|
+
}
|
|
1241
|
+
function cleanObject(o) {
|
|
1242
|
+
Object.keys(o).forEach((key2) => {
|
|
1243
|
+
const k = key2;
|
|
1244
|
+
delete o[k];
|
|
1245
|
+
});
|
|
1246
|
+
return o;
|
|
1247
|
+
}
|
|
1248
|
+
class GemError extends Error {
|
|
1249
|
+
constructor(msg) {
|
|
1250
|
+
super(msg);
|
|
1251
|
+
this.message = `gem: ${this.message}`;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
function isArrayChange(newValues, oldValues) {
|
|
1255
|
+
const length = newValues.length;
|
|
1256
|
+
if (oldValues.length !== length)
|
|
1257
|
+
return true;
|
|
1258
|
+
for (let i = 0; i < length; i++) {
|
|
1259
|
+
if (newValues[i] !== oldValues[i])
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
function removeItems(target, items) {
|
|
1265
|
+
const set = new Set(items);
|
|
1266
|
+
return target.filter((e) => {
|
|
1267
|
+
if (set.has(e)) {
|
|
1268
|
+
set.delete(e);
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
return true;
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
function styleMap(object) {
|
|
1275
|
+
let styleString = "";
|
|
1276
|
+
for (const key2 in object) {
|
|
1277
|
+
if (object[key2] !== void 0) {
|
|
1278
|
+
styleString += `${camelToKebabCase(key2)}:${object[key2]};`;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
return styleString;
|
|
1282
|
+
}
|
|
1283
|
+
function classMap(obj) {
|
|
1284
|
+
let classList = " ";
|
|
1285
|
+
for (const className in obj) {
|
|
1286
|
+
if (obj[className]) {
|
|
1287
|
+
classList += `${className} `;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
return classList;
|
|
1291
|
+
}
|
|
1292
|
+
const partMap = classMap;
|
|
1293
|
+
const StoreListenerMap = new WeakMap();
|
|
1294
|
+
function createStore(originStore) {
|
|
1295
|
+
if (StoreListenerMap.has(originStore)) {
|
|
1296
|
+
throw new GemError("argument error");
|
|
1297
|
+
}
|
|
1298
|
+
StoreListenerMap.set(originStore, new Set());
|
|
1299
|
+
return originStore;
|
|
1300
|
+
}
|
|
1301
|
+
function createStoreSet(originStoreSet) {
|
|
1302
|
+
const keys = Object.keys(originStoreSet);
|
|
1303
|
+
keys.forEach((key2) => {
|
|
1304
|
+
createStore(originStoreSet[key2]);
|
|
1305
|
+
});
|
|
1306
|
+
return originStoreSet;
|
|
1307
|
+
}
|
|
1308
|
+
function updateStore(store2, value) {
|
|
1309
|
+
Object.assign(store2, value);
|
|
1310
|
+
const listeners = StoreListenerMap.get(store2);
|
|
1311
|
+
listeners == null ? void 0 : listeners.forEach((func) => {
|
|
1312
|
+
addMicrotask(func);
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
function connect(store2, func) {
|
|
1316
|
+
const listeners = StoreListenerMap.get(store2);
|
|
1317
|
+
listeners == null ? void 0 : listeners.add(func);
|
|
1318
|
+
}
|
|
1319
|
+
function disconnect(store2, func) {
|
|
1320
|
+
const listeners = StoreListenerMap.get(store2);
|
|
1321
|
+
listeners == null ? void 0 : listeners.delete(func);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* @license
|
|
1325
|
+
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
1326
|
+
* This code may only be used under the BSD style license found at
|
|
1327
|
+
* http://polymer.github.io/LICENSE.txt
|
|
1328
|
+
* The complete set of authors may be found at
|
|
1329
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
1330
|
+
* The complete set of contributors may be found at
|
|
1331
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
1332
|
+
* Code distributed by Google as part of the polymer project is also
|
|
1333
|
+
* subject to an additional IP rights grant found at
|
|
1334
|
+
* http://polymer.github.io/PATENTS.txt
|
|
1335
|
+
*/
|
|
1336
|
+
const createAndInsertPart = (containerPart, beforePart) => {
|
|
1337
|
+
const container = containerPart.startNode.parentNode;
|
|
1338
|
+
const beforeNode = beforePart === void 0 ? containerPart.endNode : beforePart.startNode;
|
|
1339
|
+
const startNode = container.insertBefore(createMarker(), beforeNode);
|
|
1340
|
+
container.insertBefore(createMarker(), beforeNode);
|
|
1341
|
+
const newPart = new NodePart(containerPart.options);
|
|
1342
|
+
newPart.insertAfterNode(startNode);
|
|
1343
|
+
return newPart;
|
|
1344
|
+
};
|
|
1345
|
+
const updatePart = (part2, value) => {
|
|
1346
|
+
part2.setValue(value);
|
|
1347
|
+
part2.commit();
|
|
1348
|
+
return part2;
|
|
1349
|
+
};
|
|
1350
|
+
const insertPartBefore = (containerPart, part2, ref) => {
|
|
1351
|
+
const container = containerPart.startNode.parentNode;
|
|
1352
|
+
const beforeNode = ref ? ref.startNode : containerPart.endNode;
|
|
1353
|
+
const endNode = part2.endNode.nextSibling;
|
|
1354
|
+
if (endNode !== beforeNode) {
|
|
1355
|
+
reparentNodes(container, part2.startNode, endNode, beforeNode);
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
const removePart = (part2) => {
|
|
1359
|
+
removeNodes(part2.startNode.parentNode, part2.startNode, part2.endNode.nextSibling);
|
|
1360
|
+
};
|
|
1361
|
+
const generateMap = (list, start, end) => {
|
|
1362
|
+
const map = new Map();
|
|
1363
|
+
for (let i = start; i <= end; i++) {
|
|
1364
|
+
map.set(list[i], i);
|
|
1365
|
+
}
|
|
1366
|
+
return map;
|
|
1367
|
+
};
|
|
1368
|
+
const partListCache = new WeakMap();
|
|
1369
|
+
const keyListCache = new WeakMap();
|
|
1370
|
+
const repeat = directive((items, keyFnOrTemplate, template) => {
|
|
1371
|
+
let keyFn;
|
|
1372
|
+
if (template === void 0) {
|
|
1373
|
+
template = keyFnOrTemplate;
|
|
1374
|
+
} else if (keyFnOrTemplate !== void 0) {
|
|
1375
|
+
keyFn = keyFnOrTemplate;
|
|
1376
|
+
}
|
|
1377
|
+
return (containerPart) => {
|
|
1378
|
+
if (!(containerPart instanceof NodePart)) {
|
|
1379
|
+
throw new Error("repeat can only be used in text bindings");
|
|
1380
|
+
}
|
|
1381
|
+
const oldParts = partListCache.get(containerPart) || [];
|
|
1382
|
+
const oldKeys = keyListCache.get(containerPart) || [];
|
|
1383
|
+
const newParts = [];
|
|
1384
|
+
const newValues = [];
|
|
1385
|
+
const newKeys = [];
|
|
1386
|
+
let index = 0;
|
|
1387
|
+
for (const item of items) {
|
|
1388
|
+
newKeys[index] = keyFn ? keyFn(item, index) : index;
|
|
1389
|
+
newValues[index] = template(item, index);
|
|
1390
|
+
index++;
|
|
1391
|
+
}
|
|
1392
|
+
let newKeyToIndexMap;
|
|
1393
|
+
let oldKeyToIndexMap;
|
|
1394
|
+
let oldHead = 0;
|
|
1395
|
+
let oldTail = oldParts.length - 1;
|
|
1396
|
+
let newHead = 0;
|
|
1397
|
+
let newTail = newValues.length - 1;
|
|
1398
|
+
while (oldHead <= oldTail && newHead <= newTail) {
|
|
1399
|
+
if (oldParts[oldHead] === null) {
|
|
1400
|
+
oldHead++;
|
|
1401
|
+
} else if (oldParts[oldTail] === null) {
|
|
1402
|
+
oldTail--;
|
|
1403
|
+
} else if (oldKeys[oldHead] === newKeys[newHead]) {
|
|
1404
|
+
newParts[newHead] = updatePart(oldParts[oldHead], newValues[newHead]);
|
|
1405
|
+
oldHead++;
|
|
1406
|
+
newHead++;
|
|
1407
|
+
} else if (oldKeys[oldTail] === newKeys[newTail]) {
|
|
1408
|
+
newParts[newTail] = updatePart(oldParts[oldTail], newValues[newTail]);
|
|
1409
|
+
oldTail--;
|
|
1410
|
+
newTail--;
|
|
1411
|
+
} else if (oldKeys[oldHead] === newKeys[newTail]) {
|
|
1412
|
+
newParts[newTail] = updatePart(oldParts[oldHead], newValues[newTail]);
|
|
1413
|
+
insertPartBefore(containerPart, oldParts[oldHead], newParts[newTail + 1]);
|
|
1414
|
+
oldHead++;
|
|
1415
|
+
newTail--;
|
|
1416
|
+
} else if (oldKeys[oldTail] === newKeys[newHead]) {
|
|
1417
|
+
newParts[newHead] = updatePart(oldParts[oldTail], newValues[newHead]);
|
|
1418
|
+
insertPartBefore(containerPart, oldParts[oldTail], oldParts[oldHead]);
|
|
1419
|
+
oldTail--;
|
|
1420
|
+
newHead++;
|
|
1421
|
+
} else {
|
|
1422
|
+
if (newKeyToIndexMap === void 0) {
|
|
1423
|
+
newKeyToIndexMap = generateMap(newKeys, newHead, newTail);
|
|
1424
|
+
oldKeyToIndexMap = generateMap(oldKeys, oldHead, oldTail);
|
|
1425
|
+
}
|
|
1426
|
+
if (!newKeyToIndexMap.has(oldKeys[oldHead])) {
|
|
1427
|
+
removePart(oldParts[oldHead]);
|
|
1428
|
+
oldHead++;
|
|
1429
|
+
} else if (!newKeyToIndexMap.has(oldKeys[oldTail])) {
|
|
1430
|
+
removePart(oldParts[oldTail]);
|
|
1431
|
+
oldTail--;
|
|
1432
|
+
} else {
|
|
1433
|
+
const oldIndex = oldKeyToIndexMap.get(newKeys[newHead]);
|
|
1434
|
+
const oldPart = oldIndex !== void 0 ? oldParts[oldIndex] : null;
|
|
1435
|
+
if (oldPart === null) {
|
|
1436
|
+
const newPart = createAndInsertPart(containerPart, oldParts[oldHead]);
|
|
1437
|
+
updatePart(newPart, newValues[newHead]);
|
|
1438
|
+
newParts[newHead] = newPart;
|
|
1439
|
+
} else {
|
|
1440
|
+
newParts[newHead] = updatePart(oldPart, newValues[newHead]);
|
|
1441
|
+
insertPartBefore(containerPart, oldPart, oldParts[oldHead]);
|
|
1442
|
+
oldParts[oldIndex] = null;
|
|
1443
|
+
}
|
|
1444
|
+
newHead++;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
while (newHead <= newTail) {
|
|
1449
|
+
const newPart = createAndInsertPart(containerPart, newParts[newTail + 1]);
|
|
1450
|
+
updatePart(newPart, newValues[newHead]);
|
|
1451
|
+
newParts[newHead++] = newPart;
|
|
1452
|
+
}
|
|
1453
|
+
while (oldHead <= oldTail) {
|
|
1454
|
+
const oldPart = oldParts[oldHead++];
|
|
1455
|
+
if (oldPart !== null) {
|
|
1456
|
+
removePart(oldPart);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
partListCache.set(containerPart, newParts);
|
|
1460
|
+
keyListCache.set(containerPart, newKeys);
|
|
1461
|
+
};
|
|
1462
|
+
});
|
|
1463
|
+
/**
|
|
1464
|
+
* @license
|
|
1465
|
+
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
|
|
1466
|
+
* This code may only be used under the BSD style license found at
|
|
1467
|
+
* http://polymer.github.io/LICENSE.txt
|
|
1468
|
+
* The complete set of authors may be found at
|
|
1469
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
1470
|
+
* The complete set of contributors may be found at
|
|
1471
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
1472
|
+
* Code distributed by Google as part of the polymer project is also
|
|
1473
|
+
* subject to an additional IP rights grant found at
|
|
1474
|
+
* http://polymer.github.io/PATENTS.txt
|
|
1475
|
+
*/
|
|
1476
|
+
const previousValues$1 = new WeakMap();
|
|
1477
|
+
const guard = directive((value, f) => (part2) => {
|
|
1478
|
+
const previousValue = previousValues$1.get(part2);
|
|
1479
|
+
if (Array.isArray(value)) {
|
|
1480
|
+
if (Array.isArray(previousValue) && previousValue.length === value.length && value.every((v, i) => v === previousValue[i])) {
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
} else if (previousValue === value && (value !== void 0 || previousValues$1.has(part2))) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
part2.setValue(f());
|
|
1487
|
+
previousValues$1.set(part2, Array.isArray(value) ? Array.from(value) : value);
|
|
1488
|
+
});
|
|
1489
|
+
/**
|
|
1490
|
+
* @license
|
|
1491
|
+
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
|
|
1492
|
+
* This code may only be used under the BSD style license found at
|
|
1493
|
+
* http://polymer.github.io/LICENSE.txt
|
|
1494
|
+
* The complete set of authors may be found at
|
|
1495
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
1496
|
+
* The complete set of contributors may be found at
|
|
1497
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
1498
|
+
* Code distributed by Google as part of the polymer project is also
|
|
1499
|
+
* subject to an additional IP rights grant found at
|
|
1500
|
+
* http://polymer.github.io/PATENTS.txt
|
|
1501
|
+
*/
|
|
1502
|
+
const previousValues = new WeakMap();
|
|
1503
|
+
const ifDefined = directive((value) => (part2) => {
|
|
1504
|
+
const previousValue = previousValues.get(part2);
|
|
1505
|
+
if (value === void 0 && part2 instanceof AttributePart) {
|
|
1506
|
+
if (previousValue !== void 0 || !previousValues.has(part2)) {
|
|
1507
|
+
const name = part2.committer.name;
|
|
1508
|
+
part2.committer.element.removeAttribute(name);
|
|
1509
|
+
}
|
|
1510
|
+
} else if (value !== previousValue) {
|
|
1511
|
+
part2.setValue(value);
|
|
1512
|
+
}
|
|
1513
|
+
previousValues.set(part2, value);
|
|
1514
|
+
});
|
|
1515
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
1516
|
+
if (!member.has(obj))
|
|
1517
|
+
throw TypeError("Cannot " + msg);
|
|
1518
|
+
};
|
|
1519
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
1520
|
+
__accessCheck$1(obj, member, "read from private field");
|
|
1521
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
1522
|
+
};
|
|
1523
|
+
var __privateAdd$1 = (obj, member, value) => {
|
|
1524
|
+
if (member.has(obj))
|
|
1525
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1526
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1527
|
+
};
|
|
1528
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
1529
|
+
__accessCheck$1(obj, member, "write to private field");
|
|
1530
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1531
|
+
return value;
|
|
1532
|
+
};
|
|
1533
|
+
var _renderRoot, _internals, _isAppendReason, _isAsync, _effectList, _momeList, _unmountCallback, _exec, _execEffect, _execMemo, _initEffect, _render, _shouldUpdate, _updateCallback, _update, _updated, _connectedCallback;
|
|
1534
|
+
function emptyFunction() {
|
|
1535
|
+
}
|
|
1536
|
+
function execCallback(fun) {
|
|
1537
|
+
typeof fun === "function" && fun();
|
|
1538
|
+
}
|
|
1539
|
+
const asyncRenderTaskList = new LinkedList();
|
|
1540
|
+
const tick = (timeStamp = performance.now()) => {
|
|
1541
|
+
if (performance.now() > timeStamp + 16)
|
|
1542
|
+
return requestAnimationFrame(tick);
|
|
1543
|
+
const task = asyncRenderTaskList.get();
|
|
1544
|
+
if (task) {
|
|
1545
|
+
task();
|
|
1546
|
+
tick(timeStamp);
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
asyncRenderTaskList.addEventListener("start", () => addMicrotask(tick));
|
|
1550
|
+
const initSymbol = Symbol("init");
|
|
1551
|
+
const updateSymbol = Symbol("update");
|
|
1552
|
+
class GemElement extends HTMLElement {
|
|
1553
|
+
constructor({ isAsync, isLight, delegatesFocus } = {}) {
|
|
1554
|
+
super();
|
|
1555
|
+
__privateAdd$1(this, _renderRoot, void 0);
|
|
1556
|
+
__privateAdd$1(this, _internals, void 0);
|
|
1557
|
+
__privateAdd$1(this, _isAppendReason, void 0);
|
|
1558
|
+
__privateAdd$1(this, _isAsync, void 0);
|
|
1559
|
+
__privateAdd$1(this, _effectList, void 0);
|
|
1560
|
+
__privateAdd$1(this, _momeList, void 0);
|
|
1561
|
+
__privateAdd$1(this, _unmountCallback, void 0);
|
|
1562
|
+
this.setState = (payload) => {
|
|
1563
|
+
if (!this.state)
|
|
1564
|
+
throw new GemError("`state` not initialized");
|
|
1565
|
+
Object.assign(this.state, payload);
|
|
1566
|
+
addMicrotask(__privateGet$1(this, _update));
|
|
1567
|
+
};
|
|
1568
|
+
__privateAdd$1(this, _exec, (list) => {
|
|
1569
|
+
list == null ? void 0 : list.forEach((effectItem) => {
|
|
1570
|
+
const { callback, getDep, values, preCallback } = effectItem;
|
|
1571
|
+
const newValues = getDep == null ? void 0 : getDep();
|
|
1572
|
+
if (!getDep || !values || isArrayChange(values, newValues)) {
|
|
1573
|
+
execCallback(preCallback);
|
|
1574
|
+
effectItem.preCallback = callback(newValues, values);
|
|
1575
|
+
effectItem.values = newValues;
|
|
1576
|
+
}
|
|
1577
|
+
});
|
|
1578
|
+
});
|
|
1579
|
+
__privateAdd$1(this, _execEffect, () => {
|
|
1580
|
+
__privateGet$1(this, _exec).call(this, __privateGet$1(this, _effectList));
|
|
1581
|
+
});
|
|
1582
|
+
__privateAdd$1(this, _execMemo, () => {
|
|
1583
|
+
__privateGet$1(this, _exec).call(this, __privateGet$1(this, _momeList));
|
|
1584
|
+
});
|
|
1585
|
+
this.effect = (callback, getDep) => {
|
|
1586
|
+
if (!__privateGet$1(this, _effectList))
|
|
1587
|
+
__privateSet$1(this, _effectList, []);
|
|
1588
|
+
const effectItem = {
|
|
1589
|
+
callback,
|
|
1590
|
+
getDep,
|
|
1591
|
+
values: void 0,
|
|
1592
|
+
initialized: !!this.isConnected
|
|
1593
|
+
};
|
|
1594
|
+
if (this.isConnected) {
|
|
1595
|
+
effectItem.values = getDep == null ? void 0 : getDep();
|
|
1596
|
+
effectItem.preCallback = callback(effectItem.values);
|
|
1597
|
+
}
|
|
1598
|
+
__privateGet$1(this, _effectList).push(effectItem);
|
|
1599
|
+
};
|
|
1600
|
+
this.memo = (callback, getDep) => {
|
|
1601
|
+
if (!__privateGet$1(this, _momeList))
|
|
1602
|
+
__privateSet$1(this, _momeList, []);
|
|
1603
|
+
__privateGet$1(this, _momeList).push({
|
|
1604
|
+
callback,
|
|
1605
|
+
getDep,
|
|
1606
|
+
values: [Symbol()],
|
|
1607
|
+
initialized: this.isConnected
|
|
1608
|
+
});
|
|
1609
|
+
};
|
|
1610
|
+
__privateAdd$1(this, _initEffect, () => {
|
|
1611
|
+
var _a2;
|
|
1612
|
+
(_a2 = __privateGet$1(this, _effectList)) == null ? void 0 : _a2.forEach((effectItem) => {
|
|
1613
|
+
const { callback, getDep, initialized } = effectItem;
|
|
1614
|
+
if (!initialized) {
|
|
1615
|
+
effectItem.values = getDep == null ? void 0 : getDep();
|
|
1616
|
+
effectItem.preCallback = callback(effectItem.values);
|
|
1617
|
+
effectItem.initialized = true;
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
});
|
|
1621
|
+
__privateAdd$1(this, _render, () => {
|
|
1622
|
+
var _a2, _b;
|
|
1623
|
+
__privateGet$1(this, _execMemo).call(this);
|
|
1624
|
+
const styles = useNativeCSSStyleSheet ? "" : html`${(_b = (_a2 = this.shadowRoot) == null ? void 0 : _a2.adoptedStyleSheets) == null ? void 0 : _b.map((e) => html`
|
|
1625
|
+
<style media=${e.media.mediaText}>
|
|
1626
|
+
${e.style}
|
|
1627
|
+
</style>
|
|
1628
|
+
`)}`;
|
|
1629
|
+
if (this.render)
|
|
1630
|
+
return html`${this.render()}${styles}`;
|
|
1631
|
+
return __privateGet$1(this, _renderRoot) === this ? void 0 : html`<slot></slot>${styles}`;
|
|
1632
|
+
});
|
|
1633
|
+
__privateAdd$1(this, _shouldUpdate, () => {
|
|
1634
|
+
return this.shouldUpdate ? this.shouldUpdate() : true;
|
|
1635
|
+
});
|
|
1636
|
+
__privateAdd$1(this, _updateCallback, () => {
|
|
1637
|
+
if (this.isConnected && __privateGet$1(this, _shouldUpdate).call(this)) {
|
|
1638
|
+
const temp = __privateGet$1(this, _render).call(this);
|
|
1639
|
+
temp !== void 0 && render(temp, __privateGet$1(this, _renderRoot));
|
|
1640
|
+
addMicrotask(__privateGet$1(this, _updated));
|
|
1641
|
+
addMicrotask(__privateGet$1(this, _execEffect));
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
__privateAdd$1(this, _update, () => {
|
|
1645
|
+
if (__privateGet$1(this, _isAsync)) {
|
|
1646
|
+
asyncRenderTaskList.add(__privateGet$1(this, _updateCallback));
|
|
1647
|
+
} else {
|
|
1648
|
+
__privateGet$1(this, _updateCallback).call(this);
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
this.update = () => {
|
|
1652
|
+
addMicrotask(__privateGet$1(this, _update));
|
|
1653
|
+
};
|
|
1654
|
+
__privateAdd$1(this, _updated, () => {
|
|
1655
|
+
var _a2;
|
|
1656
|
+
(_a2 = this.updated) == null ? void 0 : _a2.call(this);
|
|
1657
|
+
});
|
|
1658
|
+
__privateAdd$1(this, _connectedCallback, () => {
|
|
1659
|
+
var _a2, _b, _c;
|
|
1660
|
+
if (__privateGet$1(this, _isAppendReason)) {
|
|
1661
|
+
__privateSet$1(this, _isAppendReason, false);
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
(_a2 = this.willMount) == null ? void 0 : _a2.call(this);
|
|
1665
|
+
const { observedStores, rootElement: rootElement2 } = this.constructor;
|
|
1666
|
+
observedStores == null ? void 0 : observedStores.forEach((store2) => {
|
|
1667
|
+
connect(store2, __privateGet$1(this, _update));
|
|
1668
|
+
});
|
|
1669
|
+
const temp = __privateGet$1(this, _render).call(this);
|
|
1670
|
+
temp !== void 0 && render(temp, __privateGet$1(this, _renderRoot));
|
|
1671
|
+
__privateSet$1(this, _unmountCallback, (_b = this.mounted) == null ? void 0 : _b.call(this));
|
|
1672
|
+
__privateGet$1(this, _initEffect).call(this);
|
|
1673
|
+
if (rootElement2 && ((_c = this.getRootNode().host) == null ? void 0 : _c.tagName) !== rootElement2.toUpperCase()) {
|
|
1674
|
+
throw new GemError(`not allow current root type`);
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
addMicrotask(() => this[initSymbol] = false);
|
|
1678
|
+
this[initSymbol] = true;
|
|
1679
|
+
this[updateSymbol] = () => {
|
|
1680
|
+
if (this.isConnected) {
|
|
1681
|
+
addMicrotask(__privateGet$1(this, _update));
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
__privateSet$1(this, _isAsync, isAsync);
|
|
1685
|
+
__privateSet$1(this, _renderRoot, isLight ? this : this.attachShadow({ mode: "open", delegatesFocus }));
|
|
1686
|
+
const { adoptedStyleSheets } = new.target;
|
|
1687
|
+
if (adoptedStyleSheets) {
|
|
1688
|
+
const sheets = adoptedStyleSheets.map((item) => item[SheetToken] || item);
|
|
1689
|
+
if (this.shadowRoot) {
|
|
1690
|
+
this.shadowRoot.adoptedStyleSheets = sheets;
|
|
1691
|
+
} else {
|
|
1692
|
+
this.effect(() => {
|
|
1693
|
+
const root = this.getRootNode();
|
|
1694
|
+
if (!useNativeCSSStyleSheet) {
|
|
1695
|
+
const ele = root === document ? document.body : root;
|
|
1696
|
+
ele._sheets = ele._sheets || {};
|
|
1697
|
+
sheets.forEach(({ style, media }) => {
|
|
1698
|
+
if (ele._sheets[style]) {
|
|
1699
|
+
ele._sheets[style].count++;
|
|
1700
|
+
} else {
|
|
1701
|
+
const s = document.createElement("style");
|
|
1702
|
+
s.innerHTML = style;
|
|
1703
|
+
s.media = media.mediaText;
|
|
1704
|
+
ele.append(s);
|
|
1705
|
+
ele._sheets[style] = { ele: s, count: 1 };
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
return () => {
|
|
1709
|
+
sheets.forEach(({ style }) => {
|
|
1710
|
+
ele._sheets[style].count--;
|
|
1711
|
+
if (!ele._sheets[style].count) {
|
|
1712
|
+
delete ele._sheets[style];
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
};
|
|
1716
|
+
} else {
|
|
1717
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, ...sheets];
|
|
1718
|
+
return () => {
|
|
1719
|
+
root.adoptedStyleSheets = removeItems(root.adoptedStyleSheets, sheets);
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
}, () => []);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
get internals() {
|
|
1727
|
+
if (!__privateGet$1(this, _internals)) {
|
|
1728
|
+
const getCustomStateSet = () => {
|
|
1729
|
+
const getV = (v) => v.replace(/-/g, "");
|
|
1730
|
+
return {
|
|
1731
|
+
has: (v) => getV(v) in this.dataset,
|
|
1732
|
+
add: (v) => {
|
|
1733
|
+
this.dataset[getV(v)] = "";
|
|
1734
|
+
},
|
|
1735
|
+
delete: (v) => delete this.dataset[getV(v)]
|
|
1736
|
+
};
|
|
1737
|
+
};
|
|
1738
|
+
if (!this.attachInternals) {
|
|
1739
|
+
this.attachInternals = () => {
|
|
1740
|
+
return { states: getCustomStateSet() };
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
__privateSet$1(this, _internals, this.attachInternals());
|
|
1744
|
+
if (!__privateGet$1(this, _internals).states) {
|
|
1745
|
+
__privateGet$1(this, _internals).states = getCustomStateSet();
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
return __privateGet$1(this, _internals);
|
|
1749
|
+
}
|
|
1750
|
+
attributeChangedCallback() {
|
|
1751
|
+
if (this.isConnected) {
|
|
1752
|
+
addMicrotask(__privateGet$1(this, _update));
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
closestElement(constructorOrTag) {
|
|
1756
|
+
const isConstructor = typeof constructorOrTag === "function";
|
|
1757
|
+
const tagName = typeof constructorOrTag === "string" && constructorOrTag.toUpperCase();
|
|
1758
|
+
const getRootElement = (ele) => {
|
|
1759
|
+
const rootEle = ele.parentElement || ele.getRootNode().host;
|
|
1760
|
+
if (!rootEle)
|
|
1761
|
+
return null;
|
|
1762
|
+
if (isConstructor) {
|
|
1763
|
+
if (rootEle.constructor === constructorOrTag) {
|
|
1764
|
+
return rootEle;
|
|
1765
|
+
}
|
|
1766
|
+
} else if (rootEle.tagName === tagName) {
|
|
1767
|
+
return rootEle;
|
|
1768
|
+
}
|
|
1769
|
+
return getRootElement(rootEle);
|
|
1770
|
+
};
|
|
1771
|
+
return getRootElement(this);
|
|
1772
|
+
}
|
|
1773
|
+
connectedCallback() {
|
|
1774
|
+
if (__privateGet$1(this, _isAsync)) {
|
|
1775
|
+
asyncRenderTaskList.add(__privateGet$1(this, _connectedCallback));
|
|
1776
|
+
} else {
|
|
1777
|
+
__privateGet$1(this, _connectedCallback).call(this);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
disconnectedCallback() {
|
|
1781
|
+
var _a2, _b, _c;
|
|
1782
|
+
if (this.isConnected) {
|
|
1783
|
+
__privateSet$1(this, _isAppendReason, true);
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
const { observedStores } = this.constructor;
|
|
1787
|
+
observedStores == null ? void 0 : observedStores.forEach((store2) => {
|
|
1788
|
+
disconnect(store2, __privateGet$1(this, _update));
|
|
1789
|
+
});
|
|
1790
|
+
execCallback(__privateGet$1(this, _unmountCallback));
|
|
1791
|
+
(_a2 = this.unmounted) == null ? void 0 : _a2.call(this);
|
|
1792
|
+
(_b = __privateGet$1(this, _effectList)) == null ? void 0 : _b.forEach((effectItem) => {
|
|
1793
|
+
execCallback(effectItem.preCallback);
|
|
1794
|
+
});
|
|
1795
|
+
__privateSet$1(this, _momeList, (_c = __privateGet$1(this, _momeList)) == null ? void 0 : _c.filter(({ initialized }) => !initialized));
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
_renderRoot = new WeakMap();
|
|
1799
|
+
_internals = new WeakMap();
|
|
1800
|
+
_isAppendReason = new WeakMap();
|
|
1801
|
+
_isAsync = new WeakMap();
|
|
1802
|
+
_effectList = new WeakMap();
|
|
1803
|
+
_momeList = new WeakMap();
|
|
1804
|
+
_unmountCallback = new WeakMap();
|
|
1805
|
+
_exec = new WeakMap();
|
|
1806
|
+
_execEffect = new WeakMap();
|
|
1807
|
+
_execMemo = new WeakMap();
|
|
1808
|
+
_initEffect = new WeakMap();
|
|
1809
|
+
_render = new WeakMap();
|
|
1810
|
+
_shouldUpdate = new WeakMap();
|
|
1811
|
+
_updateCallback = new WeakMap();
|
|
1812
|
+
_update = new WeakMap();
|
|
1813
|
+
_updated = new WeakMap();
|
|
1814
|
+
_connectedCallback = new WeakMap();
|
|
1815
|
+
const gemElementProxyMap = new PropProxyMap();
|
|
1816
|
+
function defineAttribute(target, prop, attr) {
|
|
1817
|
+
const { booleanAttributes, numberAttributes } = target.constructor;
|
|
1818
|
+
Object.defineProperty(target, prop, {
|
|
1819
|
+
configurable: true,
|
|
1820
|
+
get() {
|
|
1821
|
+
if (!(initSymbol in this))
|
|
1822
|
+
return;
|
|
1823
|
+
const that = this;
|
|
1824
|
+
const value = that.getAttribute(attr);
|
|
1825
|
+
if (booleanAttributes == null ? void 0 : booleanAttributes.has(attr)) {
|
|
1826
|
+
return value === null ? false : true;
|
|
1827
|
+
}
|
|
1828
|
+
if (numberAttributes == null ? void 0 : numberAttributes.has(attr)) {
|
|
1829
|
+
return Number(value);
|
|
1830
|
+
}
|
|
1831
|
+
return value || "";
|
|
1832
|
+
},
|
|
1833
|
+
set(v) {
|
|
1834
|
+
const that = this;
|
|
1835
|
+
const proxy = gemElementProxyMap.get(this);
|
|
1836
|
+
const hasSet = proxy[prop];
|
|
1837
|
+
const value = that.getAttribute(attr);
|
|
1838
|
+
if (this[initSymbol] && value !== null && !hasSet)
|
|
1839
|
+
return;
|
|
1840
|
+
proxy[prop] = true;
|
|
1841
|
+
const isBool = booleanAttributes == null ? void 0 : booleanAttributes.has(attr);
|
|
1842
|
+
if (v === null || v === void 0) {
|
|
1843
|
+
that.removeAttribute(attr);
|
|
1844
|
+
} else if (isBool) {
|
|
1845
|
+
that.toggleAttribute(attr, !!v);
|
|
1846
|
+
} else {
|
|
1847
|
+
if (value !== String(v))
|
|
1848
|
+
that.setAttribute(attr, String(v));
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
const isEventHandleSymbol = Symbol("event handle");
|
|
1854
|
+
function defineProperty(target, prop, event, eventOptions) {
|
|
1855
|
+
Object.defineProperty(target, prop, {
|
|
1856
|
+
configurable: true,
|
|
1857
|
+
get() {
|
|
1858
|
+
const value = gemElementProxyMap.get(this)[prop];
|
|
1859
|
+
if (value || !event) {
|
|
1860
|
+
return value;
|
|
1861
|
+
} else {
|
|
1862
|
+
this[prop] = emptyFunction;
|
|
1863
|
+
return this[prop];
|
|
1864
|
+
}
|
|
1865
|
+
},
|
|
1866
|
+
set(v) {
|
|
1867
|
+
const that = this;
|
|
1868
|
+
const proxy = gemElementProxyMap.get(that);
|
|
1869
|
+
if (v !== proxy[prop]) {
|
|
1870
|
+
if (event) {
|
|
1871
|
+
proxy[prop] = (v == null ? void 0 : v[isEventHandleSymbol]) ? v : (detail, options) => {
|
|
1872
|
+
const evt = new CustomEvent(event, __spreadProps(__spreadValues(__spreadValues({}, options), eventOptions), { detail }));
|
|
1873
|
+
that.dispatchEvent(evt);
|
|
1874
|
+
v(detail, options);
|
|
1875
|
+
};
|
|
1876
|
+
proxy[prop][isEventHandleSymbol] = true;
|
|
1877
|
+
} else {
|
|
1878
|
+
proxy[prop] = v;
|
|
1879
|
+
this[updateSymbol]();
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
function defineRef(target, prop, ref) {
|
|
1886
|
+
Object.defineProperty(target, prop, {
|
|
1887
|
+
configurable: true,
|
|
1888
|
+
get() {
|
|
1889
|
+
const proxy = gemElementProxyMap.get(this);
|
|
1890
|
+
let refobject2 = proxy[prop];
|
|
1891
|
+
if (!refobject2) {
|
|
1892
|
+
const that = this;
|
|
1893
|
+
const ele = that.shadowRoot || that;
|
|
1894
|
+
refobject2 = {
|
|
1895
|
+
get ref() {
|
|
1896
|
+
return ref;
|
|
1897
|
+
},
|
|
1898
|
+
get element() {
|
|
1899
|
+
const gemReflects = [...ele.querySelectorAll("gem-reflect")].map((e) => e.target);
|
|
1900
|
+
for (const e of [ele, ...gemReflects]) {
|
|
1901
|
+
const result = e.querySelector(`[ref=${ref}]`);
|
|
1902
|
+
if (result)
|
|
1903
|
+
return result;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
};
|
|
1907
|
+
proxy[prop] = refobject2;
|
|
1908
|
+
}
|
|
1909
|
+
return refobject2;
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
function defineCSSState(target, prop, state2) {
|
|
1914
|
+
Object.defineProperty(target, prop, {
|
|
1915
|
+
configurable: true,
|
|
1916
|
+
get() {
|
|
1917
|
+
var _a2;
|
|
1918
|
+
const that = this;
|
|
1919
|
+
const { states } = that.internals;
|
|
1920
|
+
return (_a2 = states.has) == null ? void 0 : _a2.call(states, state2);
|
|
1921
|
+
},
|
|
1922
|
+
set(v) {
|
|
1923
|
+
const that = this;
|
|
1924
|
+
const { states } = that.internals;
|
|
1925
|
+
if (v) {
|
|
1926
|
+
states.add(state2);
|
|
1927
|
+
} else {
|
|
1928
|
+
states.delete(state2);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
const nativeDefineElement = customElements.define.bind(customElements);
|
|
1934
|
+
customElements.define = (name, cls, options) => {
|
|
1935
|
+
if (cls.prototype instanceof GemElement) {
|
|
1936
|
+
const { observedAttributes, observedPropertys, defineEvents, defineCSSStates, defineRefs } = cls;
|
|
1937
|
+
observedAttributes == null ? void 0 : observedAttributes.forEach((attr) => defineAttribute(cls.prototype, kebabToCamelCase(attr), attr));
|
|
1938
|
+
observedPropertys == null ? void 0 : observedPropertys.forEach((prop) => defineProperty(cls.prototype, prop));
|
|
1939
|
+
defineEvents == null ? void 0 : defineEvents.forEach((event) => defineProperty(cls.prototype, kebabToCamelCase(event), event));
|
|
1940
|
+
defineCSSStates == null ? void 0 : defineCSSStates.forEach((state2) => defineCSSState(cls.prototype, kebabToCamelCase(state2), `--${state2}`));
|
|
1941
|
+
defineRefs == null ? void 0 : defineRefs.forEach((ref) => defineRef(cls.prototype, kebabToCamelCase(ref), ref));
|
|
1942
|
+
}
|
|
1943
|
+
nativeDefineElement(name, cls, options);
|
|
1944
|
+
};
|
|
1945
|
+
function pushStaticField(target, field, member, isSet = false) {
|
|
1946
|
+
const cls = target.constructor;
|
|
1947
|
+
const current = cls[field];
|
|
1948
|
+
if (!cls.hasOwnProperty(field)) {
|
|
1949
|
+
Object.defineProperty(cls, field, {
|
|
1950
|
+
value: isSet ? new Set(current) : current ? Array.from(current) : []
|
|
1951
|
+
});
|
|
1952
|
+
}
|
|
1953
|
+
cls[field][isSet ? "add" : "push"](member);
|
|
1954
|
+
}
|
|
1955
|
+
function refobject(target, prop) {
|
|
1956
|
+
const ref = `${camelToKebabCase(prop)}-${randomStr()}`;
|
|
1957
|
+
pushStaticField(target, "defineRefs", ref);
|
|
1958
|
+
defineRef(target, prop, ref);
|
|
1959
|
+
}
|
|
1960
|
+
function defineAttr(target, prop, attr) {
|
|
1961
|
+
pushStaticField(target, "observedAttributes", attr);
|
|
1962
|
+
defineAttribute(target, prop, attr);
|
|
1963
|
+
}
|
|
1964
|
+
function attribute(target, prop) {
|
|
1965
|
+
defineAttr(target, prop, camelToKebabCase(prop));
|
|
1966
|
+
}
|
|
1967
|
+
function boolattribute(target, prop) {
|
|
1968
|
+
const attr = camelToKebabCase(prop);
|
|
1969
|
+
pushStaticField(target, "booleanAttributes", attr, true);
|
|
1970
|
+
defineAttr(target, prop, attr);
|
|
1971
|
+
}
|
|
1972
|
+
function numattribute(target, prop) {
|
|
1973
|
+
const attr = camelToKebabCase(prop);
|
|
1974
|
+
pushStaticField(target, "numberAttributes", attr, true);
|
|
1975
|
+
defineAttr(target, prop, attr);
|
|
1976
|
+
}
|
|
1977
|
+
function property(target, prop) {
|
|
1978
|
+
pushStaticField(target, "observedPropertys", prop);
|
|
1979
|
+
defineProperty(target, prop);
|
|
1980
|
+
}
|
|
1981
|
+
function state(target, prop) {
|
|
1982
|
+
const attr = camelToKebabCase(prop);
|
|
1983
|
+
pushStaticField(target, "defineCSSStates", attr);
|
|
1984
|
+
defineCSSState(target, prop, `--${attr}`);
|
|
1985
|
+
}
|
|
1986
|
+
function slot(target, prop) {
|
|
1987
|
+
const attr = camelToKebabCase(target[prop] || prop);
|
|
1988
|
+
target[prop] = attr;
|
|
1989
|
+
pushStaticField(target instanceof GemElement ? target : target.prototype, "defineSlots", attr);
|
|
1990
|
+
}
|
|
1991
|
+
function part(target, prop) {
|
|
1992
|
+
const attr = camelToKebabCase(target[prop] || prop);
|
|
1993
|
+
target[prop] = attr;
|
|
1994
|
+
pushStaticField(target instanceof GemElement ? target : target.prototype, "defineParts", attr);
|
|
1995
|
+
}
|
|
1996
|
+
function emitter(target, prop) {
|
|
1997
|
+
defineEmitter(target, prop);
|
|
1998
|
+
}
|
|
1999
|
+
function globalemitter(target, prop) {
|
|
2000
|
+
defineEmitter(target, prop, { bubbles: true, composed: true });
|
|
2001
|
+
}
|
|
2002
|
+
function defineEmitter(target, prop, options) {
|
|
2003
|
+
const event = camelToKebabCase(prop);
|
|
2004
|
+
pushStaticField(target, "defineEvents", event);
|
|
2005
|
+
defineProperty(target, prop, event, options);
|
|
2006
|
+
}
|
|
2007
|
+
function adoptedStyle(style) {
|
|
2008
|
+
return function(cls) {
|
|
2009
|
+
const con = cls;
|
|
2010
|
+
pushStaticField(con.prototype, "adoptedStyleSheets", style);
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
function connectStore(store2) {
|
|
2014
|
+
return function(cls) {
|
|
2015
|
+
const con = cls;
|
|
2016
|
+
pushStaticField(con.prototype, "observedStores", store2);
|
|
2017
|
+
};
|
|
2018
|
+
}
|
|
2019
|
+
function rootElement(rootType) {
|
|
2020
|
+
return function(cls) {
|
|
2021
|
+
const con = cls;
|
|
2022
|
+
con.rootElement = rootType;
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
function customElement(name) {
|
|
2026
|
+
return function(cls) {
|
|
2027
|
+
nativeDefineElement(name, cls);
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
const nativeHistory = window.history;
|
|
2031
|
+
const nativePushState = nativeHistory.pushState.bind(nativeHistory);
|
|
2032
|
+
const nativeReplaceState = nativeHistory.replaceState.bind(nativeHistory);
|
|
2033
|
+
let key = 0;
|
|
2034
|
+
const getKey = () => `${performance.now()}-${++key}`;
|
|
2035
|
+
const store = createStore({
|
|
2036
|
+
$hasCloseHandle: false,
|
|
2037
|
+
$hasOpenHandle: false,
|
|
2038
|
+
$hasShouldCloseHandle: false,
|
|
2039
|
+
$key: ""
|
|
2040
|
+
});
|
|
2041
|
+
const paramsMap = new Map();
|
|
2042
|
+
function validData({ $key, $hasCloseHandle, $hasOpenHandle, $hasShouldCloseHandle } = {}) {
|
|
2043
|
+
if (store.$key === $key)
|
|
2044
|
+
return;
|
|
2045
|
+
if ($key)
|
|
2046
|
+
throw new GemError("`$key` is not allowed");
|
|
2047
|
+
if ($hasCloseHandle)
|
|
2048
|
+
throw new GemError("`$hasCloseHandle` is not allowed");
|
|
2049
|
+
if ($hasOpenHandle)
|
|
2050
|
+
throw new GemError("`$hasOpenHandle` is not allowed");
|
|
2051
|
+
if ($hasShouldCloseHandle)
|
|
2052
|
+
throw new GemError("`$hasShouldCloseHandle` is not allowed");
|
|
2053
|
+
}
|
|
2054
|
+
function getUrlbarPath(internalPath) {
|
|
2055
|
+
return gemHistory.basePath ? gemHistory.basePath + internalPath : internalPath;
|
|
2056
|
+
}
|
|
2057
|
+
function getInternalPath(urlbarPath) {
|
|
2058
|
+
if (urlbarPath === gemHistory.basePath)
|
|
2059
|
+
return "/";
|
|
2060
|
+
return urlbarPath.replace(new RegExp(`^${gemHistory.basePath}/`), "/");
|
|
2061
|
+
}
|
|
2062
|
+
function normalizeParams(params) {
|
|
2063
|
+
const current = paramsMap.get(store.$key) || {};
|
|
2064
|
+
const path = params.path ? absoluteLocation(current.path, params.path) : getInternalPath(location.pathname);
|
|
2065
|
+
const query = new QueryString(params.query || (params.path ? "" : location.search));
|
|
2066
|
+
const pathChanged = params.path && params.path !== current.path || params.query && String(params.query) !== String(current.query);
|
|
2067
|
+
const title = params.title || (pathChanged ? "" : document.title);
|
|
2068
|
+
const statusChanged = params.close || params.data || params.open || params.shouldClose;
|
|
2069
|
+
const hash = params.hash || (!pathChanged && statusChanged ? decodeURIComponent(location.hash) : "");
|
|
2070
|
+
return __spreadProps(__spreadValues({}, params), { title, path, query, hash });
|
|
2071
|
+
}
|
|
2072
|
+
function updateHistory(p, native) {
|
|
2073
|
+
validData(p.data);
|
|
2074
|
+
const params = normalizeParams(p);
|
|
2075
|
+
const { title, path, query, hash, close, open: open2, shouldClose, data } = params;
|
|
2076
|
+
const state2 = __spreadValues({
|
|
2077
|
+
$hasCloseHandle: !!close,
|
|
2078
|
+
$hasOpenHandle: !!open2,
|
|
2079
|
+
$hasShouldCloseHandle: !!shouldClose,
|
|
2080
|
+
$key: getKey()
|
|
2081
|
+
}, data);
|
|
2082
|
+
paramsMap.set(state2.$key, params);
|
|
2083
|
+
updateStore(cleanObject(store), state2);
|
|
2084
|
+
const url = getUrlbarPath(path) + new QueryString(query) + hash;
|
|
2085
|
+
const prevHash = decodeURIComponent(location.hash);
|
|
2086
|
+
native(state2, title, url);
|
|
2087
|
+
if (prevHash !== hash)
|
|
2088
|
+
window.dispatchEvent(new CustomEvent("hashchange"));
|
|
2089
|
+
}
|
|
2090
|
+
function updateHistoryByNative(data, title, originUrl, native) {
|
|
2091
|
+
validData(data);
|
|
2092
|
+
const state2 = __spreadValues({
|
|
2093
|
+
$key: getKey()
|
|
2094
|
+
}, data || {});
|
|
2095
|
+
const { pathname, search, hash } = new URL(originUrl, location.origin + location.pathname);
|
|
2096
|
+
const params = normalizeParams({ path: pathname, query: new QueryString(search), hash, title, data });
|
|
2097
|
+
paramsMap.set(state2.$key, params);
|
|
2098
|
+
updateStore(cleanObject(store), state2);
|
|
2099
|
+
const url = getUrlbarPath(pathname) + params.query + hash;
|
|
2100
|
+
const prevHash = location.hash;
|
|
2101
|
+
native(state2, title, url);
|
|
2102
|
+
if (prevHash !== hash)
|
|
2103
|
+
window.dispatchEvent(new CustomEvent("hashchange"));
|
|
2104
|
+
}
|
|
2105
|
+
const gemBasePathStore = createStore({
|
|
2106
|
+
basePath: ""
|
|
2107
|
+
});
|
|
2108
|
+
class GemHistory {
|
|
2109
|
+
get store() {
|
|
2110
|
+
return store;
|
|
2111
|
+
}
|
|
2112
|
+
get basePath() {
|
|
2113
|
+
return gemBasePathStore.basePath;
|
|
2114
|
+
}
|
|
2115
|
+
set basePath(basePath) {
|
|
2116
|
+
updateStore(gemBasePathStore, { basePath });
|
|
2117
|
+
Object.assign(paramsMap.get(store.$key), { path: getInternalPath(location.pathname) });
|
|
2118
|
+
}
|
|
2119
|
+
getParams() {
|
|
2120
|
+
return paramsMap.get(store.$key);
|
|
2121
|
+
}
|
|
2122
|
+
updateParams(params) {
|
|
2123
|
+
Object.assign(paramsMap.get(store.$key), params);
|
|
2124
|
+
updateStore(store, {});
|
|
2125
|
+
}
|
|
2126
|
+
push(params) {
|
|
2127
|
+
updateHistory(params, nativePushState);
|
|
2128
|
+
}
|
|
2129
|
+
replace(params) {
|
|
2130
|
+
updateHistory(params, nativeReplaceState);
|
|
2131
|
+
}
|
|
2132
|
+
pushIgnoreCloseHandle(params) {
|
|
2133
|
+
var _a2, _b;
|
|
2134
|
+
if (store.$hasCloseHandle) {
|
|
2135
|
+
(_b = (_a2 = paramsMap.get(store.$key)) == null ? void 0 : _a2.close) == null ? void 0 : _b.call(_a2);
|
|
2136
|
+
this.replace(params);
|
|
2137
|
+
} else {
|
|
2138
|
+
this.push(params);
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
forward() {
|
|
2142
|
+
nativeHistory.forward();
|
|
2143
|
+
}
|
|
2144
|
+
back() {
|
|
2145
|
+
nativeHistory.back();
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
const gemHistory = new GemHistory();
|
|
2149
|
+
const gemTitleStore = createStore({ title: "" });
|
|
2150
|
+
const _GEMHISTORY = { history: gemHistory, titleStore: gemTitleStore, basePathStore: gemBasePathStore };
|
|
2151
|
+
if (!window._GEMHISTORY) {
|
|
2152
|
+
window._GEMHISTORY = _GEMHISTORY;
|
|
2153
|
+
nativeHistory.pushState = function(state2, title, path) {
|
|
2154
|
+
updateHistoryByNative(state2, title, path, nativePushState);
|
|
2155
|
+
};
|
|
2156
|
+
nativeHistory.replaceState = function(state2, title, path) {
|
|
2157
|
+
updateHistoryByNative(state2, title, path, nativeReplaceState);
|
|
2158
|
+
};
|
|
2159
|
+
window.addEventListener("hashchange", ({ isTrusted }) => {
|
|
2160
|
+
if (isTrusted) {
|
|
2161
|
+
gemHistory.replace({ hash: decodeURIComponent(location.hash) });
|
|
2162
|
+
}
|
|
2163
|
+
});
|
|
2164
|
+
if (!nativeHistory.state) {
|
|
2165
|
+
const { pathname, search, hash } = location;
|
|
2166
|
+
gemHistory.replace({ path: pathname, query: search, hash });
|
|
2167
|
+
} else if (nativeHistory.state.$hasCloseHandle) {
|
|
2168
|
+
updateStore(store, nativeHistory.state);
|
|
2169
|
+
const params = normalizeParams({ title: document.title });
|
|
2170
|
+
paramsMap.set(store.$key, params);
|
|
2171
|
+
gemHistory.back();
|
|
2172
|
+
} else {
|
|
2173
|
+
const params = normalizeParams({ title: document.title, hash: location.hash });
|
|
2174
|
+
updateStore(store, __spreadValues({
|
|
2175
|
+
$key: getKey()
|
|
2176
|
+
}, nativeHistory.state || {}));
|
|
2177
|
+
paramsMap.set(store.$key, params);
|
|
2178
|
+
}
|
|
2179
|
+
connect(gemTitleStore, () => {
|
|
2180
|
+
const params = paramsMap.get(store.$key);
|
|
2181
|
+
if (params) {
|
|
2182
|
+
params.title = gemTitleStore.title;
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
connect(store, () => {
|
|
2186
|
+
const { title } = gemHistory.getParams();
|
|
2187
|
+
if (title !== gemTitleStore.title) {
|
|
2188
|
+
updateStore(gemTitleStore, { title });
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
let navigating = false;
|
|
2192
|
+
window.addEventListener("popstate", (event) => {
|
|
2193
|
+
var _a2, _b;
|
|
2194
|
+
const newState = event.state;
|
|
2195
|
+
if (!(newState == null ? void 0 : newState.$key)) {
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
if (navigating) {
|
|
2199
|
+
navigating = false;
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2202
|
+
if (!paramsMap.has(newState.$key)) {
|
|
2203
|
+
const { pathname, search, hash } = location;
|
|
2204
|
+
paramsMap.set(newState.$key, {
|
|
2205
|
+
path: pathname,
|
|
2206
|
+
query: new QueryString(search),
|
|
2207
|
+
hash,
|
|
2208
|
+
title: document.title,
|
|
2209
|
+
data: newState
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
const prevState = store;
|
|
2213
|
+
if (parseFloat(newState.$key) > parseFloat(prevState.$key) && newState.$hasOpenHandle) {
|
|
2214
|
+
(_b = (_a2 = paramsMap.get(newState.$key)) == null ? void 0 : _a2.open) == null ? void 0 : _b.call(_a2);
|
|
2215
|
+
} else if (prevState.$hasCloseHandle) {
|
|
2216
|
+
const prevParams = paramsMap.get(prevState.$key);
|
|
2217
|
+
const closeHandle = prevParams == null ? void 0 : prevParams.close;
|
|
2218
|
+
const shouldCloseHandle = prevParams == null ? void 0 : prevParams.shouldClose;
|
|
2219
|
+
const notAllowClose = shouldCloseHandle && !shouldCloseHandle();
|
|
2220
|
+
if (notAllowClose) {
|
|
2221
|
+
navigating = true;
|
|
2222
|
+
gemHistory.forward();
|
|
2223
|
+
return;
|
|
2224
|
+
} else {
|
|
2225
|
+
if (closeHandle) {
|
|
2226
|
+
closeHandle();
|
|
2227
|
+
} else if (newState.$hasCloseHandle) {
|
|
2228
|
+
navigating = true;
|
|
2229
|
+
gemHistory.back();
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
updateStore(cleanObject(store), newState);
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
const { history, titleStore, basePathStore } = window._GEMHISTORY;
|
|
2237
|
+
var __defProp$6 = Object.defineProperty;
|
|
2238
|
+
var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
|
|
2239
|
+
var __decorateClass$6 = (decorators, target, key2, kind) => {
|
|
2240
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key2) : target;
|
|
2241
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2242
|
+
if (decorator = decorators[i])
|
|
2243
|
+
result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
|
|
2244
|
+
if (kind && result)
|
|
2245
|
+
__defProp$6(target, key2, result);
|
|
2246
|
+
return result;
|
|
2247
|
+
};
|
|
2248
|
+
var __accessCheck2 = (obj, member, msg) => {
|
|
2249
|
+
if (!member.has(obj))
|
|
2250
|
+
throw TypeError("Cannot " + msg);
|
|
2251
|
+
};
|
|
2252
|
+
var __privateGet2 = (obj, member, getter) => {
|
|
2253
|
+
__accessCheck2(obj, member, "read from private field");
|
|
2254
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
2255
|
+
};
|
|
2256
|
+
var __privateAdd2 = (obj, member, value) => {
|
|
2257
|
+
if (member.has(obj))
|
|
2258
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2259
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2260
|
+
};
|
|
2261
|
+
var __privateSet2 = (obj, member, value, setter) => {
|
|
2262
|
+
__accessCheck2(obj, member, "write to private field");
|
|
2263
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
2264
|
+
return value;
|
|
2265
|
+
};
|
|
2266
|
+
var _lastLoader, _updateLocationStore, _setContent;
|
|
2267
|
+
class ParamsRegExp extends RegExp {
|
|
2268
|
+
constructor(pattern) {
|
|
2269
|
+
const namePosition = {};
|
|
2270
|
+
let i = 0;
|
|
2271
|
+
super(`^${pattern.replace(/:([^/$]+)/g, (_m, name) => {
|
|
2272
|
+
namePosition[name] = i++;
|
|
2273
|
+
return `([^/]+)`;
|
|
2274
|
+
}).replace("*", ".*")}$`, "i");
|
|
2275
|
+
this.namePosition = namePosition;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
function matchPath(pattern, path) {
|
|
2279
|
+
const reg = new ParamsRegExp(pattern);
|
|
2280
|
+
const matchResult = path.match(reg) || `${path}/`.match(reg);
|
|
2281
|
+
if (!matchResult)
|
|
2282
|
+
return null;
|
|
2283
|
+
const params = {};
|
|
2284
|
+
if (matchResult) {
|
|
2285
|
+
Object.keys(reg.namePosition).forEach((name) => {
|
|
2286
|
+
params[name] = matchResult[reg.namePosition[name] + 1];
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
return params;
|
|
2290
|
+
}
|
|
2291
|
+
function createPath(route, options) {
|
|
2292
|
+
let path = route.pattern;
|
|
2293
|
+
const params = options == null ? void 0 : options.params;
|
|
2294
|
+
if (params) {
|
|
2295
|
+
Object.keys(params).forEach((key2) => {
|
|
2296
|
+
path = path.replace(new RegExp(`:${key2}`, "g"), params[key2]);
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
return path;
|
|
2300
|
+
}
|
|
2301
|
+
function createHistoryParams(route, options) {
|
|
2302
|
+
const path = createPath(route, options);
|
|
2303
|
+
return __spreadValues({
|
|
2304
|
+
path
|
|
2305
|
+
}, options);
|
|
2306
|
+
}
|
|
2307
|
+
let GemRouteElement = class extends GemElement {
|
|
2308
|
+
constructor({ isLight, routes } = {}) {
|
|
2309
|
+
super({ isLight });
|
|
2310
|
+
this.currentParams = {};
|
|
2311
|
+
__privateAdd2(this, _lastLoader, void 0);
|
|
2312
|
+
this.state = {
|
|
2313
|
+
content: void 0
|
|
2314
|
+
};
|
|
2315
|
+
__privateAdd2(this, _updateLocationStore, () => {
|
|
2316
|
+
if (this.locationStore) {
|
|
2317
|
+
const { path, query, data } = history.getParams();
|
|
2318
|
+
updateStore(this.locationStore, {
|
|
2319
|
+
path,
|
|
2320
|
+
params: this.currentParams,
|
|
2321
|
+
query,
|
|
2322
|
+
data
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
});
|
|
2326
|
+
__privateAdd2(this, _setContent, (route, params, content) => {
|
|
2327
|
+
__privateSet2(this, _lastLoader, void 0);
|
|
2328
|
+
this.currentRoute = route;
|
|
2329
|
+
this.currentParams = params;
|
|
2330
|
+
this.setState({ content });
|
|
2331
|
+
this.routechange(this.currentRoute);
|
|
2332
|
+
__privateGet2(this, _updateLocationStore).call(this);
|
|
2333
|
+
});
|
|
2334
|
+
this.routes = routes;
|
|
2335
|
+
}
|
|
2336
|
+
mounted() {
|
|
2337
|
+
this.effect(([key2, path], old) => {
|
|
2338
|
+
if (old && key2 === old[0] && path === old[1]) {
|
|
2339
|
+
__privateGet2(this, _updateLocationStore).call(this);
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
const { route, params = {} } = GemRouteElement.findRoute(this.routes, path);
|
|
2343
|
+
const { redirect, content, getContent } = route || {};
|
|
2344
|
+
if (redirect) {
|
|
2345
|
+
history.replace({ path: redirect });
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2348
|
+
const title = route == null ? void 0 : route.title;
|
|
2349
|
+
if (title)
|
|
2350
|
+
updateStore(titleStore, { title });
|
|
2351
|
+
const contentOrLoader = content || (getContent == null ? void 0 : getContent(params));
|
|
2352
|
+
if (contentOrLoader instanceof Promise) {
|
|
2353
|
+
this.loading(route);
|
|
2354
|
+
__privateSet2(this, _lastLoader, contentOrLoader);
|
|
2355
|
+
const isSomeLoader = () => __privateGet2(this, _lastLoader) === contentOrLoader;
|
|
2356
|
+
contentOrLoader.then((content2) => {
|
|
2357
|
+
if (isSomeLoader())
|
|
2358
|
+
__privateGet2(this, _setContent).call(this, route, params, content2);
|
|
2359
|
+
}).catch((err) => {
|
|
2360
|
+
if (isSomeLoader())
|
|
2361
|
+
this.error(err);
|
|
2362
|
+
});
|
|
2363
|
+
return;
|
|
2364
|
+
}
|
|
2365
|
+
__privateGet2(this, _setContent).call(this, route, params, contentOrLoader);
|
|
2366
|
+
}, () => {
|
|
2367
|
+
const { path } = history.getParams();
|
|
2368
|
+
return [this.key, path, location.search];
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
shouldUpdate() {
|
|
2372
|
+
if (this.inert)
|
|
2373
|
+
return false;
|
|
2374
|
+
return true;
|
|
2375
|
+
}
|
|
2376
|
+
render() {
|
|
2377
|
+
const { content } = this.state;
|
|
2378
|
+
if (!this.shadowRoot)
|
|
2379
|
+
return html`${content}`;
|
|
2380
|
+
return html`
|
|
2381
|
+
<style>
|
|
2382
|
+
:host,
|
|
2383
|
+
:not(:defined) {
|
|
2384
|
+
display: contents;
|
|
2385
|
+
}
|
|
2386
|
+
</style>
|
|
2387
|
+
${content != null ? content : html`<slot></slot>`}
|
|
2388
|
+
`;
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
_lastLoader = new WeakMap();
|
|
2392
|
+
_updateLocationStore = new WeakMap();
|
|
2393
|
+
_setContent = new WeakMap();
|
|
2394
|
+
GemRouteElement.createLocationStore = () => {
|
|
2395
|
+
const { path, query, data } = history.getParams();
|
|
2396
|
+
return createStore({ path, query, data, params: {} });
|
|
2397
|
+
};
|
|
2398
|
+
GemRouteElement.findRoute = (target = [], path) => {
|
|
2399
|
+
let defaultRoute = null;
|
|
2400
|
+
let routes;
|
|
2401
|
+
if (target instanceof Array) {
|
|
2402
|
+
routes = target;
|
|
2403
|
+
} else {
|
|
2404
|
+
routes = Object.values(target);
|
|
2405
|
+
}
|
|
2406
|
+
for (const route of routes) {
|
|
2407
|
+
if (route.pattern === "*") {
|
|
2408
|
+
defaultRoute = route;
|
|
2409
|
+
} else {
|
|
2410
|
+
const params = matchPath(route.pattern, path);
|
|
2411
|
+
if (params) {
|
|
2412
|
+
return { route, params };
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
return { route: defaultRoute };
|
|
2417
|
+
};
|
|
2418
|
+
__decorateClass$6([
|
|
2419
|
+
property
|
|
2420
|
+
], GemRouteElement.prototype, "routes", 2);
|
|
2421
|
+
__decorateClass$6([
|
|
2422
|
+
property
|
|
2423
|
+
], GemRouteElement.prototype, "locationStore", 2);
|
|
2424
|
+
__decorateClass$6([
|
|
2425
|
+
property
|
|
2426
|
+
], GemRouteElement.prototype, "key", 2);
|
|
2427
|
+
__decorateClass$6([
|
|
2428
|
+
emitter
|
|
2429
|
+
], GemRouteElement.prototype, "routechange", 2);
|
|
2430
|
+
__decorateClass$6([
|
|
2431
|
+
emitter
|
|
2432
|
+
], GemRouteElement.prototype, "loading", 2);
|
|
2433
|
+
__decorateClass$6([
|
|
2434
|
+
emitter
|
|
2435
|
+
], GemRouteElement.prototype, "error", 2);
|
|
2436
|
+
GemRouteElement = __decorateClass$6([
|
|
2437
|
+
connectStore(history.store)
|
|
2438
|
+
], GemRouteElement);
|
|
2439
|
+
class GemLightRouteElement extends GemRouteElement {
|
|
2440
|
+
constructor(options = {}) {
|
|
2441
|
+
super(__spreadProps(__spreadValues({}, options), { isLight: true }));
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
var __defProp$5 = Object.defineProperty;
|
|
2445
|
+
var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
|
|
2446
|
+
var __decorateClass$5 = (decorators, target, key2, kind) => {
|
|
2447
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target;
|
|
2448
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2449
|
+
if (decorator = decorators[i])
|
|
2450
|
+
result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
|
|
2451
|
+
if (kind && result)
|
|
2452
|
+
__defProp$5(target, key2, result);
|
|
2453
|
+
return result;
|
|
2454
|
+
};
|
|
2455
|
+
let GemLinkElement = class extends GemElement {
|
|
2456
|
+
constructor() {
|
|
2457
|
+
super();
|
|
2458
|
+
this.clickHandle = async (e) => {
|
|
2459
|
+
var _a2;
|
|
2460
|
+
const pathInfo = this.getPathInfo();
|
|
2461
|
+
if (!pathInfo)
|
|
2462
|
+
return;
|
|
2463
|
+
if (this.isExternal(pathInfo)) {
|
|
2464
|
+
switch (this.target) {
|
|
2465
|
+
case "_self":
|
|
2466
|
+
window.location.href = pathInfo;
|
|
2467
|
+
return;
|
|
2468
|
+
case "_parent":
|
|
2469
|
+
window.parent.location.href = pathInfo;
|
|
2470
|
+
return;
|
|
2471
|
+
case "_top":
|
|
2472
|
+
window.top.location.href = pathInfo;
|
|
2473
|
+
return;
|
|
2474
|
+
default:
|
|
2475
|
+
window.open(pathInfo);
|
|
2476
|
+
return;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
const { path, query, hash } = history.getParams();
|
|
2480
|
+
if (path + query + hash === pathInfo) {
|
|
2481
|
+
return;
|
|
2482
|
+
}
|
|
2483
|
+
e.stopPropagation();
|
|
2484
|
+
await ((_a2 = this.prepare) == null ? void 0 : _a2.call(this));
|
|
2485
|
+
if (this.route) {
|
|
2486
|
+
history.pushIgnoreCloseHandle(__spreadProps(__spreadValues({}, createHistoryParams(this.route, this.options)), {
|
|
2487
|
+
title: this.route.title || this.docTitle
|
|
2488
|
+
}));
|
|
2489
|
+
} else if (this.href) {
|
|
2490
|
+
const { pathname, search, hash: hash2 } = new URL(pathInfo, location.origin);
|
|
2491
|
+
history.pushIgnoreCloseHandle({
|
|
2492
|
+
path: pathname,
|
|
2493
|
+
query: search,
|
|
2494
|
+
hash: hash2,
|
|
2495
|
+
title: this.docTitle
|
|
2496
|
+
});
|
|
2497
|
+
} else {
|
|
2498
|
+
history.pushIgnoreCloseHandle({ path: this.path, query: this.query, hash: this.hash, title: this.docTitle });
|
|
2499
|
+
}
|
|
2500
|
+
};
|
|
2501
|
+
this.preventDefault = (e) => {
|
|
2502
|
+
e.preventDefault();
|
|
2503
|
+
};
|
|
2504
|
+
this.tabIndex = 0;
|
|
2505
|
+
this.addEventListener("click", this.clickHandle);
|
|
2506
|
+
}
|
|
2507
|
+
getPathInfo() {
|
|
2508
|
+
var _a2, _b;
|
|
2509
|
+
if (this.route) {
|
|
2510
|
+
const queryProp = ((_a2 = this.options) == null ? void 0 : _a2.query) || "";
|
|
2511
|
+
const hashProp = ((_b = this.options) == null ? void 0 : _b.hash) || "";
|
|
2512
|
+
return createPath(this.route, this.options) + queryProp + hashProp;
|
|
2513
|
+
} else {
|
|
2514
|
+
const url = this.href || this.path + this.query + this.hash;
|
|
2515
|
+
const { path, query } = history.getParams();
|
|
2516
|
+
if (url.startsWith("#")) {
|
|
2517
|
+
return `${path}${query}${url}`;
|
|
2518
|
+
} else if (url.startsWith("?")) {
|
|
2519
|
+
return `${path}${url}`;
|
|
2520
|
+
} else if (url.startsWith(".")) {
|
|
2521
|
+
return absoluteLocation(path, url);
|
|
2522
|
+
} else {
|
|
2523
|
+
return url;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
isExternal(pathInfo) {
|
|
2528
|
+
return !pathInfo.startsWith("/");
|
|
2529
|
+
}
|
|
2530
|
+
render(pathInfo = this.getPathInfo()) {
|
|
2531
|
+
return html`
|
|
2532
|
+
<style>
|
|
2533
|
+
:host {
|
|
2534
|
+
/* link default style */
|
|
2535
|
+
cursor: pointer;
|
|
2536
|
+
color: blue;
|
|
2537
|
+
text-decoration: underline;
|
|
2538
|
+
}
|
|
2539
|
+
a {
|
|
2540
|
+
all: unset;
|
|
2541
|
+
display: contents;
|
|
2542
|
+
}
|
|
2543
|
+
a:visited {
|
|
2544
|
+
color: unset;
|
|
2545
|
+
}
|
|
2546
|
+
</style>
|
|
2547
|
+
<a
|
|
2548
|
+
part=${this.link}
|
|
2549
|
+
@click=${this.preventDefault}
|
|
2550
|
+
href=${ifDefined(this.hint === "off" ? void 0 : this.isExternal(pathInfo) ? pathInfo : new URL(history.basePath + pathInfo, location.origin).toString())}
|
|
2551
|
+
>
|
|
2552
|
+
<slot></slot>
|
|
2553
|
+
</a>
|
|
2554
|
+
`;
|
|
2555
|
+
}
|
|
2556
|
+
};
|
|
2557
|
+
__decorateClass$5([
|
|
2558
|
+
attribute
|
|
2559
|
+
], GemLinkElement.prototype, "href", 2);
|
|
2560
|
+
__decorateClass$5([
|
|
2561
|
+
attribute
|
|
2562
|
+
], GemLinkElement.prototype, "target", 2);
|
|
2563
|
+
__decorateClass$5([
|
|
2564
|
+
attribute
|
|
2565
|
+
], GemLinkElement.prototype, "path", 2);
|
|
2566
|
+
__decorateClass$5([
|
|
2567
|
+
attribute
|
|
2568
|
+
], GemLinkElement.prototype, "query", 2);
|
|
2569
|
+
__decorateClass$5([
|
|
2570
|
+
attribute
|
|
2571
|
+
], GemLinkElement.prototype, "hash", 2);
|
|
2572
|
+
__decorateClass$5([
|
|
2573
|
+
attribute
|
|
2574
|
+
], GemLinkElement.prototype, "docTitle", 2);
|
|
2575
|
+
__decorateClass$5([
|
|
2576
|
+
attribute
|
|
2577
|
+
], GemLinkElement.prototype, "hint", 2);
|
|
2578
|
+
__decorateClass$5([
|
|
2579
|
+
property
|
|
2580
|
+
], GemLinkElement.prototype, "route", 2);
|
|
2581
|
+
__decorateClass$5([
|
|
2582
|
+
property
|
|
2583
|
+
], GemLinkElement.prototype, "options", 2);
|
|
2584
|
+
__decorateClass$5([
|
|
2585
|
+
property
|
|
2586
|
+
], GemLinkElement.prototype, "prepare", 2);
|
|
2587
|
+
__decorateClass$5([
|
|
2588
|
+
part
|
|
2589
|
+
], GemLinkElement.prototype, "link", 2);
|
|
2590
|
+
GemLinkElement = __decorateClass$5([
|
|
2591
|
+
connectStore(basePathStore)
|
|
2592
|
+
], GemLinkElement);
|
|
2593
|
+
let GemActiveLinkElement = class extends GemLinkElement {
|
|
2594
|
+
render() {
|
|
2595
|
+
const { path, query, hash } = history.getParams();
|
|
2596
|
+
const isMatchPattern = this.pattern && matchPath(this.pattern, path);
|
|
2597
|
+
const pathInfo = this.getPathInfo();
|
|
2598
|
+
if (isMatchPattern || path + query + hash === pathInfo) {
|
|
2599
|
+
this.active = true;
|
|
2600
|
+
} else {
|
|
2601
|
+
this.active = false;
|
|
2602
|
+
}
|
|
2603
|
+
return super.render(pathInfo);
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
__decorateClass$5([
|
|
2607
|
+
attribute
|
|
2608
|
+
], GemActiveLinkElement.prototype, "pattern", 2);
|
|
2609
|
+
__decorateClass$5([
|
|
2610
|
+
state
|
|
2611
|
+
], GemActiveLinkElement.prototype, "active", 2);
|
|
2612
|
+
GemActiveLinkElement = __decorateClass$5([
|
|
2613
|
+
connectStore(history.store)
|
|
2614
|
+
], GemActiveLinkElement);
|
|
2615
|
+
customElements.define("gem-link", GemLinkElement);
|
|
2616
|
+
customElements.define("gem-active-link", GemActiveLinkElement);
|
|
2617
|
+
customElements.define("gem-route", GemRouteElement);
|
|
2618
|
+
customElements.define("gem-light-route", GemLightRouteElement);
|
|
2619
|
+
var __defProp$4 = Object.defineProperty;
|
|
2620
|
+
var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
2621
|
+
var __decorateClass$4 = (decorators, target, key2, kind) => {
|
|
2622
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target;
|
|
2623
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2624
|
+
if (decorator = decorators[i])
|
|
2625
|
+
result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
|
|
2626
|
+
if (kind && result)
|
|
2627
|
+
__defProp$4(target, key2, result);
|
|
2628
|
+
return result;
|
|
2629
|
+
};
|
|
2630
|
+
let GemTitleElement = class extends GemElement {
|
|
2631
|
+
static setTitle(title) {
|
|
2632
|
+
updateStore(titleStore, { title });
|
|
2633
|
+
}
|
|
2634
|
+
static updateTitle(str = "", suffix = "") {
|
|
2635
|
+
const { title } = titleStore;
|
|
2636
|
+
if (title && title !== GemTitleElement.defaultTitle) {
|
|
2637
|
+
GemTitleElement.title = title;
|
|
2638
|
+
document.title = GemTitleElement.title + suffix;
|
|
2639
|
+
} else if (str) {
|
|
2640
|
+
GemTitleElement.title = str;
|
|
2641
|
+
document.title = GemTitleElement.title + suffix;
|
|
2642
|
+
} else {
|
|
2643
|
+
GemTitleElement.title = GemTitleElement.defaultTitle;
|
|
2644
|
+
document.title = GemTitleElement.title;
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
constructor() {
|
|
2648
|
+
super();
|
|
2649
|
+
new MutationObserver(() => this.update()).observe(this, { childList: true, characterData: true, subtree: true });
|
|
2650
|
+
}
|
|
2651
|
+
render() {
|
|
2652
|
+
GemTitleElement.updateTitle(this.textContent || "", this.suffix);
|
|
2653
|
+
if (this.hidden) {
|
|
2654
|
+
return html``;
|
|
2655
|
+
}
|
|
2656
|
+
return html`${GemTitleElement.title}`;
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
GemTitleElement.title = document.title;
|
|
2660
|
+
GemTitleElement.defaultTitle = document.title;
|
|
2661
|
+
GemTitleElement.defaultSuffix = ` - ${document.title}`;
|
|
2662
|
+
__decorateClass$4([
|
|
2663
|
+
attribute
|
|
2664
|
+
], GemTitleElement.prototype, "suffix", 2);
|
|
2665
|
+
GemTitleElement = __decorateClass$4([
|
|
2666
|
+
connectStore(titleStore)
|
|
2667
|
+
], GemTitleElement);
|
|
2668
|
+
connect(titleStore, GemTitleElement.updateTitle);
|
|
2669
|
+
customElements.define("gem-title", GemTitleElement);
|
|
2670
|
+
var __defProp$3 = Object.defineProperty;
|
|
2671
|
+
var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
|
|
2672
|
+
var __decorateClass$3 = (decorators, target, key2, kind) => {
|
|
2673
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target;
|
|
2674
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2675
|
+
if (decorator = decorators[i])
|
|
2676
|
+
result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
|
|
2677
|
+
if (kind && result)
|
|
2678
|
+
__defProp$3(target, key2, result);
|
|
2679
|
+
return result;
|
|
2680
|
+
};
|
|
2681
|
+
const eleCache = new Map();
|
|
2682
|
+
class GemUseElement extends GemElement {
|
|
2683
|
+
getContent() {
|
|
2684
|
+
const ele = this.element || (this.selector ? (this.root || document).querySelector(this.selector) : null);
|
|
2685
|
+
if (typeof ele === "string") {
|
|
2686
|
+
let temp = eleCache.get(ele);
|
|
2687
|
+
if (!temp) {
|
|
2688
|
+
temp = document.createElement("template");
|
|
2689
|
+
temp.innerHTML = ele;
|
|
2690
|
+
eleCache.set(ele, temp);
|
|
2691
|
+
}
|
|
2692
|
+
return temp.content.cloneNode(true);
|
|
2693
|
+
} else if (ele instanceof HTMLTemplateElement) {
|
|
2694
|
+
return ele.content.cloneNode(true);
|
|
2695
|
+
} else {
|
|
2696
|
+
return ele == null ? void 0 : ele.cloneNode(true);
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
render() {
|
|
2700
|
+
return html`
|
|
2701
|
+
<style>
|
|
2702
|
+
:host {
|
|
2703
|
+
position: relative;
|
|
2704
|
+
}
|
|
2705
|
+
:host(:not([hidden])) {
|
|
2706
|
+
display: inline-flex;
|
|
2707
|
+
align-items: center;
|
|
2708
|
+
}
|
|
2709
|
+
svg {
|
|
2710
|
+
width: 100%;
|
|
2711
|
+
height: 100%;
|
|
2712
|
+
}
|
|
2713
|
+
</style>
|
|
2714
|
+
${this.getContent()}
|
|
2715
|
+
<slot></slot>
|
|
2716
|
+
`;
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
__decorateClass$3([
|
|
2720
|
+
attribute
|
|
2721
|
+
], GemUseElement.prototype, "selector", 2);
|
|
2722
|
+
__decorateClass$3([
|
|
2723
|
+
property
|
|
2724
|
+
], GemUseElement.prototype, "root", 2);
|
|
2725
|
+
__decorateClass$3([
|
|
2726
|
+
property
|
|
2727
|
+
], GemUseElement.prototype, "element", 2);
|
|
2728
|
+
__decorateClass$3([
|
|
2729
|
+
state
|
|
2730
|
+
], GemUseElement.prototype, "active", 2);
|
|
2731
|
+
customElements.define("gem-use", GemUseElement);
|
|
2732
|
+
var __defProp$2 = Object.defineProperty;
|
|
2733
|
+
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
2734
|
+
var __decorateClass$2 = (decorators, target, key2, kind) => {
|
|
2735
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target;
|
|
2736
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2737
|
+
if (decorator = decorators[i])
|
|
2738
|
+
result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
|
|
2739
|
+
if (kind && result)
|
|
2740
|
+
__defProp$2(target, key2, result);
|
|
2741
|
+
return result;
|
|
2742
|
+
};
|
|
2743
|
+
class GemUnsafeElement extends GemElement {
|
|
2744
|
+
constructor() {
|
|
2745
|
+
super();
|
|
2746
|
+
this.effect(() => {
|
|
2747
|
+
if (this.shadowRoot) {
|
|
2748
|
+
this.shadowRoot.innerHTML = `
|
|
2749
|
+
<style>
|
|
2750
|
+
:host {
|
|
2751
|
+
display: contents;
|
|
2752
|
+
}
|
|
2753
|
+
${this.contentcss}
|
|
2754
|
+
</style>
|
|
2755
|
+
${this.content}
|
|
2756
|
+
`;
|
|
2757
|
+
}
|
|
2758
|
+
}, () => [this.content, this.contentcss]);
|
|
2759
|
+
}
|
|
2760
|
+
render() {
|
|
2761
|
+
return void 0;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
__decorateClass$2([
|
|
2765
|
+
attribute
|
|
2766
|
+
], GemUnsafeElement.prototype, "content", 2);
|
|
2767
|
+
__decorateClass$2([
|
|
2768
|
+
attribute
|
|
2769
|
+
], GemUnsafeElement.prototype, "contentcss", 2);
|
|
2770
|
+
customElements.define("gem-unsafe", GemUnsafeElement);
|
|
2771
|
+
var __defProp$1 = Object.defineProperty;
|
|
2772
|
+
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
2773
|
+
var __decorateClass$1 = (decorators, target, key2, kind) => {
|
|
2774
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target;
|
|
2775
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2776
|
+
if (decorator = decorators[i])
|
|
2777
|
+
result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
|
|
2778
|
+
if (kind && result)
|
|
2779
|
+
__defProp$1(target, key2, result);
|
|
2780
|
+
return result;
|
|
2781
|
+
};
|
|
2782
|
+
document.querySelectorAll("[data-reflect]").forEach((e) => e.remove());
|
|
2783
|
+
class GemReflectElement extends GemElement {
|
|
2784
|
+
constructor() {
|
|
2785
|
+
super({ isLight: true });
|
|
2786
|
+
this.target = document.head;
|
|
2787
|
+
this.hidden = true;
|
|
2788
|
+
this.effect(() => {
|
|
2789
|
+
const childNodes = [...this.childNodes];
|
|
2790
|
+
childNodes.forEach((node) => {
|
|
2791
|
+
if (node instanceof HTMLElement) {
|
|
2792
|
+
node.dataset.reflect = "";
|
|
2793
|
+
}
|
|
2794
|
+
this.target.append(node);
|
|
2795
|
+
});
|
|
2796
|
+
return () => {
|
|
2797
|
+
childNodes.forEach((node) => node.remove());
|
|
2798
|
+
};
|
|
2799
|
+
}, () => [this.target]);
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
__decorateClass$1([
|
|
2803
|
+
property
|
|
2804
|
+
], GemReflectElement.prototype, "target", 2);
|
|
2805
|
+
customElements.define("gem-reflect", GemReflectElement);
|
|
2806
|
+
const open = Symbol("open mark");
|
|
2807
|
+
function createModalClass(options) {
|
|
2808
|
+
var _a2;
|
|
2809
|
+
return _a2 = class extends GemElement {
|
|
2810
|
+
constructor() {
|
|
2811
|
+
super();
|
|
2812
|
+
this.label = "";
|
|
2813
|
+
this.internals.role = "alertdialog";
|
|
2814
|
+
this.internals.ariaModal = "true";
|
|
2815
|
+
}
|
|
2816
|
+
static get isOpen() {
|
|
2817
|
+
return this.store[open];
|
|
2818
|
+
}
|
|
2819
|
+
static get observedStores() {
|
|
2820
|
+
return [history.store, this.store];
|
|
2821
|
+
}
|
|
2822
|
+
static open(opts) {
|
|
2823
|
+
const instance = new this();
|
|
2824
|
+
this.instance = instance;
|
|
2825
|
+
this.inertStore = [...document.body.children].filter((e) => !e.inert);
|
|
2826
|
+
this.inertStore.forEach((e) => e.inert = true);
|
|
2827
|
+
document.body.append(instance);
|
|
2828
|
+
const changeStore = () => updateStore(this.store, __spreadValues({ [open]: true }, opts));
|
|
2829
|
+
setTimeout(() => {
|
|
2830
|
+
changeStore();
|
|
2831
|
+
history.push({
|
|
2832
|
+
title: instance.label,
|
|
2833
|
+
open: changeStore,
|
|
2834
|
+
close: this.closeHandle.bind(this),
|
|
2835
|
+
shouldClose: this.shouldClose.bind(this)
|
|
2836
|
+
});
|
|
2837
|
+
}, 100);
|
|
2838
|
+
}
|
|
2839
|
+
static close() {
|
|
2840
|
+
history.back();
|
|
2841
|
+
}
|
|
2842
|
+
static closeHandle() {
|
|
2843
|
+
var _a3;
|
|
2844
|
+
this.inertStore.forEach((e) => e.inert = false);
|
|
2845
|
+
(_a3 = this.instance) == null ? void 0 : _a3.remove();
|
|
2846
|
+
updateStore(this.store, __spreadValues({ [open]: false }, options));
|
|
2847
|
+
}
|
|
2848
|
+
static shouldClose() {
|
|
2849
|
+
return true;
|
|
2850
|
+
}
|
|
2851
|
+
}, _a2.inertStore = [], _a2.instance = null, _a2.store = createStore(__spreadValues({
|
|
2852
|
+
[open]: false
|
|
2853
|
+
}, options)), _a2;
|
|
2854
|
+
}
|
|
2855
|
+
var __defProp2 = Object.defineProperty;
|
|
2856
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2857
|
+
var __decorateClass = (decorators, target, key2, kind) => {
|
|
2858
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target;
|
|
2859
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2860
|
+
if (decorator = decorators[i])
|
|
2861
|
+
result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
|
|
2862
|
+
if (kind && result)
|
|
2863
|
+
__defProp2(target, key2, result);
|
|
2864
|
+
return result;
|
|
2865
|
+
};
|
|
2866
|
+
let GemDialogBaseElement = (_a = class extends GemElement {
|
|
2867
|
+
constructor() {
|
|
2868
|
+
super();
|
|
2869
|
+
__privateAdd(this, _nextSibling, void 0);
|
|
2870
|
+
__privateAdd(this, _parentElement, void 0);
|
|
2871
|
+
__privateAdd(this, _inertStore, void 0);
|
|
2872
|
+
this.inert = true;
|
|
2873
|
+
__privateSet(this, _inertStore, []);
|
|
2874
|
+
this.closeHandle = () => {
|
|
2875
|
+
var _a2;
|
|
2876
|
+
this.inert = true;
|
|
2877
|
+
__privateGet(this, _inertStore).forEach((e) => e.inert = false);
|
|
2878
|
+
if (__privateGet(this, _nextSibling)) {
|
|
2879
|
+
__privateGet(this, _nextSibling).before(this);
|
|
2880
|
+
} else if (__privateGet(this, _parentElement)) {
|
|
2881
|
+
(_a2 = __privateGet(this, _parentElement)) == null ? void 0 : _a2.appendChild(this);
|
|
2882
|
+
}
|
|
2883
|
+
this.dispatchEvent(new CustomEvent("close"));
|
|
2884
|
+
this.opened = false;
|
|
2885
|
+
};
|
|
2886
|
+
this.openHandle = () => {
|
|
2887
|
+
this.hidden = false;
|
|
2888
|
+
this.inert = false;
|
|
2889
|
+
__privateSet(this, _nextSibling, this.nextSibling);
|
|
2890
|
+
__privateSet(this, _parentElement, this.parentElement || this.getRootNode());
|
|
2891
|
+
__privateSet(this, _inertStore, [...document.body.children].filter((e) => !e.inert));
|
|
2892
|
+
__privateGet(this, _inertStore).forEach((e) => e.inert = true);
|
|
2893
|
+
document.body.append(this);
|
|
2894
|
+
this.dispatchEvent(new CustomEvent("open"));
|
|
2895
|
+
this.opened = true;
|
|
2896
|
+
};
|
|
2897
|
+
this.open = () => {
|
|
2898
|
+
if (this.opened)
|
|
2899
|
+
return;
|
|
2900
|
+
this.openHandle();
|
|
2901
|
+
history.push({
|
|
2902
|
+
title: this.label,
|
|
2903
|
+
open: this.openHandle,
|
|
2904
|
+
close: this.closeHandle,
|
|
2905
|
+
shouldClose: this.shouldClose
|
|
2906
|
+
});
|
|
2907
|
+
};
|
|
2908
|
+
this.close = () => {
|
|
2909
|
+
history.back();
|
|
2910
|
+
};
|
|
2911
|
+
this.forceClose = () => {
|
|
2912
|
+
this.opened = false;
|
|
2913
|
+
setTimeout(this.close, 100);
|
|
2914
|
+
};
|
|
2915
|
+
this.internals.role = "dialog";
|
|
2916
|
+
this.internals.ariaModal = "true";
|
|
2917
|
+
}
|
|
2918
|
+
shouldClose() {
|
|
2919
|
+
return true;
|
|
2920
|
+
}
|
|
2921
|
+
}, _nextSibling = new WeakMap(), _parentElement = new WeakMap(), _inertStore = new WeakMap(), _a);
|
|
2922
|
+
__decorateClass([
|
|
2923
|
+
attribute
|
|
2924
|
+
], GemDialogBaseElement.prototype, "label", 2);
|
|
2925
|
+
__decorateClass([
|
|
2926
|
+
state
|
|
2927
|
+
], GemDialogBaseElement.prototype, "opened", 2);
|
|
2928
|
+
GemDialogBaseElement = __decorateClass([
|
|
2929
|
+
connectStore(history.store)
|
|
2930
|
+
], GemDialogBaseElement);
|
|
2931
|
+
const themeStoreMap = new WeakMap();
|
|
2932
|
+
function getThemeStore(theme) {
|
|
2933
|
+
return themeStoreMap.get(theme);
|
|
2934
|
+
}
|
|
2935
|
+
const themePropMap = new WeakMap();
|
|
2936
|
+
function getThemeProp(theme) {
|
|
2937
|
+
return themePropMap.get(theme);
|
|
2938
|
+
}
|
|
2939
|
+
function replaceStyle(style, theme) {
|
|
2940
|
+
const themeStore = themeStoreMap.get(theme);
|
|
2941
|
+
const themeProp = themePropMap.get(theme);
|
|
2942
|
+
const rules = Object.keys(themeStore).reduce((prev, key2) => {
|
|
2943
|
+
if (!themeStore[key2])
|
|
2944
|
+
return prev;
|
|
2945
|
+
return prev + `${themeProp[key2]}:${themeStore[key2]};`;
|
|
2946
|
+
}, "");
|
|
2947
|
+
style.textContent = `:root, :host {${rules}}`;
|
|
2948
|
+
}
|
|
2949
|
+
function createTheme(themeObj) {
|
|
2950
|
+
const salt = randomStr();
|
|
2951
|
+
const style = document.createElement("style");
|
|
2952
|
+
const themeStore = createStore(themeObj);
|
|
2953
|
+
const theme = {};
|
|
2954
|
+
const themeProp = {};
|
|
2955
|
+
themePropMap.set(theme, themeProp);
|
|
2956
|
+
themeStoreMap.set(theme, themeStore);
|
|
2957
|
+
Object.keys(themeStore).forEach((key2) => {
|
|
2958
|
+
themeProp[key2] = `--${camelToKebabCase(key2)}-${salt}`;
|
|
2959
|
+
theme[key2] = `var(${themeProp[key2]})`;
|
|
2960
|
+
});
|
|
2961
|
+
const replace = () => replaceStyle(style, theme);
|
|
2962
|
+
connect(themeStore, replace);
|
|
2963
|
+
replace();
|
|
2964
|
+
(document.head || document.documentElement).append(style);
|
|
2965
|
+
return theme;
|
|
2966
|
+
}
|
|
2967
|
+
function updateTheme(theme, newThemeObj) {
|
|
2968
|
+
const store2 = getThemeStore(theme);
|
|
2969
|
+
updateStore(store2, newThemeObj);
|
|
2970
|
+
}
|
|
2971
|
+
const splitReg = /\$\d(?:<[^>]*>)?/;
|
|
2972
|
+
const matchReg = /\$(\d)(<([^>]*)>)?/g;
|
|
2973
|
+
const matchStrIndex = 3;
|
|
2974
|
+
function splice(rawValue, ...rest) {
|
|
2975
|
+
const templateArr = rawValue.split(splitReg);
|
|
2976
|
+
const values = [];
|
|
2977
|
+
let result;
|
|
2978
|
+
while (result = matchReg.exec(rawValue)) {
|
|
2979
|
+
const str = result[matchStrIndex];
|
|
2980
|
+
const index = Number(result[1]) - 1;
|
|
2981
|
+
const arg = rest[index];
|
|
2982
|
+
values.push(typeof arg === "string" ? arg : arg(str));
|
|
2983
|
+
}
|
|
2984
|
+
return html(templateArr, ...values);
|
|
2985
|
+
}
|
|
2986
|
+
const modules = new Set();
|
|
2987
|
+
const _I18n = class {
|
|
2988
|
+
constructor(options) {
|
|
2989
|
+
__privateAdd(this, _cacheCurrentKey);
|
|
2990
|
+
__privateAdd(this, _urlParamsLang);
|
|
2991
|
+
__privateAdd(this, _cacheLang);
|
|
2992
|
+
__privateAdd(this, _isMain);
|
|
2993
|
+
__privateAdd(this, _lang);
|
|
2994
|
+
this.cachePrefix = "gem-i18n";
|
|
2995
|
+
if (!options.resources[options.fallbackLanguage]) {
|
|
2996
|
+
throw new GemError("i18n: fallbackLanguage invalid");
|
|
2997
|
+
}
|
|
2998
|
+
this.store = createStore(this);
|
|
2999
|
+
Object.assign(this, options);
|
|
3000
|
+
let currentLanguage = __privateGet(this, _urlParamsLang, urlParamsLang_get) || this.currentLanguage || __privateGet(this, _cacheLang, cacheLang_get);
|
|
3001
|
+
const ele = document.querySelector(`[type*=${this.cachePrefix}]`);
|
|
3002
|
+
if (ele) {
|
|
3003
|
+
try {
|
|
3004
|
+
const prerenderData = JSON.parse(ele.textContent || "");
|
|
3005
|
+
currentLanguage = prerenderData.currentLanguage;
|
|
3006
|
+
this.resources[prerenderData.currentLanguage] = prerenderData.currentLanguagePack;
|
|
3007
|
+
} catch {
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
if (currentLanguage) {
|
|
3011
|
+
__privateSet(this, _lang, currentLanguage, lang_set);
|
|
3012
|
+
this.setLanguage(currentLanguage);
|
|
3013
|
+
} else {
|
|
3014
|
+
this.resetLanguage();
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
get(s, ...rest) {
|
|
3018
|
+
const currentLanguagePack = this.resources[this.currentLanguage];
|
|
3019
|
+
const fallbackLanguagePack = this.resources[this.fallbackLanguage];
|
|
3020
|
+
const msg = currentLanguagePack[s] || fallbackLanguagePack[s];
|
|
3021
|
+
const rawValue = (msg == null ? void 0 : msg.message) || msg || `[${s}]`;
|
|
3022
|
+
if (!rest.length)
|
|
3023
|
+
return rawValue;
|
|
3024
|
+
return splice(rawValue, ...rest);
|
|
3025
|
+
}
|
|
3026
|
+
detectLanguage() {
|
|
3027
|
+
const availableLangs = Object.keys(this.resources);
|
|
3028
|
+
const uiLangs = navigator.languages.map((lang) => lang.replace(/-(.*)/, ($1) => $1.toUpperCase()));
|
|
3029
|
+
for (const lang of uiLangs) {
|
|
3030
|
+
const matched = availableLangs.find((e) => e === lang || lang.startsWith(`${e}-`));
|
|
3031
|
+
if (matched)
|
|
3032
|
+
return matched;
|
|
3033
|
+
}
|
|
3034
|
+
return this.fallbackLanguage;
|
|
3035
|
+
}
|
|
3036
|
+
async setLanguage(lang) {
|
|
3037
|
+
if (__privateGet(this, _isMain, isMain_get)) {
|
|
3038
|
+
modules.forEach(async (i18n) => await i18n.setLanguage(lang));
|
|
3039
|
+
}
|
|
3040
|
+
let pack;
|
|
3041
|
+
const data = this.resources[lang];
|
|
3042
|
+
if (!data) {
|
|
3043
|
+
console.warn(`${this.cachePrefix}: not found \`${lang}\``);
|
|
3044
|
+
return this.resetLanguage();
|
|
3045
|
+
}
|
|
3046
|
+
if (typeof data === "string") {
|
|
3047
|
+
const prefix = `${this.cachePrefix}:`;
|
|
3048
|
+
const localKey = `${prefix}${data}`;
|
|
3049
|
+
const localPackString = localStorage.getItem(localKey);
|
|
3050
|
+
const fetchPack = async () => {
|
|
3051
|
+
const pack2 = await (await fetch(data)).json();
|
|
3052
|
+
if (this.cache) {
|
|
3053
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
3054
|
+
const key2 = localStorage.key(i);
|
|
3055
|
+
if (key2.startsWith(prefix)) {
|
|
3056
|
+
localStorage.removeItem(key2);
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
localStorage.setItem(localKey, JSON.stringify(pack2));
|
|
3060
|
+
}
|
|
3061
|
+
return pack2;
|
|
3062
|
+
};
|
|
3063
|
+
if (localPackString) {
|
|
3064
|
+
try {
|
|
3065
|
+
pack = JSON.parse(localPackString);
|
|
3066
|
+
} catch (e) {
|
|
3067
|
+
pack = await fetchPack();
|
|
3068
|
+
}
|
|
3069
|
+
} else {
|
|
3070
|
+
pack = await fetchPack();
|
|
3071
|
+
}
|
|
3072
|
+
} else {
|
|
3073
|
+
pack = data;
|
|
3074
|
+
}
|
|
3075
|
+
this.resources[lang] = pack;
|
|
3076
|
+
updateStore(this.store, {});
|
|
3077
|
+
if (lang !== this.currentLanguage) {
|
|
3078
|
+
__privateSet(this, _lang, lang, lang_set);
|
|
3079
|
+
}
|
|
3080
|
+
if (this.cache === true) {
|
|
3081
|
+
this.setCache();
|
|
3082
|
+
}
|
|
3083
|
+
return lang;
|
|
3084
|
+
}
|
|
3085
|
+
resetLanguage() {
|
|
3086
|
+
if (__privateGet(this, _isMain, isMain_get)) {
|
|
3087
|
+
modules.forEach((i18n) => i18n.resetLanguage());
|
|
3088
|
+
}
|
|
3089
|
+
__privateSet(this, _lang, this.fallbackLanguage, lang_set);
|
|
3090
|
+
if (this.cache) {
|
|
3091
|
+
localStorage.removeItem(__privateGet(this, _cacheCurrentKey, cacheCurrentKey_get));
|
|
3092
|
+
}
|
|
3093
|
+
return this.setLanguage(this.detectLanguage());
|
|
3094
|
+
}
|
|
3095
|
+
setCache() {
|
|
3096
|
+
if (__privateGet(this, _isMain, isMain_get)) {
|
|
3097
|
+
modules.forEach((i18n) => i18n.setCache());
|
|
3098
|
+
}
|
|
3099
|
+
localStorage.setItem(__privateGet(this, _cacheCurrentKey, cacheCurrentKey_get), this.currentLanguage);
|
|
3100
|
+
}
|
|
3101
|
+
createSubModule(name, resources) {
|
|
3102
|
+
const module = new _I18n({
|
|
3103
|
+
resources,
|
|
3104
|
+
cachePrefix: `${this.cachePrefix}-${name}`,
|
|
3105
|
+
currentLanguage: this.currentLanguage,
|
|
3106
|
+
fallbackLanguage: this.fallbackLanguage,
|
|
3107
|
+
cache: this.cache
|
|
3108
|
+
});
|
|
3109
|
+
modules.add(module);
|
|
3110
|
+
return module;
|
|
3111
|
+
}
|
|
3112
|
+
toJSON() {
|
|
3113
|
+
return {
|
|
3114
|
+
currentLanguage: this.currentLanguage,
|
|
3115
|
+
currentLanguagePack: this.resources[this.currentLanguage]
|
|
3116
|
+
};
|
|
3117
|
+
}
|
|
3118
|
+
};
|
|
3119
|
+
let I18n = _I18n;
|
|
3120
|
+
_cacheCurrentKey = new WeakSet();
|
|
3121
|
+
cacheCurrentKey_get = function() {
|
|
3122
|
+
return `${this.cachePrefix}:current`;
|
|
3123
|
+
};
|
|
3124
|
+
_urlParamsLang = new WeakSet();
|
|
3125
|
+
urlParamsLang_get = function() {
|
|
3126
|
+
const { hostname, pathname, search } = location;
|
|
3127
|
+
const parts2 = hostname.split(".");
|
|
3128
|
+
switch (this.urlParamsType) {
|
|
3129
|
+
case "ccTLD":
|
|
3130
|
+
return parts2.pop();
|
|
3131
|
+
case "gTLD":
|
|
3132
|
+
return parts2.shift();
|
|
3133
|
+
case "path":
|
|
3134
|
+
return pathname.split("/")[1];
|
|
3135
|
+
default:
|
|
3136
|
+
const fragment = this.urlParamsName && new URLSearchParams(search).get(this.urlParamsName) || "";
|
|
3137
|
+
return fragment in this.resources ? fragment : "";
|
|
3138
|
+
}
|
|
3139
|
+
};
|
|
3140
|
+
_cacheLang = new WeakSet();
|
|
3141
|
+
cacheLang_get = function() {
|
|
3142
|
+
return this.cache && localStorage.getItem(__privateGet(this, _cacheCurrentKey, cacheCurrentKey_get)) || "";
|
|
3143
|
+
};
|
|
3144
|
+
_isMain = new WeakSet();
|
|
3145
|
+
isMain_get = function() {
|
|
3146
|
+
return !modules.has(this);
|
|
3147
|
+
};
|
|
3148
|
+
_lang = new WeakSet();
|
|
3149
|
+
lang_set = function(lang) {
|
|
3150
|
+
var _a2;
|
|
3151
|
+
if (__privateGet(this, _isMain, isMain_get)) {
|
|
3152
|
+
document.documentElement.lang = lang;
|
|
3153
|
+
}
|
|
3154
|
+
this.currentLanguage = lang;
|
|
3155
|
+
(_a2 = this.onChange) == null ? void 0 : _a2.call(this, lang);
|
|
3156
|
+
};
|
|
3157
|
+
const defaultReq = {
|
|
3158
|
+
credentials: "include",
|
|
3159
|
+
mode: "cors"
|
|
3160
|
+
};
|
|
3161
|
+
async function request(uri, options = {}) {
|
|
3162
|
+
const res = await fetch(uri, __spreadValues(__spreadValues({}, defaultReq), options));
|
|
3163
|
+
if (res.status === 0)
|
|
3164
|
+
throw new Error("Request fail");
|
|
3165
|
+
if (res.status >= 500)
|
|
3166
|
+
throw new Error(res.statusText);
|
|
3167
|
+
if (res.status >= 400)
|
|
3168
|
+
throw new Error(await res.text() || res.statusText);
|
|
3169
|
+
return await res.json();
|
|
3170
|
+
}
|
|
3171
|
+
const TypedArray = Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array()));
|
|
3172
|
+
function serializationBody(body) {
|
|
3173
|
+
if (body instanceof FormData || body instanceof Blob || body instanceof TypedArray || body instanceof URLSearchParams || body instanceof ReadableStream || body instanceof ArrayBuffer) {
|
|
3174
|
+
return body;
|
|
3175
|
+
}
|
|
3176
|
+
if (typeof body === "object") {
|
|
3177
|
+
return JSON.stringify(body);
|
|
3178
|
+
}
|
|
3179
|
+
return body;
|
|
3180
|
+
}
|
|
3181
|
+
function get(url, params) {
|
|
3182
|
+
const { origin, pathname, search } = new URL(url, location.origin);
|
|
3183
|
+
const query = new URLSearchParams(params).toString();
|
|
3184
|
+
return request(`${origin}${pathname}${search ? `${search}&` : query ? "?" : ""}${query}`, {
|
|
3185
|
+
method: "GET"
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
function del(url) {
|
|
3189
|
+
return request(url, { method: "DELETE" });
|
|
3190
|
+
}
|
|
3191
|
+
function put(url, body) {
|
|
3192
|
+
return request(url, { method: "PUT", body: serializationBody(body) });
|
|
3193
|
+
}
|
|
3194
|
+
function post(url, body) {
|
|
3195
|
+
return request(url, { method: "POST", body: serializationBody(body) });
|
|
3196
|
+
}
|
|
3197
|
+
const matche = (query) => window.matchMedia(query).matches;
|
|
3198
|
+
const mediaQuery = {
|
|
3199
|
+
PRINT: "print",
|
|
3200
|
+
get isPrint() {
|
|
3201
|
+
return matche(this.PRINT);
|
|
3202
|
+
},
|
|
3203
|
+
HOVER: "(hover: hover)",
|
|
3204
|
+
get isHover() {
|
|
3205
|
+
return matche(this.HOVER);
|
|
3206
|
+
},
|
|
3207
|
+
PHONE: "(min-width: 319px) and (max-width: 480px)",
|
|
3208
|
+
get isPhone() {
|
|
3209
|
+
return matche(this.PHONE);
|
|
3210
|
+
},
|
|
3211
|
+
LAPTOP: "(min-width: 1023px) and (max-width: 1280px) and (orientation: landscape)",
|
|
3212
|
+
get isLaptop() {
|
|
3213
|
+
return matche(this.LAPTOP);
|
|
3214
|
+
},
|
|
3215
|
+
DESKTOP: "(min-width: 1279px) and (orientation: landscape)",
|
|
3216
|
+
get isDesktop() {
|
|
3217
|
+
return matche(this.DESKTOP);
|
|
3218
|
+
},
|
|
3219
|
+
WIDTHSCREEN: "(min-width: 1919px) and (orientation: landscape)",
|
|
3220
|
+
get isWidthScreen() {
|
|
3221
|
+
return matche(this.WIDTHSCREEN);
|
|
3222
|
+
},
|
|
3223
|
+
PHONE_LANDSCAPE: "(min-width: 479px) and (max-width: 767px) and (orientation: landscape)",
|
|
3224
|
+
get isPhoneLandscape() {
|
|
3225
|
+
return matche(this.PHONE_LANDSCAPE);
|
|
3226
|
+
},
|
|
3227
|
+
TABLET: "(min-width: 768px) and (max-width: 1024px)",
|
|
3228
|
+
get isTablet() {
|
|
3229
|
+
return matche(this.TABLET);
|
|
3230
|
+
},
|
|
3231
|
+
SMALL_PHONE: "(min-width: 319px) and (max-width: 480px) and (max-height: 640px)",
|
|
3232
|
+
get isSmallPhone() {
|
|
3233
|
+
return matche(this.SMALL_PHONE);
|
|
3234
|
+
},
|
|
3235
|
+
WATCH: "(max-width: 319px)",
|
|
3236
|
+
get isWatch() {
|
|
3237
|
+
return matche(this.WATCH);
|
|
3238
|
+
},
|
|
3239
|
+
SHORT: "(min-width: 479px) and (max-height: 320px)",
|
|
3240
|
+
get isShort() {
|
|
3241
|
+
return matche(this.SHORT);
|
|
3242
|
+
},
|
|
3243
|
+
PWA: "(display-mode: standalone)",
|
|
3244
|
+
get isPWA() {
|
|
3245
|
+
return matche(this.PWA);
|
|
3246
|
+
},
|
|
3247
|
+
MOTION_REDUCE: "(prefers-reduced-motion: reduce)",
|
|
3248
|
+
get isMotionReduce() {
|
|
3249
|
+
return matche(this.MOTION_REDUCE);
|
|
3250
|
+
},
|
|
3251
|
+
DATA_REDUCE: "(prefers-reduced-data: reduce)",
|
|
3252
|
+
get isDataReduce() {
|
|
3253
|
+
return matche(this.DATA_REDUCE);
|
|
3254
|
+
}
|
|
3255
|
+
};
|
|
3256
|
+
const version = "1.6.5";
|
|
3257
|
+
if (window.__GEM_DEVTOOLS__HOOK__) {
|
|
3258
|
+
Object.assign(window.__GEM_DEVTOOLS__HOOK__, __spreadValues({}, Gem));
|
|
3259
|
+
}
|
|
3260
|
+
export { GemActiveLinkElement, GemDialogBaseElement, GemElement, GemError, GemLightRouteElement, GemLinkElement, GemReflectElement, GemRouteElement, GemTitleElement, GemUnsafeElement, GemUseElement, I18n, LinkedList, PropProxyMap, QueryString, SVGTemplateResult, SheetToken, StoreListenerMap, TemplateResult, absoluteLocation, addMicrotask, addMicrotaskToStack, adoptedStyle, attribute, basePathStore, boolattribute, camelToKebabCase, classMap, cleanObject, connect, connectStore, createCSSSheet, createHistoryParams, createModalClass, createPath, createStore, createStoreSet, createTheme, css, customElement, defineAttribute, defineCSSState, defineProperty, defineRef, del, directive, disconnect, emitter, get, getThemeProp, getThemeStore, globalemitter, guard, history, html, ifDefined, isArrayChange, kebabToCamelCase, matchPath, mediaQuery, nativeDefineElement, numattribute, part, partMap, post, property, put, randomStr, raw, refobject, removeItems, render, repeat, request, rootElement, slot, splice, state, styleMap, styled, svg, titleStore, updateStore, updateTheme, useNativeCSSStyleSheet, version };
|