@salesforce/vite-plugin-lwc-ui-bundle 1.131.2 → 1.132.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.
Files changed (32) hide show
  1. package/README.md +36 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +14 -4
  4. package/dist/index.js.map +1 -1
  5. package/dist/providers/index.d.ts +3 -1
  6. package/dist/providers/index.d.ts.map +1 -1
  7. package/dist/providers/index.js +4 -163
  8. package/dist/providers/index.js.map +1 -1
  9. package/dist/providers/lds/index.d.ts +10 -0
  10. package/dist/providers/lds/index.d.ts.map +1 -0
  11. package/dist/providers/lds/index.js +106 -0
  12. package/dist/providers/lds/index.js.map +1 -0
  13. package/dist/providers/lds/runtime.js +96 -0
  14. package/dist/providers/lds/runtime.js.map +1 -0
  15. package/dist/providers/lds/types.d.ts +22 -0
  16. package/dist/providers/lds/types.d.ts.map +1 -0
  17. package/dist/providers/lightning-graphql/index.d.ts +10 -0
  18. package/dist/providers/lightning-graphql/index.d.ts.map +1 -0
  19. package/dist/providers/lightning-graphql/index.js +24 -0
  20. package/dist/providers/lightning-graphql/index.js.map +1 -0
  21. package/dist/providers/lightning-graphql/runtime.js +103 -0
  22. package/dist/providers/lightning-graphql/runtime.js.map +1 -0
  23. package/dist/providers/shared/normalize-mcp-response.d.ts +20 -0
  24. package/dist/providers/shared/normalize-mcp-response.d.ts.map +1 -0
  25. package/dist/types.d.ts +1 -1
  26. package/dist/types.d.ts.map +1 -1
  27. package/docs/consumer-guide.md +429 -0
  28. package/package.json +21 -6
  29. package/skills/setup-lwc-vite-plugin/SKILL.md +242 -0
  30. package/dist/providers/lightning-graphql.d.ts +0 -17
  31. package/dist/providers/lightning-graphql.d.ts.map +0 -1
  32. package/docs/user-guide.md +0 -377
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  Vite plugin for compiling and running LWC components off-platform. Bundles the full compilation pipeline — scoped module providers, Lightning npm resolution, missing CSS handling, and the Vite/LWC bridge — behind a single configurable entry point.
4
4
 
5
+ > **Getting started?** See the [Consumer Guide](docs/consumer-guide.md) for a
6
+ > step-by-step walkthrough of adding this plugin to an existing LWC project.
7
+
5
8
  ## Installation
6
9
 
7
10
  ```bash
@@ -220,3 +223,36 @@ globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: "/" } });
220
223
  | ---------- | --------- | ------------------ | ------------------------------------ |
221
224
  | `orgAlias` | `string` | sf CLI default org | Salesforce org alias |
222
225
  | `debug` | `boolean` | `false` | Log each proxied request to terminal |
226
+
227
+ ## Claude Code Skill
228
+
229
+ This package includes a [Claude Code](https://docs.anthropic.com/en/docs/claude-code) skill that interactively sets up the plugin in your LWC project. It detects your project structure, asks which component to use as the root, inspects the component tree for GraphQL/label/base-component usage, and generates all the config files.
230
+
231
+ ### Installing the skill
232
+
233
+ **Option A — Global (available in all projects):**
234
+
235
+ ```bash
236
+ cp -r node_modules/@salesforce/vite-plugin-lwc-ui-bundle/skills/setup-lwc-vite-plugin \
237
+ ~/.claude/skills/setup-lwc-vite-plugin
238
+ ```
239
+
240
+ **Option B — Project-scoped (available only in this project):**
241
+
242
+ ```bash
243
+ mkdir -p .claude/skills
244
+ cp -r node_modules/@salesforce/vite-plugin-lwc-ui-bundle/skills/setup-lwc-vite-plugin \
245
+ .claude/skills/setup-lwc-vite-plugin
246
+ ```
247
+
248
+ ### Using the skill
249
+
250
+ Once installed, the skill triggers automatically in Claude Code when you ask things like:
251
+
252
+ - "Set up vite-plugin-lwc-ui-bundle in my project"
253
+ - "I want to run my LWC components outside Salesforce"
254
+ - "Build a static LWC bundle"
255
+ - "Add Vite to my SFDX project"
256
+ - "Compile LWC off-platform"
257
+
258
+ You can also invoke it explicitly with `/setup-lwc-vite-plugin`.
@@ -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,EAAE,oBAAoB,EAA8B,MAAM,SAAS,CAAC;AAEhF,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;AA6BvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAgJlF"}
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;AAmCvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAoJlF"}
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { createRequire } from "node:module";
2
2
  import path from "node:path";
3
3
  import { existsSync, statSync, readdirSync } from "node:fs";
4
- import { label, i18n, accessCheck, client, gate, primitiveUtils, lightningGraphql } from "./providers/index.js";
4
+ import { label, i18n, accessCheck, client, gate, primitiveUtils } from "./providers/index.js";
5
5
  import { i } from "./providers/index.js";
6
6
  import * as http from "node:http";
7
7
  import * as https from "node:https";
8
+ import { lightningGraphql } from "./providers/lightning-graphql/index.js";
9
+ import { lds } from "./providers/lds/index.js";
8
10
  function discoverModules(dirs = []) {
9
11
  const modules = [];
10
12
  for (const dir of dirs) {
@@ -368,9 +370,13 @@ function defaultProviders() {
368
370
  client(),
369
371
  gate(),
370
372
  primitiveUtils(),
371
- lightningGraphql()
373
+ lightningGraphql(),
374
+ lds()
372
375
  ];
373
376
  }
377
+ function isProvider(item) {
378
+ return typeof item.resolve === "function";
379
+ }
374
380
  async function loadLwcRollup() {
375
381
  try {
376
382
  const mod = await import("@lwc/rollup-plugin");
@@ -378,7 +384,7 @@ async function loadLwcRollup() {
378
384
  } catch (error) {
379
385
  const errMsg = error instanceof Error ? error.message : String(error);
380
386
  throw new Error(
381
- `vite-plugin-lwc-ui-bundle requires @lwc/rollup-plugin as a peer dependency. Install it with: npm install -D @lwc/rollup-plugin
387
+ `@salesforce/vite-plugin-lwc-ui-bundle requires @lwc/rollup-plugin as a peer dependency. Install it with: npm install -D @lwc/rollup-plugin
382
388
  Debug: cwd=${process.cwd()}, error=${errMsg}`
383
389
  );
384
390
  }
@@ -396,7 +402,9 @@ function lwcVitePlugin(options = {}) {
396
402
  ],
397
403
  passthroughRules = []
398
404
  } = options;
399
- const resolvedProviders = providers ?? defaultProviders();
405
+ const resolvedItems = providers ?? defaultProviders();
406
+ const resolvedProviders = resolvedItems.filter(isProvider);
407
+ const rawPlugins = resolvedItems.filter((item) => !isProvider(item));
400
408
  const { dirs = [], npm: npmPackages = [] } = modules;
401
409
  const resolvedDirs = dirs.map(
402
410
  (d) => typeof d === "string" ? { path: path.resolve(d), namespace: "" } : { ...d, path: path.resolve(d.path) }
@@ -456,6 +464,8 @@ function lwcVitePlugin(options = {}) {
456
464
  };
457
465
  }
458
466
  },
467
+ // plugins returned by plugin-style builtins (e.g. lds())
468
+ ...rawPlugins,
459
469
  scopedProviders(resolvedProviders, {
460
470
  ignorePatterns,
461
471
  interceptPrefixes: [...interceptPrefixes],
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 { LwcVitePluginOptions, NpmModuleConfig, DirConfig } 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() {\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.lightningGraphql(),\n\t];\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\"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 resolvedProviders = providers ?? defaultProviders();\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\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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,UAA4B;AAAA,sBAClE,MAAM,KAAK;AAAA,sBACX,UAAU;AAAA,oBAAA,EACT;AAAA,kBACH;AAAA,gBAAA;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MAEF;AAAA,IAAA;AAAA,IAED,gBAAgB,mBAAmB;AAAA,MAClC;AAAA,MACA,mBAAmB,CAAC,GAAG,iBAAiB;AAAA,MACxC;AAAA,IAAA,CACA;AAAA,IAED,GAAG,SAAS;AAAA,MAAI,CAAC,YAChB,aAAa;AAAA,QACZ;AAAA,QACA,cAAc;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,IAGF,WAAA;AAAA,IACA,UAAU,gBAAgB;AAAA,IAC1B;AAAA,MACC;AAAA,MACA;AAAA,QACC,SAAS,QAAQ,IAAA;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;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;"}
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.lightningGraphql(),\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.lightningGraphql","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,YAA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AAK;AAAA,sBACX,UAAU;AAAA,oBAAA,EACT;AAAA,kBACH;AAAA,gBAAA;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MAEF;AAAA,IAAA;AAAA;AAAA,IAGD,GAAG;AAAA,IACH,gBAAgB,mBAAmB;AAAA,MAClC;AAAA,MACA,mBAAmB,CAAC,GAAG,iBAAiB;AAAA,MACxC;AAAA,IAAA,CACA;AAAA,IAED,GAAG,SAAS;AAAA,MAAI,CAAC,YAChB,aAAa;AAAA,QACZ;AAAA,QACA,cAAc;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,IAGF,WAAA;AAAA,IACA,UAAU,gBAAgB;AAAA,IAC1B;AAAA,MACC;AAAA,MACA;AAAA,QACC,SAAS,QAAQ,IAAA;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;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;"}
@@ -9,5 +9,7 @@ export { gate } from './gate';
9
9
  export { accessCheck } from './access-check';
10
10
  export { client } from './client';
11
11
  export { primitiveUtils } from './primitive-utils';
12
- export { lightningGraphql } from './lightning-graphql';
12
+ export { lightningGraphql } from './lightning-graphql/index';
13
+ export { lds } from './lds/index';
14
+ export type { LdsAdapterRegistry, LdsWireAdapterConfig } from './lds/index';
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { lightningGraphql } from "./lightning-graphql/index.js";
2
+ import { lds } from "./lds/index.js";
1
3
  const LABEL_DEFAULTS = {
2
4
  "LightningForm.edit": "Edit",
3
5
  "LightningForm.save": "Save",
@@ -276,169 +278,6 @@ export function reflectAttribute(element, attrName, value) {
276
278
  }
277
279
  };
278
280
  }
279
- function buildGraphqlSource(toolName) {
280
- return `
281
- import { getChatSDK } from '@salesforce/sdk-chat';
282
-
283
- export function gql(strings, ...values) {
284
- let result = '';
285
- strings.forEach((string, i) => {
286
- result += string;
287
- if (i < values.length) result += String(values[i]);
288
- });
289
- return result;
290
- }
291
-
292
- export class graphql {
293
- _dataCallback;
294
- _config;
295
-
296
- constructor(dataCallback) {
297
- this._dataCallback = dataCallback;
298
- }
299
-
300
- connect() { this._fetch(); }
301
- disconnect() {}
302
-
303
- update(config) {
304
- this._config = config;
305
- this._fetch();
306
- }
307
-
308
- refresh() {
309
- return this._fetch();
310
- }
311
-
312
- async _fetch() {
313
- const query = this._config?.query;
314
- const variables = this._config?.variables ?? {};
315
-
316
- if (!query) {
317
- this._emit({ data: undefined, errors: undefined });
318
- return;
319
- }
320
-
321
- try {
322
- // 1. UIBundle / local dev: use globalThis.__sfdc_sdk__.graphql if available
323
- if (typeof globalThis.__sfdc_sdk__?.graphql === 'function') {
324
- const result = await globalThis.__sfdc_sdk__.graphql(query, variables);
325
- this._emit({ data: result?.data, errors: result?.errors });
326
- return;
327
- }
328
-
329
- // 2. MCP surface: use getChatSDK().callTool
330
- const sdk = await getChatSDK();
331
-
332
- if (typeof sdk.callTool !== 'function') {
333
- throw new Error(
334
- '[lightning/graphql] No data surface available. ' +
335
- 'Either initialise globalThis.__sfdc_sdk__ with createDataSDK, ' +
336
- 'or run inside a ChatGPT / MCP Apps context.'
337
- );
338
- }
339
-
340
- const raw = await sdk.callTool({
341
- toolName: ${JSON.stringify(toolName)},
342
- params: { query, variables },
343
- });
344
-
345
- // Normalise result across surfaces:
346
- // - OpenAI surface: { result: "<JSON string of { data, errors }>" }
347
- // - MCP Apps surface: { structuredContent: { data, errors }, content: [...] }
348
- let result;
349
- if (raw?.structuredContent !== undefined) {
350
- result = raw.structuredContent;
351
- } else if (typeof raw?.result === 'string') {
352
- const parsed = JSON.parse(raw.result);
353
- if (Array.isArray(parsed)) {
354
- // MCP content array - extract text from first text block
355
- const textBlock = parsed.find(
356
- (b) => b && b.type === 'text' && typeof b.text === 'string',
357
- );
358
- const text = textBlock ? textBlock.text : null;
359
- if (text) {
360
- try { result = JSON.parse(text); } catch { result = { errors: [{ message: text }] }; }
361
- } else {
362
- result = {};
363
- }
364
- } else {
365
- result = parsed;
366
- }
367
- } else {
368
- result = raw ?? {};
369
- }
370
-
371
- this._emit({ data: result?.data, errors: result?.errors });
372
- } catch (error) {
373
- this._emit({ data: undefined, errors: [{ message: error.message }] });
374
- }
375
- }
376
-
377
- _emit({ data, errors }) {
378
- this._dataCallback({
379
- data,
380
- error: errors?.length ? errors : undefined,
381
- refresh: () => this.refresh(),
382
- });
383
- }
384
- }
385
-
386
- export async function executeMutation(config) {
387
- const { query, variables } = config;
388
- if (!query) return { data: undefined, errors: [{ message: 'No query provided' }] };
389
- try {
390
- // 1. UIBundle / local dev
391
- if (typeof globalThis.__sfdc_sdk__?.graphql === 'function') {
392
- const result = await globalThis.__sfdc_sdk__.graphql(query, variables ?? {});
393
- return { data: result?.data, errors: result?.errors };
394
- }
395
- // 2. MCP surface
396
- const sdk = await getChatSDK();
397
- if (typeof sdk.callTool !== 'function') {
398
- throw new Error('[lightning/graphql] No data surface available.');
399
- }
400
- const raw = await sdk.callTool({
401
- toolName: ${JSON.stringify(toolName)},
402
- params: { query, variables: variables ?? {} },
403
- });
404
- let result;
405
- if (raw?.structuredContent !== undefined) {
406
- result = raw.structuredContent;
407
- } else if (typeof raw?.result === 'string') {
408
- const parsed = JSON.parse(raw.result);
409
- if (Array.isArray(parsed)) {
410
- const textBlock = parsed.find(
411
- (b) => b && b.type === 'text' && typeof b.text === 'string',
412
- );
413
- const text = textBlock ? textBlock.text : null;
414
- if (text) {
415
- try { result = JSON.parse(text); } catch { result = { errors: [{ message: text }] }; }
416
- } else {
417
- result = {};
418
- }
419
- } else {
420
- result = parsed;
421
- }
422
- } else {
423
- result = raw ?? {};
424
- }
425
- return { data: result?.data, errors: result?.errors };
426
- } catch (error) {
427
- return { data: undefined, errors: [{ message: error.message }] };
428
- }
429
- }
430
- `;
431
- }
432
- function lightningGraphql(options = {}) {
433
- const toolName = options.toolName ?? "graphqlQuery";
434
- return {
435
- prefix: "lightning/graphql",
436
- resolve(specifier) {
437
- if (specifier !== "lightning/graphql") return null;
438
- return buildGraphqlSource(toolName);
439
- }
440
- };
441
- }
442
281
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
443
282
  __proto__: null,
444
283
  accessCheck,
@@ -446,6 +285,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
446
285
  gate,
447
286
  i18n,
448
287
  label,
288
+ lds,
449
289
  lightningGraphql,
450
290
  primitiveUtils
451
291
  }, Symbol.toStringTag, { value: "Module" }));
@@ -456,6 +296,7 @@ export {
456
296
  index as i,
457
297
  i18n,
458
298
  label,
299
+ lds,
459
300
  lightningGraphql,
460
301
  primitiveUtils
461
302
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/providers/label.ts","../../src/providers/i18n.ts","../../src/providers/gate.ts","../../src/providers/access-check.ts","../../src/providers/client.ts","../../src/providers/primitive-utils.ts","../../src/providers/lightning-graphql.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst LABEL_DEFAULTS: Record<string, string> = {\n\t\"LightningForm.edit\": \"Edit\",\n\t\"LightningForm.save\": \"Save\",\n\t\"LightningForm.cancel\": \"Cancel\",\n\t\"LightningForm.error\": \"Error\",\n\t\"RecordDetailUC.Expand\": \"Expand\",\n\t\"RecordDetailUC.Collapse\": \"Collapse\",\n\t\"Global_Entity.created_by\": \"Created By\",\n\t\"Global_Entity.last_modified_by\": \"Last Modified By\",\n\t\"DetailError.GenericSaveError\": \"An error occurred while saving.\",\n\t\"MobileWebError.NoPreEditAccess\": \"You don't have access to edit this record.\",\n\t\"DuplicateList.ToastMessageBlock\": \"Duplicate records were found.\",\n\t\"DuplicateList.NonBlockingHeaderText\": \"Duplicate records found\",\n\t\"DuplicateList.ToastMessageAlertEdit\": \"Duplicate records were found. You can continue editing.\",\n\t\"Errors.ErrorPopoverHeading\": \"Error\",\n};\n\nexport function label(overrides: Record<string, string> = {}): Provider {\n\tconst defaults = { ...LABEL_DEFAULTS, ...overrides };\n\treturn {\n\t\tprefix: \"@salesforce/label/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/label/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/label/\".length);\n\t\t\tconst fallbackLabel = key\n\t\t\t\t.split(\".\")\n\t\t\t\t.at(-1)!\n\t\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t\t.replace(/_/g, \" \")\n\t\t\t\t.trim();\n\t\t\tconst value = defaults[key] ?? fallbackLabel;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\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 { Provider } from \"../types\";\n\nconst BROWSER_DERIVED = new Set([\n\t\"lang\",\n\t\"dir\",\n\t\"locale\",\n\t\"currency\",\n\t\"timeZone\",\n\t\"firstDayOfWeek\",\n]);\n\nconst STATIC_DEFAULTS: Record<string, string> = {\n\t\"dateTime.shortDateFormat\": \"M/d/yyyy\",\n\t\"dateTime.mediumDateFormat\": \"MMM d, yyyy\",\n\t\"dateTime.longDateFormat\": \"MMMM d, yyyy\",\n\t\"dateTime.shortTimeFormat\": \"h:mm a\",\n\t\"dateTime.mediumTimeFormat\": \"h:mm:ss a\",\n\t\"dateTime.longTimeFormat\": \"h:mm:ss a z\",\n\t\"dateTime.shortDateTimeFormat\": \"M/d/yyyy, h:mm a\",\n\t\"number.numberFormat\": \"#,##0.##\",\n\t\"number.currencyFormat\": \"¤#,##0.00\",\n\t\"number.decimalSeparator\": \".\",\n\t\"number.groupingSeparator\": \",\",\n\t\"number.percentFormat\": \"#,##0%\",\n\t\"number.percentSign\": \"%\",\n\t\"number.plusSign\": \"+\",\n\t\"number.minusSign\": \"-\",\n\t\"number.exponentialSign\": \"E\",\n\t\"number.superscriptingExponentSign\": \"×\",\n\t\"number.perMilleSign\": \"‰\",\n\t\"number.infinity\": \"∞\",\n\t\"number.nan\": \"NaN\",\n\t\"number.currencySymbol\": \"$\",\n\tdefaultCalendar: \"gregory\",\n\tdefaultNumberingSystem: \"latn\",\n};\n\nconst MONTHS_WIDE = [\n\t\"January\",\n\t\"February\",\n\t\"March\",\n\t\"April\",\n\t\"May\",\n\t\"June\",\n\t\"July\",\n\t\"August\",\n\t\"September\",\n\t\"October\",\n\t\"November\",\n\t\"December\",\n];\nconst MONTHS_ABBR = [\n\t\"Jan\",\n\t\"Feb\",\n\t\"Mar\",\n\t\"Apr\",\n\t\"May\",\n\t\"Jun\",\n\t\"Jul\",\n\t\"Aug\",\n\t\"Sep\",\n\t\"Oct\",\n\t\"Nov\",\n\t\"Dec\",\n];\nconst DAYS_WIDE = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\nconst DAYS_ABBR = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nconst OBJECT_DEFAULTS: Record<string, unknown> = {\n\t\"common.digits\": { latn: \"0123456789\" },\n\t\"common.calendarData\": {\n\t\tgregory: { calendarSystem: \"solar\", eras: {} },\n\t},\n\tcalendarData: {\n\t\tgregory: {\n\t\t\tmonths: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: MONTHS_WIDE,\n\t\t\t\t\tabbreviated: MONTHS_ABBR,\n\t\t\t\t\tnarrow: MONTHS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdays: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: DAYS_WIDE,\n\t\t\t\t\tabbreviated: DAYS_ABBR,\n\t\t\t\t\tnarrow: DAYS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdayPeriods: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: [\"AM\", \"PM\"],\n\t\t\t\t\tabbreviated: [\"am\", \"pm\"],\n\t\t\t\t\tnarrow: [\"a\", \"p\"],\n\t\t\t\t},\n\t\t\t},\n\t\t\teras: {\n\t\t\t\teraAbbr: [\"AD\"],\n\t\t\t\teraNames: [\"Anno Domini\"],\n\t\t\t\teraNarrow: [\"A\"],\n\t\t\t},\n\t\t},\n\t},\n};\n\nconst RUNTIME_SOURCE = `\nconst RTL_LANGS = new Set([\n 'ar', 'arc', 'dv', 'fa', 'ha', 'he', 'khw', 'ks', 'ku', 'ps', 'ur', 'yi',\n]);\n\nfunction getLocale() {\n if (typeof navigator === 'undefined') return 'en-US';\n return navigator.language || 'en-US';\n}\n\nfunction getLang() {\n return getLocale().split('-')[0];\n}\n\nfunction getDir() {\n return RTL_LANGS.has(getLang()) ? 'rtl' : 'ltr';\n}\n\nfunction getCurrency() {\n try {\n const parts = new Intl.NumberFormat(getLocale(), {\n style: 'currency',\n currency: 'USD',\n currencyDisplay: 'code',\n }).resolvedOptions();\n return parts.currency || 'USD';\n } catch {\n return 'USD';\n }\n}\n\nfunction getTimeZone() {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';\n } catch {\n return 'UTC';\n }\n}\n\nfunction getFirstDayOfWeek() {\n try {\n const loc = new Intl.Locale(getLocale());\n if (loc.weekInfo) return String(loc.weekInfo.firstDay);\n if (typeof loc.getWeekInfo === 'function') return String(loc.getWeekInfo().firstDay);\n } catch { /* unsupported in this browser */ }\n return '7';\n}\n\nconst values = {\n lang: getLang(),\n dir: getDir(),\n locale: getLocale(),\n currency: getCurrency(),\n timeZone: getTimeZone(),\n firstDayOfWeek: getFirstDayOfWeek(),\n};\n\nexport default values['__KEY__'];\n`;\n\nexport interface I18nOptions {\n\tstaticOverrides?: Record<string, string>;\n\tobjectOverrides?: Record<string, unknown>;\n}\n\nexport function i18n(options: I18nOptions = {}): Provider {\n\tconst { staticOverrides = {}, objectOverrides = {} } = options;\n\tconst statics = { ...STATIC_DEFAULTS, ...staticOverrides };\n\tconst objects = { ...OBJECT_DEFAULTS, ...objectOverrides };\n\n\treturn {\n\t\tprefix: \"@salesforce/i18n/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/i18n/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/i18n/\".length);\n\n\t\t\tif (BROWSER_DERIVED.has(key)) {\n\t\t\t\treturn RUNTIME_SOURCE.replace(\"__KEY__\", key);\n\t\t\t}\n\n\t\t\tif (key in objects) {\n\t\t\t\treturn `export default ${JSON.stringify(objects[key])};`;\n\t\t\t}\n\n\t\t\tconst value = statics[key] ?? key;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\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 { Provider } from \"../types\";\n\nexport function gate(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/gate/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/gate/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/gate/\".length);\n\t\t\tconst isOpen = overrides[name] ?? true;\n\t\t\treturn `export default { isOpen: () => ${isOpen} };`;\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 { Provider } from \"../types\";\n\nexport function accessCheck(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/accessCheck/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/accessCheck/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/accessCheck/\".length);\n\t\t\tconst value = overrides[name] ?? false;\n\t\t\treturn `export default ${value};`;\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 { Provider } from \"../types\";\n\nconst FORM_FACTOR_SOURCE = `\nfunction getFormFactor() {\n if (typeof window === 'undefined') return 'Large';\n if (window.matchMedia('(max-width: 767px)').matches) return 'Small';\n if (window.matchMedia('(max-width: 1023px)').matches) return 'Medium';\n return 'Large';\n}\n\nexport default getFormFactor();\n`;\n\nexport function client(): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/client/\",\n\t\tresolve(specifier) {\n\t\t\tif (specifier === \"@salesforce/client/formFactor\") {\n\t\t\t\treturn FORM_FACTOR_SOURCE;\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 { Provider } from \"../types\";\n\nexport function primitiveUtils(): Provider {\n\treturn {\n\t\tprefix: \"lightning/primitiveUtils\",\n\t\tmatch(id) {\n\t\t\treturn id === \"lightning/primitiveUtils\";\n\t\t},\n\t\tresolve(specifier) {\n\t\t\tif (specifier !== \"lightning/primitiveUtils\") return null;\n\n\t\t\treturn `export function normalizeBoolean(value) {\n return typeof value === 'string' || !!value;\n}\n\nexport function reflectAttribute(element, attrName, value) {\n if (!element) return;\n if (typeof value === 'string') {\n element.setAttribute(attrName, value);\n } else if (value === true) {\n element.setAttribute(attrName, '');\n } else if (!value) {\n element.removeAttribute(attrName);\n } else {\n console.warn(\\`Invalid attribute value for \"\\${attrName}\": \\${value}\\`);\n }\n}\n`;\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 { Provider } from \"../types\";\n\nexport interface LightningGraphqlOptions {\n\t/**\n\t * Name of the MCP tool to call for GraphQL query execution.\n\t * Defaults to `'graphqlQuery'`.\n\t *\n\t * The tool must accept `{ query: string; variables?: Record<string, unknown> }`\n\t * and return a GraphQL-shaped response: `{ data: unknown; errors?: unknown[] }`.\n\t *\n\t * The result is normalised across surfaces:\n\t * - OpenAI surface: `sdk.callTool()` resolves with `{ result: \"<JSON string>\" }`\n\t * - MCP Apps surface: `sdk.callTool()` resolves with `{ structuredContent, content }`\n\t */\n\ttoolName?: string;\n}\n\n/**\n * Off-platform implementation of `lightning/graphql`.\n *\n * Provides the `gql` tagged-template helper and a `graphql` wire adapter that\n * executes GraphQL queries by calling an MCP tool via `@salesforce/sdk-chat`.\n *\n * `getChatSDK()` auto-detects the host surface:\n * - `window.openai` present → OpenAI/ChatGPT bridge (`window.openai.callTool`)\n * - Inside an iframe → MCP Apps JSON-RPC session (with OpenAI fallback)\n * - Neither → UIBundle stub (no callTool; adapter emits an error)\n *\n * The tool name is configurable via `options.toolName` (default `'graphqlQuery'`).\n * Requires `@salesforce/sdk-chat` as a peer dependency.\n */\nfunction buildGraphqlSource(toolName: string): string {\n\treturn `\nimport { getChatSDK } from '@salesforce/sdk-chat';\n\nexport function gql(strings, ...values) {\n let result = '';\n strings.forEach((string, i) => {\n result += string;\n if (i < values.length) result += String(values[i]);\n });\n return result;\n}\n\nexport class graphql {\n _dataCallback;\n _config;\n\n constructor(dataCallback) {\n this._dataCallback = dataCallback;\n }\n\n connect() { this._fetch(); }\n disconnect() {}\n\n update(config) {\n this._config = config;\n this._fetch();\n }\n\n refresh() {\n return this._fetch();\n }\n\n async _fetch() {\n const query = this._config?.query;\n const variables = this._config?.variables ?? {};\n\n if (!query) {\n this._emit({ data: undefined, errors: undefined });\n return;\n }\n\n try {\n // 1. UIBundle / local dev: use globalThis.__sfdc_sdk__.graphql if available\n if (typeof globalThis.__sfdc_sdk__?.graphql === 'function') {\n const result = await globalThis.__sfdc_sdk__.graphql(query, variables);\n this._emit({ data: result?.data, errors: result?.errors });\n return;\n }\n\n // 2. MCP surface: use getChatSDK().callTool\n const sdk = await getChatSDK();\n\n if (typeof sdk.callTool !== 'function') {\n throw new Error(\n '[lightning/graphql] No data surface available. ' +\n 'Either initialise globalThis.__sfdc_sdk__ with createDataSDK, ' +\n 'or run inside a ChatGPT / MCP Apps context.'\n );\n }\n\n const raw = await sdk.callTool({\n toolName: ${JSON.stringify(toolName)},\n params: { query, variables },\n });\n\n // Normalise result across surfaces:\n // - OpenAI surface: { result: \"<JSON string of { data, errors }>\" }\n // - MCP Apps surface: { structuredContent: { data, errors }, content: [...] }\n let result;\n if (raw?.structuredContent !== undefined) {\n result = raw.structuredContent;\n } else if (typeof raw?.result === 'string') {\n const parsed = JSON.parse(raw.result);\n if (Array.isArray(parsed)) {\n // MCP content array - extract text from first text block\n const textBlock = parsed.find(\n (b) => b && b.type === 'text' && typeof b.text === 'string',\n );\n const text = textBlock ? textBlock.text : null;\n if (text) {\n try { result = JSON.parse(text); } catch { result = { errors: [{ message: text }] }; }\n } else {\n result = {};\n }\n } else {\n result = parsed;\n }\n } else {\n result = raw ?? {};\n }\n\n this._emit({ data: result?.data, errors: result?.errors });\n } catch (error) {\n this._emit({ data: undefined, errors: [{ message: error.message }] });\n }\n }\n\n _emit({ data, errors }) {\n this._dataCallback({\n data,\n error: errors?.length ? errors : undefined,\n refresh: () => this.refresh(),\n });\n }\n}\n\nexport async function executeMutation(config) {\n const { query, variables } = config;\n if (!query) return { data: undefined, errors: [{ message: 'No query provided' }] };\n try {\n // 1. UIBundle / local dev\n if (typeof globalThis.__sfdc_sdk__?.graphql === 'function') {\n const result = await globalThis.__sfdc_sdk__.graphql(query, variables ?? {});\n return { data: result?.data, errors: result?.errors };\n }\n // 2. MCP surface\n const sdk = await getChatSDK();\n if (typeof sdk.callTool !== 'function') {\n throw new Error('[lightning/graphql] No data surface available.');\n }\n const raw = await sdk.callTool({\n toolName: ${JSON.stringify(toolName)},\n params: { query, variables: variables ?? {} },\n });\n let result;\n if (raw?.structuredContent !== undefined) {\n result = raw.structuredContent;\n } else if (typeof raw?.result === 'string') {\n const parsed = JSON.parse(raw.result);\n if (Array.isArray(parsed)) {\n const textBlock = parsed.find(\n (b) => b && b.type === 'text' && typeof b.text === 'string',\n );\n const text = textBlock ? textBlock.text : null;\n if (text) {\n try { result = JSON.parse(text); } catch { result = { errors: [{ message: text }] }; }\n } else {\n result = {};\n }\n } else {\n result = parsed;\n }\n } else {\n result = raw ?? {};\n }\n return { data: result?.data, errors: result?.errors };\n } catch (error) {\n return { data: undefined, errors: [{ message: error.message }] };\n }\n}\n`;\n}\n\nexport function lightningGraphql(options: LightningGraphqlOptions = {}): Provider {\n\tconst toolName = options.toolName ?? \"graphqlQuery\";\n\treturn {\n\t\tprefix: \"lightning/graphql\",\n\t\tresolve(specifier) {\n\t\t\tif (specifier !== \"lightning/graphql\") return null;\n\t\t\treturn buildGraphqlSource(toolName);\n\t\t},\n\t};\n}\n"],"names":[],"mappings":"AAOA,MAAM,iBAAyC;AAAA,EAC9C,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,gCAAgC;AAAA,EAChC,kCAAkC;AAAA,EAClC,mCAAmC;AAAA,EACnC,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,8BAA8B;AAC/B;AAEO,SAAS,MAAM,YAAoC,IAAc;AACvE,QAAM,WAAW,EAAE,GAAG,gBAAgB,GAAG,UAAA;AACzC,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,CAAC,UAAU,WAAW,oBAAoB,EAAG,QAAO;AAExD,YAAM,MAAM,UAAU,MAAM,qBAAqB,MAAM;AACvD,YAAM,gBAAgB,IACpB,MAAM,GAAG,EACT,GAAG,EAAE,EACL,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,MAAM,GAAG,EACjB,KAAA;AACF,YAAM,QAAQ,SAAS,GAAG,KAAK;AAC/B,aAAO,kBAAkB,K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AAAA;AAAA;AA8BhD;AAEO,SAAS,iBAAiB,UAAmC,IAAc;AACjF,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,cAAc,oBAAqB,QAAO;AAC9C,aAAO,mBAAmB,QAAQ;AAAA,IACnC;AAAA,EAAA;AAEF;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/providers/label.ts","../../src/providers/i18n.ts","../../src/providers/gate.ts","../../src/providers/access-check.ts","../../src/providers/client.ts","../../src/providers/primitive-utils.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst LABEL_DEFAULTS: Record<string, string> = {\n\t\"LightningForm.edit\": \"Edit\",\n\t\"LightningForm.save\": \"Save\",\n\t\"LightningForm.cancel\": \"Cancel\",\n\t\"LightningForm.error\": \"Error\",\n\t\"RecordDetailUC.Expand\": \"Expand\",\n\t\"RecordDetailUC.Collapse\": \"Collapse\",\n\t\"Global_Entity.created_by\": \"Created By\",\n\t\"Global_Entity.last_modified_by\": \"Last Modified By\",\n\t\"DetailError.GenericSaveError\": \"An error occurred while saving.\",\n\t\"MobileWebError.NoPreEditAccess\": \"You don't have access to edit this record.\",\n\t\"DuplicateList.ToastMessageBlock\": \"Duplicate records were found.\",\n\t\"DuplicateList.NonBlockingHeaderText\": \"Duplicate records found\",\n\t\"DuplicateList.ToastMessageAlertEdit\": \"Duplicate records were found. You can continue editing.\",\n\t\"Errors.ErrorPopoverHeading\": \"Error\",\n};\n\nexport function label(overrides: Record<string, string> = {}): Provider {\n\tconst defaults = { ...LABEL_DEFAULTS, ...overrides };\n\treturn {\n\t\tprefix: \"@salesforce/label/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/label/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/label/\".length);\n\t\t\tconst fallbackLabel = key\n\t\t\t\t.split(\".\")\n\t\t\t\t.at(-1)!\n\t\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t\t.replace(/_/g, \" \")\n\t\t\t\t.trim();\n\t\t\tconst value = defaults[key] ?? fallbackLabel;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\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 { Provider } from \"../types\";\n\nconst BROWSER_DERIVED = new Set([\n\t\"lang\",\n\t\"dir\",\n\t\"locale\",\n\t\"currency\",\n\t\"timeZone\",\n\t\"firstDayOfWeek\",\n]);\n\nconst STATIC_DEFAULTS: Record<string, string> = {\n\t\"dateTime.shortDateFormat\": \"M/d/yyyy\",\n\t\"dateTime.mediumDateFormat\": \"MMM d, yyyy\",\n\t\"dateTime.longDateFormat\": \"MMMM d, yyyy\",\n\t\"dateTime.shortTimeFormat\": \"h:mm a\",\n\t\"dateTime.mediumTimeFormat\": \"h:mm:ss a\",\n\t\"dateTime.longTimeFormat\": \"h:mm:ss a z\",\n\t\"dateTime.shortDateTimeFormat\": \"M/d/yyyy, h:mm a\",\n\t\"number.numberFormat\": \"#,##0.##\",\n\t\"number.currencyFormat\": \"¤#,##0.00\",\n\t\"number.decimalSeparator\": \".\",\n\t\"number.groupingSeparator\": \",\",\n\t\"number.percentFormat\": \"#,##0%\",\n\t\"number.percentSign\": \"%\",\n\t\"number.plusSign\": \"+\",\n\t\"number.minusSign\": \"-\",\n\t\"number.exponentialSign\": \"E\",\n\t\"number.superscriptingExponentSign\": \"×\",\n\t\"number.perMilleSign\": \"‰\",\n\t\"number.infinity\": \"∞\",\n\t\"number.nan\": \"NaN\",\n\t\"number.currencySymbol\": \"$\",\n\tdefaultCalendar: \"gregory\",\n\tdefaultNumberingSystem: \"latn\",\n};\n\nconst MONTHS_WIDE = [\n\t\"January\",\n\t\"February\",\n\t\"March\",\n\t\"April\",\n\t\"May\",\n\t\"June\",\n\t\"July\",\n\t\"August\",\n\t\"September\",\n\t\"October\",\n\t\"November\",\n\t\"December\",\n];\nconst MONTHS_ABBR = [\n\t\"Jan\",\n\t\"Feb\",\n\t\"Mar\",\n\t\"Apr\",\n\t\"May\",\n\t\"Jun\",\n\t\"Jul\",\n\t\"Aug\",\n\t\"Sep\",\n\t\"Oct\",\n\t\"Nov\",\n\t\"Dec\",\n];\nconst DAYS_WIDE = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\nconst DAYS_ABBR = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nconst OBJECT_DEFAULTS: Record<string, unknown> = {\n\t\"common.digits\": { latn: \"0123456789\" },\n\t\"common.calendarData\": {\n\t\tgregory: { calendarSystem: \"solar\", eras: {} },\n\t},\n\tcalendarData: {\n\t\tgregory: {\n\t\t\tmonths: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: MONTHS_WIDE,\n\t\t\t\t\tabbreviated: MONTHS_ABBR,\n\t\t\t\t\tnarrow: MONTHS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdays: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: DAYS_WIDE,\n\t\t\t\t\tabbreviated: DAYS_ABBR,\n\t\t\t\t\tnarrow: DAYS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdayPeriods: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: [\"AM\", \"PM\"],\n\t\t\t\t\tabbreviated: [\"am\", \"pm\"],\n\t\t\t\t\tnarrow: [\"a\", \"p\"],\n\t\t\t\t},\n\t\t\t},\n\t\t\teras: {\n\t\t\t\teraAbbr: [\"AD\"],\n\t\t\t\teraNames: [\"Anno Domini\"],\n\t\t\t\teraNarrow: [\"A\"],\n\t\t\t},\n\t\t},\n\t},\n};\n\nconst RUNTIME_SOURCE = `\nconst RTL_LANGS = new Set([\n 'ar', 'arc', 'dv', 'fa', 'ha', 'he', 'khw', 'ks', 'ku', 'ps', 'ur', 'yi',\n]);\n\nfunction getLocale() {\n if (typeof navigator === 'undefined') return 'en-US';\n return navigator.language || 'en-US';\n}\n\nfunction getLang() {\n return getLocale().split('-')[0];\n}\n\nfunction getDir() {\n return RTL_LANGS.has(getLang()) ? 'rtl' : 'ltr';\n}\n\nfunction getCurrency() {\n try {\n const parts = new Intl.NumberFormat(getLocale(), {\n style: 'currency',\n currency: 'USD',\n currencyDisplay: 'code',\n }).resolvedOptions();\n return parts.currency || 'USD';\n } catch {\n return 'USD';\n }\n}\n\nfunction getTimeZone() {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';\n } catch {\n return 'UTC';\n }\n}\n\nfunction getFirstDayOfWeek() {\n try {\n const loc = new Intl.Locale(getLocale());\n if (loc.weekInfo) return String(loc.weekInfo.firstDay);\n if (typeof loc.getWeekInfo === 'function') return String(loc.getWeekInfo().firstDay);\n } catch { /* unsupported in this browser */ }\n return '7';\n}\n\nconst values = {\n lang: getLang(),\n dir: getDir(),\n locale: getLocale(),\n currency: getCurrency(),\n timeZone: getTimeZone(),\n firstDayOfWeek: getFirstDayOfWeek(),\n};\n\nexport default values['__KEY__'];\n`;\n\nexport interface I18nOptions {\n\tstaticOverrides?: Record<string, string>;\n\tobjectOverrides?: Record<string, unknown>;\n}\n\nexport function i18n(options: I18nOptions = {}): Provider {\n\tconst { staticOverrides = {}, objectOverrides = {} } = options;\n\tconst statics = { ...STATIC_DEFAULTS, ...staticOverrides };\n\tconst objects = { ...OBJECT_DEFAULTS, ...objectOverrides };\n\n\treturn {\n\t\tprefix: \"@salesforce/i18n/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/i18n/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/i18n/\".length);\n\n\t\t\tif (BROWSER_DERIVED.has(key)) {\n\t\t\t\treturn RUNTIME_SOURCE.replace(\"__KEY__\", key);\n\t\t\t}\n\n\t\t\tif (key in objects) {\n\t\t\t\treturn `export default ${JSON.stringify(objects[key])};`;\n\t\t\t}\n\n\t\t\tconst value = statics[key] ?? key;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\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 { Provider } from \"../types\";\n\nexport function gate(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/gate/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/gate/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/gate/\".length);\n\t\t\tconst isOpen = overrides[name] ?? true;\n\t\t\treturn `export default { isOpen: () => ${isOpen} };`;\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 { Provider } from \"../types\";\n\nexport function accessCheck(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/accessCheck/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/accessCheck/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/accessCheck/\".length);\n\t\t\tconst value = overrides[name] ?? false;\n\t\t\treturn `export default ${value};`;\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 { Provider } from \"../types\";\n\nconst FORM_FACTOR_SOURCE = `\nfunction getFormFactor() {\n if (typeof window === 'undefined') return 'Large';\n if (window.matchMedia('(max-width: 767px)').matches) return 'Small';\n if (window.matchMedia('(max-width: 1023px)').matches) return 'Medium';\n return 'Large';\n}\n\nexport default getFormFactor();\n`;\n\nexport function client(): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/client/\",\n\t\tresolve(specifier) {\n\t\t\tif (specifier === \"@salesforce/client/formFactor\") {\n\t\t\t\treturn FORM_FACTOR_SOURCE;\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 { Provider } from \"../types\";\n\nexport function primitiveUtils(): Provider {\n\treturn {\n\t\tprefix: \"lightning/primitiveUtils\",\n\t\tmatch(id) {\n\t\t\treturn id === \"lightning/primitiveUtils\";\n\t\t},\n\t\tresolve(specifier) {\n\t\t\tif (specifier !== \"lightning/primitiveUtils\") return null;\n\n\t\t\treturn `export function normalizeBoolean(value) {\n return typeof value === 'string' || !!value;\n}\n\nexport function reflectAttribute(element, attrName, value) {\n if (!element) return;\n if (typeof value === 'string') {\n element.setAttribute(attrName, value);\n } else if (value === true) {\n element.setAttribute(attrName, '');\n } else if (!value) {\n element.removeAttribute(attrName);\n } else {\n console.warn(\\`Invalid attribute value for \"\\${attrName}\": \\${value}\\`);\n }\n}\n`;\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAyC;AAAA,EAC9C,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,gCAAgC;AAAA,EAChC,kCAAkC;AAAA,EAClC,mCAAmC;AAAA,EACnC,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,8BAA8B;AAC/B;AAEO,SAAS,MAAM,YAAoC,IAAc;AACvE,QAAM,WAAW,EAAE,GAAG,gBAAgB,GAAG,UAAA;AACzC,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,CAAC,UAAU,WAAW,oBAAoB,EAAG,QAAO;AAExD,YAAM,MA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ClC,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,cAAc,iCAAiC;AAClD,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAAA,EAAA;AAEF;ACrBO,SAAS,iBAA2B;AAC1C,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,MAAM,IAAI;AACT,aAAO,OAAO;AAAA,IACf;AAAA,IACA,QAAQ,WAAW;AAClB,UAAI,cAAc,2BAA4B,QAAO;AAErD,aAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAiBR;AAAA,EAAA;AAEF;;;;;;;;;;;;"}
@@ -0,0 +1,10 @@
1
+ import { Plugin } from 'vite';
2
+ import { JsonSchema } from './types';
3
+ export interface LdsWireAdapterConfig {
4
+ type: "wire";
5
+ toolName: string;
6
+ configJsonSchema: JsonSchema;
7
+ }
8
+ export type LdsAdapterRegistry = Record<string, Record<string, LdsWireAdapterConfig>>;
9
+ export declare function lds(adapters?: LdsAdapterRegistry): Plugin;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,UAAU,CAAC;CAC7B;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;AA+BtF,wBAAgB,GAAG,CAAC,QAAQ,GAAE,kBAAqC,GAAG,MAAM,CAqF3E"}