@fayz-ai/sdk 0.5.0 → 0.6.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/dist/vite.cjs ADDED
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var react = require('@vitejs/plugin-react');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var react__default = /*#__PURE__*/_interopDefault(react);
10
+
11
+ // src/vite.ts
12
+ var SDK_PACKAGES = [
13
+ "sdk",
14
+ "core",
15
+ "auth",
16
+ "ui",
17
+ "saas",
18
+ "shop",
19
+ "storefront",
20
+ "portal",
21
+ "courses",
22
+ "db"
23
+ ];
24
+ var SDK_PLUGINS = [
25
+ "agenda",
26
+ "automations",
27
+ "conversations",
28
+ "courses",
29
+ "crm",
30
+ "dashboard",
31
+ "financial",
32
+ "forms",
33
+ "inventory",
34
+ "marketing",
35
+ "menu",
36
+ "orders",
37
+ "reports",
38
+ "reputation",
39
+ "shop",
40
+ "sites",
41
+ "tables",
42
+ "tasks"
43
+ ];
44
+ function fayzVite(opts = {}) {
45
+ const root = opts.root ?? process.cwd();
46
+ const fayzSdk = path.resolve(root, opts.sdkDir ?? "../../fayz-sdk");
47
+ const wantLocal = process.env.FAYZ_SDK_SOURCE !== "published";
48
+ const localPresent = fs.existsSync(path.resolve(fayzSdk, "packages/core/src/index.ts"));
49
+ const useLocal = wantLocal && localPresent;
50
+ const localAliases = {};
51
+ if (useLocal) {
52
+ for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = path.resolve(fayzSdk, `packages/${p}/src`);
53
+ for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = path.resolve(fayzSdk, `plugins/plugin-${p}/src`);
54
+ }
55
+ return {
56
+ plugins: [react__default.default(), ...opts.plugins ?? []],
57
+ envPrefix: ["VITE_", "PUBLIC_"],
58
+ resolve: {
59
+ alias: {
60
+ "@": path.resolve(root, "src"),
61
+ ...localAliases,
62
+ ...opts.aliases ?? {}
63
+ },
64
+ dedupe: ["react", "react-dom", "zustand"],
65
+ conditions: useLocal ? ["source", "browser", "module", "jsnext:main", "jsnext"] : void 0
66
+ },
67
+ optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
68
+ server: {
69
+ port: opts.port,
70
+ strictPort: opts.strictPort,
71
+ fs: { allow: [root, fayzSdk] }
72
+ }
73
+ };
74
+ }
75
+
76
+ exports.fayzVite = fayzVite;
77
+ //# sourceMappingURL=vite.cjs.map
78
+ //# sourceMappingURL=vite.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite.ts"],"names":["resolve","existsSync","react"],"mappings":";;;;;;;;;;;AAQA,IAAM,YAAA,GAAe;AAAA,EACnB,KAAA;AAAA,EAAO,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,IAAA;AAAA,EAAM,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,YAAA;AAAA,EAAc,QAAA;AAAA,EAAU,SAAA;AAAA,EAAW;AAClF,CAAA;AAEA,IAAM,WAAA,GAAc;AAAA,EAClB,QAAA;AAAA,EAAU,aAAA;AAAA,EAAe,eAAA;AAAA,EAAiB,SAAA;AAAA,EAAW,KAAA;AAAA,EAAO,WAAA;AAAA,EAC5D,WAAA;AAAA,EAAa,OAAA;AAAA,EAAS,WAAA;AAAA,EAAa,WAAA;AAAA,EAAa,MAAA;AAAA,EAAQ,QAAA;AAAA,EAAU,SAAA;AAAA,EAClE,YAAA;AAAA,EAAc,MAAA;AAAA,EAAQ,OAAA;AAAA,EAAS,QAAA;AAAA,EAAU;AAC3C,CAAA;AA2BO,SAAS,QAAA,CAAS,IAAA,GAAwB,EAAC,EAAe;AAC/D,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,IAAQ,OAAA,CAAQ,GAAA,EAAI;AACtC,EAAA,MAAM,OAAA,GAAUA,YAAA,CA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AA,IACA,YAAA,EAAc,EAAE,OAAA,EAAS,QAAA,GAAW,OAAO,IAAA,CAAK,YAAY,CAAA,GAAI,EAAC,EAAE;AAAA,IACnE,MAAA,EAAQ;AAAA,MACN,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,YAAY,IAAA,CAAK,UAAA;AAAA,MACjB,IAAI,EAAE,KAAA,EAAO,CAAC,IAAA,EAAM,OAAO,CAAA;AAAE;AAC/B,GACF;AACF","file":"vite.cjs","sourcesContent":["import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport react from '@vitejs/plugin-react'\nimport type { UserConfig, PluginOption, AliasOptions } from 'vite'\n\n// All publishable @fayz-ai/* packages (root src). Subpaths (e.g.\n// @fayz-ai/saas/ui, @fayz-ai/storefront/catalog) resolve automatically via\n// Vite's prefix alias matching — the shim files mirror the subpath under src/.\nconst SDK_PACKAGES = [\n 'sdk', 'core', 'auth', 'ui', 'saas', 'shop', 'storefront', 'portal', 'courses', 'db',\n] as const\n\nconst SDK_PLUGINS = [\n 'agenda', 'automations', 'conversations', 'courses', 'crm', 'dashboard',\n 'financial', 'forms', 'inventory', 'marketing', 'menu', 'orders', 'reports',\n 'reputation', 'shop', 'sites', 'tables', 'tasks',\n] as const\n\nexport interface FayzViteOptions {\n /** Dev server port. */\n port?: number\n /** Fail instead of incrementing if the port is taken. */\n strictPort?: boolean\n /** Extra app-specific aliases, merged after the SDK aliases. */\n aliases?: Record<string, string>\n /** Extra Vite plugins, appended after @vitejs/plugin-react. */\n plugins?: PluginOption[]\n /** SDK source location relative to the app root (default ../../fayz-sdk). */\n sdkDir?: string\n /** App root directory (default process.cwd()). */\n root?: string\n}\n\n/**\n * Shared Vite config for Fayz dogfood apps. Resolves `@fayz-ai/*` from the local\n * SDK source when it is checked out next to the app AND `FAYZ_SDK_SOURCE` is not\n * `published`; otherwise from node_modules (the Fayz editor sandbox / published\n * npm). Apps no longer hand-maintain alias maps or the local-vs-npm guard.\n *\n * import { defineConfig } from 'vite'\n * import { fayzVite } from '@fayz-ai/sdk/vite'\n * export default defineConfig(fayzVite({ port: 5185, strictPort: true }))\n */\nexport function fayzVite(opts: FayzViteOptions = {}): UserConfig {\n const root = opts.root ?? process.cwd()\n const fayzSdk = resolve(root, opts.sdkDir ?? '../../fayz-sdk')\n const wantLocal = process.env.FAYZ_SDK_SOURCE !== 'published'\n const localPresent = existsSync(resolve(fayzSdk, 'packages/core/src/index.ts'))\n const useLocal = wantLocal && localPresent\n\n const localAliases: Record<string, string> = {}\n if (useLocal) {\n for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = resolve(fayzSdk, `packages/${p}/src`)\n for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`)\n }\n\n return {\n plugins: [react(), ...(opts.plugins ?? [])],\n envPrefix: ['VITE_', 'PUBLIC_'],\n resolve: {\n alias: {\n '@': resolve(root, 'src'),\n ...localAliases,\n ...(opts.aliases ?? {}),\n } as AliasOptions,\n dedupe: ['react', 'react-dom', 'zustand'],\n conditions: useLocal ? ['source', 'browser', 'module', 'jsnext:main', 'jsnext'] : undefined,\n },\n optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },\n server: {\n port: opts.port,\n strictPort: opts.strictPort,\n fs: { allow: [root, fayzSdk] },\n },\n }\n}\n"]}
package/dist/vite.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { UserConfig, PluginOption } from 'vite';
2
+ export interface FayzViteOptions {
3
+ /** Dev server port. */
4
+ port?: number;
5
+ /** Fail instead of incrementing if the port is taken. */
6
+ strictPort?: boolean;
7
+ /** Extra app-specific aliases, merged after the SDK aliases. */
8
+ aliases?: Record<string, string>;
9
+ /** Extra Vite plugins, appended after @vitejs/plugin-react. */
10
+ plugins?: PluginOption[];
11
+ /** SDK source location relative to the app root (default ../../fayz-sdk). */
12
+ sdkDir?: string;
13
+ /** App root directory (default process.cwd()). */
14
+ root?: string;
15
+ }
16
+ /**
17
+ * Shared Vite config for Fayz dogfood apps. Resolves `@fayz-ai/*` from the local
18
+ * SDK source when it is checked out next to the app AND `FAYZ_SDK_SOURCE` is not
19
+ * `published`; otherwise from node_modules (the Fayz editor sandbox / published
20
+ * npm). Apps no longer hand-maintain alias maps or the local-vs-npm guard.
21
+ *
22
+ * import { defineConfig } from 'vite'
23
+ * import { fayzVite } from '@fayz-ai/sdk/vite'
24
+ * export default defineConfig(fayzVite({ port: 5185, strictPort: true }))
25
+ */
26
+ export declare function fayzVite(opts?: FayzViteOptions): UserConfig;
27
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAgB,MAAM,MAAM,CAAA;AAelE,MAAM,WAAW,eAAe;IAC9B,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yDAAyD;IACzD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,GAAE,eAAoB,GAAG,UAAU,CAgC/D"}
package/dist/vite.js ADDED
@@ -0,0 +1,72 @@
1
+ import { existsSync } from 'fs';
2
+ import { resolve } from 'path';
3
+ import react from '@vitejs/plugin-react';
4
+
5
+ // src/vite.ts
6
+ var SDK_PACKAGES = [
7
+ "sdk",
8
+ "core",
9
+ "auth",
10
+ "ui",
11
+ "saas",
12
+ "shop",
13
+ "storefront",
14
+ "portal",
15
+ "courses",
16
+ "db"
17
+ ];
18
+ var SDK_PLUGINS = [
19
+ "agenda",
20
+ "automations",
21
+ "conversations",
22
+ "courses",
23
+ "crm",
24
+ "dashboard",
25
+ "financial",
26
+ "forms",
27
+ "inventory",
28
+ "marketing",
29
+ "menu",
30
+ "orders",
31
+ "reports",
32
+ "reputation",
33
+ "shop",
34
+ "sites",
35
+ "tables",
36
+ "tasks"
37
+ ];
38
+ function fayzVite(opts = {}) {
39
+ const root = opts.root ?? process.cwd();
40
+ const fayzSdk = resolve(root, opts.sdkDir ?? "../../fayz-sdk");
41
+ const wantLocal = process.env.FAYZ_SDK_SOURCE !== "published";
42
+ const localPresent = existsSync(resolve(fayzSdk, "packages/core/src/index.ts"));
43
+ const useLocal = wantLocal && localPresent;
44
+ const localAliases = {};
45
+ if (useLocal) {
46
+ for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = resolve(fayzSdk, `packages/${p}/src`);
47
+ for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`);
48
+ }
49
+ return {
50
+ plugins: [react(), ...opts.plugins ?? []],
51
+ envPrefix: ["VITE_", "PUBLIC_"],
52
+ resolve: {
53
+ alias: {
54
+ "@": resolve(root, "src"),
55
+ ...localAliases,
56
+ ...opts.aliases ?? {}
57
+ },
58
+ dedupe: ["react", "react-dom", "zustand"],
59
+ conditions: useLocal ? ["source", "browser", "module", "jsnext:main", "jsnext"] : void 0
60
+ },
61
+ optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
62
+ server: {
63
+ port: opts.port,
64
+ strictPort: opts.strictPort,
65
+ fs: { allow: [root, fayzSdk] }
66
+ }
67
+ };
68
+ }
69
+
70
+ export { fayzVite };
71
+ //# sourceMappingURL=vite.js.map
72
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite.ts"],"names":[],"mappings":";;;;;AAQA,IAAM,YAAA,GAAe;AA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A,KAAA,MAAW,CAAA,IAAK,WAAA,EAAa,YAAA,CAAa,CAAA,gBAAA,EAAmB,CAAC,CAAA,CAAE,CAAA,GAAI,OAAA,CAAQ,OAAA,EAAS,CAAA,eAAA,EAAkB,CAAC,CAAA,IAAA,CAAM,CAAA;AAAA,EAChH;AAEA,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,CAAC,KAAA,EAAM,EAAG,GAAI,IAAA,CAAK,OAAA,IAAW,EAAG,CAAA;AAAA,IAC1C,SAAA,EAAW,CAAC,OAAA,EAAS,SAAS,CAAA;AAAA,IAC9B,OAAA,EAAS;AAAA,MACP,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,OAAA,CAAQ,IAAA,EAAM,KAAK,CAAA;AAAA,QACxB,GAAG,YAAA;AAAA,QACH,GAAI,IAAA,CAAK,OAAA,IAAW;AAAC,OACvB;AAAA,MACA,MAAA,EAAQ,CAAC,OAAA,EAAS,WAAA,EAAa,SAAS,CAAA;AAAA,MACxC,UAAA,EAAY,WAAW,CAAC,QAAA,EAAU,WAAW,QAAA,EAAU,aAAA,EAAe,QAAQ,CAAA,GAAI;AAAA,KACpF;AAAA,IACA,YAAA,EAAc,EAAE,OAAA,EAAS,QAAA,GAAW,OAAO,IAAA,CAAK,YAAY,CAAA,GAAI,EAAC,EAAE;AAAA,IACnE,MAAA,EAAQ;AAAA,MACN,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,YAAY,IAAA,CAAK,UAAA;AAAA,MACjB,IAAI,EAAE,KAAA,EAAO,CAAC,IAAA,EAAM,OAAO,CAAA;AAAE;AAC/B,GACF;AACF","file":"vite.js","sourcesContent":["import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport react from '@vitejs/plugin-react'\nimport type { UserConfig, PluginOption, AliasOptions } from 'vite'\n\n// All publishable @fayz-ai/* packages (root src). Subpaths (e.g.\n// @fayz-ai/saas/ui, @fayz-ai/storefront/catalog) resolve automatically via\n// Vite's prefix alias matching — the shim files mirror the subpath under src/.\nconst SDK_PACKAGES = [\n 'sdk', 'core', 'auth', 'ui', 'saas', 'shop', 'storefront', 'portal', 'courses', 'db',\n] as const\n\nconst SDK_PLUGINS = [\n 'agenda', 'automations', 'conversations', 'courses', 'crm', 'dashboard',\n 'financial', 'forms', 'inventory', 'marketing', 'menu', 'orders', 'reports',\n 'reputation', 'shop', 'sites', 'tables', 'tasks',\n] as const\n\nexport interface FayzViteOptions {\n /** Dev server port. */\n port?: number\n /** Fail instead of incrementing if the port is taken. */\n strictPort?: boolean\n /** Extra app-specific aliases, merged after the SDK aliases. */\n aliases?: Record<string, string>\n /** Extra Vite plugins, appended after @vitejs/plugin-react. */\n plugins?: PluginOption[]\n /** SDK source location relative to the app root (default ../../fayz-sdk). */\n sdkDir?: string\n /** App root directory (default process.cwd()). */\n root?: string\n}\n\n/**\n * Shared Vite config for Fayz dogfood apps. Resolves `@fayz-ai/*` from the local\n * SDK source when it is checked out next to the app AND `FAYZ_SDK_SOURCE` is not\n * `published`; otherwise from node_modules (the Fayz editor sandbox / published\n * npm). Apps no longer hand-maintain alias maps or the local-vs-npm guard.\n *\n * import { defineConfig } from 'vite'\n * import { fayzVite } from '@fayz-ai/sdk/vite'\n * export default defineConfig(fayzVite({ port: 5185, strictPort: true }))\n */\nexport function fayzVite(opts: FayzViteOptions = {}): UserConfig {\n const root = opts.root ?? process.cwd()\n const fayzSdk = resolve(root, opts.sdkDir ?? '../../fayz-sdk')\n const wantLocal = process.env.FAYZ_SDK_SOURCE !== 'published'\n const localPresent = existsSync(resolve(fayzSdk, 'packages/core/src/index.ts'))\n const useLocal = wantLocal && localPresent\n\n const localAliases: Record<string, string> = {}\n if (useLocal) {\n for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = resolve(fayzSdk, `packages/${p}/src`)\n for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`)\n }\n\n return {\n plugins: [react(), ...(opts.plugins ?? [])],\n envPrefix: ['VITE_', 'PUBLIC_'],\n resolve: {\n alias: {\n '@': resolve(root, 'src'),\n ...localAliases,\n ...(opts.aliases ?? {}),\n } as AliasOptions,\n dedupe: ['react', 'react-dom', 'zustand'],\n conditions: useLocal ? ['source', 'browser', 'module', 'jsnext:main', 'jsnext'] : undefined,\n },\n optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },\n server: {\n port: opts.port,\n strictPort: opts.strictPort,\n fs: { allow: [root, fayzSdk] },\n },\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fayz-ai/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Fayz SDK — API client, app params, runtime broker helpers, and shared types for generated Fayz projects",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -62,6 +62,12 @@
62
62
  "types": "./dist/types.d.ts",
63
63
  "import": "./dist/types.js",
64
64
  "require": "./dist/types.cjs"
65
+ },
66
+ "./vite": {
67
+ "source": "./src/vite.ts",
68
+ "types": "./dist/vite.d.ts",
69
+ "import": "./dist/vite.js",
70
+ "require": "./dist/vite.cjs"
65
71
  }
66
72
  },
67
73
  "files": [
@@ -69,9 +75,23 @@
69
75
  "src",
70
76
  "README.md"
71
77
  ],
78
+ "peerDependencies": {
79
+ "vite": "^5.0.0 || ^6.0.0",
80
+ "@vitejs/plugin-react": "^4.0.0"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "vite": {
84
+ "optional": true
85
+ },
86
+ "@vitejs/plugin-react": {
87
+ "optional": true
88
+ }
89
+ },
72
90
  "devDependencies": {
91
+ "@vitejs/plugin-react": "^4.3.0",
73
92
  "tsup": "^8.2.0",
74
93
  "typescript": "^5.5.0",
94
+ "vite": "^5.4.0",
75
95
  "vitest": "^2.1.9"
76
96
  },
77
97
  "license": "MIT",
package/src/vite.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { existsSync } from 'node:fs'
2
+ import { resolve } from 'node:path'
3
+ import react from '@vitejs/plugin-react'
4
+ import type { UserConfig, PluginOption, AliasOptions } from 'vite'
5
+
6
+ // All publishable @fayz-ai/* packages (root src). Subpaths (e.g.
7
+ // @fayz-ai/saas/ui, @fayz-ai/storefront/catalog) resolve automatically via
8
+ // Vite's prefix alias matching — the shim files mirror the subpath under src/.
9
+ const SDK_PACKAGES = [
10
+ 'sdk', 'core', 'auth', 'ui', 'saas', 'shop', 'storefront', 'portal', 'courses', 'db',
11
+ ] as const
12
+
13
+ const SDK_PLUGINS = [
14
+ 'agenda', 'automations', 'conversations', 'courses', 'crm', 'dashboard',
15
+ 'financial', 'forms', 'inventory', 'marketing', 'menu', 'orders', 'reports',
16
+ 'reputation', 'shop', 'sites', 'tables', 'tasks',
17
+ ] as const
18
+
19
+ export interface FayzViteOptions {
20
+ /** Dev server port. */
21
+ port?: number
22
+ /** Fail instead of incrementing if the port is taken. */
23
+ strictPort?: boolean
24
+ /** Extra app-specific aliases, merged after the SDK aliases. */
25
+ aliases?: Record<string, string>
26
+ /** Extra Vite plugins, appended after @vitejs/plugin-react. */
27
+ plugins?: PluginOption[]
28
+ /** SDK source location relative to the app root (default ../../fayz-sdk). */
29
+ sdkDir?: string
30
+ /** App root directory (default process.cwd()). */
31
+ root?: string
32
+ }
33
+
34
+ /**
35
+ * Shared Vite config for Fayz dogfood apps. Resolves `@fayz-ai/*` from the local
36
+ * SDK source when it is checked out next to the app AND `FAYZ_SDK_SOURCE` is not
37
+ * `published`; otherwise from node_modules (the Fayz editor sandbox / published
38
+ * npm). Apps no longer hand-maintain alias maps or the local-vs-npm guard.
39
+ *
40
+ * import { defineConfig } from 'vite'
41
+ * import { fayzVite } from '@fayz-ai/sdk/vite'
42
+ * export default defineConfig(fayzVite({ port: 5185, strictPort: true }))
43
+ */
44
+ export function fayzVite(opts: FayzViteOptions = {}): UserConfig {
45
+ const root = opts.root ?? process.cwd()
46
+ const fayzSdk = resolve(root, opts.sdkDir ?? '../../fayz-sdk')
47
+ const wantLocal = process.env.FAYZ_SDK_SOURCE !== 'published'
48
+ const localPresent = existsSync(resolve(fayzSdk, 'packages/core/src/index.ts'))
49
+ const useLocal = wantLocal && localPresent
50
+
51
+ const localAliases: Record<string, string> = {}
52
+ if (useLocal) {
53
+ for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = resolve(fayzSdk, `packages/${p}/src`)
54
+ for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`)
55
+ }
56
+
57
+ return {
58
+ plugins: [react(), ...(opts.plugins ?? [])],
59
+ envPrefix: ['VITE_', 'PUBLIC_'],
60
+ resolve: {
61
+ alias: {
62
+ '@': resolve(root, 'src'),
63
+ ...localAliases,
64
+ ...(opts.aliases ?? {}),
65
+ } as AliasOptions,
66
+ dedupe: ['react', 'react-dom', 'zustand'],
67
+ conditions: useLocal ? ['source', 'browser', 'module', 'jsnext:main', 'jsnext'] : undefined,
68
+ },
69
+ optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
70
+ server: {
71
+ port: opts.port,
72
+ strictPort: opts.strictPort,
73
+ fs: { allow: [root, fayzSdk] },
74
+ },
75
+ }
76
+ }