@locker/cli 0.28.4 → 0.28.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -227,6 +227,8 @@ The compiler runs with `enableLightningWebSecurityTransforms: true` — the same
227
227
  - `--name <tag-name>` — override the derived custom-element tag name. By default the tag is camelCase → kebab-case (`helloWorld` → `hello-world`).
228
228
  - `--namespace <ns>` — override the LWC namespace. Default is `c`.
229
229
  - `--lwc-modules <dir>`: additional LWC namespace-root directory the compiler should resolve imports from. Repeatable; argv-order is preserved (first match wins). Layered before the implicit grandparent default, so an explicit `--lwc-modules` path takes precedence when both have the same `<ns>/<name>`. Use this to point the compiler at vendored or first-party component sources (`lightning/`, `ui/`, project-local namespaces, etc.) that live outside the component's own directory tree.
230
+ - `--wire-mode <mode>`: auto-mock the component's `@wire` adapters so it renders on a laptop with no scratch-org deploy. Takes an explicit value: `--wire-mode=success` feeds each adapter fabricated data (the data branch); `--wire-mode=error` fires each adapter's error callback instead (the error branch), so you can exercise a component's error UI. There is no bare form; the value must be `success` or `error`. See "Wire auto-mocking" below for how the data is chosen and how it is reported. Omit the flag entirely and adapters are left untouched (the default). Config key: `wireMode`.
231
+ - `--wire-fixtures <adapter>=<path-to-json>`: supply your own mock data for one adapter, overriding whatever `--wire-mode` would have chosen for it. `<adapter>` is either the module specifier (`lightning/uiRecordApi`) or the adapter export name (`getRecord`); `<path-to-json>` is a JSON file whose parsed contents become the adapter's `data`. Repeatable (one adapter per occurrence, last wins on a duplicate). A file that is missing or is not valid JSON fails the run before a browser launches. Only meaningful together with `--wire-mode`. Config key: `wireFixtures`.
230
232
 
231
233
  ### Examples
232
234
 
@@ -282,6 +284,57 @@ lws component ./my-component --lwc-modules ./vendor/components
282
284
  lws component ./my-component \
283
285
  --lwc-modules ./vendor/lightning-base \
284
286
  --lwc-modules ./vendor/ui-base
287
+
288
+ # Auto-mock a component's @wire adapters so it renders locally with no
289
+ # scratch-org deploy. Every adapter gets fabricated data, and a
290
+ # [wire mock] marker prints to stderr per adapter.
291
+ lws component ./my-component --wire-mode=success
292
+
293
+ # Exercise the component's error UI instead: every adapter fires its
294
+ # error callback rather than its data callback.
295
+ lws component ./my-component --wire-mode=error
296
+
297
+ # Supply your own data for one adapter, letting the rest auto-mock.
298
+ # The adapter can be named by module specifier or by export name.
299
+ lws component ./my-component \
300
+ --wire-mode=success \
301
+ --wire-fixtures getRecord=./fixtures/record.json
302
+ ```
303
+
304
+ ### Wire auto-mocking (`--wire-mode` / `--wire-fixtures`)
305
+
306
+ An LWC that uses `@wire` normally needs a live Salesforce org: `lightning/uiRecordApi`, `@salesforce/schema/*`, and `@salesforce/apex/*` all resolve to org-provided modules that do not exist on a laptop. Without them the compile externalizes the import and the render throws at runtime on the missing binding. `--wire-mode` closes that gap by supplying each `@wire` adapter a synthetic implementation so the component renders locally.
307
+
308
+ **Turning it on.** `--wire-mode` takes an explicit value:
309
+
310
+ - `--wire-mode=success` feeds every adapter fabricated data (fires the adapter's data callback).
311
+ - `--wire-mode=error` fires every adapter's error callback instead, with a `FetchResponse`-shaped error object, so a component's error branch and error UI are exercised.
312
+
313
+ There is no bare `--wire-mode`; the value is required and must be `success` or `error`. Omit the flag and adapters are untouched (unchanged from a normal `lws component` run).
314
+
315
+ **Where the fake data comes from.** For each adapter, the data is resolved through a four-step ladder, highest priority first:
316
+
317
+ 1. **Your override.** A `--wire-fixtures <adapter>=<path.json>` for that adapter. The parsed JSON becomes the adapter's `data` verbatim.
318
+ 2. **A curated shape.** For a known platform adapter (`getRecord`, `getRecords`, `getObjectInfo`, `getPicklistValues`, `getRelatedListRecords`), a hand-authored shape that matches the adapter's real payload. Values for the `@salesforce/schema` fields the component declares are filled in from the field name (a `Name` field gets a plausible name string, and so on).
319
+ 3. **An inferred shape.** For any other adapter (including `@salesforce/apex/*` methods), the component's own source is scanned for the `this.<wired>.data.<path>` properties it reads, and an object with exactly those paths present is synthesized. This is enough to get the component past its `if (this.x.data)` guards and render.
320
+ 4. **Empty.** If none of the above apply, the adapter emits `null` data (the component renders in its no-data state).
321
+
322
+ **How it is reported.** Fabricated data must never be mistaken for real data, so every mocked adapter prints one line to stderr:
323
+
324
+ ```
325
+ [wire mock] getRecord -> A/success
326
+ ```
327
+
328
+ The suffix names which rung of the ladder supplied the data (`override`, `A` for curated, `B` for inferred, or `null`) and the mode (`success` or `error`). One line per adapter.
329
+
330
+ **Overriding one adapter.** `--wire-fixtures <adapter>=<path.json>` supplies your own data for a single adapter while the rest auto-mock. Name the adapter by module specifier (`lightning/uiRecordApi`) or by export name (`getRecord`). The flag is repeatable (one adapter per occurrence, last wins if you name the same adapter twice). A path that is missing or is not valid JSON fails the run before a browser launches, so a typo is caught immediately rather than surfacing as a confusing render error.
331
+
332
+ ```sh
333
+ # fixtures/record.json:
334
+ # { "fields": { "Name": { "value": "Acme Corp" } } }
335
+ lws component ./recordCard \
336
+ --wire-mode=success \
337
+ --wire-fixtures getRecord=./fixtures/record.json
285
338
  ```
286
339
 
287
340
  ---
@@ -505,7 +558,7 @@ export default {
505
558
  };
506
559
  ```
507
560
 
508
- Keys are camelCase because a few flags are kebab-case on the command line: `--lwc-modules` is `lwcModules`, `--gates-on` is `gatesOn`, and `--gates-off` is `gatesOff` in the file. Everything else is the flag name verbatim (`browser`, `headed`, `key`, `port`, `before`, `after`, `endowments`, `timeout`, `json`, `quiet`, `verbose`, `watch`, `name`, `namespace`). The array-valued keys (`before`, `after`, `lwcModules`, `gatesOn`, `gatesOff`) take an array of strings; `gatesOn`/`gatesOff` also accept a single comma-separated string for convenience. An unknown key (a typo like `broswer`) fails the run with a message naming the offending key and the file it came from, so a misspelling never silently does nothing.
561
+ Keys are camelCase because a few flags are kebab-case on the command line: `--lwc-modules` is `lwcModules`, `--gates-on` is `gatesOn`, `--gates-off` is `gatesOff`, and `--wire-mode` is `wireMode` in the file. Everything else is the flag name verbatim (`browser`, `headed`, `key`, `port`, `before`, `after`, `endowments`, `timeout`, `json`, `quiet`, `verbose`, `watch`, `name`, `namespace`, `wireFixtures`). The array-valued keys (`before`, `after`, `lwcModules`, `gatesOn`, `gatesOff`, `wireFixtures`) take an array of strings; `gatesOn`/`gatesOff` also accept a single comma-separated string for convenience. `wireMode` is a single string (`'success'` or `'error'`); `wireFixtures` is an array of `<adapter>=<path.json>` strings. An unknown key (a typo like `broswer`) fails the run with a message naming the offending key and the file it came from, so a misspelling never silently does nothing.
509
562
 
510
563
  ### How a config value is resolved (the cascade)
511
564
 
package/bin/lws.mjs CHANGED
@@ -4,7 +4,7 @@ import { hideBin } from 'yargs/helpers';
4
4
  import yargs from 'yargs/yargs';
5
5
 
6
6
  import { BUILTIN_DEFAULTS, resolveConfig } from '../src/config-resolver.mjs';
7
- import { SUPPORTED_BROWSERS } from '../src/constants.mjs';
7
+ import { SUPPORTED_BROWSERS, WIRE_MOCK_MODES } from '../src/constants.mjs';
8
8
  import { assertPlaywrightInstalled } from '../src/playwright-check.mjs';
9
9
 
10
10
  // The command modules (runner.mjs, repl.mjs) statically import
@@ -273,6 +273,40 @@ await yargs(hideBin(process.argv))
273
273
  nargs: 1,
274
274
  default: config.lwcModules ?? BUILTIN_DEFAULTS.lwcModules,
275
275
  })
276
+ // Wire auto-mocking (D16). Takes an explicit value:
277
+ // --wire-mode=success renders each @wire adapter with fake
278
+ // data; --wire-mode=error fires its error branch instead.
279
+ // There is no bare form: yargs cannot express a
280
+ // bare-or-`=value` optional-value flag that is also safe next
281
+ // to the required <directory> positional (a bare flag
282
+ // greedily consumes the positional as its value). A plain
283
+ // string+choices option sidesteps that: the value only
284
+ // attaches via `=`, so the positional is never eaten, and
285
+ // yargs validates the value natively, so argv.wireMode is
286
+ // already `undefined | 'success' | 'error'` with no coercion.
287
+ // WIRE_MOCK_MODES comes from constants.mjs (Playwright-free)
288
+ // so this validates without loading wire-mock.mjs + babel.
289
+ .option('wire-mode', {
290
+ describe:
291
+ 'Auto-mock @wire adapters so the component renders locally: =success fills fake data, =error fires the error branch. Prints a [wire mock] marker per adapter.',
292
+ choices: WIRE_MOCK_MODES,
293
+ type: 'string',
294
+ default: config.wireMode ?? BUILTIN_DEFAULTS.wireMode,
295
+ })
296
+ // Per-adapter explicit fixture data, overriding the auto shape.
297
+ // Repeatable `<adapter>=<path-to-json>`, argv-order (last
298
+ // wins on a duplicate adapter). The adapter is a module
299
+ // specifier (lightning/uiRecordApi) or an export name
300
+ // (getRecord). Same array/nargs:1 shape as --lwc-modules;
301
+ // the config key is camelCase (wireFixtures).
302
+ .option('wire-fixtures', {
303
+ describe:
304
+ 'Explicit fixture data for one @wire adapter: <adapter>=<path-to-json> (repeatable). Overrides the auto-mock shape for that adapter.',
305
+ type: 'string',
306
+ array: true,
307
+ nargs: 1,
308
+ default: config.wireFixtures ?? BUILTIN_DEFAULTS.wireFixtures,
309
+ })
276
310
  .option('watch', {
277
311
  describe: 'Re-compile and reload when files in the directory change',
278
312
  type: 'boolean',
package/dist/index.cjs.js CHANGED
@@ -2,4 +2,4 @@
2
2
  * Copyright (C) 2026 salesforce.com, inc.
3
3
  */
4
4
  'use strict';
5
- /*! version: 0.28.4 */
5
+ /*! version: 0.28.6 */
package/dist/index.mjs.js CHANGED
@@ -2,4 +2,4 @@
2
2
  * Copyright (C) 2026 salesforce.com, inc.
3
3
  */
4
4
 
5
- /*! version: 0.28.4 */
5
+ /*! version: 0.28.6 */
@@ -1369,7 +1369,7 @@
1369
1369
  // reads identically to what isGaterEnabledFeature stores (register and
1370
1370
  // deregister also accept the short form via fullName above). Frozen so a
1371
1371
  // consumer cannot mutate the shared array.
1372
- Object.freeze([`${FEATURE_NAME_PREFIX$LWS}changesSince.256`, `${FEATURE_NAME_PREFIX$LWS}changesSince.258`, `${FEATURE_NAME_PREFIX$LWS}changesSince.260`, `${FEATURE_NAME_PREFIX$LWS}changesSince.262`, `${FEATURE_NAME_PREFIX$LWS}changesSince.264`, `${FEATURE_NAME_PREFIX$LWS}htmlAnchorElementHrefValidation`, `${FEATURE_NAME_PREFIX$LWS}enableSandboxedSameOriginIframe`, `${FEATURE_NAME_PREFIX$LWS}xmlEntityAttackPrologScan`]);
1372
+ Object.freeze([`${FEATURE_NAME_PREFIX$LWS}changesSince.260`, `${FEATURE_NAME_PREFIX$LWS}changesSince.262`, `${FEATURE_NAME_PREFIX$LWS}changesSince.264`, `${FEATURE_NAME_PREFIX$LWS}htmlAnchorElementHrefValidation`, `${FEATURE_NAME_PREFIX$LWS}enableSandboxedSameOriginIframe`, `${FEATURE_NAME_PREFIX$LWS}xmlEntityAttackPrologScan`]);
1373
1373
  function registerGaterEnabledFeatures$LWS(lockerGaterEnabledFeatures$LWS) {
1374
1374
  if (ArrayIsArray$LWS$1(lockerGaterEnabledFeatures$LWS)) {
1375
1375
  lockerGaterEnabledFeatures$LWS.forEach(feature$LWS => gaterEnabledFeatures$LWS.add(fullName$LWS(feature$LWS)));
@@ -1539,7 +1539,7 @@
1539
1539
  const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
1540
1540
  const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
1541
1541
  toSafeSet$LWS(new SetCtor$LWS$1());
1542
- /*! version: 0.28.4 */
1542
+ /*! version: 0.28.6 */
1543
1543
 
1544
1544
  /*!
1545
1545
  * Copyright (C) 2019 salesforce.com, inc.
@@ -1998,15 +1998,43 @@
1998
1998
  const lowerCasedInput$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, toSafeStringValue$LWS(input$LWS), []);
1999
1999
  return ReflectApply$LWS$1(StringProtoReplace$LWS, lowerCasedInput$LWS, [INVISIBLE_CHARS_REGEX$LWS, replacement$LWS]);
2000
2000
  }
2001
- // Regex to detect DOCTYPE with internal DTD subset containing entity definitions.
2002
- // Matches: <!DOCTYPE root [...anything...]>
2003
- // The internal subset can contain ENTITY, ELEMENT, ATTLIST, NOTATION declarations.
2004
- // This is an XXE attack vector where entities can contain malicious script content.
2005
- const DOCTYPE_WITH_INTERNAL_SUBSET_REGEX$LWS = /<!doctype\s+\S+\s*\[/;
2006
- // Regex to detect DOCTYPE with SYSTEM or PUBLIC external entity references.
2007
- // Matches: <!DOCTYPE root SYSTEM "..."> or <!DOCTYPE root PUBLIC "..." "...">
2008
- // External DTDs can define entities that get expanded with malicious content.
2009
- const DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS = /<!doctype\s+\S+\s+(?:system|public)\s/;
2001
+ // Regexes to detect a dangerous DOCTYPE — one carrying an internal DTD subset
2002
+ // (e.g. <!DOCTYPE root [...]>, which can hold ENTITY/ELEMENT/ATTLIST/NOTATION
2003
+ // declarations) or a SYSTEM/PUBLIC external-entity reference. Both are XXE
2004
+ // vectors: entities can be expanded with malicious content when the markup is
2005
+ // parsed as XML/SVG.
2006
+ //
2007
+ // These UNANCHORED forms are used only by the legacy whole-input fallback (when
2008
+ // the prolog-scan gate is off). They must match a DOCTYPE anywhere in the input,
2009
+ // so they cannot be anchored. The root-name token is [^>\s]+ (not \S+) so it
2010
+ // cannot span a DOCTYPE's own closing `>`, which trims — but does not eliminate —
2011
+ // bridging across unrelated downstream text in the broad scan. The prolog-scan
2012
+ // path below uses the anchored forms instead, which is the accurate check.
2013
+ const DOCTYPE_WITH_INTERNAL_SUBSET_REGEX$LWS = /<!doctype\s+[^>\s]+\s*\[/;
2014
+ const DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS = /<!doctype\s+[^>\s]+\s+(?:system|public)\s/;
2015
+ // Anchored forms of the two DOCTYPE checks, used by the prolog-scan path.
2016
+ // findPrologDoctype() returns a slice that begins EXACTLY at the document's
2017
+ // prolog DOCTYPE — the only DOCTYPE a parser treats as a DTD. Anchoring with `^`
2018
+ // classifies that leading DOCTYPE and nothing else, so the regex cannot scan
2019
+ // downstream and re-match a later, inert `<!DOCTYPE ...` that is merely source
2020
+ // text — e.g. a string literal inside a minified XML-serializer bundle that
2021
+ // builds `"<!DOCTYPE "+rootName+" PUBLIC ..."`. Such a literal has no `>` between
2022
+ // `<!doctype` and `public`, so the unanchored [^>\s]+ bound alone does not stop
2023
+ // it; anchoring to the prolog slice does. (W-23591510-r1: the print-iframe fix
2024
+ // bounded the token but left the regex free to roam the whole 30 KB–2 MB slice.)
2025
+ const PROLOG_DOCTYPE_INTERNAL_SUBSET_REGEX$LWS = /^<!doctype\s+[^>\s]+\s*\[/;
2026
+ const PROLOG_DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS = /^<!doctype\s+[^>\s]+\s+(?:system|public)\s/;
2027
+ // Regex to detect a namespaced <script> whose start tag carries an xmlns
2028
+ // declaration. Matches <script or <prefix:script (the leading [<:]), then a
2029
+ // whitespace or `/` separator so decoy tags like <scripting> or <scriptx> are
2030
+ // not matched, then scans the start tag up to xmlns. The gap alternation treats
2031
+ // quoted attribute values as opaque ("[^"]*" and '[^']*') so a `>` inside an
2032
+ // attribute value (e.g. title=">") cannot prematurely end the start tag and let
2033
+ // the real xmlns escape the scan. Requiring xmlns inside the script start tag —
2034
+ // rather than anywhere in the body — is what distinguishes the executable XML
2035
+ // namespaced-script vector from benign HTML that merely mentions "xmlns"
2036
+ // elsewhere (e.g. a sanitizer's attribute allowlist).
2037
+ const NAMESPACED_SCRIPT_XMLNS_REGEX$LWS = /[<:]script[\s/](?:[^>"']|"[^"]*"|'[^']*')*xmlns/;
2010
2038
  const DOCTYPE_OPENER$LWS = '<!doctype';
2011
2039
  const PI_OPENER$LWS = '<?';
2012
2040
  const PI_CLOSER$LWS = '?>';
@@ -2106,7 +2134,7 @@
2106
2134
  if (prologDoctype$LWS === null) {
2107
2135
  return false;
2108
2136
  }
2109
- return ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_WITH_INTERNAL_SUBSET_REGEX$LWS, [prologDoctype$LWS]) || ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS, [prologDoctype$LWS]);
2137
+ return ReflectApply$LWS$1(RegExpProtoTest$LWS$1, PROLOG_DOCTYPE_INTERNAL_SUBSET_REGEX$LWS, [prologDoctype$LWS]) || ReflectApply$LWS$1(RegExpProtoTest$LWS$1, PROLOG_DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS, [prologDoctype$LWS]);
2110
2138
  }
2111
2139
  return ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_WITH_INTERNAL_SUBSET_REGEX$LWS, [normalizedInput$LWS]) || ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS, [normalizedInput$LWS]);
2112
2140
  };
@@ -2116,10 +2144,18 @@
2116
2144
  // when the namespace is XHTML or SVG. The namespace URL itself can be
2117
2145
  // obfuscated with XML character entities in attribute values, but the
2118
2146
  // xmlns attribute name cannot, so checking for "xmlns" is reliable.
2147
+ //
2148
+ // The xmlns must appear inside the script start tag for the namespace to
2149
+ // apply to that script. An earlier form only checked for a <script> tag and
2150
+ // the substring "xmlns" anywhere in the body; that false-positived on benign
2151
+ // HTML that carries a plain <script> and also mentions "xmlns" in an
2152
+ // unrelated place (a sanitizer's attribute allowlist, an SVG child element,
2153
+ // a string literal). NAMESPACED_SCRIPT_XMLNS_REGEX ties the two together by
2154
+ // scanning from the script start tag to xmlns within the same tag.
2119
2155
  // eslint-disable-next-line class-methods-use-this
2120
2156
  this.isXMLNamespacedScriptAttack = input$LWS => {
2121
- const normalizedInput$LWS = normalizeInput$LWS(input$LWS);
2122
- return hasTag$LWS(normalizedInput$LWS, 'script') && ReflectApply$LWS$1(StringProtoIncludes$LWS, normalizedInput$LWS, ['xmlns']);
2157
+ const normalizedInput$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, normalizeInput$LWS(input$LWS), [/\s+/g, ' ']);
2158
+ return ReflectApply$LWS$1(RegExpProtoTest$LWS$1, NAMESPACED_SCRIPT_XMLNS_REGEX$LWS, [normalizedInput$LWS]);
2123
2159
  };
2124
2160
  // Detects the iframe+srcdoc substring combination in raw input.
2125
2161
  // Any HTML or XML containing both <iframe> and the substring
@@ -2284,11 +2320,8 @@
2284
2320
  return false;
2285
2321
  }
2286
2322
  function hasTag$LWS(input$LWS, tag$LWS) {
2287
- let checkableInput$LWS = input$LWS;
2288
- if (isGaterEnabledFeature$LWS('changesSince.256')) {
2289
- // Input is already lowercased and invisible chars stripped by caller
2290
- checkableInput$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, input$LWS, [/\s+/g, ' ']);
2291
- }
2323
+ // Input is already lowercased and invisible chars stripped by caller
2324
+ const checkableInput$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, input$LWS, [/\s+/g, ' ']);
2292
2325
  // Match <tag or :tag (namespaced) followed by whitespace, >, /
2293
2326
  // Also match when directly followed by src or srcdoc (null byte was stripped)
2294
2327
  const tagPattern$LWS = new RegExpCtor$LWS$1(`[<:]${tag$LWS}(?:[\\s>/]|(?=src))`);
@@ -2622,7 +2655,7 @@
2622
2655
  const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
2623
2656
  const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
2624
2657
  ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
2625
- /*! version: 0.28.4 */
2658
+ /*! version: 0.28.6 */
2626
2659
 
2627
2660
  /*!
2628
2661
  * Copyright (C) 2019 salesforce.com, inc.
@@ -2790,7 +2823,7 @@
2790
2823
  }
2791
2824
  return sanitized$LWS;
2792
2825
  }
2793
- /*! version: 0.28.4 */
2826
+ /*! version: 0.28.6 */
2794
2827
 
2795
2828
  /*!
2796
2829
  * Copyright (C) 2023 salesforce.com, inc.
@@ -2866,7 +2899,7 @@
2866
2899
  // swallow
2867
2900
  }
2868
2901
  const trusted = createPolicy('trusted', policyOptions);
2869
- /*! version: 0.28.4 */
2902
+ /*! version: 0.28.6 */
2870
2903
 
2871
2904
  /*!
2872
2905
  * Copyright (C) 2019 salesforce.com, inc.
@@ -3175,7 +3208,7 @@
3175
3208
  }
3176
3209
  return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
3177
3210
  }
3178
- /*! version: 0.28.4 */
3211
+ /*! version: 0.28.6 */
3179
3212
 
3180
3213
  /*!
3181
3214
  * Copyright (C) 2023 salesforce.com, inc.
@@ -3384,7 +3417,7 @@
3384
3417
  ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
3385
3418
  };
3386
3419
  }
3387
- /*! version: 0.28.4 */
3420
+ /*! version: 0.28.6 */
3388
3421
 
3389
3422
  /*!
3390
3423
  * Copyright (C) 2019 salesforce.com, inc.
@@ -5488,14 +5521,8 @@
5488
5521
  }
5489
5522
  const childWindow$LWS = ReflectApply$LWS$1(originalDocumentOpen$LWS, this, normalizedArgs$LWS);
5490
5523
  // istanbul ignore next: behavior will not be tested in collection coverage
5491
- if (!isGaterEnabledFeature$LWS('changesSince.262')) {
5492
- if (isGaterEnabledFeature$LWS('changesSince.256')) {
5493
- if (isSameOriginURL$LWS(resourceUrl$LWS)) {
5494
- markForUnsafePropertyBlocking$LWS(childWindow$LWS);
5495
- }
5496
- } else {
5497
- markForUnsafePropertyBlocking$LWS(childWindow$LWS);
5498
- }
5524
+ if (!isGaterEnabledFeature$LWS('changesSince.262') && isSameOriginURL$LWS(resourceUrl$LWS)) {
5525
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
5499
5526
  }
5500
5527
  if (childWindow$LWS) {
5501
5528
  initWindowOpenChildWindow$LWS(childWindow$LWS, resourceUrl$LWS);
@@ -7884,14 +7911,12 @@
7884
7911
  if (urlString$LWS && !isValidURLScheme$LWS(urlString$LWS)) {
7885
7912
  throw new LockerSecurityError$LWS('HTMLIFrameElement.src supports http://, https:// schemes, relative urls and about:blank.');
7886
7913
  }
7887
- if (isGaterEnabledFeature$LWS('changesSince.258')) {
7888
- const parsedURL$LWS = parseURL$LWS(urlString$LWS);
7889
- if (!isAllowedEndpointURL$LWS(parsedURL$LWS)) {
7890
- const {
7891
- normalizedURL: normalizedURL$LWS
7892
- } = parsedURL$LWS;
7893
- throw new LockerSecurityError$LWS(`Cannot request disallowed endpoint: ${toSafeTemplateStringValue$LWS(normalizedURL$LWS)}`);
7894
- }
7914
+ const parsedURL$LWS = parseURL$LWS(urlString$LWS);
7915
+ if (!isAllowedEndpointURL$LWS(parsedURL$LWS)) {
7916
+ const {
7917
+ normalizedURL: normalizedURL$LWS
7918
+ } = parsedURL$LWS;
7919
+ throw new LockerSecurityError$LWS(`Cannot request disallowed endpoint: ${toSafeTemplateStringValue$LWS(normalizedURL$LWS)}`);
7895
7920
  }
7896
7921
  // Same-origin URLs go through an async pre-flight that fetches
7897
7922
  // the resource and runs its body through the rootValidator
@@ -8822,7 +8847,7 @@
8822
8847
  const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(HTMLScriptElement$LWS.prototype, 'textContent');
8823
8848
  // This may not be implemented in all browsers.
8824
8849
  // https://www.w3.org/TR/trusted-types/#enforcement-in-scripts
8825
- if (!isGaterEnabledFeature$LWS('changesSince.256') || !descriptor$LWS) {
8850
+ if (!descriptor$LWS) {
8826
8851
  return noop$LWS$1;
8827
8852
  }
8828
8853
  // istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
@@ -8853,7 +8878,7 @@
8853
8878
  const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(HTMLScriptElement$LWS.prototype, 'textContent');
8854
8879
  // This may not be implemented in all browsers.
8855
8880
  // https://www.w3.org/TR/trusted-types/#enforcement-in-scripts
8856
- if (!isGaterEnabledFeature$LWS('changesSince.256') || !descriptor$LWS) {
8881
+ if (!descriptor$LWS) {
8857
8882
  return noop$LWS$1;
8858
8883
  }
8859
8884
  // istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
@@ -11890,9 +11915,6 @@
11890
11915
  return noop$LWS$1;
11891
11916
  }
11892
11917
  const distortionEntry$LWS = [originalFetchLater$LWS, function fetchLater$LWS(...args$LWS) {
11893
- if (!isGaterEnabledFeature$LWS('changesSince.258')) {
11894
- return ReflectApply$LWS$1(originalFetchLater$LWS, this, args$LWS);
11895
- }
11896
11918
  // Let the native method handle missing parameters error or null/undefined URL case.
11897
11919
  let {
11898
11920
  0: url$LWS
@@ -12279,14 +12301,8 @@
12279
12301
  }
12280
12302
  const childWindow$LWS = ReflectApply$LWS$1(originalWindowOpen$LWS, this, normalizedArgs$LWS);
12281
12303
  // istanbul ignore next: behavior will not be tested in collection coverage
12282
- if (!isGaterEnabledFeature$LWS('changesSince.262')) {
12283
- if (isGaterEnabledFeature$LWS('changesSince.256')) {
12284
- if (isSameOriginURL$LWS(resourceUrl$LWS)) {
12285
- markForUnsafePropertyBlocking$LWS(childWindow$LWS);
12286
- }
12287
- } else {
12288
- markForUnsafePropertyBlocking$LWS(childWindow$LWS);
12289
- }
12304
+ if (!isGaterEnabledFeature$LWS('changesSince.262') && isSameOriginURL$LWS(resourceUrl$LWS)) {
12305
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
12290
12306
  }
12291
12307
  // W-14218118
12292
12308
  // If the target is '_self', '_parent', or '_top', only makes one request
@@ -12370,7 +12386,7 @@
12370
12386
  // Defer transforming source text asynchronously.
12371
12387
  sandboxEvaluator$LWS(transformSourceText$LWS(sourceText$LWS), UNCOMPILED_CONTEXT$LWS);
12372
12388
  };
12373
- } else if (isGaterEnabledFeature$LWS('changesSince.256')) {
12389
+ } else {
12374
12390
  throwIfUnsafeCallbackReference$LWS(callback$LWS);
12375
12391
  }
12376
12392
  }
@@ -12407,7 +12423,7 @@
12407
12423
  // Defer transforming source text asynchronously.
12408
12424
  sandboxEvaluator$LWS(transformSourceText$LWS(sourceText$LWS), UNCOMPILED_CONTEXT$LWS);
12409
12425
  };
12410
- } else if (isGaterEnabledFeature$LWS('changesSince.256')) {
12426
+ } else {
12411
12427
  throwIfUnsafeCallbackReference$LWS(callback$LWS);
12412
12428
  }
12413
12429
  }
@@ -12789,7 +12805,7 @@
12789
12805
  const UIEventProtoBlockedProperties$LWS = ['rangeParent'];
12790
12806
  const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
12791
12807
  const XSLTProcessorProtoBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
12792
- /*! version: 0.28.4 */
12808
+ /*! version: 0.28.6 */
12793
12809
 
12794
12810
  /*!
12795
12811
  * Copyright (C) 2021 salesforce.com, inc.
@@ -12798,7 +12814,7 @@
12798
12814
  function getPdpSchema$LWS() {
12799
12815
  return pdpSchema$LWS;
12800
12816
  }
12801
- /*! version: 0.28.4 */
12817
+ /*! version: 0.28.6 */
12802
12818
 
12803
12819
  /*!
12804
12820
  * Copyright (C) 2019 salesforce.com, inc.
@@ -18190,7 +18206,7 @@
18190
18206
  // tools from mistaking the regexp or the replacement string for an
18191
18207
  // actual source mapping URL.
18192
18208
  /\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
18193
- sourceText$LWS = `\n//# LWS Version = "0.28.4"\n${sourceText$LWS}`;
18209
+ sourceText$LWS = `\n//# LWS Version = "0.28.6"\n${sourceText$LWS}`;
18194
18210
  return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
18195
18211
  // Append "'use strict'" to the extracted function body so it is
18196
18212
  // evaluated in strict mode.
@@ -18870,7 +18886,7 @@
18870
18886
  }
18871
18887
  toSafeMap$LWS$1(new MapCtor$LWS$1());
18872
18888
  toSafeSet$LWS(new SetCtor$LWS$1(['lightning/platformResourceLoader', 'lightning:platformResourceLoader', 'lightningmobileruntime/platformResourceLoader', 'lightningmobileruntime:platformResourceLoader']));
18873
- /*! version: 0.28.4 */
18889
+ /*! version: 0.28.6 */
18874
18890
 
18875
18891
  // Expose evaluateInSandbox on the window global so the browser harness page
18876
18892
  // (eval.html / component.html) can invoke it against source delivered by the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locker/cli",
3
- "version": "0.28.4",
3
+ "version": "0.28.6",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "author": "Salesforce UI Security Team",
6
6
  "description": "Lightning Web Security CLI",
@@ -26,9 +26,10 @@
26
26
  "test:integration": "jest --config jest.config.integration.cjs"
27
27
  },
28
28
  "dependencies": {
29
- "@locker/rollup-plugin": "0.28.4",
30
- "@locker/sandbox": "0.28.4",
31
- "@locker/shared": "0.28.4",
29
+ "@babel/parser": "7.28.0",
30
+ "@locker/rollup-plugin": "0.28.6",
31
+ "@locker/sandbox": "0.28.6",
32
+ "@locker/shared": "0.28.6",
32
33
  "@lwc/engine-dom": "8.21.1",
33
34
  "@lwc/rollup-plugin": "8.21.1",
34
35
  "@rollup/plugin-commonjs": "21.1.0",
@@ -42,5 +43,5 @@
42
43
  "rollup-plugin-ts": "3.4.5",
43
44
  "yargs": "17.7.2"
44
45
  },
45
- "gitHead": "5a4e252a066299e969fa95068928dd569f3cf9aa"
46
+ "gitHead": "d55906f587fffdeffb3b57e011de6248a0f623b5"
46
47
  }
@@ -5,6 +5,8 @@ import path from 'node:path';
5
5
 
6
6
  import { rollup } from 'rollup';
7
7
 
8
+ import { createWireMockPlugin } from './wire-mock.mjs';
9
+
8
10
  const require = createRequire(import.meta.url);
9
11
  const lockerRollupPlugin = require('@locker/rollup-plugin');
10
12
  const lwcRollupPlugin = require('@lwc/rollup-plugin');
@@ -54,6 +56,15 @@ export async function compileComponent({
54
56
  namespace = DEFAULT_NAMESPACE,
55
57
  sandboxKey = 'cli',
56
58
  lwcModules = [],
59
+ // Wire auto-mocking (D16). `wireMode` is undefined (off), 'success', or
60
+ // 'error'; `wireMockOverrides` is the Map from loadWireMockOverrides
61
+ // (adapter -> explicit shape); `onWireMock` receives each
62
+ // `[wire mock] ...` marker line so the runner can print it to stderr.
63
+ // When wireMode is undefined the plugin is not added and compilation
64
+ // is byte-for-byte what it was before D16.
65
+ wireMode,
66
+ wireMockOverrides = new Map(),
67
+ onWireMock = () => {},
57
68
  }) {
58
69
  const { dirName, jsFile } = await validateComponentDir(directory);
59
70
  const derivedTag = name ?? deriveTagName(dirName);
@@ -96,9 +107,35 @@ export async function compileComponent({
96
107
  }));
97
108
  const moduleRecords = [...explicitModules, { dir: modulesRoot }];
98
109
 
110
+ // Wire auto-mocking (D16). When enabled, a virtual-module plugin
111
+ // supplies synthetic source for the wire specifiers the component
112
+ // imports (lightning/uiRecordApi, @salesforce/schema/*,
113
+ // @salesforce/apex/*) so the component renders locally with fake data
114
+ // instead of dying at runtime on an unresolved platform module. The
115
+ // plugin needs the component's OWN source for Tier A schema-field
116
+ // collection and Tier B usage inference, so read the entry component
117
+ // file here. It MUST sit before nodeResolve in the plugins array (see
118
+ // below) so it claims the wire specifiers before node-resolve can
119
+ // externalize them.
120
+ const wireMockPlugins = [];
121
+ if (wireMode !== undefined) {
122
+ const componentSource = await fs.readFile(jsFile, 'utf8');
123
+ wireMockPlugins.push(
124
+ createWireMockPlugin({
125
+ mode: wireMode,
126
+ overrides: wireMockOverrides,
127
+ componentSource,
128
+ report: onWireMock,
129
+ }),
130
+ );
131
+ }
132
+
99
133
  const bundle = await rollup({
100
134
  input: entryFile,
101
135
  plugins: [
136
+ // Wire-mock virtual modules first: its resolveId must claim the
137
+ // wire specifiers before nodeResolve can mark them external.
138
+ ...wireMockPlugins,
102
139
  nodeResolve({ preferBuiltins: true }),
103
140
  // Plugin order matters: LWC compiler MUST run before the LWS
104
141
  // compiler. Reversing the order breaks LWC component-file
@@ -45,8 +45,8 @@ const CONFIG_KEY = 'config';
45
45
  // (the flag is simply absent unless set), e.g. `timeout`, `name`.
46
46
  //
47
47
  // INVARIANT: array-typed options default to `[]`, never `undefined`.
48
- // `before`, `after`, `lwcModules`, `gatesOn`, and `gatesOff` are
49
- // `array: true` yargs options. Feeding `default: undefined` to an
48
+ // `before`, `after`, `lwcModules`, `gatesOn`, `gatesOff`, and `wireFixtures`
49
+ // are `array: true` yargs options. Feeding `default: undefined` to an
50
50
  // `array: true` option does NOT leave it absent: yargs wraps the scalar
51
51
  // default in an array and yields `[null]`, which then flows into the
52
52
  // consumer (loadScriptFiles -> resolveInput(null), or parseGateList) and
@@ -86,6 +86,8 @@ export const BUILTIN_DEFAULTS = Object.freeze({
86
86
  timeout: undefined,
87
87
  verbose: false,
88
88
  watch: false,
89
+ wireFixtures: [],
90
+ wireMode: undefined,
89
91
  });
90
92
 
91
93
  // The typo guard: a config key outside this set (e.g. `broswer`) is
package/src/constants.mjs CHANGED
@@ -13,3 +13,21 @@ export const SUPPORTED_BROWSERS = ['chromium', 'firefox', 'webkit', 'chrome'];
13
13
  export const BROWSER_CHANNEL_MAP = {
14
14
  chrome: { launcher: 'chromium', channel: 'chrome' },
15
15
  };
16
+
17
+ // Wire auto-mocking modes (D16), shared between bin/lws.mjs (the
18
+ // --wire-mode `choices` list) and wire-mock.mjs (adapter emission).
19
+ // `success` fires each mocked adapter's data branch; `error` fires its
20
+ // error branch so a component's error UI can be exercised. These live here
21
+ // (a Playwright-free module bin already imports) so the flag validates via
22
+ // yargs `choices` without pulling wire-mock.mjs and its @babel/parser
23
+ // dependency into the eager bin load.
24
+ //
25
+ // The flag takes an explicit value (--wire-mode=success | --wire-mode=error),
26
+ // with no bare form: yargs cannot express a bare-or-`=value` optional-value
27
+ // flag that is also safe next to the required <directory> positional (a
28
+ // bare flag greedily consumes the positional). A plain string+choices
29
+ // option sidesteps that entirely and validates the value natively, so no
30
+ // custom coercion is needed. Verified against yargs 17.7.2.
31
+ export const WIRE_MOCK_MODE_SUCCESS = 'success';
32
+ export const WIRE_MOCK_MODE_ERROR = 'error';
33
+ export const WIRE_MOCK_MODES = [WIRE_MOCK_MODE_SUCCESS, WIRE_MOCK_MODE_ERROR];
package/src/runner.mjs CHANGED
@@ -21,6 +21,7 @@ import { Server } from './server.mjs';
21
21
  import { transform } from './transform.mjs';
22
22
  import { awaitAndEmitUpgradeNotice, startVersionCheckForCLI } from './version-check.mjs';
23
23
  import { assertWatchableEvalOrigin, rerunBanner, watchPaths } from './watcher.mjs';
24
+ import { loadWireMockOverrides } from './wire-mock.mjs';
24
25
 
25
26
  const require = createRequire(import.meta.url);
26
27
  // `private: true` in package.json is the pre-publish signal that skips
@@ -360,6 +361,7 @@ export async function runComponent(argv) {
360
361
  const directory = path.resolve(process.cwd(), argv.directory);
361
362
 
362
363
  output.timing.start('compile');
364
+ const wireMockOverrides = await loadWireMockOverrides(argv['wire-fixtures']);
363
365
  const compiled = await compileComponent({
364
366
  directory,
365
367
  name: argv.name,
@@ -368,6 +370,17 @@ export async function runComponent(argv) {
368
370
  // yargs gives us the array on argv['lwc-modules'] when --lwc-modules
369
371
  // is passed at least once; default to [] when absent.
370
372
  lwcModules: argv['lwc-modules'] ?? [],
373
+ // Wire auto-mocking (D16). argv.wireMode is undefined (off),
374
+ // 'success', or 'error'. Each mocked adapter emits a
375
+ // `[wire mock] ...` marker to stderr so the run is unmistakably
376
+ // flagged as using fabricated data.
377
+ wireMode: argv.wireMode,
378
+ wireMockOverrides,
379
+ // info(), not debug(): a wire mock means the render used
380
+ // fabricated data and is NOT a true production render, so the
381
+ // marker must be visible by default (suppressed only under
382
+ // --quiet / --json, which opt out of all info by contract).
383
+ onWireMock: (line) => output.info(line),
371
384
  });
372
385
  output.timing.end('compile');
373
386
  tmpDir = compiled.tmpDir;
@@ -729,6 +742,12 @@ async function runComponentWatch(argv) {
729
742
  });
730
743
  }
731
744
 
745
+ // Wire-mock overrides (D16) are loaded once, like endowments: the
746
+ // override JSON files are not the watch target (the component
747
+ // directory is), so a one-time load matches the watch scope. Each
748
+ // re-compile reuses the same override Map.
749
+ const wireMockOverrides = await loadWireMockOverrides(argv['wire-fixtures']);
750
+
732
751
  const runOnce = async () => {
733
752
  const compiled = await compileComponent({
734
753
  directory,
@@ -736,6 +755,9 @@ async function runComponentWatch(argv) {
736
755
  namespace: argv.namespace,
737
756
  sandboxKey: argv.key,
738
757
  lwcModules: argv['lwc-modules'] ?? [],
758
+ wireMode: argv.wireMode,
759
+ wireMockOverrides,
760
+ onWireMock: (line) => output.info(line),
739
761
  });
740
762
  output.result(compiled.code);
741
763
  output.debug(`compiled component → ${compiled.bundleFile} (tag: ${compiled.tag})`);