@toyz/loom 0.15.2 → 0.15.4
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/element/context.d.ts +64 -0
- package/dist/element/context.d.ts.map +1 -0
- package/dist/element/context.js +189 -0
- package/dist/element/context.js.map +1 -0
- package/dist/element/index.d.ts +4 -0
- package/dist/element/index.d.ts.map +1 -1
- package/dist/element/index.js +4 -0
- package/dist/element/index.js.map +1 -1
- package/dist/element/log.d.ts +106 -0
- package/dist/element/log.d.ts.map +1 -0
- package/dist/element/log.js +218 -0
- package/dist/element/log.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — @provide / @consume context (TC39 Stage 3)
|
|
3
|
+
*
|
|
4
|
+
* Cross-shadow-DOM data sharing using the W3C Context Protocol.
|
|
5
|
+
* Class-based keys (like @service), auto-instantiation, reactive updates.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* class ThemeContext {
|
|
9
|
+
* mode: "dark" | "light" = "dark";
|
|
10
|
+
* primary = "#818cf8";
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* // Provider (ancestor)
|
|
14
|
+
* @provide(ThemeContext) accessor theme!: ThemeContext;
|
|
15
|
+
*
|
|
16
|
+
* // Consumer (any descendant — crosses shadow boundaries)
|
|
17
|
+
* @consume(ThemeContext) accessor theme!: ThemeContext;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* W3C Context Protocol event.
|
|
22
|
+
* Dispatched by consumers, intercepted by providers.
|
|
23
|
+
*
|
|
24
|
+
* `composed: true` lets it cross shadow DOM boundaries.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ContextRequestEvent<T = unknown> extends Event {
|
|
27
|
+
/** The context key (class constructor, string, or symbol) */
|
|
28
|
+
readonly context: unknown;
|
|
29
|
+
/** Callback the provider calls with the current value */
|
|
30
|
+
readonly callback: ContextCallback<T>;
|
|
31
|
+
/** Whether to subscribe to future updates (default: true) */
|
|
32
|
+
readonly subscribe: boolean;
|
|
33
|
+
constructor(
|
|
34
|
+
/** The context key (class constructor, string, or symbol) */
|
|
35
|
+
context: unknown,
|
|
36
|
+
/** Callback the provider calls with the current value */
|
|
37
|
+
callback: ContextCallback<T>,
|
|
38
|
+
/** Whether to subscribe to future updates (default: true) */
|
|
39
|
+
subscribe?: boolean);
|
|
40
|
+
}
|
|
41
|
+
export type ContextCallback<T> = (value: T, unsubscribe: () => void) => void;
|
|
42
|
+
/**
|
|
43
|
+
* @provide(Key) — Provide a context value to descendants.
|
|
44
|
+
*
|
|
45
|
+
* If Key is a class constructor and no initial value is set,
|
|
46
|
+
* the decorator auto-instantiates via `new Key()`.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* @provide(ThemeContext) accessor theme!: ThemeContext;
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function provide<T>(key: (new () => T) | string | symbol): <This extends object>(target: ClassAccessorDecoratorTarget<This, T>, context: ClassAccessorDecoratorContext<This, T>) => ClassAccessorDecoratorResult<This, T>;
|
|
53
|
+
/**
|
|
54
|
+
* @consume(Key) — Consume a context value from the nearest provider ancestor.
|
|
55
|
+
*
|
|
56
|
+
* The accessor is automatically typed from the Key if it's a class constructor.
|
|
57
|
+
* Updates reactively when the provider changes the value.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* @consume(ThemeContext) accessor theme!: ThemeContext;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function consume<T>(key: (new () => T) | string | symbol): <This extends object>(_target: ClassAccessorDecoratorTarget<This, T>, context: ClassAccessorDecoratorContext<This, T>) => ClassAccessorDecoratorResult<This, T>;
|
|
64
|
+
//# s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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — @provide / @consume context (TC39 Stage 3)
|
|
3
|
+
*
|
|
4
|
+
* Cross-shadow-DOM data sharing using the W3C Context Protocol.
|
|
5
|
+
* Class-based keys (like @service), auto-instantiation, reactive updates.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* class ThemeContext {
|
|
9
|
+
* mode: "dark" | "light" = "dark";
|
|
10
|
+
* primary = "#818cf8";
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* // Provider (ancestor)
|
|
14
|
+
* @provide(ThemeContext) accessor theme!: ThemeContext;
|
|
15
|
+
*
|
|
16
|
+
* // Consumer (any descendant — crosses shadow boundaries)
|
|
17
|
+
* @consume(ThemeContext) accessor theme!: ThemeContext;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import { CONNECT_HOOKS } from "../decorators/symbols";
|
|
21
|
+
// ── Context Request Event ──
|
|
22
|
+
const CONTEXT_REQUEST = "context-request";
|
|
23
|
+
/**
|
|
24
|
+
* W3C Context Protocol event.
|
|
25
|
+
* Dispatched by consumers, intercepted by providers.
|
|
26
|
+
*
|
|
27
|
+
* `composed: true` lets it cross shadow DOM boundaries.
|
|
28
|
+
*/
|
|
29
|
+
export class ContextRequestEvent extends Event {
|
|
30
|
+
context;
|
|
31
|
+
callback;
|
|
32
|
+
subscribe;
|
|
33
|
+
constructor(
|
|
34
|
+
/** The context key (class constructor, string, or symbol) */
|
|
35
|
+
context,
|
|
36
|
+
/** Callback the provider calls with the current value */
|
|
37
|
+
callback,
|
|
38
|
+
/** Whether to subscribe to future updates (default: true) */
|
|
39
|
+
subscribe = true) {
|
|
40
|
+
super(CONTEXT_REQUEST, { bubbles: true, composed: true });
|
|
41
|
+
this.context = context;
|
|
42
|
+
this.callback = callback;
|
|
43
|
+
this.subscribe = subscribe;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// ── @provide ──
|
|
47
|
+
/**
|
|
48
|
+
* @provide(Key) — Provide a context value to descendants.
|
|
49
|
+
*
|
|
50
|
+
* If Key is a class constructor and no initial value is set,
|
|
51
|
+
* the decorator auto-instantiates via `new Key()`.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* @provide(ThemeContext) accessor theme!: ThemeContext;
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function provide(key) {
|
|
58
|
+
return (target, context) => {
|
|
59
|
+
const storageKey = Symbol(`ctx:provide:${String(context.name)}`);
|
|
60
|
+
const subscribersKey = Symbol(`ctx:subs:${String(context.name)}`);
|
|
61
|
+
context.addInitializer(function () {
|
|
62
|
+
const self = this;
|
|
63
|
+
const hooks = CONNECT_HOOKS.from(self);
|
|
64
|
+
const hook = (el) => {
|
|
65
|
+
const host = el;
|
|
66
|
+
// Auto-instantiate class key if no value set
|
|
67
|
+
if (host[storageKey] === undefined && typeof key === "function") {
|
|
68
|
+
host[storageKey] = new key();
|
|
69
|
+
}
|
|
70
|
+
// Subscriber list for reactive updates
|
|
71
|
+
if (!host[subscribersKey])
|
|
72
|
+
host[subscribersKey] = new Set();
|
|
73
|
+
const subs = host[subscribersKey];
|
|
74
|
+
// Listen for context requests from descendants
|
|
75
|
+
const handler = (e) => {
|
|
76
|
+
const req = e;
|
|
77
|
+
if (req.context !== key)
|
|
78
|
+
return;
|
|
79
|
+
// Stop propagation so nearest provider wins
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
const currentValue = host[storageKey];
|
|
82
|
+
if (req.subscribe) {
|
|
83
|
+
// Subscriber — store callback for future updates
|
|
84
|
+
const cb = req.callback;
|
|
85
|
+
subs.add(cb);
|
|
86
|
+
// Provide unsubscribe function
|
|
87
|
+
const unsub = () => subs.delete(cb);
|
|
88
|
+
cb(currentValue, unsub);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// One-shot read
|
|
92
|
+
req.callback(currentValue, () => { });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
host.addEventListener(CONTEXT_REQUEST, handler);
|
|
96
|
+
return () => {
|
|
97
|
+
host.removeEventListener(CONTEXT_REQUEST, handler);
|
|
98
|
+
subs.clear();
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
if (!hooks)
|
|
102
|
+
CONNECT_HOOKS.set(self, [hook]);
|
|
103
|
+
else
|
|
104
|
+
hooks.push(hook);
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
init(value) {
|
|
108
|
+
// Capture initial accessor value into our storage
|
|
109
|
+
this[storageKey] = value;
|
|
110
|
+
return value;
|
|
111
|
+
},
|
|
112
|
+
get() {
|
|
113
|
+
const self = this;
|
|
114
|
+
if (self[storageKey] === undefined && typeof key === "function") {
|
|
115
|
+
self[storageKey] = new key();
|
|
116
|
+
}
|
|
117
|
+
return self[storageKey];
|
|
118
|
+
},
|
|
119
|
+
set(value) {
|
|
120
|
+
const self = this;
|
|
121
|
+
self[storageKey] = value;
|
|
122
|
+
// Notify all subscribed consumers
|
|
123
|
+
const subs = self[subscribersKey];
|
|
124
|
+
if (subs) {
|
|
125
|
+
for (const cb of subs) {
|
|
126
|
+
cb(value, () => subs.delete(cb));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Schedule re-render
|
|
130
|
+
self.scheduleUpdate?.();
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// ── @consume ──
|
|
136
|
+
/**
|
|
137
|
+
* @consume(Key) — Consume a context value from the nearest provider ancestor.
|
|
138
|
+
*
|
|
139
|
+
* The accessor is automatically typed from the Key if it's a class constructor.
|
|
140
|
+
* Updates reactively when the provider changes the value.
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* @consume(ThemeContext) accessor theme!: ThemeContext;
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export function consume(key) {
|
|
147
|
+
return (_target, context) => {
|
|
148
|
+
const storageKey = Symbol(`ctx:consume:${String(context.name)}`);
|
|
149
|
+
const unsubKey = Symbol(`ctx:unsub:${String(context.name)}`);
|
|
150
|
+
context.addInitializer(function () {
|
|
151
|
+
const self = this;
|
|
152
|
+
const hooks = CONNECT_HOOKS.from(self);
|
|
153
|
+
const hook = (el) => {
|
|
154
|
+
const host = el;
|
|
155
|
+
// Callback from provider
|
|
156
|
+
const callback = (value, unsubscribe) => {
|
|
157
|
+
host[storageKey] = value;
|
|
158
|
+
host[unsubKey] = unsubscribe;
|
|
159
|
+
host.scheduleUpdate?.();
|
|
160
|
+
};
|
|
161
|
+
// Defer dispatch so ancestor providers are connected first.
|
|
162
|
+
// Same pattern @slot uses — parent connectedCallback may not
|
|
163
|
+
// have fired yet when both connect in the same tick.
|
|
164
|
+
queueMicrotask(() => {
|
|
165
|
+
host.dispatchEvent(new ContextRequestEvent(key, callback, true));
|
|
166
|
+
});
|
|
167
|
+
return () => {
|
|
168
|
+
// Unsubscribe from provider on disconnect
|
|
169
|
+
const unsub = host[unsubKey];
|
|
170
|
+
unsub?.();
|
|
171
|
+
host[unsubKey] = undefined;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
if (!hooks)
|
|
175
|
+
CONNECT_HOOKS.set(self, [hook]);
|
|
176
|
+
else
|
|
177
|
+
hooks.push(hook);
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
get() {
|
|
181
|
+
return this[storageKey];
|
|
182
|
+
},
|
|
183
|
+
set(value) {
|
|
184
|
+
this[storageKey] = value;
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/element/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,8BA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AC;SACJ,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
|
package/dist/element/index.d.ts
CHANGED
|
@@ -18,4 +18,8 @@ export { transition } from "./transition";
|
|
|
18
18
|
export type { TransitionOptions } from "./transition";
|
|
19
19
|
export { hotkey } from "./hotkey";
|
|
20
20
|
export type { HotkeyOptions } from "./hotkey";
|
|
21
|
+
export { log, LogTransport, ConsoleTransport, resetLogTransport } from "./log";
|
|
22
|
+
export type { LogEntry, LogLevel, LogOptions } from "./log";
|
|
23
|
+
export { provide, consume, ContextRequestEvent } from "./context";
|
|
24
|
+
export type { ContextCallback } from "./context";
|
|
21
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/element/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AASxC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAG7G,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGjE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAA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O,EAAE,GAAG,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/E,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/element/index.js
CHANGED
|
@@ -30,4 +30,8 @@ export { slot } from "./slots";
|
|
|
30
30
|
export { transition } from "./transition";
|
|
31
31
|
// Hotkey decorator
|
|
32
32
|
export { hotkey } from "./hotkey";
|
|
33
|
+
// Log decorator + transport
|
|
34
|
+
export { log, LogTransport, ConsoleTransport, resetLogTransport } from "./log";
|
|
35
|
+
// Context: provide/consume across shadow boundaries
|
|
36
|
+
export { provide, consume, ContextRequestEvent } from "./context";
|
|
33
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/element/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,kEAAkE;AAClE,gEAAgE;AAChE,0DAA0D;AAC1D,8DAA8D;AAC9D,4DAA4D;AAE5D,qBAAqB;AACrB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAElE,uBAAuB;AACvB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE9D,kBAAkB;AAClB,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,qBAAqB;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,oBAAoB;AACpB,OAAO,EAAE,QAAQ,EAAE,OAAO,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AM,SAAS,CAAC;AAE/B,uBAAuB;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,mBAAmB;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,4BAA4B;AAC5B,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/E,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — @log decorator + LogTransport (TC39 Stage 3)
|
|
3
|
+
*
|
|
4
|
+
* Pluggable structured logging for Loom components.
|
|
5
|
+
* Same transport pattern as RpcTransport in loom-rpc.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // Register a transport
|
|
9
|
+
* app.use(LogTransport, new ConsoleTransport());
|
|
10
|
+
*
|
|
11
|
+
* // Decorate methods
|
|
12
|
+
* @log
|
|
13
|
+
* open() { this.isOpen = true; }
|
|
14
|
+
*
|
|
15
|
+
* @log("warn")
|
|
16
|
+
* dangerousAction() { ... }
|
|
17
|
+
*
|
|
18
|
+
* @log({ level: "debug", label: "Search" })
|
|
19
|
+
* onInput(e: Event) { ... }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
23
|
+
export interface LogEntry {
|
|
24
|
+
/** Log severity */
|
|
25
|
+
level: LogLevel;
|
|
26
|
+
/** Component tag name (e.g. "doc-search") */
|
|
27
|
+
component: string;
|
|
28
|
+
/** Method name that was called */
|
|
29
|
+
method: string;
|
|
30
|
+
/** Custom label (from options) */
|
|
31
|
+
label?: string;
|
|
32
|
+
/** Arguments passed to the method */
|
|
33
|
+
args: unknown[];
|
|
34
|
+
/** Return value (sync methods only — async resolves before logging) */
|
|
35
|
+
result?: unknown;
|
|
36
|
+
/** Error thrown by the method */
|
|
37
|
+
error?: Error;
|
|
38
|
+
/** Execution time in milliseconds */
|
|
39
|
+
duration: number;
|
|
40
|
+
/** Timestamp (Date.now()) */
|
|
41
|
+
timestamp: number;
|
|
42
|
+
}
|
|
43
|
+
export interface LogOptions {
|
|
44
|
+
/** Log level (default: "info") */
|
|
45
|
+
level?: LogLevel;
|
|
46
|
+
/** Custom label shown in log output */
|
|
47
|
+
label?: string;
|
|
48
|
+
/** Include method arguments in the log entry (default: true) */
|
|
49
|
+
includeArgs?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Selectively redact args. Supports:
|
|
52
|
+
* - `[0, 2]` — fully redact args at those indices
|
|
53
|
+
* - `{ 0: ["password", "token"] }` — redact nested keys in object arg at index 0
|
|
54
|
+
* - `{ 0: true }` — fully redact arg at index 0
|
|
55
|
+
* - `{ 1: ["user.email", "user.ssn"] }` — dot-path for nested objects
|
|
56
|
+
*/
|
|
57
|
+
skipArgs?: number[] | Record<number, true | string[]>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Abstract log transport — implement this to control where logs go.
|
|
61
|
+
*
|
|
62
|
+
* Registered as a DI service via `app.use(LogTransport, impl)`.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* app.use(LogTransport, new ConsoleTransport());
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare abstract class LogTransport {
|
|
69
|
+
abstract send(entry: LogEntry): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Default console transport — styled, color-coded output.
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* app.use(LogTransport, new ConsoleTransport());
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare class ConsoleTransport extends LogTransport {
|
|
79
|
+
send(entry: LogEntry): void;
|
|
80
|
+
}
|
|
81
|
+
/** Reset cached transport (for testing or hot-reload) */
|
|
82
|
+
export declare function resetLogTransport(): void;
|
|
83
|
+
/**
|
|
84
|
+
* @log — Structured method logging via pluggable LogTransport.
|
|
85
|
+
*
|
|
86
|
+
* Wraps the decorated method to capture args, return value, errors,
|
|
87
|
+
* and execution duration. Sends a LogEntry through the registered
|
|
88
|
+
* LogTransport. No-op if no transport is registered.
|
|
89
|
+
*
|
|
90
|
+
* Supports sync and async methods — async methods log after resolution.
|
|
91
|
+
*
|
|
92
|
+
* ```ts
|
|
93
|
+
* @log // level: "info"
|
|
94
|
+
* open() { ... }
|
|
95
|
+
*
|
|
96
|
+
* @log("warn") // level shorthand
|
|
97
|
+
* danger() { ... }
|
|
98
|
+
*
|
|
99
|
+
* @log({ level: "debug" }) // full options
|
|
100
|
+
* tick() { ... }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function log(method: Function, context: ClassMethodDecoratorContext): void;
|
|
104
|
+
export declare function log(level: LogLevel): (method: Function, context: ClassMethodDecoratorContext) => void;
|
|
105
|
+
export declare function log(options: LogOptions): (method: Function, context: ClassMethodDecoratorContext) => void;
|
|
106
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/element/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,QAAQ;IACrB,mBAAmB;IACnB,KAAK,EAAE,QAAQ,CAAC;IAChB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,kCAAkC;IAClC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,EAAE,CAAC,CAAC;CACzD;AAID;;;;;;;;GAQG;AACH,8BAAsB,YAAY;IAC9B,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CACvC;AAED;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAC9C,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAgB9B;AAcD,yDAAyD;AACzD,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,GAAG,CACf,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,2BAA2B,GACrC,IAAI,CAAC;AACR,wBAAgB,GAAG,CACf,KAAK,EAAE,QAAQ,GAChB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC;AACpE,wBAAgB,GAAG,CACf,OAAO,EAAE,UAAU,GACpB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — @log decorator + LogTransport (TC39 Stage 3)
|
|
3
|
+
*
|
|
4
|
+
* Pluggable structured logging for Loom components.
|
|
5
|
+
* Same transport pattern as RpcTransport in loom-rpc.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // Register a transport
|
|
9
|
+
* app.use(LogTransport, new ConsoleTransport());
|
|
10
|
+
*
|
|
11
|
+
* // Decorate methods
|
|
12
|
+
* @log
|
|
13
|
+
* open() { this.isOpen = true; }
|
|
14
|
+
*
|
|
15
|
+
* @log("warn")
|
|
16
|
+
* dangerousAction() { ... }
|
|
17
|
+
*
|
|
18
|
+
* @log({ level: "debug", label: "Search" })
|
|
19
|
+
* onInput(e: Event) { ... }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { app } from "../app";
|
|
23
|
+
// ── Transport ──
|
|
24
|
+
/**
|
|
25
|
+
* Abstract log transport — implement this to control where logs go.
|
|
26
|
+
*
|
|
27
|
+
* Registered as a DI service via `app.use(LogTransport, impl)`.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* app.use(LogTransport, new ConsoleTransport());
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export class LogTransport {
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Default console transport — styled, color-coded output.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* app.use(LogTransport, new ConsoleTransport());
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class ConsoleTransport extends LogTransport {
|
|
43
|
+
send(entry) {
|
|
44
|
+
const tag = entry.label
|
|
45
|
+
? `[${entry.component}:${entry.label}]`
|
|
46
|
+
: `[${entry.component}]`;
|
|
47
|
+
const parts = [
|
|
48
|
+
`${tag} ${entry.method}()`,
|
|
49
|
+
];
|
|
50
|
+
if (entry.args.length > 0)
|
|
51
|
+
parts.push("args:", entry.args);
|
|
52
|
+
if (entry.error)
|
|
53
|
+
parts.push("error:", entry.error);
|
|
54
|
+
else if (entry.result !== undefined)
|
|
55
|
+
parts.push("→", entry.result);
|
|
56
|
+
parts.push(`(${entry.duration.toFixed(1)}ms)`);
|
|
57
|
+
console[entry.level](...parts);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// ── Cached transport resolution ──
|
|
61
|
+
let _transport = false; // false = unchecked
|
|
62
|
+
function getTransport() {
|
|
63
|
+
if (_transport === false) {
|
|
64
|
+
const result = app.maybe(LogTransport);
|
|
65
|
+
_transport = result.ok ? result.unwrap() : null;
|
|
66
|
+
}
|
|
67
|
+
return _transport;
|
|
68
|
+
}
|
|
69
|
+
/** Reset cached transport (for testing or hot-reload) */
|
|
70
|
+
export function resetLogTransport() {
|
|
71
|
+
_transport = false;
|
|
72
|
+
}
|
|
73
|
+
export function log(methodOrLevelOrOpts, context) {
|
|
74
|
+
// Direct decoration: @log (no parentheses)
|
|
75
|
+
if (typeof methodOrLevelOrOpts === "function" && context) {
|
|
76
|
+
return applyLog(methodOrLevelOrOpts, context, {});
|
|
77
|
+
}
|
|
78
|
+
// Called with args: @log("warn") or @log({ level, label })
|
|
79
|
+
const opts = typeof methodOrLevelOrOpts === "string"
|
|
80
|
+
? { level: methodOrLevelOrOpts }
|
|
81
|
+
: methodOrLevelOrOpts;
|
|
82
|
+
return (method, ctx) => {
|
|
83
|
+
return applyLog(method, ctx, opts);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// ── Arg sanitization ──
|
|
87
|
+
const REDACTED = "[redacted]";
|
|
88
|
+
function sanitizeArgs(args, includeArgs, skipArgs) {
|
|
89
|
+
if (!includeArgs)
|
|
90
|
+
return [];
|
|
91
|
+
if (!skipArgs)
|
|
92
|
+
return args;
|
|
93
|
+
// Array form: [0, 2] — fully redact those indices
|
|
94
|
+
if (Array.isArray(skipArgs)) {
|
|
95
|
+
return args.map((arg, i) => skipArgs.includes(i) ? REDACTED : arg);
|
|
96
|
+
}
|
|
97
|
+
// Record form: { 0: true, 1: ["password", "user.email"] }
|
|
98
|
+
return args.map((arg, i) => {
|
|
99
|
+
const rule = skipArgs[i];
|
|
100
|
+
if (rule === undefined)
|
|
101
|
+
return arg;
|
|
102
|
+
if (rule === true)
|
|
103
|
+
return REDACTED;
|
|
104
|
+
// rule is string[] — redact nested keys from a cloned object
|
|
105
|
+
if (typeof arg !== "object" || arg === null)
|
|
106
|
+
return arg;
|
|
107
|
+
const clone = deepClone(arg);
|
|
108
|
+
for (const path of rule) {
|
|
109
|
+
redactPath(clone, path);
|
|
110
|
+
}
|
|
111
|
+
return clone;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function deepClone(obj) {
|
|
115
|
+
if (typeof obj !== "object" || obj === null)
|
|
116
|
+
return obj;
|
|
117
|
+
if (Array.isArray(obj))
|
|
118
|
+
return obj.map(deepClone);
|
|
119
|
+
const out = {};
|
|
120
|
+
for (const k of Object.keys(obj)) {
|
|
121
|
+
out[k] = deepClone(obj[k]);
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
function redactPath(obj, path) {
|
|
126
|
+
const parts = path.split(".");
|
|
127
|
+
let target = obj;
|
|
128
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
129
|
+
target = target?.[parts[i]];
|
|
130
|
+
if (typeof target !== "object" || target === null)
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const last = parts[parts.length - 1];
|
|
134
|
+
if (target && last in target) {
|
|
135
|
+
target[last] = REDACTED;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function applyLog(method, context, opts) {
|
|
139
|
+
const methodName = String(context.name);
|
|
140
|
+
const level = opts.level ?? "info";
|
|
141
|
+
const label = opts.label;
|
|
142
|
+
const includeArgs = opts.includeArgs !== false;
|
|
143
|
+
const skipArgs = opts.skipArgs;
|
|
144
|
+
// Replace the method on the prototype via addInitializer
|
|
145
|
+
context.addInitializer(function () {
|
|
146
|
+
const original = this[methodName].bind(this);
|
|
147
|
+
const component = this.tagName?.toLowerCase() ?? "unknown";
|
|
148
|
+
this[methodName] = function (...args) {
|
|
149
|
+
const transport = getTransport();
|
|
150
|
+
if (!transport)
|
|
151
|
+
return original(...args);
|
|
152
|
+
const start = performance.now();
|
|
153
|
+
const timestamp = Date.now();
|
|
154
|
+
let result;
|
|
155
|
+
try {
|
|
156
|
+
result = original(...args);
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
const duration = performance.now() - start;
|
|
160
|
+
transport.send({
|
|
161
|
+
level: "error",
|
|
162
|
+
component,
|
|
163
|
+
method: methodName,
|
|
164
|
+
label,
|
|
165
|
+
args: sanitizeArgs(args, includeArgs, skipArgs),
|
|
166
|
+
error: err instanceof Error ? err : new Error(String(err)),
|
|
167
|
+
duration,
|
|
168
|
+
timestamp,
|
|
169
|
+
});
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
// Async support — log after promise resolves/rejects
|
|
173
|
+
if (result instanceof Promise) {
|
|
174
|
+
return result.then((resolved) => {
|
|
175
|
+
const duration = performance.now() - start;
|
|
176
|
+
transport.send({
|
|
177
|
+
level,
|
|
178
|
+
component,
|
|
179
|
+
method: methodName,
|
|
180
|
+
label,
|
|
181
|
+
args: sanitizeArgs(args, includeArgs, skipArgs),
|
|
182
|
+
result: resolved,
|
|
183
|
+
duration,
|
|
184
|
+
timestamp,
|
|
185
|
+
});
|
|
186
|
+
return resolved;
|
|
187
|
+
}, (err) => {
|
|
188
|
+
const duration = performance.now() - start;
|
|
189
|
+
transport.send({
|
|
190
|
+
level: "error",
|
|
191
|
+
component,
|
|
192
|
+
method: methodName,
|
|
193
|
+
label,
|
|
194
|
+
args: sanitizeArgs(args, includeArgs, skipArgs),
|
|
195
|
+
error: err instanceof Error ? err : new Error(String(err)),
|
|
196
|
+
duration,
|
|
197
|
+
timestamp,
|
|
198
|
+
});
|
|
199
|
+
throw err;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// Sync — log immediately
|
|
203
|
+
const duration = performance.now() - start;
|
|
204
|
+
transport.send({
|
|
205
|
+
level,
|
|
206
|
+
component,
|
|
207
|
+
method: methodName,
|
|
208
|
+
label,
|
|
209
|
+
args: sanitizeArgs(args, includeArgs, skipArgs),
|
|
210
|
+
result,
|
|
211
|
+
duration,
|
|
212
|
+
timestamp,
|
|
213
|
+
});
|
|
214
|
+
return result;
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/element/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AA4C7B,kBAAkB;AAElB;;;;;;;;GAQG;AACH,MAAM,OAAgB,YAAY;CAEjC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9C,IAAI,CAAC,KAAe;QAChB,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK;YACnB,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,KAAK,GAAG;YACvC,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,GAAG,CAAC;QAE7B,MAAM,KAAK,GAAc;YACrB,GAAG,GAAG,IAAI,KAAK,CAAC,MAAM,IAAI;SAC7B,CAAC;QAEF,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,KAAK,CAAC,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;aAC9C,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACnE,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,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Y,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC;wBAC/C,MAAM,EAAE,QAAQ;wBAChB,QAAQ;wBACR,SAAS;qBACZ,CAAC,CAAC;oBACH,OAAO,QAAQ,CAAC;gBACpB,CAAC,EACD,CAAC,GAAG,EAAE,EAAE;oBACJ,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;oBAC3C,SAAS,CAAC,IAAI,CAAC;wBACX,KAAK,EAAE,OAAO;wBACd,SAAS;wBACT,MAAM,EAAE,UAAU;wBAClB,KAAK;wBACL,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC;wBAC/C,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;wBAC1D,QAAQ;wBACR,SAAS;qBACZ,CAAC,CAAC;oBACH,MAAM,GAAG,CAAC;gBACd,CAAC,CACJ,CAAC;YACN,CAAC;YAED,yBAAyB;YACzB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;YAC3C,SAAS,CAAC,IAAI,CAAC;gBACX,KAAK;gBACL,SAAS;gBACT,MAAM,EAAE,UAAU;gBAClB,KAAK;gBACL,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC;gBAC/C,MAAM;gBACN,QAAQ;gBACR,SAAS;aACZ,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ export { service, resolveServiceName, inject, factory } from "./di";
|
|
|
21
21
|
export { SERVICE_NAME } from "./decorators/symbols";
|
|
22
22
|
/** @deprecated Use `@watch(Service)` or `@watch(Service, "prop")` instead. Will be removed in v1.0. */
|
|
23
23
|
export { watch as watchService } from "./di";
|
|
24
|
-
export { LoomElement, component, query, queryAll, styles, catch_, suspend, mount, unmount, event, observer, interval, timeout, debounce, throttle, animationFrame, form, lazy, slot, transition, hotkey, } from "./element";
|
|
25
|
-
export type { FormState, FormSchema, FieldSchema, LazyOptions, TransitionOptions, HotkeyOptions } from "./element";
|
|
24
|
+
export { LoomElement, component, query, queryAll, styles, catch_, suspend, mount, unmount, event, observer, interval, timeout, debounce, throttle, animationFrame, form, lazy, slot, transition, hotkey, log, LogTransport, ConsoleTransport, provide, consume, ContextRequestEvent, } from "./element";
|
|
25
|
+
export type { FormState, FormSchema, FieldSchema, LazyOptions, TransitionOptions, HotkeyOptions, LogEntry, LogLevel, LogOptions, ContextCallback } from "./element";
|
|
26
26
|
export { transform, createTransform, typed, typedTransformer, toNumber, toBoolean, toDate, toJSON, toTrimmed, toInt, toFloat, } from "./transform";
|
|
27
27
|
export type { TransformSchema } from "./transform";
|
|
28
28
|
export { on, emit, createDecorator, createSymbol, LoomSymbol, SYMBOL_REGISTRY } from "./decorators";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGrC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC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AAG,EAAE,YAAY,EAAE,gBAAgB,EACnC,OAAO,EAAE,OAAO,EAAE,mBAAmB,GACtC,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGpK,OAAO,EACL,SAAS,EAAE,eAAe,EAC1B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAC/D,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpG,OAAO,EACL,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,KAAK,EACL,UAAU,EACV,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG5F,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ export { SERVICE_NAME } from "./decorators/symbols";
|
|
|
26
26
|
/** @deprecated Use `@watch(Service)` or `@watch(Service, "prop")` instead. Will be removed in v1.0. */
|
|
27
27
|
export { watch as watchService } from "./di";
|
|
28
28
|
// Element: base class, element decorators
|
|
29
|
-
export { LoomElement, component, query, queryAll, styles, catch_, suspend, mount, unmount, event, observer, interval, timeout, debounce, throttle, animationFrame, form, lazy, slot, transition, hotkey, } from "./element";
|
|
29
|
+
export { LoomElement, component, query, queryAll, styles, catch_, suspend, mount, unmount, event, observer, interval, timeout, debounce, throttle, animationFrame, form, lazy, slot, transition, hotkey, log, LogTransport, ConsoleTransport, provide, consume, ContextRequestEvent, } from "./element";
|
|
30
30
|
// Transform: value transforms
|
|
31
31
|
export { transform, createTransform, typed, typedTransformer, toNumber, toBoolean, toDate, toJSON, toTrimmed, toInt, toFloat, } from "./transform";
|
|
32
32
|
// Decorators: event decorators + factory
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kBAAkB;AAClB,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG9C,MAAM;AACN,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,eAAe;AACf,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,wDAAwD;AACxD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEpD,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,0BAA0B;AAE1B,qCAAqC;AACrC,OAAO,EACL,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EACvE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE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