primitive-app 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,11 +3,12 @@
3
3
  *
4
4
  * Only items that consuming apps need directly are exported here:
5
5
  * - DevToolsRoot: mounted by the Vite plugin's virtual module at runtime
6
- * - Test-authoring types: used in .primitive-test.ts files
6
+ * - Test-authoring types and helpers: used in .primitive-test.ts files
7
7
  *
8
8
  * All other dev-tools components, stores, and utilities are internal
9
9
  * and consumed via relative imports within the dev-tools module.
10
10
  */
11
11
  export { default as DevToolsRoot } from "./vite-plugin/DevToolsRoot.vue";
12
- export type { TestDocContext, TestGroup, TestLogFn } from "./test-harness";
12
+ export type { TestDocumentHandle, TestGroup, TestLogFn } from "./test-harness";
13
+ export { createTestDocument, destroyTestDocument } from "./test-harness";
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dev-tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGzE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dev-tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGzE,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG/E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,6 +1,11 @@
1
1
  import type { RunnableTest } from "./types";
2
+ interface TestLoadError {
3
+ file: string;
4
+ error: unknown;
5
+ }
2
6
  interface Props {
3
7
  tests: RunnableTest[];
8
+ testLoadErrors?: TestLoadError[];
4
9
  onTestsComplete?: () => void | Promise<void>;
5
10
  }
6
11
  declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"TestRunner.vue.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/TestRunner.vue"],"names":[],"mappings":"AA6uBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C,UAAU,KAAK;IACb,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAggCD,QAAA,MAAM,YAAY,sRAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"TestRunner.vue.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/TestRunner.vue"],"names":[],"mappings":"AA0wBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,KAAK;IACb,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAijCD,QAAA,MAAM,YAAY,sRAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -2,6 +2,7 @@
2
2
  * Test harness exports.
3
3
  */
4
4
  export { default as TestRunner } from "./TestRunner.vue";
5
- export type { RunnableTest, TestDocContext, TestGroup, TestLogFn, } from "./types";
6
- export { TEST_DOCUMENT_PREFIX, beginTestRun, buildRunnableTests, deleteAllTestDocuments, endTestRun, } from "./lib";
5
+ export type { RunnableTest, TestGroup, TestLogFn } from "./types";
6
+ export type { TestDocumentHandle } from "./lib";
7
+ export { TEST_DOCUMENT_PREFIX, beginTestRun, buildRunnableTests, createTestDocument, deleteAllTestDocuments, destroyTestDocument, endTestRun, } from "./lib";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGzD,YAAY,EACV,YAAY,EACZ,cAAc,EACd,SAAS,EACT,SAAS,GACV,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,GACX,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGzD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAGhD,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,GACX,MAAM,OAAO,CAAC"}
@@ -1,31 +1,54 @@
1
1
  import type { RunnableTest, TestGroup } from "./types";
2
+ export declare const TEST_DOCUMENT_PREFIX = "===TEST===";
2
3
  /**
3
- * Prefix used for all test documents. This allows us to identify and clean up test documents.
4
+ * Handle returned by createTestDocument. Pass to destroyTestDocument when done.
4
5
  */
5
- export declare const TEST_DOCUMENT_PREFIX = "===TEST===";
6
+ export interface TestDocumentHandle {
7
+ docId: string;
8
+ }
6
9
  /**
7
- * Begin a test run by closing all host application documents.
8
- * Call this once at the start of a test run, before running any tests.
9
- * Returns the count of documents that were closed.
10
+ * Create an ephemeral test document for model/database operations.
11
+ * Sets it as the default document so model operations (save, query, etc.)
12
+ * target it automatically.
13
+ *
14
+ * Call destroyTestDocument() in a finally block when done.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * run: async (log) => {
19
+ * const doc = await createTestDocument();
20
+ * try {
21
+ * const task = new Task({ title: "test" });
22
+ * await task.save();
23
+ * log("saved task");
24
+ * return "passed";
25
+ * } finally {
26
+ * await destroyTestDocument(doc);
27
+ * }
28
+ * }
29
+ * ```
30
+ */
31
+ export declare function createTestDocument(): Promise<TestDocumentHandle>;
32
+ /**
33
+ * Close and delete an ephemeral test document.
34
+ */
35
+ export declare function destroyTestDocument(handle: TestDocumentHandle): Promise<void>;
36
+ /**
37
+ * Close all host application documents before running document-dependent tests.
38
+ * Call this at the start of a test run if any tests create test documents.
10
39
  */
11
40
  export declare function beginTestRun(): Promise<number>;
12
41
  /**
13
- * End a test run by restoring host application documents.
14
- * Also restores the document explorer's stored document ID.
15
- * Call this once at the end of a test run, after all tests have completed.
42
+ * Restore host application documents after a test run.
16
43
  */
17
44
  export declare function endTestRun(): Promise<void>;
18
45
  /**
19
- * Delete all test documents from the system.
20
- * This is useful for cleanup when tests start or finish, in case any documents were left behind.
21
- *
22
- * Test documents are always localOnly, so uses evict() to remove local data
23
- * and metadata without a server round-trip.
46
+ * Delete all leftover test documents. Called at startup and when the
47
+ * overlay initializes to clean up after interrupted test runs.
24
48
  */
25
49
  export declare function deleteAllTestDocuments(): Promise<number>;
26
50
  /**
27
- * Convert test groups (as written by test authors) into runnable tests.
28
- * Each test is wrapped with automatic document lifecycle management.
51
+ * Convert test groups into runnable tests (adds group name, flattens).
29
52
  */
30
53
  export declare function buildRunnableTests(groups: TestGroup[]): RunnableTest[];
31
54
  //# sourceMappingURL=lib.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/lib.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,YAAY,EAEZ,SAAS,EAEV,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAiBjD;;;;GAIG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CA6BpD;AAED;;;;GAIG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBhD;AA8FD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAkF9D;AAoCD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAStE"}
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/lib.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMvD,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAOD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CA+BtE;AAID;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAMD;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAyBpD;AAED;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAkBhD;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAmD9D;AAID;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAStE"}
@@ -3,16 +3,7 @@
3
3
  *
4
4
  * TestGroup - What test authors write in their .primitive-test.ts files
5
5
  * RunnableTest - Processed/wrapped version for the test runner
6
- * TestDocContext - Document context passed to each test
7
6
  */
8
- /**
9
- * Context for the ephemeral test document.
10
- * Each test receives this context so it can filter queries to its own document.
11
- */
12
- export interface TestDocContext {
13
- /** The document ID for the test's ephemeral document */
14
- docId: string;
15
- }
16
7
  /**
17
8
  * Function signature for test log output.
18
9
  */
@@ -25,18 +16,17 @@ export interface TestGroup {
25
16
  tests: Array<{
26
17
  id: string;
27
18
  name: string;
28
- run: (ctx: TestDocContext, log?: TestLogFn) => Promise<string>;
19
+ run: (log: TestLogFn) => Promise<string>;
29
20
  }>;
30
21
  }
31
22
  /**
32
23
  * A test that has been processed and is ready to run.
33
- * Includes the group name and has the run function wrapped with document lifecycle.
34
- * The run function no longer requires ctx since it's provided by the wrapper.
24
+ * Includes the group name for display grouping.
35
25
  */
36
26
  export interface RunnableTest {
37
27
  id: string;
38
28
  name: string;
39
29
  group: string;
40
- run: (log?: TestLogFn) => Promise<string>;
30
+ run: (log: TestLogFn) => Promise<string>;
41
31
  }
42
32
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;KAChE,CAAC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/test-harness/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;KAC1C,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1C"}
@@ -1,6 +1,11 @@
1
1
  import type { TestGroup } from "../test-harness/types";
2
+ interface TestLoadError {
3
+ file: string;
4
+ error: unknown;
5
+ }
2
6
  interface Props {
3
7
  testGroups: TestGroup[];
8
+ testLoadErrors?: TestLoadError[];
4
9
  appName: string;
5
10
  }
6
11
  declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -1 +1 @@
1
- {"version":3,"file":"DevToolsOverlay.vue.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/vite-plugin/DevToolsOverlay.vue"],"names":[],"mappings":"AAkVA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,UAAU,KAAK;IACb,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAwbD,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"DevToolsOverlay.vue.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/vite-plugin/DevToolsOverlay.vue"],"names":[],"mappings":"AAoVA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,KAAK;IACb,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB;AA6bD,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1,6 +1,11 @@
1
1
  import type { TestGroup } from "../test-harness/types";
2
+ interface TestLoadError {
3
+ file: string;
4
+ error: unknown;
5
+ }
2
6
  interface Props {
3
7
  testGroups: TestGroup[];
8
+ testLoadErrors?: TestLoadError[];
4
9
  appName: string;
5
10
  keyboardShortcut?: string;
6
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DevToolsRoot.vue.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/vite-plugin/DevToolsRoot.vue"],"names":[],"mappings":"AAmRA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQvD,UAAU,KAAK;IACb,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAwSD,QAAA,MAAM,YAAY,sRAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"DevToolsRoot.vue.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/vite-plugin/DevToolsRoot.vue"],"names":[],"mappings":"AA0RA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQvD,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,KAAK;IACb,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AA0SD,QAAA,MAAM,YAAY,sRAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1,19 +1,27 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../chunk-rCbxF51U.cjs`);let t=require(`node:fs`),n=require(`node:module`),r=require(`glob`),i=require(`path`);i=e.i(i,1);async function a(e,t=`src/tests`,n=`**/*.primitive-test.ts`){return(await(0,r.glob)(n,{cwd:i.default.join(e,t),ignore:[`**/node_modules/**`,`**/dist/**`],absolute:!0})).map(t=>({absolutePath:t,relativePath:i.default.relative(e,t)}))}var o=`virtual:primitive-devtools`,s=`\0`+o,c=`virtual:primitive-devtools-init`,l=`\0`+c;function u(e={}){let{testsDir:r=`src/tests`,testPattern:i=`**/*.primitive-test.ts`,appName:u=`Primitive App`,enabled:d=!0,keyboardShortcut:f}=e,p,m,h=(0,t.readFileSync)((0,n.createRequire)({}.url).resolve(`vue-sonner/style.css`),`utf-8`);return{name:`primitive-devtools`,configResolved(e){p=e.root,m=e.command===`serve`},resolveId(e){if(e===o)return s;if(e===c)return l},async load(e){if(e===s){let e=await a(p,r,i),t=e.map((e,t)=>`import testGroup${t} from '${e.absolutePath}';`).join(`
2
- `),n=e.map((e,t)=>`...(Array.isArray(testGroup${t}) ? testGroup${t} : [testGroup${t}])`).join(`,
3
- `);return`
4
- ${t}
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../chunk-rCbxF51U.cjs`);let t=require(`node:fs`),n=require(`node:module`),r=require(`glob`),i=require(`path`);i=e.i(i,1);async function a(e,t=`src/tests`,n=`**/*.primitive-test.ts`){return(await(0,r.glob)(n,{cwd:i.default.join(e,t),ignore:[`**/node_modules/**`,`**/dist/**`],absolute:!0})).map(t=>({absolutePath:t,relativePath:i.default.relative(e,t)}))}var o=`virtual:primitive-devtools`,s=`\0`+o,c=`virtual:primitive-devtools-init`,l=`\0`+c;function u(e={}){let{testsDir:r=`src/tests`,testPattern:i=`**/*.primitive-test.ts`,appName:u=`Primitive App`,enabled:d=!0,keyboardShortcut:f}=e,p,m,h=(0,t.readFileSync)((0,n.createRequire)({}.url).resolve(`vue-sonner/style.css`),`utf-8`);return{name:`primitive-devtools`,configResolved(e){p=e.root,m=e.command===`serve`},resolveId(e){if(e===o)return s;if(e===c)return l},async load(e){if(e===s)return`
2
+ const groups = [];
3
+ const loadErrors = [];
5
4
 
6
- export const testGroups = [
7
- ${e.length>0?n:``}
8
- ];
5
+ ${(await a(p,r,i)).map((e,t)=>` try {
6
+ const mod${t} = await import('${e.absolutePath}');
7
+ const val${t} = mod${t}.default;
8
+ if (Array.isArray(val${t})) groups.push(...val${t});
9
+ else if (val${t}) groups.push(val${t});
10
+ } catch (e) {
11
+ console.error('[primitive-devtools] Failed to load test file: ${e.relativePath}', e);
12
+ loadErrors.push({ file: '${e.relativePath}', error: e });
13
+ }`).join(`
14
+ `)}
9
15
 
16
+ export const testGroups = groups;
17
+ export const testLoadErrors = loadErrors;
10
18
  export const appName = ${JSON.stringify(u)};
11
19
  export const keyboardShortcut = ${JSON.stringify(f)};
12
- `}if(e===l)return`
20
+ `;if(e===l)return`
13
21
  import { createApp, h } from 'vue';
14
22
  import { createPinia } from 'pinia';
15
23
  import { DevToolsRoot, jsBaoClientService } from 'primitive-app';
16
- import { testGroups, appName, keyboardShortcut } from 'virtual:primitive-devtools';
24
+ import { testGroups, testLoadErrors, appName, keyboardShortcut } from 'virtual:primitive-devtools';
17
25
 
18
26
  // Wait for the host app to register its client on window.__primitiveAppClient
19
27
  async function waitForAppClient() {
@@ -48,7 +56,7 @@ const observer = new MutationObserver(async (mutations, obs) => {
48
56
  // The jsBaoClientService is linked to the app's client above
49
57
  const devToolsApp = createApp({
50
58
  render() {
51
- return h(DevToolsRoot, { testGroups, appName, keyboardShortcut });
59
+ return h(DevToolsRoot, { testGroups, testLoadErrors, appName, keyboardShortcut });
52
60
  }
53
61
  });
54
62
  devToolsApp.use(createPinia());
@@ -28,20 +28,26 @@ function l(n = {}) {
28
28
  if (e === s) return c;
29
29
  },
30
30
  async load(e) {
31
- if (e === o) {
32
- let e = await i(p, r, l), t = e.map((e, t) => `import testGroup${t} from '${e.absolutePath}';`).join("\n"), n = e.map((e, t) => `...(Array.isArray(testGroup${t}) ? testGroup${t} : [testGroup${t}])`).join(",\n ");
33
- return `
34
- ${t}
31
+ if (e === o) return `
32
+ const groups = [];
33
+ const loadErrors = [];
35
34
 
36
- export const testGroups = [
37
- ${e.length > 0 ? n : ""}
38
- ];
35
+ ${(await i(p, r, l)).map((e, t) => ` try {
36
+ const mod${t} = await import('${e.absolutePath}');
37
+ const val${t} = mod${t}.default;
38
+ if (Array.isArray(val${t})) groups.push(...val${t});
39
+ else if (val${t}) groups.push(val${t});
40
+ } catch (e) {
41
+ console.error('[primitive-devtools] Failed to load test file: ${e.relativePath}', e);
42
+ loadErrors.push({ file: '${e.relativePath}', error: e });
43
+ }`).join("\n")}
39
44
 
45
+ export const testGroups = groups;
46
+ export const testLoadErrors = loadErrors;
40
47
  export const appName = ${JSON.stringify(u)};
41
48
  export const keyboardShortcut = ${JSON.stringify(f)};
42
49
  `;
43
- }
44
- if (e === c) return "\nimport { createApp, h } from 'vue';\nimport { createPinia } from 'pinia';\nimport { DevToolsRoot, jsBaoClientService } from 'primitive-app';\nimport { testGroups, appName, keyboardShortcut } from 'virtual:primitive-devtools';\n\n// Wait for the host app to register its client on window.__primitiveAppClient\nasync function waitForAppClient() {\n return new Promise((resolve) => {\n const check = () => {\n if (window.__primitiveAppClient) {\n resolve(window.__primitiveAppClient);\n } else {\n setTimeout(check, 100);\n }\n };\n check();\n });\n}\n\n// Wait for main app to mount, then inject dev tools\nconst observer = new MutationObserver(async (mutations, obs) => {\n const appEl = document.getElementById('app');\n if (appEl && appEl.children.length > 0) {\n obs.disconnect();\n\n // Wait for the app's client to be available and link it to the debug suite\n const appClient = await waitForAppClient();\n jsBaoClientService.setExternalClient(appClient);\n\n // Create mount point for dev tools\n const devToolsMount = document.createElement('div');\n devToolsMount.id = 'primitive-devtools-root';\n document.body.appendChild(devToolsMount);\n\n // Create the dev tools app with its own Pinia instance\n // The jsBaoClientService is linked to the app's client above\n const devToolsApp = createApp({\n render() {\n return h(DevToolsRoot, { testGroups, appName, keyboardShortcut });\n }\n });\n devToolsApp.use(createPinia());\n devToolsApp.mount('#primitive-devtools-root');\n }\n});\n\nobserver.observe(document.body, { childList: true, subtree: true });\n";
50
+ if (e === c) return "\nimport { createApp, h } from 'vue';\nimport { createPinia } from 'pinia';\nimport { DevToolsRoot, jsBaoClientService } from 'primitive-app';\nimport { testGroups, testLoadErrors, appName, keyboardShortcut } from 'virtual:primitive-devtools';\n\n// Wait for the host app to register its client on window.__primitiveAppClient\nasync function waitForAppClient() {\n return new Promise((resolve) => {\n const check = () => {\n if (window.__primitiveAppClient) {\n resolve(window.__primitiveAppClient);\n } else {\n setTimeout(check, 100);\n }\n };\n check();\n });\n}\n\n// Wait for main app to mount, then inject dev tools\nconst observer = new MutationObserver(async (mutations, obs) => {\n const appEl = document.getElementById('app');\n if (appEl && appEl.children.length > 0) {\n obs.disconnect();\n\n // Wait for the app's client to be available and link it to the debug suite\n const appClient = await waitForAppClient();\n jsBaoClientService.setExternalClient(appClient);\n\n // Create mount point for dev tools\n const devToolsMount = document.createElement('div');\n devToolsMount.id = 'primitive-devtools-root';\n document.body.appendChild(devToolsMount);\n\n // Create the dev tools app with its own Pinia instance\n // The jsBaoClientService is linked to the app's client above\n const devToolsApp = createApp({\n render() {\n return h(DevToolsRoot, { testGroups, testLoadErrors, appName, keyboardShortcut });\n }\n });\n devToolsApp.use(createPinia());\n devToolsApp.mount('#primitive-devtools-root');\n }\n});\n\nobserver.observe(document.body, { childList: true, subtree: true });\n";
45
51
  },
46
52
  transformIndexHtml(e) {
47
53
  if (!m || !d) return e;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/vite-plugin/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAQD,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,MAAM,CA+IR"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/dev-tools/vite-plugin/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAQD,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,MAAM,CAoJR"}