@mantou/gem 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gem.es.js +2007 -2020
- package/dist/gem.umd.js +15 -32
- package/elements/base/dialog.d.ts +1 -1
- package/elements/base/dialog.d.ts.map +1 -1
- package/elements/base/dialog.js +2 -2
- package/elements/base/dialog.js.map +1 -1
- package/elements/base/gesture.d.ts +1 -1
- package/elements/base/gesture.d.ts.map +1 -1
- package/elements/base/gesture.js +4 -4
- package/elements/base/gesture.js.map +1 -1
- package/elements/base/link.d.ts.map +1 -1
- package/elements/base/link.js +7 -12
- package/elements/base/link.js.map +1 -1
- package/elements/base/modal-factory.d.ts +23 -12
- package/elements/base/modal-factory.d.ts.map +1 -1
- package/elements/base/modal-factory.js +14 -14
- package/elements/base/modal-factory.js.map +1 -1
- package/elements/base/reflect.d.ts +1 -2
- package/elements/base/reflect.d.ts.map +1 -1
- package/elements/base/reflect.js +8 -10
- package/elements/base/reflect.js.map +1 -1
- package/elements/base/route.d.ts +17 -7
- package/elements/base/route.d.ts.map +1 -1
- package/elements/base/route.js +6 -6
- package/elements/base/route.js.map +1 -1
- package/elements/base/title.d.ts +1 -1
- package/elements/base/title.d.ts.map +1 -1
- package/elements/base/title.js +3 -3
- package/elements/base/title.js.map +1 -1
- package/elements/base/unsafe.d.ts +1 -1
- package/elements/base/unsafe.d.ts.map +1 -1
- package/elements/base/unsafe.js +1 -1
- package/elements/base/unsafe.js.map +1 -1
- package/elements/base/use.d.ts +1 -1
- package/elements/base/use.d.ts.map +1 -1
- package/elements/base/use.js +1 -1
- package/elements/base/use.js.map +1 -1
- package/elements/link.js +1 -1
- package/elements/link.js.map +1 -1
- package/elements/route.js +1 -1
- package/elements/route.js.map +1 -1
- package/helper/hmr.d.ts +11 -0
- package/helper/hmr.d.ts.map +1 -0
- package/helper/hmr.js +255 -0
- package/helper/hmr.js.map +1 -0
- package/helper/i18n.d.ts +2 -2
- package/helper/i18n.d.ts.map +1 -1
- package/helper/i18n.js +5 -4
- package/helper/i18n.js.map +1 -1
- package/helper/logger.d.ts +1 -1
- package/helper/logger.d.ts.map +1 -1
- package/helper/logger.js +8 -5
- package/helper/logger.js.map +1 -1
- package/helper/mediaquery.js +1 -1
- package/helper/mediaquery.js.map +1 -1
- package/helper/ssr-shim.d.ts.map +1 -1
- package/helper/ssr-shim.js +2 -0
- package/helper/ssr-shim.js.map +1 -1
- package/helper/theme.d.ts +3 -4
- package/helper/theme.d.ts.map +1 -1
- package/helper/theme.js +1 -1
- package/helper/theme.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -3
- package/index.js.map +1 -1
- package/lib/decorators.d.ts +5 -13
- package/lib/decorators.d.ts.map +1 -1
- package/lib/decorators.js +40 -42
- package/lib/decorators.js.map +1 -1
- package/lib/directive.d.ts +0 -18
- package/lib/directive.d.ts.map +1 -1
- package/lib/directive.js +1 -2
- package/lib/directive.js.map +1 -1
- package/lib/element.d.ts +8 -137
- package/lib/element.d.ts.map +1 -1
- package/lib/element.js +16 -481
- package/lib/element.js.map +1 -1
- package/lib/history.d.ts +67 -9
- package/lib/history.d.ts.map +1 -1
- package/lib/history.js +12 -12
- package/lib/history.js.map +1 -1
- package/lib/lit-html.d.ts +5 -104
- package/lib/lit-html.d.ts.map +1 -1
- package/lib/lit-html.js +73 -27
- package/lib/lit-html.js.map +1 -1
- package/lib/reactive.d.ts +123 -0
- package/lib/reactive.d.ts.map +1 -0
- package/lib/reactive.js +478 -0
- package/lib/reactive.js.map +1 -0
- package/lib/repeat.d.ts +3 -3
- package/lib/repeat.d.ts.map +1 -1
- package/lib/repeat.js +3 -3
- package/lib/repeat.js.map +1 -1
- package/lib/store.d.ts +13 -2
- package/lib/store.d.ts.map +1 -1
- package/lib/store.js +1 -0
- package/lib/store.js.map +1 -1
- package/lib/utils.d.ts +23 -11
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +20 -15
- package/lib/utils.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.d.ts.map +1 -1
- package/lib/version.js +1 -2
- package/lib/version.js.map +1 -1
- package/package.json +3 -3
- package/src/dist.ts +6 -8
- package/src/elements/base/dialog.ts +2 -2
- package/src/elements/base/gesture.ts +5 -5
- package/src/elements/base/link.ts +16 -22
- package/src/elements/base/modal-factory.ts +14 -14
- package/src/elements/base/reflect.ts +2 -3
- package/src/elements/base/route.ts +13 -14
- package/src/elements/base/title.ts +4 -4
- package/src/elements/base/unsafe.ts +1 -1
- package/src/elements/base/use.ts +1 -1
- package/src/elements/link.ts +1 -1
- package/src/elements/route.ts +1 -1
- package/src/helper/hmr.ts +305 -0
- package/src/helper/i18n.ts +7 -7
- package/src/helper/logger.ts +9 -5
- package/src/helper/mediaquery.ts +1 -1
- package/src/helper/ssr-shim.ts +3 -0
- package/src/helper/theme.ts +4 -4
- package/src/index.ts +1 -4
- package/src/lib/decorators.ts +56 -68
- package/src/lib/directive.ts +3 -5
- package/src/lib/element.ts +22 -600
- package/src/lib/history.ts +14 -15
- package/src/lib/lit-html.ts +86 -34
- package/src/lib/reactive.ts +596 -0
- package/src/lib/repeat.ts +5 -5
- package/src/lib/store.ts +1 -0
- package/src/lib/utils.ts +35 -30
- package/src/lib/version.ts +1 -2
- package/src/test/elements/link.test.ts +2 -2
- package/src/test/elements/reflect.test.ts +3 -3
- package/src/test/elements/title.test.ts +2 -2
- package/src/test/gem-element/advance.test.ts +10 -9
- package/src/test/gem-element/basic.test.ts +3 -3
- package/src/test/gem-element/decorators.test.ts +10 -10
- package/src/test/gem-element/multi.test.ts +2 -2
- package/src/test/history.test.ts +1 -2
- package/src/test/store.test.ts +2 -3
- package/src/test/utils.test.ts +4 -5
- package/src/test/utils.ts +2 -2
- package/helper/react-shim.d.ts +0 -15
- package/helper/react-shim.d.ts.map +0 -1
- package/helper/react-shim.js +0 -56
- package/helper/react-shim.js.map +0 -1
- package/lib/directives.d.ts +0 -4
- package/lib/directives.d.ts.map +0 -1
- package/lib/directives.js +0 -5
- package/lib/directives.js.map +0 -1
- package/lib/ref.d.ts +0 -1
- package/lib/ref.d.ts.map +0 -1
- package/lib/ref.js +0 -2
- package/lib/ref.js.map +0 -1
package/src/lib/decorators.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { TemplateResult } from './lit-html';
|
|
2
|
+
import type { Metadata, Sheet } from './reactive';
|
|
3
|
+
import { _createTemplate, _RenderErrorEvent, GemElement, render, UpdateToken } from './reactive';
|
|
4
4
|
import type { Store } from './store';
|
|
5
|
-
import
|
|
6
|
-
import * as decoratorsExports from './decorators';
|
|
7
|
-
import * as storeExports from './store';
|
|
8
|
-
import * as versionExports from './version';
|
|
5
|
+
import { camelToKebabCase, GemError, PropProxyMap } from './utils';
|
|
9
6
|
|
|
10
7
|
type GemElementPrototype = GemElement & { '': never };
|
|
11
8
|
type StaticField = Exclude<keyof Metadata, keyof ShadowRootInit | 'aria' | 'noBlocking' | 'penetrable'>;
|
|
12
9
|
|
|
13
10
|
const { deleteProperty, getOwnPropertyDescriptor, defineProperty } = Reflect;
|
|
14
|
-
const { getPrototypeOf, assign } = Object;
|
|
11
|
+
const { getPrototypeOf, assign, hasOwn } = Object;
|
|
15
12
|
const gemElementProxyMap = new PropProxyMap<GemElement>();
|
|
16
13
|
|
|
17
14
|
function pushStaticField(context: ClassFieldDecoratorContext | ClassDecoratorContext, field: StaticField, member: any) {
|
|
@@ -27,7 +24,8 @@ function pushStaticField(context: ClassFieldDecoratorContext | ClassDecoratorCon
|
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
function clearField<T extends GemElement>(instance: T, prop: string) {
|
|
30
|
-
|
|
27
|
+
// hmr 支持不存在属性
|
|
28
|
+
const { value } = getOwnPropertyDescriptor(instance, prop) || {};
|
|
31
29
|
deleteProperty(instance, prop);
|
|
32
30
|
(instance as any)[prop] = value;
|
|
33
31
|
}
|
|
@@ -37,18 +35,19 @@ const observedTargetAttributes = new WeakMap<GemElementPrototype, Map<string, st
|
|
|
37
35
|
// 不在 Devtools 中工作 https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#dom_access
|
|
38
36
|
// 使用 Gem DevTools 注入脚本监听 attribute 变化
|
|
39
37
|
const { setAttribute, toggleAttribute, removeAttribute } = Element.prototype;
|
|
38
|
+
const getObservedPropName = (i: GemElement, n: string) => observedTargetAttributes.get(getPrototypeOf(i))?.get(n);
|
|
40
39
|
GemElement.prototype.setAttribute = function (n: string, v: string) {
|
|
41
|
-
const prop =
|
|
40
|
+
const prop = getObservedPropName(this, n);
|
|
42
41
|
if (!prop) return setAttribute.call(this, n, v);
|
|
43
42
|
(this as any)[prop] = v;
|
|
44
43
|
};
|
|
45
44
|
GemElement.prototype.removeAttribute = function (n: string) {
|
|
46
|
-
const prop =
|
|
45
|
+
const prop = getObservedPropName(this, n);
|
|
47
46
|
if (!prop) return removeAttribute.call(this, n);
|
|
48
47
|
(this as any)[prop] = null;
|
|
49
48
|
};
|
|
50
49
|
GemElement.prototype.toggleAttribute = function (n: string, force?: boolean) {
|
|
51
|
-
const prop =
|
|
50
|
+
const prop = getObservedPropName(this, n);
|
|
52
51
|
if (!prop) return toggleAttribute.call(this, n, force);
|
|
53
52
|
return ((this as any)[prop] = force ?? !this.hasAttribute(n));
|
|
54
53
|
};
|
|
@@ -114,7 +113,7 @@ function defineProp(
|
|
|
114
113
|
|
|
115
114
|
// https://github.com/tc39/proposal-decorators/issues/517
|
|
116
115
|
const targetCache = new WeakMap<DecoratorMetadataObject, GemElementPrototype>();
|
|
117
|
-
function getDecoratorTarget(element: GemElement, { metadata }:
|
|
116
|
+
function getDecoratorTarget(element: GemElement, { metadata }: ClassMemberDecoratorContext) {
|
|
118
117
|
const target = targetCache.get(metadata);
|
|
119
118
|
if (target) return target;
|
|
120
119
|
let result = element as GemElementPrototype;
|
|
@@ -131,7 +130,7 @@ function decoratorAttr<T extends GemElement>(context: ClassFieldDecoratorContext
|
|
|
131
130
|
const attr = camelToKebabCase(prop);
|
|
132
131
|
context.addInitializer(function (this: T) {
|
|
133
132
|
const target = getDecoratorTarget(this, context);
|
|
134
|
-
if (!target
|
|
133
|
+
if (!hasOwn(target, prop)) {
|
|
135
134
|
pushStaticField(context, 'observedAttributes', attr); // 没有 observe 的效果
|
|
136
135
|
defineProp(target, prop, { attr, attrType });
|
|
137
136
|
}
|
|
@@ -182,7 +181,7 @@ export function property<T extends GemElement>(_: undefined, context: ClassField
|
|
|
182
181
|
const prop = context.name as string;
|
|
183
182
|
context.addInitializer(function (this: T) {
|
|
184
183
|
const target = getDecoratorTarget(this, context);
|
|
185
|
-
if (!target
|
|
184
|
+
if (!hasOwn(target, prop)) {
|
|
186
185
|
pushStaticField(context, 'observedProperties', prop);
|
|
187
186
|
defineProp(target, prop);
|
|
188
187
|
}
|
|
@@ -210,19 +209,27 @@ export function property<T extends GemElement>(_: undefined, context: ClassField
|
|
|
210
209
|
export function memo<T extends GemElement, V = any, K = any[] | undefined>(
|
|
211
210
|
getDep?: K extends readonly any[] ? (instance: T) => K : undefined,
|
|
212
211
|
) {
|
|
213
|
-
return
|
|
212
|
+
return (
|
|
214
213
|
_: any,
|
|
215
214
|
context: ClassGetterDecoratorContext<T, V> | ClassFieldDecoratorContext<T> | ClassMethodDecoratorContext<T>,
|
|
216
|
-
) {
|
|
215
|
+
) => {
|
|
217
216
|
const { addInitializer, name, access, kind } = context;
|
|
218
217
|
addInitializer(function (this: T) {
|
|
219
218
|
const dep = getDep && (() => getDep(this) as any);
|
|
220
219
|
if (kind === 'getter') {
|
|
221
220
|
// 不能设置私有字段 https://github.com/tc39/proposal-decorators/issues/509
|
|
222
221
|
if (context.private) throw new GemError('not support');
|
|
223
|
-
|
|
222
|
+
const target = getDecoratorTarget(this, context as any);
|
|
223
|
+
// 不能直接用 `access.get.bind(this)` 是现有 builder 工具的 bug?
|
|
224
|
+
const getter = getOwnPropertyDescriptor(target, name)!.get!.bind(this);
|
|
225
|
+
this.memo(() => {
|
|
226
|
+
defineProperty(this, name, {
|
|
227
|
+
configurable: true,
|
|
228
|
+
value: getter(),
|
|
229
|
+
});
|
|
230
|
+
}, dep);
|
|
224
231
|
} else {
|
|
225
|
-
this.memo((access.get(this) as any).bind(this)
|
|
232
|
+
this.memo((access.get.call(this, this) as any).bind(this), dep);
|
|
226
233
|
}
|
|
227
234
|
});
|
|
228
235
|
};
|
|
@@ -246,24 +253,18 @@ export function memo<T extends GemElement, V = any, K = any[] | undefined>(
|
|
|
246
253
|
export function effect<T extends GemElement, V extends (depValues: K, oldDepValues?: K) => any, K = any[] | undefined>(
|
|
247
254
|
getDep?: K extends readonly any[] ? (instance: T) => K : undefined,
|
|
248
255
|
) {
|
|
249
|
-
return
|
|
250
|
-
_: any,
|
|
251
|
-
{ addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>,
|
|
252
|
-
) {
|
|
256
|
+
return (_: any, { addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>) => {
|
|
253
257
|
addInitializer(function (this: T) {
|
|
254
|
-
this.effect(access.get(this).bind(this) as any, getDep && (() => getDep(this) as any));
|
|
258
|
+
this.effect(access.get.call(this, this).bind(this) as any, getDep && (() => getDep(this) as any));
|
|
255
259
|
});
|
|
256
260
|
};
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
export function unmounted<T extends GemElement, V extends () => any>() {
|
|
260
|
-
return
|
|
261
|
-
_: any,
|
|
262
|
-
{ addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>,
|
|
263
|
-
) {
|
|
264
|
+
return (_: any, { addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>) => {
|
|
264
265
|
addInitializer(function (this: T) {
|
|
265
266
|
this.effect(
|
|
266
|
-
() => access.get(this).bind(this) as any,
|
|
267
|
+
() => access.get.call(this, this).bind(this) as any,
|
|
267
268
|
() => [],
|
|
268
269
|
);
|
|
269
270
|
});
|
|
@@ -284,13 +285,10 @@ export function template<T extends GemElement, V extends () => TemplateResult |
|
|
|
284
285
|
/** 当所有 `template` 返回 `false` 时不进行更新,包括 `memo` */
|
|
285
286
|
condition?: (instance: T) => boolean,
|
|
286
287
|
) {
|
|
287
|
-
return
|
|
288
|
-
_: any,
|
|
289
|
-
{ addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>,
|
|
290
|
-
) {
|
|
288
|
+
return (_: any, { addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>) => {
|
|
291
289
|
addInitializer(function (this: T) {
|
|
292
290
|
_createTemplate(this, {
|
|
293
|
-
render: access.get(this).bind(this),
|
|
291
|
+
render: access.get.call(this, this).bind(this),
|
|
294
292
|
condition: condition && (() => condition(this) as any),
|
|
295
293
|
});
|
|
296
294
|
});
|
|
@@ -298,13 +296,10 @@ export function template<T extends GemElement, V extends () => TemplateResult |
|
|
|
298
296
|
}
|
|
299
297
|
|
|
300
298
|
export function fallback<T extends GemElement, V extends (err: any) => TemplateResult | null | undefined>() {
|
|
301
|
-
return
|
|
302
|
-
_: any,
|
|
303
|
-
{ addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>,
|
|
304
|
-
) {
|
|
299
|
+
return (_: any, { addInitializer, access }: ClassFieldDecoratorContext<T, V> | ClassMethodDecoratorContext<T, V>) => {
|
|
305
300
|
addInitializer(function (this: T) {
|
|
306
301
|
this.addEventListener(_RenderErrorEvent, ({ detail }: CustomEvent) => {
|
|
307
|
-
render(access.get(this).apply(this, [detail]), this.internals.shadowRoot || this);
|
|
302
|
+
render(access.get.call(this, this).apply(this, [detail]), this.internals.shadowRoot || this);
|
|
308
303
|
});
|
|
309
304
|
});
|
|
310
305
|
};
|
|
@@ -348,7 +343,7 @@ export function state<T extends GemElement>(_: undefined, context: ClassFieldDec
|
|
|
348
343
|
const attr = camelToKebabCase(prop);
|
|
349
344
|
context.addInitializer(function (this: T) {
|
|
350
345
|
const target = getDecoratorTarget(this, context);
|
|
351
|
-
if (!target
|
|
346
|
+
if (!hasOwn(target, prop)) {
|
|
352
347
|
pushStaticField(context, 'definedCSSStates', attr);
|
|
353
348
|
defineCSSState(target, prop, attr);
|
|
354
349
|
}
|
|
@@ -410,7 +405,17 @@ export function part(_: undefined, context: ClassFieldDecoratorContext<any, stri
|
|
|
410
405
|
};
|
|
411
406
|
}
|
|
412
407
|
|
|
413
|
-
|
|
408
|
+
type EmitterHandler<T> = (evt: CustomEvent<T>) => void;
|
|
409
|
+
|
|
410
|
+
export type Emitter<T = any> = ((
|
|
411
|
+
detail?: T,
|
|
412
|
+
options?: Omit<CustomEventInit<unknown>, 'detail'>,
|
|
413
|
+
) => Promise<void> | void) & {
|
|
414
|
+
/**
|
|
415
|
+
* @internal 用来为 ts plugin 提供类型签名,没有值
|
|
416
|
+
*/
|
|
417
|
+
handler?: EmitterHandler<T> | (AddEventListenerOptions & { handleEvent: EmitterHandler<T> });
|
|
418
|
+
};
|
|
414
419
|
|
|
415
420
|
/**
|
|
416
421
|
* 定义一个事件发射器,类似 `HTMLElement.click`,
|
|
@@ -437,7 +442,7 @@ function defineEmitter<T extends GemElement>(
|
|
|
437
442
|
const event = camelToKebabCase(prop);
|
|
438
443
|
context.addInitializer(function (this: T) {
|
|
439
444
|
const target = getDecoratorTarget(this, context);
|
|
440
|
-
if (!target
|
|
445
|
+
if (!hasOwn(target, prop)) {
|
|
441
446
|
pushStaticField(context, 'definedEvents', event);
|
|
442
447
|
defineProp(target, prop, { event, eventOptions });
|
|
443
448
|
}
|
|
@@ -454,8 +459,8 @@ function defineEmitter<T extends GemElement>(
|
|
|
454
459
|
* class App extends GemElement {}
|
|
455
460
|
* ```
|
|
456
461
|
*/
|
|
457
|
-
export function adoptedStyle(sheet:
|
|
458
|
-
return
|
|
462
|
+
export function adoptedStyle(sheet: Sheet<unknown>) {
|
|
463
|
+
return (_: unknown, context: ClassDecoratorContext) => {
|
|
459
464
|
pushStaticField(context, 'adoptedStyleSheets', sheet);
|
|
460
465
|
};
|
|
461
466
|
}
|
|
@@ -470,7 +475,7 @@ export function adoptedStyle(sheet: ReturnType<typeof css>) {
|
|
|
470
475
|
* ```
|
|
471
476
|
*/
|
|
472
477
|
export function connectStore(store: Store<any>) {
|
|
473
|
-
return
|
|
478
|
+
return (_: unknown, context: ClassDecoratorContext) => {
|
|
474
479
|
pushStaticField(context, 'observedStores', store);
|
|
475
480
|
};
|
|
476
481
|
}
|
|
@@ -481,14 +486,14 @@ export function shadow({
|
|
|
481
486
|
delegatesFocus,
|
|
482
487
|
slotAssignment,
|
|
483
488
|
}: Partial<ShadowRootInit> = {}) {
|
|
484
|
-
return
|
|
489
|
+
return (_: any, context: ClassDecoratorContext) => {
|
|
485
490
|
const metadata = context.metadata as Metadata;
|
|
486
491
|
assign(metadata, { mode, serializable, delegatesFocus, slotAssignment });
|
|
487
492
|
};
|
|
488
493
|
}
|
|
489
494
|
|
|
490
495
|
export function light({ penetrable }: Pick<Metadata, 'penetrable'>) {
|
|
491
|
-
return
|
|
496
|
+
return (_: any, context: ClassDecoratorContext) => {
|
|
492
497
|
const metadata = context.metadata as Metadata;
|
|
493
498
|
metadata.penetrable = penetrable;
|
|
494
499
|
};
|
|
@@ -499,7 +504,7 @@ export function light({ penetrable }: Pick<Metadata, 'penetrable'>) {
|
|
|
499
504
|
* 例如:https://examples.gemjs.org/async
|
|
500
505
|
*/
|
|
501
506
|
export function async() {
|
|
502
|
-
return
|
|
507
|
+
return (_: any, context: ClassDecoratorContext) => {
|
|
503
508
|
const metadata = context.metadata as Metadata;
|
|
504
509
|
metadata.noBlocking = true;
|
|
505
510
|
};
|
|
@@ -509,7 +514,7 @@ export function async() {
|
|
|
509
514
|
* 定义元素的可访问性属性
|
|
510
515
|
*/
|
|
511
516
|
export function aria(info: Metadata['aria']) {
|
|
512
|
-
return
|
|
517
|
+
return (_: any, context: ClassDecoratorContext) => {
|
|
513
518
|
const metadata = context.metadata as Metadata;
|
|
514
519
|
metadata.aria = { ...metadata.aria, ...info };
|
|
515
520
|
};
|
|
@@ -525,26 +530,9 @@ export function aria(info: Metadata['aria']) {
|
|
|
525
530
|
* ```
|
|
526
531
|
*/
|
|
527
532
|
export function customElement(name: string) {
|
|
528
|
-
return
|
|
529
|
-
addInitializer(
|
|
533
|
+
return (cls: new (...args: any) => any, { addInitializer }: ClassDecoratorContext) => {
|
|
534
|
+
addInitializer(() => {
|
|
530
535
|
customElements.define(name, cls);
|
|
531
536
|
});
|
|
532
537
|
};
|
|
533
538
|
}
|
|
534
|
-
|
|
535
|
-
declare global {
|
|
536
|
-
interface Window {
|
|
537
|
-
__GEM_DEVTOOLS__HOOK__?:
|
|
538
|
-
| (typeof elementExports & typeof decoratorsExports & typeof storeExports & typeof versionExports)
|
|
539
|
-
| Record<string, never>;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
if (window.__GEM_DEVTOOLS__HOOK__ && !window.__GEM_DEVTOOLS__HOOK__.GemElement) {
|
|
544
|
-
assign(window.__GEM_DEVTOOLS__HOOK__, {
|
|
545
|
-
...elementExports,
|
|
546
|
-
...decoratorsExports,
|
|
547
|
-
...storeExports,
|
|
548
|
-
...versionExports,
|
|
549
|
-
});
|
|
550
|
-
}
|
package/src/lib/directive.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {
|
|
|
35
35
|
* This property needs to remain unminified.
|
|
36
36
|
* @internal
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
_$litDirective$: C;
|
|
39
39
|
/** @internal */
|
|
40
40
|
values: DirectiveParameters<InstanceType<C>>;
|
|
41
41
|
}
|
|
@@ -86,7 +86,7 @@ export const directive =
|
|
|
86
86
|
<C extends DirectiveClass>(c: C) =>
|
|
87
87
|
(...values: DirectiveParameters<InstanceType<C>>): DirectiveResult<C> => ({
|
|
88
88
|
// This property needs to remain unminified.
|
|
89
|
-
|
|
89
|
+
_$litDirective$: c,
|
|
90
90
|
values,
|
|
91
91
|
});
|
|
92
92
|
|
|
@@ -111,9 +111,7 @@ export abstract class Directive implements Disconnectable {
|
|
|
111
111
|
_$disconnectableChildren?: Set<Disconnectable>;
|
|
112
112
|
// This property needs to remain unminified.
|
|
113
113
|
//@internal
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
constructor(_partInfo: PartInfo) {}
|
|
114
|
+
_$notifyDirectiveConnectionChanged?(isConnected: boolean): void;
|
|
117
115
|
|
|
118
116
|
// See comment in Disconnectable interface for why this is a getter
|
|
119
117
|
get _$isConnected() {
|