@aibloom/adapter-vite-react 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @aibloom/adapter-vite-react
2
+
3
+ Vite + React framework adapter for Aibloom code generation targets.
4
+
5
+ Detects project conventions, generates framework-appropriate page templates, and validates output against Vite React patterns.
6
+
7
+ ## Usage
8
+
9
+ ```ts
10
+ import { ViteReactAdapter } from "@aibloom/adapter-vite-react";
11
+ ```
@@ -0,0 +1,11 @@
1
+ import { type FrameworkAdapter } from "@aibloom/core";
2
+ import type { DetectionResult, DevServerConfig, ImplementationTarget, PageShape, ProjectContext, VerificationCommand } from "@aibloom/schemas";
3
+ export declare class ViteReactAdapter implements FrameworkAdapter {
4
+ readonly id: "vite-react";
5
+ detect(projectRoot: string): Promise<DetectionResult>;
6
+ inspect(projectRoot: string): Promise<ProjectContext>;
7
+ planTarget(page: PageShape, context: ProjectContext): Promise<ImplementationTarget>;
8
+ verificationCommands(context: ProjectContext): VerificationCommand[];
9
+ resolveDevServer(context: ProjectContext): DevServerConfig;
10
+ }
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,SAAS,EACT,cAAc,EACd,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAO1B,qBAAa,gBAAiB,YAAW,gBAAgB;IACvD,QAAQ,CAAC,EAAE,EAAG,YAAY,CAAU;IAE9B,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAoBrD,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAYrD,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAUzF,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,mBAAmB,EAAE;IAcpE,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,eAAe;CAS3D"}
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { detectPackageManager, readPackageJson, } from "@aibloom/core";
4
+ function packageCommand(context, script) {
5
+ if (context.packageManager === "npm")
6
+ return { command: "npm", args: ["run", script] };
7
+ return { command: context.packageManager, args: [script] };
8
+ }
9
+ export class ViteReactAdapter {
10
+ id = "vite-react";
11
+ async detect(projectRoot) {
12
+ const pkg = await readPackageJson(projectRoot);
13
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
14
+ const evidence = [];
15
+ if (deps.vite)
16
+ evidence.push(`vite dependency: ${deps.vite}`);
17
+ if (deps.react)
18
+ evidence.push(`react dependency: ${deps.react}`);
19
+ try {
20
+ await fs.access(path.join(projectRoot, "src"));
21
+ evidence.push("src/ exists");
22
+ }
23
+ catch {
24
+ // Continue.
25
+ }
26
+ return {
27
+ detected: Boolean(deps.vite && deps.react),
28
+ framework: "vite-react",
29
+ confidence: deps.vite && deps.react ? (evidence.length >= 3 ? 1 : 0.8) : 0,
30
+ evidence,
31
+ };
32
+ }
33
+ async inspect(projectRoot) {
34
+ const pkg = await readPackageJson(projectRoot);
35
+ return {
36
+ projectRoot,
37
+ framework: "vite-react",
38
+ packageManager: await detectPackageManager(projectRoot),
39
+ sourceRoot: "src",
40
+ routeRoot: "src/pages",
41
+ scripts: pkg.scripts ?? {},
42
+ };
43
+ }
44
+ async planTarget(page, context) {
45
+ const componentName = page.pageName.replace(/[^A-Za-z0-9]/g, "");
46
+ const entryFile = path.join(context.routeRoot, `${componentName}.tsx`);
47
+ return {
48
+ route: page.route,
49
+ entryFile,
50
+ files: [entryFile, path.join(context.sourceRoot, "components", `${componentName}View.tsx`)],
51
+ };
52
+ }
53
+ verificationCommands(context) {
54
+ const commands = [];
55
+ const add = (checkType, script, required) => {
56
+ if (!context.scripts[script])
57
+ return;
58
+ const command = packageCommand(context, script);
59
+ commands.push({ checkType, ...command, required });
60
+ };
61
+ add("lint", "lint", false);
62
+ add("typecheck", "typecheck", true);
63
+ add("unit_test", "test", false);
64
+ add("build", "build", true);
65
+ return commands;
66
+ }
67
+ resolveDevServer(context) {
68
+ const command = packageCommand(context, "preview");
69
+ return {
70
+ ...command,
71
+ args: [...command.args, "--", "--host", "127.0.0.1", "--port", "4173"],
72
+ port: 4173,
73
+ readyUrl: "http://127.0.0.1:4173",
74
+ };
75
+ }
76
+ }
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,eAAe,GAEhB,MAAM,eAAe,CAAC;AAUvB,SAAS,cAAc,CAAC,OAAuB,EAAE,MAAc;IAC7D,IAAI,OAAO,CAAC,cAAc,KAAK,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;IACvF,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED,MAAM,OAAO,gBAAgB;IAClB,EAAE,GAAG,YAAqB,CAAC;IAEpC,KAAK,CAAC,MAAM,CAAC,WAAmB;QAC9B,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,GAAG,CAAC,eAAe,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W,EAAE,QAAQ,EAAE,MAAM,CAAC;YACtE,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,uBAAuB;SAClC,CAAC;IACJ,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@aibloom/adapter-vite-react",
3
+ "version": "0.2.0",
4
+ "description": "Vite + React framework adapter for Aibloom code generation targets",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md"],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.json",
18
+ "typecheck": "tsc -p tsconfig.json --noEmit"
19
+ },
20
+ "dependencies": {
21
+ "@aibloom/core": "0.2.0",
22
+ "@aibloom/schemas": "0.2.0"
23
+ }
24
+ }