@salesforce/vite-plugin-lwc-ui-bundle 1.135.0 → 2.1.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 CHANGED
@@ -97,7 +97,7 @@ lwcOptions: {
97
97
 
98
98
  ### `ignorePatterns`
99
99
 
100
- Specifier prefixes that should never be intercepted by providers, even if they match a provider or intercept prefix. Defaults to `['@salesforce/sdk-', '@salesforce/core']`.
100
+ Specifier prefixes that should never be intercepted by providers, even if they match a provider or intercept prefix. Defaults to `['@salesforce/sdk-', '@salesforce/platform-sdk-', '@salesforce/core']`. The legacy `@salesforce/sdk-` entry is kept so external consumers using the previously-published SDK package names continue to work.
101
101
 
102
102
  ### `passthroughRules`
103
103
 
@@ -151,7 +151,7 @@ lds({
151
151
  "lightning/uiRecordApi": {
152
152
  getRecord: {
153
153
  type: "wire",
154
- toolName: "getRecordMcpTool",
154
+ mcp: { toolName: "getRecordMcpTool" },
155
155
  configJsonSchema: {
156
156
  type: "object",
157
157
  properties: { recordId: { type: "string" } },
@@ -161,7 +161,7 @@ lds({
161
161
  },
162
162
  createRecord: {
163
163
  type: "imperative-mutation",
164
- toolName: "createRecordMcpTool",
164
+ mcp: { toolName: "createRecordMcpTool" },
165
165
  configJsonSchema: {
166
166
  type: "object",
167
167
  properties: {
@@ -182,7 +182,7 @@ lds({
182
182
  getObjectInfo_imperative: {
183
183
  type: "imperative-read",
184
184
  invokerShape: "legacy",
185
- toolName: "getObjectInfoMcpTool",
185
+ mcp: { toolName: "getObjectInfoMcpTool" },
186
186
  configJsonSchema: {
187
187
  type: "object",
188
188
  properties: { objectApiName: { type: "string" } },
@@ -192,8 +192,8 @@ lds({
192
192
  },
193
193
  },
194
194
  "lightning/graphql": {
195
- graphql: { type: "graphql-wire", toolName: "graphqlQuery" },
196
- executeMutation: { type: "graphql-mutation", toolName: "graphqlQuery" },
195
+ graphql: { type: "graphql-wire", mcp: { toolName: "graphqlQuery" } },
196
+ executeMutation: { type: "graphql-mutation", mcp: { toolName: "graphqlQuery" } },
197
197
  },
198
198
  });
199
199
  ```
@@ -235,7 +235,7 @@ This is deliberate: native `subscribe` is driven by a reactive store, and off-pl
235
235
 
236
236
  #### OneStore runtime dependencies
237
237
 
238
- `@conduit-client/*` is bundled into the plugin's `runtime.js` artifact at plugin-publish time, not re-imported from the consumer's module graph. Consumers don't need to install or declare any `@conduit-client/*` dependency — component code stays identical to its on-platform form. The only runtime peer the virtual module imports from is `@salesforce/sdk-chat`, which bridges to `window.openai` / MCP Apps.
238
+ `@conduit-client/*` is bundled into the plugin's `runtime.js` artifact at plugin-publish time, not re-imported from the consumer's module graph. Consumers don't need to install or declare any `@conduit-client/*` dependency — component code stays identical to its on-platform form. The only runtime peer the virtual module imports from is `@salesforce/platform-sdk-chat`, which bridges to `window.openai` / MCP Apps.
239
239
 
240
240
  ## Custom Providers
241
241
 
@@ -280,14 +280,25 @@ The plugin factory returns an array of coordinated Vite plugins:
280
280
  | `rollup-plugin-lwc-compiler` | `@lwc/rollup-plugin` with Vite guard rails |
281
281
  | `vite-plugin-lwc-stubs` | Alias stubs (only present if `stubs` is non-empty) |
282
282
 
283
- ## Local Salesforce Dev (lwcProxy)
283
+ ## Local Dev
284
284
 
285
- `lwcProxy()` is an optional companion plugin that proxies Salesforce API calls to a connected org, enabling `lightning/*` modules that call `/services/*` directly (via `@salesforce/sdk-data`) to work in local dev. `lightning/graphql` itself now dispatches through MCP (`getChatSDK().callTool("graphqlQuery", ...)`) via `builtins.lds()` — the `globalThis.__sfdc_sdk__.graphql` shortcut was removed. For local dev without an MCP host, mock `window.openai.callTool` in `bootstrap.js`.
285
+ The compiled bundle targets MCP hosts (ChatGPT, MCP Apps). For local development, you have two options:
286
+
287
+ 1. **Mock `window.openai.callTool` in your entry script** — the recommended and simplest path. See the [`lwc-simple`](../../examples/lwc-axl/lwc-simple/src/main.js) and [`lwc-records`](../../examples/lwc-axl/lwc-records/src/app/bootstrap.js) examples. Guard the install with `if (!window.openai?.callTool)` so the same compiled bundle skips the mock when loaded by a real host.
288
+ 2. **Run a local MCP server.** A local demo MCP host serves your `dist/index.html` and provides real `callTool` dispatch. More accurately reflects production runtime than the mock; ask your platform team for the current demo MCP app.
289
+
290
+ Either way, the plugin's runtime is production-only: local-dev concerns belong in your entry script (or local MCP harness), not in the compiled artifact.
291
+
292
+ ## Optional: Org Passthrough for `/services/*` Modules
293
+
294
+ `lwcProxy()` is an optional companion plugin for consumers whose components include `lightning/*` modules that call `/services/*` directly (e.g. legacy code predating the LDS adapter migration). It proxies those requests to a connected org so the dev server can serve live data.
295
+
296
+ `lightning/graphql` and `lightning/uiRecordApi` do **not** need `lwcProxy` — they dispatch through MCP (`getChatSDK().callTool`) via `builtins.lds()`. For those, route the `graphqlQuery` / `getRecordMcpTool` tool names at your MCP host (local demo or production) rather than the dev-server proxy.
286
297
 
287
298
  ### Setup
288
299
 
289
300
  ```bash
290
- npm install @salesforce/vite-plugin-lwc-ui-bundle @salesforce/sdk-data @salesforce/ui-bundle
301
+ npm install @salesforce/vite-plugin-lwc-ui-bundle @salesforce/ui-bundle
291
302
  ```
292
303
 
293
304
  ```js
@@ -302,17 +313,11 @@ export default defineConfig({
302
313
  });
303
314
  ```
304
315
 
305
- ```js
306
- // src/bootstrap.js — initialise before the app mounts
307
- import { createDataSDK } from "@salesforce/sdk-data";
308
- globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: "/" } });
309
- ```
310
-
311
316
  ### How it works
312
317
 
313
318
  - `lwcProxy()` intercepts `/services/*` and `/lwr/*` requests in the Vite dev server and forwards them to Salesforce with the org's access token
314
319
  - Credentials are read automatically from the `sf` CLI (uses `@salesforce/ui-bundle/app`, an optional peer dep)
315
- - `lightning/graphql` is handled by `builtins.lds()` and dispatches through MCP (`getChatSDK().callTool`) regardless of `lwcProxy` route the `graphqlQuery` tool to your proxy via your MCP host if you need live GraphQL against the connected org
320
+ - Works with `npm run dev` onlynot the production build
316
321
 
317
322
  ### Options
318
323
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAOnC,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAa,oBAAoB,EAA6B,MAAM,SAAS,CAAC;AAE1F,YAAY,EACX,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,SAAS,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAkCvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAoJlF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAOnC,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAa,oBAAoB,EAA6B,MAAM,SAAS,CAAC;AAE1F,YAAY,EACX,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,SAAS,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAkCvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAuJlF"}
package/dist/index.js CHANGED
@@ -394,7 +394,10 @@ function lwcVitePlugin(options = {}) {
394
394
  stubs = {},
395
395
  lwcOptions = {},
396
396
  ignorePatterns = [
397
+ // Legacy @salesforce/sdk-* prefix — kept for external consumers still on the
398
+ // pre-rename package names. Internal packages are all @salesforce/platform-sdk-*.
397
399
  "@salesforce/sdk-",
400
+ "@salesforce/platform-sdk-",
398
401
  "@salesforce/core",
399
402
  "@salesforce/vite-plugin-lwc-ui-bundle"
400
403
  ],
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/discovery.ts","../src/plugins/lightning-npm.ts","../src/plugins/lwc-bridge.ts","../src/plugins/lwc-wrapper.ts","../src/plugins/missing-css.ts","../src/plugins/scoped-providers.ts","../src/plugins/proxy.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { DirConfig, DiscoveredModule } from \"./types\";\n\nexport function discoverModules(dirs: (string | DirConfig)[] = []): DiscoveredModule[] {\n\tconst modules: DiscoveredModule[] = [];\n\n\tfor (const dir of dirs) {\n\t\tconst dirPath = typeof dir === \"string\" ? dir : dir.path;\n\t\tconst namespace = typeof dir === \"string\" ? undefined : dir.namespace;\n\t\tconst resolvedDir = path.resolve(dirPath);\n\n\t\tif (!existsSync(resolvedDir) || !statSync(resolvedDir).isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (namespace) {\n\t\t\t// Flat DX structure: <dir>/<componentName>/<componentName>.js\n\t\t\tfor (const name of readdirSync(resolvedDir)) {\n\t\t\t\tconst fullPath = path.join(resolvedDir, name);\n\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\tmodules.push({\n\t\t\t\t\t\tname: `${namespace}/${name}`,\n\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Standard structure: <dir>/<namespace>/<componentName>/<componentName>.js\n\t\t\tfor (const ns of readdirSync(resolvedDir)) {\n\t\t\t\tconst nsDir = path.join(resolvedDir, ns);\n\t\t\t\tif (!statSync(nsDir).isDirectory()) continue;\n\n\t\t\t\tfor (const name of readdirSync(nsDir)) {\n\t\t\t\t\tconst fullPath = path.join(nsDir, name);\n\t\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\t\tmodules.push({\n\t\t\t\t\t\t\tname: `${ns}/${name}`,\n\t\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modules;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport type { LightningNpmOptions } from \"../types\";\n\nfunction resolveJsFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.js`);\n\tif (existsSync(nested)) return nested;\n\tconst flat = path.join(root, `${sub}.js`);\n\tif (existsSync(flat)) return flat;\n\treturn null;\n}\n\nfunction resolveCssFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.css`);\n\treturn existsSync(nested) ? nested : null;\n}\n\nexport function lightningNpm({ npmRoot, overrideDirs = [] }: LightningNpmOptions): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-resolve-lightning-npm\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(importee) {\n\t\t\tif (!importee.startsWith(\"lightning/\")) return null;\n\n\t\t\tconst sub = importee.slice(\"lightning/\".length);\n\t\t\tconst segments = sub.split(\"/\");\n\t\t\tconst leaf = segments[segments.length - 1];\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst overridePath = path.join(dir, ...segments, `${leaf}.js`);\n\t\t\t\tif (existsSync(overridePath)) return null;\n\t\t\t}\n\n\t\t\tconst npmJs = resolveJsFromRoot(npmRoot, sub);\n\t\t\tif (npmJs) return npmJs;\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst cssFallback = path.join(dir, ...segments, `${leaf}.css`);\n\t\t\t\tif (existsSync(cssFallback)) return cssFallback;\n\t\t\t}\n\n\t\t\treturn resolveCssFromRoot(npmRoot, sub);\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\n\nexport function lwcBridge(isComponentAsset: (id: string) => boolean): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-bridge\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config: ResolvedConfig) {\n\t\t\tfor (const plugin of config.plugins) {\n\t\t\t\tif (plugin.name === \"vite:css\" || plugin.name === \"vite:css-post\") {\n\t\t\t\t\tconst p = plugin as unknown as Record<string, unknown>;\n\t\t\t\t\tconst origTransform = p[\"transform\"];\n\t\t\t\t\tif (!origTransform) continue;\n\n\t\t\t\t\tif (typeof origTransform === \"function\") {\n\t\t\t\t\t\t// Vite <7: transform is a plain function\n\t\t\t\t\t\tp[\"transform\"] = function (\n\t\t\t\t\t\t\tthis: unknown,\n\t\t\t\t\t\t\tcode: string,\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\t...rest: unknown[]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\treturn (origTransform as (...a: unknown[]) => unknown).call(this, code, id, ...rest);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof origTransform === \"object\" &&\n\t\t\t\t\t\ttypeof (origTransform as Record<string, unknown>)[\"handler\"] === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Vite 7+: transform is { handler, order? }\n\t\t\t\t\t\tconst origHandler = (origTransform as Record<string, unknown>)[\"handler\"] as (\n\t\t\t\t\t\t\t...a: unknown[]\n\t\t\t\t\t\t) => unknown;\n\t\t\t\t\t\tp[\"transform\"] = {\n\t\t\t\t\t\t\t...(origTransform as object),\n\t\t\t\t\t\t\thandler: function (this: unknown, code: string, id: string, ...rest: unknown[]) {\n\t\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\t\treturn origHandler.call(this, code, id, ...rest);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tresolveId(id, importer) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tconst cleanId = id.split(\"?\", 2)[0] ?? id;\n\n\t\t\tif (cleanId.endsWith(\".html\") && isComponentAsset(cleanId) && !id.includes(\"?lwc\")) {\n\t\t\t\treturn `${cleanId}?lwc`;\n\t\t\t}\n\n\t\t\tif (!importer) return null;\n\t\t\tif (!cleanId.endsWith(\".html\")) return null;\n\t\t\tif (!cleanId.startsWith(\"./\") && !cleanId.startsWith(\"../\")) return null;\n\t\t\tif (!isComponentAsset(importer)) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importer.split(\"?\")[0] ?? importer), cleanId);\n\n\t\t\tif (existsSync(resolved)) {\n\t\t\t\treturn resolved + \"?lwc\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn \"export default undefined;\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\ntype AnyFn = (this: unknown, ...args: unknown[]) => unknown;\ntype LwcRollupFactory = (options: Record<string, unknown>) => Plugin;\ntype LazyLwcRollupLoader = () => Promise<LwcRollupFactory>;\n\nexport function lwcWrapper(\n\tlazyLoader: LazyLwcRollupLoader,\n\toptions: Record<string, unknown>,\n\tisComponentAsset?: (id: string) => boolean,\n): Plugin {\n\tlet pluginPromise: Promise<Plugin> | null = null;\n\n\tconst getPlugin = () => {\n\t\tif (!pluginPromise) {\n\t\t\tpluginPromise = lazyLoader().then((factory) => factory(options));\n\t\t}\n\t\treturn pluginPromise;\n\t};\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-wrapper\",\n\t\tenforce: \"pre\" as const,\n\t\tasync resolveId(importee: string, importer?: string) {\n\t\t\tif (importer?.split(\"?\")[0]?.endsWith(\"index.html\") && !importer.includes(\"html-proxy\"))\n\t\t\t\treturn null;\n\t\t\tif (importee.startsWith(\"/@\") || importee.startsWith(\"\\0\")) return null;\n\t\t\tif (importer?.includes(\"/node_modules/vite/\")) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.resolveId === \"function\"\n\t\t\t\t? (plugin.resolveId as AnyFn).call(this, importee, importer)\n\t\t\t\t: null;\n\t\t},\n\t\tasync load(id: string) {\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.load === \"function\" ? (plugin.load as AnyFn).call(this, id) : null;\n\t\t},\n\t\tasync transform(code: string, id: string) {\n\t\t\t// Only pass files to the LWC compiler if they are LWC component assets.\n\t\t\t// Non-component files (SDK sources, node_modules, etc.) must be skipped.\n\t\t\tif (isComponentAsset && !isComponentAsset(id)) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.transform === \"function\"\n\t\t\t\t? (plugin.transform as AnyFn).call(this, code, id)\n\t\t\t\t: null;\n\t\t},\n\t} as Plugin;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst LWC_EMPTY_CSS = \"\\0lwc-empty-css\";\n\nexport function missingCss(): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-missing-css\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\tif (!importer || !id.startsWith(\"./\") || !id.includes(\".css\")) return null;\n\t\t\tconst importerPath = importer.split(\"?\")[0] ?? importer;\n\t\t\tif (!importerPath.endsWith(\".html\")) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importerPath), id.split(\"?\")[0] ?? id);\n\t\t\tif (existsSync(resolved)) return null;\n\n\t\t\treturn `${LWC_EMPTY_CSS}?${id}`;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(LWC_EMPTY_CSS)) {\n\t\t\t\treturn \"export default undefined\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\nimport type { Provider, ScopedProvidersOptions } from \"../types\";\n\nconst VIRTUAL_PREFIX = \"\\0sf-provider:\";\n\nexport function scopedProviders(\n\tproviders: Provider[] = [],\n\toptions: ScopedProvidersOptions = {},\n): Plugin {\n\tconst { ignorePatterns = [], interceptPrefixes = [], passthroughRules = [] } = options;\n\n\tconst prefixSet = new Set<string>();\n\tfor (const p of providers) {\n\t\tif (p.prefix) prefixSet.add(p.prefix);\n\t}\n\n\tfunction shouldIntercept(id: string): boolean {\n\t\tfor (const prefix of prefixSet) {\n\t\t\tif (id === prefix || id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const prefix of interceptPrefixes) {\n\t\t\tif (id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const p of providers) {\n\t\t\tif (!p.prefix && typeof p.match === \"function\" && p.match(id)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-scoped-module-providers\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\t// Explicit provider prefix always wins over ignorePatterns —\n\t\t\t// if a provider is registered for a specifier, it always handles it.\n\t\t\tconst handledByProvider = [...prefixSet].some((p) => id === p || id.startsWith(p + \"/\"));\n\n\t\t\tif (!handledByProvider) {\n\t\t\t\tif (!shouldIntercept(id)) return null;\n\n\t\t\t\tfor (const pattern of ignorePatterns) {\n\t\t\t\t\tif (id.startsWith(pattern)) return null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const rule of passthroughRules) {\n\t\t\t\tif (\n\t\t\t\t\timporter &&\n\t\t\t\t\tid.startsWith(rule.specifierPrefix) &&\n\t\t\t\t\timporter.includes(rule.importerPattern)\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn VIRTUAL_PREFIX + id;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(VIRTUAL_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(VIRTUAL_PREFIX.length);\n\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst result = provider.resolve(specifier);\n\t\t\t\tif (result != null) return result;\n\t\t\t}\n\n\t\t\tconsole.warn(\n\t\t\t\t`[scoped-module-providers] Unhandled import: ${specifier} — returning undefined`,\n\t\t\t);\n\t\t\treturn `export default undefined;`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport type { Plugin } from \"vite\";\n\nexport interface LwcProxyOptions {\n\t/** Salesforce org alias (defaults to the sf CLI default org) */\n\torgAlias?: string;\n\t/** Enable verbose request logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that proxies Salesforce API calls to a connected org.\n *\n * Uses the same authentication approach as @salesforce/vite-plugin-ui-bundle —\n * reads credentials from the sf CLI via @salesforce/ui-bundle/app.\n *\n * Intercepts requests to /services/ and /lwr/ and forwards them to Salesforce\n * with the org's access token. Handles token refresh on 401/403 responses.\n *\n * Usage in vite.config.js:\n * import { lwcProxy } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [lwcVitePlugin(...), lwcProxy()]\n *\n * Then initialise the SDK in your app's bootstrap:\n * import { createDataSDK } from '@salesforce/sdk-data';\n * globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: '/' } });\n */\nexport function lwcProxy(options: LwcProxyOptions = {}): Plugin {\n\tlet instanceUrl: string | undefined;\n\tlet accessToken: string | undefined;\n\tconst orgAlias: string | undefined = options.orgAlias;\n\n\tasync function loadOrgInfo(): Promise<void> {\n\t\ttry {\n\t\t\t// Dynamically import to avoid bundling @salesforce/ui-bundle at build time\n\t\t\tconst { getOrgInfo } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await getOrgInfo(orgAlias);\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.log(`[lwc-proxy] Connected to ${instanceUrl}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.error(\n\t\t\t\t`[lwc-proxy] Failed to load org info — is a Salesforce org connected?\\n ${msg}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync function refreshToken(): Promise<void> {\n\t\ttry {\n\t\t\tconst { refreshOrgAuth } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await refreshOrgAuth(orgAlias ?? \"\");\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore refresh errors\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-proxy\",\n\t\tenforce: \"pre\",\n\n\t\tasync configResolved() {\n\t\t\tawait loadOrgInfo();\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.middlewares.use(async (req, res, next) => {\n\t\t\t\tconst url = req.url ?? \"\";\n\n\t\t\t\t// Only proxy Salesforce API paths\n\t\t\t\tif (!url.startsWith(\"/services/\") && !url.startsWith(\"/lwr/\")) {\n\t\t\t\t\treturn next();\n\t\t\t\t}\n\n\t\t\t\tif (!instanceUrl || !accessToken) {\n\t\t\t\t\tres.writeHead(503, { \"Content-Type\": \"application/json\" });\n\t\t\t\t\tres.end(\n\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\terror: \"SERVICE_UNAVAILABLE\",\n\t\t\t\t\t\t\tmessage: \"Salesforce org not connected. Run: sf org display\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst forward = async (token: string): Promise<void> => {\n\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\tconst targetUrl = new URL(url, instanceUrl);\n\t\t\t\t\t\tconst isHttps = targetUrl.protocol === \"https:\";\n\t\t\t\t\t\tconst transport = isHttps ? https : http;\n\n\t\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\t\tconsole.log(`[lwc-proxy] ${req.method} ${url}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip hop-by-hop headers\n\t\t\t\t\t\tconst headers: Record<string, string | string[]> = {};\n\t\t\t\t\t\tfor (const [key, value] of Object.entries(req.headers)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t![\n\t\t\t\t\t\t\t\t\t\"host\",\n\t\t\t\t\t\t\t\t\t\"connection\",\n\t\t\t\t\t\t\t\t\t\"keep-alive\",\n\t\t\t\t\t\t\t\t\t\"proxy-authenticate\",\n\t\t\t\t\t\t\t\t\t\"proxy-authorization\",\n\t\t\t\t\t\t\t\t\t\"te\",\n\t\t\t\t\t\t\t\t\t\"trailers\",\n\t\t\t\t\t\t\t\t\t\"transfer-encoding\",\n\t\t\t\t\t\t\t\t\t\"upgrade\",\n\t\t\t\t\t\t\t\t].includes(key.toLowerCase()) &&\n\t\t\t\t\t\t\t\tvalue !== undefined\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\theaders[key] = value as string | string[];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\theaders[\"host\"] = targetUrl.host;\n\t\t\t\t\t\theaders[\"authorization\"] = `Bearer ${token}`;\n\t\t\t\t\t\theaders[\"cookie\"] = `sid=${token}`;\n\n\t\t\t\t\t\tconst proxyReq = transport.request(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\t\t\thostname: targetUrl.hostname,\n\t\t\t\t\t\t\t\tport: targetUrl.port || (isHttps ? 443 : 80),\n\t\t\t\t\t\t\t\tpath: targetUrl.pathname + targetUrl.search,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(proxyRes) => {\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\tres.writeHead(proxyRes.statusCode ?? 200, proxyRes.headers);\n\t\t\t\t\t\t\t\tproxyRes.pipe(res);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treq.pipe(proxyReq);\n\t\t\t\t\t\tproxyReq.on(\"error\", reject);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\tawait forward(accessToken!);\n\n\t\t\t\t\t// On 401/403, refresh token and retry once\n\t\t\t\t\t// Note: we can't easily check status here since we piped to res,\n\t\t\t\t\t// so we rely on the transform hook below for retries in future iterations\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.error(\"[lwc-proxy] Request failed:\", error);\n\t\t\t\t\t}\n\t\t\t\t\t// Try refreshing token and retry\n\t\t\t\t\tawait refreshToken();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait forward(accessToken!);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tnext(err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { discoverModules } from \"./discovery\";\nimport { lightningNpm } from \"./plugins/lightning-npm\";\nimport { lwcBridge } from \"./plugins/lwc-bridge\";\nimport { lwcWrapper } from \"./plugins/lwc-wrapper\";\nimport { missingCss } from \"./plugins/missing-css\";\nimport { scopedProviders } from \"./plugins/scoped-providers\";\nimport * as builtinProviders from \"./providers/index\";\nimport type { DirConfig, LwcVitePluginOptions, NpmModuleConfig, Provider } from \"./types\";\n\nexport type {\n\tProvider,\n\tLwcVitePluginOptions,\n\tPassthroughRule,\n\tDiscoveredModule,\n\tDirConfig,\n} from \"./types\";\nexport { builtinProviders as builtins };\nexport { discoverModules } from \"./discovery\";\nexport { lwcProxy } from \"./plugins/proxy\";\nexport type { LwcProxyOptions } from \"./plugins/proxy\";\n\nfunction defaultProviders(): (Provider | Plugin)[] {\n\treturn [\n\t\tbuiltinProviders.label(),\n\t\tbuiltinProviders.i18n(),\n\t\tbuiltinProviders.accessCheck(),\n\t\tbuiltinProviders.client(),\n\t\tbuiltinProviders.gate(),\n\t\tbuiltinProviders.primitiveUtils(),\n\t\tbuiltinProviders.lds(),\n\t];\n}\n\n/** Distinguishes a scoped-providers `Provider` from a raw Vite `Plugin`. */\nfunction isProvider(item: Provider | Plugin): item is Provider {\n\treturn typeof (item as Provider).resolve === \"function\";\n}\n\nasync function loadLwcRollup() {\n\ttry {\n\t\t// Use dynamic import to load ESM-only @lwc/rollup-plugin (peer dep, types not guaranteed)\n\t\tconst mod = await (import(\"@lwc/rollup-plugin\") as Promise<Record<string, unknown>>);\n\t\treturn (mod[\"default\"] ?? mod) as unknown as (options: Record<string, unknown>) => Plugin;\n\t} catch (error) {\n\t\tconst errMsg = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle requires @lwc/rollup-plugin as a peer dependency. \" +\n\t\t\t\t\"Install it with: npm install -D @lwc/rollup-plugin\\n\" +\n\t\t\t\t`Debug: cwd=${process.cwd()}, error=${errMsg}`,\n\t\t);\n\t}\n}\n\nexport default function lwcVitePlugin(options: LwcVitePluginOptions = {}): Plugin[] {\n\tconst {\n\t\tmodules = {},\n\t\tproviders,\n\t\tstubs = {},\n\t\tlwcOptions = {},\n\t\tignorePatterns = [\n\t\t\t\"@salesforce/sdk-\",\n\t\t\t\"@salesforce/core\",\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle\",\n\t\t],\n\t\tpassthroughRules = [],\n\t} = options;\n\n\tconst resolvedItems = providers ?? defaultProviders();\n\tconst resolvedProviders = resolvedItems.filter(isProvider);\n\tconst rawPlugins = resolvedItems.filter((item): item is Plugin => !isProvider(item));\n\n\tconst { dirs = [], npm: npmPackages = [] } = modules;\n\n\tconst resolvedDirs: DirConfig[] = dirs.map((d) =>\n\t\ttypeof d === \"string\"\n\t\t\t? { path: path.resolve(d), namespace: \"\" }\n\t\t\t: { ...d, path: path.resolve(d.path) },\n\t);\n\n\tconst npmConfigs: NpmModuleConfig[] = npmPackages.map((pkg) =>\n\t\ttypeof pkg === \"string\" ? { npm: pkg } : pkg,\n\t);\n\n\tconst require = createRequire(import.meta.url);\n\tconst npmRoots = npmConfigs.map((cfg) => {\n\t\tconst pkgJson = require.resolve(`${cfg.npm}/package.json`);\n\t\treturn path.join(path.dirname(pkgJson), \"src\", \"lightning\");\n\t});\n\n\tconst discoveredModules = discoverModules(dirs);\n\n\tconst lwcModules = [...npmConfigs, ...discoveredModules];\n\n\tconst lightningOverrideDirs = resolvedDirs.map((d) => path.join(d.path, \"lightning\"));\n\n\tfunction isComponentAsset(id: string): boolean {\n\t\tconst clean = id.split(\"?\")[0] ?? id;\n\t\tfor (const dir of resolvedDirs) {\n\t\t\tif (clean.includes(dir.path)) return true;\n\t\t}\n\t\tfor (const cfg of npmConfigs) {\n\t\t\tif (clean.includes(cfg.npm)) return true;\n\t\t}\n\t\treturn clean.includes(\"@lwc/\") || clean.startsWith(\"\\0lwc-empty-css\");\n\t}\n\n\tconst stubAliases: Record<string, string> = {};\n\tfor (const [specifier, stubPath] of Object.entries(stubs)) {\n\t\tstubAliases[specifier] = path.resolve(stubPath);\n\t}\n\n\tconst interceptPrefixes = new Set<string>();\n\tfor (const p of resolvedProviders) {\n\t\tif (p.prefix && p.prefix.startsWith(\"@\")) {\n\t\t\tinterceptPrefixes.add(p.prefix.split(\"/\")[0] + \"/\");\n\t\t}\n\t}\n\n\tconst plugins: Plugin[] = [\n\t\t{\n\t\t\tname: \"vite-plugin-lwc-optimize-deps\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\texclude: [\"lwc\"],\n\t\t\t\t\t\tesbuildOptions: {\n\t\t\t\t\t\t\tplugins: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"lwc-html-stub\",\n\t\t\t\t\t\t\t\t\tsetup(build: {\n\t\t\t\t\t\t\t\t\t\tonResolve: (\n\t\t\t\t\t\t\t\t\t\t\toptions: { filter: RegExp },\n\t\t\t\t\t\t\t\t\t\t\tcallback: (args: { path: string }) => {\n\t\t\t\t\t\t\t\t\t\t\t\tpath: string;\n\t\t\t\t\t\t\t\t\t\t\t\texternal: boolean;\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t) => void;\n\t\t\t\t\t\t\t\t\t}) {\n\t\t\t\t\t\t\t\t\t\t// esbuild cannot process LWC HTML templates (?lwc suffix).\n\t\t\t\t\t\t\t\t\t\t// Mark them as external so Vite's own plugin handles them.\n\t\t\t\t\t\t\t\t\t\tbuild.onResolve({ filter: /\\.html/ }, (args: { path: string }) => ({\n\t\t\t\t\t\t\t\t\t\t\tpath: args.path,\n\t\t\t\t\t\t\t\t\t\t\texternal: true,\n\t\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t// plugins returned by plugin-style builtins (e.g. lds())\n\t\t...rawPlugins,\n\t\tscopedProviders(resolvedProviders, {\n\t\t\tignorePatterns,\n\t\t\tinterceptPrefixes: [...interceptPrefixes],\n\t\t\tpassthroughRules,\n\t\t}),\n\n\t\t...npmRoots.map((npmRoot) =>\n\t\t\tlightningNpm({\n\t\t\t\tnpmRoot,\n\t\t\t\toverrideDirs: lightningOverrideDirs,\n\t\t\t}),\n\t\t),\n\n\t\tmissingCss(),\n\t\tlwcBridge(isComponentAsset),\n\t\tlwcWrapper(\n\t\t\tloadLwcRollup,\n\t\t\t{\n\t\t\t\trootDir: process.cwd(),\n\t\t\t\t...lwcOptions,\n\t\t\t\tmodules: lwcModules,\n\t\t\t\texclude: [\n\t\t\t\t\t\"**/index.html\",\n\t\t\t\t\t\"**/node_modules/vite/**\",\n\t\t\t\t\t\"**/node_modules/.vite/**\",\n\t\t\t\t\t...((lwcOptions.exclude as string[]) || []),\n\t\t\t\t],\n\t\t\t},\n\t\t\tisComponentAsset,\n\t\t),\n\t];\n\n\tif (Object.keys(stubAliases).length > 0) {\n\t\tplugins.push({\n\t\t\tname: \"vite-plugin-lwc-stubs\",\n\t\t\tenforce: \"pre\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\tresolve: {\n\t\t\t\t\t\talias: stubAliases,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t}\n\n\treturn plugins;\n}\n"],"names":["builtinProviders.label","builtinProviders.i18n","builtinProviders.accessCheck","builtinProviders.client","builtinProviders.gate","builtinProviders.primitiveUtils","builtinProviders.lds","require"],"mappings":";;;;;;;;AASO,SAAS,gBAAgB,OAA+B,IAAwB;AACtF,QAAM,UAA8B,CAAA;AAEpC,aAAW,OAAO,MAAM;AACvB,UAAM,UAAU,OAAO,QAAQ,WAAW,MAAM,IAAI;AACpD,UAAM,YAAY,OAAO,QAAQ,WAAW,SAAY,IAAI;AAC5D,UAAM,cAAc,KAAK,QAAQ,OAAO;AAExC,QAAI,CAAC,WAAW,WAAW,KAAK,CAAC,SAAS,WAAW,EAAE,eAAe;AACrE;AAAA,IACD;AAEA,QAAI,WAAW;AAEd,iBAAW,QAAQ,YAAY,WAAW,GAAG;AAC5C,cAAM,WAAW,KAAK,KAAK,aAAa,IAAI;AAC5C,YAAI,CAAC,SAAS,QAAQ,EAAE,cAAe;AAEvC,cAAM,YAAY,KAAK,KAAK,UAAU,GAAG,IAAI,KAAK;AAClD,YAAI,WAAW,SAAS,GAAG;AAC1B,kBAAQ,KAAK;AAAA,YACZ,MAAM,GAAG,SAAS,IAAI,IAAI;AAAA,YAC1B,MAAM,KAAK,QAAQ,SAAS;AAAA,UAAA,CAC5B;AAAA,QACF;AAAA,MACD;AAAA,IACD,OAAO;AAEN,iBAAW,MAAM,YAAY,WAAW,GAAG;AAC1C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,QAAC;AAAA,MAC1C;AAAA,MAED;AAAA,IAAA;AAAA,EACD;AAGD,MAAI,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACxC,YAAQ,KAAK;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AACR,eAAO;AAAA,UACN,SAAS;AAAA,YACR,OAAO;AAAA,UAAA;AAAA,QACR;AAAA,MAEF;AAAA,IAAA,CACA;AAAA,EACF;AAEA,SAAO;AACR;"}
1
+ {"version":3,"file":"index.js","sources":["../src/discovery.ts","../src/plugins/lightning-npm.ts","../src/plugins/lwc-bridge.ts","../src/plugins/lwc-wrapper.ts","../src/plugins/missing-css.ts","../src/plugins/scoped-providers.ts","../src/plugins/proxy.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { DirConfig, DiscoveredModule } from \"./types\";\n\nexport function discoverModules(dirs: (string | DirConfig)[] = []): DiscoveredModule[] {\n\tconst modules: DiscoveredModule[] = [];\n\n\tfor (const dir of dirs) {\n\t\tconst dirPath = typeof dir === \"string\" ? dir : dir.path;\n\t\tconst namespace = typeof dir === \"string\" ? undefined : dir.namespace;\n\t\tconst resolvedDir = path.resolve(dirPath);\n\n\t\tif (!existsSync(resolvedDir) || !statSync(resolvedDir).isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (namespace) {\n\t\t\t// Flat DX structure: <dir>/<componentName>/<componentName>.js\n\t\t\tfor (const name of readdirSync(resolvedDir)) {\n\t\t\t\tconst fullPath = path.join(resolvedDir, name);\n\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\tmodules.push({\n\t\t\t\t\t\tname: `${namespace}/${name}`,\n\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Standard structure: <dir>/<namespace>/<componentName>/<componentName>.js\n\t\t\tfor (const ns of readdirSync(resolvedDir)) {\n\t\t\t\tconst nsDir = path.join(resolvedDir, ns);\n\t\t\t\tif (!statSync(nsDir).isDirectory()) continue;\n\n\t\t\t\tfor (const name of readdirSync(nsDir)) {\n\t\t\t\t\tconst fullPath = path.join(nsDir, name);\n\t\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\t\tmodules.push({\n\t\t\t\t\t\t\tname: `${ns}/${name}`,\n\t\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modules;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport type { LightningNpmOptions } from \"../types\";\n\nfunction resolveJsFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.js`);\n\tif (existsSync(nested)) return nested;\n\tconst flat = path.join(root, `${sub}.js`);\n\tif (existsSync(flat)) return flat;\n\treturn null;\n}\n\nfunction resolveCssFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.css`);\n\treturn existsSync(nested) ? nested : null;\n}\n\nexport function lightningNpm({ npmRoot, overrideDirs = [] }: LightningNpmOptions): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-resolve-lightning-npm\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(importee) {\n\t\t\tif (!importee.startsWith(\"lightning/\")) return null;\n\n\t\t\tconst sub = importee.slice(\"lightning/\".length);\n\t\t\tconst segments = sub.split(\"/\");\n\t\t\tconst leaf = segments[segments.length - 1];\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst overridePath = path.join(dir, ...segments, `${leaf}.js`);\n\t\t\t\tif (existsSync(overridePath)) return null;\n\t\t\t}\n\n\t\t\tconst npmJs = resolveJsFromRoot(npmRoot, sub);\n\t\t\tif (npmJs) return npmJs;\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst cssFallback = path.join(dir, ...segments, `${leaf}.css`);\n\t\t\t\tif (existsSync(cssFallback)) return cssFallback;\n\t\t\t}\n\n\t\t\treturn resolveCssFromRoot(npmRoot, sub);\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\n\nexport function lwcBridge(isComponentAsset: (id: string) => boolean): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-bridge\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config: ResolvedConfig) {\n\t\t\tfor (const plugin of config.plugins) {\n\t\t\t\tif (plugin.name === \"vite:css\" || plugin.name === \"vite:css-post\") {\n\t\t\t\t\tconst p = plugin as unknown as Record<string, unknown>;\n\t\t\t\t\tconst origTransform = p[\"transform\"];\n\t\t\t\t\tif (!origTransform) continue;\n\n\t\t\t\t\tif (typeof origTransform === \"function\") {\n\t\t\t\t\t\t// Vite <7: transform is a plain function\n\t\t\t\t\t\tp[\"transform\"] = function (\n\t\t\t\t\t\t\tthis: unknown,\n\t\t\t\t\t\t\tcode: string,\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\t...rest: unknown[]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\treturn (origTransform as (...a: unknown[]) => unknown).call(this, code, id, ...rest);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof origTransform === \"object\" &&\n\t\t\t\t\t\ttypeof (origTransform as Record<string, unknown>)[\"handler\"] === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Vite 7+: transform is { handler, order? }\n\t\t\t\t\t\tconst origHandler = (origTransform as Record<string, unknown>)[\"handler\"] as (\n\t\t\t\t\t\t\t...a: unknown[]\n\t\t\t\t\t\t) => unknown;\n\t\t\t\t\t\tp[\"transform\"] = {\n\t\t\t\t\t\t\t...(origTransform as object),\n\t\t\t\t\t\t\thandler: function (this: unknown, code: string, id: string, ...rest: unknown[]) {\n\t\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\t\treturn origHandler.call(this, code, id, ...rest);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tresolveId(id, importer) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tconst cleanId = id.split(\"?\", 2)[0] ?? id;\n\n\t\t\tif (cleanId.endsWith(\".html\") && isComponentAsset(cleanId) && !id.includes(\"?lwc\")) {\n\t\t\t\treturn `${cleanId}?lwc`;\n\t\t\t}\n\n\t\t\tif (!importer) return null;\n\t\t\tif (!cleanId.endsWith(\".html\")) return null;\n\t\t\tif (!cleanId.startsWith(\"./\") && !cleanId.startsWith(\"../\")) return null;\n\t\t\tif (!isComponentAsset(importer)) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importer.split(\"?\")[0] ?? importer), cleanId);\n\n\t\t\tif (existsSync(resolved)) {\n\t\t\t\treturn resolved + \"?lwc\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn \"export default undefined;\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\ntype AnyFn = (this: unknown, ...args: unknown[]) => unknown;\ntype LwcRollupFactory = (options: Record<string, unknown>) => Plugin;\ntype LazyLwcRollupLoader = () => Promise<LwcRollupFactory>;\n\nexport function lwcWrapper(\n\tlazyLoader: LazyLwcRollupLoader,\n\toptions: Record<string, unknown>,\n\tisComponentAsset?: (id: string) => boolean,\n): Plugin {\n\tlet pluginPromise: Promise<Plugin> | null = null;\n\n\tconst getPlugin = () => {\n\t\tif (!pluginPromise) {\n\t\t\tpluginPromise = lazyLoader().then((factory) => factory(options));\n\t\t}\n\t\treturn pluginPromise;\n\t};\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-wrapper\",\n\t\tenforce: \"pre\" as const,\n\t\tasync resolveId(importee: string, importer?: string) {\n\t\t\tif (importer?.split(\"?\")[0]?.endsWith(\"index.html\") && !importer.includes(\"html-proxy\"))\n\t\t\t\treturn null;\n\t\t\tif (importee.startsWith(\"/@\") || importee.startsWith(\"\\0\")) return null;\n\t\t\tif (importer?.includes(\"/node_modules/vite/\")) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.resolveId === \"function\"\n\t\t\t\t? (plugin.resolveId as AnyFn).call(this, importee, importer)\n\t\t\t\t: null;\n\t\t},\n\t\tasync load(id: string) {\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.load === \"function\" ? (plugin.load as AnyFn).call(this, id) : null;\n\t\t},\n\t\tasync transform(code: string, id: string) {\n\t\t\t// Only pass files to the LWC compiler if they are LWC component assets.\n\t\t\t// Non-component files (SDK sources, node_modules, etc.) must be skipped.\n\t\t\tif (isComponentAsset && !isComponentAsset(id)) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.transform === \"function\"\n\t\t\t\t? (plugin.transform as AnyFn).call(this, code, id)\n\t\t\t\t: null;\n\t\t},\n\t} as Plugin;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst LWC_EMPTY_CSS = \"\\0lwc-empty-css\";\n\nexport function missingCss(): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-missing-css\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\tif (!importer || !id.startsWith(\"./\") || !id.includes(\".css\")) return null;\n\t\t\tconst importerPath = importer.split(\"?\")[0] ?? importer;\n\t\t\tif (!importerPath.endsWith(\".html\")) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importerPath), id.split(\"?\")[0] ?? id);\n\t\t\tif (existsSync(resolved)) return null;\n\n\t\t\treturn `${LWC_EMPTY_CSS}?${id}`;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(LWC_EMPTY_CSS)) {\n\t\t\t\treturn \"export default undefined\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\nimport type { Provider, ScopedProvidersOptions } from \"../types\";\n\nconst VIRTUAL_PREFIX = \"\\0sf-provider:\";\n\nexport function scopedProviders(\n\tproviders: Provider[] = [],\n\toptions: ScopedProvidersOptions = {},\n): Plugin {\n\tconst { ignorePatterns = [], interceptPrefixes = [], passthroughRules = [] } = options;\n\n\tconst prefixSet = new Set<string>();\n\tfor (const p of providers) {\n\t\tif (p.prefix) prefixSet.add(p.prefix);\n\t}\n\n\tfunction shouldIntercept(id: string): boolean {\n\t\tfor (const prefix of prefixSet) {\n\t\t\tif (id === prefix || id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const prefix of interceptPrefixes) {\n\t\t\tif (id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const p of providers) {\n\t\t\tif (!p.prefix && typeof p.match === \"function\" && p.match(id)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-scoped-module-providers\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\t// Explicit provider prefix always wins over ignorePatterns —\n\t\t\t// if a provider is registered for a specifier, it always handles it.\n\t\t\tconst handledByProvider = [...prefixSet].some((p) => id === p || id.startsWith(p + \"/\"));\n\n\t\t\tif (!handledByProvider) {\n\t\t\t\tif (!shouldIntercept(id)) return null;\n\n\t\t\t\tfor (const pattern of ignorePatterns) {\n\t\t\t\t\tif (id.startsWith(pattern)) return null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const rule of passthroughRules) {\n\t\t\t\tif (\n\t\t\t\t\timporter &&\n\t\t\t\t\tid.startsWith(rule.specifierPrefix) &&\n\t\t\t\t\timporter.includes(rule.importerPattern)\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn VIRTUAL_PREFIX + id;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(VIRTUAL_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(VIRTUAL_PREFIX.length);\n\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst result = provider.resolve(specifier);\n\t\t\t\tif (result != null) return result;\n\t\t\t}\n\n\t\t\tconsole.warn(\n\t\t\t\t`[scoped-module-providers] Unhandled import: ${specifier} — returning undefined`,\n\t\t\t);\n\t\t\treturn `export default undefined;`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport type { Plugin } from \"vite\";\n\nexport interface LwcProxyOptions {\n\t/** Salesforce org alias (defaults to the sf CLI default org) */\n\torgAlias?: string;\n\t/** Enable verbose request logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that proxies Salesforce API calls to a connected org.\n *\n * Uses the same authentication approach as @salesforce/vite-plugin-ui-bundle —\n * reads credentials from the sf CLI via @salesforce/ui-bundle/app.\n *\n * Intercepts requests to /services/ and /lwr/ and forwards them to Salesforce\n * with the org's access token. Handles token refresh on 401/403 responses.\n *\n * Usage in vite.config.js:\n * import { lwcProxy } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [lwcVitePlugin(...), lwcProxy()]\n *\n * Then initialise the SDK in your app's bootstrap:\n * import { createDataSDK } from '@salesforce/platform-sdk-data';\n * globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: '/' } });\n */\nexport function lwcProxy(options: LwcProxyOptions = {}): Plugin {\n\tlet instanceUrl: string | undefined;\n\tlet accessToken: string | undefined;\n\tconst orgAlias: string | undefined = options.orgAlias;\n\n\tasync function loadOrgInfo(): Promise<void> {\n\t\ttry {\n\t\t\t// Dynamically import to avoid bundling @salesforce/ui-bundle at build time\n\t\t\tconst { getOrgInfo } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await getOrgInfo(orgAlias);\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.log(`[lwc-proxy] Connected to ${instanceUrl}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.error(\n\t\t\t\t`[lwc-proxy] Failed to load org info — is a Salesforce org connected?\\n ${msg}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync function refreshToken(): Promise<void> {\n\t\ttry {\n\t\t\tconst { refreshOrgAuth } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await refreshOrgAuth(orgAlias ?? \"\");\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore refresh errors\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-proxy\",\n\t\tenforce: \"pre\",\n\n\t\tasync configResolved() {\n\t\t\tawait loadOrgInfo();\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.middlewares.use(async (req, res, next) => {\n\t\t\t\tconst url = req.url ?? \"\";\n\n\t\t\t\t// Only proxy Salesforce API paths\n\t\t\t\tif (!url.startsWith(\"/services/\") && !url.startsWith(\"/lwr/\")) {\n\t\t\t\t\treturn next();\n\t\t\t\t}\n\n\t\t\t\tif (!instanceUrl || !accessToken) {\n\t\t\t\t\tres.writeHead(503, { \"Content-Type\": \"application/json\" });\n\t\t\t\t\tres.end(\n\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\terror: \"SERVICE_UNAVAILABLE\",\n\t\t\t\t\t\t\tmessage: \"Salesforce org not connected. Run: sf org display\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst forward = async (token: string): Promise<void> => {\n\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\tconst targetUrl = new URL(url, instanceUrl);\n\t\t\t\t\t\tconst isHttps = targetUrl.protocol === \"https:\";\n\t\t\t\t\t\tconst transport = isHttps ? https : http;\n\n\t\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\t\tconsole.log(`[lwc-proxy] ${req.method} ${url}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip hop-by-hop headers\n\t\t\t\t\t\tconst headers: Record<string, string | string[]> = {};\n\t\t\t\t\t\tfor (const [key, value] of Object.entries(req.headers)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t![\n\t\t\t\t\t\t\t\t\t\"host\",\n\t\t\t\t\t\t\t\t\t\"connection\",\n\t\t\t\t\t\t\t\t\t\"keep-alive\",\n\t\t\t\t\t\t\t\t\t\"proxy-authenticate\",\n\t\t\t\t\t\t\t\t\t\"proxy-authorization\",\n\t\t\t\t\t\t\t\t\t\"te\",\n\t\t\t\t\t\t\t\t\t\"trailers\",\n\t\t\t\t\t\t\t\t\t\"transfer-encoding\",\n\t\t\t\t\t\t\t\t\t\"upgrade\",\n\t\t\t\t\t\t\t\t].includes(key.toLowerCase()) &&\n\t\t\t\t\t\t\t\tvalue !== undefined\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\theaders[key] = value as string | string[];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\theaders[\"host\"] = targetUrl.host;\n\t\t\t\t\t\theaders[\"authorization\"] = `Bearer ${token}`;\n\t\t\t\t\t\theaders[\"cookie\"] = `sid=${token}`;\n\n\t\t\t\t\t\tconst proxyReq = transport.request(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\t\t\thostname: targetUrl.hostname,\n\t\t\t\t\t\t\t\tport: targetUrl.port || (isHttps ? 443 : 80),\n\t\t\t\t\t\t\t\tpath: targetUrl.pathname + targetUrl.search,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(proxyRes) => {\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\tres.writeHead(proxyRes.statusCode ?? 200, proxyRes.headers);\n\t\t\t\t\t\t\t\tproxyRes.pipe(res);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treq.pipe(proxyReq);\n\t\t\t\t\t\tproxyReq.on(\"error\", reject);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\tawait forward(accessToken!);\n\n\t\t\t\t\t// On 401/403, refresh token and retry once\n\t\t\t\t\t// Note: we can't easily check status here since we piped to res,\n\t\t\t\t\t// so we rely on the transform hook below for retries in future iterations\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.error(\"[lwc-proxy] Request failed:\", error);\n\t\t\t\t\t}\n\t\t\t\t\t// Try refreshing token and retry\n\t\t\t\t\tawait refreshToken();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait forward(accessToken!);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tnext(err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { discoverModules } from \"./discovery\";\nimport { lightningNpm } from \"./plugins/lightning-npm\";\nimport { lwcBridge } from \"./plugins/lwc-bridge\";\nimport { lwcWrapper } from \"./plugins/lwc-wrapper\";\nimport { missingCss } from \"./plugins/missing-css\";\nimport { scopedProviders } from \"./plugins/scoped-providers\";\nimport * as builtinProviders from \"./providers/index\";\nimport type { DirConfig, LwcVitePluginOptions, NpmModuleConfig, Provider } from \"./types\";\n\nexport type {\n\tProvider,\n\tLwcVitePluginOptions,\n\tPassthroughRule,\n\tDiscoveredModule,\n\tDirConfig,\n} from \"./types\";\nexport { builtinProviders as builtins };\nexport { discoverModules } from \"./discovery\";\nexport { lwcProxy } from \"./plugins/proxy\";\nexport type { LwcProxyOptions } from \"./plugins/proxy\";\n\nfunction defaultProviders(): (Provider | Plugin)[] {\n\treturn [\n\t\tbuiltinProviders.label(),\n\t\tbuiltinProviders.i18n(),\n\t\tbuiltinProviders.accessCheck(),\n\t\tbuiltinProviders.client(),\n\t\tbuiltinProviders.gate(),\n\t\tbuiltinProviders.primitiveUtils(),\n\t\tbuiltinProviders.lds(),\n\t];\n}\n\n/** Distinguishes a scoped-providers `Provider` from a raw Vite `Plugin`. */\nfunction isProvider(item: Provider | Plugin): item is Provider {\n\treturn typeof (item as Provider).resolve === \"function\";\n}\n\nasync function loadLwcRollup() {\n\ttry {\n\t\t// Use dynamic import to load ESM-only @lwc/rollup-plugin (peer dep, types not guaranteed)\n\t\tconst mod = await (import(\"@lwc/rollup-plugin\") as Promise<Record<string, unknown>>);\n\t\treturn (mod[\"default\"] ?? mod) as unknown as (options: Record<string, unknown>) => Plugin;\n\t} catch (error) {\n\t\tconst errMsg = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle requires @lwc/rollup-plugin as a peer dependency. \" +\n\t\t\t\t\"Install it with: npm install -D @lwc/rollup-plugin\\n\" +\n\t\t\t\t`Debug: cwd=${process.cwd()}, error=${errMsg}`,\n\t\t);\n\t}\n}\n\nexport default function lwcVitePlugin(options: LwcVitePluginOptions = {}): Plugin[] {\n\tconst {\n\t\tmodules = {},\n\t\tproviders,\n\t\tstubs = {},\n\t\tlwcOptions = {},\n\t\tignorePatterns = [\n\t\t\t// Legacy @salesforce/sdk-* prefix — kept for external consumers still on the\n\t\t\t// pre-rename package names. Internal packages are all @salesforce/platform-sdk-*.\n\t\t\t\"@salesforce/sdk-\",\n\t\t\t\"@salesforce/platform-sdk-\",\n\t\t\t\"@salesforce/core\",\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle\",\n\t\t],\n\t\tpassthroughRules = [],\n\t} = options;\n\n\tconst resolvedItems = providers ?? defaultProviders();\n\tconst resolvedProviders = resolvedItems.filter(isProvider);\n\tconst rawPlugins = resolvedItems.filter((item): item is Plugin => !isProvider(item));\n\n\tconst { dirs = [], npm: npmPackages = [] } = modules;\n\n\tconst resolvedDirs: DirConfig[] = dirs.map((d) =>\n\t\ttypeof d === \"string\"\n\t\t\t? { path: path.resolve(d), namespace: \"\" }\n\t\t\t: { ...d, path: path.resolve(d.path) },\n\t);\n\n\tconst npmConfigs: NpmModuleConfig[] = npmPackages.map((pkg) =>\n\t\ttypeof pkg === \"string\" ? { npm: pkg } : pkg,\n\t);\n\n\tconst require = createRequire(import.meta.url);\n\tconst npmRoots = npmConfigs.map((cfg) => {\n\t\tconst pkgJson = require.resolve(`${cfg.npm}/package.json`);\n\t\treturn path.join(path.dirname(pkgJson), \"src\", \"lightning\");\n\t});\n\n\tconst discoveredModules = discoverModules(dirs);\n\n\tconst lwcModules = [...npmConfigs, ...discoveredModules];\n\n\tconst lightningOverrideDirs = resolvedDirs.map((d) => path.join(d.path, \"lightning\"));\n\n\tfunction isComponentAsset(id: string): boolean {\n\t\tconst clean = id.split(\"?\")[0] ?? id;\n\t\tfor (const dir of resolvedDirs) {\n\t\t\tif (clean.includes(dir.path)) return true;\n\t\t}\n\t\tfor (const cfg of npmConfigs) {\n\t\t\tif (clean.includes(cfg.npm)) return true;\n\t\t}\n\t\treturn clean.includes(\"@lwc/\") || clean.startsWith(\"\\0lwc-empty-css\");\n\t}\n\n\tconst stubAliases: Record<string, string> = {};\n\tfor (const [specifier, stubPath] of Object.entries(stubs)) {\n\t\tstubAliases[specifier] = path.resolve(stubPath);\n\t}\n\n\tconst interceptPrefixes = new Set<string>();\n\tfor (const p of resolvedProviders) {\n\t\tif (p.prefix && p.prefix.startsWith(\"@\")) {\n\t\t\tinterceptPrefixes.add(p.prefix.split(\"/\")[0] + \"/\");\n\t\t}\n\t}\n\n\tconst plugins: Plugin[] = [\n\t\t{\n\t\t\tname: \"vite-plugin-lwc-optimize-deps\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\texclude: [\"lwc\"],\n\t\t\t\t\t\tesbuildOptions: {\n\t\t\t\t\t\t\tplugins: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"lwc-html-stub\",\n\t\t\t\t\t\t\t\t\tsetup(build: {\n\t\t\t\t\t\t\t\t\t\tonResolve: (\n\t\t\t\t\t\t\t\t\t\t\toptions: { filter: RegExp },\n\t\t\t\t\t\t\t\t\t\t\tcallback: (args: { path: string }) => {\n\t\t\t\t\t\t\t\t\t\t\t\tpath: string;\n\t\t\t\t\t\t\t\t\t\t\t\texternal: boolean;\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t) => void;\n\t\t\t\t\t\t\t\t\t}) {\n\t\t\t\t\t\t\t\t\t\t// esbuild cannot process LWC HTML templates (?lwc suffix).\n\t\t\t\t\t\t\t\t\t\t// Mark them as external so Vite's own plugin handles them.\n\t\t\t\t\t\t\t\t\t\tbuild.onResolve({ filter: /\\.html/ }, (args: { path: string }) => ({\n\t\t\t\t\t\t\t\t\t\t\tpath: args.path,\n\t\t\t\t\t\t\t\t\t\t\texternal: true,\n\t\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t// plugins returned by plugin-style builtins (e.g. lds())\n\t\t...rawPlugins,\n\t\tscopedProviders(resolvedProviders, {\n\t\t\tignorePatterns,\n\t\t\tinterceptPrefixes: [...interceptPrefixes],\n\t\t\tpassthroughRules,\n\t\t}),\n\n\t\t...npmRoots.map((npmRoot) =>\n\t\t\tlightningNpm({\n\t\t\t\tnpmRoot,\n\t\t\t\toverrideDirs: lightningOverrideDirs,\n\t\t\t}),\n\t\t),\n\n\t\tmissingCss(),\n\t\tlwcBridge(isComponentAsset),\n\t\tlwcWrapper(\n\t\t\tloadLwcRollup,\n\t\t\t{\n\t\t\t\trootDir: process.cwd(),\n\t\t\t\t...lwcOptions,\n\t\t\t\tmodules: lwcModules,\n\t\t\t\texclude: [\n\t\t\t\t\t\"**/index.html\",\n\t\t\t\t\t\"**/node_modules/vite/**\",\n\t\t\t\t\t\"**/node_modules/.vite/**\",\n\t\t\t\t\t...((lwcOptions.exclude as string[]) || []),\n\t\t\t\t],\n\t\t\t},\n\t\t\tisComponentAsset,\n\t\t),\n\t];\n\n\tif (Object.keys(stubAliases).length > 0) {\n\t\tplugins.push({\n\t\t\tname: \"vite-plugin-lwc-stubs\",\n\t\t\tenforce: \"pre\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\tresolve: {\n\t\t\t\t\t\talias: stubAliases,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t}\n\n\treturn plugins;\n}\n"],"names":["builtinProviders.label","builtinProviders.i18n","builtinProviders.accessCheck","builtinProviders.client","builtinProviders.gate","builtinProviders.primitiveUtils","builtinProviders.lds","require"],"mappings":";;;;;;;;AASO,SAAS,gBAAgB,OAA+B,IAAwB;AACtF,QAAM,UAA8B,CAAA;AAEpC,aAAW,OAAO,MAAM;AACvB,UAAM,UAAU,OAAO,QAAQ,WAAW,MAAM,IAAI;AACpD,UAAM,YAAY,OAAO,QAAQ,WAAW,SAAY,IAAI;AAC5D,UAAM,cAAc,KAAK,QAAQ,OAAO;AAExC,QAAI,CAAC,WAAW,WAAW,KAAK,CAAC,SAAS,WAAW,EAAE,eAAe;AACrE;AAAA,IACD;AAEA,QAAI,WAAW;AAEd,iBAAW,QAAQ,YAAY,WAAW,GAAG;AAC5C,cAAM,WAAW,KAAK,KAAK,aAAa,IAAI;AAC5C,YAAI,CAAC,SAAS,QAAQ,EAAE,cAAe;AAEvC,cAAM,YAAY,KAAK,KAAK,UAAU,GAAG,IAAI,KAAK;AAClD,YAAI,WAAW,SAAS,GAAG;AAC1B,kBAAQ,KAAK;AAAA,YACZ,MAAM,GAAG,SAAS,IAAI,IAAI;AAAA,YAC1B,MAAM,KAAK,QAAQ,SAAS;AAAA,UAAA,CAC5B;AAAA,QACF;AAAA,MACD;AAAA,IAC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S;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,UACA,GAAK,WAAW,WAAwB,CAAA;AAAA,QAAC;AAAA,MAC1C;AAAA,MAED;AAAA,IAAA;AAAA,EACD;AAGD,MAAI,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACxC,YAAQ,KAAK;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AACR,eAAO;AAAA,UACN,SAAS;AAAA,YACR,OAAO;AAAA,UAAA;AAAA,QACR;AAAA,MAEF;AAAA,IAAA,CACA;AAAA,EACF;AAEA,SAAO;AACR;"}
@@ -19,7 +19,7 @@ export interface LwcProxyOptions {
19
19
  * plugins: [lwcVitePlugin(...), lwcProxy()]
20
20
  *
21
21
  * Then initialise the SDK in your app's bootstrap:
22
- * import { createDataSDK } from '@salesforce/sdk-data';
22
+ * import { createDataSDK } from '@salesforce/platform-sdk-data';
23
23
  * globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: '/' } });
24
24
  */
25
25
  export declare function lwcProxy(options?: LwcProxyOptions): Plugin;
@@ -1,11 +1,35 @@
1
1
  import { JSONSchema } from '@conduit-client/jsonschema-validate';
2
2
  import { Plugin } from 'vite';
3
3
  import { ReadInvokerShape } from './types';
4
- export interface LdsWireAdapterConfig {
5
- type: "wire";
4
+ /**
5
+ * MCP dispatch descriptor. Nested under `mcp` on every adapter config so
6
+ * additional MCP-specific fields (auth, transport, retry policy) can join
7
+ * later without reshaping every consumer entry.
8
+ */
9
+ export interface LdsAdapterMcpDispatch {
6
10
  toolName: string;
11
+ }
12
+ /**
13
+ * Base shape every LDS adapter config extends. Holds the dispatch surface in
14
+ * one place so new backings (e.g. `http`) can land as sibling optional fields
15
+ * without forking each adapter interface. Dual registration is supported at
16
+ * the type level — runtime execution still targets a single backing per call.
17
+ */
18
+ export interface LdsAdapterConfigBase {
19
+ mcp?: LdsAdapterMcpDispatch;
20
+ }
21
+ /**
22
+ * LDS adapter configs whose input is validated against a JSON Schema at
23
+ * invoke time — wire, imperative-mutation, imperative-read. GraphQL variants
24
+ * skip this base because they pass `{ query, variables }` through to the
25
+ * configured MCP tool with no schema check.
26
+ */
27
+ export interface LdsSchemaValidatedAdapterConfig extends LdsAdapterConfigBase {
7
28
  configJsonSchema: JSONSchema;
8
29
  }
30
+ export interface LdsWireAdapterConfig extends LdsSchemaValidatedAdapterConfig {
31
+ type: "wire";
32
+ }
9
33
  /**
10
34
  * Imperative **mutation** adapter. Always an async
11
35
  * `(config) => Promise<Data>` that throws on validation or tool error —
@@ -14,10 +38,8 @@ export interface LdsWireAdapterConfig {
14
38
  * `subscribe`/`refresh` make no sense on write, and allowing them here
15
39
  * would drift off-platform from on-platform semantics.
16
40
  */
17
- export interface LdsImperativeMutationAdapterConfig {
41
+ export interface LdsImperativeMutationAdapterConfig extends LdsSchemaValidatedAdapterConfig {
18
42
  type: "imperative-mutation";
19
- toolName: string;
20
- configJsonSchema: JSONSchema;
21
43
  }
22
44
  /**
23
45
  * Public alias for the read-shape union defined in `runtime.ts`. Re-exported
@@ -30,29 +52,25 @@ export interface LdsImperativeMutationAdapterConfig {
30
52
  * surface for code ported verbatim.
31
53
  */
32
54
  export type LdsImperativeReadInvokerShape = ReadInvokerShape;
33
- export interface LdsImperativeReadAdapterConfig {
55
+ export interface LdsImperativeReadAdapterConfig extends LdsSchemaValidatedAdapterConfig {
34
56
  type: "imperative-read";
35
57
  invokerShape: LdsImperativeReadInvokerShape;
36
- toolName: string;
37
- configJsonSchema: JSONSchema;
38
58
  }
39
59
  /**
40
60
  * GraphQL wire adapter. Emits `{ data, errors, refresh }` (distinct from the
41
61
  * base wire `{ data, error }`). No `configJsonSchema` — the adapter passes
42
62
  * `{ query, variables }` through to the configured MCP tool.
43
63
  */
44
- export interface LdsGraphqlWireAdapterConfig {
64
+ export interface LdsGraphqlWireAdapterConfig extends LdsAdapterConfigBase {
45
65
  type: "graphql-wire";
46
- toolName: string;
47
66
  }
48
67
  /**
49
68
  * Imperative GraphQL mutation — `(config) => Promise<{ data, errors }>`.
50
69
  * Errors are routed in-band to the `errors[]` envelope rather than thrown,
51
70
  * matching on-platform `toGraphQLResponseFromFailure`.
52
71
  */
53
- export interface LdsGraphqlMutationAdapterConfig {
72
+ export interface LdsGraphqlMutationAdapterConfig extends LdsAdapterConfigBase {
54
73
  type: "graphql-mutation";
55
- toolName: string;
56
74
  }
57
75
  /**
58
76
  * Read-shape discriminator for imperative GraphQL adapters. Mirrors the
@@ -76,10 +94,9 @@ export type LdsGraphqlImperativeReadInvokerShape = "query" | "query-refreshable"
76
94
  * routed in-band to `errors[]` (for `query`/`query-refreshable`) or into the
77
95
  * callback payload (for `legacy`); no shape throws on tool errors.
78
96
  */
79
- export interface LdsGraphqlImperativeReadAdapterConfig {
97
+ export interface LdsGraphqlImperativeReadAdapterConfig extends LdsAdapterConfigBase {
80
98
  type: "graphql-imperative-read";
81
99
  invokerShape: LdsGraphqlImperativeReadInvokerShape;
82
- toolName: string;
83
100
  }
84
101
  export type LdsAdapterConfig = LdsWireAdapterConfig | LdsImperativeMutationAdapterConfig | LdsImperativeReadAdapterConfig | LdsGraphqlWireAdapterConfig | LdsGraphqlMutationAdapterConfig | LdsGraphqlImperativeReadAdapterConfig;
85
102
  export type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAuChD,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,UAAU,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,MAAM,W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oB,GACpB,kCAAkC,GAClC,8BAA8B,GAC9B,2BAA2B,GAC3B,+BAA+B,GAC/B,qCAAqC,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;AA4KlF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,GAAG,CAAC,SAAS,GAAE,kBAAuB,GAAG,MAAM,CA+G9D"}
@@ -15,7 +15,7 @@ const DEFAULT_ADAPTERS = {
15
15
  "lightning/uiRecordApi": {
16
16
  getRecord: {
17
17
  type: "wire",
18
- toolName: "getRecordMcpTool",
18
+ mcp: { toolName: "getRecordMcpTool" },
19
19
  configJsonSchema: {
20
20
  type: "object",
21
21
  properties: {
@@ -55,7 +55,7 @@ const DEFAULT_ADAPTERS = {
55
55
  },
56
56
  createRecord: {
57
57
  type: "imperative-mutation",
58
- toolName: "createRecordMcpTool",
58
+ mcp: { toolName: "createRecordMcpTool" },
59
59
  configJsonSchema: {
60
60
  type: "object",
61
61
  properties: {
@@ -73,7 +73,7 @@ const DEFAULT_ADAPTERS = {
73
73
  },
74
74
  updateRecord: {
75
75
  type: "imperative-mutation",
76
- toolName: "updateRecordMcpTool",
76
+ mcp: { toolName: "updateRecordMcpTool" },
77
77
  configJsonSchema: {
78
78
  type: "object",
79
79
  properties: {
@@ -97,7 +97,7 @@ const DEFAULT_ADAPTERS = {
97
97
  getObjectInfo_imperative: {
98
98
  type: "imperative-read",
99
99
  invokerShape: "legacy",
100
- toolName: "getObjectInfoMcpTool",
100
+ mcp: { toolName: "getObjectInfoMcpTool" },
101
101
  configJsonSchema: {
102
102
  type: "object",
103
103
  properties: {
@@ -113,8 +113,8 @@ const DEFAULT_ADAPTERS = {
113
113
  // are registry entries; `gql` rides along automatically for any specifier
114
114
  // that has at least one graphql-typed entry (emitted by the load hook).
115
115
  "lightning/graphql": {
116
- graphql: { type: "graphql-wire", toolName: "graphqlQuery" },
117
- executeMutation: { type: "graphql-mutation", toolName: "graphqlQuery" }
116
+ graphql: { type: "graphql-wire", mcp: { toolName: "graphqlQuery" } },
117
+ executeMutation: { type: "graphql-mutation", mcp: { toolName: "graphqlQuery" } }
118
118
  }
119
119
  };
120
120
  function isGraphqlSpecifier(moduleAdapters) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/providers/lds/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { JSONSchema } from \"@conduit-client/jsonschema-validate\";\nimport { init, parse } from \"es-module-lexer\";\nimport MagicString from \"magic-string\";\nimport type { Plugin } from \"vite\";\nimport type { ReadInvokerShape } from \"./types\";\n\n// prefix to write into transformed source code\nconst ADAPTER_PREFIX = \"sf-lds-adapter:\";\n// prefix used to ID the adapter when loading the virtual module\nconst ADAPTER_ID_PREFIX = \"\\0\" + ADAPTER_PREFIX;\n\n// the source of the adapter base module — reused across virtual modules so\n// each generated specifier emits the factories once.\n//\n// Top-level exports from the runtime module are stripped so every factory and\n// `gql` becomes a private binding inside the virtual module. The load hook\n// then controls exactly which names are exported per specifier: adapter\n// entries from the registry, plus `gql` for graphql specifiers. Without this,\n// the built `runtime.js` (trailing `export { …, gql, createWireAdapter, … }`)\n// and the source `runtime.ts` (per-declaration `export function gql …`) both\n// produce a `SyntaxError: Duplicate export of 'gql'` when the load hook also\n// appends `export { gql };`. They also leak the factory names as exports on\n// every LDS virtual module, which isn't a public contract we want.\nconst adapterBaseSource = stripTopLevelExports(\n\treadFileSync(join(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"), \"utf-8\"),\n);\n\n/**\n * Removes top-level ES-module `export` keywords from the embedded runtime\n * source so its declarations survive as private bindings inside the virtual\n * module. Handles two shapes:\n * 1. Per-declaration: `export function foo …` / `export async function foo`\n * → the `export ` prefix is dropped.\n * 2. Trailing re-export clause: `export { foo, bar };` → deleted entirely.\n * Inner occurrences (inside function bodies, comments, strings) are not\n * affected because the source is a flat module with exports only at column 0.\n */\nfunction stripTopLevelExports(source: string): string {\n\treturn source\n\t\t.replace(/^export\\s+(?=(?:async\\s+)?function\\s)/gm, \"\")\n\t\t.replace(/^export\\s*\\{[^}]*};?\\s*$/gm, \"\");\n}\n\nexport interface LdsWireAdapterConfig {\n\ttype: \"wire\";\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\n/**\n * Imperative **mutation** adapter. Always an async\n * `(config) => Promise<Data>` that throws on validation or tool error —\n * matching OneStore's `DefaultImperativeBindingsService`, the only service a\n * mutation ever uses on platform. Mutations do not carry an `invokerShape`:\n * `subscribe`/`refresh` make no sense on write, and allowing them here\n * would drift off-platform from on-platform semantics.\n */\nexport interface LdsImperativeMutationAdapterConfig {\n\ttype: \"imperative-mutation\";\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\n/**\n * Public alias for the read-shape union defined in `runtime.ts`. Re-exported\n * from this module so consumers don't have to import from the runtime entry\n * point, while keeping the union pinned to one source of truth.\n *\n * Off-platform there is no store, so `subscribe` is a deliberate no-op\n * (callback never fires, returned unsubscribe is idempotent) and `refresh`\n * re-executes the underlying MCP tool. This preserves the OneStore API\n * surface for code ported verbatim.\n */\nexport type LdsImperativeReadInvokerShape = ReadInvokerShape;\n\nexport interface LdsImperativeReadAdapterConfig {\n\ttype: \"imperative-read\";\n\tinvokerShape: LdsImperativeReadInvokerShape;\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\n/**\n * GraphQL wire adapter. Emits `{ data, errors, refresh }` (distinct from the\n * base wire `{ data, error }`). No `configJsonSchema` — the adapter passes\n * `{ query, variables }` through to the configured MCP tool.\n */\nexport interface LdsGraphqlWireAdapterConfig {\n\ttype: \"graphql-wire\";\n\ttoolName: string;\n}\n\n/**\n * Imperative GraphQL mutation — `(config) => Promise<{ data, errors }>`.\n * Errors are routed in-band to the `errors[]` envelope rather than thrown,\n * matching on-platform `toGraphQLResponseFromFailure`.\n */\nexport interface LdsGraphqlMutationAdapterConfig {\n\ttype: \"graphql-mutation\";\n\ttoolName: string;\n}\n\n/**\n * Read-shape discriminator for imperative GraphQL adapters. Mirrors the\n * `imperative-read` `invokerShape` field so the two families share a pattern:\n * one `type` discriminator + a shape field that selects the return surface.\n *\n * - `query` — `Promise<{ data, errors, subscribe }>` (on-platform\n * `GraphQLImperativeBindingsService` without `exposeRefresh`).\n * - `query-refreshable` — `Promise<{ data, errors, subscribe, refresh }>`\n * (same service with `exposeRefresh: true`).\n * - `legacy` — `{ invoke(config, context, callback),\n * subscribe(config, context, callback): Unsubscribe }`, the older callback\n * surface served by `GraphQLLegacyImperativeBindingsService`.\n *\n * `subscribe` is a deliberate no-op off-platform (no reactive store).\n */\nexport type LdsGraphqlImperativeReadInvokerShape = \"query\" | \"query-refreshable\" | \"legacy\";\n\n/**\n * Imperative GraphQL read adapter. The `invokerShape` picks the return\n * surface — see {@link LdsGraphqlImperativeReadInvokerShape}. Errors are\n * routed in-band to `errors[]` (for `query`/`query-refreshable`) or into the\n * callback payload (for `legacy`); no shape throws on tool errors.\n */\nexport interface LdsGraphqlImperativeReadAdapterConfig {\n\ttype: \"graphql-imperative-read\";\n\tinvokerShape: LdsGraphqlImperativeReadInvokerShape;\n\ttoolName: string;\n}\n\nexport type LdsAdapterConfig =\n\t| LdsWireAdapterConfig\n\t| LdsImperativeMutationAdapterConfig\n\t| LdsImperativeReadAdapterConfig\n\t| LdsGraphqlWireAdapterConfig\n\t| LdsGraphqlMutationAdapterConfig\n\t| LdsGraphqlImperativeReadAdapterConfig;\n\nexport type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>>;\n\n/**\n * Default adapter registry.\n * Maps LDS module specifiers to MCP tool-backed implementations. Entries can be\n * wire adapters (`type: 'wire'`), imperative mutations (`type: 'imperative-mutation'`),\n * or imperative reads (`type: 'imperative-read'` + `invokerShape`).\n * Add entries here to support additional lightning/* exports.\n */\nconst DEFAULT_ADAPTERS: LdsAdapterRegistry = {\n\t\"lightning/uiRecordApi\": {\n\t\tgetRecord: {\n\t\t\ttype: \"wire\",\n\t\t\ttoolName: \"getRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tanyOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tfields: { type: \"array\", items: { type: \"string\" }, minItems: 1 },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"fields\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\t\t\ttype: \"array\",\n\t\t\t\t\t\t\t\titems: { type: \"string\" },\n\t\t\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"layoutTypes\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tcreateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\ttoolName: \"createRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tapiName: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"apiName\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t\tupdateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\ttoolName: \"updateRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t\"lightning/uiObjectInfoApi\": {\n\t\t// On-platform this is a `{ invoke, subscribe }` callback surface\n\t\t// emitting `{ data, error }`. The legacy invoker shape preserves that\n\t\t// contract verbatim, so ported consumers keep their call sites.\n\t\tgetObjectInfo_imperative: {\n\t\t\ttype: \"imperative-read\",\n\t\t\tinvokerShape: \"legacy\",\n\t\t\ttoolName: \"getObjectInfoMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tobjectApiName: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"objectApiName\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t// `lightning/graphql` — on-platform exports `gql`, the `graphql` wire\n\t// adapter, and `executeMutation`. Only `graphql` and `executeMutation`\n\t// are registry entries; `gql` rides along automatically for any specifier\n\t// that has at least one graphql-typed entry (emitted by the load hook).\n\t\"lightning/graphql\": {\n\t\tgraphql: { type: \"graphql-wire\", toolName: \"graphqlQuery\" },\n\t\texecuteMutation: { type: \"graphql-mutation\", toolName: \"graphqlQuery\" },\n\t},\n};\n\n/** True when any entry in a module's adapter map is a `graphql-*` type. */\nfunction isGraphqlSpecifier(moduleAdapters: Record<string, LdsAdapterConfig>): boolean {\n\treturn Object.values(moduleAdapters).some(\n\t\t(entry) =>\n\t\t\tentry.type === \"graphql-wire\" ||\n\t\t\tentry.type === \"graphql-mutation\" ||\n\t\t\tentry.type === \"graphql-imperative-read\",\n\t);\n}\n\n/** Maps a config discriminator to the factory name emitted in the virtual module. */\nfunction factoryFor(type: LdsAdapterConfig[\"type\"]): string {\n\tswitch (type) {\n\t\tcase \"wire\":\n\t\t\treturn \"createWireAdapter\";\n\t\tcase \"imperative-mutation\":\n\t\t\treturn \"createMutationAdapter\";\n\t\tcase \"imperative-read\":\n\t\t\treturn \"createReadAdapter\";\n\t\tcase \"graphql-wire\":\n\t\t\treturn \"createGraphQLWireAdapter\";\n\t\tcase \"graphql-mutation\":\n\t\t\treturn \"createGraphQLMutationAdapter\";\n\t\tcase \"graphql-imperative-read\":\n\t\t\treturn \"createGraphQLImperativeReadAdapter\";\n\t}\n}\n\nfunction parseImportSpecifiers(bracesContent: string): { original: string; full: string }[] {\n\treturn bracesContent\n\t\t.split(\",\")\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst asIdx = entry.indexOf(\" as \");\n\t\t\tconst original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();\n\t\t\treturn { original, full: entry };\n\t\t});\n}\n\n/**\n * Deep-merges user overrides onto the default registry: every specifier from\n * both sides is preserved, and per-specifier entries are merged so a consumer\n * can override `getRecord` without losing `createRecord`, or register a new\n * entry on `lightning/graphql` without losing `graphql` / `executeMutation`.\n * Pass an empty object to get just the defaults. To opt out of a default\n * entry, pass the same specifier with a different entry of the same key.\n */\nfunction mergeWithDefaults(overrides: LdsAdapterRegistry): LdsAdapterRegistry {\n\tconst merged: LdsAdapterRegistry = { ...DEFAULT_ADAPTERS };\n\tfor (const [specifier, entries] of Object.entries(overrides)) {\n\t\tmerged[specifier] = { ...(DEFAULT_ADAPTERS[specifier] ?? {}), ...entries };\n\t}\n\treturn merged;\n}\n\n/**\n * LDS provider — rewrites registered `lightning/*` imports (e.g.\n * `lightning/uiRecordApi`) to MCP-tool-backed virtual modules. Unregistered\n * exports pass through to the normal `lightning/*` resolution.\n *\n * Three Vite hooks do the work:\n *\n * - **`transform`** — parses each `.js` / `.ts` file with `es-module-lexer`,\n * finds named imports from registered specifiers, and rewrites them to pull\n * registered names from `sf-lds-adapter:<specifier>` while leaving\n * unregistered names pointing at the original specifier.\n *\n * - **`resolveId`** — maps `sf-lds-adapter:<specifier>` to a `\\0`-prefixed\n * virtual module ID, preventing Rollup from attempting a filesystem lookup.\n *\n * - **`load`** — generates the virtual module, emitting an MCP-backed\n * `createWireAdapter(...)` class for every `type: 'wire'` entry,\n * `createMutationAdapter(...)` for every `type: 'imperative-mutation'` entry,\n * and `createReadAdapter(...)` for every `type: 'imperative-read'` entry.\n *\n * Only specifiers present in the `adapters` registry are intercepted; imports from\n * unregistered specifiers pass through unchanged.\n */\nexport function lds(overrides: LdsAdapterRegistry = {}): Plugin {\n\tconst adapters = mergeWithDefaults(overrides);\n\t// Graphql specifiers are owned whole by the virtual module — every export\n\t// (adapters + `gql`) lives there, so the transform hook should not split\n\t// their imports. Non-graphql specifiers still go through transform so\n\t// unregistered names pass through to the real `lightning/*` module.\n\tconst graphqlSpecifiers = new Set<string>(\n\t\tObject.entries(adapters)\n\t\t\t.filter(([, moduleAdapters]) => isGraphqlSpecifier(moduleAdapters))\n\t\t\t.map(([specifier]) => specifier),\n\t);\n\tconst transformSpecifiers = Object.keys(adapters).filter((s) => !graphqlSpecifiers.has(s));\n\tconst specifierSnippets = transformSpecifiers.flatMap((s) => [`'${s}'`, `\"${s}\"`]);\n\n\treturn {\n\t\tname: \"vite-plugin-lds\",\n\t\tenforce: \"pre\",\n\n\t\tasync transform(code, id) {\n\t\t\tconst cleanId = id.split(\"?\")[0] ?? id;\n\t\t\tif (!cleanId.endsWith(\".js\") && !cleanId.endsWith(\".ts\")) return null;\n\t\t\tif (cleanId.includes(\"/node_modules/\")) return null;\n\t\t\tif (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;\n\n\t\t\tawait init;\n\n\t\t\tlet imports: ReturnType<typeof parse>[0];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code);\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst relevant = imports.filter(\n\t\t\t\t(imp) =>\n\t\t\t\t\timp.d === -1 && imp.n !== undefined && imp.n in adapters && !graphqlSpecifiers.has(imp.n),\n\t\t\t);\n\t\t\tif (relevant.length === 0) return null;\n\n\t\t\tconst s = new MagicString(code);\n\t\t\tlet changed = false;\n\n\t\t\tfor (const imp of relevant) {\n\t\t\t\tconst { ss: start, se: end, n: specifier } = imp;\n\t\t\t\tconst statement = code.slice(start, end);\n\n\t\t\t\tconst openBrace = statement.indexOf(\"{\");\n\t\t\t\tconst closeBrace = statement.indexOf(\"}\");\n\t\t\t\tif (openBrace === -1 || closeBrace === -1) continue;\n\n\t\t\t\tconst bracesContent = statement.slice(openBrace + 1, closeBrace);\n\t\t\t\tconst moduleAdapters = adapters[specifier!]!;\n\t\t\t\tconst parsedImport = parseImportSpecifiers(bracesContent);\n\t\t\t\tconst registered = parsedImport.filter((p) => p.original in moduleAdapters);\n\t\t\t\tconst unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));\n\n\t\t\t\tif (registered.length === 0) continue;\n\n\t\t\t\tconst parts: string[] = [\n\t\t\t\t\t`import { ${registered.map((p) => p.full).join(\", \")} } from '${ADAPTER_PREFIX}${specifier}';`,\n\t\t\t\t];\n\n\t\t\t\tif (unregistered.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`import { ${unregistered.map((p) => p.full).join(\", \")} } from '${specifier}';`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ts.overwrite(start, end, parts.join(\"\\n\"));\n\t\t\t\tchanged = true;\n\t\t\t}\n\n\t\t\tif (!changed) return null;\n\t\t\treturn { code: s.toString(), map: s.generateMap({ hires: true }) };\n\t\t},\n\n\t\tresolveId(id) {\n\t\t\t// Graphql specifiers are intercepted raw — no transform hook split\n\t\t\t// — and mapped into the same `\\0sf-lds-adapter:` virtual namespace\n\t\t\t// so the load hook emits one module per specifier.\n\t\t\tif (graphqlSpecifiers.has(id)) return ADAPTER_ID_PREFIX + id;\n\t\t\tif (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(ADAPTER_ID_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(ADAPTER_ID_PREFIX.length);\n\t\t\tconst moduleAdapters = adapters[specifier];\n\t\t\tif (!moduleAdapters) return null;\n\n\t\t\t// create lines of code used to create MCP tool based adapters\n\t\t\tconst lines: string[] = [adapterBaseSource];\n\t\t\tfor (const [name, entry] of Object.entries(moduleAdapters)) {\n\t\t\t\tconst { type, ...cfg } = entry;\n\t\t\t\tlines.push(\n\t\t\t\t\t`export const ${name} = ${factoryFor(type)}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// `gql` rides along with any specifier that declares a graphql\n\t\t\t// adapter, so `import { gql } from 'lightning/graphql'` (or any\n\t\t\t// aliased form) keeps resolving even when no adapters are\n\t\t\t// imported alongside it. The binding itself is a private function\n\t\t\t// inside `adapterBaseSource` after `stripTopLevelExports`.\n\t\t\tif (graphqlSpecifiers.has(specifier)) {\n\t\t\t\tlines.push(\"export { gql };\");\n\t\t\t}\n\t\t\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;AAAA,QAAA;AAAA,MAE5F;AAMA,UAAI,kBAAkB,IAAI,SAAS,GAAG;AACrC,cAAM,KAAK,iBAAiB;AAAA,MAC7B;AACA,aAAO,MAAM,KAAK,IAAI;AAAA,IACvB;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/providers/lds/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { JSONSchema } from \"@conduit-client/jsonschema-validate\";\nimport { init, parse } from \"es-module-lexer\";\nimport MagicString from \"magic-string\";\nimport type { Plugin } from \"vite\";\nimport type { ReadInvokerShape } from \"./types\";\n\n// prefix to write into transformed source code\nconst ADAPTER_PREFIX = \"sf-lds-adapter:\";\n// prefix used to ID the adapter when loading the virtual module\nconst ADAPTER_ID_PREFIX = \"\\0\" + ADAPTER_PREFIX;\n\n// the source of the adapter base module — reused across virtual modules so\n// each generated specifier emits the factories once.\n//\n// Top-level exports from the runtime module are stripped so every factory and\n// `gql` becomes a private binding inside the virtual module. The load hook\n// then controls exactly which names are exported per specifier: adapter\n// entries from the registry, plus `gql` for graphql specifiers. Without this,\n// the built `runtime.js` (trailing `export { …, gql, createWireAdapter, … }`)\n// and the source `runtime.ts` (per-declaration `export function gql …`) both\n// produce a `SyntaxError: Duplicate export of 'gql'` when the load hook also\n// appends `export { gql };`. They also leak the factory names as exports on\n// every LDS virtual module, which isn't a public contract we want.\nconst adapterBaseSource = stripTopLevelExports(\n\treadFileSync(join(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"), \"utf-8\"),\n);\n\n/**\n * Removes top-level ES-module `export` keywords from the embedded runtime\n * source so its declarations survive as private bindings inside the virtual\n * module. Handles two shapes:\n * 1. Per-declaration: `export function foo …` / `export async function foo`\n * → the `export ` prefix is dropped.\n * 2. Trailing re-export clause: `export { foo, bar };` → deleted entirely.\n * Inner occurrences (inside function bodies, comments, strings) are not\n * affected because the source is a flat module with exports only at column 0.\n */\nfunction stripTopLevelExports(source: string): string {\n\treturn source\n\t\t.replace(/^export\\s+(?=(?:async\\s+)?function\\s)/gm, \"\")\n\t\t.replace(/^export\\s*\\{[^}]*};?\\s*$/gm, \"\");\n}\n\n/**\n * MCP dispatch descriptor. Nested under `mcp` on every adapter config so\n * additional MCP-specific fields (auth, transport, retry policy) can join\n * later without reshaping every consumer entry.\n */\nexport interface LdsAdapterMcpDispatch {\n\ttoolName: string;\n}\n\n/**\n * Base shape every LDS adapter config extends. Holds the dispatch surface in\n * one place so new backings (e.g. `http`) can land as sibling optional fields\n * without forking each adapter interface. Dual registration is supported at\n * the type level — runtime execution still targets a single backing per call.\n */\nexport interface LdsAdapterConfigBase {\n\tmcp?: LdsAdapterMcpDispatch;\n}\n\n/**\n * LDS adapter configs whose input is validated against a JSON Schema at\n * invoke time — wire, imperative-mutation, imperative-read. GraphQL variants\n * skip this base because they pass `{ query, variables }` through to the\n * configured MCP tool with no schema check.\n */\nexport interface LdsSchemaValidatedAdapterConfig extends LdsAdapterConfigBase {\n\tconfigJsonSchema: JSONSchema;\n}\n\nexport interface LdsWireAdapterConfig extends LdsSchemaValidatedAdapterConfig {\n\ttype: \"wire\";\n}\n\n/**\n * Imperative **mutation** adapter. Always an async\n * `(config) => Promise<Data>` that throws on validation or tool error —\n * matching OneStore's `DefaultImperativeBindingsService`, the only service a\n * mutation ever uses on platform. Mutations do not carry an `invokerShape`:\n * `subscribe`/`refresh` make no sense on write, and allowing them here\n * would drift off-platform from on-platform semantics.\n */\nexport interface LdsImperativeMutationAdapterConfig extends LdsSchemaValidatedAdapterConfig {\n\ttype: \"imperative-mutation\";\n}\n\n/**\n * Public alias for the read-shape union defined in `runtime.ts`. Re-exported\n * from this module so consumers don't have to import from the runtime entry\n * point, while keeping the union pinned to one source of truth.\n *\n * Off-platform there is no store, so `subscribe` is a deliberate no-op\n * (callback never fires, returned unsubscribe is idempotent) and `refresh`\n * re-executes the underlying MCP tool. This preserves the OneStore API\n * surface for code ported verbatim.\n */\nexport type LdsImperativeReadInvokerShape = ReadInvokerShape;\n\nexport interface LdsImperativeReadAdapterConfig extends LdsSchemaValidatedAdapterConfig {\n\ttype: \"imperative-read\";\n\tinvokerShape: LdsImperativeReadInvokerShape;\n}\n\n/**\n * GraphQL wire adapter. Emits `{ data, errors, refresh }` (distinct from the\n * base wire `{ data, error }`). No `configJsonSchema` — the adapter passes\n * `{ query, variables }` through to the configured MCP tool.\n */\nexport interface LdsGraphqlWireAdapterConfig extends LdsAdapterConfigBase {\n\ttype: \"graphql-wire\";\n}\n\n/**\n * Imperative GraphQL mutation — `(config) => Promise<{ data, errors }>`.\n * Errors are routed in-band to the `errors[]` envelope rather than thrown,\n * matching on-platform `toGraphQLResponseFromFailure`.\n */\nexport interface LdsGraphqlMutationAdapterConfig extends LdsAdapterConfigBase {\n\ttype: \"graphql-mutation\";\n}\n\n/**\n * Read-shape discriminator for imperative GraphQL adapters. Mirrors the\n * `imperative-read` `invokerShape` field so the two families share a pattern:\n * one `type` discriminator + a shape field that selects the return surface.\n *\n * - `query` — `Promise<{ data, errors, subscribe }>` (on-platform\n * `GraphQLImperativeBindingsService` without `exposeRefresh`).\n * - `query-refreshable` — `Promise<{ data, errors, subscribe, refresh }>`\n * (same service with `exposeRefresh: true`).\n * - `legacy` — `{ invoke(config, context, callback),\n * subscribe(config, context, callback): Unsubscribe }`, the older callback\n * surface served by `GraphQLLegacyImperativeBindingsService`.\n *\n * `subscribe` is a deliberate no-op off-platform (no reactive store).\n */\nexport type LdsGraphqlImperativeReadInvokerShape = \"query\" | \"query-refreshable\" | \"legacy\";\n\n/**\n * Imperative GraphQL read adapter. The `invokerShape` picks the return\n * surface — see {@link LdsGraphqlImperativeReadInvokerShape}. Errors are\n * routed in-band to `errors[]` (for `query`/`query-refreshable`) or into the\n * callback payload (for `legacy`); no shape throws on tool errors.\n */\nexport interface LdsGraphqlImperativeReadAdapterConfig extends LdsAdapterConfigBase {\n\ttype: \"graphql-imperative-read\";\n\tinvokerShape: LdsGraphqlImperativeReadInvokerShape;\n}\n\nexport type LdsAdapterConfig =\n\t| LdsWireAdapterConfig\n\t| LdsImperativeMutationAdapterConfig\n\t| LdsImperativeReadAdapterConfig\n\t| LdsGraphqlWireAdapterConfig\n\t| LdsGraphqlMutationAdapterConfig\n\t| LdsGraphqlImperativeReadAdapterConfig;\n\nexport type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>>;\n\n/**\n * Default adapter registry.\n * Maps LDS module specifiers to MCP tool-backed implementations. Entries can be\n * wire adapters (`type: 'wire'`), imperative mutations (`type: 'imperative-mutation'`),\n * or imperative reads (`type: 'imperative-read'` + `invokerShape`).\n * Add entries here to support additional lightning/* exports.\n */\nconst DEFAULT_ADAPTERS: LdsAdapterRegistry = {\n\t\"lightning/uiRecordApi\": {\n\t\tgetRecord: {\n\t\t\ttype: \"wire\",\n\t\t\tmcp: { toolName: \"getRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tanyOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tfields: { type: \"array\", items: { type: \"string\" }, minItems: 1 },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"fields\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\t\t\ttype: \"array\",\n\t\t\t\t\t\t\t\titems: { type: \"string\" },\n\t\t\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"layoutTypes\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tcreateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\tmcp: { toolName: \"createRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tapiName: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"apiName\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t\tupdateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\tmcp: { toolName: \"updateRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t\"lightning/uiObjectInfoApi\": {\n\t\t// On-platform this is a `{ invoke, subscribe }` callback surface\n\t\t// emitting `{ data, error }`. The legacy invoker shape preserves that\n\t\t// contract verbatim, so ported consumers keep their call sites.\n\t\tgetObjectInfo_imperative: {\n\t\t\ttype: \"imperative-read\",\n\t\t\tinvokerShape: \"legacy\",\n\t\t\tmcp: { toolName: \"getObjectInfoMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tobjectApiName: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"objectApiName\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t// `lightning/graphql` — on-platform exports `gql`, the `graphql` wire\n\t// adapter, and `executeMutation`. Only `graphql` and `executeMutation`\n\t// are registry entries; `gql` rides along automatically for any specifier\n\t// that has at least one graphql-typed entry (emitted by the load hook).\n\t\"lightning/graphql\": {\n\t\tgraphql: { type: \"graphql-wire\", mcp: { toolName: \"graphqlQuery\" } },\n\t\texecuteMutation: { type: \"graphql-mutation\", mcp: { toolName: \"graphqlQuery\" } },\n\t},\n};\n\n/** True when any entry in a module's adapter map is a `graphql-*` type. */\nfunction isGraphqlSpecifier(moduleAdapters: Record<string, LdsAdapterConfig>): boolean {\n\treturn Object.values(moduleAdapters).some(\n\t\t(entry) =>\n\t\t\tentry.type === \"graphql-wire\" ||\n\t\t\tentry.type === \"graphql-mutation\" ||\n\t\t\tentry.type === \"graphql-imperative-read\",\n\t);\n}\n\n/** Maps a config discriminator to the factory name emitted in the virtual module. */\nfunction factoryFor(type: LdsAdapterConfig[\"type\"]): string {\n\tswitch (type) {\n\t\tcase \"wire\":\n\t\t\treturn \"createWireAdapter\";\n\t\tcase \"imperative-mutation\":\n\t\t\treturn \"createMutationAdapter\";\n\t\tcase \"imperative-read\":\n\t\t\treturn \"createReadAdapter\";\n\t\tcase \"graphql-wire\":\n\t\t\treturn \"createGraphQLWireAdapter\";\n\t\tcase \"graphql-mutation\":\n\t\t\treturn \"createGraphQLMutationAdapter\";\n\t\tcase \"graphql-imperative-read\":\n\t\t\treturn \"createGraphQLImperativeReadAdapter\";\n\t}\n}\n\nfunction parseImportSpecifiers(bracesContent: string): { original: string; full: string }[] {\n\treturn bracesContent\n\t\t.split(\",\")\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst asIdx = entry.indexOf(\" as \");\n\t\t\tconst original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();\n\t\t\treturn { original, full: entry };\n\t\t});\n}\n\n/**\n * Deep-merges user overrides onto the default registry: every specifier from\n * both sides is preserved, and per-specifier entries are merged so a consumer\n * can override `getRecord` without losing `createRecord`, or register a new\n * entry on `lightning/graphql` without losing `graphql` / `executeMutation`.\n * Pass an empty object to get just the defaults. To opt out of a default\n * entry, pass the same specifier with a different entry of the same key.\n */\nfunction mergeWithDefaults(overrides: LdsAdapterRegistry): LdsAdapterRegistry {\n\tconst merged: LdsAdapterRegistry = { ...DEFAULT_ADAPTERS };\n\tfor (const [specifier, entries] of Object.entries(overrides)) {\n\t\tmerged[specifier] = { ...(DEFAULT_ADAPTERS[specifier] ?? {}), ...entries };\n\t}\n\treturn merged;\n}\n\n/**\n * LDS provider — rewrites registered `lightning/*` imports (e.g.\n * `lightning/uiRecordApi`) to MCP-tool-backed virtual modules. Unregistered\n * exports pass through to the normal `lightning/*` resolution.\n *\n * Three Vite hooks do the work:\n *\n * - **`transform`** — parses each `.js` / `.ts` file with `es-module-lexer`,\n * finds named imports from registered specifiers, and rewrites them to pull\n * registered names from `sf-lds-adapter:<specifier>` while leaving\n * unregistered names pointing at the original specifier.\n *\n * - **`resolveId`** — maps `sf-lds-adapter:<specifier>` to a `\\0`-prefixed\n * virtual module ID, preventing Rollup from attempting a filesystem lookup.\n *\n * - **`load`** — generates the virtual module, emitting an MCP-backed\n * `createWireAdapter(...)` class for every `type: 'wire'` entry,\n * `createMutationAdapter(...)` for every `type: 'imperative-mutation'` entry,\n * and `createReadAdapter(...)` for every `type: 'imperative-read'` entry.\n *\n * Only specifiers present in the `adapters` registry are intercepted; imports from\n * unregistered specifiers pass through unchanged.\n */\nexport function lds(overrides: LdsAdapterRegistry = {}): Plugin {\n\tconst adapters = mergeWithDefaults(overrides);\n\t// Graphql specifiers are owned whole by the virtual module — every export\n\t// (adapters + `gql`) lives there, so the transform hook should not split\n\t// their imports. Non-graphql specifiers still go through transform so\n\t// unregistered names pass through to the real `lightning/*` module.\n\tconst graphqlSpecifiers = new Set<string>(\n\t\tObject.entries(adapters)\n\t\t\t.filter(([, moduleAdapters]) => isGraphqlSpecifier(moduleAdapters))\n\t\t\t.map(([specifier]) => specifier),\n\t);\n\tconst transformSpecifiers = Object.keys(adapters).filter((s) => !graphqlSpecifiers.has(s));\n\tconst specifierSnippets = transformSpecifiers.flatMap((s) => [`'${s}'`, `\"${s}\"`]);\n\n\treturn {\n\t\tname: \"vite-plugin-lds\",\n\t\tenforce: \"pre\",\n\n\t\tasync transform(code, id) {\n\t\t\tconst cleanId = id.split(\"?\")[0] ?? id;\n\t\t\tif (!cleanId.endsWith(\".js\") && !cleanId.endsWith(\".ts\")) return null;\n\t\t\tif (cleanId.includes(\"/node_modules/\")) return null;\n\t\t\tif (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;\n\n\t\t\tawait init;\n\n\t\t\tlet imports: ReturnType<typeof parse>[0];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code);\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst relevant = imports.filter(\n\t\t\t\t(imp) =>\n\t\t\t\t\timp.d === -1 && imp.n !== undefined && imp.n in adapters && !graphqlSpecifiers.has(imp.n),\n\t\t\t);\n\t\t\tif (relevant.length === 0) return null;\n\n\t\t\tconst s = new MagicString(code);\n\t\t\tlet changed = false;\n\n\t\t\tfor (const imp of relevant) {\n\t\t\t\tconst { ss: start, se: end, n: specifier } = imp;\n\t\t\t\tconst statement = code.slice(start, end);\n\n\t\t\t\tconst openBrace = statement.indexOf(\"{\");\n\t\t\t\tconst closeBrace = statement.indexOf(\"}\");\n\t\t\t\tif (openBrace === -1 || closeBrace === -1) continue;\n\n\t\t\t\tconst bracesContent = statement.slice(openBrace + 1, closeBrace);\n\t\t\t\tconst moduleAdapters = adapters[specifier!]!;\n\t\t\t\tconst parsedImport = parseImportSpecifiers(bracesContent);\n\t\t\t\tconst registered = parsedImport.filter((p) => p.original in moduleAdapters);\n\t\t\t\tconst unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));\n\n\t\t\t\tif (registered.length === 0) continue;\n\n\t\t\t\tconst parts: string[] = [\n\t\t\t\t\t`import { ${registered.map((p) => p.full).join(\", \")} } from '${ADAPTER_PREFIX}${specifier}';`,\n\t\t\t\t];\n\n\t\t\t\tif (unregistered.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`import { ${unregistered.map((p) => p.full).join(\", \")} } from '${specifier}';`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ts.overwrite(start, end, parts.join(\"\\n\"));\n\t\t\t\tchanged = true;\n\t\t\t}\n\n\t\t\tif (!changed) return null;\n\t\t\treturn { code: s.toString(), map: s.generateMap({ hires: true }) };\n\t\t},\n\n\t\tresolveId(id) {\n\t\t\t// Graphql specifiers are intercepted raw — no transform hook split\n\t\t\t// — and mapped into the same `\\0sf-lds-adapter:` virtual namespace\n\t\t\t// so the load hook emits one module per specifier.\n\t\t\tif (graphqlSpecifiers.has(id)) return ADAPTER_ID_PREFIX + id;\n\t\t\tif (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(ADAPTER_ID_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(ADAPTER_ID_PREFIX.length);\n\t\t\tconst moduleAdapters = adapters[specifier];\n\t\t\tif (!moduleAdapters) return null;\n\n\t\t\t// create lines of code used to create MCP tool based adapters\n\t\t\tconst lines: string[] = [adapterBaseSource];\n\t\t\tfor (const [name, entry] of Object.entries(moduleAdapters)) {\n\t\t\t\tconst { type, ...cfg } = entry;\n\t\t\t\tlines.push(\n\t\t\t\t\t`export const ${name} = ${factoryFor(type)}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// `gql` rides along with any specifier that declares a graphql\n\t\t\t// adapter, so `import { gql } from 'lightning/graphql'` (or any\n\t\t\t// aliased form) keeps resolving even when no adapters are\n\t\t\t// imported alongside it. The binding itself is a private function\n\t\t\t// inside `adapterBaseSource` after `stripTopLevelExports`.\n\t\t\tif (graphqlSpecifiers.has(specifier)) {\n\t\t\t\tlines.push(\"export { gql };\");\n\t\t\t}\n\t\t\treturn lines.join(\"\\n\");\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;;;;AAeA,MAAM,iBAAiB;AAEvB,MAAM,oBAAoB,OAAO;AAcjC,MAAM,oBAAoB;AAAA,EACzB,aAAa,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,YAAY,GAAG,OAAO;AAClF;AAYA,SAAS,qBAAqB,QAAwB;AACrD,SAAO,OACL,QAAQ,2CAA2C,EAAE,EACrD,QAAQ,8BAA8B,EAAE;AAC3C;AA+HA,MAAM,mBAAuC;AAAA,EAC5C,yBAAyB;AAAA,IACxB,WAAW;AAAA,MACV,MAAM;AAAA,MACN,KAAK,EAAE,UAAU,mBAAA;AAAA,MACjB,kBAAkB;AAAA,QACjB,MAAM;AAAA,QACN,YAAY;AAAA,UACX,UAAU,EAAE,MAAM,SAAA;AAAA,UAClB,aAAa;AAAA,YACZ,OAAO,CAAC,EAAE,MAAM,SAAS,OAAO,EAAE,MAAM,SAAA,EAAS,GAAK,EAAE,MAAM,QAAQ;AAAA,UAAA;AAAA,UAEvE,QAAQ;AAAA,YACP,OAAO,CAAC,EAAE,MAAM,SAAS,OAAO,EAAE,MAAM,SAAA,EAAS,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