@skybridge/vite-plugin 0.0.0-dev.50c10e1 → 0.0.0-dev.59194c3
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/README.md +4 -0
- package/dist/evals/index.d.ts +3 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +2 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/matchers.d.ts +26 -0
- package/dist/evals/matchers.d.ts.map +1 -0
- package/dist/evals/matchers.js +131 -0
- package/dist/evals/matchers.js.map +1 -0
- package/dist/evals/types.d.ts +27 -0
- package/dist/evals/types.d.ts.map +1 -0
- package/dist/evals/types.js +2 -0
- package/dist/evals/types.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +15 -23
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +37 -28
- package/dist/plugin.js.map +1 -1
- package/package.json +15 -3
- package/dist/scan-views.d.ts +0 -17
- package/dist/scan-views.d.ts.map +0 -1
- package/dist/scan-views.js +0 -88
- package/dist/scan-views.js.map +0 -1
- package/dist/validate-view.d.ts +0 -2
- package/dist/validate-view.d.ts.map +0 -1
- package/dist/validate-view.js +0 -9
- package/dist/validate-view.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@ The Vite plugin behind [Skybridge](https://skybridge.tech): it discovers view
|
|
|
4
4
|
modules, serves them as virtual entries, applies the `data-llm` transform, and
|
|
5
5
|
tells `skybridge build` which packages to leave unbundled.
|
|
6
6
|
|
|
7
|
+
Its `evals` option wires up [`@skybridge/test`](https://www.npmjs.com/package/@skybridge/test),
|
|
8
|
+
which boots the server and extends vitest's assertions with chat-oriented
|
|
9
|
+
matchers for checking that a prompt reaches the right tool.
|
|
10
|
+
|
|
7
11
|
Projects created with `npm create skybridge` already have it wired up.
|
|
8
12
|
|
|
9
13
|
```ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evals/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/evals/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "vitest";
|
|
2
|
+
import type { ToolInput, ToolNames } from "skybridge/server";
|
|
3
|
+
import type { ChatLike } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Assertions about the tool calls a conversation produced. Kept off vitest's
|
|
6
|
+
* global `Matchers` so they never appear on unrelated `expect()` calls, and so
|
|
7
|
+
* this stays the one place later tool-call helpers are added.
|
|
8
|
+
*/
|
|
9
|
+
export interface ChatMatchers<App> {
|
|
10
|
+
toHaveCalledToolOnce<Name extends ToolNames<App>>(name: Name, args?: Partial<ToolInput<App, Name>>): void;
|
|
11
|
+
toHaveCalledToolWith<Name extends ToolNames<App>>(name: Name, args: Partial<ToolInput<App, Name>>): void;
|
|
12
|
+
toNeverHaveCalledTool<Name extends ToolNames<App>>(name: Name): void;
|
|
13
|
+
toHaveFailedToolCall<Name extends ToolNames<App>>(name: Name): void;
|
|
14
|
+
toHaveSaid(text: string | RegExp): void;
|
|
15
|
+
toHaveCalledToolsInOrder(...names: [ToolNames<App>, ...ToolNames<App>[]]): void;
|
|
16
|
+
toHaveCalledNoTools(): void;
|
|
17
|
+
}
|
|
18
|
+
export interface ChatAssertion<App> extends ChatMatchers<App> {
|
|
19
|
+
not: ChatMatchers<App>;
|
|
20
|
+
}
|
|
21
|
+
declare module "vitest" {
|
|
22
|
+
interface ExpectStatic {
|
|
23
|
+
chat<App>(chat: ChatLike<App>): ChatAssertion<App>;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IAC3D,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;CACxB;AAED,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,YAAY;QACpB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;KACpD;CACF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import "vitest";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
function attemptedCalls(chat, name) {
|
|
4
|
+
return chat.toolCalls.filter((call) => String(call.name) === name);
|
|
5
|
+
}
|
|
6
|
+
function acceptedAll(chat) {
|
|
7
|
+
return chat.toolCalls.filter((call) => call.failed === undefined);
|
|
8
|
+
}
|
|
9
|
+
function acceptedCalls(chat, name) {
|
|
10
|
+
return acceptedAll(chat).filter((call) => String(call.name) === name);
|
|
11
|
+
}
|
|
12
|
+
function observed(chat) {
|
|
13
|
+
if (chat.toolCalls.length === 0) {
|
|
14
|
+
return " (no tool was called)";
|
|
15
|
+
}
|
|
16
|
+
return chat.toolCalls
|
|
17
|
+
.map((call, index) => ` ${index + 1}. ${call.name} ${JSON.stringify(call.arguments)}${call.failed === undefined ? "" : ` (failed: ${call.failed})`}`)
|
|
18
|
+
.join("\n");
|
|
19
|
+
}
|
|
20
|
+
function collapse(text) {
|
|
21
|
+
return text.replace(/\s+/g, " ").trim();
|
|
22
|
+
}
|
|
23
|
+
function said(chat, text) {
|
|
24
|
+
return chat.assistantTurns.some((turn) => typeof text === "string"
|
|
25
|
+
? collapse(turn).toLowerCase().includes(collapse(text).toLowerCase())
|
|
26
|
+
: text.test(turn));
|
|
27
|
+
}
|
|
28
|
+
function spoken(chat) {
|
|
29
|
+
if (chat.assistantTurns.length === 0) {
|
|
30
|
+
return " (the assistant said nothing)";
|
|
31
|
+
}
|
|
32
|
+
return chat.assistantTurns
|
|
33
|
+
.map((turn, index) => ` ${index + 1}. ${collapse(turn)}`)
|
|
34
|
+
.join("\n");
|
|
35
|
+
}
|
|
36
|
+
function report(chat, summary) {
|
|
37
|
+
return `${summary}
|
|
38
|
+
|
|
39
|
+
Calls the model actually made:
|
|
40
|
+
${observed(chat)}`;
|
|
41
|
+
}
|
|
42
|
+
expect.extend({
|
|
43
|
+
toHaveCalledToolOnce(received, name, args) {
|
|
44
|
+
const matching = acceptedCalls(received, name);
|
|
45
|
+
const argsMatch = args === undefined ||
|
|
46
|
+
(matching.length === 1 &&
|
|
47
|
+
this.equals(matching[0]?.arguments, expect.objectContaining(args)));
|
|
48
|
+
const pass = matching.length === 1 && argsMatch;
|
|
49
|
+
return {
|
|
50
|
+
pass,
|
|
51
|
+
message: () => report(received, pass
|
|
52
|
+
? `Expected "${name}" not to be called exactly once.`
|
|
53
|
+
: matching.length === 1
|
|
54
|
+
? `Expected "${name}" to be called once with ${JSON.stringify(args)}, but it was called with ${JSON.stringify(matching[0]?.arguments)}.`
|
|
55
|
+
: `Expected "${name}" to be called exactly once by a call that succeeded, but ${matching.length} such calls were made.`),
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
toHaveCalledToolWith(received, name, args) {
|
|
59
|
+
const pass = acceptedCalls(received, name).some((call) => this.equals(call.arguments, expect.objectContaining(args)));
|
|
60
|
+
return {
|
|
61
|
+
pass,
|
|
62
|
+
message: () => report(received, pass
|
|
63
|
+
? `Expected no call to "${name}" with ${JSON.stringify(args)}.`
|
|
64
|
+
: `Expected "${name}" to be called with ${JSON.stringify(args)}.`),
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
toHaveFailedToolCall(received, name) {
|
|
68
|
+
const attempted = attemptedCalls(received, name);
|
|
69
|
+
const failed = attempted.filter((call) => call.failed !== undefined);
|
|
70
|
+
return {
|
|
71
|
+
pass: failed.length > 0,
|
|
72
|
+
message: () => report(received, failed.length > 0
|
|
73
|
+
? `Expected every call to "${name}" to succeed.`
|
|
74
|
+
: attempted.length === 0
|
|
75
|
+
? `Expected "${name}" to be called and fail, but it was never called.`
|
|
76
|
+
: `Expected "${name}" to fail, but all ${attempted.length} calls succeeded.`),
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
toHaveSaid(received, text) {
|
|
80
|
+
const pass = said(received, text);
|
|
81
|
+
const wanted = typeof text === "string" ? `"${text}"` : String(text);
|
|
82
|
+
return {
|
|
83
|
+
pass,
|
|
84
|
+
message: () => `${pass
|
|
85
|
+
? `Expected the assistant not to say ${wanted}.`
|
|
86
|
+
: `Expected the assistant to say ${wanted}.`}
|
|
87
|
+
|
|
88
|
+
What the assistant actually said:
|
|
89
|
+
${spoken(received)}`,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
toHaveCalledNoTools(received) {
|
|
93
|
+
const count = received.toolCalls.length;
|
|
94
|
+
return {
|
|
95
|
+
pass: count === 0,
|
|
96
|
+
message: () => report(received, count === 0
|
|
97
|
+
? "Expected the model to call at least one tool."
|
|
98
|
+
: `Expected the model not to call any tool, but it made ${count} ${count === 1 ? "call" : "calls"}.`),
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
toHaveCalledToolsInOrder(received, ...names) {
|
|
102
|
+
let matched = 0;
|
|
103
|
+
for (const call of acceptedAll(received)) {
|
|
104
|
+
if (String(call.name) === names[matched]) {
|
|
105
|
+
matched += 1;
|
|
106
|
+
}
|
|
107
|
+
if (matched === names.length) {
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const pass = matched === names.length;
|
|
112
|
+
const wanted = names.map((name) => `"${name}"`).join(" then ");
|
|
113
|
+
return {
|
|
114
|
+
pass,
|
|
115
|
+
message: () => report(received, pass
|
|
116
|
+
? `Expected ${wanted} not to be called in that order.`
|
|
117
|
+
: `Expected ${wanted} in that order, but "${names[matched]}" never came${matched === 0 ? "" : ` after "${names[matched - 1]}"`}.`),
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
toNeverHaveCalledTool(received, name) {
|
|
121
|
+
const matching = attemptedCalls(received, name);
|
|
122
|
+
return {
|
|
123
|
+
pass: matching.length === 0,
|
|
124
|
+
message: () => report(received, matching.length === 0
|
|
125
|
+
? `Expected "${name}" to be called at least once.`
|
|
126
|
+
: `Expected "${name}" never to be called, but it was called ${matching.length} times.`),
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
expect.chat = (chat) => expect(chat);
|
|
131
|
+
//# sourceMappingURL=matchers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchers.js","sourceRoot":"","sources":["../../src/evals/matchers.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,CAAC;AAEhB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAoChC,SAAS,cAAc,CACrB,IAAuB,EACvB,IAAY;IAEZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,WAAW,CAAC,IAAuB;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,aAAa,CACpB,IAAuB,EACvB,IAAY;IAEZ,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,QAAQ,CAAC,IAAuB;IACvC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC,SAAS;SAClB,GAAG,CACF,CAAC,IAAuB,EAAE,KAAa,EAAE,EAAE,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,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,CACpI;SACJ,CAAC;IACJ,CAAC;IAED,qBAAqB,CAAC,QAA2B,EAAE,IAAY;QAC7D,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC;YAC3B,OAAO,EAAE,GAAG,EAAE,CACZ,MAAM,CACJ,QAAQ,EACR,QAAQ,CAAC,MAAM,KAAK,CAAC;gBACnB,CAAC,CAAC,aAAa,IAAI,+BAA+B;gBAClD,CAAC,CAAC,aAAa,IAAI,2CAA2C,QAAQ,CAAC,MAAM,SAAS,CACzF;SACJ,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,IAAI,GAAG,CAAM,IAAmB,EAAsB,EAAE,CAC7D,MAAM,CAAC,IAAI,CAAkC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ToolInput, ToolNames } from "skybridge/server";
|
|
2
|
+
import type { EvalsOptions } from "../plugin.js";
|
|
3
|
+
/**
|
|
4
|
+
* One recorded call, typed against the project's own registry: `name` is a
|
|
5
|
+
* union of the project's tool names and `arguments` is discriminated on it.
|
|
6
|
+
* `failed` carries the server's reason when the call did not go through.
|
|
7
|
+
*/
|
|
8
|
+
export type ToolCall<App> = {
|
|
9
|
+
[Name in ToolNames<App>]: {
|
|
10
|
+
name: Name;
|
|
11
|
+
arguments: ToolInput<App, Name>;
|
|
12
|
+
failed?: string;
|
|
13
|
+
};
|
|
14
|
+
}[ToolNames<App>];
|
|
15
|
+
/** The part of a conversation the matchers assert on. */
|
|
16
|
+
export interface ChatLike<App> {
|
|
17
|
+
/** Type-only anchor so `expect.chat` infers `App` from the conversation. */
|
|
18
|
+
readonly $app?: App;
|
|
19
|
+
readonly toolCalls: ToolCall<App>[];
|
|
20
|
+
readonly assistantTurns: string[];
|
|
21
|
+
}
|
|
22
|
+
declare module "vitest" {
|
|
23
|
+
interface ProvidedContext {
|
|
24
|
+
skybridgeEvals: EvalsOptions | undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/evals/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,GAAG,IAAI;KACzB,IAAI,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG;QACxB,IAAI,EAAE,IAAI,CAAC;QACX,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CACF,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAElB,yDAAyD;AACzD,MAAM,WAAW,QAAQ,CAAC,GAAG;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;CACnC;AAED,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,eAAe;QACvB,cAAc,EAAE,YAAY,GAAG,SAAS,CAAC;KAC1C;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/evals/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { type EvalsOptions, type
|
|
2
|
-
export { scanAndWriteViewsDts, scanViewsSync } from "./scan-views.js";
|
|
1
|
+
export { type EvalsOptions, type SkybridgePluginOptions, skybridge, } from "./plugin.js";
|
|
3
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,SAAS,GACV,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,GACV,MAAM,aAAa,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Plugin } from "vite";
|
|
2
2
|
/**
|
|
3
3
|
* Options for the eval runner, wired in through the `evals` plugin option and
|
|
4
4
|
* consumed by `@skybridge/test`. Defined here so the runtime package can
|
|
5
5
|
* import the shape while this package keeps no dependency on it.
|
|
6
6
|
*/
|
|
7
|
-
export interface ModelDescriptor {
|
|
8
|
-
provider: "anthropic";
|
|
9
|
-
name: string;
|
|
10
|
-
apiKeyEnv?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ModelFile {
|
|
13
|
-
file: string;
|
|
14
|
-
}
|
|
15
7
|
export interface EvalsOptions {
|
|
16
|
-
model: ModelDescriptor | ModelFile;
|
|
17
8
|
temperature?: number;
|
|
18
9
|
systemPrompt?: string;
|
|
19
10
|
maxSteps?: number;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Per-scenario timeout in milliseconds. Defaults to two minutes, because
|
|
13
|
+
* every turn in a scenario is a live model call and vitest's own 5s default
|
|
14
|
+
* expires mid-conversation.
|
|
15
|
+
*/
|
|
16
|
+
timeout?: number;
|
|
26
17
|
}
|
|
27
18
|
/** Options for the {@link skybridge} Vite plugin. */
|
|
28
19
|
export interface SkybridgePluginOptions {
|
|
@@ -35,12 +26,13 @@ export interface SkybridgePluginOptions {
|
|
|
35
26
|
*/
|
|
36
27
|
serverExternal?: string[];
|
|
37
28
|
/**
|
|
38
|
-
*
|
|
39
|
-
* `
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
29
|
+
* Registers the `expect.chat` matchers and, optionally, the defaults every
|
|
30
|
+
* conversation starts from (`temperature`, `systemPrompt`, `maxSteps`).
|
|
31
|
+
* Point vitest at this config to run the scenarios. Requires
|
|
32
|
+
* `@skybridge/test` as a dev dependency.
|
|
33
|
+
*
|
|
34
|
+
* Scenarios always run the app in-process via `start({ app })`, so
|
|
35
|
+
* `evals: {}` is enough to wire the matchers up.
|
|
44
36
|
*/
|
|
45
37
|
evals?: EvalsOptions;
|
|
46
38
|
}
|
|
@@ -70,5 +62,5 @@ export interface SkybridgePluginOptions {
|
|
|
70
62
|
* });
|
|
71
63
|
* ```
|
|
72
64
|
*/
|
|
73
|
-
export declare function skybridge(options?: SkybridgePluginOptions):
|
|
65
|
+
export declare function skybridge(options?: SkybridgePluginOptions): Plugin;
|
|
74
66
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAWA,OAAO,EAAW,KAAK,MAAM,EAAsB,MAAM,MAAM,CAAC;AAOhE;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qDAAqD;AACrD,MAAM,WAAW,sBAAsB;IACrC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAElE"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
2
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { assertUniqueViewNames, discoverViewsSync, scanViewsSync, writeViewsDts, } from "
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { assertUniqueViewNames, discoverViewsSync, hasDefaultExport, scanViewsSync, writeViewsDts, } from "skybridge/views";
|
|
5
|
+
import { loadEnv } from "vite";
|
|
5
6
|
import { transform as dataLlmTransform } from "./transform-data-llm.js";
|
|
6
|
-
import { hasDefaultExport } from "./validate-view.js";
|
|
7
7
|
const VIRTUAL_PREFIX = "/_skybridge/view/";
|
|
8
8
|
const VIRTUAL_MODULE_PREFIX = "\0skybridge:view:";
|
|
9
9
|
function buildVirtualEntry(viewFilePath) {
|
|
@@ -46,29 +46,19 @@ function getViewEntryPattern(viewsDir) {
|
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
48
|
export function skybridge(options) {
|
|
49
|
-
|
|
50
|
-
const evals = options?.evals;
|
|
51
|
-
if (evals !== undefined) {
|
|
52
|
-
plugins.push(loadEvalsPlugin(evals));
|
|
53
|
-
}
|
|
54
|
-
return plugins;
|
|
49
|
+
return viewsPlugin(options);
|
|
55
50
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
resolved = projectRequire.resolve("@skybridge/test/plugin");
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
throw new Error("The `evals` option requires the @skybridge/test package. Install it as a dev dependency.");
|
|
51
|
+
const EVALS_DIR = "evals";
|
|
52
|
+
const DEFAULT_EVAL_TIMEOUT_MS = 120_000;
|
|
53
|
+
function here(file) {
|
|
54
|
+
return fileURLToPath(new URL(file, import.meta.url));
|
|
55
|
+
}
|
|
56
|
+
function hasEvalScenarios(projectRoot) {
|
|
57
|
+
const dir = resolve(projectRoot, EVALS_DIR);
|
|
58
|
+
if (!existsSync(dir)) {
|
|
59
|
+
return false;
|
|
69
60
|
}
|
|
70
|
-
|
|
71
|
-
return module.evals(evals);
|
|
61
|
+
return readdirSync(dir, { recursive: true }).some((entry) => /\.eval\.(c|m)?ts$/.test(entry.toString()));
|
|
72
62
|
}
|
|
73
63
|
function viewsPlugin(options) {
|
|
74
64
|
const rawViewsDir = options?.viewsDir ?? "src/views";
|
|
@@ -82,7 +72,7 @@ function viewsPlugin(options) {
|
|
|
82
72
|
// Read by `skybridge build` to resolve viewsDir before `tsc -b` runs, and
|
|
83
73
|
// to feed esbuild's external list when bundling the server.
|
|
84
74
|
api: { viewsDir: rawViewsDir, serverExternal: options?.serverExternal },
|
|
85
|
-
config(config) {
|
|
75
|
+
config(config, { mode }) {
|
|
86
76
|
projectRoot = config.root || process.cwd();
|
|
87
77
|
resolvedViewsDir = isAbsolute(rawViewsDir)
|
|
88
78
|
? rawViewsDir
|
|
@@ -95,7 +85,7 @@ function viewsPlugin(options) {
|
|
|
95
85
|
for (const view of views) {
|
|
96
86
|
input[view.name] = `${VIRTUAL_PREFIX}${view.name}`;
|
|
97
87
|
}
|
|
98
|
-
|
|
88
|
+
const base = {
|
|
99
89
|
base: "/assets",
|
|
100
90
|
// Fixes "Invalid hook call" on createStore by forcing a single
|
|
101
91
|
// copy of React. Under pnpm's isolated node_modules, zustand
|
|
@@ -146,6 +136,25 @@ function viewsPlugin(options) {
|
|
|
146
136
|
},
|
|
147
137
|
},
|
|
148
138
|
};
|
|
139
|
+
if (!options?.evals) {
|
|
140
|
+
if (hasEvalScenarios(projectRoot)) {
|
|
141
|
+
this.warn(`Found scenarios in "${EVALS_DIR}/" but the \`evals\` plugin option is not set, so they are not collected. Add \`skybridge({ evals: {} })\` to run them.`);
|
|
142
|
+
}
|
|
143
|
+
return base;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
...base,
|
|
147
|
+
test: {
|
|
148
|
+
setupFiles: [here("./evals/matchers.js")],
|
|
149
|
+
provide: { skybridgeEvals: options.evals },
|
|
150
|
+
include: [
|
|
151
|
+
"**/*.{test,spec}.?(c|m)[jt]s?(x)",
|
|
152
|
+
`${EVALS_DIR}/**/*.eval.?(c|m)ts`,
|
|
153
|
+
],
|
|
154
|
+
testTimeout: options.evals.timeout ?? DEFAULT_EVAL_TIMEOUT_MS,
|
|
155
|
+
env: loadEnv(mode, projectRoot, ""),
|
|
156
|
+
},
|
|
157
|
+
};
|
|
149
158
|
},
|
|
150
159
|
resolveId(id) {
|
|
151
160
|
if (id.startsWith(VIRTUAL_PREFIX)) {
|
|
@@ -217,7 +226,7 @@ function viewsPlugin(options) {
|
|
|
217
226
|
server.watcher.on("unlink", rescan);
|
|
218
227
|
},
|
|
219
228
|
async transform(code, id) {
|
|
220
|
-
if (viewEntryPattern?.test(id) && !hasDefaultExport(code
|
|
229
|
+
if (viewEntryPattern?.test(id) && !hasDefaultExport(code)) {
|
|
221
230
|
this.warn(`View file "${id.split("/").pop()}" is missing a default export.`);
|
|
222
231
|
}
|
|
223
232
|
return await dataLlmTransform(code, id);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,qBAAqB,EAErB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAmC,MAAM,MAAM,CAAC;AAEhE,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAyClD,SAAS,iBAAiB,CAAC,YAAoB;IAC7C,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpD,OAAO;QACL,4CAA4C;QAC5C,0BAA0B,UAAU,IAAI;QACxC,wCAAwC;QACxC,sCAAsC;KACvC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAChE,OAAO,IAAI,MAAM,CACf,GAA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AC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBACjE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CACxB,mCAAmC,OAAO,EAAE,CAC7C,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC;YAEF,sEAAsE;YACtE,MAAM,EAAE,CAAC;YACT,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACjC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACpC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE;YACtB,IAAI,gBAAgB,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1D,IAAI,CAAC,IAAI,CACP,cAAc,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,gCAAgC,CAClE,CAAC;YACJ,CAAC;YAED,OAAO,MAAM,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skybridge/vite-plugin",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.59194c3",
|
|
4
4
|
"description": "The Skybridge Vite plugin: view discovery, data-llm transforms, and eval wiring",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./evals": {
|
|
17
|
+
"types": "./dist/evals/index.d.ts",
|
|
18
|
+
"default": "./dist/evals/index.js"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"files": [
|
|
@@ -21,18 +25,26 @@
|
|
|
21
25
|
"@babel/core": "^7.29.7"
|
|
22
26
|
},
|
|
23
27
|
"peerDependencies": {
|
|
24
|
-
"
|
|
28
|
+
"skybridge": "^2.0.0",
|
|
29
|
+
"vite": ">=7.3.1",
|
|
30
|
+
"vitest": ">=4.1.0"
|
|
25
31
|
},
|
|
26
32
|
"devDependencies": {
|
|
27
33
|
"@types/babel__core": "^7.20.5",
|
|
28
34
|
"@types/node": "^24.13.3",
|
|
29
35
|
"typescript": "^5.9.3",
|
|
30
36
|
"vite": "^8.1.5",
|
|
31
|
-
"vitest": "^4.1.10"
|
|
37
|
+
"vitest": "^4.1.10",
|
|
38
|
+
"skybridge": "0.0.0-dev.59194c3"
|
|
32
39
|
},
|
|
33
40
|
"engines": {
|
|
34
41
|
"node": ">=22.23.1"
|
|
35
42
|
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"vitest": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
36
48
|
"scripts": {
|
|
37
49
|
"build": "tsc -p tsconfig.json",
|
|
38
50
|
"format": "biome check --write --error-on-warnings",
|
package/dist/scan-views.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface DiscoveredView {
|
|
2
|
-
name: string;
|
|
3
|
-
filePath: string;
|
|
4
|
-
}
|
|
5
|
-
export interface InvalidView {
|
|
6
|
-
filePath: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function scanViewsSync(viewsDir: string): {
|
|
9
|
-
valid: DiscoveredView[];
|
|
10
|
-
invalid: InvalidView[];
|
|
11
|
-
};
|
|
12
|
-
export declare function assertUniqueViewNames(views: DiscoveredView[]): void;
|
|
13
|
-
export declare function discoverViewsSync(viewsDir: string): DiscoveredView[];
|
|
14
|
-
export declare function generateViewsDts(views: DiscoveredView[]): string;
|
|
15
|
-
export declare function writeViewsDts(projectRoot: string, views: DiscoveredView[]): void;
|
|
16
|
-
export declare function scanAndWriteViewsDts(projectRoot?: string, viewsDir?: string): void;
|
|
17
|
-
//# sourceMappingURL=scan-views.d.ts.map
|
package/dist/scan-views.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scan-views.d.ts","sourceRoot":"","sources":["../src/scan-views.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG;IAC/C,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAmCA;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,CAenE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAIpE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,MAAM,CAYhE;AAED,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,cAAc,EAAE,GACtB,IAAI,CAiBN;AAED,wBAAgB,oBAAoB,CAClC,WAAW,CAAC,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAON"}
|
package/dist/scan-views.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { globSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { basename, dirname, isAbsolute, join, parse, resolve } from "node:path";
|
|
3
|
-
import { hasDefaultExport } from "./validate-view.js";
|
|
4
|
-
export function scanViewsSync(viewsDir) {
|
|
5
|
-
const flatPattern = resolve(viewsDir, "*.{tsx,jsx}");
|
|
6
|
-
const dirPattern = resolve(viewsDir, "*/index.{tsx,jsx}");
|
|
7
|
-
const flatFiles = globSync(flatPattern).map((file) => ({
|
|
8
|
-
name: parse(file).name,
|
|
9
|
-
filePath: file,
|
|
10
|
-
}));
|
|
11
|
-
const dirFiles = globSync(dirPattern).map((file) => ({
|
|
12
|
-
name: basename(dirname(file)),
|
|
13
|
-
filePath: file,
|
|
14
|
-
}));
|
|
15
|
-
// A barrel file like `views/foo/index.tsx` (no default export) must not
|
|
16
|
-
// falsely collide with a sibling `views/foo.tsx`. Drop top-level `index`
|
|
17
|
-
// before splitting valid vs invalid.
|
|
18
|
-
const candidates = [...flatFiles, ...dirFiles].filter((v) => v.name !== "index");
|
|
19
|
-
const valid = [];
|
|
20
|
-
const invalid = [];
|
|
21
|
-
for (const candidate of candidates) {
|
|
22
|
-
const code = readFileSync(candidate.filePath, "utf-8");
|
|
23
|
-
if (hasDefaultExport(code, candidate.filePath)) {
|
|
24
|
-
valid.push(candidate);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
invalid.push({
|
|
28
|
-
filePath: candidate.filePath,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return { valid, invalid };
|
|
33
|
-
}
|
|
34
|
-
export function assertUniqueViewNames(views) {
|
|
35
|
-
const nameMap = new Map();
|
|
36
|
-
for (const view of views) {
|
|
37
|
-
const paths = nameMap.get(view.name) ?? [];
|
|
38
|
-
paths.push(view.filePath);
|
|
39
|
-
nameMap.set(view.name, paths);
|
|
40
|
-
}
|
|
41
|
-
for (const [name, paths] of nameMap) {
|
|
42
|
-
if (paths.length > 1) {
|
|
43
|
-
throw new Error(`skybridge: duplicate view name "${name}" resolved from:\n - ${paths.join("\n - ")}\nRename one of the files to avoid the conflict.`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export function discoverViewsSync(viewsDir) {
|
|
48
|
-
const { valid } = scanViewsSync(viewsDir);
|
|
49
|
-
assertUniqueViewNames(valid);
|
|
50
|
-
return valid;
|
|
51
|
-
}
|
|
52
|
-
export function generateViewsDts(views) {
|
|
53
|
-
const entries = views.map((v) => ` "${v.name}": true;`).join("\n");
|
|
54
|
-
return [
|
|
55
|
-
"export {};",
|
|
56
|
-
"",
|
|
57
|
-
'declare module "skybridge/server" {',
|
|
58
|
-
" interface ViewNameRegistry {",
|
|
59
|
-
entries,
|
|
60
|
-
" }",
|
|
61
|
-
"}",
|
|
62
|
-
"",
|
|
63
|
-
].join("\n");
|
|
64
|
-
}
|
|
65
|
-
export function writeViewsDts(projectRoot, views) {
|
|
66
|
-
const dir = join(projectRoot, ".skybridge");
|
|
67
|
-
mkdirSync(dir, { recursive: true });
|
|
68
|
-
const filePath = join(dir, "views.d.ts");
|
|
69
|
-
const content = generateViewsDts(views);
|
|
70
|
-
try {
|
|
71
|
-
const existing = readFileSync(filePath, "utf-8");
|
|
72
|
-
if (existing === content) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// File doesn't exist yet
|
|
78
|
-
}
|
|
79
|
-
writeFileSync(filePath, content, "utf-8");
|
|
80
|
-
}
|
|
81
|
-
export function scanAndWriteViewsDts(projectRoot, viewsDir) {
|
|
82
|
-
const root = projectRoot ?? process.cwd();
|
|
83
|
-
const rawDir = viewsDir ?? "src/views";
|
|
84
|
-
const resolvedDir = isAbsolute(rawDir) ? rawDir : resolve(root, rawDir);
|
|
85
|
-
const views = discoverViewsSync(resolvedDir);
|
|
86
|
-
writeViewsDts(root, views);
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=scan-views.js.map
|
package/dist/scan-views.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scan-views.js","sourceRoot":"","sources":["../src/scan-views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,E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IAAI,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/validate-view.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-view.d.ts","sourceRoot":"","sources":["../src/validate-view.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAM1E"}
|
package/dist/validate-view.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
function stripComments(code) {
|
|
2
|
-
return code.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
3
|
-
}
|
|
4
|
-
export function hasDefaultExport(code, _filePath) {
|
|
5
|
-
const stripped = stripComments(code);
|
|
6
|
-
return (/export\s+default\s/.test(stripped) ||
|
|
7
|
-
/export\s*\{[^}]*\bas\s+default\b[^}]*}/.test(stripped));
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=validate-view.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-view.js","sourceRoot":"","sources":["../src/validate-view.ts"],"names":[],"mappings":"AAAA,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,SAAkB;IAC/D,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CACL,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC;QACnC,wCAAwC,CAAC,IAAI,CAAC,QAAQ,CAAC,CACxD,CAAC;AACJ,CAAC"}
|