@toyz/loom 0.1.2 → 0.2.0
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/decorators/create.d.ts +56 -0
- package/dist/decorators/create.d.ts.map +1 -0
- package/dist/decorators/create.js +72 -0
- package/dist/decorators/create.js.map +1 -0
- package/dist/decorators/events.d.ts +6 -9
- package/dist/decorators/events.d.ts.map +1 -1
- package/dist/decorators/events.js +27 -22
- package/dist/decorators/events.js.map +1 -1
- package/dist/decorators/index.d.ts +13 -13
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +20 -21
- package/dist/decorators/index.js.map +1 -1
- package/dist/{decorators/di.d.ts → di/decorators.d.ts} +10 -3
- package/dist/di/decorators.d.ts.map +1 -0
- package/dist/{decorators/di.js → di/decorators.js} +16 -10
- package/dist/di/decorators.js.map +1 -0
- package/dist/di/index.d.ts +8 -0
- package/dist/di/index.d.ts.map +1 -0
- package/dist/di/index.js +10 -0
- package/dist/di/index.js.map +1 -0
- package/dist/di/watch.d.ts +23 -0
- package/dist/di/watch.d.ts.map +1 -0
- package/dist/di/watch.js +41 -0
- package/dist/di/watch.js.map +1 -0
- package/dist/element/decorators.d.ts +32 -0
- package/dist/element/decorators.d.ts.map +1 -0
- package/dist/element/decorators.js +72 -0
- package/dist/element/decorators.js.map +1 -0
- package/dist/{element.d.ts → element/element.d.ts} +5 -11
- package/dist/element/element.d.ts.map +1 -0
- package/dist/{element.js → element/element.js} +8 -34
- package/dist/element/element.js.map +1 -0
- package/dist/element/icon.d.ts.map +1 -0
- package/dist/{icon.js → element/icon.js} +3 -2
- package/dist/element/icon.js.map +1 -0
- package/dist/element/index.d.ts +11 -0
- package/dist/element/index.d.ts.map +1 -0
- package/dist/element/index.js +14 -0
- package/dist/element/index.js.map +1 -0
- package/dist/{decorators → element}/lifecycle.d.ts +9 -1
- package/dist/element/lifecycle.d.ts.map +1 -0
- package/dist/{decorators → element}/lifecycle.js +50 -35
- package/dist/element/lifecycle.js.map +1 -0
- package/dist/element/timing.d.ts +65 -0
- package/dist/element/timing.d.ts.map +1 -0
- package/dist/element/timing.js +116 -0
- package/dist/element/timing.js.map +1 -0
- package/dist/element/virtual.d.ts.map +1 -0
- package/dist/{virtual.js → element/virtual.js} +1 -1
- package/dist/element/virtual.js.map +1 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/router/decorators.d.ts +50 -0
- package/dist/router/decorators.d.ts.map +1 -0
- package/dist/router/decorators.js +84 -0
- package/dist/router/decorators.js.map +1 -0
- package/dist/router/index.d.ts +4 -3
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +6 -4
- package/dist/router/index.js.map +1 -1
- package/dist/router/outlet.d.ts +1 -1
- package/dist/router/outlet.d.ts.map +1 -1
- package/dist/router/outlet.js +2 -2
- package/dist/router/outlet.js.map +1 -1
- package/dist/router/route.d.ts +16 -47
- package/dist/router/route.d.ts.map +1 -1
- package/dist/router/route.js +5 -102
- package/dist/router/route.js.map +1 -1
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +2 -1
- package/dist/router/router.js.map +1 -1
- package/dist/{decorators/state.d.ts → store/decorators.d.ts} +8 -1
- package/dist/store/decorators.d.ts.map +1 -0
- package/dist/{decorators/state.js → store/decorators.js} +13 -4
- package/dist/store/decorators.js.map +1 -0
- package/dist/store/index.d.ts +12 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +14 -0
- package/dist/store/index.js.map +1 -0
- package/dist/{reactive.d.ts → store/reactive.d.ts} +7 -5
- package/dist/store/reactive.d.ts.map +1 -0
- package/dist/{reactive.js → store/reactive.js} +9 -5
- package/dist/store/reactive.js.map +1 -0
- package/dist/store/storage.d.ts +53 -0
- package/dist/store/storage.d.ts.map +1 -0
- package/dist/store/storage.js +78 -0
- package/dist/store/storage.js.map +1 -0
- package/dist/store/watch.d.ts +27 -0
- package/dist/store/watch.d.ts.map +1 -0
- package/dist/store/watch.js +30 -0
- package/dist/store/watch.js.map +1 -0
- package/dist/transform/built-in.d.ts +36 -0
- package/dist/transform/built-in.d.ts.map +1 -0
- package/dist/transform/built-in.js +37 -0
- package/dist/transform/built-in.js.map +1 -0
- package/dist/transform/create.d.ts +19 -0
- package/dist/transform/create.d.ts.map +1 -0
- package/dist/transform/create.js +27 -0
- package/dist/transform/create.js.map +1 -0
- package/dist/transform/index.d.ts +11 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +14 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/transform.d.ts +14 -0
- package/dist/transform/transform.d.ts.map +1 -0
- package/dist/transform/transform.js +21 -0
- package/dist/transform/transform.js.map +1 -0
- package/dist/transform/typed.d.ts +40 -0
- package/dist/transform/typed.d.ts.map +1 -0
- package/dist/transform/typed.js +55 -0
- package/dist/transform/typed.js.map +1 -0
- package/package.json +35 -3
- package/dist/decorators/component.d.ts +0 -11
- package/dist/decorators/component.d.ts.map +0 -1
- package/dist/decorators/component.js +0 -38
- package/dist/decorators/component.js.map +0 -1
- package/dist/decorators/di.d.ts.map +0 -1
- package/dist/decorators/di.js.map +0 -1
- package/dist/decorators/dom.d.ts +0 -15
- package/dist/decorators/dom.d.ts.map +0 -1
- package/dist/decorators/dom.js +0 -33
- package/dist/decorators/dom.js.map +0 -1
- package/dist/decorators/lifecycle.d.ts.map +0 -1
- package/dist/decorators/lifecycle.js.map +0 -1
- package/dist/decorators/state.d.ts.map +0 -1
- package/dist/decorators/state.js.map +0 -1
- package/dist/decorators/timing.d.ts +0 -35
- package/dist/decorators/timing.d.ts.map +0 -1
- package/dist/decorators/timing.js +0 -57
- package/dist/decorators/timing.js.map +0 -1
- package/dist/decorators/transform.d.ts +0 -45
- package/dist/decorators/transform.d.ts.map +0 -1
- package/dist/decorators/transform.js +0 -48
- package/dist/decorators/transform.js.map +0 -1
- package/dist/element.d.ts.map +0 -1
- package/dist/element.js.map +0 -1
- package/dist/icon.d.ts.map +0 -1
- package/dist/icon.js.map +0 -1
- package/dist/reactive.d.ts.map +0 -1
- package/dist/reactive.js.map +0 -1
- package/dist/storage.d.ts +0 -55
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js +0 -90
- package/dist/storage.js.map +0 -1
- package/dist/virtual.d.ts.map +0 -1
- package/dist/virtual.js.map +0 -1
- /package/dist/{icon.d.ts → element/icon.d.ts} +0 -0
- /package/dist/{virtual.d.ts → element/virtual.d.ts} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createDecorator — Universal decorator factory.
|
|
3
|
+
*
|
|
4
|
+
* The foundation every Loom decorator is built on.
|
|
5
|
+
*
|
|
6
|
+
* Setup runs at **define-time** (on the prototype or constructor).
|
|
7
|
+
* If setup returns a function, it runs **per-instance on connect**.
|
|
8
|
+
* If the connect function returns a function, it runs **on disconnect**.
|
|
9
|
+
*
|
|
10
|
+
* Flow: define → connect → disconnect
|
|
11
|
+
*
|
|
12
|
+
* @typeParam Args — Tuple of decorator argument types
|
|
13
|
+
* @typeParam T — Element type (default: any)
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* // Define-time only — property getter
|
|
17
|
+
* const query = createDecorator<[sel: string]>((proto, key, sel) => {
|
|
18
|
+
* Object.defineProperty(proto, key, {
|
|
19
|
+
* get() { return this.shadow.querySelector(sel); }
|
|
20
|
+
* });
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Lifecycle only — setup on connect, cleanup on disconnect
|
|
24
|
+
* const interval = createDecorator<[ms: number]>((proto, key, ms) => {
|
|
25
|
+
* return (el) => {
|
|
26
|
+
* const id = setInterval(() => el[key](), ms);
|
|
27
|
+
* return () => clearInterval(id);
|
|
28
|
+
* };
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Both — define-time work + lifecycle
|
|
32
|
+
* const on = createDecorator<[Type: any]>((proto, key, Type) => {
|
|
33
|
+
* // define-time: store metadata, modify prototype, etc.
|
|
34
|
+
* return (el) => bus.on(Type, (e) => el[key](e));
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Class decorator
|
|
38
|
+
* const component = createDecorator<[tag: string]>((ctor, tag) => {
|
|
39
|
+
* app.register(tag, ctor);
|
|
40
|
+
* }, { class: true });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
type ConnectFn = (element: any) => void | (() => void);
|
|
44
|
+
type PropertySetup<Args extends any[]> = (proto: any, key: string, ...args: Args) => void | ConnectFn;
|
|
45
|
+
type ClassSetup<Args extends any[]> = (ctor: any, ...args: Args) => void;
|
|
46
|
+
export interface DecoratorOptions {
|
|
47
|
+
class?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare function createDecorator<Args extends any[] = [], T = any>(setup: ClassSetup<Args>, options: {
|
|
50
|
+
class: true;
|
|
51
|
+
}): (...args: Args) => (ctor: any) => void;
|
|
52
|
+
export declare function createDecorator<Args extends any[] = [], T = any>(setup: PropertySetup<Args>, options?: {
|
|
53
|
+
class?: false;
|
|
54
|
+
}): (...args: Args) => (target: any, key: string, desc?: PropertyDescriptor) => void;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/decorators/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AACvD,KAAK,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,SAAS,CAAC;AAEtG,KAAK,UAAU,CAAC,IAAI,SAAS,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAGD,wBAAgB,eAAe,CAAC,IAAI,SAAS,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,EAC9D,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,EACvB,OAAO,EAAE;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GACvB,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAG1C,wBAAgB,eAAe,CAAC,IAAI,SAAS,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,EAC9D,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,EAC1B,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC1B,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createDecorator — Universal decorator factory.
|
|
3
|
+
*
|
|
4
|
+
* The foundation every Loom decorator is built on.
|
|
5
|
+
*
|
|
6
|
+
* Setup runs at **define-time** (on the prototype or constructor).
|
|
7
|
+
* If setup returns a function, it runs **per-instance on connect**.
|
|
8
|
+
* If the connect function returns a function, it runs **on disconnect**.
|
|
9
|
+
*
|
|
10
|
+
* Flow: define → connect → disconnect
|
|
11
|
+
*
|
|
12
|
+
* @typeParam Args — Tuple of decorator argument types
|
|
13
|
+
* @typeParam T — Element type (default: any)
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* // Define-time only — property getter
|
|
17
|
+
* const query = createDecorator<[sel: string]>((proto, key, sel) => {
|
|
18
|
+
* Object.defineProperty(proto, key, {
|
|
19
|
+
* get() { return this.shadow.querySelector(sel); }
|
|
20
|
+
* });
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Lifecycle only — setup on connect, cleanup on disconnect
|
|
24
|
+
* const interval = createDecorator<[ms: number]>((proto, key, ms) => {
|
|
25
|
+
* return (el) => {
|
|
26
|
+
* const id = setInterval(() => el[key](), ms);
|
|
27
|
+
* return () => clearInterval(id);
|
|
28
|
+
* };
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Both — define-time work + lifecycle
|
|
32
|
+
* const on = createDecorator<[Type: any]>((proto, key, Type) => {
|
|
33
|
+
* // define-time: store metadata, modify prototype, etc.
|
|
34
|
+
* return (el) => bus.on(Type, (e) => el[key](e));
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Class decorator
|
|
38
|
+
* const component = createDecorator<[tag: string]>((ctor, tag) => {
|
|
39
|
+
* app.register(tag, ctor);
|
|
40
|
+
* }, { class: true });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
// Implementation
|
|
44
|
+
export function createDecorator(setup, options = { class: false }) {
|
|
45
|
+
if (options.class) {
|
|
46
|
+
// Class decorator: (...args) => (ctor) => void
|
|
47
|
+
return (...args) => {
|
|
48
|
+
return (ctor) => {
|
|
49
|
+
setup(ctor, ...args);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Property/method decorator: (...args) => (target, key, desc?) => void
|
|
54
|
+
return (...args) => {
|
|
55
|
+
return (target, key, desc) => {
|
|
56
|
+
const connectFn = desc
|
|
57
|
+
? setup(target, key, desc, ...args)
|
|
58
|
+
: setup(target, key, ...args);
|
|
59
|
+
if (typeof connectFn === "function") {
|
|
60
|
+
// Has lifecycle — wire into connectedCallback
|
|
61
|
+
const orig = target.connectedCallback;
|
|
62
|
+
target.connectedCallback = function () {
|
|
63
|
+
orig?.call(this);
|
|
64
|
+
const cleanup = connectFn(this);
|
|
65
|
+
if (cleanup)
|
|
66
|
+
this.track(cleanup);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/decorators/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAuBH,iBAAiB;AACjB,MAAM,UAAU,eAAe,CAC7B,KAA8B,EAC9B,UAA4B,EAAE,KAAK,EAAE,KAAK,EAAE;IAE5C,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,+CAA+C;QAC/C,OAAO,CAAC,GAAG,IAAU,EAAE,EAAE;YACvB,OAAO,CAAC,IAAS,EAAE,EAAE;gBAClB,KAA0B,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;YAC7C,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,uEAAuE;IACvE,OAAO,CAAC,GAAG,IAAU,EAAE,EAAE;QACvB,OAAO,CAAC,MAAW,EAAE,GAAW,EAAE,IAAyB,EAAE,EAAE;YAC7D,MAAM,SAAS,GAAG,IAAI;gBACpB,CAAC,CAAE,KAA2B,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;gBAC1D,CAAC,CAAE,KAA6B,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;YAEzD,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;gBACpC,8CAA8C;gBAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC;gBACtC,MAAM,CAAC,iBAAiB,GAAG;oBACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;oBACjB,MAAM,OAAO,GAAI,SAAuB,CAAC,IAAI,CAAC,CAAC;oBAC/C,IAAI,OAAO;wBAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACnC,CAAC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Event decorators
|
|
3
|
+
*
|
|
4
|
+
* @on — Declarative event subscription (bus events or DOM events)
|
|
5
|
+
* @emit — Auto-broadcast to the bus (field or method form)
|
|
6
|
+
*/
|
|
1
7
|
import { LoomEvent } from "../event";
|
|
2
8
|
import { type Constructor } from "../bus";
|
|
3
9
|
/**
|
|
@@ -17,15 +23,6 @@ import { type Constructor } from "../bus";
|
|
|
17
23
|
*/
|
|
18
24
|
export declare function on<T extends LoomEvent>(type: Constructor<T>): (target: any, key: string) => void;
|
|
19
25
|
export declare function on(target: EventTarget, event: string): (target: any, key: string) => void;
|
|
20
|
-
/**
|
|
21
|
-
* React to specific field changes. Receives new and previous values.
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* @watch("value")
|
|
25
|
-
* onValueChange(newVal: number, oldVal: number) { ... }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function watch(field: string): (target: any, key: string) => void;
|
|
29
26
|
/**
|
|
30
27
|
* Auto-broadcast to the bus.
|
|
31
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/decorators/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/decorators/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAO,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,EAAE,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAClG,wBAAgB,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AA4B3F;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,EACtC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,IAEjB,QAAQ,GAAG,EAAE,KAAK,MAAM,EAAE,OAAO,kBAAkB,UAe5D"}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Event decorators
|
|
3
|
+
*
|
|
4
|
+
* @on — Declarative event subscription (bus events or DOM events)
|
|
5
|
+
* @emit — Auto-broadcast to the bus (field or method form)
|
|
6
|
+
*/
|
|
7
|
+
import { EMITTERS, ON_HANDLERS } from "./symbols";
|
|
2
8
|
import { LoomEvent } from "../event";
|
|
3
9
|
import { bus } from "../bus";
|
|
4
10
|
export function on(typeOrTarget, event) {
|
|
5
11
|
return (target, key) => {
|
|
12
|
+
// Store metadata for service wiring by app.start()
|
|
6
13
|
if (!target[ON_HANDLERS])
|
|
7
14
|
target[ON_HANDLERS] = [];
|
|
8
15
|
if (event !== undefined) {
|
|
9
|
-
|
|
10
|
-
target[ON_HANDLERS].push({ domTarget: typeOrTarget, event, key });
|
|
16
|
+
target[ON_HANDLERS].push({ key, domTarget: typeOrTarget, event });
|
|
11
17
|
}
|
|
12
18
|
else {
|
|
13
|
-
|
|
14
|
-
target[ON_HANDLERS].push({ type: typeOrTarget, key });
|
|
19
|
+
target[ON_HANDLERS].push({ key, type: typeOrTarget });
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
// Patch connectedCallback for LoomElement self-wiring
|
|
22
|
+
const orig = target.connectedCallback;
|
|
23
|
+
target.connectedCallback = function () {
|
|
24
|
+
orig?.call(this);
|
|
25
|
+
if (event !== undefined) {
|
|
26
|
+
// DOM EventTarget: @on(window, "resize")
|
|
27
|
+
const fn = (e) => this[key](e);
|
|
28
|
+
typeOrTarget.addEventListener(event, fn);
|
|
29
|
+
this.track(() => typeOrTarget.removeEventListener(event, fn));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// Bus event: @on(ColorSelect)
|
|
33
|
+
this.track(bus.on(typeOrTarget, (e) => this[key](e)));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
@@ -49,7 +54,7 @@ export function watch(field) {
|
|
|
49
54
|
export function emit(_type, factory) {
|
|
50
55
|
return (target, key, desc) => {
|
|
51
56
|
if (desc?.value) {
|
|
52
|
-
// Method decorator — wrap, emit return value
|
|
57
|
+
// Method decorator — wrap, emit return value (define-time)
|
|
53
58
|
const orig = desc.value;
|
|
54
59
|
desc.value = function (...args) {
|
|
55
60
|
const result = orig.apply(this, args);
|
|
@@ -59,7 +64,7 @@ export function emit(_type, factory) {
|
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
66
|
else {
|
|
62
|
-
// Field decorator —
|
|
67
|
+
// Field decorator — store metadata for @reactive subscriber wiring (define-time)
|
|
63
68
|
if (!target[EMITTERS])
|
|
64
69
|
target[EMITTERS] = [];
|
|
65
70
|
target[EMITTERS].push({ field: key, factory });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/decorators/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/decorators/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,GAAG,EAAoB,MAAM,QAAQ,CAAC;AAmB/C,MAAM,UAAU,EAAE,CAAC,YAAiB,EAAE,KAAc;IAClD,OAAO,CAAC,MAAW,EAAE,GAAW,EAAE,EAAE;QAClC,mDAAmD;QACnD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAAE,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;QACpE,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,sDAAsD;QACtD,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACtC,MAAM,CAAC,iBAAiB,GAAG;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,yCAAyC;gBACzC,MAAM,EAAE,GAAG,CAAC,CAAQ,EAAE,EAAE,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC/C,YAAY,CAAC,gBAAgB,CAAC,KAAK,EAAE,EAAE,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3
|
*
|
|
4
|
-
* Barrel re-export for the full decorator arsenal
|
|
5
|
-
*
|
|
6
|
-
* @query, @queryAll, @catch_, @suspend, @mount, @unmount,
|
|
7
|
-
* @interval, @timeout, @animationFrame, @service, @inject, @factory
|
|
4
|
+
* Barrel re-export for the full decorator arsenal.
|
|
5
|
+
* Re-exports from domain folders so imports from "@toyz/loom/decorators" still work.
|
|
8
6
|
*/
|
|
9
|
-
export { REACTIVES, PROPS,
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
7
|
+
export { REACTIVES, PROPS, WATCHERS, EMITTERS, COMPUTED_DIRTY, CATCH_HANDLER, INJECT_PARAMS, ON_HANDLERS, ROUTE_PROPS, TRANSFORMS, } from "./symbols";
|
|
8
|
+
export { createDecorator } from "./create";
|
|
9
|
+
export { on, emit } from "./events";
|
|
10
|
+
export { reactive, prop, computed, params, routeQuery, watch } from "../store";
|
|
11
|
+
export { service, inject, factory } from "../di";
|
|
12
|
+
export { watch as watchService } from "../di";
|
|
13
|
+
export { component, query, queryAll } from "../element";
|
|
14
|
+
export { catch_, suspend, mount, unmount } from "../element";
|
|
15
|
+
export { interval, timeout, debounce, throttle, animationFrame } from "../element";
|
|
16
|
+
export { transform, createTransform, typed, typedTransformer } from "../transform";
|
|
17
|
+
export { toNumber, toBoolean, toDate, toJSON, toTrimmed, toInt, toFloat } from "../transform";
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKpC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAG/E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGnF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Loom — Decorators
|
|
3
3
|
*
|
|
4
|
-
* Barrel re-export for the full decorator arsenal
|
|
5
|
-
*
|
|
6
|
-
* @query, @queryAll, @catch_, @suspend, @mount, @unmount,
|
|
7
|
-
* @interval, @timeout, @animationFrame, @service, @inject, @factory
|
|
4
|
+
* Barrel re-export for the full decorator arsenal.
|
|
5
|
+
* Re-exports from domain folders so imports from "@toyz/loom/decorators" still work.
|
|
8
6
|
*/
|
|
9
7
|
// Symbols (consumed by LoomElement and App)
|
|
10
|
-
export { REACTIVES, PROPS,
|
|
11
|
-
//
|
|
12
|
-
export {
|
|
13
|
-
//
|
|
14
|
-
export {
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
//
|
|
22
|
-
export {
|
|
23
|
-
|
|
24
|
-
export { interval, timeout, animationFrame } from "
|
|
25
|
-
//
|
|
26
|
-
export {
|
|
8
|
+
export { REACTIVES, PROPS, WATCHERS, EMITTERS, COMPUTED_DIRTY, CATCH_HANDLER, INJECT_PARAMS, ON_HANDLERS, ROUTE_PROPS, TRANSFORMS, } from "./symbols";
|
|
9
|
+
// Decorator factory (public API for user-defined decorators)
|
|
10
|
+
export { createDecorator } from "./create";
|
|
11
|
+
// Event system (stays in decorators/)
|
|
12
|
+
export { on, emit } from "./events";
|
|
13
|
+
// ── Re-exports from domain folders ──
|
|
14
|
+
// Store: reactive state, persistence, @watch(field/store)
|
|
15
|
+
export { reactive, prop, computed, params, routeQuery, watch } from "../store";
|
|
16
|
+
// DI: service container decorators, @watch(Service)
|
|
17
|
+
export { service, inject, factory } from "../di";
|
|
18
|
+
export { watch as watchService } from "../di";
|
|
19
|
+
// Element: component registration, DOM queries, lifecycle, timing
|
|
20
|
+
export { component, query, queryAll } from "../element";
|
|
21
|
+
export { catch_, suspend, mount, unmount } from "../element";
|
|
22
|
+
export { interval, timeout, debounce, throttle, animationFrame } from "../element";
|
|
23
|
+
// Transform: value transforms, factory, typed helpers
|
|
24
|
+
export { transform, createTransform, typed, typedTransformer } from "../transform";
|
|
25
|
+
export { toNumber, toBoolean, toDate, toJSON, toTrimmed, toInt, toFloat } from "../transform";
|
|
27
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names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
1
|
+
/**
|
|
2
|
+
* Loom — DI decorators
|
|
3
|
+
*
|
|
4
|
+
* @service — Auto-instantiated singleton, registered on app.start()
|
|
5
|
+
* @inject — Dual-mode dependency injection (property or constructor param)
|
|
6
|
+
* @factory — Method decorator, return value registered as a provider
|
|
7
|
+
*/
|
|
1
8
|
/**
|
|
2
9
|
* Auto-instantiated singleton. Registered on app.start().
|
|
3
10
|
* Constructor @inject params are resolved automatically.
|
|
@@ -7,7 +14,7 @@
|
|
|
7
14
|
* class BookmarkStore extends CollectionStore<Bookmark> { ... }
|
|
8
15
|
* ```
|
|
9
16
|
*/
|
|
10
|
-
export declare
|
|
17
|
+
export declare const service: () => (ctor: any) => void;
|
|
11
18
|
/**
|
|
12
19
|
* Dual-mode dependency injection.
|
|
13
20
|
*
|
|
@@ -33,5 +40,5 @@ export declare function inject<T = any>(key: any): (target: any, propOrMethod: s
|
|
|
33
40
|
* }
|
|
34
41
|
* ```
|
|
35
42
|
*/
|
|
36
|
-
export declare
|
|
37
|
-
//# sourceMappingURL=
|
|
43
|
+
export declare const factory: (key?: any) => (target: any, key: string, desc?: PropertyDescriptor) => void;
|
|
44
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/di/decorators.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,2BAED,CAAC;AAEpB;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAC9B,QAAQ,GAAG,EAAE,cAAc,MAAM,GAAG,SAAS,EAAE,QAAQ,MAAM,UAiBtE;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,gDAGc,CAAC,6BADjC,CAAC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Loom — DI decorators
|
|
3
|
+
*
|
|
4
|
+
* @service — Auto-instantiated singleton, registered on app.start()
|
|
5
|
+
* @inject — Dual-mode dependency injection (property or constructor param)
|
|
6
|
+
* @factory — Method decorator, return value registered as a provider
|
|
7
|
+
*/
|
|
8
|
+
import { INJECT_PARAMS } from "../decorators/symbols";
|
|
2
9
|
import { app } from "../app";
|
|
10
|
+
import { createDecorator } from "../decorators/create";
|
|
3
11
|
/**
|
|
4
12
|
* Auto-instantiated singleton. Registered on app.start().
|
|
5
13
|
* Constructor @inject params are resolved automatically.
|
|
@@ -9,9 +17,9 @@ import { app } from "../app";
|
|
|
9
17
|
* class BookmarkStore extends CollectionStore<Bookmark> { ... }
|
|
10
18
|
* ```
|
|
11
19
|
*/
|
|
12
|
-
export
|
|
20
|
+
export const service = createDecorator((ctor) => {
|
|
13
21
|
app.registerService(ctor);
|
|
14
|
-
}
|
|
22
|
+
}, { class: true });
|
|
15
23
|
/**
|
|
16
24
|
* Dual-mode dependency injection.
|
|
17
25
|
*
|
|
@@ -32,7 +40,7 @@ export function inject(key) {
|
|
|
32
40
|
proto[INJECT_PARAMS].push({ method, index, key });
|
|
33
41
|
}
|
|
34
42
|
else {
|
|
35
|
-
// Property decorator → lazy getter
|
|
43
|
+
// Property decorator → lazy getter (define-time)
|
|
36
44
|
Object.defineProperty(target, propOrMethod, {
|
|
37
45
|
get() {
|
|
38
46
|
return app.get(key);
|
|
@@ -57,9 +65,7 @@ export function inject(key) {
|
|
|
57
65
|
* }
|
|
58
66
|
* ```
|
|
59
67
|
*/
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=di.js.map
|
|
68
|
+
export const factory = createDecorator((proto, method, key) => {
|
|
69
|
+
app.registerFactory(key, proto, method);
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dec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AAC,MAAM,OAAO,GAAG,eAAe,CAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IACzE,GAAG,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/di/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/di/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom DI — Barrel exports
|
|
3
|
+
*
|
|
4
|
+
* Dependency injection decorators and DI-aware @watch.
|
|
5
|
+
*/
|
|
6
|
+
// DI decorators
|
|
7
|
+
export { service, inject, factory } from "./decorators";
|
|
8
|
+
// DI-aware watch
|
|
9
|
+
export { watch } from "./watch";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/di/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gBAAgB;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAExD,iBAAiB;AACjB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — DI @watch
|
|
3
|
+
*
|
|
4
|
+
* Form 3: Watch a DI-resolved service (or a reactive property on it).
|
|
5
|
+
* Resolves via app.get() at connectedCallback time.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* React to changes on a DI-resolved service.
|
|
9
|
+
*
|
|
10
|
+
* Watch the service itself (must extend Reactive):
|
|
11
|
+
* ```ts
|
|
12
|
+
* @watch(TodoStore)
|
|
13
|
+
* onTodos(items: Todo[], prev: Todo[]) { ... }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Watch a named reactive property on the service:
|
|
17
|
+
* ```ts
|
|
18
|
+
* @watch(ThemeService, "theme")
|
|
19
|
+
* onTheme(value: string, prev: string) { ... }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function watch(service: new (...args: any[]) => any, prop?: string): (proto: any, key: string) => void;
|
|
23
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/di/watch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,IAC/D,OAAO,GAAG,EAAE,KAAK,MAAM,UAkBhC"}
|
package/dist/di/watch.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — DI @watch
|
|
3
|
+
*
|
|
4
|
+
* Form 3: Watch a DI-resolved service (or a reactive property on it).
|
|
5
|
+
* Resolves via app.get() at connectedCallback time.
|
|
6
|
+
*/
|
|
7
|
+
import { app } from "../app";
|
|
8
|
+
/**
|
|
9
|
+
* React to changes on a DI-resolved service.
|
|
10
|
+
*
|
|
11
|
+
* Watch the service itself (must extend Reactive):
|
|
12
|
+
* ```ts
|
|
13
|
+
* @watch(TodoStore)
|
|
14
|
+
* onTodos(items: Todo[], prev: Todo[]) { ... }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Watch a named reactive property on the service:
|
|
18
|
+
* ```ts
|
|
19
|
+
* @watch(ThemeService, "theme")
|
|
20
|
+
* onTheme(value: string, prev: string) { ... }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function watch(service, prop) {
|
|
24
|
+
return (proto, key) => {
|
|
25
|
+
const orig = proto.connectedCallback;
|
|
26
|
+
proto.connectedCallback = function () {
|
|
27
|
+
orig?.call(this);
|
|
28
|
+
const svc = app.get(service);
|
|
29
|
+
const reactive = prop ? svc[prop] : svc;
|
|
30
|
+
if (typeof reactive?.subscribe !== "function") {
|
|
31
|
+
throw new Error(`[loom] @watch: ${service.name}${prop ? "." + prop : ""} is not a Reactive`);
|
|
32
|
+
}
|
|
33
|
+
const unsub = reactive.subscribe((v, p) => {
|
|
34
|
+
this[key](v, p);
|
|
35
|
+
this.scheduleUpdate?.();
|
|
36
|
+
});
|
|
37
|
+
this.track(unsub);
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/di/watch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,OAAoC,EAAE,IAAa;IACvE,OAAO,CAAC,KAAU,EAAE,GAAW,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,KAAK,CAAC,iBAAiB,CAAC;QACrC,KAAK,CAAC,iBAAiB,GAAG;YACxB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAE,GAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACjD,IAAI,OAAO,QAAQ,EAAE,SAAS,KAAK,UAAU,EAAE,CAAC;gBAC9C,MAAM,IAAI,KAAK,CACb,kBAAkB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAC5E,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE;gBAClD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAChB,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Element decorators
|
|
3
|
+
*
|
|
4
|
+
* @component — Register a class as a custom element
|
|
5
|
+
* @query — Lazy shadow DOM querySelector
|
|
6
|
+
* @queryAll — Lazy shadow DOM querySelectorAll
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Register a class as a custom element. Wires @prop observed attributes
|
|
10
|
+
* and attributeChangedCallback auto-parsing.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* @component("my-counter")
|
|
14
|
+
* class MyCounter extends LoomElement { ... }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const component: (tag: string) => (ctor: any) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Lazy shadow DOM querySelector.
|
|
20
|
+
* ```ts
|
|
21
|
+
* @query(".submit-btn") submitBtn!: HTMLButtonElement;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const query: (selector: string) => (target: any, key: string, desc?: PropertyDescriptor) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Lazy shadow DOM querySelectorAll.
|
|
27
|
+
* ```ts
|
|
28
|
+
* @queryAll("input") inputs!: HTMLInputElement[];
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const queryAll: (selector: string) => (target: any, key: string, desc?: PropertyDescriptor) => void;
|
|
32
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/element/decorators.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,sCA6BH,CAAC;AAEpB;;;;;GAKG;AACH,eAAO,MAAM,KAAK,uDAkBX,CAAC,6BAXN,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,uDAGd,CAAC,6BAIN,CAAC"}
|