@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/utils.ts
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
const { assign, fromEntries, entries, keys } = Object;
|
|
2
2
|
|
|
3
3
|
const microtaskSet = new Set<() => void>();
|
|
4
|
-
export function addMicrotask(func: () => void) {
|
|
4
|
+
export function addMicrotask(func: () => void, isNodeForceMicrotask?: boolean) {
|
|
5
5
|
if (microtaskSet.has(func)) return;
|
|
6
|
-
|
|
6
|
+
const next = () => {
|
|
7
7
|
microtaskSet.delete(func);
|
|
8
8
|
func();
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
if (isNodeForceMicrotask) {
|
|
11
|
+
process.nextTick(next);
|
|
12
|
+
} else {
|
|
13
|
+
Promise.resolve().then(next);
|
|
14
|
+
}
|
|
10
15
|
microtaskSet.add(func);
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
type OverrideFn = {
|
|
19
|
+
name: never;
|
|
20
|
+
apply: never;
|
|
21
|
+
call: never;
|
|
22
|
+
bind: never;
|
|
23
|
+
toString: never;
|
|
24
|
+
prototype: never;
|
|
25
|
+
length: never;
|
|
26
|
+
arguments: never;
|
|
27
|
+
caller: never;
|
|
28
|
+
[Symbol.hasInstance]: never;
|
|
29
|
+
[Symbol.metadata]: never;
|
|
30
|
+
};
|
|
31
|
+
|
|
13
32
|
// 注意 typeof state === 'function' 但是没有 Function 的方法和属性
|
|
14
33
|
export function createUpdater<T, Fn = (payload?: Partial<T>) => any>(initState: T, fn: Fn) {
|
|
15
34
|
const state: any = fn;
|
|
@@ -18,8 +37,9 @@ export function createUpdater<T, Fn = (payload?: Partial<T>) => any>(initState:
|
|
|
18
37
|
delete state.name;
|
|
19
38
|
delete state.length;
|
|
20
39
|
assign(state, initState);
|
|
21
|
-
//
|
|
22
|
-
|
|
40
|
+
// ts 不允许直接 Omit 掉 Fn 上的属性
|
|
41
|
+
// 只能利用 ts plugin 移除多余的自动完成项
|
|
42
|
+
return state as Fn & Omit<OverrideFn, keyof T> & T;
|
|
23
43
|
}
|
|
24
44
|
|
|
25
45
|
// 不编码 hash 用于比较
|
|
@@ -107,8 +127,10 @@ export class LinkedList<T = any> extends EventTarget {
|
|
|
107
127
|
return this.#map.get(value);
|
|
108
128
|
}
|
|
109
129
|
|
|
110
|
-
|
|
111
|
-
|
|
130
|
+
/**
|
|
131
|
+
* 添加到尾部,已存在时会删除老的项目
|
|
132
|
+
* 如果是添加第一个,start 事件会在添加前触发,避免处理事件重复的逻辑
|
|
133
|
+
*/
|
|
112
134
|
add(value: T) {
|
|
113
135
|
if (!this.#lastItem) {
|
|
114
136
|
this.dispatchEvent(new CustomEvent('start'));
|
|
@@ -126,7 +148,7 @@ export class LinkedList<T = any> extends EventTarget {
|
|
|
126
148
|
this.#map.set(value, item);
|
|
127
149
|
}
|
|
128
150
|
|
|
129
|
-
|
|
151
|
+
/** 删除这个元素后没有其他元素时立即出发 end 事件 */
|
|
130
152
|
delete(value: T) {
|
|
131
153
|
const deleteItem = this.#delete(value);
|
|
132
154
|
if (!this.#firstItem) {
|
|
@@ -135,8 +157,7 @@ export class LinkedList<T = any> extends EventTarget {
|
|
|
135
157
|
return deleteItem;
|
|
136
158
|
}
|
|
137
159
|
|
|
138
|
-
|
|
139
|
-
// 会从链表删除
|
|
160
|
+
/** 获取头部元素,会从链表删除 */
|
|
140
161
|
get(): T | undefined {
|
|
141
162
|
const firstItem = this.#firstItem;
|
|
142
163
|
if (!firstItem) return;
|
|
@@ -157,10 +178,6 @@ export class PropProxyMap<T extends NonPrimitive, V = unknown> extends WeakMap<T
|
|
|
157
178
|
}
|
|
158
179
|
|
|
159
180
|
export class QueryString extends URLSearchParams {
|
|
160
|
-
constructor(param?: any) {
|
|
161
|
-
super(param);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
181
|
// support `{ key: ObjectValue }`
|
|
165
182
|
concat(param: any) {
|
|
166
183
|
let query: any;
|
|
@@ -236,7 +253,7 @@ export function randomStr(len = 5): string {
|
|
|
236
253
|
}
|
|
237
254
|
|
|
238
255
|
export function camelToKebabCase(str: string) {
|
|
239
|
-
return str.replace(/[A-Z]/g,
|
|
256
|
+
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
240
257
|
}
|
|
241
258
|
|
|
242
259
|
export function kebabToCamelCase(str: string) {
|
|
@@ -269,25 +286,18 @@ export function isArrayChange(newValues: any[], oldValues: any[]) {
|
|
|
269
286
|
export function objectMapToString<T = any>(
|
|
270
287
|
object: Record<string, T>,
|
|
271
288
|
separate: string,
|
|
272
|
-
|
|
289
|
+
toStr: (key: string, value: T) => string,
|
|
273
290
|
) {
|
|
274
291
|
let result = separate;
|
|
275
292
|
for (const key in object) {
|
|
276
|
-
const s =
|
|
293
|
+
const s = toStr(key, object[key]);
|
|
277
294
|
result += s ? s + separate : '';
|
|
278
295
|
}
|
|
279
296
|
return result;
|
|
280
297
|
}
|
|
281
298
|
|
|
282
299
|
// Wait: Typescript lib dom CSSStyleDeclaration anchor position
|
|
283
|
-
type StyleProp =
|
|
284
|
-
| keyof CSSStyleDeclaration
|
|
285
|
-
| `--${string}`
|
|
286
|
-
| 'scrollbarWidth'
|
|
287
|
-
| 'scrollbarColor'
|
|
288
|
-
| 'positionAnchor'
|
|
289
|
-
| 'anchorDefault'
|
|
290
|
-
| 'anchorName';
|
|
300
|
+
type StyleProp = keyof CSSStyleDeclaration | `--${string}` | 'positionAnchor' | 'anchorDefault' | 'anchorName';
|
|
291
301
|
|
|
292
302
|
export type StyleObject = Partial<Record<StyleProp, string | number | false | undefined | null>>;
|
|
293
303
|
|
|
@@ -310,8 +320,3 @@ export function exportPartsMap(object: Record<string, string | boolean | undefin
|
|
|
310
320
|
value === true || key === value ? key : value ? `${key}:${value}` : '',
|
|
311
321
|
);
|
|
312
322
|
}
|
|
313
|
-
|
|
314
|
-
declare global {
|
|
315
|
-
interface PropertyIndexedKeyframes extends StyleObject {}
|
|
316
|
-
interface Keyframe extends StyleObject {}
|
|
317
|
-
}
|
package/src/lib/version.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const version = '0.0.0';
|
|
1
|
+
export const version = '2.2.1';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fixture, expect } from '../utils';
|
|
2
|
-
import { html } from '../../lib/element';
|
|
3
1
|
import type { GemActiveLinkElement } from '../../elements/link';
|
|
2
|
+
import { html } from '../../lib/element';
|
|
3
|
+
import { expect, fixture } from '../utils';
|
|
4
4
|
|
|
5
5
|
import '../../elements/link';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { fixture, expect, nextFrame } from '../utils';
|
|
2
|
-
import { css, GemElement, html } from '../../lib/element';
|
|
3
|
-
import { adoptedStyle, customElement } from '../../lib/decorators';
|
|
4
1
|
import type { GemReflectElement } from '../../elements/reflect';
|
|
2
|
+
import { adoptedStyle, customElement } from '../../lib/decorators';
|
|
3
|
+
import { css, GemElement, html } from '../../lib/element';
|
|
4
|
+
import { expect, fixture, nextFrame } from '../utils';
|
|
5
5
|
|
|
6
6
|
import '../../elements/reflect';
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fixture, expect, nextFrame } from '../utils';
|
|
2
|
-
import { html } from '../../lib/element';
|
|
3
1
|
import type { GemTitleElement } from '../../elements/title';
|
|
2
|
+
import { html } from '../../lib/element';
|
|
3
|
+
import { expect, fixture, nextFrame } from '../utils';
|
|
4
4
|
|
|
5
5
|
import '../../elements/title';
|
|
6
6
|
|
|
@@ -6,21 +6,22 @@
|
|
|
6
6
|
* - 派生元素(类扩展)
|
|
7
7
|
* - 无渲染内容 Gem 元素
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
import type { Metadata } from '../../lib/element';
|
|
11
|
-
import { css, createState, GemElement, html, createRef } from '../../lib/element';
|
|
12
|
-
import { createStore } from '../../lib/store';
|
|
9
|
+
|
|
13
10
|
import {
|
|
11
|
+
adoptedStyle,
|
|
12
|
+
async,
|
|
14
13
|
attribute,
|
|
15
|
-
|
|
14
|
+
connectStore,
|
|
16
15
|
customElement,
|
|
17
16
|
emitter,
|
|
18
|
-
adoptedStyle,
|
|
19
|
-
connectStore,
|
|
20
|
-
async,
|
|
21
|
-
shadow,
|
|
22
17
|
mounted,
|
|
18
|
+
property,
|
|
19
|
+
shadow,
|
|
23
20
|
} from '../../lib/decorators';
|
|
21
|
+
import type { Metadata } from '../../lib/element';
|
|
22
|
+
import { createRef, createState, css, GemElement, html } from '../../lib/element';
|
|
23
|
+
import { createStore } from '../../lib/store';
|
|
24
|
+
import { expect, fixture, nextFrame } from '../utils';
|
|
24
25
|
|
|
25
26
|
const store = createStore({
|
|
26
27
|
a: 1,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { fixture, expect, nextFrame } from '../utils';
|
|
2
|
-
import { css, createState, GemElement, html } from '../../lib/element';
|
|
3
|
-
import { createStore } from '../../lib/store';
|
|
4
1
|
import {
|
|
5
2
|
adoptedStyle,
|
|
6
3
|
attribute,
|
|
@@ -12,6 +9,9 @@ import {
|
|
|
12
9
|
property,
|
|
13
10
|
shadow,
|
|
14
11
|
} from '../../lib/decorators';
|
|
12
|
+
import { createState, css, GemElement, html } from '../../lib/element';
|
|
13
|
+
import { createStore } from '../../lib/store';
|
|
14
|
+
import { expect, fixture, nextFrame } from '../utils';
|
|
15
15
|
|
|
16
16
|
const store = createStore({
|
|
17
17
|
a: 1,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { fixture, expect } from '../utils';
|
|
2
|
-
import type { Metadata } from '../../lib/element';
|
|
3
|
-
import { css, GemElement, html } from '../../lib/element';
|
|
4
|
-
import { createStore } from '../../lib/store';
|
|
5
1
|
import type { Emitter } from '../../lib/decorators';
|
|
6
2
|
import {
|
|
3
|
+
adoptedStyle,
|
|
7
4
|
attribute,
|
|
8
|
-
|
|
9
|
-
customElement,
|
|
5
|
+
boolattribute,
|
|
10
6
|
connectStore,
|
|
11
|
-
|
|
7
|
+
customElement,
|
|
12
8
|
emitter,
|
|
13
|
-
boolattribute,
|
|
14
9
|
numattribute,
|
|
15
10
|
part,
|
|
11
|
+
property,
|
|
12
|
+
shadow,
|
|
16
13
|
slot,
|
|
17
14
|
state,
|
|
18
|
-
shadow,
|
|
19
15
|
} from '../../lib/decorators';
|
|
16
|
+
import type { Metadata } from '../../lib/element';
|
|
17
|
+
import { css, GemElement, html } from '../../lib/element';
|
|
18
|
+
import { createStore } from '../../lib/store';
|
|
19
|
+
import { expect, fixture } from '../utils';
|
|
20
20
|
|
|
21
21
|
const store = createStore({
|
|
22
22
|
a: 1,
|
|
@@ -81,7 +81,7 @@ describe('装饰器', () => {
|
|
|
81
81
|
store({ a: 1 });
|
|
82
82
|
await Promise.resolve();
|
|
83
83
|
const metadata: Metadata = Reflect.get(DecoratorGemElement, Symbol.metadata);
|
|
84
|
-
expect({ ...metadata.observedStores
|
|
84
|
+
expect({ ...metadata.observedStores?.at(0) }).to.eql({ a: 1 });
|
|
85
85
|
expect(metadata.observedAttributes).to.eql(['rank-attr', 'rank-disabled', 'rank-count']);
|
|
86
86
|
expect(metadata.definedEvents).to.eql(['say-hi']);
|
|
87
87
|
expect(metadata.definedCSSStates).to.eql(['open-state']);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { attribute, customElement, type Emitter, emitter, mounted, property } from '../../lib/decorators';
|
|
2
|
+
import { createRef, createState, GemElement, html } from '../../lib/element';
|
|
1
3
|
import { expect, fixture } from '../utils';
|
|
2
|
-
import { attribute, customElement, emitter, mounted, property, type Emitter } from '../../lib/decorators';
|
|
3
|
-
import { GemElement, html, createRef, createState } from '../../lib/element';
|
|
4
4
|
|
|
5
5
|
@customElement('app-children')
|
|
6
6
|
export class Children extends GemElement {
|
package/src/test/history.test.ts
CHANGED
package/src/test/store.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { _StoreListenerMap,
|
|
2
|
-
|
|
3
|
-
import { expect, aTimeout } from './utils';
|
|
1
|
+
import { _StoreListenerMap, connect, createStore } from '../lib/store';
|
|
2
|
+
import { aTimeout, expect } from './utils';
|
|
4
3
|
|
|
5
4
|
describe('store 测试', () => {
|
|
6
5
|
it('create store', () => {
|
package/src/test/utils.test.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { css, SheetToken } from '../lib/element';
|
|
2
2
|
import {
|
|
3
|
+
absoluteLocation,
|
|
4
|
+
classMap,
|
|
5
|
+
exportPartsMap,
|
|
3
6
|
LinkedList,
|
|
4
7
|
QueryString,
|
|
5
8
|
raw,
|
|
6
9
|
styled,
|
|
7
10
|
styleMap,
|
|
8
|
-
classMap,
|
|
9
|
-
exportPartsMap,
|
|
10
|
-
absoluteLocation,
|
|
11
11
|
} from '../lib/utils';
|
|
12
|
-
|
|
13
12
|
import { expect } from './utils';
|
|
14
13
|
|
|
15
14
|
declare global {
|
|
@@ -77,7 +76,7 @@ describe('utils 测试', () => {
|
|
|
77
76
|
query.setAny('obj', [{ a: 1, b: 2 }]);
|
|
78
77
|
expect(query.getAny('obj')).to.deep.equal({ a: 1, b: 2 });
|
|
79
78
|
expect(query.getAnyAll('obj')).to.deep.equal([{ a: 1, b: 2 }]);
|
|
80
|
-
expect(new QueryString({ a: 1 }).toString()).to.equal('?a=1');
|
|
79
|
+
expect(new QueryString({ a: '1' }).toString()).to.equal('?a=1');
|
|
81
80
|
expect(new QueryString(query).toString()).to.equal(query.toString());
|
|
82
81
|
});
|
|
83
82
|
it('css', () => {
|
package/src/test/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { expect, should
|
|
1
|
+
import { assert, expect, should } from 'chai';
|
|
2
2
|
|
|
3
|
-
import { render } from '../lib/element';
|
|
4
3
|
import type { TemplateResult } from '../lib/element';
|
|
4
|
+
import { render } from '../lib/element';
|
|
5
5
|
|
|
6
6
|
export { expect, should, assert };
|
|
7
7
|
|
package/helper/react-shim.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Store } from '../lib/store';
|
|
3
|
-
/**
|
|
4
|
-
* `<gem-route>.routes.getContent`
|
|
5
|
-
*/
|
|
6
|
-
export declare function renderReactNode(ele: any, node: ReactNode): void;
|
|
7
|
-
/**
|
|
8
|
-
* Same as `@connectStore`
|
|
9
|
-
*/
|
|
10
|
-
export declare function connectStore<T extends object>(store: Store<T>): void;
|
|
11
|
-
/**
|
|
12
|
-
* Warning: https://github.com/facebook/react/issues/25675
|
|
13
|
-
*/
|
|
14
|
-
export declare function useReactNode(node: ReactNode): any;
|
|
15
|
-
//# sourceMappingURL=react-shim.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-shim.d.ts","sourceRoot":"","sources":["../src/helper/react-shim.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAM/D,OAAO,EAAE,KAAK,EAAW,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,QAgBxD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,QAG7D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,OAe3C"}
|
package/helper/react-shim.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
// eslint-disable-next-line import/no-unresolved
|
|
4
|
-
import { useEffect, useRef, useState } from 'react';
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
// eslint-disable-next-line import/no-unresolved
|
|
8
|
-
import { createRoot } from 'react-dom/client';
|
|
9
|
-
import { connect } from '../lib/store';
|
|
10
|
-
/**
|
|
11
|
-
* `<gem-route>.routes.getContent`
|
|
12
|
-
*/
|
|
13
|
-
export function renderReactNode(ele, node) {
|
|
14
|
-
var _a;
|
|
15
|
-
(_a = ele.react) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
16
|
-
ele.react = createRoot(ele);
|
|
17
|
-
// async
|
|
18
|
-
ele.react.render(node);
|
|
19
|
-
// override
|
|
20
|
-
const routeEle = ele instanceof HTMLElement ? ele : ele.host;
|
|
21
|
-
const originUnmounted = routeEle.unmounted;
|
|
22
|
-
if (!(originUnmounted === null || originUnmounted === void 0 ? void 0 : originUnmounted.react)) {
|
|
23
|
-
routeEle.unmounted = () => {
|
|
24
|
-
originUnmounted === null || originUnmounted === void 0 ? void 0 : originUnmounted.apply(routeEle);
|
|
25
|
-
ele.react.unmount();
|
|
26
|
-
};
|
|
27
|
-
routeEle.unmounted.react = true;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Same as `@connectStore`
|
|
32
|
-
*/
|
|
33
|
-
export function connectStore(store) {
|
|
34
|
-
const [_, update] = useState({});
|
|
35
|
-
useEffect(() => connect(store, () => update({})), []);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Warning: https://github.com/facebook/react/issues/25675
|
|
39
|
-
*/
|
|
40
|
-
export function useReactNode(node) {
|
|
41
|
-
const ref = useRef();
|
|
42
|
-
// Warning: Attempted to synchronously unmount a root while React was already rendering. React cannot finish unmounting the root until the current render has completed, which may lead to a race condition.
|
|
43
|
-
useEffect(() => () => { var _a; return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.root.unmount(); }, []);
|
|
44
|
-
if (ref.current) {
|
|
45
|
-
ref.current.root.render(node);
|
|
46
|
-
return ref.current.container;
|
|
47
|
-
}
|
|
48
|
-
const container = document.createElement('div');
|
|
49
|
-
container.style.display = 'contents';
|
|
50
|
-
const root = createRoot(container);
|
|
51
|
-
ref.current = { root, container };
|
|
52
|
-
// Warning: Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate.
|
|
53
|
-
root.render(node);
|
|
54
|
-
return container;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=react-shim.js.map
|
package/helper/react-shim.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-shim.js","sourceRoot":"","sources":["../src/helper/react-shim.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,aAAa;AACb,gDAAgD;AAChD,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,6DAA6D;AAC7D,aAAa;AACb,gDAAgD;AAChD,OAAO,EAAQ,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAS,OAAO,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAQ,EAAE,IAAe;;IACvD,MAAA,GAAG,CAAC,KAAK,0CAAE,OAAO,EAAE,CAAC;IACrB,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5B,QAAQ;IACR,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEvB,WAAW;IACX,MAAM,QAAQ,GAAG,GAAG,YAAY,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,SAAS,CAAC;IAC3C,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,CAAA,EAAE,CAAC;QAC5B,QAAQ,CAAC,SAAS,GAAG,GAAG,EAAE;YACxB,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;YACjC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC,CAAC;QACF,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC;IAClC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAmB,KAAe;IAC5D,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjC,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAe;IAC1C,MAAM,GAAG,GAAG,MAAM,EAA0C,CAAC;IAC7D,4MAA4M;IAC5M,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,WAAC,OAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,IAAI,CAAC,OAAO,EAAE,CAAA,EAAA,EAAE,EAAE,CAAC,CAAC;IACvD,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAChB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC;IAC/B,CAAC;IACD,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC;IACrC,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACnC,GAAG,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAClC,oMAAoM;IACpM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/directives.d.ts
DELETED
package/lib/directives.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/lib/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC"}
|
package/lib/directives.js
DELETED
package/lib/directives.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../src/lib/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,kDAAkD;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC"}
|
package/lib/ref.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=ref.d.ts.map
|
package/lib/ref.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../src/lib/ref.ts"],"names":[],"mappings":""}
|
package/lib/ref.js
DELETED
package/lib/ref.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../src/lib/ref.ts"],"names":[],"mappings":""}
|