@salesforce/lds-worker-api 1.418.0 → 1.420.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.
@@ -2351,7 +2351,7 @@ function isDefined(value) {
2351
2351
  /**
2352
2352
  * Checks if the given variable is an object
2353
2353
  */
2354
- function isObject$2(value) {
2354
+ function isObject$3(value) {
2355
2355
  return typeof value === 'object' && value !== null;
2356
2356
  }
2357
2357
 
@@ -2981,10 +2981,10 @@ class Reader {
2981
2981
  }
2982
2982
  if (fragment.opaque) {
2983
2983
  this.checkIfChanged(result.value, { useDeepEquals: true });
2984
- if (isObject$2(result.value) && !readerOpaqueReferenceMap.has(result.value)) {
2984
+ if (isObject$3(result.value) && !readerOpaqueReferenceMap.has(result.value)) {
2985
2985
  readerOpaqueReferenceMap.set(result.value, this.opaqueCopy(result.value));
2986
2986
  }
2987
- const opaqueValue = isObject$2(result.value)
2987
+ const opaqueValue = isObject$3(result.value)
2988
2988
  ? readerOpaqueReferenceMap.get(result.value)
2989
2989
  : result.value;
2990
2990
  return {
@@ -4146,7 +4146,7 @@ function createResourceParamsImpl(config, configMetadata) {
4146
4146
  }
4147
4147
  return resourceParams;
4148
4148
  }
4149
- // engine version: 0.160.1-e075b880
4149
+ // engine version: 0.160.3-354dc58b
4150
4150
 
4151
4151
  /**
4152
4152
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -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.420.0-fc658f6118
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.420.0-fc658f6118
5325
5322
 
5326
5323
  /**
5327
5324
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -5420,7 +5417,7 @@ var TypeCheckShapes;
5420
5417
  TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
5421
5418
  TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
5422
5419
  })(TypeCheckShapes || (TypeCheckShapes = {}));
5423
- // engine version: 0.160.1-e075b880
5420
+ // engine version: 0.160.3-354dc58b
5424
5421
 
5425
5422
  const { keys: ObjectKeys$4, create: ObjectCreate$4 } = Object;
5426
5423
 
@@ -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.420.0-576a1ea316
35498
35495
 
35499
35496
  var allowUpdatesForNonCachedRecords = {
35500
35497
  isOpen: function (e) {
@@ -48925,7 +48922,7 @@ const RedirectDurableSegment$1 = 'REDIRECT_KEYS';
48925
48922
  const MessagingDurableSegment = 'MESSAGING';
48926
48923
  const MessageNotifyStoreUpdateAvailable = 'notifyStoreUpdateAvailable';
48927
48924
 
48928
- const { keys: keys$5, create: create$5, assign: assign$4, freeze: freeze$2 } = Object;
48925
+ const { keys: keys$5, create: create$5, assign: assign$4, freeze: freeze$2, isFrozen: isFrozen$1$1 } = Object;
48929
48926
 
48930
48927
  //Durable store error instrumentation key
48931
48928
  const DURABLE_STORE_ERROR = 'durable-store-error';
@@ -49009,6 +49006,74 @@ function publishDurableStoreEntries(durableRecords, put, publishMetadata) {
49009
49006
  }
49010
49007
  return { revivedKeys, hadUnexpectedShape };
49011
49008
  }
49009
+ /**
49010
+ * Extracts field filtering configuration from the selection.
49011
+ */
49012
+ function extractFieldFilteringConfig(select, recordId, baseEnvironment) {
49013
+ const rootRecordKey = serializeStructuredKey(baseEnvironment.storeGetCanonicalKey(recordId));
49014
+ let topLevelFields;
49015
+ let nestedFieldRequirements;
49016
+ if (select &&
49017
+ select.node.kind === 'Fragment' &&
49018
+ 'selections' in select.node &&
49019
+ select.node.selections) {
49020
+ topLevelFields = extractRequestedFieldNames(select.node.selections);
49021
+ nestedFieldRequirements = extractNestedFieldRequirements(select.node.selections);
49022
+ }
49023
+ // Merge all nested field requirements into a single set
49024
+ let nestedFields;
49025
+ if (nestedFieldRequirements && nestedFieldRequirements.size > 0) {
49026
+ nestedFields = new Set();
49027
+ for (const fieldSet of nestedFieldRequirements.values()) {
49028
+ for (const field of fieldSet) {
49029
+ nestedFields.add(field);
49030
+ }
49031
+ }
49032
+ }
49033
+ return { rootRecordKey, topLevelFields, nestedFields };
49034
+ }
49035
+ /**
49036
+ * Categorizes keys into different fetch strategies based on filtering requirements.
49037
+ */
49038
+ function categorizeKeysForL2Fetch(keysToRevive, config, baseEnvironment, shouldFilterFields) {
49039
+ const unfilteredKeys = [];
49040
+ const rootKeysWithTopLevelFields = [];
49041
+ const nestedKeysWithNestedFields = [];
49042
+ const canFilter = config.topLevelFields !== undefined && config.topLevelFields.size > 0;
49043
+ for (let i = 0, len = keysToRevive.length; i < len; i += 1) {
49044
+ const canonicalKey = serializeStructuredKey(baseEnvironment.storeGetCanonicalKey(keysToRevive[i]));
49045
+ if (!shouldFilterFields(canonicalKey) || !canFilter) {
49046
+ unfilteredKeys.push(canonicalKey);
49047
+ continue;
49048
+ }
49049
+ const isRootRecord = canonicalKey === config.rootRecordKey;
49050
+ if (isRootRecord) {
49051
+ rootKeysWithTopLevelFields.push(canonicalKey);
49052
+ }
49053
+ else if (config.nestedFields !== undefined && config.nestedFields.size > 0) {
49054
+ nestedKeysWithNestedFields.push(canonicalKey);
49055
+ }
49056
+ else {
49057
+ unfilteredKeys.push(canonicalKey);
49058
+ }
49059
+ }
49060
+ return { unfilteredKeys, rootKeysWithTopLevelFields, nestedKeysWithNestedFields };
49061
+ }
49062
+ /**
49063
+ * Builds L2 fetch promises for different key categories.
49064
+ */
49065
+ function buildL2FetchPromises(categorizedKeys, config, durableStore) {
49066
+ const promises = [
49067
+ durableStore.getEntries(categorizedKeys.unfilteredKeys, DefaultDurableSegment),
49068
+ ];
49069
+ if (config.topLevelFields && categorizedKeys.rootKeysWithTopLevelFields.length > 0) {
49070
+ promises.push(durableStore.getEntriesWithSpecificFields(categorizedKeys.rootKeysWithTopLevelFields, config.topLevelFields, DefaultDurableSegment));
49071
+ }
49072
+ if (config.nestedFields && categorizedKeys.nestedKeysWithNestedFields.length > 0) {
49073
+ promises.push(durableStore.getEntriesWithSpecificFields(categorizedKeys.nestedKeysWithNestedFields, config.nestedFields, DefaultDurableSegment));
49074
+ }
49075
+ return promises;
49076
+ }
49012
49077
  /**
49013
49078
  * This method returns a Promise to a snapshot that is revived from L2 cache. If
49014
49079
  * L2 does not have the entries necessary to fulfill the snapshot then this method
@@ -49044,53 +49109,41 @@ function reviveSnapshot(baseEnvironment, durableStore, unavailableSnapshot, dura
49044
49109
  const keysToRevive = keysToReviveSet.keysAsArray();
49045
49110
  const start = Date.now();
49046
49111
  const { l2Trips } = reviveMetrics;
49047
- // Extract requested fields first to determine if filtering is possible
49048
- let requestedFields;
49049
- if (select.node.kind === 'Fragment' && 'selections' in select.node && select.node.selections) {
49050
- requestedFields = extractRequestedFieldNames(select.node.selections);
49051
- }
49052
- const canonicalKeys = [];
49053
- const filteredCanonicalKeys = [];
49054
- for (let i = 0, len = keysToRevive.length; i < len; i += 1) {
49055
- const canonicalKey = serializeStructuredKey(baseEnvironment.storeGetCanonicalKey(keysToRevive[i]));
49056
- // Only filter if we have fields to filter and shouldFilterFields returns true
49057
- if (requestedFields !== undefined &&
49058
- requestedFields.size > 0 &&
49059
- shouldFilterFields(canonicalKey)) {
49060
- filteredCanonicalKeys.push(canonicalKey);
49061
- }
49062
- else {
49063
- canonicalKeys.push(canonicalKey);
49064
- }
49065
- }
49066
- const fetchPromises = [
49067
- durableStore.getEntries(canonicalKeys, DefaultDurableSegment),
49068
- ];
49069
- if (requestedFields !== undefined &&
49070
- requestedFields.size > 0 &&
49071
- filteredCanonicalKeys.length > 0) {
49072
- fetchPromises.push(durableStore.getEntriesWithSpecificFields(filteredCanonicalKeys, requestedFields, DefaultDurableSegment));
49073
- }
49074
- return Promise.all(fetchPromises).then(([durableRecords, filteredDurableRecords]) => {
49112
+ // Extract field filtering requirements from the selection
49113
+ const fieldFilteringConfig = extractFieldFilteringConfig(select, recordId, baseEnvironment);
49114
+ // Categorize keys by how they should be fetched from L2
49115
+ const categorizedKeys = categorizeKeysForL2Fetch(keysToRevive, fieldFilteringConfig, baseEnvironment, shouldFilterFields);
49116
+ // Build fetch promises for each category
49117
+ const fetchPromises = buildL2FetchPromises(categorizedKeys, fieldFilteringConfig, durableStore);
49118
+ return Promise.all(fetchPromises).then(([durableRecords, filteredDurableRecords, nestedFilteredDurableRecords]) => {
49119
+ const totalKeysRequested = categorizedKeys.unfilteredKeys.length +
49120
+ categorizedKeys.rootKeysWithTopLevelFields.length +
49121
+ categorizedKeys.nestedKeysWithNestedFields.length;
49075
49122
  l2Trips.push({
49076
49123
  duration: Date.now() - start,
49077
- keysRequestedCount: canonicalKeys.length + filteredCanonicalKeys.length,
49124
+ keysRequestedCount: totalKeysRequested,
49078
49125
  });
49079
- // Process both normal and filtered records in a single pass
49126
+ // Process all three categories of records
49080
49127
  const revivedKeys = new StoreKeySet();
49081
49128
  let hadUnexpectedShape = false;
49082
- // Process normal records
49129
+ // Process normal records (all fields)
49083
49130
  if (durableRecords !== undefined) {
49084
49131
  const normalResult = publishDurableStoreEntries(durableRecords, baseEnvironment.storePut.bind(baseEnvironment), baseEnvironment.publishStoreMetadata.bind(baseEnvironment));
49085
49132
  revivedKeys.merge(normalResult.revivedKeys);
49086
49133
  hadUnexpectedShape = hadUnexpectedShape || normalResult.hadUnexpectedShape;
49087
49134
  }
49088
- // Process filtered records with merging
49135
+ // Process filtered records (root with top-level fields) with merging
49089
49136
  if (filteredDurableRecords !== undefined) {
49090
49137
  const filteredResult = publishDurableStoreEntries(filteredDurableRecords, createMergeFilteredPut((key) => baseEnvironment.store.readEntry(key), baseEnvironment.storePut.bind(baseEnvironment)), baseEnvironment.publishStoreMetadata.bind(baseEnvironment));
49091
49138
  revivedKeys.merge(filteredResult.revivedKeys);
49092
49139
  hadUnexpectedShape = hadUnexpectedShape || filteredResult.hadUnexpectedShape;
49093
49140
  }
49141
+ // Process nested filtered records with merging
49142
+ if (nestedFilteredDurableRecords !== undefined) {
49143
+ const nestedFilteredResult = publishDurableStoreEntries(nestedFilteredDurableRecords, createMergeFilteredPut((key) => baseEnvironment.store.readEntry(key), baseEnvironment.storePut.bind(baseEnvironment)), baseEnvironment.publishStoreMetadata.bind(baseEnvironment));
49144
+ revivedKeys.merge(nestedFilteredResult.revivedKeys);
49145
+ hadUnexpectedShape = hadUnexpectedShape || nestedFilteredResult.hadUnexpectedShape;
49146
+ }
49094
49147
  // if the data coming back from DS had an unexpected shape then just
49095
49148
  // return the L1 snapshot
49096
49149
  if (hadUnexpectedShape === true) {
@@ -49136,6 +49189,54 @@ function reviveSnapshot(baseEnvironment, durableStore, unavailableSnapshot, dura
49136
49189
  return { snapshot: unavailableSnapshot, metrics: reviveMetrics };
49137
49190
  });
49138
49191
  }
49192
+ /**
49193
+ * Filters out null fields from a fields object (null indicates field doesn't exist in L2).
49194
+ * Returns a new object without null values, or the original if no filtering needed.
49195
+ */
49196
+ function filterNullFields(fields) {
49197
+ const keys$1 = keys$5(fields);
49198
+ let hasNull = false;
49199
+ // Check if any nulls exist before allocating new object
49200
+ for (let i = 0, len = keys$1.length; i < len; i += 1) {
49201
+ if (fields[keys$1[i]] === null) {
49202
+ hasNull = true;
49203
+ break;
49204
+ }
49205
+ }
49206
+ if (!hasNull) {
49207
+ return fields;
49208
+ }
49209
+ const cleaned = {};
49210
+ for (let i = 0, len = keys$1.length; i < len; i += 1) {
49211
+ const key = keys$1[i];
49212
+ if (fields[key] !== null) {
49213
+ cleaned[key] = fields[key];
49214
+ }
49215
+ }
49216
+ return cleaned;
49217
+ }
49218
+ /**
49219
+ * Merges new fields into existing fields object, skipping null values.
49220
+ * Creates a new object to avoid mutations.
49221
+ */
49222
+ function mergeFieldsObjects(existing, incoming) {
49223
+ const merged = { ...existing };
49224
+ const keys$1 = keys$5(incoming);
49225
+ for (let i = 0, len = keys$1.length; i < len; i += 1) {
49226
+ const key = keys$1[i];
49227
+ // Skip null values - they indicate the field doesn't exist in L2
49228
+ if (incoming[key] !== null) {
49229
+ merged[key] = incoming[key];
49230
+ }
49231
+ }
49232
+ return merged;
49233
+ }
49234
+ /**
49235
+ * Type guard to check if value is a non-null object.
49236
+ */
49237
+ function isObject$1(value) {
49238
+ return typeof value === 'object' && value !== null;
49239
+ }
49139
49240
  /**
49140
49241
  * Creates a put function that merges filtered fields with existing L1 records instead of replacing them.
49141
49242
  * This is used when reviving filtered fields from L2 to preserve existing data in L1.
@@ -49143,28 +49244,36 @@ function reviveSnapshot(baseEnvironment, durableStore, unavailableSnapshot, dura
49143
49244
  function createMergeFilteredPut(readEntry, storePut) {
49144
49245
  return (key, filteredData) => {
49145
49246
  const existingRecord = readEntry(key);
49146
- if (existingRecord !== undefined &&
49147
- existingRecord !== null &&
49148
- typeof filteredData === 'object' &&
49149
- filteredData !== null &&
49150
- typeof existingRecord === 'object') {
49151
- const filteredFields = filteredData;
49152
- const existingObj = existingRecord;
49153
- // Check if object is frozen (can happen after deepFreeze)
49154
- // If frozen, create a shallow copy to merge fields into
49155
- let targetObj = existingObj;
49156
- if (Object.isFrozen(existingObj)) {
49157
- targetObj = { ...existingObj };
49158
- }
49159
- const keys = Object.keys(filteredFields);
49160
- for (let i = 0, len = keys.length; i < len; i += 1) {
49161
- const fieldKey = keys[i];
49162
- targetObj[fieldKey] = filteredFields[fieldKey];
49247
+ // Merge with existing record if both are objects
49248
+ if (isObject$1(existingRecord) && isObject$1(filteredData)) {
49249
+ // Create target object (copy if frozen to avoid mutation errors)
49250
+ const targetObj = isFrozen$1$1(existingRecord)
49251
+ ? { ...existingRecord }
49252
+ : existingRecord;
49253
+ const keys$1 = keys$5(filteredData);
49254
+ for (let i = 0, len = keys$1.length; i < len; i += 1) {
49255
+ const fieldKey = keys$1[i];
49256
+ const incomingValue = filteredData[fieldKey];
49257
+ // Special handling for 'fields' property to merge rather than replace
49258
+ if (fieldKey === 'fields' &&
49259
+ isObject$1(incomingValue) &&
49260
+ isObject$1(targetObj[fieldKey])) {
49261
+ targetObj[fieldKey] = mergeFieldsObjects(targetObj[fieldKey], incomingValue);
49262
+ }
49263
+ else {
49264
+ targetObj[fieldKey] = incomingValue;
49265
+ }
49163
49266
  }
49164
49267
  storePut(key, targetObj);
49165
49268
  }
49166
49269
  else {
49167
- // No existing record, just put the filtered data
49270
+ // No existing record - clean null fields before storing
49271
+ if (isObject$1(filteredData) && 'fields' in filteredData) {
49272
+ const fields = filteredData.fields;
49273
+ if (isObject$1(fields)) {
49274
+ filteredData.fields = filterNullFields(fields);
49275
+ }
49276
+ }
49168
49277
  storePut(key, filteredData);
49169
49278
  }
49170
49279
  };
@@ -49178,16 +49287,101 @@ function extractRequestedFieldNames(selections) {
49178
49287
  return undefined;
49179
49288
  }
49180
49289
  // Find the 'fields' ObjectSelection
49181
- const fieldsSelection = selections.find((sel) => sel.kind === 'Object' && sel.name === 'fields');
49182
- if (!fieldsSelection || !fieldsSelection.selections) {
49290
+ let fieldsSelection;
49291
+ for (let i = 0, len = selections.length; i < len; i += 1) {
49292
+ const sel = selections[i];
49293
+ if (sel.kind === 'Object' && sel.name === 'fields') {
49294
+ fieldsSelection = sel;
49295
+ break;
49296
+ }
49297
+ }
49298
+ if (!fieldsSelection ||
49299
+ !fieldsSelection.selections ||
49300
+ fieldsSelection.selections.length === 0) {
49183
49301
  return undefined;
49184
49302
  }
49185
49303
  // Extract all field names from the fields selections
49304
+ const fieldSelections = fieldsSelection.selections;
49186
49305
  const fieldNames = new Set();
49187
- for (const fieldSel of fieldsSelection.selections) {
49188
- fieldNames.add(fieldSel.name);
49306
+ for (let i = 0, len = fieldSelections.length; i < len; i += 1) {
49307
+ fieldNames.add(fieldSelections[i].name);
49308
+ }
49309
+ return fieldNames;
49310
+ }
49311
+ /**
49312
+ * Extracts nested field requirements for spanning fields.
49313
+ * For spanning fields like Case.CreatedBy.Name, we need to extract what fields
49314
+ * are requested from the nested record (User in this case).
49315
+ * The structure is: fields { CreatedBy { value (Link with fragment) { fields { Name } } } }
49316
+ */
49317
+ function extractNestedFieldRequirements(selections) {
49318
+ if (!selections) {
49319
+ return undefined;
49320
+ }
49321
+ // Find the 'fields' ObjectSelection
49322
+ let fieldsSelection;
49323
+ for (let i = 0, len = selections.length; i < len; i += 1) {
49324
+ const sel = selections[i];
49325
+ if (sel.kind === 'Object' && sel.name === 'fields') {
49326
+ fieldsSelection = sel;
49327
+ break;
49328
+ }
49329
+ }
49330
+ if (!fieldsSelection || !fieldsSelection.selections) {
49331
+ return undefined;
49332
+ }
49333
+ let nestedFieldsMap;
49334
+ // Look for ObjectSelections within fields (these are spanning fields)
49335
+ const fieldSelections = fieldsSelection.selections;
49336
+ for (let i = 0, len = fieldSelections.length; i < len; i += 1) {
49337
+ const fieldSel = fieldSelections[i];
49338
+ if (fieldSel.kind !== 'Object') {
49339
+ continue;
49340
+ }
49341
+ const objSel = fieldSel;
49342
+ if (!objSel.selections) {
49343
+ continue;
49344
+ }
49345
+ // Look for the 'value' Link selection
49346
+ let valueLinkSelection;
49347
+ for (let j = 0, jlen = objSel.selections.length; j < jlen; j += 1) {
49348
+ const sel = objSel.selections[j];
49349
+ if (sel.kind === 'Link' && sel.name === 'value') {
49350
+ valueLinkSelection = sel;
49351
+ break;
49352
+ }
49353
+ }
49354
+ if (!valueLinkSelection || !('fragment' in valueLinkSelection)) {
49355
+ continue;
49356
+ }
49357
+ const fragment = valueLinkSelection.fragment;
49358
+ if (!fragment || !fragment.selections) {
49359
+ continue;
49360
+ }
49361
+ // Look for the 'fields' selection within the fragment
49362
+ let nestedFieldsSelection;
49363
+ for (let j = 0, jlen = fragment.selections.length; j < jlen; j += 1) {
49364
+ const sel = fragment.selections[j];
49365
+ if (sel.kind === 'Object' && sel.name === 'fields') {
49366
+ nestedFieldsSelection = sel;
49367
+ break;
49368
+ }
49369
+ }
49370
+ if (nestedFieldsSelection && nestedFieldsSelection.selections) {
49371
+ const nestedFields = new Set();
49372
+ for (const nestedFieldSel of nestedFieldsSelection.selections) {
49373
+ nestedFields.add(nestedFieldSel.name);
49374
+ }
49375
+ if (nestedFields.size > 0) {
49376
+ // Lazy initialize map only if we have nested fields
49377
+ if (!nestedFieldsMap) {
49378
+ nestedFieldsMap = new Map();
49379
+ }
49380
+ nestedFieldsMap.set(fieldSel.name, nestedFields);
49381
+ }
49382
+ }
49189
49383
  }
49190
- return fieldNames.size > 0 ? fieldNames : undefined;
49384
+ return nestedFieldsMap;
49191
49385
  }
49192
49386
 
49193
49387
  const TTL_DURABLE_SEGMENT = 'TTL_DURABLE_SEGMENT';
@@ -91331,7 +91525,7 @@ function ldsParamsToString(params) {
91331
91525
  else {
91332
91526
  returnParams[key] = `${value}`;
91333
91527
  }
91334
- if (isObject$1(value) === true && keys$2$1(value).length > 0) {
91528
+ if (isObject$2(value) === true && keys$2$1(value).length > 0) {
91335
91529
  returnParams[key] = stringify$4(value);
91336
91530
  }
91337
91531
  }
@@ -91384,7 +91578,7 @@ function isStatusOk(status) {
91384
91578
  return status >= 200 && status <= 299;
91385
91579
  }
91386
91580
  // adapted from adapter-utils untrustedIsObject
91387
- function isObject$1(value) {
91581
+ function isObject$2(value) {
91388
91582
  return typeof value === 'object' && value !== null && isArray$2$1(value) === false;
91389
91583
  }
91390
91584
  function stringifyIfPresent(value) {
@@ -92822,7 +93016,7 @@ class LdsInternalDataTable {
92822
93016
  }
92823
93017
 
92824
93018
  const tasker = idleDetector.declareNotifierTaskMulti('NimbusSqliteStore');
92825
- const instrumentation$2 = getInstrumentation();
93019
+ const instrumentation$2$1 = getInstrumentation();
92826
93020
  const GRAPHQL_QUERY_ROOT_KEY = 'UiApi::uiapi::Query[uiapi]__uiapi__query';
92827
93021
  const GRAPHQL_QUERY_ROOT_METRIC_NAME = 'gql-query-root-object-size';
92828
93022
  class NimbusSqliteStore {
@@ -92991,7 +93185,7 @@ class NimbusSqliteStore {
92991
93185
  if (!(row && row[1] && typeof row[1] === 'string')) {
92992
93186
  return;
92993
93187
  }
92994
- instrumentation$2.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
93188
+ instrumentation$2$1.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
92995
93189
  }
92996
93190
  catch { }
92997
93191
  }
@@ -98875,7 +99069,7 @@ function buildServiceDescriptor$b(luvio) {
98875
99069
  },
98876
99070
  };
98877
99071
  }
98878
- // version: 1.418.0-68f5961c99
99072
+ // version: 1.420.0-576a1ea316
98879
99073
 
98880
99074
  /**
98881
99075
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -98901,7 +99095,7 @@ function buildServiceDescriptor$a(notifyRecordUpdateAvailable, getNormalizedLuvi
98901
99095
  },
98902
99096
  };
98903
99097
  }
98904
- // version: 1.418.0-68f5961c99
99098
+ // version: 1.420.0-576a1ea316
98905
99099
 
98906
99100
  /*!
98907
99101
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -101550,7 +101744,7 @@ register$1({
101550
101744
  id: '@salesforce/lds-network-adapter',
101551
101745
  instrument: instrument$2,
101552
101746
  });
101553
- // version: 1.418.0-b4def2b6ce
101747
+ // version: 1.420.0-fc658f6118
101554
101748
 
101555
101749
  const { create: create$2, keys: keys$2 } = Object;
101556
101750
  const { stringify, parse } = JSON;
@@ -103593,17 +103787,117 @@ class SignalBaseClass {
103593
103787
  const connectContext = Symbol('connectContext');
103594
103788
  const disconnectContext = Symbol('disconnectContext');
103595
103789
  const NOOP = () => { };
103790
+ const signalMarker = Symbol('signalMarker');
103791
+ class LwcStateSignalBaseClass extends SignalBaseClass {
103792
+ constructor() {
103793
+ super();
103794
+ // Marks the signal as a state manager signal so it can be identified and handled appropriately
103795
+ Object.defineProperty(this, signalMarker, {
103796
+ value: true,
103797
+ });
103798
+ }
103799
+ }
103800
+ const isSignal = (signal) => {
103801
+ return typeof signal === 'object' && signal !== null && !!signal[signalMarker];
103802
+ };
103803
+ /**
103804
+ * Binds all prototype methods and accessors of an instance
103805
+ * so that `this` is always the instance, even if you extract them.
103806
+ */
103807
+ function bindInstanceMethods(instance, collectedKeyDescriptorMap) {
103808
+ for (const [key, desc] of collectedKeyDescriptorMap.entries()) {
103809
+ const { configurable, enumerable = false, writable = false } = desc;
103810
+ if ('value' in desc && typeof desc.value === 'function') {
103811
+ // Method -> bind to instance
103812
+ Object.defineProperty(instance, key, {
103813
+ configurable,
103814
+ enumerable,
103815
+ writable,
103816
+ value: desc.value.bind(instance),
103817
+ });
103818
+ }
103819
+ else if (desc.get || desc.set) {
103820
+ // Accessor -> bind getter/setter to instance
103821
+ const get = desc.get ? desc.get.bind(instance) : undefined;
103822
+ const set = desc.set ? desc.set.bind(instance) : undefined;
103823
+ Object.defineProperty(instance, key, {
103824
+ configurable,
103825
+ enumerable,
103826
+ get,
103827
+ set,
103828
+ });
103829
+ }
103830
+ }
103831
+ }
103832
+ function collectKeyDescriptorsMap(Base) {
103833
+ let proto = Base.prototype;
103834
+ const nonConfigurablePrototypeProps = new Set();
103835
+ const collectedKeyDescriptorMap = new Map();
103836
+ while (proto && proto !== Object.prototype) {
103837
+ for (const key of Reflect.ownKeys(proto)) {
103838
+ // Skip the constructor (string key only)
103839
+ if (key === 'constructor')
103840
+ continue;
103841
+ // Already defined directly on the instance? Don't overwrite it.
103842
+ if (collectedKeyDescriptorMap.has(key) ||
103843
+ // Already defined as non-configurable in a subclass
103844
+ nonConfigurablePrototypeProps.has(key)) {
103845
+ continue;
103846
+ }
103847
+ const desc = Object.getOwnPropertyDescriptor(proto, key);
103848
+ if (!desc)
103849
+ continue;
103850
+ // Do not touch non-configurable prototype props, or redefined ones as non-configurable in a subclass
103851
+ if (desc.configurable === false) {
103852
+ nonConfigurablePrototypeProps.add(key);
103853
+ continue;
103854
+ }
103855
+ collectedKeyDescriptorMap.set(key, desc);
103856
+ }
103857
+ proto = Object.getPrototypeOf(proto);
103858
+ }
103859
+ return collectedKeyDescriptorMap;
103860
+ }
103861
+ /**
103862
+ * Given a class Base, returns a new class with the *same* public shape,
103863
+ * but whose instances auto-bind all methods/accessors (string + symbol keys)
103864
+ * to themselves.
103865
+ *
103866
+ * This is a delegate pattern implementation, with advantage of preserving the
103867
+ * object's identity.
103868
+ */
103869
+ function LockerSafeClass(Base) {
103870
+ const collectedKeyDescriptorMap = collectKeyDescriptorsMap(Base);
103871
+ class Bound extends Base {
103872
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
103873
+ constructor(...args) {
103874
+ super(...args);
103875
+ bindInstanceMethods(this, collectedKeyDescriptorMap);
103876
+ }
103877
+ }
103878
+ return Bound;
103879
+ }
103596
103880
 
103597
103881
  const trustedSignalSet = new WeakSet();
103598
103882
  setTrustedSignalSet(trustedSignalSet);
103599
103883
 
103884
+ let instrumentation$2 = {
103885
+ stateCreated: (_context) => { }, // Invoked whenever a state manager is created with defineState()
103886
+ stateDefined: (_context) => { }, // Invoked whenever a state manager is defined with defineState()
103887
+ contextConsumed: (_context) => { }, // Invoked whenever fromContext consumes a context
103888
+ };
103889
+
103600
103890
  const atomSetter = Symbol('atomSetter');
103601
103891
  const contextID = Symbol('contextID');
103602
- class AtomSignal extends SignalBaseClass {
103892
+ /**
103893
+ * Signal subclass used to hold atom() values.
103894
+ */
103895
+ class AtomSignal extends LwcStateSignalBaseClass {
103896
+ _value;
103897
+ isSignal = false;
103898
+ unsubscribe = NOOP;
103603
103899
  constructor(value) {
103604
103900
  super();
103605
- this.isSignal = false;
103606
- this.unsubscribe = NOOP;
103607
103901
  this.obtainValue(value);
103608
103902
  }
103609
103903
  [atomSetter](value) {
@@ -103624,13 +103918,17 @@ class AtomSignal extends SignalBaseClass {
103624
103918
  return this.isSignal ? this._value.value : this._value;
103625
103919
  }
103626
103920
  }
103627
- const isSignal = (signal) => {
103628
- return typeof signal === 'object' && signal !== null && isTrustedSignal();
103629
- };
103630
- class ComputedSignal extends SignalBaseClass {
103921
+ const LockerSafeAtomSignal = LockerSafeClass(AtomSignal);
103922
+ /**
103923
+ * Signal subclass used to hold computed() values.
103924
+ */
103925
+ class ComputedSignal extends LwcStateSignalBaseClass {
103926
+ computer;
103927
+ dependencies;
103928
+ _value;
103929
+ isStale = true;
103631
103930
  constructor(inputSignals, computer) {
103632
103931
  super();
103633
- this.isStale = true;
103634
103932
  this.computer = computer;
103635
103933
  this.dependencies = inputSignals;
103636
103934
  const onUpdate = () => this.notify();
@@ -103656,12 +103954,13 @@ class ComputedSignal extends SignalBaseClass {
103656
103954
  return this._value;
103657
103955
  }
103658
103956
  }
103957
+ const LockerSafeComputedSignal = LockerSafeClass(ComputedSignal);
103659
103958
  const isUpdater = (signalOrUpdater) => typeof signalOrUpdater === 'function';
103660
103959
  function createStateManagerAtomsClosure() {
103661
103960
  const smAtoms = new WeakSet();
103662
103961
  return {
103663
103962
  atom: (v) => {
103664
- const a = new AtomSignal(v);
103963
+ const a = new LockerSafeAtomSignal(v);
103665
103964
  smAtoms.add(a);
103666
103965
  return a;
103667
103966
  },
@@ -103672,15 +103971,27 @@ function createStateManagerAtomsClosure() {
103672
103971
  },
103673
103972
  };
103674
103973
  }
103675
- const computed = (inputSignalsObj, computer) => new ComputedSignal(inputSignalsObj, computer);
103676
- const defineState = (defineStateCallback // legacy pattern
103677
- ) => {
103974
+ const computed = (inputSignalsObj, computer) => new LockerSafeComputedSignal(inputSignalsObj, computer);
103975
+ /**
103976
+ * Symbol used to store the state definition metadata.
103977
+ */
103978
+ const stateDefMetadataSymbol = Symbol('stateDefMetadata');
103979
+ const defineState = function (defineStateCallback, // legacy pattern
103980
+ options) {
103981
+ // Read metadata from options parameter
103982
+ const metadata = options?.metadata;
103983
+ const stateDefMetadata = {
103984
+ definedBy: metadata?.definedBy || '',
103985
+ type: metadata?.type || 'unknown',
103986
+ };
103678
103987
  const stateDefinition = (...args) => {
103679
- class StateManagerSignal extends SignalBaseClass {
103988
+ class StateManagerSignal extends LwcStateSignalBaseClass {
103989
+ internalStateShape;
103990
+ _value;
103991
+ isStale = true;
103992
+ isNotifyScheduled = false;
103680
103993
  constructor() {
103681
103994
  super();
103682
- this.isStale = true;
103683
- this.isNotifyScheduled = false;
103684
103995
  const { atom, setAtom } = createStateManagerAtomsClosure();
103685
103996
  const callbackResult = defineStateCallback({
103686
103997
  atom,
@@ -103747,11 +104058,68 @@ const defineState = (defineStateCallback // legacy pattern
103747
104058
  return this._value;
103748
104059
  }
103749
104060
  }
103750
- return new StateManagerSignal();
104061
+ {
104062
+ const LockerSafeStateManagerSignal = LockerSafeClass(StateManagerSignal);
104063
+ return new LockerSafeStateManagerSignal();
104064
+ }
103751
104065
  };
104066
+ // Attach metadata to the state definition function for access via fromContext
104067
+ Object.defineProperty(stateDefinition, stateDefMetadataSymbol, {
104068
+ value: stateDefMetadata,
104069
+ writable: false,
104070
+ enumerable: false,
104071
+ configurable: false,
104072
+ });
103752
104073
  return stateDefinition;
103753
104074
  };
103754
104075
 
104076
+ class ConsumedContextSignal extends LwcStateSignalBaseClass {
104077
+ desiredStateDef;
104078
+ providedContextSignal;
104079
+ isStale = true;
104080
+ _value;
104081
+ _unsubscribe = NOOP;
104082
+ constructor(stateDef) {
104083
+ super();
104084
+ this.desiredStateDef = stateDef;
104085
+ }
104086
+ get value() {
104087
+ if (this.isStale) {
104088
+ this.isStale = false;
104089
+ this._value = this.providedContextSignal?.value;
104090
+ }
104091
+ return this._value;
104092
+ }
104093
+ [connectContext](runtimeAdapter) {
104094
+ if (!runtimeAdapter) {
104095
+ throw new Error('Implementation error: runtimeAdapter must be present at the time of connect.');
104096
+ }
104097
+ runtimeAdapter.consumeContext(this.desiredStateDef, (providedContextSignal) => {
104098
+ this.providedContextSignal = providedContextSignal;
104099
+ const onUpdate = () => {
104100
+ this.isStale = true;
104101
+ this.notify();
104102
+ };
104103
+ onUpdate();
104104
+ this._unsubscribe = providedContextSignal.subscribe(onUpdate);
104105
+ // Call instrumentation hook with metadata
104106
+ instrumentation$2.contextConsumed({
104107
+ stateDefMetadata: this.desiredStateDef[stateDefMetadataSymbol],
104108
+ componentName: runtimeAdapter.component?.tagName || 'unknown',
104109
+ });
104110
+ });
104111
+ }
104112
+ [disconnectContext]() {
104113
+ // Unlike the state manager's fromContext which can subscribe to multiple
104114
+ // ancestor contexts simultaneously, this standalone version only subscribes
104115
+ // to a single context at a time.
104116
+ this._unsubscribe();
104117
+ this.providedContextSignal = undefined;
104118
+ this._unsubscribe = NOOP;
104119
+ }
104120
+ }
104121
+ LockerSafeClass(ConsumedContextSignal);
104122
+
103755
104123
  /**
103756
104124
  * Copyright (c) 2022, Salesforce, Inc.,
103757
104125
  * All rights reserved.
@@ -108918,7 +109286,7 @@ function registerCallback(cb) {
108918
109286
  cb(graphql_v1_import, graphql_imperative$1, graphql_imperative_legacy_v1_import, graphql_state_manager, useOneStoreGraphQL);
108919
109287
  }
108920
109288
  }
108921
- // version: 1.418.0-68f5961c99
109289
+ // version: 1.420.0-576a1ea316
108922
109290
 
108923
109291
  function createFragmentMap(documentNode) {
108924
109292
  const fragments = {};
@@ -138143,7 +138511,7 @@ register$1({
138143
138511
  configuration: { ...configurationForGraphQLAdapters$1 },
138144
138512
  instrument: instrument$1,
138145
138513
  });
138146
- // version: 1.418.0-68f5961c99
138514
+ // version: 1.420.0-576a1ea316
138147
138515
 
138148
138516
  // On core the unstable adapters are re-exported with different names,
138149
138517
  // we want to match them here.
@@ -138295,7 +138663,7 @@ withDefaultLuvio((luvio) => {
138295
138663
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
138296
138664
  graphQLImperative = ldsAdapter;
138297
138665
  });
138298
- // version: 1.418.0-68f5961c99
138666
+ // version: 1.420.0-576a1ea316
138299
138667
 
138300
138668
  var gqlApi = /*#__PURE__*/Object.freeze({
138301
138669
  __proto__: null,
@@ -139094,7 +139462,7 @@ const callbacks$1 = [];
139094
139462
  function register(r) {
139095
139463
  callbacks$1.forEach((callback) => callback(r));
139096
139464
  }
139097
- // version: 1.418.0-b4def2b6ce
139465
+ // version: 1.420.0-fc658f6118
139098
139466
 
139099
139467
  /**
139100
139468
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -140410,4 +140778,4 @@ const { luvio } = getRuntime();
140410
140778
  setDefaultLuvio({ luvio });
140411
140779
 
140412
140780
  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
140781
+ // version: 1.420.0-fc658f6118