@fayz-ai/sdk 0.6.1 → 0.6.3

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 CHANGED
@@ -47,23 +47,51 @@ function fayzVite(opts = {}) {
47
47
  for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = path.resolve(fayzSdk, `packages/${p}/src`);
48
48
  for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = path.resolve(fayzSdk, `plugins/plugin-${p}/src`);
49
49
  }
50
+ const { alias: userAlias, dedupe: userDedupe, conditions: _ignore, ...restResolve } = opts.resolve ?? {};
50
51
  return {
51
52
  plugins: [...opts.plugins ?? []],
52
53
  envPrefix: ["VITE_", "PUBLIC_"],
53
54
  resolve: {
55
+ ...restResolve,
54
56
  alias: {
55
57
  "@": path.resolve(root, "src"),
56
58
  ...localAliases,
57
- ...opts.aliases ?? {}
59
+ ...opts.aliases ?? {},
60
+ ...userAlias ?? {}
58
61
  },
59
- dedupe: ["react", "react-dom", "zustand"],
62
+ // lucide-react + @tanstack/react-table are pulled by both the app and
63
+ // every @fayz-ai/* package; without dedupe a version skew installs two
64
+ // copies and esbuild pre-bundles each barrel separately (lucide alone is
65
+ // ~1,500 icon modules). Collapsing to one copy is the single biggest cut
66
+ // to the editor-container optimize RAM/CPU spike.
67
+ dedupe: userDedupe ?? ["react", "react-dom", "zustand", "lucide-react", "@tanstack/react-table"],
60
68
  conditions: useLocal ? ["source", "browser", "module", "jsnext:main", "jsnext"] : void 0
61
69
  },
62
- optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
70
+ // Pre-bundle the wide barrel deps up front so the first page load runs one
71
+ // deterministic esbuild pass instead of discovering them lazily and
72
+ // triggering repeated "re-optimizing dependencies" full-page reloads.
73
+ optimizeDeps: {
74
+ exclude: useLocal ? Object.keys(localAliases) : [],
75
+ include: ["lucide-react", "@tanstack/react-table"]
76
+ },
77
+ // The preview-container runtime contract: Vite 5.4 host-check 403s any
78
+ // non-local Host (browser iframe via Caddy, health probe via
79
+ // host.docker.internal) unless allowedHosts is set. host/cors/headers keep
80
+ // the proxied iframe + cross-origin asset fetches working. Owned here
81
+ // because the app's vite.config has no literal `server: {` for the
82
+ // container's text patchers to anchor on. Caller `server` merges last.
63
83
  server: {
84
+ host: true,
64
85
  port: opts.port,
65
86
  strictPort: opts.strictPort,
66
- fs: { allow: [root, fayzSdk] }
87
+ cors: true,
88
+ allowedHosts: true,
89
+ headers: {
90
+ "Access-Control-Allow-Origin": "*",
91
+ "Cross-Origin-Resource-Policy": "cross-origin"
92
+ },
93
+ fs: { allow: [root, fayzSdk] },
94
+ ...opts.server ?? {}
67
95
  }
68
96
  };
69
97
  }
package/dist/vite.cjs.map CHANGED
@@ -1 +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,CAA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A,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.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"]}
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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AAAA,QACP,6BAAA,EAA+B,GAAA;AAAA,QAC/B,8BAAA,EAAgC;AAAA,OAClC;AAAA,MACA,IAAI,EAAE,KAAA,EAAO,CAAC,IAAA,EAAM,OAAO,CAAA,EAAE;AAAA,MAC7B,GAAI,IAAA,CAAK,MAAA,IAAU;AAAC;AACtB,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 * Extra Vite `server` config, merged over the SDK server defaults. The\n * preview-container contract (host/cors/allowedHosts/headers) is applied\n * first, so an override can add e.g. `proxy` without dropping it.\n */\n server?: UserConfig['server']\n /**\n * Extra Vite `resolve` config, merged over the SDK resolve defaults. The SDK\n * alias map / dedupe / conditions win for `@fayz-ai/*` local-source\n * resolution; any other resolve keys (and extra aliases) are merged in.\n */\n resolve?: UserConfig['resolve']\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 // Pull SDK-owned resolve keys out of any caller override so they can't clobber\n // local-source @fayz-ai/* resolution; the rest of `resolve` is merged in.\n const { alias: userAlias, dedupe: userDedupe, conditions: _ignore, ...restResolve } =\n (opts.resolve ?? {}) as Exclude<UserConfig['resolve'], undefined>\n\n return {\n plugins: [...(opts.plugins ?? [])],\n envPrefix: ['VITE_', 'PUBLIC_'],\n resolve: {\n ...restResolve,\n alias: {\n '@': resolve(root, 'src'),\n ...localAliases,\n ...(opts.aliases ?? {}),\n ...((userAlias as Record<string, string> | undefined) ?? {}),\n } as AliasOptions,\n // lucide-react + @tanstack/react-table are pulled by both the app and\n // every @fayz-ai/* package; without dedupe a version skew installs two\n // copies and esbuild pre-bundles each barrel separately (lucide alone is\n // ~1,500 icon modules). Collapsing to one copy is the single biggest cut\n // to the editor-container optimize RAM/CPU spike.\n dedupe: userDedupe ?? ['react', 'react-dom', 'zustand', 'lucide-react', '@tanstack/react-table'],\n conditions: useLocal ? ['source', 'browser', 'module', 'jsnext:main', 'jsnext'] : undefined,\n },\n // Pre-bundle the wide barrel deps up front so the first page load runs one\n // deterministic esbuild pass instead of discovering them lazily and\n // triggering repeated \"re-optimizing dependencies\" full-page reloads.\n optimizeDeps: {\n exclude: useLocal ? Object.keys(localAliases) : [],\n include: ['lucide-react', '@tanstack/react-table'],\n },\n // The preview-container runtime contract: Vite 5.4 host-check 403s any\n // non-local Host (browser iframe via Caddy, health probe via\n // host.docker.internal) unless allowedHosts is set. host/cors/headers keep\n // the proxied iframe + cross-origin asset fetches working. Owned here\n // because the app's vite.config has no literal `server: {` for the\n // container's text patchers to anchor on. Caller `server` merges last.\n server: {\n host: true,\n port: opts.port,\n strictPort: opts.strictPort,\n cors: true,\n allowedHosts: true,\n headers: {\n 'Access-Control-Allow-Origin': '*',\n 'Cross-Origin-Resource-Policy': 'cross-origin',\n },\n fs: { allow: [root, fayzSdk] },\n ...(opts.server ?? {}),\n },\n }\n}\n"]}
package/dist/vite.d.ts CHANGED
@@ -12,6 +12,18 @@ export interface FayzViteOptions {
12
12
  sdkDir?: string;
13
13
  /** App root directory (default process.cwd()). */
14
14
  root?: string;
15
+ /**
16
+ * Extra Vite `server` config, merged over the SDK server defaults. The
17
+ * preview-container contract (host/cors/allowedHosts/headers) is applied
18
+ * first, so an override can add e.g. `proxy` without dropping it.
19
+ */
20
+ server?: UserConfig['server'];
21
+ /**
22
+ * Extra Vite `resolve` config, merged over the SDK resolve defaults. The SDK
23
+ * alias map / dedupe / conditions win for `@fayz-ai/*` local-source
24
+ * resolution; any other resolve keys (and extra aliases) are merged in.
25
+ */
26
+ resolve?: UserConfig['resolve'];
15
27
  }
16
28
  /**
17
29
  * Shared Vite config for Fayz dogfood apps. Resolves `@fayz-ai/*` from the local
@@ -1 +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"}
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;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAChC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,GAAE,eAAoB,GAAG,UAAU,CAgE/D"}
package/dist/vite.js CHANGED
@@ -45,23 +45,51 @@ function fayzVite(opts = {}) {
45
45
  for (const p of SDK_PACKAGES) localAliases[`@fayz-ai/${p}`] = resolve(fayzSdk, `packages/${p}/src`);
46
46
  for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`);
47
47
  }
48
+ const { alias: userAlias, dedupe: userDedupe, conditions: _ignore, ...restResolve } = opts.resolve ?? {};
48
49
  return {
49
50
  plugins: [...opts.plugins ?? []],
50
51
  envPrefix: ["VITE_", "PUBLIC_"],
51
52
  resolve: {
53
+ ...restResolve,
52
54
  alias: {
53
55
  "@": resolve(root, "src"),
54
56
  ...localAliases,
55
- ...opts.aliases ?? {}
57
+ ...opts.aliases ?? {},
58
+ ...userAlias ?? {}
56
59
  },
57
- dedupe: ["react", "react-dom", "zustand"],
60
+ // lucide-react + @tanstack/react-table are pulled by both the app and
61
+ // every @fayz-ai/* package; without dedupe a version skew installs two
62
+ // copies and esbuild pre-bundles each barrel separately (lucide alone is
63
+ // ~1,500 icon modules). Collapsing to one copy is the single biggest cut
64
+ // to the editor-container optimize RAM/CPU spike.
65
+ dedupe: userDedupe ?? ["react", "react-dom", "zustand", "lucide-react", "@tanstack/react-table"],
58
66
  conditions: useLocal ? ["source", "browser", "module", "jsnext:main", "jsnext"] : void 0
59
67
  },
60
- optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
68
+ // Pre-bundle the wide barrel deps up front so the first page load runs one
69
+ // deterministic esbuild pass instead of discovering them lazily and
70
+ // triggering repeated "re-optimizing dependencies" full-page reloads.
71
+ optimizeDeps: {
72
+ exclude: useLocal ? Object.keys(localAliases) : [],
73
+ include: ["lucide-react", "@tanstack/react-table"]
74
+ },
75
+ // The preview-container runtime contract: Vite 5.4 host-check 403s any
76
+ // non-local Host (browser iframe via Caddy, health probe via
77
+ // host.docker.internal) unless allowedHosts is set. host/cors/headers keep
78
+ // the proxied iframe + cross-origin asset fetches working. Owned here
79
+ // because the app's vite.config has no literal `server: {` for the
80
+ // container's text patchers to anchor on. Caller `server` merges last.
61
81
  server: {
82
+ host: true,
62
83
  port: opts.port,
63
84
  strictPort: opts.strictPort,
64
- fs: { allow: [root, fayzSdk] }
85
+ cors: true,
86
+ allowedHosts: true,
87
+ headers: {
88
+ "Access-Control-Allow-Origin": "*",
89
+ "Cross-Origin-Resource-Policy": "cross-origin"
90
+ },
91
+ fs: { allow: [root, fayzSdk] },
92
+ ...opts.server ?? {}
65
93
  }
66
94
  };
67
95
  }
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite.ts"],"names":[],"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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AAQ,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"]}
1
+ {"version":3,"sources":["../src/vite.ts"],"names":[],"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,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8BAAA,EAAgC;AAAA,OAClC;AAAA,MACA,IAAI,EAAE,KAAA,EAAO,CAAC,IAAA,EAAM,OAAO,CAAA,EAAE;AAAA,MAC7B,GAAI,IAAA,CAAK,MAAA,IAAU;AAAC;AACtB,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 * Extra Vite `server` config, merged over the SDK server defaults. The\n * preview-container contract (host/cors/allowedHosts/headers) is applied\n * first, so an override can add e.g. `proxy` without dropping it.\n */\n server?: UserConfig['server']\n /**\n * Extra Vite `resolve` config, merged over the SDK resolve defaults. The SDK\n * alias map / dedupe / conditions win for `@fayz-ai/*` local-source\n * resolution; any other resolve keys (and extra aliases) are merged in.\n */\n resolve?: UserConfig['resolve']\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 // Pull SDK-owned resolve keys out of any caller override so they can't clobber\n // local-source @fayz-ai/* resolution; the rest of `resolve` is merged in.\n const { alias: userAlias, dedupe: userDedupe, conditions: _ignore, ...restResolve } =\n (opts.resolve ?? {}) as Exclude<UserConfig['resolve'], undefined>\n\n return {\n plugins: [...(opts.plugins ?? [])],\n envPrefix: ['VITE_', 'PUBLIC_'],\n resolve: {\n ...restResolve,\n alias: {\n '@': resolve(root, 'src'),\n ...localAliases,\n ...(opts.aliases ?? {}),\n ...((userAlias as Record<string, string> | undefined) ?? {}),\n } as AliasOptions,\n // lucide-react + @tanstack/react-table are pulled by both the app and\n // every @fayz-ai/* package; without dedupe a version skew installs two\n // copies and esbuild pre-bundles each barrel separately (lucide alone is\n // ~1,500 icon modules). Collapsing to one copy is the single biggest cut\n // to the editor-container optimize RAM/CPU spike.\n dedupe: userDedupe ?? ['react', 'react-dom', 'zustand', 'lucide-react', '@tanstack/react-table'],\n conditions: useLocal ? ['source', 'browser', 'module', 'jsnext:main', 'jsnext'] : undefined,\n },\n // Pre-bundle the wide barrel deps up front so the first page load runs one\n // deterministic esbuild pass instead of discovering them lazily and\n // triggering repeated \"re-optimizing dependencies\" full-page reloads.\n optimizeDeps: {\n exclude: useLocal ? Object.keys(localAliases) : [],\n include: ['lucide-react', '@tanstack/react-table'],\n },\n // The preview-container runtime contract: Vite 5.4 host-check 403s any\n // non-local Host (browser iframe via Caddy, health probe via\n // host.docker.internal) unless allowedHosts is set. host/cors/headers keep\n // the proxied iframe + cross-origin asset fetches working. Owned here\n // because the app's vite.config has no literal `server: {` for the\n // container's text patchers to anchor on. Caller `server` merges last.\n server: {\n host: true,\n port: opts.port,\n strictPort: opts.strictPort,\n cors: true,\n allowedHosts: true,\n headers: {\n 'Access-Control-Allow-Origin': '*',\n 'Cross-Origin-Resource-Policy': 'cross-origin',\n },\n fs: { allow: [root, fayzSdk] },\n ...(opts.server ?? {}),\n },\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fayz-ai/sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
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",
package/src/vite.ts CHANGED
@@ -28,6 +28,18 @@ export interface FayzViteOptions {
28
28
  sdkDir?: string
29
29
  /** App root directory (default process.cwd()). */
30
30
  root?: string
31
+ /**
32
+ * Extra Vite `server` config, merged over the SDK server defaults. The
33
+ * preview-container contract (host/cors/allowedHosts/headers) is applied
34
+ * first, so an override can add e.g. `proxy` without dropping it.
35
+ */
36
+ server?: UserConfig['server']
37
+ /**
38
+ * Extra Vite `resolve` config, merged over the SDK resolve defaults. The SDK
39
+ * alias map / dedupe / conditions win for `@fayz-ai/*` local-source
40
+ * resolution; any other resolve keys (and extra aliases) are merged in.
41
+ */
42
+ resolve?: UserConfig['resolve']
31
43
  }
32
44
 
33
45
  /**
@@ -58,23 +70,55 @@ export function fayzVite(opts: FayzViteOptions = {}): UserConfig {
58
70
  for (const p of SDK_PLUGINS) localAliases[`@fayz-ai/plugin-${p}`] = resolve(fayzSdk, `plugins/plugin-${p}/src`)
59
71
  }
60
72
 
73
+ // Pull SDK-owned resolve keys out of any caller override so they can't clobber
74
+ // local-source @fayz-ai/* resolution; the rest of `resolve` is merged in.
75
+ const { alias: userAlias, dedupe: userDedupe, conditions: _ignore, ...restResolve } =
76
+ (opts.resolve ?? {}) as Exclude<UserConfig['resolve'], undefined>
77
+
61
78
  return {
62
79
  plugins: [...(opts.plugins ?? [])],
63
80
  envPrefix: ['VITE_', 'PUBLIC_'],
64
81
  resolve: {
82
+ ...restResolve,
65
83
  alias: {
66
84
  '@': resolve(root, 'src'),
67
85
  ...localAliases,
68
86
  ...(opts.aliases ?? {}),
87
+ ...((userAlias as Record<string, string> | undefined) ?? {}),
69
88
  } as AliasOptions,
70
- dedupe: ['react', 'react-dom', 'zustand'],
89
+ // lucide-react + @tanstack/react-table are pulled by both the app and
90
+ // every @fayz-ai/* package; without dedupe a version skew installs two
91
+ // copies and esbuild pre-bundles each barrel separately (lucide alone is
92
+ // ~1,500 icon modules). Collapsing to one copy is the single biggest cut
93
+ // to the editor-container optimize RAM/CPU spike.
94
+ dedupe: userDedupe ?? ['react', 'react-dom', 'zustand', 'lucide-react', '@tanstack/react-table'],
71
95
  conditions: useLocal ? ['source', 'browser', 'module', 'jsnext:main', 'jsnext'] : undefined,
72
96
  },
73
- optimizeDeps: { exclude: useLocal ? Object.keys(localAliases) : [] },
97
+ // Pre-bundle the wide barrel deps up front so the first page load runs one
98
+ // deterministic esbuild pass instead of discovering them lazily and
99
+ // triggering repeated "re-optimizing dependencies" full-page reloads.
100
+ optimizeDeps: {
101
+ exclude: useLocal ? Object.keys(localAliases) : [],
102
+ include: ['lucide-react', '@tanstack/react-table'],
103
+ },
104
+ // The preview-container runtime contract: Vite 5.4 host-check 403s any
105
+ // non-local Host (browser iframe via Caddy, health probe via
106
+ // host.docker.internal) unless allowedHosts is set. host/cors/headers keep
107
+ // the proxied iframe + cross-origin asset fetches working. Owned here
108
+ // because the app's vite.config has no literal `server: {` for the
109
+ // container's text patchers to anchor on. Caller `server` merges last.
74
110
  server: {
111
+ host: true,
75
112
  port: opts.port,
76
113
  strictPort: opts.strictPort,
114
+ cors: true,
115
+ allowedHosts: true,
116
+ headers: {
117
+ 'Access-Control-Allow-Origin': '*',
118
+ 'Cross-Origin-Resource-Policy': 'cross-origin',
119
+ },
77
120
  fs: { allow: [root, fayzSdk] },
121
+ ...(opts.server ?? {}),
78
122
  },
79
123
  }
80
124
  }