devframe 0.0.0 → 0.1.17

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.
Files changed (75) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +62 -0
  3. package/dist/_shared-Bxa2_kq7.mjs +20 -0
  4. package/dist/adapters/build.d.mts +37 -0
  5. package/dist/adapters/build.mjs +68 -0
  6. package/dist/adapters/cli.d.mts +35 -0
  7. package/dist/adapters/cli.mjs +357 -0
  8. package/dist/adapters/embedded.d.mts +19 -0
  9. package/dist/adapters/embedded.mjs +15 -0
  10. package/dist/adapters/kit.d.mts +23 -0
  11. package/dist/adapters/kit.mjs +16 -0
  12. package/dist/adapters/mcp.d.mts +39 -0
  13. package/dist/adapters/mcp.mjs +278 -0
  14. package/dist/adapters/vite.d.mts +32 -0
  15. package/dist/adapters/vite.mjs +31 -0
  16. package/dist/client/index.d.mts +228 -0
  17. package/dist/client/index.mjs +2 -0
  18. package/dist/client-CsR1_h3o.mjs +1569 -0
  19. package/dist/constants.d.mts +20 -0
  20. package/dist/constants.mjs +34 -0
  21. package/dist/context-xQo1FcxX.mjs +6827 -0
  22. package/dist/define-CW9gLnyG.mjs +11 -0
  23. package/dist/devtool-CHT-4_OU.d.mts +1233 -0
  24. package/dist/helpers/nuxt/index.d.mts +46 -0
  25. package/dist/helpers/nuxt/index.mjs +58 -0
  26. package/dist/helpers/nuxt/runtime/plugin.client.d.mts +8 -0
  27. package/dist/helpers/nuxt/runtime/plugin.client.mjs +12 -0
  28. package/dist/human-id-CHS0s28X.mjs +844 -0
  29. package/dist/immer-DEqg5kOd.mjs +894 -0
  30. package/dist/index-Cei8vVcd.d.mts +140 -0
  31. package/dist/index.d.mts +10 -0
  32. package/dist/index.mjs +2 -0
  33. package/dist/main-BJD9t8dk.mjs +601 -0
  34. package/dist/node/index.d.mts +393 -0
  35. package/dist/node/index.mjs +69 -0
  36. package/dist/open-BMO2_-wC.mjs +533 -0
  37. package/dist/recipes/open-helpers.d.mts +108 -0
  38. package/dist/recipes/open-helpers.mjs +69 -0
  39. package/dist/rpc/client.d.mts +9 -0
  40. package/dist/rpc/client.mjs +13 -0
  41. package/dist/rpc/index.d.mts +3 -0
  42. package/dist/rpc/index.mjs +4 -0
  43. package/dist/rpc/server.d.mts +8 -0
  44. package/dist/rpc/server.mjs +10 -0
  45. package/dist/rpc/transports/ws-client.d.mts +2 -0
  46. package/dist/rpc/transports/ws-client.mjs +58 -0
  47. package/dist/rpc/transports/ws-server.d.mts +2 -0
  48. package/dist/rpc/transports/ws-server.mjs +73 -0
  49. package/dist/rpc-hbRk8qtt.mjs +456 -0
  50. package/dist/serialization-CWcWE7x7.mjs +112 -0
  51. package/dist/server-DkJ2-s0Y.mjs +49 -0
  52. package/dist/src-DIKqQIjp.mjs +85 -0
  53. package/dist/static-dump-DwFfj4U_.mjs +97 -0
  54. package/dist/transports-4bqw6Fqg.mjs +15 -0
  55. package/dist/types/index.d.mts +4 -0
  56. package/dist/types/index.mjs +6 -0
  57. package/dist/types-BkyzI9r4.d.mts +273 -0
  58. package/dist/utils/events.d.mts +9 -0
  59. package/dist/utils/events.mjs +40 -0
  60. package/dist/utils/human-id.d.mts +10 -0
  61. package/dist/utils/human-id.mjs +3 -0
  62. package/dist/utils/nanoid.d.mts +4 -0
  63. package/dist/utils/nanoid.mjs +10 -0
  64. package/dist/utils/promise.d.mts +8 -0
  65. package/dist/utils/promise.mjs +15 -0
  66. package/dist/utils/shared-state.d.mts +2 -0
  67. package/dist/utils/shared-state.mjs +36 -0
  68. package/dist/utils/state.d.mts +49 -0
  69. package/dist/utils/state.mjs +26 -0
  70. package/dist/utils/when.d.mts +2 -0
  71. package/dist/utils/when.mjs +424 -0
  72. package/dist/when-aBBXAEh5.d.mts +401 -0
  73. package/dist/ws-client-CDGmViwt.d.mts +26 -0
  74. package/dist/ws-server-Cu8tmZcF.d.mts +49 -0
  75. package/package.json +116 -8
@@ -0,0 +1,401 @@
1
+ //#region ../../../node_modules/.pnpm/whenexpr@0.1.2/node_modules/whenexpr/dist/index.d.mts
2
+ //#region src/paths.d.ts
3
+ /**
4
+ * Union of valid context paths for `T` — both flat keys (`keyof T`) and
5
+ * `.`/`:`-separated nested paths. Mirrors the runtime `resolve()` lookup:
6
+ * first a flat literal key, then a segmented path.
7
+ *
8
+ * @example
9
+ * type P = ContextPaths<{ editor: { lang: string }, debug: boolean }>
10
+ * // 'editor' | 'debug' | 'editor.lang' | 'editor:lang'
11
+ */
12
+ type ContextPaths<T, P extends string = ''> = { [K in keyof T & string]: `${P}${K}` | (T[K] extends readonly unknown[] ? never : T[K] extends ((...args: never[]) => unknown) ? never : T[K] extends object ? ContextPaths<T[K], `${P}${K}.`> | ContextPaths<T[K], `${P}${K}:`> : never) }[keyof T & string]; //#endregion
13
+ //#region src/types.d.ts
14
+ /**
15
+ * Branded error type surfaced at the call site of `evaluateWhen` when the
16
+ * expression string fails static validation. The embedded message appears in
17
+ * the TS error tooltip because `WhenExpressionError<M>` is not assignable from a
18
+ * plain string literal.
19
+ */
20
+ type WhenExpressionError<M extends string> = string & {
21
+ readonly __whenExpressionError: M;
22
+ };
23
+ type Ws = ' ' | '\t' | '\n' | '\r';
24
+ type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
25
+ type Lower = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
26
+ type Upper = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
27
+ type IdentStart = Lower | Upper | '_' | '$';
28
+ type IdentCont = IdentStart | Digit | '.' | ':';
29
+ type Op = '===' | '!==' | '==' | '!=' | '<=' | '>=' | '&&' | '||' | '<' | '>' | '+' | '-' | '*' | '/' | '%' | '!';
30
+ type Tok = {
31
+ k: 'num';
32
+ v: string;
33
+ } | {
34
+ k: 'str';
35
+ v: string;
36
+ } | {
37
+ k: 'id';
38
+ v: string;
39
+ } | {
40
+ k: 'bool';
41
+ v: 'true' | 'false';
42
+ } | {
43
+ k: 'op';
44
+ v: Op;
45
+ } | {
46
+ k: 'lp';
47
+ } | {
48
+ k: 'rp';
49
+ } | {
50
+ k: 'eof';
51
+ };
52
+ interface TokErr {
53
+ __err: string;
54
+ }
55
+ type Tokenize<S extends string, Acc extends Tok[] = []> = S extends '' ? [...Acc, {
56
+ k: 'eof';
57
+ }] : S extends `${Ws}${infer R}` ? Tokenize<R, Acc> : S extends `===${infer R}` ? Tokenize<R, [...Acc, {
58
+ k: 'op';
59
+ v: '===';
60
+ }]> : S extends `!==${infer R}` ? Tokenize<R, [...Acc, {
61
+ k: 'op';
62
+ v: '!==';
63
+ }]> : S extends `==${infer R}` ? Tokenize<R, [...Acc, {
64
+ k: 'op';
65
+ v: '==';
66
+ }]> : S extends `!=${infer R}` ? Tokenize<R, [...Acc, {
67
+ k: 'op';
68
+ v: '!=';
69
+ }]> : S extends `<=${infer R}` ? Tokenize<R, [...Acc, {
70
+ k: 'op';
71
+ v: '<=';
72
+ }]> : S extends `>=${infer R}` ? Tokenize<R, [...Acc, {
73
+ k: 'op';
74
+ v: '>=';
75
+ }]> : S extends `&&${infer R}` ? Tokenize<R, [...Acc, {
76
+ k: 'op';
77
+ v: '&&';
78
+ }]> : S extends `||${infer R}` ? Tokenize<R, [...Acc, {
79
+ k: 'op';
80
+ v: '||';
81
+ }]> : S extends `<${infer R}` ? Tokenize<R, [...Acc, {
82
+ k: 'op';
83
+ v: '<';
84
+ }]> : S extends `>${infer R}` ? Tokenize<R, [...Acc, {
85
+ k: 'op';
86
+ v: '>';
87
+ }]> : S extends `+${infer R}` ? Tokenize<R, [...Acc, {
88
+ k: 'op';
89
+ v: '+';
90
+ }]> : S extends `-${infer R}` ? Tokenize<R, [...Acc, {
91
+ k: 'op';
92
+ v: '-';
93
+ }]> : S extends `*${infer R}` ? Tokenize<R, [...Acc, {
94
+ k: 'op';
95
+ v: '*';
96
+ }]> : S extends `/${infer R}` ? Tokenize<R, [...Acc, {
97
+ k: 'op';
98
+ v: '/';
99
+ }]> : S extends `%${infer R}` ? Tokenize<R, [...Acc, {
100
+ k: 'op';
101
+ v: '%';
102
+ }]> : S extends `!${infer R}` ? Tokenize<R, [...Acc, {
103
+ k: 'op';
104
+ v: '!';
105
+ }]> : S extends `(${infer R}` ? Tokenize<R, [...Acc, {
106
+ k: 'lp';
107
+ }]> : S extends `)${infer R}` ? Tokenize<R, [...Acc, {
108
+ k: 'rp';
109
+ }]> : S extends `"${infer R}` ? ConsumeStr<R, '', '"', Acc> : S extends `'${infer R}` ? ConsumeStr<R, '', '\'', Acc> : S extends `${infer C extends Digit}${infer R}` ? ConsumeNum<R, C, Acc> : S extends `${infer C extends IdentStart}${infer R}` ? ConsumeIdent<R, C, Acc> : {
110
+ __err: `Unexpected character in "${S}"`;
111
+ };
112
+ type ConsumeNum<S extends string, N extends string, Acc extends Tok[]> = S extends `${infer C extends Digit}${infer R}` ? ConsumeNum<R, `${N}${C}`, Acc> : S extends `.${infer C extends Digit}${infer R}` ? ConsumeNumFrac<R, `${N}.${C}`, Acc> : Tokenize<S, [...Acc, {
113
+ k: 'num';
114
+ v: N;
115
+ }]>;
116
+ type ConsumeNumFrac<S extends string, N extends string, Acc extends Tok[]> = S extends `${infer C extends Digit}${infer R}` ? ConsumeNumFrac<R, `${N}${C}`, Acc> : Tokenize<S, [...Acc, {
117
+ k: 'num';
118
+ v: N;
119
+ }]>;
120
+ type ConsumeIdent<S extends string, N extends string, Acc extends Tok[]> = S extends `${infer C extends IdentCont}${infer R}` ? ConsumeIdent<R, `${N}${C}`, Acc> : Tokenize<S, [...Acc, ClassifyIdent<N>]>;
121
+ type ClassifyIdent<N extends string> = N extends 'true' ? {
122
+ k: 'bool';
123
+ v: 'true';
124
+ } : N extends 'false' ? {
125
+ k: 'bool';
126
+ v: 'false';
127
+ } : {
128
+ k: 'id';
129
+ v: N;
130
+ };
131
+ type ConsumeStr<S extends string, V extends string, Q extends '"' | '\'', Acc extends Tok[]> = S extends `${Q}${infer R}` ? Tokenize<R, [...Acc, {
132
+ k: 'str';
133
+ v: V;
134
+ }]> : S extends `\\${infer C}${infer R}` ? ConsumeStr<R, `${V}${C}`, Q, Acc> : S extends `${infer C}${infer R}` ? ConsumeStr<R, `${V}${C}`, Q, Acc> : {
135
+ __err: 'Unterminated string literal';
136
+ };
137
+ type BinOp = '||' | '&&' | '==' | '!=' | '===' | '!==' | '<' | '>' | '<=' | '>=' | '+' | '-' | '*' | '/' | '%';
138
+ type UnOp = '!' | '-' | '+';
139
+ interface LitNode {
140
+ t: 'lit';
141
+ v: string;
142
+ }
143
+ interface KeyNode {
144
+ t: 'key';
145
+ v: string;
146
+ }
147
+ interface UnNode {
148
+ t: 'un';
149
+ op: UnOp;
150
+ x: Ast;
151
+ }
152
+ interface BinNode {
153
+ t: 'bin';
154
+ op: BinOp;
155
+ l: Ast;
156
+ r: Ast;
157
+ }
158
+ type Ast = LitNode | KeyNode | UnNode | BinNode;
159
+ type Parse<Toks extends Tok[]> = ParseOr<Toks>;
160
+ type ParseOr<T extends Tok[]> = OrTail<ParseAnd<T>>;
161
+ type OrTail<R> = R extends [infer L extends Ast, infer Rest extends Tok[]] ? Rest extends [{
162
+ k: 'op';
163
+ v: '||';
164
+ }, ...infer After extends Tok[]] ? ParseAnd<After> extends [infer Rh extends Ast, infer Next extends Tok[]] ? OrTail<[{
165
+ t: 'bin';
166
+ op: '||';
167
+ l: L;
168
+ r: Rh;
169
+ }, Next]> : 'err' : R : R;
170
+ type ParseAnd<T extends Tok[]> = AndTail<ParseEq<T>>;
171
+ type AndTail<R> = R extends [infer L extends Ast, infer Rest extends Tok[]] ? Rest extends [{
172
+ k: 'op';
173
+ v: '&&';
174
+ }, ...infer After extends Tok[]] ? ParseEq<After> extends [infer Rh extends Ast, infer Next extends Tok[]] ? AndTail<[{
175
+ t: 'bin';
176
+ op: '&&';
177
+ l: L;
178
+ r: Rh;
179
+ }, Next]> : 'err' : R : R;
180
+ type ParseEq<T extends Tok[]> = EqTail<ParseRel<T>>;
181
+ type EqTail<R> = R extends [infer L extends Ast, infer Rest extends Tok[]] ? Rest extends [{
182
+ k: 'op';
183
+ v: infer O extends '==' | '!=';
184
+ }, ...infer After extends Tok[]] ? ParseValueRhs<After> extends [infer Rh extends Ast, infer Next extends Tok[]] ? EqTail<[{
185
+ t: 'bin';
186
+ op: O;
187
+ l: L;
188
+ r: Rh;
189
+ }, Next]> : 'err' : Rest extends [{
190
+ k: 'op';
191
+ v: infer O extends '===' | '!==';
192
+ }, ...infer After extends Tok[]] ? ParseRel<After> extends [infer Rh extends Ast, infer Next extends Tok[]] ? EqTail<[{
193
+ t: 'bin';
194
+ op: O;
195
+ l: L;
196
+ r: Rh;
197
+ }, Next]> : 'err' : R : R;
198
+ type ParseValueRhs<T extends Tok[]> = T extends [{
199
+ k: 'id';
200
+ v: infer V extends string;
201
+ }, ...infer R extends Tok[]] ? [{
202
+ t: 'lit';
203
+ v: V;
204
+ }, R] : T extends [{
205
+ k: 'str';
206
+ v: infer V extends string;
207
+ }, ...infer R extends Tok[]] ? [{
208
+ t: 'lit';
209
+ v: V;
210
+ }, R] : T extends [{
211
+ k: 'num';
212
+ v: infer V extends string;
213
+ }, ...infer R extends Tok[]] ? [{
214
+ t: 'lit';
215
+ v: V;
216
+ }, R] : T extends [{
217
+ k: 'bool';
218
+ v: infer V extends string;
219
+ }, ...infer R extends Tok[]] ? [{
220
+ t: 'lit';
221
+ v: V;
222
+ }, R] : 'err';
223
+ type ParseRel<T extends Tok[]> = RelTail<ParseAdd<T>>;
224
+ type RelTail<R> = R extends [infer L extends Ast, infer Rest extends Tok[]] ? Rest extends [{
225
+ k: 'op';
226
+ v: infer O extends '<=' | '>=' | '<' | '>';
227
+ }, ...infer After extends Tok[]] ? ParseAdd<After> extends [infer Rh extends Ast, infer Next extends Tok[]] ? RelTail<[{
228
+ t: 'bin';
229
+ op: O;
230
+ l: L;
231
+ r: Rh;
232
+ }, Next]> : 'err' : R : R;
233
+ type ParseAdd<T extends Tok[]> = AddTail<ParseMul<T>>;
234
+ type AddTail<R> = R extends [infer L extends Ast, infer Rest extends Tok[]] ? Rest extends [{
235
+ k: 'op';
236
+ v: infer O extends '+' | '-';
237
+ }, ...infer After extends Tok[]] ? ParseMul<After> extends [infer Rh extends Ast, infer Next extends Tok[]] ? AddTail<[{
238
+ t: 'bin';
239
+ op: O;
240
+ l: L;
241
+ r: Rh;
242
+ }, Next]> : 'err' : R : R;
243
+ type ParseMul<T extends Tok[]> = MulTail<ParseUnary<T>>;
244
+ type MulTail<R> = R extends [infer L extends Ast, infer Rest extends Tok[]] ? Rest extends [{
245
+ k: 'op';
246
+ v: infer O extends '*' | '/' | '%';
247
+ }, ...infer After extends Tok[]] ? ParseUnary<After> extends [infer Rh extends Ast, infer Next extends Tok[]] ? MulTail<[{
248
+ t: 'bin';
249
+ op: O;
250
+ l: L;
251
+ r: Rh;
252
+ }, Next]> : 'err' : R : R;
253
+ type ParseUnary<T extends Tok[]> = T extends [{
254
+ k: 'op';
255
+ v: infer O extends UnOp;
256
+ }, ...infer Rest extends Tok[]] ? ParseUnary<Rest> extends [infer X extends Ast, infer Next extends Tok[]] ? [{
257
+ t: 'un';
258
+ op: O;
259
+ x: X;
260
+ }, Next] : 'err' : ParsePrimary<T>;
261
+ type ParsePrimary<T extends Tok[]> = T extends [{
262
+ k: 'num';
263
+ v: infer V extends string;
264
+ }, ...infer R extends Tok[]] ? [{
265
+ t: 'lit';
266
+ v: V;
267
+ }, R] : T extends [{
268
+ k: 'str';
269
+ v: infer V extends string;
270
+ }, ...infer R extends Tok[]] ? [{
271
+ t: 'lit';
272
+ v: V;
273
+ }, R] : T extends [{
274
+ k: 'bool';
275
+ v: infer V extends string;
276
+ }, ...infer R extends Tok[]] ? [{
277
+ t: 'lit';
278
+ v: V;
279
+ }, R] : T extends [{
280
+ k: 'id';
281
+ v: infer V extends string;
282
+ }, ...infer R extends Tok[]] ? [{
283
+ t: 'key';
284
+ v: V;
285
+ }, R] : T extends [{
286
+ k: 'lp';
287
+ }, ...infer Rest extends Tok[]] ? ParseOr<Rest> extends [infer N extends Ast, infer After extends Tok[]] ? After extends [{
288
+ k: 'rp';
289
+ }, ...infer Next extends Tok[]] ? [N, Next] : 'err' : 'err' : 'err';
290
+ type CollectKeys<N> = N extends KeyNode ? N['v'] : N extends UnNode ? CollectKeys<N['x']> : N extends {
291
+ t: 'bin';
292
+ op: '==' | '!=';
293
+ l: infer L;
294
+ } ? CollectKeys<L> : N extends BinNode ? CollectKeys<N['l']> | CollectKeys<N['r']> : never;
295
+ /**
296
+ * Validate a when-clause expression string `S` against context type `T`.
297
+ * Returns `S` on success, or a `WhenExpressionError<Msg>` branded error string
298
+ * that surfaces at the call site with a human-readable message.
299
+ *
300
+ * - Dynamic `string` expressions skip all validation.
301
+ * - Wide context types (`object`, `any`, `unknown`, `Record<string, unknown>`,
302
+ * empty `{}`, etc.) still run **syntax** checking but skip **key** checking.
303
+ * - Specific context types run full validation (syntax + keys).
304
+ */
305
+ type ValidateExpression<S extends string, T> = string extends S ? S : Tokenize<S> extends infer Toks ? Toks extends TokErr ? WhenExpressionError<`Syntax error: ${Toks['__err']}`> : Toks extends Tok[] ? Parse<Toks> extends [infer N extends Ast, [{
306
+ k: 'eof';
307
+ }]] ? [keyof T] extends [never] ? S : string extends keyof T ? S : Exclude<CollectKeys<N>, ContextPaths<T>> extends infer Missing ? [Missing] extends [never] ? S : WhenExpressionError<`Unknown context key: "${Extract<Missing, string>}"`> : never : WhenExpressionError<'Syntax error in expression'> : never : never;
308
+ /**
309
+ * A when-clause expression string validated against context type `T`.
310
+ * Use inside your own typed define helpers to have TypeScript check `when`
311
+ * fields at the call site.
312
+ *
313
+ * @example
314
+ * interface AppCtx { mode: 'dev' | 'prod', debug: boolean }
315
+ *
316
+ * function defineCommand<const W extends string>(cmd: {
317
+ * name: string
318
+ * title: string
319
+ * when?: WhenExpression<AppCtx, W>
320
+ * }): typeof cmd {
321
+ * return cmd
322
+ * }
323
+ *
324
+ * defineCommand({ name: 'x', title: 'X', when: 'debug && mode == dev' })
325
+ * defineCommand({ name: 'x', title: 'X', when: 'typo' })
326
+ * // ^^^^^ type error
327
+ */
328
+ type WhenExpression<T, S extends string> = S & ValidateExpression<S, T>; //#endregion
329
+ //#region src/index.d.ts
330
+ interface EvaluateOptions {
331
+ /**
332
+ * If `true`, throw when the expression references a context key that does
333
+ * not exist. Defaults to `false`, where unknown keys evaluate to `undefined`.
334
+ */
335
+ strict?: boolean;
336
+ }
337
+ /**
338
+ * Evaluate a when-clause expression string against a context object.
339
+ * Equivalent to `evaluate(parse(expression), ctx, options)`.
340
+ *
341
+ * Supports a JS-expression subset:
342
+ * - Literals: booleans, numbers, strings (quoted with `"` or `'`)
343
+ * - Identifiers: bare keys, including namespaced (`vite.mode`, `vite:buildMode`)
344
+ * - Logical: `&&`, `||`, `!`
345
+ * - Equality: `==`, `!=` (string comparison, bare identifier RHS treated as string),
346
+ * `===`, `!==` (JS strict equality with full expression RHS)
347
+ * - Relational: `<`, `<=`, `>`, `>=`
348
+ * - Arithmetic: `+`, `-`, `*`, `/`, `%`, unary `-` / `+`
349
+ * - Grouping: `(` … `)`
350
+ *
351
+ * When `ctx` has a specific type with known keys, the expression string is
352
+ * **statically validated** — unknown context keys and syntax errors surface
353
+ * as TypeScript errors at the call site. Pass `ctx` typed as
354
+ * `Record<string, unknown>`, or the expression as `string`, to opt out of
355
+ * static checking (e.g. for dynamic expressions).
356
+ *
357
+ * With `{ strict: true }`, referencing an unknown context key at runtime
358
+ * throws. Short-circuit evaluation still applies — keys not reached are not
359
+ * checked.
360
+ */
361
+ declare function evaluateWhen<T extends object, const E extends string>(expression: E & ValidateExpression<E, T>, ctx: T, options?: EvaluateOptions): boolean;
362
+ /**
363
+ * Resolve a context value by key. Supports namespaced keys with `.` or `:` separators.
364
+ *
365
+ * Lookup order:
366
+ * 1. Exact match — `ctx['plugin.mode']` or `ctx['plugin:mode']`
367
+ * 2. Nested path — e.g. `plugin.mode` falls back to `ctx.plugin?.mode`
368
+ *
369
+ * Returns `undefined` for unknown keys.
370
+ */
371
+ declare function resolveContextValue<T extends Record<string, unknown>>(key: string, ctx: T): unknown; //#endregion
372
+ //#endregion
373
+ //#region src/utils/when.d.ts
374
+ /**
375
+ * Context object for evaluating `when` expressions.
376
+ *
377
+ * Built-in variables:
378
+ * - `clientType` — `'embedded' | 'standalone'`
379
+ * - `dockOpen` — whether the dock panel is open
380
+ * - `paletteOpen` — whether the command palette is open
381
+ * - `dockSelectedId` — ID of the selected dock entry (empty string if none)
382
+ *
383
+ * Plugins can add namespaced variables using dot or colon separators:
384
+ * - `vite.mode`, `vite:mode` — stored as `{ 'vite.mode': 'development' }` or nested `{ vite: { mode: 'development' } }`
385
+ *
386
+ * The expression language — including all operators and precedence — is provided by
387
+ * the [`whenexpr`](https://github.com/antfu/whenexpr) package. In addition to the
388
+ * VS-Code-style `!`/`==`/`!=`/`&&`/`||` operators, parentheses, strict equality
389
+ * (`===`/`!==`), relational (`<`/`<=`/`>`/`>=`), arithmetic (`+ - * / %`), and
390
+ * number/string literals are supported.
391
+ */
392
+ interface WhenContext {
393
+ clientType: 'embedded' | 'standalone';
394
+ dockOpen: boolean;
395
+ paletteOpen: boolean;
396
+ dockSelectedId: string;
397
+ /** Allow custom context variables from plugins */
398
+ [key: string]: unknown;
399
+ }
400
+ //#endregion
401
+ export { resolveContextValue as i, WhenExpression as n, evaluateWhen as r, WhenContext as t };
@@ -0,0 +1,26 @@
1
+ import { g as RpcFunctionDefinitionAny } from "./types-BkyzI9r4.mjs";
2
+ import { ChannelOptions } from "birpc";
3
+
4
+ //#region src/rpc/transports/ws-client.d.ts
5
+ interface WsRpcChannelOptions {
6
+ url: string;
7
+ onConnected?: (e: Event) => void;
8
+ onError?: (e: Error) => void;
9
+ onDisconnected?: (e: CloseEvent) => void;
10
+ authToken?: string;
11
+ /**
12
+ * RPC function definitions (or just the `jsonSerializable` flag per
13
+ * method) used to dispatch the per-call wire serializer. Pass an
14
+ * empty / partial map on clients that don't have the full registry —
15
+ * encoding falls back to structured-clone (the safer superset) and
16
+ * decoding still routes correctly via the wire prefix.
17
+ */
18
+ definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>;
19
+ }
20
+ /**
21
+ * Build a birpc `ChannelOptions` object backed by a browser `WebSocket`.
22
+ * Pass the result straight to `createRpcClient`'s `channel` option.
23
+ */
24
+ declare function createWsRpcChannel(options: WsRpcChannelOptions): ChannelOptions;
25
+ //#endregion
26
+ export { createWsRpcChannel as n, WsRpcChannelOptions as t };
@@ -0,0 +1,49 @@
1
+ import { g as RpcFunctionDefinitionAny } from "./types-BkyzI9r4.mjs";
2
+ import { BirpcGroup, ChannelOptions } from "birpc";
3
+ import { ServerOptions } from "node:https";
4
+ import { WebSocket, WebSocketServer } from "ws";
5
+ import { IncomingMessage } from "node:http";
6
+
7
+ //#region src/rpc/transports/ws-server.d.ts
8
+ interface DevToolsNodeRpcSessionMeta {
9
+ id: number;
10
+ ws?: WebSocket;
11
+ clientAuthToken?: string;
12
+ isTrusted?: boolean;
13
+ subscribedStates: Set<string>;
14
+ }
15
+ interface WsRpcTransportOptions {
16
+ /** Attach to an existing WebSocketServer. When provided, `port`, `host`, and `https` are ignored. */
17
+ wss?: WebSocketServer;
18
+ /** Port for a newly-created WebSocketServer. */
19
+ port?: number;
20
+ /** Host for a newly-created WebSocketServer. Defaults to `localhost`. */
21
+ host?: string;
22
+ /** When set, a new https.Server is created and the WebSocketServer is attached to it. */
23
+ https?: ServerOptions;
24
+ /**
25
+ * RPC function definitions, used by the per-call wire serializer to
26
+ * dispatch between strict-JSON and structured-clone encoding based
27
+ * on each function's `jsonSerializable` flag.
28
+ *
29
+ * When omitted, all messages fall back to structured-clone — safe but
30
+ * loses dev-time validation for `jsonSerializable: true` declarations.
31
+ */
32
+ definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>;
33
+ onConnected?: (ws: WebSocket, req: IncomingMessage, meta: DevToolsNodeRpcSessionMeta) => void;
34
+ onDisconnected?: (ws: WebSocket, meta: DevToolsNodeRpcSessionMeta) => void;
35
+ /** Override the default per-call serializer. Most callers should leave this unset. */
36
+ serialize?: ChannelOptions['serialize'];
37
+ /** Override the default per-call deserializer. Most callers should leave this unset. */
38
+ deserialize?: ChannelOptions['deserialize'];
39
+ }
40
+ /**
41
+ * Attach a WebSocket transport to an existing RPC group. Either pass an
42
+ * existing `WebSocketServer` via `wss`, or let this helper create one from
43
+ * `port` / `host` / `https`.
44
+ */
45
+ declare function attachWsRpcTransport<ClientFunctions extends object, ServerFunctions extends object>(rpcGroup: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: WsRpcTransportOptions): {
46
+ wss: WebSocketServer;
47
+ };
48
+ //#endregion
49
+ export { WsRpcTransportOptions as n, attachWsRpcTransport as r, DevToolsNodeRpcSessionMeta as t };
package/package.json CHANGED
@@ -1,13 +1,121 @@
1
1
  {
2
2
  "name": "devframe",
3
- "version": "0.0.0",
4
- "packageManager": "pnpm@10.33.0",
5
- "description": "",
6
- "author": "Anthony Fu",
3
+ "type": "module",
4
+ "version": "0.1.17",
5
+ "description": "Framework for building generic DevTools",
6
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
8
- "keywords": [],
9
- "main": "index.js",
8
+ "homepage": "https://github.com/vitejs/devtools#readme",
9
+ "repository": {
10
+ "directory": "devframe/packages/devframe",
11
+ "type": "git",
12
+ "url": "git+https://github.com/vitejs/devtools.git"
13
+ },
14
+ "bugs": "https://github.com/vitejs/devtools/issues",
15
+ "keywords": [
16
+ "devtools",
17
+ "rpc",
18
+ "toolbox"
19
+ ],
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": "./dist/index.mjs",
23
+ "./adapters/build": "./dist/adapters/build.mjs",
24
+ "./adapters/cli": "./dist/adapters/cli.mjs",
25
+ "./adapters/embedded": "./dist/adapters/embedded.mjs",
26
+ "./adapters/kit": "./dist/adapters/kit.mjs",
27
+ "./adapters/mcp": "./dist/adapters/mcp.mjs",
28
+ "./adapters/vite": "./dist/adapters/vite.mjs",
29
+ "./client": "./dist/client/index.mjs",
30
+ "./constants": "./dist/constants.mjs",
31
+ "./helpers/nuxt": "./dist/helpers/nuxt/index.mjs",
32
+ "./helpers/nuxt/runtime/plugin.client": "./dist/helpers/nuxt/runtime/plugin.client.mjs",
33
+ "./node": "./dist/node/index.mjs",
34
+ "./recipes/open-helpers": "./dist/recipes/open-helpers.mjs",
35
+ "./rpc": "./dist/rpc/index.mjs",
36
+ "./rpc/client": "./dist/rpc/client.mjs",
37
+ "./rpc/server": "./dist/rpc/server.mjs",
38
+ "./rpc/transports/ws-client": "./dist/rpc/transports/ws-client.mjs",
39
+ "./rpc/transports/ws-server": "./dist/rpc/transports/ws-server.mjs",
40
+ "./types": "./dist/types/index.mjs",
41
+ "./utils/events": "./dist/utils/events.mjs",
42
+ "./utils/human-id": "./dist/utils/human-id.mjs",
43
+ "./utils/nanoid": "./dist/utils/nanoid.mjs",
44
+ "./utils/promise": "./dist/utils/promise.mjs",
45
+ "./utils/shared-state": "./dist/utils/shared-state.mjs",
46
+ "./utils/state": "./dist/utils/state.mjs",
47
+ "./utils/when": "./dist/utils/when.mjs",
48
+ "./package.json": "./package.json"
49
+ },
50
+ "types": "./dist/index.d.ts",
51
+ "files": [
52
+ "dist"
53
+ ],
54
+ "peerDependencies": {
55
+ "@modelcontextprotocol/sdk": "^1.0.0",
56
+ "@nuxt/kit": "^3.0.0 || ^4.0.0",
57
+ "launch-editor": "^2.0.0"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "@modelcontextprotocol/sdk": {
61
+ "optional": true
62
+ },
63
+ "@nuxt/kit": {
64
+ "optional": true
65
+ },
66
+ "launch-editor": {
67
+ "optional": true
68
+ }
69
+ },
70
+ "dependencies": {
71
+ "@valibot/to-json-schema": "^1.6.0",
72
+ "ansis": "^4.2.0",
73
+ "birpc": "^4.0.0",
74
+ "cac": "^7.0.0",
75
+ "h3": "^1.15.11",
76
+ "logs-sdk": "^0.0.6",
77
+ "ohash": "^2.0.11",
78
+ "pathe": "^2.0.3",
79
+ "sirv": "^3.0.2",
80
+ "structured-clone-es": "^2.0.0",
81
+ "valibot": "^1.3.1",
82
+ "ws": "^8.20.0"
83
+ },
84
+ "devDependencies": {
85
+ "@modelcontextprotocol/sdk": "^1.29.0",
86
+ "@nuxt/kit": "^4.4.4",
87
+ "launch-editor": "^2.13.2",
88
+ "tsdown": "^0.21.10",
89
+ "whenexpr": "^0.1.2"
90
+ },
91
+ "inlinedDependencies": {
92
+ "acorn": "8.16.0",
93
+ "bundle-name": "4.1.0",
94
+ "default-browser": "5.4.0",
95
+ "default-browser-id": "5.0.1",
96
+ "define-lazy-prop": "3.0.0",
97
+ "get-port-please": "3.2.0",
98
+ "human-id": "4.1.3",
99
+ "immer": "11.1.4",
100
+ "is-docker": "3.0.0",
101
+ "is-in-ssh": "1.0.0",
102
+ "is-inside-container": "1.0.0",
103
+ "is-wsl": "3.1.0",
104
+ "mlly": "1.8.2",
105
+ "obug": "2.1.1",
106
+ "open": "11.0.0",
107
+ "p-limit": "7.3.0",
108
+ "perfect-debounce": "2.1.0",
109
+ "powershell-utils": "0.1.0",
110
+ "run-applescript": "7.1.0",
111
+ "tinyexec": "1.1.2",
112
+ "ua-parser-modern": "0.1.1",
113
+ "whenexpr": "0.1.2",
114
+ "wsl-utils": "0.3.1",
115
+ "yocto-queue": "1.2.2"
116
+ },
10
117
  "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1"
118
+ "build": "tsdown",
119
+ "watch": "tsdown --watch"
12
120
  }
13
- }
121
+ }