@salesforce/lds-worker-api 1.418.0 → 1.419.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.
@@ -1371,4 +1371,4 @@ if (process.env.NODE_ENV !== 'production') {
1371
1371
  }
1372
1372
 
1373
1373
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1374
- // version: 1.418.0-b4def2b6ce
1374
+ // version: 1.419.0-ade430921b
@@ -4274,7 +4274,7 @@ function withDefaultLuvio(callback) {
4274
4274
  }
4275
4275
  callbacks.push(callback);
4276
4276
  }
4277
- // version: 1.418.0-b4def2b6ce
4277
+ // version: 1.419.0-ade430921b
4278
4278
 
4279
4279
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4280
4280
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -4287,9 +4287,6 @@ function instrumentLuvio(_context) { }
4287
4287
  // Bringing those functions in would also bring in a lot of other LWC code that calls
4288
4288
  // DOM apis, which JSContext can't handle. For now we just fake in the functions we
4289
4289
  // need with no-op stubs.
4290
- function isTrustedSignal(target) {
4291
- return true;
4292
- }
4293
4290
  // unwrap for lwc-luvio
4294
4291
  function unwrap(data) {
4295
4292
  return data;
@@ -5321,7 +5318,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
5321
5318
  const { apiFamily, name } = metadata;
5322
5319
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5323
5320
  }
5324
- // version: 1.418.0-b4def2b6ce
5321
+ // version: 1.419.0-ade430921b
5325
5322
 
5326
5323
  /**
5327
5324
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -35494,7 +35491,7 @@ withDefaultLuvio((luvio) => {
35494
35491
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
35495
35492
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
35496
35493
  });
35497
- // version: 1.418.0-68f5961c99
35494
+ // version: 1.419.0-8232dcd0ab
35498
35495
 
35499
35496
  var allowUpdatesForNonCachedRecords = {
35500
35497
  isOpen: function (e) {
@@ -92822,7 +92819,7 @@ class LdsInternalDataTable {
92822
92819
  }
92823
92820
 
92824
92821
  const tasker = idleDetector.declareNotifierTaskMulti('NimbusSqliteStore');
92825
- const instrumentation$2 = getInstrumentation();
92822
+ const instrumentation$2$1 = getInstrumentation();
92826
92823
  const GRAPHQL_QUERY_ROOT_KEY = 'UiApi::uiapi::Query[uiapi]__uiapi__query';
92827
92824
  const GRAPHQL_QUERY_ROOT_METRIC_NAME = 'gql-query-root-object-size';
92828
92825
  class NimbusSqliteStore {
@@ -92991,7 +92988,7 @@ class NimbusSqliteStore {
92991
92988
  if (!(row && row[1] && typeof row[1] === 'string')) {
92992
92989
  return;
92993
92990
  }
92994
- instrumentation$2.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
92991
+ instrumentation$2$1.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
92995
92992
  }
92996
92993
  catch { }
92997
92994
  }
@@ -98875,7 +98872,7 @@ function buildServiceDescriptor$b(luvio) {
98875
98872
  },
98876
98873
  };
98877
98874
  }
98878
- // version: 1.418.0-68f5961c99
98875
+ // version: 1.419.0-8232dcd0ab
98879
98876
 
98880
98877
  /**
98881
98878
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -98901,7 +98898,7 @@ function buildServiceDescriptor$a(notifyRecordUpdateAvailable, getNormalizedLuvi
98901
98898
  },
98902
98899
  };
98903
98900
  }
98904
- // version: 1.418.0-68f5961c99
98901
+ // version: 1.419.0-8232dcd0ab
98905
98902
 
98906
98903
  /*!
98907
98904
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -101550,7 +101547,7 @@ register$1({
101550
101547
  id: '@salesforce/lds-network-adapter',
101551
101548
  instrument: instrument$2,
101552
101549
  });
101553
- // version: 1.418.0-b4def2b6ce
101550
+ // version: 1.419.0-ade430921b
101554
101551
 
101555
101552
  const { create: create$2, keys: keys$2 } = Object;
101556
101553
  const { stringify, parse } = JSON;
@@ -103593,17 +103590,117 @@ class SignalBaseClass {
103593
103590
  const connectContext = Symbol('connectContext');
103594
103591
  const disconnectContext = Symbol('disconnectContext');
103595
103592
  const NOOP = () => { };
103593
+ const signalMarker = Symbol('signalMarker');
103594
+ class LwcStateSignalBaseClass extends SignalBaseClass {
103595
+ constructor() {
103596
+ super();
103597
+ // Marks the signal as a state manager signal so it can be identified and handled appropriately
103598
+ Object.defineProperty(this, signalMarker, {
103599
+ value: true,
103600
+ });
103601
+ }
103602
+ }
103603
+ const isSignal = (signal) => {
103604
+ return typeof signal === 'object' && signal !== null && !!signal[signalMarker];
103605
+ };
103606
+ /**
103607
+ * Binds all prototype methods and accessors of an instance
103608
+ * so that `this` is always the instance, even if you extract them.
103609
+ */
103610
+ function bindInstanceMethods(instance, collectedKeyDescriptorMap) {
103611
+ for (const [key, desc] of collectedKeyDescriptorMap.entries()) {
103612
+ const { configurable, enumerable = false, writable = false } = desc;
103613
+ if ('value' in desc && typeof desc.value === 'function') {
103614
+ // Method -> bind to instance
103615
+ Object.defineProperty(instance, key, {
103616
+ configurable,
103617
+ enumerable,
103618
+ writable,
103619
+ value: desc.value.bind(instance),
103620
+ });
103621
+ }
103622
+ else if (desc.get || desc.set) {
103623
+ // Accessor -> bind getter/setter to instance
103624
+ const get = desc.get ? desc.get.bind(instance) : undefined;
103625
+ const set = desc.set ? desc.set.bind(instance) : undefined;
103626
+ Object.defineProperty(instance, key, {
103627
+ configurable,
103628
+ enumerable,
103629
+ get,
103630
+ set,
103631
+ });
103632
+ }
103633
+ }
103634
+ }
103635
+ function collectKeyDescriptorsMap(Base) {
103636
+ let proto = Base.prototype;
103637
+ const nonConfigurablePrototypeProps = new Set();
103638
+ const collectedKeyDescriptorMap = new Map();
103639
+ while (proto && proto !== Object.prototype) {
103640
+ for (const key of Reflect.ownKeys(proto)) {
103641
+ // Skip the constructor (string key only)
103642
+ if (key === 'constructor')
103643
+ continue;
103644
+ // Already defined directly on the instance? Don't overwrite it.
103645
+ if (collectedKeyDescriptorMap.has(key) ||
103646
+ // Already defined as non-configurable in a subclass
103647
+ nonConfigurablePrototypeProps.has(key)) {
103648
+ continue;
103649
+ }
103650
+ const desc = Object.getOwnPropertyDescriptor(proto, key);
103651
+ if (!desc)
103652
+ continue;
103653
+ // Do not touch non-configurable prototype props, or redefined ones as non-configurable in a subclass
103654
+ if (desc.configurable === false) {
103655
+ nonConfigurablePrototypeProps.add(key);
103656
+ continue;
103657
+ }
103658
+ collectedKeyDescriptorMap.set(key, desc);
103659
+ }
103660
+ proto = Object.getPrototypeOf(proto);
103661
+ }
103662
+ return collectedKeyDescriptorMap;
103663
+ }
103664
+ /**
103665
+ * Given a class Base, returns a new class with the *same* public shape,
103666
+ * but whose instances auto-bind all methods/accessors (string + symbol keys)
103667
+ * to themselves.
103668
+ *
103669
+ * This is a delegate pattern implementation, with advantage of preserving the
103670
+ * object's identity.
103671
+ */
103672
+ function LockerSafeClass(Base) {
103673
+ const collectedKeyDescriptorMap = collectKeyDescriptorsMap(Base);
103674
+ class Bound extends Base {
103675
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
103676
+ constructor(...args) {
103677
+ super(...args);
103678
+ bindInstanceMethods(this, collectedKeyDescriptorMap);
103679
+ }
103680
+ }
103681
+ return Bound;
103682
+ }
103596
103683
 
103597
103684
  const trustedSignalSet = new WeakSet();
103598
103685
  setTrustedSignalSet(trustedSignalSet);
103599
103686
 
103687
+ let instrumentation$2 = {
103688
+ stateCreated: (_context) => { }, // Invoked whenever a state manager is created with defineState()
103689
+ stateDefined: (_context) => { }, // Invoked whenever a state manager is defined with defineState()
103690
+ contextConsumed: (_context) => { }, // Invoked whenever fromContext consumes a context
103691
+ };
103692
+
103600
103693
  const atomSetter = Symbol('atomSetter');
103601
103694
  const contextID = Symbol('contextID');
103602
- class AtomSignal extends SignalBaseClass {
103695
+ /**
103696
+ * Signal subclass used to hold atom() values.
103697
+ */
103698
+ class AtomSignal extends LwcStateSignalBaseClass {
103699
+ _value;
103700
+ isSignal = false;
103701
+ unsubscribe = NOOP;
103603
103702
  constructor(value) {
103604
103703
  super();
103605
- this.isSignal = false;
103606
- this.unsubscribe = NOOP;
103607
103704
  this.obtainValue(value);
103608
103705
  }
103609
103706
  [atomSetter](value) {
@@ -103624,13 +103721,17 @@ class AtomSignal extends SignalBaseClass {
103624
103721
  return this.isSignal ? this._value.value : this._value;
103625
103722
  }
103626
103723
  }
103627
- const isSignal = (signal) => {
103628
- return typeof signal === 'object' && signal !== null && isTrustedSignal();
103629
- };
103630
- class ComputedSignal extends SignalBaseClass {
103724
+ const LockerSafeAtomSignal = LockerSafeClass(AtomSignal);
103725
+ /**
103726
+ * Signal subclass used to hold computed() values.
103727
+ */
103728
+ class ComputedSignal extends LwcStateSignalBaseClass {
103729
+ computer;
103730
+ dependencies;
103731
+ _value;
103732
+ isStale = true;
103631
103733
  constructor(inputSignals, computer) {
103632
103734
  super();
103633
- this.isStale = true;
103634
103735
  this.computer = computer;
103635
103736
  this.dependencies = inputSignals;
103636
103737
  const onUpdate = () => this.notify();
@@ -103656,12 +103757,13 @@ class ComputedSignal extends SignalBaseClass {
103656
103757
  return this._value;
103657
103758
  }
103658
103759
  }
103760
+ const LockerSafeComputedSignal = LockerSafeClass(ComputedSignal);
103659
103761
  const isUpdater = (signalOrUpdater) => typeof signalOrUpdater === 'function';
103660
103762
  function createStateManagerAtomsClosure() {
103661
103763
  const smAtoms = new WeakSet();
103662
103764
  return {
103663
103765
  atom: (v) => {
103664
- const a = new AtomSignal(v);
103766
+ const a = new LockerSafeAtomSignal(v);
103665
103767
  smAtoms.add(a);
103666
103768
  return a;
103667
103769
  },
@@ -103672,15 +103774,27 @@ function createStateManagerAtomsClosure() {
103672
103774
  },
103673
103775
  };
103674
103776
  }
103675
- const computed = (inputSignalsObj, computer) => new ComputedSignal(inputSignalsObj, computer);
103676
- const defineState = (defineStateCallback // legacy pattern
103677
- ) => {
103777
+ const computed = (inputSignalsObj, computer) => new LockerSafeComputedSignal(inputSignalsObj, computer);
103778
+ /**
103779
+ * Symbol used to store the state definition metadata.
103780
+ */
103781
+ const stateDefMetadataSymbol = Symbol('stateDefMetadata');
103782
+ const defineState = function (defineStateCallback, // legacy pattern
103783
+ options) {
103784
+ // Read metadata from options parameter
103785
+ const metadata = options?.metadata;
103786
+ const stateDefMetadata = {
103787
+ definedBy: metadata?.definedBy || '',
103788
+ type: metadata?.type || 'unknown',
103789
+ };
103678
103790
  const stateDefinition = (...args) => {
103679
- class StateManagerSignal extends SignalBaseClass {
103791
+ class StateManagerSignal extends LwcStateSignalBaseClass {
103792
+ internalStateShape;
103793
+ _value;
103794
+ isStale = true;
103795
+ isNotifyScheduled = false;
103680
103796
  constructor() {
103681
103797
  super();
103682
- this.isStale = true;
103683
- this.isNotifyScheduled = false;
103684
103798
  const { atom, setAtom } = createStateManagerAtomsClosure();
103685
103799
  const callbackResult = defineStateCallback({
103686
103800
  atom,
@@ -103747,11 +103861,68 @@ const defineState = (defineStateCallback // legacy pattern
103747
103861
  return this._value;
103748
103862
  }
103749
103863
  }
103750
- return new StateManagerSignal();
103864
+ {
103865
+ const LockerSafeStateManagerSignal = LockerSafeClass(StateManagerSignal);
103866
+ return new LockerSafeStateManagerSignal();
103867
+ }
103751
103868
  };
103869
+ // Attach metadata to the state definition function for access via fromContext
103870
+ Object.defineProperty(stateDefinition, stateDefMetadataSymbol, {
103871
+ value: stateDefMetadata,
103872
+ writable: false,
103873
+ enumerable: false,
103874
+ configurable: false,
103875
+ });
103752
103876
  return stateDefinition;
103753
103877
  };
103754
103878
 
103879
+ class ConsumedContextSignal extends LwcStateSignalBaseClass {
103880
+ desiredStateDef;
103881
+ providedContextSignal;
103882
+ isStale = true;
103883
+ _value;
103884
+ _unsubscribe = NOOP;
103885
+ constructor(stateDef) {
103886
+ super();
103887
+ this.desiredStateDef = stateDef;
103888
+ }
103889
+ get value() {
103890
+ if (this.isStale) {
103891
+ this.isStale = false;
103892
+ this._value = this.providedContextSignal?.value;
103893
+ }
103894
+ return this._value;
103895
+ }
103896
+ [connectContext](runtimeAdapter) {
103897
+ if (!runtimeAdapter) {
103898
+ throw new Error('Implementation error: runtimeAdapter must be present at the time of connect.');
103899
+ }
103900
+ runtimeAdapter.consumeContext(this.desiredStateDef, (providedContextSignal) => {
103901
+ this.providedContextSignal = providedContextSignal;
103902
+ const onUpdate = () => {
103903
+ this.isStale = true;
103904
+ this.notify();
103905
+ };
103906
+ onUpdate();
103907
+ this._unsubscribe = providedContextSignal.subscribe(onUpdate);
103908
+ // Call instrumentation hook with metadata
103909
+ instrumentation$2.contextConsumed({
103910
+ stateDefMetadata: this.desiredStateDef[stateDefMetadataSymbol],
103911
+ componentName: runtimeAdapter.component?.tagName || 'unknown',
103912
+ });
103913
+ });
103914
+ }
103915
+ [disconnectContext]() {
103916
+ // Unlike the state manager's fromContext which can subscribe to multiple
103917
+ // ancestor contexts simultaneously, this standalone version only subscribes
103918
+ // to a single context at a time.
103919
+ this._unsubscribe();
103920
+ this.providedContextSignal = undefined;
103921
+ this._unsubscribe = NOOP;
103922
+ }
103923
+ }
103924
+ LockerSafeClass(ConsumedContextSignal);
103925
+
103755
103926
  /**
103756
103927
  * Copyright (c) 2022, Salesforce, Inc.,
103757
103928
  * All rights reserved.
@@ -108918,7 +109089,7 @@ function registerCallback(cb) {
108918
109089
  cb(graphql_v1_import, graphql_imperative$1, graphql_imperative_legacy_v1_import, graphql_state_manager, useOneStoreGraphQL);
108919
109090
  }
108920
109091
  }
108921
- // version: 1.418.0-68f5961c99
109092
+ // version: 1.419.0-8232dcd0ab
108922
109093
 
108923
109094
  function createFragmentMap(documentNode) {
108924
109095
  const fragments = {};
@@ -138143,7 +138314,7 @@ register$1({
138143
138314
  configuration: { ...configurationForGraphQLAdapters$1 },
138144
138315
  instrument: instrument$1,
138145
138316
  });
138146
- // version: 1.418.0-68f5961c99
138317
+ // version: 1.419.0-8232dcd0ab
138147
138318
 
138148
138319
  // On core the unstable adapters are re-exported with different names,
138149
138320
  // we want to match them here.
@@ -138295,7 +138466,7 @@ withDefaultLuvio((luvio) => {
138295
138466
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
138296
138467
  graphQLImperative = ldsAdapter;
138297
138468
  });
138298
- // version: 1.418.0-68f5961c99
138469
+ // version: 1.419.0-8232dcd0ab
138299
138470
 
138300
138471
  var gqlApi = /*#__PURE__*/Object.freeze({
138301
138472
  __proto__: null,
@@ -139094,7 +139265,7 @@ const callbacks$1 = [];
139094
139265
  function register(r) {
139095
139266
  callbacks$1.forEach((callback) => callback(r));
139096
139267
  }
139097
- // version: 1.418.0-b4def2b6ce
139268
+ // version: 1.419.0-ade430921b
139098
139269
 
139099
139270
  /**
139100
139271
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -140410,4 +140581,4 @@ const { luvio } = getRuntime();
140410
140581
  setDefaultLuvio({ luvio });
140411
140582
 
140412
140583
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
140413
- // version: 1.418.0-b4def2b6ce
140584
+ // version: 1.419.0-ade430921b
@@ -4280,7 +4280,7 @@
4280
4280
  }
4281
4281
  callbacks.push(callback);
4282
4282
  }
4283
- // version: 1.418.0-b4def2b6ce
4283
+ // version: 1.419.0-ade430921b
4284
4284
 
4285
4285
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4286
4286
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -4293,9 +4293,6 @@
4293
4293
  // Bringing those functions in would also bring in a lot of other LWC code that calls
4294
4294
  // DOM apis, which JSContext can't handle. For now we just fake in the functions we
4295
4295
  // need with no-op stubs.
4296
- function isTrustedSignal(target) {
4297
- return true;
4298
- }
4299
4296
  // unwrap for lwc-luvio
4300
4297
  function unwrap(data) {
4301
4298
  return data;
@@ -5327,7 +5324,7 @@
5327
5324
  const { apiFamily, name } = metadata;
5328
5325
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5329
5326
  }
5330
- // version: 1.418.0-b4def2b6ce
5327
+ // version: 1.419.0-ade430921b
5331
5328
 
5332
5329
  /**
5333
5330
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -35500,7 +35497,7 @@
35500
35497
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
35501
35498
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
35502
35499
  });
35503
- // version: 1.418.0-68f5961c99
35500
+ // version: 1.419.0-8232dcd0ab
35504
35501
 
35505
35502
  var allowUpdatesForNonCachedRecords = {
35506
35503
  isOpen: function (e) {
@@ -92828,7 +92825,7 @@
92828
92825
  }
92829
92826
 
92830
92827
  const tasker = idleDetector.declareNotifierTaskMulti('NimbusSqliteStore');
92831
- const instrumentation$2 = getInstrumentation();
92828
+ const instrumentation$2$1 = getInstrumentation();
92832
92829
  const GRAPHQL_QUERY_ROOT_KEY = 'UiApi::uiapi::Query[uiapi]__uiapi__query';
92833
92830
  const GRAPHQL_QUERY_ROOT_METRIC_NAME = 'gql-query-root-object-size';
92834
92831
  class NimbusSqliteStore {
@@ -92997,7 +92994,7 @@
92997
92994
  if (!(row && row[1] && typeof row[1] === 'string')) {
92998
92995
  return;
92999
92996
  }
93000
- instrumentation$2.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
92997
+ instrumentation$2$1.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
93001
92998
  }
93002
92999
  catch { }
93003
93000
  }
@@ -98881,7 +98878,7 @@
98881
98878
  },
98882
98879
  };
98883
98880
  }
98884
- // version: 1.418.0-68f5961c99
98881
+ // version: 1.419.0-8232dcd0ab
98885
98882
 
98886
98883
  /**
98887
98884
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -98907,7 +98904,7 @@
98907
98904
  },
98908
98905
  };
98909
98906
  }
98910
- // version: 1.418.0-68f5961c99
98907
+ // version: 1.419.0-8232dcd0ab
98911
98908
 
98912
98909
  /*!
98913
98910
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -101556,7 +101553,7 @@
101556
101553
  id: '@salesforce/lds-network-adapter',
101557
101554
  instrument: instrument$2,
101558
101555
  });
101559
- // version: 1.418.0-b4def2b6ce
101556
+ // version: 1.419.0-ade430921b
101560
101557
 
101561
101558
  const { create: create$2, keys: keys$2 } = Object;
101562
101559
  const { stringify, parse } = JSON;
@@ -103599,17 +103596,117 @@
103599
103596
  const connectContext = Symbol('connectContext');
103600
103597
  const disconnectContext = Symbol('disconnectContext');
103601
103598
  const NOOP = () => { };
103599
+ const signalMarker = Symbol('signalMarker');
103600
+ class LwcStateSignalBaseClass extends SignalBaseClass {
103601
+ constructor() {
103602
+ super();
103603
+ // Marks the signal as a state manager signal so it can be identified and handled appropriately
103604
+ Object.defineProperty(this, signalMarker, {
103605
+ value: true,
103606
+ });
103607
+ }
103608
+ }
103609
+ const isSignal = (signal) => {
103610
+ return typeof signal === 'object' && signal !== null && !!signal[signalMarker];
103611
+ };
103612
+ /**
103613
+ * Binds all prototype methods and accessors of an instance
103614
+ * so that `this` is always the instance, even if you extract them.
103615
+ */
103616
+ function bindInstanceMethods(instance, collectedKeyDescriptorMap) {
103617
+ for (const [key, desc] of collectedKeyDescriptorMap.entries()) {
103618
+ const { configurable, enumerable = false, writable = false } = desc;
103619
+ if ('value' in desc && typeof desc.value === 'function') {
103620
+ // Method -> bind to instance
103621
+ Object.defineProperty(instance, key, {
103622
+ configurable,
103623
+ enumerable,
103624
+ writable,
103625
+ value: desc.value.bind(instance),
103626
+ });
103627
+ }
103628
+ else if (desc.get || desc.set) {
103629
+ // Accessor -> bind getter/setter to instance
103630
+ const get = desc.get ? desc.get.bind(instance) : undefined;
103631
+ const set = desc.set ? desc.set.bind(instance) : undefined;
103632
+ Object.defineProperty(instance, key, {
103633
+ configurable,
103634
+ enumerable,
103635
+ get,
103636
+ set,
103637
+ });
103638
+ }
103639
+ }
103640
+ }
103641
+ function collectKeyDescriptorsMap(Base) {
103642
+ let proto = Base.prototype;
103643
+ const nonConfigurablePrototypeProps = new Set();
103644
+ const collectedKeyDescriptorMap = new Map();
103645
+ while (proto && proto !== Object.prototype) {
103646
+ for (const key of Reflect.ownKeys(proto)) {
103647
+ // Skip the constructor (string key only)
103648
+ if (key === 'constructor')
103649
+ continue;
103650
+ // Already defined directly on the instance? Don't overwrite it.
103651
+ if (collectedKeyDescriptorMap.has(key) ||
103652
+ // Already defined as non-configurable in a subclass
103653
+ nonConfigurablePrototypeProps.has(key)) {
103654
+ continue;
103655
+ }
103656
+ const desc = Object.getOwnPropertyDescriptor(proto, key);
103657
+ if (!desc)
103658
+ continue;
103659
+ // Do not touch non-configurable prototype props, or redefined ones as non-configurable in a subclass
103660
+ if (desc.configurable === false) {
103661
+ nonConfigurablePrototypeProps.add(key);
103662
+ continue;
103663
+ }
103664
+ collectedKeyDescriptorMap.set(key, desc);
103665
+ }
103666
+ proto = Object.getPrototypeOf(proto);
103667
+ }
103668
+ return collectedKeyDescriptorMap;
103669
+ }
103670
+ /**
103671
+ * Given a class Base, returns a new class with the *same* public shape,
103672
+ * but whose instances auto-bind all methods/accessors (string + symbol keys)
103673
+ * to themselves.
103674
+ *
103675
+ * This is a delegate pattern implementation, with advantage of preserving the
103676
+ * object's identity.
103677
+ */
103678
+ function LockerSafeClass(Base) {
103679
+ const collectedKeyDescriptorMap = collectKeyDescriptorsMap(Base);
103680
+ class Bound extends Base {
103681
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
103682
+ constructor(...args) {
103683
+ super(...args);
103684
+ bindInstanceMethods(this, collectedKeyDescriptorMap);
103685
+ }
103686
+ }
103687
+ return Bound;
103688
+ }
103602
103689
 
103603
103690
  const trustedSignalSet = new WeakSet();
103604
103691
  setTrustedSignalSet(trustedSignalSet);
103605
103692
 
103693
+ let instrumentation$2 = {
103694
+ stateCreated: (_context) => { }, // Invoked whenever a state manager is created with defineState()
103695
+ stateDefined: (_context) => { }, // Invoked whenever a state manager is defined with defineState()
103696
+ contextConsumed: (_context) => { }, // Invoked whenever fromContext consumes a context
103697
+ };
103698
+
103606
103699
  const atomSetter = Symbol('atomSetter');
103607
103700
  const contextID = Symbol('contextID');
103608
- class AtomSignal extends SignalBaseClass {
103701
+ /**
103702
+ * Signal subclass used to hold atom() values.
103703
+ */
103704
+ class AtomSignal extends LwcStateSignalBaseClass {
103705
+ _value;
103706
+ isSignal = false;
103707
+ unsubscribe = NOOP;
103609
103708
  constructor(value) {
103610
103709
  super();
103611
- this.isSignal = false;
103612
- this.unsubscribe = NOOP;
103613
103710
  this.obtainValue(value);
103614
103711
  }
103615
103712
  [atomSetter](value) {
@@ -103630,13 +103727,17 @@
103630
103727
  return this.isSignal ? this._value.value : this._value;
103631
103728
  }
103632
103729
  }
103633
- const isSignal = (signal) => {
103634
- return typeof signal === 'object' && signal !== null && isTrustedSignal();
103635
- };
103636
- class ComputedSignal extends SignalBaseClass {
103730
+ const LockerSafeAtomSignal = LockerSafeClass(AtomSignal);
103731
+ /**
103732
+ * Signal subclass used to hold computed() values.
103733
+ */
103734
+ class ComputedSignal extends LwcStateSignalBaseClass {
103735
+ computer;
103736
+ dependencies;
103737
+ _value;
103738
+ isStale = true;
103637
103739
  constructor(inputSignals, computer) {
103638
103740
  super();
103639
- this.isStale = true;
103640
103741
  this.computer = computer;
103641
103742
  this.dependencies = inputSignals;
103642
103743
  const onUpdate = () => this.notify();
@@ -103662,12 +103763,13 @@
103662
103763
  return this._value;
103663
103764
  }
103664
103765
  }
103766
+ const LockerSafeComputedSignal = LockerSafeClass(ComputedSignal);
103665
103767
  const isUpdater = (signalOrUpdater) => typeof signalOrUpdater === 'function';
103666
103768
  function createStateManagerAtomsClosure() {
103667
103769
  const smAtoms = new WeakSet();
103668
103770
  return {
103669
103771
  atom: (v) => {
103670
- const a = new AtomSignal(v);
103772
+ const a = new LockerSafeAtomSignal(v);
103671
103773
  smAtoms.add(a);
103672
103774
  return a;
103673
103775
  },
@@ -103678,15 +103780,27 @@
103678
103780
  },
103679
103781
  };
103680
103782
  }
103681
- const computed = (inputSignalsObj, computer) => new ComputedSignal(inputSignalsObj, computer);
103682
- const defineState = (defineStateCallback // legacy pattern
103683
- ) => {
103783
+ const computed = (inputSignalsObj, computer) => new LockerSafeComputedSignal(inputSignalsObj, computer);
103784
+ /**
103785
+ * Symbol used to store the state definition metadata.
103786
+ */
103787
+ const stateDefMetadataSymbol = Symbol('stateDefMetadata');
103788
+ const defineState = function (defineStateCallback, // legacy pattern
103789
+ options) {
103790
+ // Read metadata from options parameter
103791
+ const metadata = options?.metadata;
103792
+ const stateDefMetadata = {
103793
+ definedBy: metadata?.definedBy || '',
103794
+ type: metadata?.type || 'unknown',
103795
+ };
103684
103796
  const stateDefinition = (...args) => {
103685
- class StateManagerSignal extends SignalBaseClass {
103797
+ class StateManagerSignal extends LwcStateSignalBaseClass {
103798
+ internalStateShape;
103799
+ _value;
103800
+ isStale = true;
103801
+ isNotifyScheduled = false;
103686
103802
  constructor() {
103687
103803
  super();
103688
- this.isStale = true;
103689
- this.isNotifyScheduled = false;
103690
103804
  const { atom, setAtom } = createStateManagerAtomsClosure();
103691
103805
  const callbackResult = defineStateCallback({
103692
103806
  atom,
@@ -103753,11 +103867,68 @@
103753
103867
  return this._value;
103754
103868
  }
103755
103869
  }
103756
- return new StateManagerSignal();
103870
+ {
103871
+ const LockerSafeStateManagerSignal = LockerSafeClass(StateManagerSignal);
103872
+ return new LockerSafeStateManagerSignal();
103873
+ }
103757
103874
  };
103875
+ // Attach metadata to the state definition function for access via fromContext
103876
+ Object.defineProperty(stateDefinition, stateDefMetadataSymbol, {
103877
+ value: stateDefMetadata,
103878
+ writable: false,
103879
+ enumerable: false,
103880
+ configurable: false,
103881
+ });
103758
103882
  return stateDefinition;
103759
103883
  };
103760
103884
 
103885
+ class ConsumedContextSignal extends LwcStateSignalBaseClass {
103886
+ desiredStateDef;
103887
+ providedContextSignal;
103888
+ isStale = true;
103889
+ _value;
103890
+ _unsubscribe = NOOP;
103891
+ constructor(stateDef) {
103892
+ super();
103893
+ this.desiredStateDef = stateDef;
103894
+ }
103895
+ get value() {
103896
+ if (this.isStale) {
103897
+ this.isStale = false;
103898
+ this._value = this.providedContextSignal?.value;
103899
+ }
103900
+ return this._value;
103901
+ }
103902
+ [connectContext](runtimeAdapter) {
103903
+ if (!runtimeAdapter) {
103904
+ throw new Error('Implementation error: runtimeAdapter must be present at the time of connect.');
103905
+ }
103906
+ runtimeAdapter.consumeContext(this.desiredStateDef, (providedContextSignal) => {
103907
+ this.providedContextSignal = providedContextSignal;
103908
+ const onUpdate = () => {
103909
+ this.isStale = true;
103910
+ this.notify();
103911
+ };
103912
+ onUpdate();
103913
+ this._unsubscribe = providedContextSignal.subscribe(onUpdate);
103914
+ // Call instrumentation hook with metadata
103915
+ instrumentation$2.contextConsumed({
103916
+ stateDefMetadata: this.desiredStateDef[stateDefMetadataSymbol],
103917
+ componentName: runtimeAdapter.component?.tagName || 'unknown',
103918
+ });
103919
+ });
103920
+ }
103921
+ [disconnectContext]() {
103922
+ // Unlike the state manager's fromContext which can subscribe to multiple
103923
+ // ancestor contexts simultaneously, this standalone version only subscribes
103924
+ // to a single context at a time.
103925
+ this._unsubscribe();
103926
+ this.providedContextSignal = undefined;
103927
+ this._unsubscribe = NOOP;
103928
+ }
103929
+ }
103930
+ LockerSafeClass(ConsumedContextSignal);
103931
+
103761
103932
  /**
103762
103933
  * Copyright (c) 2022, Salesforce, Inc.,
103763
103934
  * All rights reserved.
@@ -108924,7 +109095,7 @@
108924
109095
  cb(graphql_v1_import, graphql_imperative$1, graphql_imperative_legacy_v1_import, graphql_state_manager, useOneStoreGraphQL);
108925
109096
  }
108926
109097
  }
108927
- // version: 1.418.0-68f5961c99
109098
+ // version: 1.419.0-8232dcd0ab
108928
109099
 
108929
109100
  function createFragmentMap(documentNode) {
108930
109101
  const fragments = {};
@@ -138149,7 +138320,7 @@
138149
138320
  configuration: { ...configurationForGraphQLAdapters$1 },
138150
138321
  instrument: instrument$1,
138151
138322
  });
138152
- // version: 1.418.0-68f5961c99
138323
+ // version: 1.419.0-8232dcd0ab
138153
138324
 
138154
138325
  // On core the unstable adapters are re-exported with different names,
138155
138326
  // we want to match them here.
@@ -138301,7 +138472,7 @@
138301
138472
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
138302
138473
  graphQLImperative = ldsAdapter;
138303
138474
  });
138304
- // version: 1.418.0-68f5961c99
138475
+ // version: 1.419.0-8232dcd0ab
138305
138476
 
138306
138477
  var gqlApi = /*#__PURE__*/Object.freeze({
138307
138478
  __proto__: null,
@@ -139100,7 +139271,7 @@
139100
139271
  function register(r) {
139101
139272
  callbacks$1.forEach((callback) => callback(r));
139102
139273
  }
139103
- // version: 1.418.0-b4def2b6ce
139274
+ // version: 1.419.0-ade430921b
139104
139275
 
139105
139276
  /**
139106
139277
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -140437,4 +140608,4 @@
140437
140608
  exports.subscribeToAdapter = subscribeToAdapter;
140438
140609
 
140439
140610
  }));
140440
- // version: 1.418.0-b4def2b6ce
140611
+ // version: 1.419.0-ade430921b
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.418.0",
3
+ "version": "1.419.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
38
- "@salesforce/lds-adapters-graphql": "^1.418.0",
39
- "@salesforce/lds-adapters-uiapi": "^1.418.0",
40
- "@salesforce/lds-default-luvio": "^1.418.0",
41
- "@salesforce/lds-drafts": "^1.418.0",
42
- "@salesforce/lds-graphql-parser": "^1.418.0",
43
- "@salesforce/lds-luvio-engine": "^1.418.0",
44
- "@salesforce/lds-runtime-mobile": "^1.418.0",
45
- "@salesforce/nimbus-plugin-lds": "^1.418.0",
38
+ "@salesforce/lds-adapters-graphql": "^1.419.0",
39
+ "@salesforce/lds-adapters-uiapi": "^1.419.0",
40
+ "@salesforce/lds-default-luvio": "^1.419.0",
41
+ "@salesforce/lds-drafts": "^1.419.0",
42
+ "@salesforce/lds-graphql-parser": "^1.419.0",
43
+ "@salesforce/lds-luvio-engine": "^1.419.0",
44
+ "@salesforce/lds-runtime-mobile": "^1.419.0",
45
+ "@salesforce/nimbus-plugin-lds": "^1.419.0",
46
46
  "ajv": "^8.11.0",
47
47
  "glob": "^7.1.5",
48
48
  "nimbus-types": "^2.0.0-alpha1",