@salesforce/vite-plugin-lwc-ui-bundle 1.131.3 → 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.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +3 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +4 -163
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/lds/index.d.ts +10 -0
- package/dist/providers/lds/index.d.ts.map +1 -0
- package/dist/providers/lds/index.js +106 -0
- package/dist/providers/lds/index.js.map +1 -0
- package/dist/providers/lds/runtime.js +96 -0
- package/dist/providers/lds/runtime.js.map +1 -0
- package/dist/providers/lds/types.d.ts +22 -0
- package/dist/providers/lds/types.d.ts.map +1 -0
- package/dist/providers/lightning-graphql/index.d.ts +10 -0
- package/dist/providers/lightning-graphql/index.d.ts.map +1 -0
- package/dist/providers/lightning-graphql/index.js +24 -0
- package/dist/providers/lightning-graphql/index.js.map +1 -0
- package/dist/providers/lightning-graphql/runtime.js +103 -0
- package/dist/providers/lightning-graphql/runtime.js.map +1 -0
- package/dist/providers/shared/normalize-mcp-response.d.ts +20 -0
- package/dist/providers/shared/normalize-mcp-response.d.ts.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -5
- package/dist/providers/lightning-graphql.d.ts +0 -17
- package/dist/providers/lightning-graphql.d.ts.map +0 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
-
|
|
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
|
|
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.client","builtinProviders.gate","builtinProviders.primitiveUtils","builtinProviders.lightningGraphql","require"],"mappings":";;;;;;;AASO,SAAS,gBAAgB,OAA+B,IAAwB;AACtF,QAAM,UAA8B,CAAA;AAEpC,aAAW,OAAO,MAAM;AACvB,UAAM,UAAU,OAAO,QAAQ,WAAW,MAAM,IAAI;AACpD,UAAM,YAAY,OAAO,QAAQ,WAAW,SAAY,IAAI;AAC5D,UAAM,cAAc,KAAK,QAAQ,OAAO;AAEx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AAA,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,YAAY,OAAO,QAAQ,WAAW,SAAY,IAAI;AAC5D,UAAM,cAAc,KAAK,QAAQ,OAAO;AAExC,QAAI,CAAC,WAAW,WAAW,KAAK,CAAC,SAAS,WAAW,EAAE,eAAe;AACrE;AAAA,IACD;AAEA,QAAI,WAAW;AAEd,iBAAW,QAAQ,YAAY,WAAW,GAAG;AAC5C,cAAM,WAAW,KAAK,KAAK,aAAa,IAAI;AAC5C,YAAI,CAAC,SAAS,QAAQ,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;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,
|
|
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"}
|
package/dist/providers/index.js
CHANGED
|
@@ -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: 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: 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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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,GA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kBAAkB,KAAK;AAAA,IAC/B;AAAA,EAAA;AAEF;ACVA,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWpB,SAAS,SAAmB;AAClC,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"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { init, parse } from "es-module-lexer";
|
|
5
|
+
import MagicString from "magic-string";
|
|
6
|
+
const ADAPTER_PREFIX = "sf-lds-adapter:";
|
|
7
|
+
const ADAPTER_ID_PREFIX = "\0" + ADAPTER_PREFIX;
|
|
8
|
+
const adapterBaseSource = readFileSync(
|
|
9
|
+
join(dirname(fileURLToPath(import.meta.url)), "runtime.js"),
|
|
10
|
+
"utf-8"
|
|
11
|
+
);
|
|
12
|
+
const DEFAULT_ADAPTERS = {
|
|
13
|
+
"lightning/uiRecordApi": {
|
|
14
|
+
getRecord: {
|
|
15
|
+
type: "wire",
|
|
16
|
+
toolName: "getRecordMcpTool",
|
|
17
|
+
configJsonSchema: {
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
recordId: { type: "string" },
|
|
21
|
+
fields: { type: "array", items: { type: "string" } }
|
|
22
|
+
},
|
|
23
|
+
required: ["recordId"]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function parseImportSpecifiers(bracesContent) {
|
|
29
|
+
return bracesContent.split(",").map((s) => s.trim()).filter(Boolean).map((entry) => {
|
|
30
|
+
const asIdx = entry.indexOf(" as ");
|
|
31
|
+
const original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();
|
|
32
|
+
return { original, full: entry };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function lds(adapters = DEFAULT_ADAPTERS) {
|
|
36
|
+
const specifierSnippets = Object.keys(adapters).flatMap((s) => [`'${s}'`, `"${s}"`]);
|
|
37
|
+
return {
|
|
38
|
+
name: "vite-plugin-lds",
|
|
39
|
+
enforce: "pre",
|
|
40
|
+
async transform(code, id) {
|
|
41
|
+
const cleanId = id.split("?")[0] ?? id;
|
|
42
|
+
if (!cleanId.endsWith(".js") && !cleanId.endsWith(".ts")) return null;
|
|
43
|
+
if (cleanId.includes("/node_modules/")) return null;
|
|
44
|
+
if (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;
|
|
45
|
+
await init;
|
|
46
|
+
let imports;
|
|
47
|
+
try {
|
|
48
|
+
[imports] = parse(code);
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const relevant = imports.filter(
|
|
53
|
+
(imp) => imp.d === -1 && imp.n !== void 0 && imp.n in adapters
|
|
54
|
+
);
|
|
55
|
+
if (relevant.length === 0) return null;
|
|
56
|
+
const s = new MagicString(code);
|
|
57
|
+
let changed = false;
|
|
58
|
+
for (const imp of relevant) {
|
|
59
|
+
const { ss: start, se: end, n: specifier } = imp;
|
|
60
|
+
const statement = code.slice(start, end);
|
|
61
|
+
const openBrace = statement.indexOf("{");
|
|
62
|
+
const closeBrace = statement.indexOf("}");
|
|
63
|
+
if (openBrace === -1 || closeBrace === -1) continue;
|
|
64
|
+
const bracesContent = statement.slice(openBrace + 1, closeBrace);
|
|
65
|
+
const moduleAdapters = adapters[specifier];
|
|
66
|
+
const parsedImport = parseImportSpecifiers(bracesContent);
|
|
67
|
+
const registered = parsedImport.filter((p) => p.original in moduleAdapters);
|
|
68
|
+
const unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));
|
|
69
|
+
if (registered.length === 0) continue;
|
|
70
|
+
const parts = [
|
|
71
|
+
`import { ${registered.map((p) => p.full).join(", ")} } from '${ADAPTER_PREFIX}${specifier}';`
|
|
72
|
+
];
|
|
73
|
+
if (unregistered.length > 0) {
|
|
74
|
+
parts.push(
|
|
75
|
+
`import { ${unregistered.map((p) => p.full).join(", ")} } from '${specifier}';`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
s.overwrite(start, end, parts.join("\n"));
|
|
79
|
+
changed = true;
|
|
80
|
+
}
|
|
81
|
+
if (!changed) return null;
|
|
82
|
+
return { code: s.toString(), map: s.generateMap({ hires: true }) };
|
|
83
|
+
},
|
|
84
|
+
resolveId(id) {
|
|
85
|
+
if (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);
|
|
86
|
+
return null;
|
|
87
|
+
},
|
|
88
|
+
load(id) {
|
|
89
|
+
if (!id.startsWith(ADAPTER_ID_PREFIX)) return null;
|
|
90
|
+
const specifier = id.slice(ADAPTER_ID_PREFIX.length);
|
|
91
|
+
const moduleAdapters = adapters[specifier];
|
|
92
|
+
if (!moduleAdapters) return null;
|
|
93
|
+
const lines = [adapterBaseSource];
|
|
94
|
+
for (const [name, { type: _type, ...cfg }] of Object.entries(moduleAdapters)) {
|
|
95
|
+
lines.push(
|
|
96
|
+
`export const ${name} = createWireAdapter(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return lines.join("\n");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
lds
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/providers/lds/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { init, parse } from \"es-module-lexer\";\nimport MagicString from \"magic-string\";\nimport type { Plugin } from \"vite\";\nimport type { JsonSchema } from \"./types\";\n\nconst ADAPTER_PREFIX = \"sf-lds-adapter:\";\nconst ADAPTER_ID_PREFIX = \"\\0\" + ADAPTER_PREFIX;\n\nconst adapterBaseSource = readFileSync(\n\tjoin(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"),\n\t\"utf-8\",\n);\n\nexport interface LdsWireAdapterConfig {\n\ttype: \"wire\";\n\ttoolName: string;\n\tconfigJsonSchema: JsonSchema;\n}\n\nexport type LdsAdapterRegistry = Record<string, Record<string, LdsWireAdapterConfig>>;\n\nconst DEFAULT_ADAPTERS: LdsAdapterRegistry = {\n\t\"lightning/uiRecordApi\": {\n\t\tgetRecord: {\n\t\t\ttype: \"wire\",\n\t\t\ttoolName: \"getRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tfields: { type: \"array\", items: { type: \"string\" } },\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\"],\n\t\t\t},\n\t\t},\n\t},\n};\n\nfunction parseImportSpecifiers(bracesContent: string): { original: string; full: string }[] {\n\treturn bracesContent\n\t\t.split(\",\")\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst asIdx = entry.indexOf(\" as \");\n\t\t\tconst original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();\n\t\t\treturn { original, full: entry };\n\t\t});\n}\n\nexport function lds(adapters: LdsAdapterRegistry = DEFAULT_ADAPTERS): Plugin {\n\tconst specifierSnippets = Object.keys(adapters).flatMap((s) => [`'${s}'`, `\"${s}\"`]);\n\n\treturn {\n\t\tname: \"vite-plugin-lds\",\n\t\tenforce: \"pre\",\n\n\t\tasync transform(code, id) {\n\t\t\tconst cleanId = id.split(\"?\")[0] ?? id;\n\t\t\tif (!cleanId.endsWith(\".js\") && !cleanId.endsWith(\".ts\")) return null;\n\t\t\tif (cleanId.includes(\"/node_modules/\")) return null;\n\t\t\tif (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;\n\n\t\t\tawait init;\n\n\t\t\tlet imports: ReturnType<typeof parse>[0];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code);\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst relevant = imports.filter(\n\t\t\t\t(imp) => imp.d === -1 && imp.n !== undefined && imp.n in adapters,\n\t\t\t);\n\t\t\tif (relevant.length === 0) return null;\n\n\t\t\tconst s = new MagicString(code);\n\t\t\tlet changed = false;\n\n\t\t\tfor (const imp of relevant) {\n\t\t\t\tconst { ss: start, se: end, n: specifier } = imp;\n\t\t\t\tconst statement = code.slice(start, end);\n\n\t\t\t\tconst openBrace = statement.indexOf(\"{\");\n\t\t\t\tconst closeBrace = statement.indexOf(\"}\");\n\t\t\t\tif (openBrace === -1 || closeBrace === -1) continue;\n\n\t\t\t\tconst bracesContent = statement.slice(openBrace + 1, closeBrace);\n\t\t\t\tconst moduleAdapters = adapters[specifier!]!;\n\t\t\t\tconst parsedImport = parseImportSpecifiers(bracesContent);\n\t\t\t\tconst registered = parsedImport.filter((p) => p.original in moduleAdapters);\n\t\t\t\tconst unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));\n\n\t\t\t\tif (registered.length === 0) continue;\n\n\t\t\t\tconst parts: string[] = [\n\t\t\t\t\t`import { ${registered.map((p) => p.full).join(\", \")} } from '${ADAPTER_PREFIX}${specifier}';`,\n\t\t\t\t];\n\n\t\t\t\tif (unregistered.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`import { ${unregistered.map((p) => p.full).join(\", \")} } from '${specifier}';`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ts.overwrite(start, end, parts.join(\"\\n\"));\n\t\t\t\tchanged = true;\n\t\t\t}\n\n\t\t\tif (!changed) return null;\n\t\t\treturn { code: s.toString(), map: s.generateMap({ hires: true }) };\n\t\t},\n\n\t\tresolveId(id) {\n\t\t\tif (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(ADAPTER_ID_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(ADAPTER_ID_PREFIX.length);\n\t\t\tconst moduleAdapters = adapters[specifier];\n\t\t\tif (!moduleAdapters) return null;\n\n\t\t\tconst lines: string[] = [adapterBaseSource];\n\t\t\tfor (const [name, { type: _type, ...cfg }] of Object.entries(moduleAdapters)) {\n\t\t\t\tlines.push(\n\t\t\t\t\t`export const ${name} = createWireAdapter(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn lines.join(\"\\n\");\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;;;;AAaA,MAAM,iBAAiB;AACvB,MAAM,oBAAoB,OAAO;AAEjC,MAAM,oBAAoB;AAAA,EACzB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,YAAY;AAAA,EAC1D;AACD;AAUA,MAAM,mBAAuC;AAAA,EAC5C,yBAAyB;AAAA,IACxB,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,kBAAkB;AAAA,QACjB,MAAM;AAAA,QACN,YAAY;AAAA,UACX,UAAU,EAAE,MAAM,SAAA;AAAA,UAClB,QAAQ,EAAE,MAAM,SAAS,OAAO,EAAE,MAAM,WAAS;AAAA,QAAE;AAAA,QAEpD,UAAU,CAAC,UAAU;AAAA,MAAA;AAAA,IACtB;AAAA,EACD;AAEF;AAEA,SAAS,sBAAsB,eAA6D;AAC3F,SAAO,cACL,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAA,CAAM,EACnB,OAAO,OAAO,EACd,IAAI,CAAC,UAAU;AACf,UAAM,QAAQ,MAAM,QAAQ,MAAM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,KAAK,UAAU,GAAG,CAAC;AAAA,QAAA;AAAA,MAE1F;AACA,aAAO,MAAM,KAAK,IAAI;AAAA,IACvB;AAAA,EAAA;AAEF;"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { getChatSDK } from "@salesforce/sdk-chat";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
function normalizeMcpResponse(raw) {
|
|
4
|
+
if (raw && typeof raw === "object" && "structuredContent" in raw) {
|
|
5
|
+
return raw.structuredContent;
|
|
6
|
+
}
|
|
7
|
+
if (raw && typeof raw === "object" && typeof raw.result === "string") {
|
|
8
|
+
const parsed = JSON.parse(raw.result);
|
|
9
|
+
if (Array.isArray(parsed)) {
|
|
10
|
+
const textBlock = parsed.find(
|
|
11
|
+
(b) => b && b.type === "text" && typeof b.text === "string"
|
|
12
|
+
);
|
|
13
|
+
const text = textBlock ? textBlock.text : null;
|
|
14
|
+
if (text) {
|
|
15
|
+
return JSON.parse(text);
|
|
16
|
+
}
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
return raw ?? {};
|
|
22
|
+
}
|
|
23
|
+
function buildSchema(schema) {
|
|
24
|
+
switch (schema.type) {
|
|
25
|
+
case "string":
|
|
26
|
+
return z.string();
|
|
27
|
+
case "number":
|
|
28
|
+
return z.number();
|
|
29
|
+
case "integer":
|
|
30
|
+
return z.number().int();
|
|
31
|
+
case "boolean":
|
|
32
|
+
return z.boolean();
|
|
33
|
+
case "array":
|
|
34
|
+
return z.array(buildSchema(schema.items));
|
|
35
|
+
case "object": {
|
|
36
|
+
const required = new Set(schema.required ?? []);
|
|
37
|
+
const shape = Object.fromEntries(
|
|
38
|
+
Object.entries(schema.properties ?? {}).map(
|
|
39
|
+
([key, val]) => [key, required.has(key) ? buildSchema(val) : buildSchema(val).optional()]
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
return z.object(shape);
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
return z.unknown();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function createWireAdapter(name, cfg) {
|
|
49
|
+
const toolName = cfg.toolName;
|
|
50
|
+
const schema = buildSchema(cfg.configJsonSchema);
|
|
51
|
+
class McpToolBackedWireAdapter {
|
|
52
|
+
callback;
|
|
53
|
+
config = null;
|
|
54
|
+
constructor(callback) {
|
|
55
|
+
this.callback = callback;
|
|
56
|
+
this.config = null;
|
|
57
|
+
}
|
|
58
|
+
connect() {
|
|
59
|
+
this.run();
|
|
60
|
+
}
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
62
|
+
disconnect() {
|
|
63
|
+
}
|
|
64
|
+
update(config) {
|
|
65
|
+
this.config = config;
|
|
66
|
+
this.run();
|
|
67
|
+
}
|
|
68
|
+
async run() {
|
|
69
|
+
if (!schema.safeParse(this.config).success) {
|
|
70
|
+
this.callback({ data: void 0, error: void 0 });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const app = await getChatSDK();
|
|
75
|
+
if (!app.callTool) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`[${name}] sdk.callTool is not available on this surface. Make sure window.openai is configured or the component is running in an MCP Apps / OpenAI chat context.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const raw = await app.callTool({
|
|
81
|
+
toolName,
|
|
82
|
+
params: this.config ?? void 0
|
|
83
|
+
});
|
|
84
|
+
const result = normalizeMcpResponse(raw);
|
|
85
|
+
this.callback({ data: result?.data, error: result?.error });
|
|
86
|
+
} catch (e) {
|
|
87
|
+
this.callback({ data: void 0, error: e });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return McpToolBackedWireAdapter;
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
createWireAdapter
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":["../../../src/providers/shared/normalize-mcp-response.ts","../../../src/providers/lds/runtime.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\n/**\n * Unwraps the MCP tool transport envelope and returns the tool's payload as-is.\n *\n * Handles the three surface shapes `sdk.callTool()` can resolve with:\n * - MCP Apps surface: `{ structuredContent, content }`\n * - OpenAI surface: `{ result: \"<JSON string>\" }`, where the JSON may itself be\n * an MCP content array (`[{ type: 'text', text: \"<JSON string>\" }, ...]`)\n * - Fallback: the raw value returned by `callTool`\n *\n * The shape of the unwrapped payload is the tool's responsibility — this helper\n * does not project out `data` / `error` / `errors`. Callers read whichever keys\n * their tool contract defines.\n */\nexport function normalizeMcpResponse(raw: unknown): unknown {\n\tif (raw && typeof raw === \"object\" && \"structuredContent\" in raw) {\n\t\treturn (raw as { structuredContent: unknown }).structuredContent;\n\t}\n\n\tif (raw && typeof raw === \"object\" && typeof (raw as { result?: unknown }).result === \"string\") {\n\t\tconst parsed = JSON.parse((raw as { result: string }).result);\n\t\tif (Array.isArray(parsed)) {\n\t\t\tconst textBlock = parsed.find(\n\t\t\t\t(b: { type?: string; text?: string }) =>\n\t\t\t\t\tb && b.type === \"text\" && typeof b.text === \"string\",\n\t\t\t);\n\t\t\tconst text = textBlock ? textBlock.text : null;\n\t\t\tif (text) {\n\t\t\t\treturn JSON.parse(text);\n\t\t\t}\n\t\t\treturn {};\n\t\t}\n\t\treturn parsed;\n\t}\n\n\treturn raw ?? {};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { getChatSDK } from \"@salesforce/sdk-chat\";\nimport { z, type ZodType } from \"zod\";\nimport type { JsonSchema } from \"./types\";\nimport { normalizeMcpResponse } from \"../shared/normalize-mcp-response\";\n\nexport type { JsonSchema };\n\ntype WireCallback = (result: { data: unknown; error: unknown }) => void;\n\nfunction buildSchema(schema: JsonSchema): ZodType {\n\tswitch (schema.type) {\n\t\tcase \"string\":\n\t\t\treturn z.string();\n\t\tcase \"number\":\n\t\t\treturn z.number();\n\t\tcase \"integer\":\n\t\t\treturn z.number().int();\n\t\tcase \"boolean\":\n\t\t\treturn z.boolean();\n\t\tcase \"array\":\n\t\t\treturn z.array(buildSchema(schema.items as JsonSchema));\n\t\tcase \"object\": {\n\t\t\tconst required = new Set<string>((schema.required as string[]) ?? []);\n\t\t\tconst shape = Object.fromEntries(\n\t\t\t\tObject.entries((schema.properties as Record<string, JsonSchema>) ?? {}).map(\n\t\t\t\t\t([key, val]) => [key, required.has(key) ? buildSchema(val) : buildSchema(val).optional()],\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn z.object(shape);\n\t\t}\n\t\tdefault:\n\t\t\treturn z.unknown();\n\t}\n}\n\ninterface AdapterConfig {\n\ttoolName: string;\n\tconfigJsonSchema: JsonSchema;\n}\n\nexport function createWireAdapter(name: string, cfg: AdapterConfig) {\n\tconst toolName = cfg.toolName;\n\tconst schema = buildSchema(cfg.configJsonSchema);\n\tclass McpToolBackedWireAdapter {\n\t\tcallback: WireCallback;\n\t\tconfig: Record<string, unknown> | null = null;\n\n\t\tconstructor(callback: WireCallback) {\n\t\t\tthis.callback = callback;\n\t\t\tthis.config = null;\n\t\t}\n\n\t\tconnect() {\n\t\t\tthis.run();\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\t\tdisconnect() {}\n\n\t\tupdate(config: Record<string, unknown> | null) {\n\t\t\tthis.config = config;\n\t\t\tthis.run();\n\t\t}\n\n\t\tasync run() {\n\t\t\tif (!schema.safeParse(this.config).success) {\n\t\t\t\tthis.callback({ data: undefined, error: undefined });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst app = await getChatSDK();\n\n\t\t\t\tif (!app.callTool) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[${name}] sdk.callTool is not available on this surface. ` +\n\t\t\t\t\t\t\t\"Make sure window.openai is configured or the component is running in \" +\n\t\t\t\t\t\t\t\"an MCP Apps / OpenAI chat context.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst raw = await app.callTool({\n\t\t\t\t\ttoolName,\n\t\t\t\t\tparams: this.config ?? undefined,\n\t\t\t\t});\n\n\t\t\t\tconst result = normalizeMcpResponse(raw) as { data?: unknown; error?: unknown };\n\n\t\t\t\tthis.callback({ data: result?.data, error: result?.error });\n\t\t\t} catch (e) {\n\t\t\t\tthis.callback({ data: undefined, error: e });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn McpToolBackedWireAdapter;\n}\n"],"names":[],"mappings":";;AAmBO,SAAS,qBAAqB,KAAuB;AAC3D,MAAI,OAAO,OAAO,QAAQ,YAAY,uBAAuB,KAAK;AACjE,WAAQ,IAAuC;AAAA,EAChD;AAEA,MAAI,OAAO,OAAO,QAAQ,YAAY,OAAQ,IAA6B,WAAW,UAAU;AAC/F,UAAM,SAAS,KAAK,MAAO,IAA2B,MAAM;AAC5D,QAAI,MAAM,QAAQ,MAAM,GAAG;AAC1B,YAAM,YAAY,OAAO;AAAA,QACxB,CAAC,MACA,KAAK,EAAE,SAAS,UAAU,OAAO,EAAE,SAAS;AAAA,MAAA;AAE9C,YAAM,OAAO,YAAY,UAAU,OAAO;AAC1C,UAAI,MAAM;AACT,eAAO,KAAK,MAAM,IAAI;AAAA,MACvB;AACA,aAAO,CAAA;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAEA,SAAO,OAAO,CAAA;AACf;AC3BA,SAAS,YAAY,QAA6B;AACjD,UAAQ,OAAO,MAAA;AAAA,IACd,KAAK;AACJ,aAAO,EAAE,OAAA;AAAA,IACV,KAAK;AACJ,aAAO,EAAE,OAAA;AAAA,IACV,KAAK;AACJ,aAAO,EAAE,OAAA,EAAS,IAAA;AAAA,IACnB,KAAK;AACJ,aAAO,EAAE,QAAA;AAAA,IACV,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AAqB,GAAG;AAEvC,aAAK,SAAS,EAAE,MAAM,QAAQ,MAAM,OAAO,QAAQ,OAAO;AAAA,MAC3D,SAAS,GAAG;AACX,aAAK,SAAS,EAAE,MAAM,QAAW,OAAO,GAAG;AAAA,MAC5C;AAAA,IACD;AAAA,EAAA;AAGD,SAAO;AACR;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export type JsonSchema = {
|
|
7
|
+
type: "string";
|
|
8
|
+
} | {
|
|
9
|
+
type: "number";
|
|
10
|
+
} | {
|
|
11
|
+
type: "integer";
|
|
12
|
+
} | {
|
|
13
|
+
type: "boolean";
|
|
14
|
+
} | {
|
|
15
|
+
type: "array";
|
|
16
|
+
items: JsonSchema;
|
|
17
|
+
} | {
|
|
18
|
+
type: "object";
|
|
19
|
+
properties?: Record<string, JsonSchema>;
|
|
20
|
+
required?: string[];
|
|
21
|
+
} | Record<string, unknown>;
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,UAAU,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAChF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Provider } from '../../types';
|
|
2
|
+
export interface LightningGraphqlOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Name of the MCP tool to call for GraphQL query execution.
|
|
5
|
+
* Defaults to `'graphqlQuery'`.
|
|
6
|
+
*/
|
|
7
|
+
toolName?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function lightningGraphql(options?: LightningGraphqlOptions): Provider;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/lightning-graphql/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,uBAAuB;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAOD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,QAAQ,CAUhF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const runtimeSource = readFileSync(
|
|
5
|
+
join(dirname(fileURLToPath(import.meta.url)), "runtime.js"),
|
|
6
|
+
"utf-8"
|
|
7
|
+
);
|
|
8
|
+
function lightningGraphql(options = {}) {
|
|
9
|
+
const toolName = options.toolName ?? "graphqlQuery";
|
|
10
|
+
const source = `${runtimeSource}
|
|
11
|
+
TOOL_NAME = ${JSON.stringify(toolName)};
|
|
12
|
+
`;
|
|
13
|
+
return {
|
|
14
|
+
match: (id) => id === "lightning/graphql",
|
|
15
|
+
resolve(specifier) {
|
|
16
|
+
if (specifier !== "lightning/graphql") return null;
|
|
17
|
+
return source;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
lightningGraphql
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/providers/lightning-graphql/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { 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\ttoolName?: string;\n}\n\nconst runtimeSource = readFileSync(\n\tjoin(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"),\n\t\"utf-8\",\n);\n\nexport function lightningGraphql(options: LightningGraphqlOptions = {}): Provider {\n\tconst toolName = options.toolName ?? \"graphqlQuery\";\n\tconst source = `${runtimeSource}\\nTOOL_NAME = ${JSON.stringify(toolName)};\\n`;\n\treturn {\n\t\tmatch: (id) => id === \"lightning/graphql\",\n\t\tresolve(specifier) {\n\t\t\tif (specifier !== \"lightning/graphql\") return null;\n\t\t\treturn source;\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;;AAkBA,MAAM,gBAAgB;AAAA,EACrB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,YAAY;AAAA,EAC1D;AACD;AAEO,SAAS,iBAAiB,UAAmC,IAAc;AACjF,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,SAAS,GAAG,aAAa;AAAA,cAAiB,KAAK,UAAU,QAAQ,CAAC;AAAA;AACxE,SAAO;AAAA,IACN,OAAO,CAAC,OAAO,OAAO;AAAA,IACtB,QAAQ,WAAW;AAClB,UAAI,cAAc,oBAAqB,QAAO;AAC9C,aAAO;AAAA,IACR;AAAA,EAAA;AAEF;"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { getChatSDK } from "@salesforce/sdk-chat";
|
|
2
|
+
function normalizeMcpResponse(raw) {
|
|
3
|
+
if (raw && typeof raw === "object" && "structuredContent" in raw) {
|
|
4
|
+
return raw.structuredContent;
|
|
5
|
+
}
|
|
6
|
+
if (raw && typeof raw === "object" && typeof raw.result === "string") {
|
|
7
|
+
const parsed = JSON.parse(raw.result);
|
|
8
|
+
if (Array.isArray(parsed)) {
|
|
9
|
+
const textBlock = parsed.find(
|
|
10
|
+
(b) => b && b.type === "text" && typeof b.text === "string"
|
|
11
|
+
);
|
|
12
|
+
const text = textBlock ? textBlock.text : null;
|
|
13
|
+
if (text) {
|
|
14
|
+
return JSON.parse(text);
|
|
15
|
+
}
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
return parsed;
|
|
19
|
+
}
|
|
20
|
+
return raw ?? {};
|
|
21
|
+
}
|
|
22
|
+
let TOOL_NAME = "graphqlQuery";
|
|
23
|
+
function gql(strings, ...values) {
|
|
24
|
+
let result = "";
|
|
25
|
+
strings.forEach((string, i) => {
|
|
26
|
+
result += string;
|
|
27
|
+
if (i < values.length) result += String(values[i]);
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
async function runQuery(config) {
|
|
32
|
+
const { query, variables } = config;
|
|
33
|
+
if (!query) return { data: void 0, errors: void 0 };
|
|
34
|
+
if (typeof globalThis.__sfdc_sdk__ === "object" && typeof globalThis.__sfdc_sdk__?.graphql === "function") {
|
|
35
|
+
const sdkGraphql = globalThis.__sfdc_sdk__.graphql;
|
|
36
|
+
const result = await sdkGraphql({ query, variables: variables ?? {} });
|
|
37
|
+
return { data: result?.data, errors: result?.errors };
|
|
38
|
+
}
|
|
39
|
+
const sdk = await getChatSDK();
|
|
40
|
+
if (typeof sdk.callTool !== "function") {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"[lightning/graphql] No data surface available. Either initialise globalThis.__sfdc_sdk__ with createDataSDK, or run inside a ChatGPT / MCP Apps context."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const raw = await sdk.callTool({
|
|
46
|
+
toolName: TOOL_NAME,
|
|
47
|
+
params: { query, variables: variables ?? {} }
|
|
48
|
+
});
|
|
49
|
+
return normalizeMcpResponse(raw) ?? {};
|
|
50
|
+
}
|
|
51
|
+
class graphql {
|
|
52
|
+
_dataCallback;
|
|
53
|
+
_config;
|
|
54
|
+
constructor(dataCallback) {
|
|
55
|
+
this._dataCallback = dataCallback;
|
|
56
|
+
}
|
|
57
|
+
connect() {
|
|
58
|
+
this._fetch();
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
61
|
+
disconnect() {
|
|
62
|
+
}
|
|
63
|
+
update(config) {
|
|
64
|
+
this._config = config;
|
|
65
|
+
this._fetch();
|
|
66
|
+
}
|
|
67
|
+
refresh() {
|
|
68
|
+
return this._fetch();
|
|
69
|
+
}
|
|
70
|
+
async _fetch() {
|
|
71
|
+
try {
|
|
72
|
+
const result = await runQuery(this._config ?? {});
|
|
73
|
+
this._emit(result);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
this._emit({
|
|
76
|
+
data: void 0,
|
|
77
|
+
errors: [{ message: error.message }]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_emit({ data, errors }) {
|
|
82
|
+
this._dataCallback({
|
|
83
|
+
data,
|
|
84
|
+
errors: errors?.length ? errors : void 0,
|
|
85
|
+
refresh: () => this.refresh()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function executeMutation(config) {
|
|
90
|
+
if (!config?.query) return { data: void 0, errors: [{ message: "No query provided" }] };
|
|
91
|
+
try {
|
|
92
|
+
return await runQuery(config);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
return { data: void 0, errors: [{ message: error.message }] };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
TOOL_NAME,
|
|
99
|
+
executeMutation,
|
|
100
|
+
gql,
|
|
101
|
+
graphql
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":["../../../src/providers/shared/normalize-mcp-response.ts","../../../src/providers/lightning-graphql/runtime.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\n/**\n * Unwraps the MCP tool transport envelope and returns the tool's payload as-is.\n *\n * Handles the three surface shapes `sdk.callTool()` can resolve with:\n * - MCP Apps surface: `{ structuredContent, content }`\n * - OpenAI surface: `{ result: \"<JSON string>\" }`, where the JSON may itself be\n * an MCP content array (`[{ type: 'text', text: \"<JSON string>\" }, ...]`)\n * - Fallback: the raw value returned by `callTool`\n *\n * The shape of the unwrapped payload is the tool's responsibility — this helper\n * does not project out `data` / `error` / `errors`. Callers read whichever keys\n * their tool contract defines.\n */\nexport function normalizeMcpResponse(raw: unknown): unknown {\n\tif (raw && typeof raw === \"object\" && \"structuredContent\" in raw) {\n\t\treturn (raw as { structuredContent: unknown }).structuredContent;\n\t}\n\n\tif (raw && typeof raw === \"object\" && typeof (raw as { result?: unknown }).result === \"string\") {\n\t\tconst parsed = JSON.parse((raw as { result: string }).result);\n\t\tif (Array.isArray(parsed)) {\n\t\t\tconst textBlock = parsed.find(\n\t\t\t\t(b: { type?: string; text?: string }) =>\n\t\t\t\t\tb && b.type === \"text\" && typeof b.text === \"string\",\n\t\t\t);\n\t\t\tconst text = textBlock ? textBlock.text : null;\n\t\t\tif (text) {\n\t\t\t\treturn JSON.parse(text);\n\t\t\t}\n\t\t\treturn {};\n\t\t}\n\t\treturn parsed;\n\t}\n\n\treturn raw ?? {};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { getChatSDK } from \"@salesforce/sdk-chat\";\nimport { normalizeMcpResponse } from \"../shared/normalize-mcp-response\";\n\n// Overwritten at plugin-load time by the `lightningGraphql` Vite shim, which\n// appends `TOOL_NAME = \"<configured-name>\";` to the bundled output. The initial\n// value is the default.\n// eslint-disable-next-line prefer-const\nexport let TOOL_NAME = \"graphqlQuery\";\n\ninterface GraphqlConfig {\n\tquery?: string;\n\tvariables?: Record<string, unknown>;\n}\n\ninterface GraphqlResult {\n\tdata?: unknown;\n\terrors?: { message: string }[];\n}\n\ntype WireCallback = (result: {\n\tdata: unknown;\n\terrors: { message: string }[] | undefined;\n\trefresh: () => Promise<void>;\n}) => void;\n\nexport function gql(strings: TemplateStringsArray, ...values: unknown[]): string {\n\tlet result = \"\";\n\tstrings.forEach((string, i) => {\n\t\tresult += string;\n\t\tif (i < values.length) result += String(values[i]);\n\t});\n\treturn result;\n}\n\nasync function runQuery(config: GraphqlConfig): Promise<GraphqlResult> {\n\tconst { query, variables } = config;\n\tif (!query) return { data: undefined, errors: undefined };\n\n\t// 1. UIBundle / local dev: use globalThis.__sfdc_sdk__.graphql if available\n\tif (\n\t\ttypeof (globalThis as Record<string, unknown>).__sfdc_sdk__ === \"object\" &&\n\t\ttypeof ((globalThis as Record<string, unknown>).__sfdc_sdk__ as Record<string, unknown>)\n\t\t\t?.graphql === \"function\"\n\t) {\n\t\tconst sdkGraphql = (\n\t\t\t(globalThis as Record<string, unknown>).__sfdc_sdk__ as Record<string, unknown>\n\t\t).graphql as (args: {\n\t\t\tquery: string;\n\t\t\tvariables: Record<string, unknown>;\n\t\t}) => Promise<GraphqlResult>;\n\t\tconst result = await sdkGraphql({ query, variables: variables ?? {} });\n\t\treturn { data: result?.data, errors: result?.errors };\n\t}\n\n\t// 2. MCP surface: use getChatSDK().callTool\n\tconst sdk = await getChatSDK();\n\tif (typeof sdk.callTool !== \"function\") {\n\t\tthrow new Error(\n\t\t\t\"[lightning/graphql] No data surface available. \" +\n\t\t\t\t\"Either initialise globalThis.__sfdc_sdk__ with createDataSDK, \" +\n\t\t\t\t\"or run inside a ChatGPT / MCP Apps context.\",\n\t\t);\n\t}\n\n\tconst raw = await sdk.callTool({\n\t\ttoolName: TOOL_NAME,\n\t\tparams: { query, variables: variables ?? {} },\n\t});\n\n\treturn (normalizeMcpResponse(raw) as GraphqlResult) ?? {};\n}\n\nexport class graphql {\n\t_dataCallback: WireCallback;\n\t_config: GraphqlConfig | undefined;\n\n\tconstructor(dataCallback: WireCallback) {\n\t\tthis._dataCallback = dataCallback;\n\t}\n\n\tconnect() {\n\t\tthis._fetch();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tdisconnect() {}\n\n\tupdate(config: GraphqlConfig) {\n\t\tthis._config = config;\n\t\tthis._fetch();\n\t}\n\n\trefresh() {\n\t\treturn this._fetch();\n\t}\n\n\tasync _fetch() {\n\t\ttry {\n\t\t\tconst result = await runQuery(this._config ?? {});\n\t\t\tthis._emit(result);\n\t\t} catch (error) {\n\t\t\tthis._emit({\n\t\t\t\tdata: undefined,\n\t\t\t\terrors: [{ message: (error as Error).message }],\n\t\t\t});\n\t\t}\n\t}\n\n\t_emit({ data, errors }: GraphqlResult) {\n\t\tthis._dataCallback({\n\t\t\tdata,\n\t\t\terrors: errors?.length ? errors : undefined,\n\t\t\trefresh: () => this.refresh(),\n\t\t});\n\t}\n}\n\nexport async function executeMutation(config: GraphqlConfig): Promise<GraphqlResult> {\n\tif (!config?.query) return { data: undefined, errors: [{ message: \"No query provided\" }] };\n\ttry {\n\t\treturn await runQuery(config);\n\t} catch (error) {\n\t\treturn { data: undefined, errors: [{ message: (error as Error).message }] };\n\t}\n}\n"],"names":[],"mappings":";AAmBO,SAAS,qBAAqB,KAAuB;AAC3D,MAAI,OAAO,OAAO,QAAQ,YAAY,uBAAuB,KAAK;AACjE,WAAQ,IAAuC;AAAA,EAChD;AAEA,MAAI,OAAO,OAAO,Q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
|
6
|
+
/**
|
|
7
|
+
* Unwraps the MCP tool transport envelope and returns the tool's payload as-is.
|
|
8
|
+
*
|
|
9
|
+
* Handles the three surface shapes `sdk.callTool()` can resolve with:
|
|
10
|
+
* - MCP Apps surface: `{ structuredContent, content }`
|
|
11
|
+
* - OpenAI surface: `{ result: "<JSON string>" }`, where the JSON may itself be
|
|
12
|
+
* an MCP content array (`[{ type: 'text', text: "<JSON string>" }, ...]`)
|
|
13
|
+
* - Fallback: the raw value returned by `callTool`
|
|
14
|
+
*
|
|
15
|
+
* The shape of the unwrapped payload is the tool's responsibility — this helper
|
|
16
|
+
* does not project out `data` / `error` / `errors`. Callers read whichever keys
|
|
17
|
+
* their tool contract defines.
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeMcpResponse(raw: unknown): unknown;
|
|
20
|
+
//# sourceMappingURL=normalize-mcp-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-mcp-response.d.ts","sourceRoot":"","sources":["../../../src/providers/shared/normalize-mcp-response.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAsB1D"}
|
package/dist/types.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface PassthroughRule {
|
|
|
21
21
|
}
|
|
22
22
|
export interface LwcVitePluginOptions {
|
|
23
23
|
modules?: ModuleConfig;
|
|
24
|
-
providers?: Provider[];
|
|
24
|
+
providers?: (Provider | Plugin)[];
|
|
25
25
|
stubs?: Record<string, string>;
|
|
26
26
|
lwcOptions?: Record<string, unknown>;
|
|
27
27
|
ignorePatterns?: string[];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE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CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9B,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACpC,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,CAAC,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,sBAAsB;IACtC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/vite-plugin-lwc-ui-bundle",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.132.0",
|
|
4
4
|
"description": "Vite plugin for compiling LWC components into static bundles for off-platform and MCP use",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Salesforce",
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
"types": "./dist/providers/index.d.ts",
|
|
31
31
|
"import": "./dist/providers/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./providers/lds": {
|
|
34
|
+
"types": "./dist/providers/lds/index.d.ts",
|
|
35
|
+
"import": "./dist/providers/lds/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./providers/lightning-graphql": {
|
|
38
|
+
"types": "./dist/providers/lightning-graphql/index.d.ts",
|
|
39
|
+
"import": "./dist/providers/lightning-graphql/index.js"
|
|
40
|
+
},
|
|
33
41
|
"./package.json": "./package.json"
|
|
34
42
|
},
|
|
35
43
|
"main": "./dist/index.js",
|
|
@@ -41,7 +49,7 @@
|
|
|
41
49
|
"skills"
|
|
42
50
|
],
|
|
43
51
|
"scripts": {
|
|
44
|
-
"build": "vite build",
|
|
52
|
+
"build": "vite build && vite build --mode runtime-lds && vite build --mode runtime-lightning-graphql",
|
|
45
53
|
"clean": "rm -rf dist",
|
|
46
54
|
"dev": "vite build --watch",
|
|
47
55
|
"test": "vitest run",
|
|
@@ -52,19 +60,25 @@
|
|
|
52
60
|
"@lwc/rollup-plugin": "^9.0.0",
|
|
53
61
|
"@salesforce/sdk-chat": "^1.123.0",
|
|
54
62
|
"@salesforce/ui-bundle": "^1.123.0",
|
|
55
|
-
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
63
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
64
|
+
"zod": "^3.23.8"
|
|
56
65
|
},
|
|
57
66
|
"peerDependenciesMeta": {
|
|
58
67
|
"@salesforce/ui-bundle": {
|
|
59
68
|
"optional": true
|
|
60
69
|
}
|
|
61
70
|
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"es-module-lexer": "^1.7.0",
|
|
73
|
+
"magic-string": "^0.30.17"
|
|
74
|
+
},
|
|
62
75
|
"devDependencies": {
|
|
63
|
-
"@salesforce/sdk-chat": "^1.
|
|
76
|
+
"@salesforce/sdk-chat": "^1.132.0",
|
|
64
77
|
"typescript": "^5.9.3",
|
|
65
78
|
"vite": "^7.0.0",
|
|
66
79
|
"vite-plugin-dts": "^4.5.4",
|
|
67
|
-
"vitest": "^4.0.6"
|
|
80
|
+
"vitest": "^4.0.6",
|
|
81
|
+
"zod": "^3.23.8"
|
|
68
82
|
},
|
|
69
83
|
"engines": {
|
|
70
84
|
"node": ">=20.0.0"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Provider } from '../types';
|
|
2
|
-
export interface LightningGraphqlOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Name of the MCP tool to call for GraphQL query execution.
|
|
5
|
-
* Defaults to `'graphqlQuery'`.
|
|
6
|
-
*
|
|
7
|
-
* The tool must accept `{ query: string; variables?: Record<string, unknown> }`
|
|
8
|
-
* and return a GraphQL-shaped response: `{ data: unknown; errors?: unknown[] }`.
|
|
9
|
-
*
|
|
10
|
-
* The result is normalised across surfaces:
|
|
11
|
-
* - OpenAI surface: `sdk.callTool()` resolves with `{ result: "<JSON string>" }`
|
|
12
|
-
* - MCP Apps surface: `sdk.callTool()` resolves with `{ structuredContent, content }`
|
|
13
|
-
*/
|
|
14
|
-
toolName?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare function lightningGraphql(options?: LightningGraphqlOptions): Provider;
|
|
17
|
-
//# sourceMappingURL=lightning-graphql.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lightning-graphql.d.ts","sourceRoot":"","sources":["../../src/providers/lightning-graphql.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,uBAAuB;IACvC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AA0KD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,QAAQ,CAShF"}
|