@salesforce/vite-plugin-lwc-ui-bundle 1.134.5 → 1.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +1 -2
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/lds/index.d.ts +47 -2
- package/dist/providers/lds/index.d.ts.map +1 -1
- package/dist/providers/lds/index.js +54 -8
- package/dist/providers/lds/index.js.map +1 -1
- package/dist/providers/lds/runtime.js +158 -11
- package/dist/providers/lds/runtime.js.map +1 -1
- package/docs/consumer-guide.md +17 -10
- package/package.json +3 -7
- package/skills/setup-lwc-vite-plugin/SKILL.md +34 -24
- package/skills/setup-lwc-vite-plugin/references/known-pitfalls.md +27 -44
- package/dist/providers/lightning-graphql/index.d.ts +0 -10
- package/dist/providers/lightning-graphql/index.d.ts.map +0 -1
- package/dist/providers/lightning-graphql/index.js +0 -24
- package/dist/providers/lightning-graphql/index.js.map +0 -1
- package/dist/providers/lightning-graphql/runtime.js +0 -103
- package/dist/providers/lightning-graphql/runtime.js.map +0 -1
package/README.md
CHANGED
|
@@ -142,9 +142,9 @@ Handles `lightning/primitiveUtils`. Stubs `normalizeBoolean` and `reflectAttribu
|
|
|
142
142
|
|
|
143
143
|
### `lds(adapters?)`
|
|
144
144
|
|
|
145
|
-
Handles LDS (Lightning Data Service) specifiers such as `lightning/uiRecordApi` by routing registered exports to MCP tools. Unregistered exports pass through to normal `lightning/*` resolution.
|
|
145
|
+
Handles LDS (Lightning Data Service) specifiers such as `lightning/uiRecordApi`, `lightning/uiObjectInfoApi`, and `lightning/graphql` by routing registered exports to MCP tools. Unregistered exports pass through to normal `lightning/*` resolution.
|
|
146
146
|
|
|
147
|
-
A single specifier often mixes wire and imperative exports, so all
|
|
147
|
+
A single specifier often mixes wire and imperative exports, so all shapes (`wire`, `imperative-mutation`, `imperative-read`, `graphql-wire`, `graphql-mutation`) live in the same registry keyed by module + export name:
|
|
148
148
|
|
|
149
149
|
```js
|
|
150
150
|
lds({
|
|
@@ -191,21 +191,32 @@ lds({
|
|
|
191
191
|
},
|
|
192
192
|
},
|
|
193
193
|
},
|
|
194
|
+
"lightning/graphql": {
|
|
195
|
+
graphql: { type: "graphql-wire", toolName: "graphqlQuery" },
|
|
196
|
+
executeMutation: { type: "graphql-mutation", toolName: "graphqlQuery" },
|
|
197
|
+
},
|
|
194
198
|
});
|
|
195
199
|
```
|
|
196
200
|
|
|
201
|
+
The `lightning/graphql` specifier is owned end-to-end by the virtual module: `gql` is auto-exported alongside the registered adapters, so `import { gql, graphql } from 'lightning/graphql'` works without any additional wiring. Both the wire and mutation adapters dispatch through MCP (`getChatSDK().callTool`) and surface errors in the GraphQL `{ data, errors[] }` envelope rather than throwing.
|
|
202
|
+
|
|
197
203
|
`configJsonSchema` is OneStore's [`JSONSchema`](https://www.npmjs.com/package/@conduit-client/jsonschema-validate) — `ObjectType` requires `properties`, `required`, and `additionalProperties` to be declared. Validation is performed at invoke time by the same `assertIsValid` used on-platform.
|
|
198
204
|
|
|
199
205
|
#### Supported invoker shapes
|
|
200
206
|
|
|
201
|
-
| `type`
|
|
202
|
-
|
|
|
203
|
-
| `wire`
|
|
204
|
-
| `imperative-mutation`
|
|
205
|
-
| `imperative-read`
|
|
206
|
-
| `imperative-read`
|
|
207
|
-
| `imperative-read`
|
|
208
|
-
| `imperative-read`
|
|
207
|
+
| `type` | `invokerShape` | Export signature | Error surface |
|
|
208
|
+
| ------------------------- | -------------------------- | -------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
209
|
+
| `wire` | — | `WireAdapter` class consumed by `@wire` | Emits `{ data, error }` to the wire callback. |
|
|
210
|
+
| `imperative-mutation` | — | `(config) => Promise<Data>` | Throws on validation or tool error. |
|
|
211
|
+
| `imperative-read` | `query` | `(config) => Promise<{ data }>` | Throws on validation or tool error. |
|
|
212
|
+
| `imperative-read` | `subscribable` | `(config) => Promise<{ data, subscribe }>` | Throws on validation or tool error. |
|
|
213
|
+
| `imperative-read` | `subscribable-refreshable` | `(config) => Promise<{ data, subscribe, refresh }>` | Throws on validation or tool error. |
|
|
214
|
+
| `imperative-read` | `legacy` | `{ invoke(config, context, callback), subscribe(...): Unsubscribe }` | Callback fires with `{ data, error }`; neither throws. |
|
|
215
|
+
| `graphql-wire` | — | `WireAdapter` class consumed by `@wire(graphql, ...)` | Emits `{ data, errors, refresh }`; errors routed in-band, not thrown. |
|
|
216
|
+
| `graphql-mutation` | — | `(config) => Promise<{ data, errors }>` | Errors routed in-band via `errors[]`, not thrown. |
|
|
217
|
+
| `graphql-imperative-read` | `query` | `(config) => Promise<{ data, errors, subscribe }>` | Errors routed in-band via `errors[]`, not thrown. |
|
|
218
|
+
| `graphql-imperative-read` | `query-refreshable` | `(config) => Promise<{ data, errors, subscribe, refresh }>` | Errors routed in-band via `errors[]`, not thrown. |
|
|
219
|
+
| `graphql-imperative-read` | `legacy` | `{ invoke(config, context, callback), subscribe(...): Unsubscribe }` | Callback fires with `{ data, errors }`; neither throws. |
|
|
209
220
|
|
|
210
221
|
Each shape is a direct delegation to the matching OneStore service descriptor (`Default`, `Query`, `Subscribable`, or `Legacy` `ImperativeBindingsService`). Consumer code is identical whether the import resolves to native implementation on-platform or to this MCP-backed replacement off-platform — no conditional wrapping, no `{ data, error }` indirection for imperative shapes. Write one `try/catch`, ship both places.
|
|
211
222
|
|
|
@@ -213,9 +224,12 @@ Because each shape inherits OneStore's invoker wholesale, successful payloads ar
|
|
|
213
224
|
|
|
214
225
|
`legacy` preserves the older `{ invoke, subscribe }` contract. `context` is accepted but ignored. Callback payloads always use `{ data, error }`; `data` is deep-frozen on success.
|
|
215
226
|
|
|
216
|
-
#### `subscribe()` stance
|
|
227
|
+
#### `subscribe()` / `refresh()` stance
|
|
228
|
+
|
|
229
|
+
On-platform, the reactive store drives `subscribe` callbacks — including after `refresh()` — by fanning fresh data out to every listener. Off-platform there is no store, so behavior is partitioned by whether the shape exposes `refresh`:
|
|
217
230
|
|
|
218
|
-
|
|
231
|
+
- **Shapes with no `refresh`** (`legacy`, `subscribable`, `graphql-imperative-read` with `invokerShape: "query"`): `subscribe` is a **deliberate no-op**. Nothing can ever trigger a post-initial update, so the callback never fires; the returned unsubscribe is idempotent.
|
|
232
|
+
- **Shapes with `refresh`** (`subscribable-refreshable`, `graphql-imperative-read` with `invokerShape: "query-refreshable"`): `subscribe` **is wired into `refresh()`**. Each call to the returned function owns its own subscriber set. `refresh()` re-executes the MCP tool and broadcasts the fresh payload — `{ data, error }` for LDS, `{ data, errors }` (in-band) for GraphQL — to every registered subscriber before resolving. This preserves the on-platform contract end-to-end off-platform.
|
|
219
233
|
|
|
220
234
|
This is deliberate: native `subscribe` is driven by a reactive store, and off-platform there is no store to observe. Pretending otherwise would be dishonest.
|
|
221
235
|
|
|
@@ -268,7 +282,7 @@ The plugin factory returns an array of coordinated Vite plugins:
|
|
|
268
282
|
|
|
269
283
|
## Local Salesforce Dev (lwcProxy)
|
|
270
284
|
|
|
271
|
-
`lwcProxy()` is an optional companion plugin that proxies Salesforce API calls to a connected org, enabling `lightning/
|
|
285
|
+
`lwcProxy()` is an optional companion plugin that proxies Salesforce API calls to a connected org, enabling `lightning/*` modules that call `/services/*` directly (via `@salesforce/sdk-data`) to work in local dev. `lightning/graphql` itself now dispatches through MCP (`getChatSDK().callTool("graphqlQuery", ...)`) via `builtins.lds()` — the `globalThis.__sfdc_sdk__.graphql` shortcut was removed. For local dev without an MCP host, mock `window.openai.callTool` in `bootstrap.js`.
|
|
272
286
|
|
|
273
287
|
### Setup
|
|
274
288
|
|
|
@@ -298,7 +312,7 @@ globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: "/" } });
|
|
|
298
312
|
|
|
299
313
|
- `lwcProxy()` intercepts `/services/*` and `/lwr/*` requests in the Vite dev server and forwards them to Salesforce with the org's access token
|
|
300
314
|
- Credentials are read automatically from the `sf` CLI (uses `@salesforce/ui-bundle/app`, an optional peer dep)
|
|
301
|
-
- `lightning/graphql`
|
|
315
|
+
- `lightning/graphql` is handled by `builtins.lds()` and dispatches through MCP (`getChatSDK().callTool`) regardless of `lwcProxy` — route the `graphqlQuery` tool to your proxy via your MCP host if you need live GraphQL against the connected org
|
|
302
316
|
|
|
303
317
|
### Options
|
|
304
318
|
|
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,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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAOnC,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAa,oBAAoB,EAA6B,MAAM,SAAS,CAAC;AAE1F,YAAY,EACX,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,SAAS,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAkCvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAoJlF"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { label, i18n, accessCheck, client, gate, primitiveUtils } from "./provid
|
|
|
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
8
|
import { lds } from "./providers/lds/index.js";
|
|
10
9
|
function discoverModules(dirs = []) {
|
|
11
10
|
const modules = [];
|
|
@@ -370,7 +369,6 @@ function defaultProviders() {
|
|
|
370
369
|
client(),
|
|
371
370
|
gate(),
|
|
372
371
|
primitiveUtils(),
|
|
373
|
-
lightningGraphql(),
|
|
374
372
|
lds()
|
|
375
373
|
];
|
|
376
374
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/discovery.ts","../src/plugins/lightning-npm.ts","../src/plugins/lwc-bridge.ts","../src/plugins/lwc-wrapper.ts","../src/plugins/missing-css.ts","../src/plugins/scoped-providers.ts","../src/plugins/proxy.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { DirConfig, DiscoveredModule } from \"./types\";\n\nexport function discoverModules(dirs: (string | DirConfig)[] = []): DiscoveredModule[] {\n\tconst modules: DiscoveredModule[] = [];\n\n\tfor (const dir of dirs) {\n\t\tconst dirPath = typeof dir === \"string\" ? dir : dir.path;\n\t\tconst namespace = typeof dir === \"string\" ? undefined : dir.namespace;\n\t\tconst resolvedDir = path.resolve(dirPath);\n\n\t\tif (!existsSync(resolvedDir) || !statSync(resolvedDir).isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (namespace) {\n\t\t\t// Flat DX structure: <dir>/<componentName>/<componentName>.js\n\t\t\tfor (const name of readdirSync(resolvedDir)) {\n\t\t\t\tconst fullPath = path.join(resolvedDir, name);\n\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\tmodules.push({\n\t\t\t\t\t\tname: `${namespace}/${name}`,\n\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Standard structure: <dir>/<namespace>/<componentName>/<componentName>.js\n\t\t\tfor (const ns of readdirSync(resolvedDir)) {\n\t\t\t\tconst nsDir = path.join(resolvedDir, ns);\n\t\t\t\tif (!statSync(nsDir).isDirectory()) continue;\n\n\t\t\t\tfor (const name of readdirSync(nsDir)) {\n\t\t\t\t\tconst fullPath = path.join(nsDir, name);\n\t\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\t\tmodules.push({\n\t\t\t\t\t\t\tname: `${ns}/${name}`,\n\t\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modules;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport type { LightningNpmOptions } from \"../types\";\n\nfunction resolveJsFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.js`);\n\tif (existsSync(nested)) return nested;\n\tconst flat = path.join(root, `${sub}.js`);\n\tif (existsSync(flat)) return flat;\n\treturn null;\n}\n\nfunction resolveCssFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.css`);\n\treturn existsSync(nested) ? nested : null;\n}\n\nexport function lightningNpm({ npmRoot, overrideDirs = [] }: LightningNpmOptions): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-resolve-lightning-npm\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(importee) {\n\t\t\tif (!importee.startsWith(\"lightning/\")) return null;\n\n\t\t\tconst sub = importee.slice(\"lightning/\".length);\n\t\t\tconst segments = sub.split(\"/\");\n\t\t\tconst leaf = segments[segments.length - 1];\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst overridePath = path.join(dir, ...segments, `${leaf}.js`);\n\t\t\t\tif (existsSync(overridePath)) return null;\n\t\t\t}\n\n\t\t\tconst npmJs = resolveJsFromRoot(npmRoot, sub);\n\t\t\tif (npmJs) return npmJs;\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst cssFallback = path.join(dir, ...segments, `${leaf}.css`);\n\t\t\t\tif (existsSync(cssFallback)) return cssFallback;\n\t\t\t}\n\n\t\t\treturn resolveCssFromRoot(npmRoot, sub);\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\n\nexport function lwcBridge(isComponentAsset: (id: string) => boolean): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-bridge\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config: ResolvedConfig) {\n\t\t\tfor (const plugin of config.plugins) {\n\t\t\t\tif (plugin.name === \"vite:css\" || plugin.name === \"vite:css-post\") {\n\t\t\t\t\tconst p = plugin as unknown as Record<string, unknown>;\n\t\t\t\t\tconst origTransform = p[\"transform\"];\n\t\t\t\t\tif (!origTransform) continue;\n\n\t\t\t\t\tif (typeof origTransform === \"function\") {\n\t\t\t\t\t\t// Vite <7: transform is a plain function\n\t\t\t\t\t\tp[\"transform\"] = function (\n\t\t\t\t\t\t\tthis: unknown,\n\t\t\t\t\t\t\tcode: string,\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\t...rest: unknown[]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\treturn (origTransform as (...a: unknown[]) => unknown).call(this, code, id, ...rest);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof origTransform === \"object\" &&\n\t\t\t\t\t\ttypeof (origTransform as Record<string, unknown>)[\"handler\"] === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Vite 7+: transform is { handler, order? }\n\t\t\t\t\t\tconst origHandler = (origTransform as Record<string, unknown>)[\"handler\"] as (\n\t\t\t\t\t\t\t...a: unknown[]\n\t\t\t\t\t\t) => unknown;\n\t\t\t\t\t\tp[\"transform\"] = {\n\t\t\t\t\t\t\t...(origTransform as object),\n\t\t\t\t\t\t\thandler: function (this: unknown, code: string, id: string, ...rest: unknown[]) {\n\t\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\t\treturn origHandler.call(this, code, id, ...rest);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tresolveId(id, importer) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tconst cleanId = id.split(\"?\", 2)[0] ?? id;\n\n\t\t\tif (cleanId.endsWith(\".html\") && isComponentAsset(cleanId) && !id.includes(\"?lwc\")) {\n\t\t\t\treturn `${cleanId}?lwc`;\n\t\t\t}\n\n\t\t\tif (!importer) return null;\n\t\t\tif (!cleanId.endsWith(\".html\")) return null;\n\t\t\tif (!cleanId.startsWith(\"./\") && !cleanId.startsWith(\"../\")) return null;\n\t\t\tif (!isComponentAsset(importer)) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importer.split(\"?\")[0] ?? importer), cleanId);\n\n\t\t\tif (existsSync(resolved)) {\n\t\t\t\treturn resolved + \"?lwc\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn \"export default undefined;\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\ntype AnyFn = (this: unknown, ...args: unknown[]) => unknown;\ntype LwcRollupFactory = (options: Record<string, unknown>) => Plugin;\ntype LazyLwcRollupLoader = () => Promise<LwcRollupFactory>;\n\nexport function lwcWrapper(\n\tlazyLoader: LazyLwcRollupLoader,\n\toptions: Record<string, unknown>,\n\tisComponentAsset?: (id: string) => boolean,\n): Plugin {\n\tlet pluginPromise: Promise<Plugin> | null = null;\n\n\tconst getPlugin = () => {\n\t\tif (!pluginPromise) {\n\t\t\tpluginPromise = lazyLoader().then((factory) => factory(options));\n\t\t}\n\t\treturn pluginPromise;\n\t};\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-wrapper\",\n\t\tenforce: \"pre\" as const,\n\t\tasync resolveId(importee: string, importer?: string) {\n\t\t\tif (importer?.split(\"?\")[0]?.endsWith(\"index.html\") && !importer.includes(\"html-proxy\"))\n\t\t\t\treturn null;\n\t\t\tif (importee.startsWith(\"/@\") || importee.startsWith(\"\\0\")) return null;\n\t\t\tif (importer?.includes(\"/node_modules/vite/\")) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.resolveId === \"function\"\n\t\t\t\t? (plugin.resolveId as AnyFn).call(this, importee, importer)\n\t\t\t\t: null;\n\t\t},\n\t\tasync load(id: string) {\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.load === \"function\" ? (plugin.load as AnyFn).call(this, id) : null;\n\t\t},\n\t\tasync transform(code: string, id: string) {\n\t\t\t// Only pass files to the LWC compiler if they are LWC component assets.\n\t\t\t// Non-component files (SDK sources, node_modules, etc.) must be skipped.\n\t\t\tif (isComponentAsset && !isComponentAsset(id)) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.transform === \"function\"\n\t\t\t\t? (plugin.transform as AnyFn).call(this, code, id)\n\t\t\t\t: null;\n\t\t},\n\t} as Plugin;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst LWC_EMPTY_CSS = \"\\0lwc-empty-css\";\n\nexport function missingCss(): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-missing-css\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\tif (!importer || !id.startsWith(\"./\") || !id.includes(\".css\")) return null;\n\t\t\tconst importerPath = importer.split(\"?\")[0] ?? importer;\n\t\t\tif (!importerPath.endsWith(\".html\")) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importerPath), id.split(\"?\")[0] ?? id);\n\t\t\tif (existsSync(resolved)) return null;\n\n\t\t\treturn `${LWC_EMPTY_CSS}?${id}`;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(LWC_EMPTY_CSS)) {\n\t\t\t\treturn \"export default undefined\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\nimport type { Provider, ScopedProvidersOptions } from \"../types\";\n\nconst VIRTUAL_PREFIX = \"\\0sf-provider:\";\n\nexport function scopedProviders(\n\tproviders: Provider[] = [],\n\toptions: ScopedProvidersOptions = {},\n): Plugin {\n\tconst { ignorePatterns = [], interceptPrefixes = [], passthroughRules = [] } = options;\n\n\tconst prefixSet = new Set<string>();\n\tfor (const p of providers) {\n\t\tif (p.prefix) prefixSet.add(p.prefix);\n\t}\n\n\tfunction shouldIntercept(id: string): boolean {\n\t\tfor (const prefix of prefixSet) {\n\t\t\tif (id === prefix || id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const prefix of interceptPrefixes) {\n\t\t\tif (id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const p of providers) {\n\t\t\tif (!p.prefix && typeof p.match === \"function\" && p.match(id)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-scoped-module-providers\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\t// Explicit provider prefix always wins over ignorePatterns —\n\t\t\t// if a provider is registered for a specifier, it always handles it.\n\t\t\tconst handledByProvider = [...prefixSet].some((p) => id === p || id.startsWith(p + \"/\"));\n\n\t\t\tif (!handledByProvider) {\n\t\t\t\tif (!shouldIntercept(id)) return null;\n\n\t\t\t\tfor (const pattern of ignorePatterns) {\n\t\t\t\t\tif (id.startsWith(pattern)) return null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const rule of passthroughRules) {\n\t\t\t\tif (\n\t\t\t\t\timporter &&\n\t\t\t\t\tid.startsWith(rule.specifierPrefix) &&\n\t\t\t\t\timporter.includes(rule.importerPattern)\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn VIRTUAL_PREFIX + id;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(VIRTUAL_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(VIRTUAL_PREFIX.length);\n\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst result = provider.resolve(specifier);\n\t\t\t\tif (result != null) return result;\n\t\t\t}\n\n\t\t\tconsole.warn(\n\t\t\t\t`[scoped-module-providers] Unhandled import: ${specifier} — returning undefined`,\n\t\t\t);\n\t\t\treturn `export default undefined;`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport type { Plugin } from \"vite\";\n\nexport interface LwcProxyOptions {\n\t/** Salesforce org alias (defaults to the sf CLI default org) */\n\torgAlias?: string;\n\t/** Enable verbose request logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that proxies Salesforce API calls to a connected org.\n *\n * Uses the same authentication approach as @salesforce/vite-plugin-ui-bundle —\n * reads credentials from the sf CLI via @salesforce/ui-bundle/app.\n *\n * Intercepts requests to /services/ and /lwr/ and forwards them to Salesforce\n * with the org's access token. Handles token refresh on 401/403 responses.\n *\n * Usage in vite.config.js:\n * import { lwcProxy } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [lwcVitePlugin(...), lwcProxy()]\n *\n * Then initialise the SDK in your app's bootstrap:\n * import { createDataSDK } from '@salesforce/sdk-data';\n * globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: '/' } });\n */\nexport function lwcProxy(options: LwcProxyOptions = {}): Plugin {\n\tlet instanceUrl: string | undefined;\n\tlet accessToken: string | undefined;\n\tconst orgAlias: string | undefined = options.orgAlias;\n\n\tasync function loadOrgInfo(): Promise<void> {\n\t\ttry {\n\t\t\t// Dynamically import to avoid bundling @salesforce/ui-bundle at build time\n\t\t\tconst { getOrgInfo } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await getOrgInfo(orgAlias);\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.log(`[lwc-proxy] Connected to ${instanceUrl}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.error(\n\t\t\t\t`[lwc-proxy] Failed to load org info — is a Salesforce org connected?\\n ${msg}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync function refreshToken(): Promise<void> {\n\t\ttry {\n\t\t\tconst { refreshOrgAuth } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await refreshOrgAuth(orgAlias ?? \"\");\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore refresh errors\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-proxy\",\n\t\tenforce: \"pre\",\n\n\t\tasync configResolved() {\n\t\t\tawait loadOrgInfo();\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.middlewares.use(async (req, res, next) => {\n\t\t\t\tconst url = req.url ?? \"\";\n\n\t\t\t\t// Only proxy Salesforce API paths\n\t\t\t\tif (!url.startsWith(\"/services/\") && !url.startsWith(\"/lwr/\")) {\n\t\t\t\t\treturn next();\n\t\t\t\t}\n\n\t\t\t\tif (!instanceUrl || !accessToken) {\n\t\t\t\t\tres.writeHead(503, { \"Content-Type\": \"application/json\" });\n\t\t\t\t\tres.end(\n\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\terror: \"SERVICE_UNAVAILABLE\",\n\t\t\t\t\t\t\tmessage: \"Salesforce org not connected. Run: sf org display\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst forward = async (token: string): Promise<void> => {\n\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\tconst targetUrl = new URL(url, instanceUrl);\n\t\t\t\t\t\tconst isHttps = targetUrl.protocol === \"https:\";\n\t\t\t\t\t\tconst transport = isHttps ? https : http;\n\n\t\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\t\tconsole.log(`[lwc-proxy] ${req.method} ${url}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip hop-by-hop headers\n\t\t\t\t\t\tconst headers: Record<string, string | string[]> = {};\n\t\t\t\t\t\tfor (const [key, value] of Object.entries(req.headers)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t![\n\t\t\t\t\t\t\t\t\t\"host\",\n\t\t\t\t\t\t\t\t\t\"connection\",\n\t\t\t\t\t\t\t\t\t\"keep-alive\",\n\t\t\t\t\t\t\t\t\t\"proxy-authenticate\",\n\t\t\t\t\t\t\t\t\t\"proxy-authorization\",\n\t\t\t\t\t\t\t\t\t\"te\",\n\t\t\t\t\t\t\t\t\t\"trailers\",\n\t\t\t\t\t\t\t\t\t\"transfer-encoding\",\n\t\t\t\t\t\t\t\t\t\"upgrade\",\n\t\t\t\t\t\t\t\t].includes(key.toLowerCase()) &&\n\t\t\t\t\t\t\t\tvalue !== undefined\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\theaders[key] = value as string | string[];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\theaders[\"host\"] = targetUrl.host;\n\t\t\t\t\t\theaders[\"authorization\"] = `Bearer ${token}`;\n\t\t\t\t\t\theaders[\"cookie\"] = `sid=${token}`;\n\n\t\t\t\t\t\tconst proxyReq = transport.request(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\t\t\thostname: targetUrl.hostname,\n\t\t\t\t\t\t\t\tport: targetUrl.port || (isHttps ? 443 : 80),\n\t\t\t\t\t\t\t\tpath: targetUrl.pathname + targetUrl.search,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(proxyRes) => {\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\tres.writeHead(proxyRes.statusCode ?? 200, proxyRes.headers);\n\t\t\t\t\t\t\t\tproxyRes.pipe(res);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treq.pipe(proxyReq);\n\t\t\t\t\t\tproxyReq.on(\"error\", reject);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\tawait forward(accessToken!);\n\n\t\t\t\t\t// On 401/403, refresh token and retry once\n\t\t\t\t\t// Note: we can't easily check status here since we piped to res,\n\t\t\t\t\t// so we rely on the transform hook below for retries in future iterations\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.error(\"[lwc-proxy] Request failed:\", error);\n\t\t\t\t\t}\n\t\t\t\t\t// Try refreshing token and retry\n\t\t\t\t\tawait refreshToken();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait forward(accessToken!);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tnext(err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { discoverModules } from \"./discovery\";\nimport { lightningNpm } from \"./plugins/lightning-npm\";\nimport { lwcBridge } from \"./plugins/lwc-bridge\";\nimport { lwcWrapper } from \"./plugins/lwc-wrapper\";\nimport { missingCss } from \"./plugins/missing-css\";\nimport { scopedProviders } from \"./plugins/scoped-providers\";\nimport * as builtinProviders from \"./providers/index\";\nimport type { DirConfig, LwcVitePluginOptions, NpmModuleConfig, Provider } from \"./types\";\n\nexport type {\n\tProvider,\n\tLwcVitePluginOptions,\n\tPassthroughRule,\n\tDiscoveredModule,\n\tDirConfig,\n} from \"./types\";\nexport { builtinProviders as builtins };\nexport { discoverModules } from \"./discovery\";\nexport { lwcProxy } from \"./plugins/proxy\";\nexport type { LwcProxyOptions } from \"./plugins/proxy\";\n\nfunction defaultProviders(): (Provider | Plugin)[] {\n\treturn [\n\t\tbuiltinProviders.label(),\n\t\tbuiltinProviders.i18n(),\n\t\tbuiltinProviders.accessCheck(),\n\t\tbuiltinProviders.client(),\n\t\tbuiltinProviders.gate(),\n\t\tbuiltinProviders.primitiveUtils(),\n\t\tbuiltinProviders.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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A,IAAA;AAAA;AAAA,IAGD,GAAG;AAAA,IACH,gBAAgB,mBAAmB;AAAA,MAClC;AAAA,MACA,mBAAmB,CAAC,GAAG,iBAAiB;AAAA,MACxC;AAAA,IAAA,CACA;AAAA,IAED,GAAG,SAAS;AAAA,MAAI,CAAC,YAChB,aAAa;AAAA,QACZ;AAAA,QACA,cAAc;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,IAGF,WAAA;AAAA,IACA,UAAU,gBAAgB;AAAA,IAC1B;AAAA,MACC;AAAA,MACA;AAAA,QACC,SAAS,QAAQ,IAAA;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,UACA,GAAK,WAAW,WAAwB,CAAA;AAAA,QAAC;AAAA,MAC1C;AAAA,MAED;AAAA,IAAA;AAAA,EACD;AAGD,MAAI,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACxC,YAAQ,KAAK;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AACR,eAAO;AAAA,UACN,SAAS;AAAA,YACR,OAAO;AAAA,UAAA;AAAA,QACR;AAAA,MAEF;AAAA,IAAA,CACA;AAAA,EACF;AAEA,SAAO;AACR;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/discovery.ts","../src/plugins/lightning-npm.ts","../src/plugins/lwc-bridge.ts","../src/plugins/lwc-wrapper.ts","../src/plugins/missing-css.ts","../src/plugins/scoped-providers.ts","../src/plugins/proxy.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { DirConfig, DiscoveredModule } from \"./types\";\n\nexport function discoverModules(dirs: (string | DirConfig)[] = []): DiscoveredModule[] {\n\tconst modules: DiscoveredModule[] = [];\n\n\tfor (const dir of dirs) {\n\t\tconst dirPath = typeof dir === \"string\" ? dir : dir.path;\n\t\tconst namespace = typeof dir === \"string\" ? undefined : dir.namespace;\n\t\tconst resolvedDir = path.resolve(dirPath);\n\n\t\tif (!existsSync(resolvedDir) || !statSync(resolvedDir).isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (namespace) {\n\t\t\t// Flat DX structure: <dir>/<componentName>/<componentName>.js\n\t\t\tfor (const name of readdirSync(resolvedDir)) {\n\t\t\t\tconst fullPath = path.join(resolvedDir, name);\n\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\tmodules.push({\n\t\t\t\t\t\tname: `${namespace}/${name}`,\n\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Standard structure: <dir>/<namespace>/<componentName>/<componentName>.js\n\t\t\tfor (const ns of readdirSync(resolvedDir)) {\n\t\t\t\tconst nsDir = path.join(resolvedDir, ns);\n\t\t\t\tif (!statSync(nsDir).isDirectory()) continue;\n\n\t\t\t\tfor (const name of readdirSync(nsDir)) {\n\t\t\t\t\tconst fullPath = path.join(nsDir, name);\n\t\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\t\tmodules.push({\n\t\t\t\t\t\t\tname: `${ns}/${name}`,\n\t\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modules;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport type { LightningNpmOptions } from \"../types\";\n\nfunction resolveJsFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.js`);\n\tif (existsSync(nested)) return nested;\n\tconst flat = path.join(root, `${sub}.js`);\n\tif (existsSync(flat)) return flat;\n\treturn null;\n}\n\nfunction resolveCssFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.css`);\n\treturn existsSync(nested) ? nested : null;\n}\n\nexport function lightningNpm({ npmRoot, overrideDirs = [] }: LightningNpmOptions): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-resolve-lightning-npm\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(importee) {\n\t\t\tif (!importee.startsWith(\"lightning/\")) return null;\n\n\t\t\tconst sub = importee.slice(\"lightning/\".length);\n\t\t\tconst segments = sub.split(\"/\");\n\t\t\tconst leaf = segments[segments.length - 1];\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst overridePath = path.join(dir, ...segments, `${leaf}.js`);\n\t\t\t\tif (existsSync(overridePath)) return null;\n\t\t\t}\n\n\t\t\tconst npmJs = resolveJsFromRoot(npmRoot, sub);\n\t\t\tif (npmJs) return npmJs;\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst cssFallback = path.join(dir, ...segments, `${leaf}.css`);\n\t\t\t\tif (existsSync(cssFallback)) return cssFallback;\n\t\t\t}\n\n\t\t\treturn resolveCssFromRoot(npmRoot, sub);\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\n\nexport function lwcBridge(isComponentAsset: (id: string) => boolean): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-bridge\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config: ResolvedConfig) {\n\t\t\tfor (const plugin of config.plugins) {\n\t\t\t\tif (plugin.name === \"vite:css\" || plugin.name === \"vite:css-post\") {\n\t\t\t\t\tconst p = plugin as unknown as Record<string, unknown>;\n\t\t\t\t\tconst origTransform = p[\"transform\"];\n\t\t\t\t\tif (!origTransform) continue;\n\n\t\t\t\t\tif (typeof origTransform === \"function\") {\n\t\t\t\t\t\t// Vite <7: transform is a plain function\n\t\t\t\t\t\tp[\"transform\"] = function (\n\t\t\t\t\t\t\tthis: unknown,\n\t\t\t\t\t\t\tcode: string,\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\t...rest: unknown[]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\treturn (origTransform as (...a: unknown[]) => unknown).call(this, code, id, ...rest);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof origTransform === \"object\" &&\n\t\t\t\t\t\ttypeof (origTransform as Record<string, unknown>)[\"handler\"] === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Vite 7+: transform is { handler, order? }\n\t\t\t\t\t\tconst origHandler = (origTransform as Record<string, unknown>)[\"handler\"] as (\n\t\t\t\t\t\t\t...a: unknown[]\n\t\t\t\t\t\t) => unknown;\n\t\t\t\t\t\tp[\"transform\"] = {\n\t\t\t\t\t\t\t...(origTransform as object),\n\t\t\t\t\t\t\thandler: function (this: unknown, code: string, id: string, ...rest: unknown[]) {\n\t\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\t\treturn origHandler.call(this, code, id, ...rest);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tresolveId(id, importer) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tconst cleanId = id.split(\"?\", 2)[0] ?? id;\n\n\t\t\tif (cleanId.endsWith(\".html\") && isComponentAsset(cleanId) && !id.includes(\"?lwc\")) {\n\t\t\t\treturn `${cleanId}?lwc`;\n\t\t\t}\n\n\t\t\tif (!importer) return null;\n\t\t\tif (!cleanId.endsWith(\".html\")) return null;\n\t\t\tif (!cleanId.startsWith(\"./\") && !cleanId.startsWith(\"../\")) return null;\n\t\t\tif (!isComponentAsset(importer)) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importer.split(\"?\")[0] ?? importer), cleanId);\n\n\t\t\tif (existsSync(resolved)) {\n\t\t\t\treturn resolved + \"?lwc\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn \"export default undefined;\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\ntype AnyFn = (this: unknown, ...args: unknown[]) => unknown;\ntype LwcRollupFactory = (options: Record<string, unknown>) => Plugin;\ntype LazyLwcRollupLoader = () => Promise<LwcRollupFactory>;\n\nexport function lwcWrapper(\n\tlazyLoader: LazyLwcRollupLoader,\n\toptions: Record<string, unknown>,\n\tisComponentAsset?: (id: string) => boolean,\n): Plugin {\n\tlet pluginPromise: Promise<Plugin> | null = null;\n\n\tconst getPlugin = () => {\n\t\tif (!pluginPromise) {\n\t\t\tpluginPromise = lazyLoader().then((factory) => factory(options));\n\t\t}\n\t\treturn pluginPromise;\n\t};\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-wrapper\",\n\t\tenforce: \"pre\" as const,\n\t\tasync resolveId(importee: string, importer?: string) {\n\t\t\tif (importer?.split(\"?\")[0]?.endsWith(\"index.html\") && !importer.includes(\"html-proxy\"))\n\t\t\t\treturn null;\n\t\t\tif (importee.startsWith(\"/@\") || importee.startsWith(\"\\0\")) return null;\n\t\t\tif (importer?.includes(\"/node_modules/vite/\")) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.resolveId === \"function\"\n\t\t\t\t? (plugin.resolveId as AnyFn).call(this, importee, importer)\n\t\t\t\t: null;\n\t\t},\n\t\tasync load(id: string) {\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.load === \"function\" ? (plugin.load as AnyFn).call(this, id) : null;\n\t\t},\n\t\tasync transform(code: string, id: string) {\n\t\t\t// Only pass files to the LWC compiler if they are LWC component assets.\n\t\t\t// Non-component files (SDK sources, node_modules, etc.) must be skipped.\n\t\t\tif (isComponentAsset && !isComponentAsset(id)) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.transform === \"function\"\n\t\t\t\t? (plugin.transform as AnyFn).call(this, code, id)\n\t\t\t\t: null;\n\t\t},\n\t} as Plugin;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst LWC_EMPTY_CSS = \"\\0lwc-empty-css\";\n\nexport function missingCss(): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-missing-css\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\tif (!importer || !id.startsWith(\"./\") || !id.includes(\".css\")) return null;\n\t\t\tconst importerPath = importer.split(\"?\")[0] ?? importer;\n\t\t\tif (!importerPath.endsWith(\".html\")) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importerPath), id.split(\"?\")[0] ?? id);\n\t\t\tif (existsSync(resolved)) return null;\n\n\t\t\treturn `${LWC_EMPTY_CSS}?${id}`;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(LWC_EMPTY_CSS)) {\n\t\t\t\treturn \"export default undefined\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\nimport type { Provider, ScopedProvidersOptions } from \"../types\";\n\nconst VIRTUAL_PREFIX = \"\\0sf-provider:\";\n\nexport function scopedProviders(\n\tproviders: Provider[] = [],\n\toptions: ScopedProvidersOptions = {},\n): Plugin {\n\tconst { ignorePatterns = [], interceptPrefixes = [], passthroughRules = [] } = options;\n\n\tconst prefixSet = new Set<string>();\n\tfor (const p of providers) {\n\t\tif (p.prefix) prefixSet.add(p.prefix);\n\t}\n\n\tfunction shouldIntercept(id: string): boolean {\n\t\tfor (const prefix of prefixSet) {\n\t\t\tif (id === prefix || id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const prefix of interceptPrefixes) {\n\t\t\tif (id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const p of providers) {\n\t\t\tif (!p.prefix && typeof p.match === \"function\" && p.match(id)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-scoped-module-providers\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\t// Explicit provider prefix always wins over ignorePatterns —\n\t\t\t// if a provider is registered for a specifier, it always handles it.\n\t\t\tconst handledByProvider = [...prefixSet].some((p) => id === p || id.startsWith(p + \"/\"));\n\n\t\t\tif (!handledByProvider) {\n\t\t\t\tif (!shouldIntercept(id)) return null;\n\n\t\t\t\tfor (const pattern of ignorePatterns) {\n\t\t\t\t\tif (id.startsWith(pattern)) return null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const rule of passthroughRules) {\n\t\t\t\tif (\n\t\t\t\t\timporter &&\n\t\t\t\t\tid.startsWith(rule.specifierPrefix) &&\n\t\t\t\t\timporter.includes(rule.importerPattern)\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn VIRTUAL_PREFIX + id;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(VIRTUAL_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(VIRTUAL_PREFIX.length);\n\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst result = provider.resolve(specifier);\n\t\t\t\tif (result != null) return result;\n\t\t\t}\n\n\t\t\tconsole.warn(\n\t\t\t\t`[scoped-module-providers] Unhandled import: ${specifier} — returning undefined`,\n\t\t\t);\n\t\t\treturn `export default undefined;`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport type { Plugin } from \"vite\";\n\nexport interface LwcProxyOptions {\n\t/** Salesforce org alias (defaults to the sf CLI default org) */\n\torgAlias?: string;\n\t/** Enable verbose request logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that proxies Salesforce API calls to a connected org.\n *\n * Uses the same authentication approach as @salesforce/vite-plugin-ui-bundle —\n * reads credentials from the sf CLI via @salesforce/ui-bundle/app.\n *\n * Intercepts requests to /services/ and /lwr/ and forwards them to Salesforce\n * with the org's access token. Handles token refresh on 401/403 responses.\n *\n * Usage in vite.config.js:\n * import { lwcProxy } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [lwcVitePlugin(...), lwcProxy()]\n *\n * Then initialise the SDK in your app's bootstrap:\n * import { createDataSDK } from '@salesforce/sdk-data';\n * globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: '/' } });\n */\nexport function lwcProxy(options: LwcProxyOptions = {}): Plugin {\n\tlet instanceUrl: string | undefined;\n\tlet accessToken: string | undefined;\n\tconst orgAlias: string | undefined = options.orgAlias;\n\n\tasync function loadOrgInfo(): Promise<void> {\n\t\ttry {\n\t\t\t// Dynamically import to avoid bundling @salesforce/ui-bundle at build time\n\t\t\tconst { getOrgInfo } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await getOrgInfo(orgAlias);\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.log(`[lwc-proxy] Connected to ${instanceUrl}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.error(\n\t\t\t\t`[lwc-proxy] Failed to load org info — is a Salesforce org connected?\\n ${msg}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync function refreshToken(): Promise<void> {\n\t\ttry {\n\t\t\tconst { refreshOrgAuth } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await refreshOrgAuth(orgAlias ?? \"\");\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore refresh errors\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-proxy\",\n\t\tenforce: \"pre\",\n\n\t\tasync configResolved() {\n\t\t\tawait loadOrgInfo();\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.middlewares.use(async (req, res, next) => {\n\t\t\t\tconst url = req.url ?? \"\";\n\n\t\t\t\t// Only proxy Salesforce API paths\n\t\t\t\tif (!url.startsWith(\"/services/\") && !url.startsWith(\"/lwr/\")) {\n\t\t\t\t\treturn next();\n\t\t\t\t}\n\n\t\t\t\tif (!instanceUrl || !accessToken) {\n\t\t\t\t\tres.writeHead(503, { \"Content-Type\": \"application/json\" });\n\t\t\t\t\tres.end(\n\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\terror: \"SERVICE_UNAVAILABLE\",\n\t\t\t\t\t\t\tmessage: \"Salesforce org not connected. Run: sf org display\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst forward = async (token: string): Promise<void> => {\n\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\tconst targetUrl = new URL(url, instanceUrl);\n\t\t\t\t\t\tconst isHttps = targetUrl.protocol === \"https:\";\n\t\t\t\t\t\tconst transport = isHttps ? https : http;\n\n\t\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\t\tconsole.log(`[lwc-proxy] ${req.method} ${url}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip hop-by-hop headers\n\t\t\t\t\t\tconst headers: Record<string, string | string[]> = {};\n\t\t\t\t\t\tfor (const [key, value] of Object.entries(req.headers)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t![\n\t\t\t\t\t\t\t\t\t\"host\",\n\t\t\t\t\t\t\t\t\t\"connection\",\n\t\t\t\t\t\t\t\t\t\"keep-alive\",\n\t\t\t\t\t\t\t\t\t\"proxy-authenticate\",\n\t\t\t\t\t\t\t\t\t\"proxy-authorization\",\n\t\t\t\t\t\t\t\t\t\"te\",\n\t\t\t\t\t\t\t\t\t\"trailers\",\n\t\t\t\t\t\t\t\t\t\"transfer-encoding\",\n\t\t\t\t\t\t\t\t\t\"upgrade\",\n\t\t\t\t\t\t\t\t].includes(key.toLowerCase()) &&\n\t\t\t\t\t\t\t\tvalue !== undefined\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\theaders[key] = value as string | string[];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\theaders[\"host\"] = targetUrl.host;\n\t\t\t\t\t\theaders[\"authorization\"] = `Bearer ${token}`;\n\t\t\t\t\t\theaders[\"cookie\"] = `sid=${token}`;\n\n\t\t\t\t\t\tconst proxyReq = transport.request(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\t\t\thostname: targetUrl.hostname,\n\t\t\t\t\t\t\t\tport: targetUrl.port || (isHttps ? 443 : 80),\n\t\t\t\t\t\t\t\tpath: targetUrl.pathname + targetUrl.search,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(proxyRes) => {\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\tres.writeHead(proxyRes.statusCode ?? 200, proxyRes.headers);\n\t\t\t\t\t\t\t\tproxyRes.pipe(res);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treq.pipe(proxyReq);\n\t\t\t\t\t\tproxyReq.on(\"error\", reject);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\tawait forward(accessToken!);\n\n\t\t\t\t\t// On 401/403, refresh token and retry once\n\t\t\t\t\t// Note: we can't easily check status here since we piped to res,\n\t\t\t\t\t// so we rely on the transform hook below for retries in future iterations\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.error(\"[lwc-proxy] Request failed:\", error);\n\t\t\t\t\t}\n\t\t\t\t\t// Try refreshing token and retry\n\t\t\t\t\tawait refreshToken();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait forward(accessToken!);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tnext(err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { discoverModules } from \"./discovery\";\nimport { lightningNpm } from \"./plugins/lightning-npm\";\nimport { lwcBridge } from \"./plugins/lwc-bridge\";\nimport { lwcWrapper } from \"./plugins/lwc-wrapper\";\nimport { missingCss } from \"./plugins/missing-css\";\nimport { scopedProviders } from \"./plugins/scoped-providers\";\nimport * as builtinProviders from \"./providers/index\";\nimport type { DirConfig, LwcVitePluginOptions, NpmModuleConfig, Provider } from \"./types\";\n\nexport type {\n\tProvider,\n\tLwcVitePluginOptions,\n\tPassthroughRule,\n\tDiscoveredModule,\n\tDirConfig,\n} from \"./types\";\nexport { builtinProviders as builtins };\nexport { discoverModules } from \"./discovery\";\nexport { lwcProxy } from \"./plugins/proxy\";\nexport type { LwcProxyOptions } from \"./plugins/proxy\";\n\nfunction defaultProviders(): (Provider | Plugin)[] {\n\treturn [\n\t\tbuiltinProviders.label(),\n\t\tbuiltinProviders.i18n(),\n\t\tbuiltinProviders.accessCheck(),\n\t\tbuiltinProviders.client(),\n\t\tbuiltinProviders.gate(),\n\t\tbuiltinProviders.primitiveUtils(),\n\t\tbuiltinProviders.lds(),\n\t];\n}\n\n/** Distinguishes a scoped-providers `Provider` from a raw Vite `Plugin`. */\nfunction isProvider(item: Provider | Plugin): item is Provider {\n\treturn typeof (item as Provider).resolve === \"function\";\n}\n\nasync function loadLwcRollup() {\n\ttry {\n\t\t// Use dynamic import to load ESM-only @lwc/rollup-plugin (peer dep, types not guaranteed)\n\t\tconst mod = await (import(\"@lwc/rollup-plugin\") as Promise<Record<string, unknown>>);\n\t\treturn (mod[\"default\"] ?? mod) as unknown as (options: Record<string, unknown>) => Plugin;\n\t} catch (error) {\n\t\tconst errMsg = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle requires @lwc/rollup-plugin as a peer dependency. \" +\n\t\t\t\t\"Install it with: npm install -D @lwc/rollup-plugin\\n\" +\n\t\t\t\t`Debug: cwd=${process.cwd()}, error=${errMsg}`,\n\t\t);\n\t}\n}\n\nexport default function lwcVitePlugin(options: LwcVitePluginOptions = {}): Plugin[] {\n\tconst {\n\t\tmodules = {},\n\t\tproviders,\n\t\tstubs = {},\n\t\tlwcOptions = {},\n\t\tignorePatterns = [\n\t\t\t\"@salesforce/sdk-\",\n\t\t\t\"@salesforce/core\",\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle\",\n\t\t],\n\t\tpassthroughRules = [],\n\t} = options;\n\n\tconst resolvedItems = providers ?? defaultProviders();\n\tconst resolvedProviders = resolvedItems.filter(isProvider);\n\tconst rawPlugins = resolvedItems.filter((item): item is Plugin => !isProvider(item));\n\n\tconst { dirs = [], npm: npmPackages = [] } = modules;\n\n\tconst resolvedDirs: DirConfig[] = dirs.map((d) =>\n\t\ttypeof d === \"string\"\n\t\t\t? { path: path.resolve(d), namespace: \"\" }\n\t\t\t: { ...d, path: path.resolve(d.path) },\n\t);\n\n\tconst npmConfigs: NpmModuleConfig[] = npmPackages.map((pkg) =>\n\t\ttypeof pkg === \"string\" ? { npm: pkg } : pkg,\n\t);\n\n\tconst require = createRequire(import.meta.url);\n\tconst npmRoots = npmConfigs.map((cfg) => {\n\t\tconst pkgJson = require.resolve(`${cfg.npm}/package.json`);\n\t\treturn path.join(path.dirname(pkgJson), \"src\", \"lightning\");\n\t});\n\n\tconst discoveredModules = discoverModules(dirs);\n\n\tconst lwcModules = [...npmConfigs, ...discoveredModules];\n\n\tconst lightningOverrideDirs = resolvedDirs.map((d) => path.join(d.path, \"lightning\"));\n\n\tfunction isComponentAsset(id: string): boolean {\n\t\tconst clean = id.split(\"?\")[0] ?? id;\n\t\tfor (const dir of resolvedDirs) {\n\t\t\tif (clean.includes(dir.path)) return true;\n\t\t}\n\t\tfor (const cfg of npmConfigs) {\n\t\t\tif (clean.includes(cfg.npm)) return true;\n\t\t}\n\t\treturn clean.includes(\"@lwc/\") || clean.startsWith(\"\\0lwc-empty-css\");\n\t}\n\n\tconst stubAliases: Record<string, string> = {};\n\tfor (const [specifier, stubPath] of Object.entries(stubs)) {\n\t\tstubAliases[specifier] = path.resolve(stubPath);\n\t}\n\n\tconst interceptPrefixes = new Set<string>();\n\tfor (const p of resolvedProviders) {\n\t\tif (p.prefix && p.prefix.startsWith(\"@\")) {\n\t\t\tinterceptPrefixes.add(p.prefix.split(\"/\")[0] + \"/\");\n\t\t}\n\t}\n\n\tconst plugins: Plugin[] = [\n\t\t{\n\t\t\tname: \"vite-plugin-lwc-optimize-deps\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\texclude: [\"lwc\"],\n\t\t\t\t\t\tesbuildOptions: {\n\t\t\t\t\t\t\tplugins: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"lwc-html-stub\",\n\t\t\t\t\t\t\t\t\tsetup(build: {\n\t\t\t\t\t\t\t\t\t\tonResolve: (\n\t\t\t\t\t\t\t\t\t\t\toptions: { filter: RegExp },\n\t\t\t\t\t\t\t\t\t\t\tcallback: (args: { path: string }) => {\n\t\t\t\t\t\t\t\t\t\t\t\tpath: string;\n\t\t\t\t\t\t\t\t\t\t\t\texternal: boolean;\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t) => void;\n\t\t\t\t\t\t\t\t\t}) {\n\t\t\t\t\t\t\t\t\t\t// esbuild cannot process LWC HTML templates (?lwc suffix).\n\t\t\t\t\t\t\t\t\t\t// Mark them as external so Vite's own plugin handles them.\n\t\t\t\t\t\t\t\t\t\tbuild.onResolve({ filter: /\\.html/ }, (args: { path: string }) => ({\n\t\t\t\t\t\t\t\t\t\t\tpath: args.path,\n\t\t\t\t\t\t\t\t\t\t\texternal: true,\n\t\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t// plugins returned by plugin-style builtins (e.g. lds())\n\t\t...rawPlugins,\n\t\tscopedProviders(resolvedProviders, {\n\t\t\tignorePatterns,\n\t\t\tinterceptPrefixes: [...interceptPrefixes],\n\t\t\tpassthroughRules,\n\t\t}),\n\n\t\t...npmRoots.map((npmRoot) =>\n\t\t\tlightningNpm({\n\t\t\t\tnpmRoot,\n\t\t\t\toverrideDirs: lightningOverrideDirs,\n\t\t\t}),\n\t\t),\n\n\t\tmissingCss(),\n\t\tlwcBridge(isComponentAsset),\n\t\tlwcWrapper(\n\t\t\tloadLwcRollup,\n\t\t\t{\n\t\t\t\trootDir: process.cwd(),\n\t\t\t\t...lwcOptions,\n\t\t\t\tmodules: lwcModules,\n\t\t\t\texclude: [\n\t\t\t\t\t\"**/index.html\",\n\t\t\t\t\t\"**/node_modules/vite/**\",\n\t\t\t\t\t\"**/node_modules/.vite/**\",\n\t\t\t\t\t...((lwcOptions.exclude as string[]) || []),\n\t\t\t\t],\n\t\t\t},\n\t\t\tisComponentAsset,\n\t\t),\n\t];\n\n\tif (Object.keys(stubAliases).length > 0) {\n\t\tplugins.push({\n\t\t\tname: \"vite-plugin-lwc-stubs\",\n\t\t\tenforce: \"pre\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\tresolve: {\n\t\t\t\t\t\talias: stubAliases,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t}\n\n\treturn plugins;\n}\n"],"names":["builtinProviders.label","builtinProviders.i18n","builtinProviders.accessCheck","builtinProviders.client","builtinProviders.gate","builtinProviders.primitiveUtils","builtinProviders.lds","require"],"mappings":";;;;;;;;AASO,SAAS,gBAAgB,OAA+B,IAAwB;AACtF,QAAM,UAA8B,CAAA;AAEpC,aAAW,OAAO,MAAM;AACvB,UAAM,UAAU,OAAO,QAAQ,WAAW,MAAM,IAAI;AACpD,UAAM,YAAY,OAAO,QAAQ,WAAW,SAAY,IAAI;AAC5D,UAAM,cAAc,KAAK,QAAQ,OAAO;AAExC,QAAI,CAAC,WAAW,WAAW,KAAK,CAAC,SAAS,WAAW,EAAE,eAAe;AACrE;AAAA,IACD;AAEA,QAAI,WAA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AClC;AAAA,MACA,mBAAmB,CAAC,GAAG,iBAAiB;AAAA,MACxC;AAAA,IAAA,CACA;AAAA,IAED,GAAG,SAAS;AAAA,MAAI,CAAC,YAChB,aAAa;AAAA,QACZ;AAAA,QACA,cAAc;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,IAGF,WAAA;AAAA,IACA,UAAU,gBAAgB;AAAA,IAC1B;AAAA,MACC;AAAA,MACA;AAAA,QACC,SAAS,QAAQ,IAAA;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,UACA,GAAK,WAAW,WAAwB,CAAA;AAAA,QAAC;AAAA,MAC1C;AAAA,MAED;AAAA,IAAA;AAAA,EACD;AAGD,MAAI,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACxC,YAAQ,KAAK;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AACR,eAAO;AAAA,UACN,SAAS;AAAA,YACR,OAAO;AAAA,UAAA;AAAA,QACR;AAAA,MAEF;AAAA,IAAA,CACA;AAAA,EACF;AAEA,SAAO;AACR;"}
|
|
@@ -9,7 +9,6 @@ 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/index';
|
|
13
12
|
export { lds } from './lds/index';
|
|
14
|
-
export type { LdsAdapterRegistry, LdsWireAdapterConfig } from './lds/index';
|
|
13
|
+
export type { LdsAdapterConfig, LdsAdapterRegistry, LdsGraphqlImperativeReadAdapterConfig, LdsGraphqlImperativeReadInvokerShape, LdsGraphqlMutationAdapterConfig, LdsGraphqlWireAdapterConfig, LdsImperativeMutationAdapterConfig, LdsImperativeReadAdapterConfig, LdsImperativeReadInvokerShape, LdsWireAdapterConfig, } from './lds/index';
|
|
15
14
|
//# 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,
|
|
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,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,YAAY,EACX,gBAAgB,EAChB,kBAAkB,EAClB,qCAAqC,EACrC,oCAAoC,EACpC,+BAA+B,EAC/B,2BAA2B,EAC3B,kCAAkC,EAClC,8BAA8B,EAC9B,6BAA6B,EAC7B,oBAAoB,GACpB,MAAM,aAAa,CAAC"}
|
package/dist/providers/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { lightningGraphql } from "./lightning-graphql/index.js";
|
|
2
1
|
import { lds } from "./lds/index.js";
|
|
3
2
|
const LABEL_DEFAULTS = {
|
|
4
3
|
"LightningForm.edit": "Edit",
|
|
@@ -286,7 +285,6 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
286
285
|
i18n,
|
|
287
286
|
label,
|
|
288
287
|
lds,
|
|
289
|
-
lightningGraphql,
|
|
290
288
|
primitiveUtils
|
|
291
289
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
292
290
|
export {
|
|
@@ -297,7 +295,6 @@ export {
|
|
|
297
295
|
i18n,
|
|
298
296
|
label,
|
|
299
297
|
lds,
|
|
300
|
-
lightningGraphql,
|
|
301
298
|
primitiveUtils
|
|
302
299
|
};
|
|
303
300
|
//# sourceMappingURL=index.js.map
|
|
@@ -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"],"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,SAA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C9D,YAAM,QAAQ,UAAU,IAAI,KAAK;AACjC,aAAO,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;;;;;;;;;;;;"}
|
|
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,E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;AAAA,IAChD;AAAA,EAAA;AAEF;ACVO,SAAS,YAAY,YAAqC,IAAc;AAC9E,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,CAAC,UAAU,WAAW,0BAA0B,EAAG,QAAO;AAC9D,YAAM,OAAO,UAAU,MAAM,2BAA2B,MAAM;AAC9D,YAAM,QAAQ,UAAU,IAAI,KAAK;AACjC,aAAO,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;;;;;;;;;;;"}
|
|
@@ -36,7 +36,52 @@ export interface LdsImperativeReadAdapterConfig {
|
|
|
36
36
|
toolName: string;
|
|
37
37
|
configJsonSchema: JSONSchema;
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* GraphQL wire adapter. Emits `{ data, errors, refresh }` (distinct from the
|
|
41
|
+
* base wire `{ data, error }`). No `configJsonSchema` — the adapter passes
|
|
42
|
+
* `{ query, variables }` through to the configured MCP tool.
|
|
43
|
+
*/
|
|
44
|
+
export interface LdsGraphqlWireAdapterConfig {
|
|
45
|
+
type: "graphql-wire";
|
|
46
|
+
toolName: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Imperative GraphQL mutation — `(config) => Promise<{ data, errors }>`.
|
|
50
|
+
* Errors are routed in-band to the `errors[]` envelope rather than thrown,
|
|
51
|
+
* matching on-platform `toGraphQLResponseFromFailure`.
|
|
52
|
+
*/
|
|
53
|
+
export interface LdsGraphqlMutationAdapterConfig {
|
|
54
|
+
type: "graphql-mutation";
|
|
55
|
+
toolName: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Read-shape discriminator for imperative GraphQL adapters. Mirrors the
|
|
59
|
+
* `imperative-read` `invokerShape` field so the two families share a pattern:
|
|
60
|
+
* one `type` discriminator + a shape field that selects the return surface.
|
|
61
|
+
*
|
|
62
|
+
* - `query` — `Promise<{ data, errors, subscribe }>` (on-platform
|
|
63
|
+
* `GraphQLImperativeBindingsService` without `exposeRefresh`).
|
|
64
|
+
* - `query-refreshable` — `Promise<{ data, errors, subscribe, refresh }>`
|
|
65
|
+
* (same service with `exposeRefresh: true`).
|
|
66
|
+
* - `legacy` — `{ invoke(config, context, callback),
|
|
67
|
+
* subscribe(config, context, callback): Unsubscribe }`, the older callback
|
|
68
|
+
* surface served by `GraphQLLegacyImperativeBindingsService`.
|
|
69
|
+
*
|
|
70
|
+
* `subscribe` is a deliberate no-op off-platform (no reactive store).
|
|
71
|
+
*/
|
|
72
|
+
export type LdsGraphqlImperativeReadInvokerShape = "query" | "query-refreshable" | "legacy";
|
|
73
|
+
/**
|
|
74
|
+
* Imperative GraphQL read adapter. The `invokerShape` picks the return
|
|
75
|
+
* surface — see {@link LdsGraphqlImperativeReadInvokerShape}. Errors are
|
|
76
|
+
* routed in-band to `errors[]` (for `query`/`query-refreshable`) or into the
|
|
77
|
+
* callback payload (for `legacy`); no shape throws on tool errors.
|
|
78
|
+
*/
|
|
79
|
+
export interface LdsGraphqlImperativeReadAdapterConfig {
|
|
80
|
+
type: "graphql-imperative-read";
|
|
81
|
+
invokerShape: LdsGraphqlImperativeReadInvokerShape;
|
|
82
|
+
toolName: string;
|
|
83
|
+
}
|
|
84
|
+
export type LdsAdapterConfig = LdsWireAdapterConfig | LdsImperativeMutationAdapterConfig | LdsImperativeReadAdapterConfig | LdsGraphqlWireAdapterConfig | LdsGraphqlMutationAdapterConfig | LdsGraphqlImperativeReadAdapterConfig;
|
|
40
85
|
export type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>>;
|
|
41
86
|
/**
|
|
42
87
|
* LDS provider — rewrites registered `lightning/*` imports (e.g.
|
|
@@ -61,5 +106,5 @@ export type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>
|
|
|
61
106
|
* Only specifiers present in the `adapters` registry are intercepted; imports from
|
|
62
107
|
* unregistered specifiers pass through unchanged.
|
|
63
108
|
*/
|
|
64
|
-
export declare function lds(
|
|
109
|
+
export declare function lds(overrides?: LdsAdapterRegistry): Plugin;
|
|
65
110
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAuChD,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,g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 @@ import { init, parse } from "es-module-lexer";
|
|
|
5
5
|
import MagicString from "magic-string";
|
|
6
6
|
const ADAPTER_PREFIX = "sf-lds-adapter:";
|
|
7
7
|
const ADAPTER_ID_PREFIX = "\0" + ADAPTER_PREFIX;
|
|
8
|
-
const adapterBaseSource =
|
|
9
|
-
join(dirname(fileURLToPath(import.meta.url)), "runtime.js"),
|
|
10
|
-
"utf-8"
|
|
8
|
+
const adapterBaseSource = stripTopLevelExports(
|
|
9
|
+
readFileSync(join(dirname(fileURLToPath(import.meta.url)), "runtime.js"), "utf-8")
|
|
11
10
|
);
|
|
11
|
+
function stripTopLevelExports(source) {
|
|
12
|
+
return source.replace(/^export\s+(?=(?:async\s+)?function\s)/gm, "").replace(/^export\s*\{[^}]*};?\s*$/gm, "");
|
|
13
|
+
}
|
|
12
14
|
const DEFAULT_ADAPTERS = {
|
|
13
15
|
"lightning/uiRecordApi": {
|
|
14
16
|
getRecord: {
|
|
@@ -105,8 +107,37 @@ const DEFAULT_ADAPTERS = {
|
|
|
105
107
|
additionalProperties: false
|
|
106
108
|
}
|
|
107
109
|
}
|
|
110
|
+
},
|
|
111
|
+
// `lightning/graphql` — on-platform exports `gql`, the `graphql` wire
|
|
112
|
+
// adapter, and `executeMutation`. Only `graphql` and `executeMutation`
|
|
113
|
+
// are registry entries; `gql` rides along automatically for any specifier
|
|
114
|
+
// that has at least one graphql-typed entry (emitted by the load hook).
|
|
115
|
+
"lightning/graphql": {
|
|
116
|
+
graphql: { type: "graphql-wire", toolName: "graphqlQuery" },
|
|
117
|
+
executeMutation: { type: "graphql-mutation", toolName: "graphqlQuery" }
|
|
108
118
|
}
|
|
109
119
|
};
|
|
120
|
+
function isGraphqlSpecifier(moduleAdapters) {
|
|
121
|
+
return Object.values(moduleAdapters).some(
|
|
122
|
+
(entry) => entry.type === "graphql-wire" || entry.type === "graphql-mutation" || entry.type === "graphql-imperative-read"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
function factoryFor(type) {
|
|
126
|
+
switch (type) {
|
|
127
|
+
case "wire":
|
|
128
|
+
return "createWireAdapter";
|
|
129
|
+
case "imperative-mutation":
|
|
130
|
+
return "createMutationAdapter";
|
|
131
|
+
case "imperative-read":
|
|
132
|
+
return "createReadAdapter";
|
|
133
|
+
case "graphql-wire":
|
|
134
|
+
return "createGraphQLWireAdapter";
|
|
135
|
+
case "graphql-mutation":
|
|
136
|
+
return "createGraphQLMutationAdapter";
|
|
137
|
+
case "graphql-imperative-read":
|
|
138
|
+
return "createGraphQLImperativeReadAdapter";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
110
141
|
function parseImportSpecifiers(bracesContent) {
|
|
111
142
|
return bracesContent.split(",").map((s) => s.trim()).filter(Boolean).map((entry) => {
|
|
112
143
|
const asIdx = entry.indexOf(" as ");
|
|
@@ -114,8 +145,20 @@ function parseImportSpecifiers(bracesContent) {
|
|
|
114
145
|
return { original, full: entry };
|
|
115
146
|
});
|
|
116
147
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
148
|
+
function mergeWithDefaults(overrides) {
|
|
149
|
+
const merged = { ...DEFAULT_ADAPTERS };
|
|
150
|
+
for (const [specifier, entries] of Object.entries(overrides)) {
|
|
151
|
+
merged[specifier] = { ...DEFAULT_ADAPTERS[specifier] ?? {}, ...entries };
|
|
152
|
+
}
|
|
153
|
+
return merged;
|
|
154
|
+
}
|
|
155
|
+
function lds(overrides = {}) {
|
|
156
|
+
const adapters = mergeWithDefaults(overrides);
|
|
157
|
+
const graphqlSpecifiers = new Set(
|
|
158
|
+
Object.entries(adapters).filter(([, moduleAdapters]) => isGraphqlSpecifier(moduleAdapters)).map(([specifier]) => specifier)
|
|
159
|
+
);
|
|
160
|
+
const transformSpecifiers = Object.keys(adapters).filter((s) => !graphqlSpecifiers.has(s));
|
|
161
|
+
const specifierSnippets = transformSpecifiers.flatMap((s) => [`'${s}'`, `"${s}"`]);
|
|
119
162
|
return {
|
|
120
163
|
name: "vite-plugin-lds",
|
|
121
164
|
enforce: "pre",
|
|
@@ -132,7 +175,7 @@ function lds(adapters = DEFAULT_ADAPTERS) {
|
|
|
132
175
|
return null;
|
|
133
176
|
}
|
|
134
177
|
const relevant = imports.filter(
|
|
135
|
-
(imp) => imp.d === -1 && imp.n !== void 0 && imp.n in adapters
|
|
178
|
+
(imp) => imp.d === -1 && imp.n !== void 0 && imp.n in adapters && !graphqlSpecifiers.has(imp.n)
|
|
136
179
|
);
|
|
137
180
|
if (relevant.length === 0) return null;
|
|
138
181
|
const s = new MagicString(code);
|
|
@@ -164,6 +207,7 @@ function lds(adapters = DEFAULT_ADAPTERS) {
|
|
|
164
207
|
return { code: s.toString(), map: s.generateMap({ hires: true }) };
|
|
165
208
|
},
|
|
166
209
|
resolveId(id) {
|
|
210
|
+
if (graphqlSpecifiers.has(id)) return ADAPTER_ID_PREFIX + id;
|
|
167
211
|
if (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);
|
|
168
212
|
return null;
|
|
169
213
|
},
|
|
@@ -175,11 +219,13 @@ function lds(adapters = DEFAULT_ADAPTERS) {
|
|
|
175
219
|
const lines = [adapterBaseSource];
|
|
176
220
|
for (const [name, entry] of Object.entries(moduleAdapters)) {
|
|
177
221
|
const { type, ...cfg } = entry;
|
|
178
|
-
const factory = type === "wire" ? "createWireAdapter" : type === "imperative-mutation" ? "createMutationAdapter" : "createReadAdapter";
|
|
179
222
|
lines.push(
|
|
180
|
-
`export const ${name} = ${
|
|
223
|
+
`export const ${name} = ${factoryFor(type)}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`
|
|
181
224
|
);
|
|
182
225
|
}
|
|
226
|
+
if (graphqlSpecifiers.has(specifier)) {
|
|
227
|
+
lines.push("export { gql };");
|
|
228
|
+
}
|
|
183
229
|
return lines.join("\n");
|
|
184
230
|
}
|
|
185
231
|
};
|