@toyz/loom 0.1.3 → 0.3.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 +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/router/decorators.d.ts +86 -0
- package/dist/router/decorators.d.ts.map +1 -0
- package/dist/router/decorators.js +174 -0
- package/dist/router/decorators.js.map +1 -0
- package/dist/router/index.d.ts +7 -5
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +7 -4
- package/dist/router/index.js.map +1 -1
- package/dist/router/link.d.ts +6 -0
- package/dist/router/link.d.ts.map +1 -1
- package/dist/router/link.js +27 -3
- package/dist/router/link.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 +32 -42
- package/dist/router/route.d.ts.map +1 -1
- package/dist/router/route.js +22 -96
- package/dist/router/route.js.map +1 -1
- package/dist/router/router.d.ts +13 -4
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +19 -7
- 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,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Storage adapters
|
|
3
|
+
*
|
|
4
|
+
* StorageAdapter defines the contract for persistent stores.
|
|
5
|
+
* Ships with LocalAdapter (localStorage) and SessionAdapter (sessionStorage).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Contract for storage backends used by Reactive's persist option.
|
|
9
|
+
*/
|
|
10
|
+
export interface StorageAdapter {
|
|
11
|
+
get(key: string): string | null;
|
|
12
|
+
set(key: string, value: string): void;
|
|
13
|
+
remove(key: string): void;
|
|
14
|
+
}
|
|
15
|
+
/** @deprecated Use StorageAdapter */
|
|
16
|
+
export type StorageMedium = StorageAdapter;
|
|
17
|
+
/**
|
|
18
|
+
* Persist options for Reactive / CollectionStore constructors.
|
|
19
|
+
*/
|
|
20
|
+
export interface PersistOptions {
|
|
21
|
+
key: string;
|
|
22
|
+
storage: StorageAdapter;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* In-memory storage. Useful for testing or transient state.
|
|
26
|
+
*/
|
|
27
|
+
export declare class MemoryStorage implements StorageAdapter {
|
|
28
|
+
private data;
|
|
29
|
+
get(key: string): string | null;
|
|
30
|
+
set(key: string, value: string): void;
|
|
31
|
+
remove(key: string): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* localStorage adapter. Silently falls back on errors (SSR, iframe sandbox).
|
|
35
|
+
*/
|
|
36
|
+
export declare class LocalAdapter implements StorageAdapter {
|
|
37
|
+
get(key: string): string | null;
|
|
38
|
+
set(key: string, value: string): void;
|
|
39
|
+
remove(key: string): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* sessionStorage adapter. Silently falls back on errors.
|
|
43
|
+
*/
|
|
44
|
+
export declare class SessionAdapter implements StorageAdapter {
|
|
45
|
+
get(key: string): string | null;
|
|
46
|
+
set(key: string, value: string): void;
|
|
47
|
+
remove(key: string): void;
|
|
48
|
+
}
|
|
49
|
+
/** @deprecated Use LocalAdapter */
|
|
50
|
+
export declare const LocalMedium: typeof LocalAdapter;
|
|
51
|
+
/** @deprecated Use SessionAdapter */
|
|
52
|
+
export declare const SessionMedium: typeof SessionAdapter;
|
|
53
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/store/storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,qCAAqC;AACrC,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,IAAI,CAA6B;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM;IACf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAC9B,MAAM,CAAC,GAAG,EAAE,MAAM;CACnB;AAED;;GAEG;AACH,qBAAa,YAAa,YAAW,cAAc;IACjD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAO/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAOrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAO1B;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,cAAc;IACnD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAO/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAOrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAO1B;AAED,mCAAmC;AACnC,eAAO,MAAM,WAAW,qBAAe,CAAC;AAExC,qCAAqC;AACrC,eAAO,MAAM,aAAa,uBAAiB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Storage adapters
|
|
3
|
+
*
|
|
4
|
+
* StorageAdapter defines the contract for persistent stores.
|
|
5
|
+
* Ships with LocalAdapter (localStorage) and SessionAdapter (sessionStorage).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* In-memory storage. Useful for testing or transient state.
|
|
9
|
+
*/
|
|
10
|
+
export class MemoryStorage {
|
|
11
|
+
data = new Map();
|
|
12
|
+
get(key) { return this.data.get(key) ?? null; }
|
|
13
|
+
set(key, value) { this.data.set(key, value); }
|
|
14
|
+
remove(key) { this.data.delete(key); }
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* localStorage adapter. Silently falls back on errors (SSR, iframe sandbox).
|
|
18
|
+
*/
|
|
19
|
+
export class LocalAdapter {
|
|
20
|
+
get(key) {
|
|
21
|
+
try {
|
|
22
|
+
return localStorage.getItem(key);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
set(key, value) {
|
|
29
|
+
try {
|
|
30
|
+
localStorage.setItem(key, value);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
/* quota exceeded or unavailable */
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
remove(key) {
|
|
37
|
+
try {
|
|
38
|
+
localStorage.removeItem(key);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
/* unavailable */
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* sessionStorage adapter. Silently falls back on errors.
|
|
47
|
+
*/
|
|
48
|
+
export class SessionAdapter {
|
|
49
|
+
get(key) {
|
|
50
|
+
try {
|
|
51
|
+
return sessionStorage.getItem(key);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
set(key, value) {
|
|
58
|
+
try {
|
|
59
|
+
sessionStorage.setItem(key, value);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
/* quota exceeded or unavailable */
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
remove(key) {
|
|
66
|
+
try {
|
|
67
|
+
sessionStorage.removeItem(key);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
/* unavailable */
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** @deprecated Use LocalAdapter */
|
|
75
|
+
export const LocalMedium = LocalAdapter;
|
|
76
|
+
/** @deprecated Use SessionAdapter */
|
|
77
|
+
export const SessionMedium = SessionAdapter;
|
|
78
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/store/storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH;;GAEG;AACH,MAAM,OAAO,aAAa;IAChB,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,GAAG,CAAC,GAAW,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IACvD,GAAG,CAAC,GAAW,EAAE,KAAa,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,GAAW,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB,GAAG,CAAC,GAAW;QACb,IAAI,CAAC;YACH,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,GAAG,CAAC,GAAW,EAAE,KAAa;QAC5B,IAAI,CAAC;YACH,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,mCAAmC;QACrC,CAAC;IACH,CAAC;IACD,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC;YACH,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,GAAG,CAAC,GAAW;QACb,IAAI,CAAC;YACH,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,GAAG,CAAC,GAAW,EAAE,KAAa;QAC5B,IAAI,CAAC;YACH,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACP,mCAAmC;QACrC,CAAC;IACH,CAAC;IACD,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC;YACH,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;IACH,CAAC;CACF;AAED,mCAAmC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC,qCAAqC;AACrC,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Store @watch
|
|
3
|
+
*
|
|
4
|
+
* Form 1: Watch a local @reactive field by name
|
|
5
|
+
* Form 2: Watch a direct Reactive/CollectionStore instance
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* React to local @reactive field changes or direct store changes.
|
|
9
|
+
*
|
|
10
|
+
* Local @reactive field — stores metadata consumed by @reactive's subscriber wiring:
|
|
11
|
+
* ```ts
|
|
12
|
+
* @watch("value")
|
|
13
|
+
* onValueChange(curr: number, prev: number) { ... }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Direct Reactive/CollectionStore instance — subscribes on connect, cleans up on disconnect:
|
|
17
|
+
* ```ts
|
|
18
|
+
* @watch(todos)
|
|
19
|
+
* onTodosChange(items: Todo[], prev: Todo[]) { ... }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function watch(field: string): (target: any, key: string) => void;
|
|
23
|
+
export declare function watch(store: {
|
|
24
|
+
subscribe: Function;
|
|
25
|
+
value: any;
|
|
26
|
+
}): (target: any, key: string) => void;
|
|
27
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/store/watch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AACzE,wBAAgB,KAAK,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Store @watch
|
|
3
|
+
*
|
|
4
|
+
* Form 1: Watch a local @reactive field by name
|
|
5
|
+
* Form 2: Watch a direct Reactive/CollectionStore instance
|
|
6
|
+
*/
|
|
7
|
+
import { WATCHERS } from "../decorators/symbols";
|
|
8
|
+
export function watch(target) {
|
|
9
|
+
return (proto, key) => {
|
|
10
|
+
if (typeof target === "string") {
|
|
11
|
+
// Form 1: local @reactive field — store metadata for @reactive to wire
|
|
12
|
+
if (!proto[WATCHERS])
|
|
13
|
+
proto[WATCHERS] = [];
|
|
14
|
+
proto[WATCHERS].push({ field: target, key });
|
|
15
|
+
}
|
|
16
|
+
else if (typeof target === "object" && typeof target.subscribe === "function") {
|
|
17
|
+
// Form 2: direct Reactive instance — subscribe on connect
|
|
18
|
+
const orig = proto.connectedCallback;
|
|
19
|
+
proto.connectedCallback = function () {
|
|
20
|
+
orig?.call(this);
|
|
21
|
+
const unsub = target.subscribe((v, p) => {
|
|
22
|
+
this[key](v, p);
|
|
23
|
+
this.scheduleUpdate?.();
|
|
24
|
+
});
|
|
25
|
+
this.track(unsub);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/store/watch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAmBjD,MAAM,UAAU,KAAK,CAAC,MAAoD;IACxE,OAAO,CAAC,KAAU,EAAE,GAAW,EAAE,EAAE;QACjC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,uEAAuE;YACvE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAC3C,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/C,CAAC;aAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;YAChF,0DAA0D;YAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,iBAAiB,CAAC;YACrC,KAAK,CAAC,iBAAiB,GAAG;gBACxB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjB,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE;oBAChD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAChB,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;gBAC1B,CAAC,CAAC,CAAC;gBACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Built-in transforms
|
|
3
|
+
*
|
|
4
|
+
* Pre-built transform decorators created with createTransform.
|
|
5
|
+
* These are ready-to-use property decorators that pipe values
|
|
6
|
+
* through standard JavaScript coercion functions.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* @prop({ param: "id" })
|
|
10
|
+
* @toNumber
|
|
11
|
+
* userId!: number;
|
|
12
|
+
*
|
|
13
|
+
* @prop({ param: "active" })
|
|
14
|
+
* @toBoolean
|
|
15
|
+
* isActive!: boolean;
|
|
16
|
+
*
|
|
17
|
+
* @prop({ param: "created" })
|
|
18
|
+
* @toDate
|
|
19
|
+
* createdAt!: Date;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
/** Coerce to number via Number() */
|
|
23
|
+
export declare const toNumber: (target: any, key: string) => void;
|
|
24
|
+
/** Coerce to boolean — "true" and "1" → true, everything else → false */
|
|
25
|
+
export declare const toBoolean: (target: any, key: string) => void;
|
|
26
|
+
/** Parse ISO date string to Date object */
|
|
27
|
+
export declare const toDate: (target: any, key: string) => void;
|
|
28
|
+
/** Parse JSON string to object */
|
|
29
|
+
export declare const toJSON: (target: any, key: string) => void;
|
|
30
|
+
/** Trim whitespace */
|
|
31
|
+
export declare const toTrimmed: (target: any, key: string) => void;
|
|
32
|
+
/** Coerce to integer via parseInt */
|
|
33
|
+
export declare const toInt: (target: any, key: string) => void;
|
|
34
|
+
/** Coerce to float via parseFloat */
|
|
35
|
+
export declare const toFloat: (target: any, key: string) => void;
|
|
36
|
+
//# sourceMappingURL=built-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../../src/transform/built-in.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,oCAAoC;AACpC,eAAO,MAAM,QAAQ,oCAA0C,CAAC;AAEhE,yEAAyE;AACzE,eAAO,MAAM,SAAS,oCAErB,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,MAAM,oCAElB,CAAC;AAEF,kCAAkC;AAClC,eAAO,MAAM,MAAM,oCAElB,CAAC;AAEF,sBAAsB;AACtB,eAAO,MAAM,SAAS,oCAErB,CAAC;AAEF,qCAAqC;AACrC,eAAO,MAAM,KAAK,oCAEjB,CAAC;AAEF,qCAAqC;AACrC,eAAO,MAAM,OAAO,oCAA8C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Built-in transforms
|
|
3
|
+
*
|
|
4
|
+
* Pre-built transform decorators created with createTransform.
|
|
5
|
+
* These are ready-to-use property decorators that pipe values
|
|
6
|
+
* through standard JavaScript coercion functions.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* @prop({ param: "id" })
|
|
10
|
+
* @toNumber
|
|
11
|
+
* userId!: number;
|
|
12
|
+
*
|
|
13
|
+
* @prop({ param: "active" })
|
|
14
|
+
* @toBoolean
|
|
15
|
+
* isActive!: boolean;
|
|
16
|
+
*
|
|
17
|
+
* @prop({ param: "created" })
|
|
18
|
+
* @toDate
|
|
19
|
+
* createdAt!: Date;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { createTransform } from "./create";
|
|
23
|
+
/** Coerce to number via Number() */
|
|
24
|
+
export const toNumber = createTransform(Number);
|
|
25
|
+
/** Coerce to boolean — "true" and "1" → true, everything else → false */
|
|
26
|
+
export const toBoolean = createTransform((v) => v === "true" || v === "1");
|
|
27
|
+
/** Parse ISO date string to Date object */
|
|
28
|
+
export const toDate = createTransform((v) => new Date(v));
|
|
29
|
+
/** Parse JSON string to object */
|
|
30
|
+
export const toJSON = createTransform((v) => JSON.parse(v));
|
|
31
|
+
/** Trim whitespace */
|
|
32
|
+
export const toTrimmed = createTransform((v) => v.trim());
|
|
33
|
+
/** Coerce to integer via parseInt */
|
|
34
|
+
export const toInt = createTransform((v) => parseInt(v, 10));
|
|
35
|
+
/** Coerce to float via parseFloat */
|
|
36
|
+
export const toFloat = createTransform(parseFloat);
|
|
37
|
+
//# sourceMappingURL=built-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in.js","sourceRoot":"","sources":["../../src/transform/built-in.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,oCAAoC;AACpC,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAiB,MAAM,CAAC,CAAC;AAEhE,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG,CACjC,CAAC;AAEF,2CAA2C;AAC3C,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CACnC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CACnB,CAAC;AAEF,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CACnC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CACrB,CAAC;AAEF,sBAAsB;AACtB,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAChB,CAAC;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAClC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CACvB,CAAC;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAiB,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — createTransform
|
|
3
|
+
*
|
|
4
|
+
* Factory for building reusable @transform decorators.
|
|
5
|
+
* Returns a property decorator that pipes values through the given function.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // Create a reusable transform decorator
|
|
9
|
+
* const toNumber = createTransform(Number);
|
|
10
|
+
* const toDate = createTransform((v: string) => new Date(v));
|
|
11
|
+
*
|
|
12
|
+
* // Use it:
|
|
13
|
+
* @prop({ param: "id" })
|
|
14
|
+
* @toNumber
|
|
15
|
+
* userId!: number;
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function createTransform<In = any, Out = any>(fn: (value: In) => Out): (target: any, key: string) => void;
|
|
19
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/transform/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,wBAAgB,eAAe,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EACjD,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,GAAG,GACrB,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAMpC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — createTransform
|
|
3
|
+
*
|
|
4
|
+
* Factory for building reusable @transform decorators.
|
|
5
|
+
* Returns a property decorator that pipes values through the given function.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // Create a reusable transform decorator
|
|
9
|
+
* const toNumber = createTransform(Number);
|
|
10
|
+
* const toDate = createTransform((v: string) => new Date(v));
|
|
11
|
+
*
|
|
12
|
+
* // Use it:
|
|
13
|
+
* @prop({ param: "id" })
|
|
14
|
+
* @toNumber
|
|
15
|
+
* userId!: number;
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { TRANSFORMS } from "../decorators/symbols";
|
|
19
|
+
export function createTransform(fn) {
|
|
20
|
+
return (proto, key) => {
|
|
21
|
+
const ctor = proto.constructor;
|
|
22
|
+
if (!ctor[TRANSFORMS])
|
|
23
|
+
ctor[TRANSFORMS] = new Map();
|
|
24
|
+
ctor[TRANSFORMS].set(key, fn);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/transform/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,UAAU,eAAe,CAC7B,EAAsB;IAEtB,OAAO,CAAC,KAAU,EAAE,GAAW,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,EAAoB,CAAC;QACtE,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom Transform — Barrel exports
|
|
3
|
+
*
|
|
4
|
+
* Transform decorator, factory, typed helpers, and built-in transforms.
|
|
5
|
+
*/
|
|
6
|
+
export { transform } from "./transform";
|
|
7
|
+
export { createTransform } from "./create";
|
|
8
|
+
export { typed, typedTransformer } from "./typed";
|
|
9
|
+
export type { TransformSchema } from "./typed";
|
|
10
|
+
export { toNumber, toBoolean, toDate, toJSON, toTrimmed, toInt, toFloat } from "./built-in";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom Transform — Barrel exports
|
|
3
|
+
*
|
|
4
|
+
* Transform decorator, factory, typed helpers, and built-in transforms.
|
|
5
|
+
*/
|
|
6
|
+
// Core decorator
|
|
7
|
+
export { transform } from "./transform";
|
|
8
|
+
// Factory for creating custom transform decorators
|
|
9
|
+
export { createTransform } from "./create";
|
|
10
|
+
// Typed schema transform
|
|
11
|
+
export { typed, typedTransformer } from "./typed";
|
|
12
|
+
// Built-in transforms
|
|
13
|
+
export { toNumber, toBoolean, toDate, toJSON, toTrimmed, toInt, toFloat } from "./built-in";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,mDAAmD;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,yBAAyB;AACzB,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGlD,sBAAsB;AACtB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Transform decorator
|
|
3
|
+
*
|
|
4
|
+
* @transform — Pipe a value through a transform function before it reaches
|
|
5
|
+
* the property. Commonly paired with @prop for route params or attribute parsing.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* @prop({ param: "id" })
|
|
9
|
+
* @transform(Number) // "42" → 42
|
|
10
|
+
* userId!: number;
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const transform: (fn: (value: any) => any) => (target: any, key: string, desc?: PropertyDescriptor) => void;
|
|
14
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/transform/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,eAAO,MAAM,SAAS,eAAgC,GAAG,KAAK,GAAG,oCAKw9C,CAAC,6BADxhD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Transform decorator
|
|
3
|
+
*
|
|
4
|
+
* @transform — Pipe a value through a transform function before it reaches
|
|
5
|
+
* the property. Commonly paired with @prop for route params or attribute parsing.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* @prop({ param: "id" })
|
|
9
|
+
* @transform(Number) // "42" → 42
|
|
10
|
+
* userId!: number;
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import { TRANSFORMS } from "../decorators/symbols";
|
|
14
|
+
import { createDecorator } from "../decorators/create";
|
|
15
|
+
export const transform = createDecorator((proto, key, fn) => {
|
|
16
|
+
const ctor = proto.constructor;
|
|
17
|
+
if (!ctor[TRANSFORMS])
|
|
18
|
+
ctor[TRANSFORMS] = new Map();
|
|
19
|
+
ctor[TRANSFORMS].set(key, fn);
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/transform/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAA4B,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE;IACrF,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;IAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtE,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Typed transform
|
|
3
|
+
*
|
|
4
|
+
* Schema-based transform helper and decorator. Converts raw string records
|
|
5
|
+
* into typed objects according to a schema.
|
|
6
|
+
*
|
|
7
|
+
* Function form (for manual use):
|
|
8
|
+
* ```ts
|
|
9
|
+
* @prop({params})
|
|
10
|
+
* @transform(typed<UserParams>({ id: Number }))
|
|
11
|
+
* routeParams!: UserParams;
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Decorator form (shorthand):
|
|
15
|
+
* ```ts
|
|
16
|
+
* @prop({params})
|
|
17
|
+
* @typedTransformer<UserParams>({ id: Number })
|
|
18
|
+
* routeParams!: UserParams;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export interface TransformSchema<T> {
|
|
22
|
+
[key: string]: (v: string) => any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build a typed transform function from a schema object.
|
|
26
|
+
* Use with @transform() or standalone.
|
|
27
|
+
*/
|
|
28
|
+
export declare function typed<T>(schema: TransformSchema<T>): (raw: Record<string, string>) => T;
|
|
29
|
+
/**
|
|
30
|
+
* Decorator: apply a typed schema transform directly.
|
|
31
|
+
* Shorthand for @transform(typed<T>(schema)).
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* @prop({params})
|
|
35
|
+
* @typedTransformer<UserParams>({ id: Number, name: String })
|
|
36
|
+
* routeParams!: UserParams;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function typedTransformer<T>(schema: TransformSchema<T>): (proto: any, key: string) => void;
|
|
40
|
+
//# sourceMappingURL=typed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/transform/typed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAQvF;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,IAEpD,OAAO,GAAG,EAAE,KAAK,MAAM,UAKhC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — Typed transform
|
|
3
|
+
*
|
|
4
|
+
* Schema-based transform helper and decorator. Converts raw string records
|
|
5
|
+
* into typed objects according to a schema.
|
|
6
|
+
*
|
|
7
|
+
* Function form (for manual use):
|
|
8
|
+
* ```ts
|
|
9
|
+
* @prop({params})
|
|
10
|
+
* @transform(typed<UserParams>({ id: Number }))
|
|
11
|
+
* routeParams!: UserParams;
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Decorator form (shorthand):
|
|
15
|
+
* ```ts
|
|
16
|
+
* @prop({params})
|
|
17
|
+
* @typedTransformer<UserParams>({ id: Number })
|
|
18
|
+
* routeParams!: UserParams;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { TRANSFORMS } from "../decorators/symbols";
|
|
22
|
+
/**
|
|
23
|
+
* Build a typed transform function from a schema object.
|
|
24
|
+
* Use with @transform() or standalone.
|
|
25
|
+
*/
|
|
26
|
+
export function typed(schema) {
|
|
27
|
+
return (raw) => {
|
|
28
|
+
const out = {};
|
|
29
|
+
for (const [k, fn] of Object.entries(schema)) {
|
|
30
|
+
if (k in raw)
|
|
31
|
+
out[k] = fn(raw[k]);
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decorator: apply a typed schema transform directly.
|
|
38
|
+
* Shorthand for @transform(typed<T>(schema)).
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* @prop({params})
|
|
42
|
+
* @typedTransformer<UserParams>({ id: Number, name: String })
|
|
43
|
+
* routeParams!: UserParams;
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function typedTransformer(schema) {
|
|
47
|
+
const fn = typed(schema);
|
|
48
|
+
return (proto, key) => {
|
|
49
|
+
const ctor = proto.constructor;
|
|
50
|
+
if (!ctor[TRANSFORMS])
|
|
51
|
+
ctor[TRANSFORMS] = new Map();
|
|
52
|
+
ctor[TRANSFORMS].set(key, fn);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=typed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed.js","sourceRoot":"","sources":["../../src/transform/typed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAMnD;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAI,MAA0B;IACjD,OAAO,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,GAAG;gBAAE,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAI,MAA0B;IAC5D,MAAM,EAAE,GAAG,KAAK,CAAI,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,KAAU,EAAE,GAAW,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,EAAoB,CAAC;QACtE,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toyz/loom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Decorator-driven web component framework with reactive state, DOM morphing, DI, and JSX",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,16 +34,48 @@
|
|
|
34
34
|
"./router": {
|
|
35
35
|
"types": "./dist/router/index.d.ts",
|
|
36
36
|
"import": "./dist/router/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./store": {
|
|
39
|
+
"types": "./dist/store/index.d.ts",
|
|
40
|
+
"import": "./dist/store/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./di": {
|
|
43
|
+
"types": "./dist/di/index.d.ts",
|
|
44
|
+
"import": "./dist/di/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./element": {
|
|
47
|
+
"types": "./dist/element/index.d.ts",
|
|
48
|
+
"import": "./dist/element/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./transform": {
|
|
51
|
+
"types": "./dist/transform/index.d.ts",
|
|
52
|
+
"import": "./dist/transform/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./element/icon": {
|
|
55
|
+
"types": "./dist/element/icon.d.ts",
|
|
56
|
+
"import": "./dist/element/icon.js"
|
|
57
|
+
},
|
|
58
|
+
"./element/virtual": {
|
|
59
|
+
"types": "./dist/element/virtual.d.ts",
|
|
60
|
+
"import": "./dist/element/virtual.js"
|
|
61
|
+
},
|
|
62
|
+
"./decorators": {
|
|
63
|
+
"types": "./dist/decorators/index.d.ts",
|
|
64
|
+
"import": "./dist/decorators/index.js"
|
|
37
65
|
}
|
|
38
66
|
},
|
|
39
67
|
"scripts": {
|
|
40
68
|
"build": "tsc",
|
|
41
69
|
"dev": "tsc --watch",
|
|
70
|
+
"test": "vitest run",
|
|
71
|
+
"test:watch": "vitest",
|
|
42
72
|
"clean": "rm -rf dist",
|
|
43
|
-
"prepublishOnly": "npm run clean && npm run build"
|
|
73
|
+
"prepublishOnly": "npm run clean && npm test && npm run build"
|
|
44
74
|
},
|
|
45
75
|
"devDependencies": {
|
|
46
|
-
"
|
|
76
|
+
"happy-dom": "^20.6.1",
|
|
77
|
+
"typescript": "^5.7.0",
|
|
78
|
+
"vitest": "^4.0.18"
|
|
47
79
|
},
|
|
48
80
|
"keywords": [
|
|
49
81
|
"web-components",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Register a class as a custom element. Wires @prop observed attributes
|
|
3
|
-
* and attributeChangedCallback auto-parsing.
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* @component("my-counter")
|
|
7
|
-
* class MyCounter extends LoomElement { ... }
|
|
8
|
-
* ```
|
|
9
|
-
*/
|
|
10
|
-
export declare function component(tag: string): (ctor: any) => void;
|
|
11
|
-
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/decorators/component.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,IAC3B,MAAM,GAAG,UA8BlB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { PROPS } from "./symbols";
|
|
2
|
-
import { app } from "../app";
|
|
3
|
-
/**
|
|
4
|
-
* Register a class as a custom element. Wires @prop observed attributes
|
|
5
|
-
* and attributeChangedCallback auto-parsing.
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* @component("my-counter")
|
|
9
|
-
* class MyCounter extends LoomElement { ... }
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export function component(tag) {
|
|
13
|
-
return (ctor) => {
|
|
14
|
-
const propMap = ctor[PROPS] ?? new Map();
|
|
15
|
-
// Wire observedAttributes from @prop fields
|
|
16
|
-
Object.defineProperty(ctor, "observedAttributes", {
|
|
17
|
-
get: () => [...propMap.keys()],
|
|
18
|
-
});
|
|
19
|
-
// Wire attributeChangedCallback to update @prop fields
|
|
20
|
-
const origCallback = ctor.prototype.attributeChangedCallback;
|
|
21
|
-
ctor.prototype.attributeChangedCallback = function (name, _old, val) {
|
|
22
|
-
const field = propMap.get(name);
|
|
23
|
-
if (field && val !== null) {
|
|
24
|
-
const current = this[field];
|
|
25
|
-
if (typeof current === "number")
|
|
26
|
-
this[field] = Number(val);
|
|
27
|
-
else if (typeof current === "boolean")
|
|
28
|
-
this[field] = val !== null && val !== "false";
|
|
29
|
-
else
|
|
30
|
-
this[field] = val;
|
|
31
|
-
}
|
|
32
|
-
origCallback?.call(this, name, _old, val);
|
|
33
|
-
};
|
|
34
|
-
app.register(tag, ctor);
|
|
35
|
-
ctor.__loom_tag = tag;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/decorators/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,CAAC,IAAS,EAAE,EAAE;QACnB,MAAM,OAAO,GACV,IAAY,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;QAEpC,4CAA4C;QAC5C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE;YAChD,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;SAC/B,CAAC,CAAC;QAEH,uDAAuD;QACvD,MAAM,YAAY,GAAI,IAAI,CAAC,SAAiB,CAAC,wBAAwB,CAAC;QACrE,IAAI,CAAC,SAAiB,CAAC,wBAAwB,GAAG,UACjD,IAAY,EACZ,IAAmB,EACnB,GAAkB;YAElB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChC,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBAC1B,MAAM,OAAO,GAAI,IAAY,CAAC,KAAK,CAAC,CAAC;gBACrC,IAAI,OAAO,OAAO,KAAK,QAAQ;oBAAG,IAAY,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;qBAC/D,IAAI,OAAO,OAAO,KAAK,SAAS;oBAClC,IAAY,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,OAAO,CAAC;;oBACnD,IAAY,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;YAClC,CAAC;YACD,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC,CAAC;QAEF,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAgC,CAAC,CAAC;QACnD,IAAY,CAAC,UAAU,GAAG,GAAG,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC"}
|