@fayz-ai/sdk 0.5.0 → 0.6.1

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,73 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+
6
+ // src/vite.ts
7
+ var SDK_PACKAGES = [
8
+ "sdk",
9
+ "core",
10
+ "auth",
11
+ "ui",
12
+ "saas",
13
+ "shop",
14
+ "storefront",
15
+ "portal",
16
+ "courses",
17
+ "db"
18
+ ];
19
+ var SDK_PLUGINS = [
20
+ "agenda",
21
+ "automations",
22
+ "conversations",
23
+ "courses",
24
+ "crm",
25
+ "dashboard",
26
+ "financial",
27
+ "forms",
28
+ "inventory",
29
+ "marketing",
30
+ "menu",
31
+ "orders",
32
+ "reports",
33
+ "reputation",
34
+ "shop",
35
+ "sites",
36
+ "tables",
37
+ "tasks"
38
+ ];
39
+ function fayzVite(opts = {}) {
40
+ const root = opts.root ?? process.cwd();
41
+ const fayzSdk = path.resolve(root, opts.sdkDir ?? "../../fayz-sdk");
42
+ const wantLocal = process.env.FAYZ_SDK_SOURCE !== "published";
43
+ const localPresent = fs.existsSync(path.resolve(fayzSdk, "packages/core/src/index.ts"));
44
+ const useLocal = wantLocal && localPresent;
45
+ const localAliases = {};
46
+ if (useLocal) {
47
+ for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = path.resolve(fayzSdk, `packages/${p}/src`);
48
+ for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = path.resolve(fayzSdk, `plugins/plugin-${p}/src`);
49
+ }
50
+ return {
51
+ plugins: [...opts.plugins ?? []],
52
+ envPrefix: ["VITE_", "PUBLIC_"],
53
+ resolve: {
54
+ alias: {
55
+ "@": path.resolve(root, "src"),
56
+ ...localAliases,
57
+ ...opts.aliases ?? {}
58
+ },
59
+ dedupe: ["react", "react-dom", "zustand"],
60
+ conditions: useLocal ? ["source", "browser", "module", "jsnext:main", "jsnext"] : void 0
61
+ },
62
+ optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
63
+ server: {
64
+ port: opts.port,
65
+ strictPort: opts.strictPort,
66
+ fs: { allow: [root, fayzSdk] }
67
+ }
68
+ };
69
+ }
70
+
71
+ exports.fayzVite = fayzVite;
72
+ //# sourceMappingURL=vite.cjs.map
73
+ //# sourceMappingURL=vite.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite.ts"],"names":["resolve","existsSync"],"mappings":";;;;;;AAOA,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;AAgCO,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,CAAQ,IAAA,EAAM,IAAA,CAAK,UAAU,gBAAgB,CAAA;AAC7D,EAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,GAAA,CAAI,eAAA,KAAoB,WAAA;AAClD,E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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 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 react from '@vitejs/plugin-react'\n * import { fayzVite } from '@fayz-ai/sdk/vite'\n * export default defineConfig(fayzVite({ port: 5185, plugins: [react()] }))\n *\n * The app passes its own `@vitejs/plugin-react` so `@fayz-ai/sdk` carries no\n * build-tool peer deps (which otherwise choke npm's peer resolution, since sdk\n * sits in every dependency path).\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: [...(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,32 @@
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 react from '@vitejs/plugin-react'
24
+ * import { fayzVite } from '@fayz-ai/sdk/vite'
25
+ * export default defineConfig(fayzVite({ port: 5185, plugins: [react()] }))
26
+ *
27
+ * The app passes its own `@vitejs/plugin-react` so `@fayz-ai/sdk` carries no
28
+ * build-tool peer deps (which otherwise choke npm's peer resolution, since sdk
29
+ * sits in every dependency path).
30
+ */
31
+ export declare function fayzVite(opts?: FayzViteOptions): UserConfig;
32
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAEA,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;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,GAAE,eAAoB,GAAG,UAAU,CAgC/D"}
package/dist/vite.js ADDED
@@ -0,0 +1,71 @@
1
+ import { existsSync } from 'fs';
2
+ import { resolve } from 'path';
3
+
4
+ // src/vite.ts
5
+ var SDK_PACKAGES = [
6
+ "sdk",
7
+ "core",
8
+ "auth",
9
+ "ui",
10
+ "saas",
11
+ "shop",
12
+ "storefront",
13
+ "portal",
14
+ "courses",
15
+ "db"
16
+ ];
17
+ var SDK_PLUGINS = [
18
+ "agenda",
19
+ "automations",
20
+ "conversations",
21
+ "courses",
22
+ "crm",
23
+ "dashboard",
24
+ "financial",
25
+ "forms",
26
+ "inventory",
27
+ "marketing",
28
+ "menu",
29
+ "orders",
30
+ "reports",
31
+ "reputation",
32
+ "shop",
33
+ "sites",
34
+ "tables",
35
+ "tasks"
36
+ ];
37
+ function fayzVite(opts = {}) {
38
+ const root = opts.root ?? process.cwd();
39
+ const fayzSdk = resolve(root, opts.sdkDir ?? "../../fayz-sdk");
40
+ const wantLocal = process.env.FAYZ_SDK_SOURCE !== "published";
41
+ const localPresent = existsSync(resolve(fayzSdk, "packages/core/src/index.ts"));
42
+ const useLocal = wantLocal && localPresent;
43
+ const localAliases = {};
44
+ if (useLocal) {
45
+ for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = resolve(fayzSdk, `packages/${p}/src`);
46
+ for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`);
47
+ }
48
+ return {
49
+ plugins: [...opts.plugins ?? []],
50
+ envPrefix: ["VITE_", "PUBLIC_"],
51
+ resolve: {
52
+ alias: {
53
+ "@": resolve(root, "src"),
54
+ ...localAliases,
55
+ ...opts.aliases ?? {}
56
+ },
57
+ dedupe: ["react", "react-dom", "zustand"],
58
+ conditions: useLocal ? ["source", "browser", "module", "jsnext:main", "jsnext"] : void 0
59
+ },
60
+ optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
61
+ server: {
62
+ port: opts.port,
63
+ strictPort: opts.strictPort,
64
+ fs: { allow: [root, fayzSdk] }
65
+ }
66
+ };
67
+ }
68
+
69
+ export { fayzVite };
70
+ //# sourceMappingURL=vite.js.map
71
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version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,EAAS,CAAA,SAAA,EAAY,CAAC,CAAA,IAAA,CAAM,CAAA;AAClG,IAAA,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,SAAS,CAAC,GAAI,IAAA,CAAK,OAAA,IAAW,EAAG,CAAA;AAAA,IACjC,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 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 react from '@vitejs/plugin-react'\n * import { fayzVite } from '@fayz-ai/sdk/vite'\n * export default defineConfig(fayzVite({ port: 5185, plugins: [react()] }))\n *\n * The app passes its own `@vitejs/plugin-react` so `@fayz-ai/sdk` carries no\n * build-tool peer deps (which otherwise choke npm's peer resolution, since sdk\n * sits in every dependency path).\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: [...(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.1",
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": [
@@ -72,6 +78,7 @@
72
78
  "devDependencies": {
73
79
  "tsup": "^8.2.0",
74
80
  "typescript": "^5.5.0",
81
+ "vite": "^5.4.0",
75
82
  "vitest": "^2.1.9"
76
83
  },
77
84
  "license": "MIT",
package/src/vite.ts ADDED
@@ -0,0 +1,80 @@
1
+ import { existsSync } from 'node:fs'
2
+ import { resolve } from 'node:path'
3
+ import type { UserConfig, PluginOption, AliasOptions } from 'vite'
4
+
5
+ // All publishable @fayz-ai/* packages (root src). Subpaths (e.g.
6
+ // @fayz-ai/saas/ui, @fayz-ai/storefront/catalog) resolve automatically via
7
+ // Vite's prefix alias matching — the shim files mirror the subpath under src/.
8
+ const SDK_PACKAGES = [
9
+ 'sdk', 'core', 'auth', 'ui', 'saas', 'shop', 'storefront', 'portal', 'courses', 'db',
10
+ ] as const
11
+
12
+ const SDK_PLUGINS = [
13
+ 'agenda', 'automations', 'conversations', 'courses', 'crm', 'dashboard',
14
+ 'financial', 'forms', 'inventory', 'marketing', 'menu', 'orders', 'reports',
15
+ 'reputation', 'shop', 'sites', 'tables', 'tasks',
16
+ ] as const
17
+
18
+ export interface FayzViteOptions {
19
+ /** Dev server port. */
20
+ port?: number
21
+ /** Fail instead of incrementing if the port is taken. */
22
+ strictPort?: boolean
23
+ /** Extra app-specific aliases, merged after the SDK aliases. */
24
+ aliases?: Record<string, string>
25
+ /** Extra Vite plugins, appended after @vitejs/plugin-react. */
26
+ plugins?: PluginOption[]
27
+ /** SDK source location relative to the app root (default ../../fayz-sdk). */
28
+ sdkDir?: string
29
+ /** App root directory (default process.cwd()). */
30
+ root?: string
31
+ }
32
+
33
+ /**
34
+ * Shared Vite config for Fayz dogfood apps. Resolves `@fayz-ai/*` from the local
35
+ * SDK source when it is checked out next to the app AND `FAYZ_SDK_SOURCE` is not
36
+ * `published`; otherwise from node_modules (the Fayz editor sandbox / published
37
+ * npm). Apps no longer hand-maintain alias maps or the local-vs-npm guard.
38
+ *
39
+ * import { defineConfig } from 'vite'
40
+ * import react from '@vitejs/plugin-react'
41
+ * import { fayzVite } from '@fayz-ai/sdk/vite'
42
+ * export default defineConfig(fayzVite({ port: 5185, plugins: [react()] }))
43
+ *
44
+ * The app passes its own `@vitejs/plugin-react` so `@fayz-ai/sdk` carries no
45
+ * build-tool peer deps (which otherwise choke npm's peer resolution, since sdk
46
+ * sits in every dependency path).
47
+ */
48
+ export function fayzVite(opts: FayzViteOptions = {}): UserConfig {
49
+ const root = opts.root ?? process.cwd()
50
+ const fayzSdk = resolve(root, opts.sdkDir ?? '../../fayz-sdk')
51
+ const wantLocal = process.env.FAYZ_SDK_SOURCE !== 'published'
52
+ const localPresent = existsSync(resolve(fayzSdk, 'packages/core/src/index.ts'))
53
+ const useLocal = wantLocal && localPresent
54
+
55
+ const localAliases: Record<string, string> = {}
56
+ if (useLocal) {
57
+ for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = resolve(fayzSdk, `packages/${p}/src`)
58
+ for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`)
59
+ }
60
+
61
+ return {
62
+ plugins: [...(opts.plugins ?? [])],
63
+ envPrefix: ['VITE_', 'PUBLIC_'],
64
+ resolve: {
65
+ alias: {
66
+ '@': resolve(root, 'src'),
67
+ ...localAliases,
68
+ ...(opts.aliases ?? {}),
69
+ } as AliasOptions,
70
+ dedupe: ['react', 'react-dom', 'zustand'],
71
+ conditions: useLocal ? ['source', 'browser', 'module', 'jsnext:main', 'jsnext'] : undefined,
72
+ },
73
+ optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
74
+ server: {
75
+ port: opts.port,
76
+ strictPort: opts.strictPort,
77
+ fs: { allow: [root, fayzSdk] },
78
+ },
79
+ }
80
+ }