@salesforce/lds-runtime-mobile 1.227.0 → 1.227.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -522,6 +522,8 @@ function isDeprecatedDurableStoreEntry(durableRecord) {
522
522
  }
523
523
  const DefaultDurableSegment = 'DEFAULT';
524
524
  const RedirectDurableSegment = 'REDIRECT_KEYS';
525
+ const MessagingDurableSegment = 'MESSAGING';
526
+ const MessageNotifyStoreUpdateAvailable = 'notifyStoreUpdateAvailable';
525
527
 
526
528
  const { keys: keys$7, create: create$6, assign: assign$6, freeze: freeze$1 } = Object;
527
529
 
@@ -960,6 +962,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
960
962
  const defaultSegmentKeys = [];
961
963
  const adapterContextSegmentKeys = [];
962
964
  const redirectSegmentKeys = [];
965
+ const messagingSegmentKeys = [];
963
966
  let shouldBroadcast = false;
964
967
  for (let i = 0, len = changes.length; i < len; i++) {
965
968
  const change = changes[i];
@@ -974,6 +977,9 @@ function makeDurable(environment, { durableStore, instrumentation }) {
974
977
  else if (change.segment === RedirectDurableSegment) {
975
978
  redirectSegmentKeys.push(...change.ids);
976
979
  }
980
+ else if (change.segment === MessagingDurableSegment) {
981
+ messagingSegmentKeys.push(...change.ids);
982
+ }
977
983
  }
978
984
  if (redirectSegmentKeys.length > 0) {
979
985
  const redirectEntries = await durableStore.getEntries(redirectSegmentKeys, RedirectDurableSegment);
@@ -1033,6 +1039,20 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1033
1039
  if (shouldBroadcast) {
1034
1040
  await environment.storeBroadcast(rebuildSnapshot, environment.snapshotAvailable);
1035
1041
  }
1042
+ // if having notifyStoreUpdateAvailable msg, then pull the message body out from store
1043
+ // and call environment.notifyStoreUpdateAvailable
1044
+ if (messagingSegmentKeys.includes(MessageNotifyStoreUpdateAvailable)) {
1045
+ const entries = await durableStore.getEntries([MessageNotifyStoreUpdateAvailable], MessagingDurableSegment);
1046
+ if (entries !== undefined) {
1047
+ const notifyEntry = entries[MessageNotifyStoreUpdateAvailable];
1048
+ if (notifyEntry !== undefined) {
1049
+ const keys = notifyEntry.data;
1050
+ if (keys.length > 0) {
1051
+ environment.notifyStoreUpdateAvailable(keys);
1052
+ }
1053
+ }
1054
+ }
1055
+ }
1036
1056
  });
1037
1057
  const dispose = function () {
1038
1058
  validateNotDisposed();
@@ -1368,6 +1388,39 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1368
1388
  return entries;
1369
1389
  });
1370
1390
  };
1391
+ // flag entries specified by keys in durable store as expired.
1392
+ // send a notifyStoreUpdateAvailable message through durable store set entries to
1393
+ // indirectly triggers all js environments to refresh snapshots if overlapping with keys.
1394
+ const notifyStoreUpdateAvailable = async function (keys$1) {
1395
+ validateNotDisposed();
1396
+ const entryKeys = keys$1.map(serializeStructuredKey);
1397
+ const entries = await durableStore.getEntries(entryKeys, DefaultDurableSegment);
1398
+ if (entries === undefined || keys$7(entries).length === 0) {
1399
+ return environment.notifyStoreUpdateAvailable(keys$1);
1400
+ }
1401
+ const now = Date.now();
1402
+ let needWriteBack = false;
1403
+ for (let i = 0; i < entryKeys.length; i++) {
1404
+ const key = entryKeys[i];
1405
+ const entry = entries[key];
1406
+ if (entry !== undefined) {
1407
+ const storeEntry = entry;
1408
+ if (storeEntry.metadata !== undefined) {
1409
+ storeEntry.metadata = {
1410
+ ...storeEntry.metadata,
1411
+ expirationTimestamp: now,
1412
+ };
1413
+ }
1414
+ needWriteBack = true;
1415
+ }
1416
+ }
1417
+ if (needWriteBack) {
1418
+ await durableStore.setEntries(entries, DefaultDurableSegment);
1419
+ }
1420
+ // push a notifyStoreUpdateAvailable message with entryKeys as data into messaging segment
1421
+ await durableStore.setEntries({ notifyStoreUpdateAvailable: { data: entryKeys } }, MessagingDurableSegment);
1422
+ return Promise.resolve(undefined);
1423
+ };
1371
1424
  // set the default cache policy of the base environment
1372
1425
  environment.setDefaultCachePolicy({
1373
1426
  type: 'stale-while-revalidate',
@@ -1398,6 +1451,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1398
1451
  handleSuccessResponse: { value: handleSuccessResponse },
1399
1452
  handleErrorResponse: { value: handleErrorResponse },
1400
1453
  getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
1454
+ notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
1401
1455
  });
1402
1456
  }
1403
1457
 
@@ -16671,4 +16725,4 @@ register({
16671
16725
  });
16672
16726
 
16673
16727
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16674
- // version: 1.227.0-f636c0f4c
16728
+ // version: 1.227.2-daae2b505
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.227.0",
3
+ "version": "1.227.2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
package/sfdc/main.js CHANGED
@@ -522,6 +522,8 @@ function isDeprecatedDurableStoreEntry(durableRecord) {
522
522
  }
523
523
  const DefaultDurableSegment = 'DEFAULT';
524
524
  const RedirectDurableSegment = 'REDIRECT_KEYS';
525
+ const MessagingDurableSegment = 'MESSAGING';
526
+ const MessageNotifyStoreUpdateAvailable = 'notifyStoreUpdateAvailable';
525
527
 
526
528
  const { keys: keys$7, create: create$6, assign: assign$6, freeze: freeze$1 } = Object;
527
529
 
@@ -960,6 +962,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
960
962
  const defaultSegmentKeys = [];
961
963
  const adapterContextSegmentKeys = [];
962
964
  const redirectSegmentKeys = [];
965
+ const messagingSegmentKeys = [];
963
966
  let shouldBroadcast = false;
964
967
  for (let i = 0, len = changes.length; i < len; i++) {
965
968
  const change = changes[i];
@@ -974,6 +977,9 @@ function makeDurable(environment, { durableStore, instrumentation }) {
974
977
  else if (change.segment === RedirectDurableSegment) {
975
978
  redirectSegmentKeys.push(...change.ids);
976
979
  }
980
+ else if (change.segment === MessagingDurableSegment) {
981
+ messagingSegmentKeys.push(...change.ids);
982
+ }
977
983
  }
978
984
  if (redirectSegmentKeys.length > 0) {
979
985
  const redirectEntries = await durableStore.getEntries(redirectSegmentKeys, RedirectDurableSegment);
@@ -1033,6 +1039,20 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1033
1039
  if (shouldBroadcast) {
1034
1040
  await environment.storeBroadcast(rebuildSnapshot, environment.snapshotAvailable);
1035
1041
  }
1042
+ // if having notifyStoreUpdateAvailable msg, then pull the message body out from store
1043
+ // and call environment.notifyStoreUpdateAvailable
1044
+ if (messagingSegmentKeys.includes(MessageNotifyStoreUpdateAvailable)) {
1045
+ const entries = await durableStore.getEntries([MessageNotifyStoreUpdateAvailable], MessagingDurableSegment);
1046
+ if (entries !== undefined) {
1047
+ const notifyEntry = entries[MessageNotifyStoreUpdateAvailable];
1048
+ if (notifyEntry !== undefined) {
1049
+ const keys = notifyEntry.data;
1050
+ if (keys.length > 0) {
1051
+ environment.notifyStoreUpdateAvailable(keys);
1052
+ }
1053
+ }
1054
+ }
1055
+ }
1036
1056
  });
1037
1057
  const dispose = function () {
1038
1058
  validateNotDisposed();
@@ -1368,6 +1388,39 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1368
1388
  return entries;
1369
1389
  });
1370
1390
  };
1391
+ // flag entries specified by keys in durable store as expired.
1392
+ // send a notifyStoreUpdateAvailable message through durable store set entries to
1393
+ // indirectly triggers all js environments to refresh snapshots if overlapping with keys.
1394
+ const notifyStoreUpdateAvailable = async function (keys$1) {
1395
+ validateNotDisposed();
1396
+ const entryKeys = keys$1.map(serializeStructuredKey);
1397
+ const entries = await durableStore.getEntries(entryKeys, DefaultDurableSegment);
1398
+ if (entries === undefined || keys$7(entries).length === 0) {
1399
+ return environment.notifyStoreUpdateAvailable(keys$1);
1400
+ }
1401
+ const now = Date.now();
1402
+ let needWriteBack = false;
1403
+ for (let i = 0; i < entryKeys.length; i++) {
1404
+ const key = entryKeys[i];
1405
+ const entry = entries[key];
1406
+ if (entry !== undefined) {
1407
+ const storeEntry = entry;
1408
+ if (storeEntry.metadata !== undefined) {
1409
+ storeEntry.metadata = {
1410
+ ...storeEntry.metadata,
1411
+ expirationTimestamp: now,
1412
+ };
1413
+ }
1414
+ needWriteBack = true;
1415
+ }
1416
+ }
1417
+ if (needWriteBack) {
1418
+ await durableStore.setEntries(entries, DefaultDurableSegment);
1419
+ }
1420
+ // push a notifyStoreUpdateAvailable message with entryKeys as data into messaging segment
1421
+ await durableStore.setEntries({ notifyStoreUpdateAvailable: { data: entryKeys } }, MessagingDurableSegment);
1422
+ return Promise.resolve(undefined);
1423
+ };
1371
1424
  // set the default cache policy of the base environment
1372
1425
  environment.setDefaultCachePolicy({
1373
1426
  type: 'stale-while-revalidate',
@@ -1398,6 +1451,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1398
1451
  handleSuccessResponse: { value: handleSuccessResponse },
1399
1452
  handleErrorResponse: { value: handleErrorResponse },
1400
1453
  getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
1454
+ notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
1401
1455
  });
1402
1456
  }
1403
1457
 
@@ -16671,4 +16725,4 @@ register({
16671
16725
  });
16672
16726
 
16673
16727
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16674
- // version: 1.227.0-f636c0f4c
16728
+ // version: 1.227.2-daae2b505