@salesforce/lds-runtime-mobile 1.285.0 → 1.286.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -18028,6 +18028,74 @@ function primingSessionFactory(config) {
18028
18028
  return instrumentPrimingSession(session);
18029
18029
  }
18030
18030
 
18031
+ const DEFAULT_MAX_RECORD_COUNT = 80000;
18032
+ const DEFAULT_MAX_BATCH_SIZE = 200;
18033
+ async function aggressiveTrim(data, deallocateFn, options = {}) {
18034
+ const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
18035
+ const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
18036
+ let deallocatedCount = 0;
18037
+ const { pendingTrimKeys, retainedIds, storeRecords } = data;
18038
+ const storeKeyLength = keys$1(storeRecords).length;
18039
+ if (storeKeyLength <= maxStoreRecords) {
18040
+ return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
18041
+ }
18042
+ const overFlowSize = storeKeyLength - maxStoreRecords;
18043
+ if (overFlowSize <= 0) {
18044
+ return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
18045
+ }
18046
+ const trimKeys = new Set();
18047
+ for (const key of pendingTrimKeys) {
18048
+ if (storeKeyLength - trimKeys.size <= maxStoreRecords) {
18049
+ break;
18050
+ }
18051
+ if ((retainedIds[key] === undefined && storeRecords[key] !== undefined) ||
18052
+ (retainedIds[key] !== undefined && retainedIds[key] <= 1)) {
18053
+ trimKeys.add(key);
18054
+ }
18055
+ }
18056
+ const batches = batchKeys(trimKeys, batchSize).map((batch) => {
18057
+ return () => batchToPromise(batch, deallocateFn);
18058
+ });
18059
+ for (const batch of batches) {
18060
+ // execute each batch between ticks
18061
+ const count = await batch();
18062
+ deallocatedCount = deallocatedCount + count;
18063
+ }
18064
+ const trimKeysSkipped = makeSetFilteredFromDifference(pendingTrimKeys, (key) => trimKeys.has(key) === false);
18065
+ return {
18066
+ deallocatedCount,
18067
+ trimKeysSkipped,
18068
+ };
18069
+ }
18070
+ function batchToPromise(batch, deallocateFn) {
18071
+ return new Promise((resolve) => {
18072
+ let count = 0;
18073
+ batch.forEach((key) => {
18074
+ deallocateFn(key);
18075
+ count++;
18076
+ });
18077
+ resolve(count);
18078
+ });
18079
+ }
18080
+ function batchKeys(keys, batchSize) {
18081
+ const keyArray = Array.from(keys);
18082
+ const batches = [];
18083
+ for (let i = 0, len = keyArray.length; i < len; i += batchSize) {
18084
+ const batch = keyArray.slice(i, i + batchSize);
18085
+ batches.push(batch);
18086
+ }
18087
+ return batches;
18088
+ }
18089
+ function makeSetFilteredFromDifference(setToFilter, diff) {
18090
+ let filteredSet = new Set();
18091
+ setToFilter.forEach((t) => {
18092
+ if (diff(t)) {
18093
+ filteredSet.add(t);
18094
+ }
18095
+ });
18096
+ return filteredSet;
18097
+ }
18098
+
18031
18099
  // so eslint doesn't complain about nimbus
18032
18100
  /* global __nimbus */
18033
18101
  function setupObserver() {
@@ -18071,7 +18139,9 @@ function getRuntime() {
18071
18139
  // user id centric record ID generator
18072
18140
  const { newRecordId, isGenerated } = recordIdGenerator(userId);
18073
18141
  // non-draft-aware base services
18074
- const store = new InMemoryStore();
18142
+ const store = new InMemoryStore({
18143
+ customTrimPolicy: aggressiveTrim,
18144
+ });
18075
18145
  lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
18076
18146
  reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
18077
18147
  }));
@@ -18211,4 +18281,4 @@ register({
18211
18281
  });
18212
18282
 
18213
18283
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18214
- // version: 1.285.0-67d4d6869
18284
+ // version: 1.286.0-09e7e5207
@@ -0,0 +1,7 @@
1
+ import type { TrimTaskData, DeallocationFunction, TrimResult } from '@luvio/engine';
2
+ type TrimOptions = {
3
+ batchSize?: number;
4
+ maxStoreRecords?: number;
5
+ };
6
+ export declare function aggressiveTrim(data: TrimTaskData, deallocateFn: DeallocationFunction, options?: TrimOptions): Promise<TrimResult>;
7
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.285.0",
3
+ "version": "1.286.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,25 +32,25 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@salesforce/lds-adapters-uiapi": "^1.285.0",
36
- "@salesforce/lds-bindings": "^1.285.0",
37
- "@salesforce/lds-instrumentation": "^1.285.0",
38
- "@salesforce/lds-priming": "^1.285.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.286.0",
36
+ "@salesforce/lds-bindings": "^1.286.0",
37
+ "@salesforce/lds-instrumentation": "^1.286.0",
38
+ "@salesforce/lds-priming": "^1.286.0",
39
39
  "@salesforce/user": "0.0.21",
40
- "o11y": "244.0.0"
40
+ "o11y": "250.7.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.285.0",
44
- "@salesforce/lds-drafts": "^1.285.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.285.0",
46
- "@salesforce/lds-graphql-eval": "^1.285.0",
47
- "@salesforce/lds-network-adapter": "^1.285.0",
48
- "@salesforce/lds-network-nimbus": "^1.285.0",
49
- "@salesforce/lds-store-binary": "^1.285.0",
50
- "@salesforce/lds-store-nimbus": "^1.285.0",
51
- "@salesforce/lds-store-sql": "^1.285.0",
52
- "@salesforce/lds-utils-adapters": "^1.285.0",
53
- "@salesforce/nimbus-plugin-lds": "^1.285.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.286.0",
44
+ "@salesforce/lds-drafts": "^1.286.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.286.0",
46
+ "@salesforce/lds-graphql-eval": "^1.286.0",
47
+ "@salesforce/lds-network-adapter": "^1.286.0",
48
+ "@salesforce/lds-network-nimbus": "^1.286.0",
49
+ "@salesforce/lds-store-binary": "^1.286.0",
50
+ "@salesforce/lds-store-nimbus": "^1.286.0",
51
+ "@salesforce/lds-store-sql": "^1.286.0",
52
+ "@salesforce/lds-utils-adapters": "^1.286.0",
53
+ "@salesforce/nimbus-plugin-lds": "^1.286.0",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
55
55
  "wait-for-expect": "^3.0.2"
56
56
  },
@@ -59,7 +59,7 @@
59
59
  "path": "./dist/main.js",
60
60
  "maxSize": {
61
61
  "none": "800 kB",
62
- "min": "322.2 kB",
62
+ "min": "323.2 kB",
63
63
  "compressed": "150 kB"
64
64
  }
65
65
  },
@@ -67,7 +67,7 @@
67
67
  "path": "./sfdc/main.js",
68
68
  "maxSize": {
69
69
  "none": "800 kB",
70
- "min": "322.2 kB",
70
+ "min": "323.2 kB",
71
71
  "compressed": "150 kB"
72
72
  }
73
73
  }
package/sfdc/main.js CHANGED
@@ -18028,6 +18028,74 @@ function primingSessionFactory(config) {
18028
18028
  return instrumentPrimingSession(session);
18029
18029
  }
18030
18030
 
18031
+ const DEFAULT_MAX_RECORD_COUNT = 80000;
18032
+ const DEFAULT_MAX_BATCH_SIZE = 200;
18033
+ async function aggressiveTrim(data, deallocateFn, options = {}) {
18034
+ const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
18035
+ const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
18036
+ let deallocatedCount = 0;
18037
+ const { pendingTrimKeys, retainedIds, storeRecords } = data;
18038
+ const storeKeyLength = keys$1(storeRecords).length;
18039
+ if (storeKeyLength <= maxStoreRecords) {
18040
+ return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
18041
+ }
18042
+ const overFlowSize = storeKeyLength - maxStoreRecords;
18043
+ if (overFlowSize <= 0) {
18044
+ return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
18045
+ }
18046
+ const trimKeys = new Set();
18047
+ for (const key of pendingTrimKeys) {
18048
+ if (storeKeyLength - trimKeys.size <= maxStoreRecords) {
18049
+ break;
18050
+ }
18051
+ if ((retainedIds[key] === undefined && storeRecords[key] !== undefined) ||
18052
+ (retainedIds[key] !== undefined && retainedIds[key] <= 1)) {
18053
+ trimKeys.add(key);
18054
+ }
18055
+ }
18056
+ const batches = batchKeys(trimKeys, batchSize).map((batch) => {
18057
+ return () => batchToPromise(batch, deallocateFn);
18058
+ });
18059
+ for (const batch of batches) {
18060
+ // execute each batch between ticks
18061
+ const count = await batch();
18062
+ deallocatedCount = deallocatedCount + count;
18063
+ }
18064
+ const trimKeysSkipped = makeSetFilteredFromDifference(pendingTrimKeys, (key) => trimKeys.has(key) === false);
18065
+ return {
18066
+ deallocatedCount,
18067
+ trimKeysSkipped,
18068
+ };
18069
+ }
18070
+ function batchToPromise(batch, deallocateFn) {
18071
+ return new Promise((resolve) => {
18072
+ let count = 0;
18073
+ batch.forEach((key) => {
18074
+ deallocateFn(key);
18075
+ count++;
18076
+ });
18077
+ resolve(count);
18078
+ });
18079
+ }
18080
+ function batchKeys(keys, batchSize) {
18081
+ const keyArray = Array.from(keys);
18082
+ const batches = [];
18083
+ for (let i = 0, len = keyArray.length; i < len; i += batchSize) {
18084
+ const batch = keyArray.slice(i, i + batchSize);
18085
+ batches.push(batch);
18086
+ }
18087
+ return batches;
18088
+ }
18089
+ function makeSetFilteredFromDifference(setToFilter, diff) {
18090
+ let filteredSet = new Set();
18091
+ setToFilter.forEach((t) => {
18092
+ if (diff(t)) {
18093
+ filteredSet.add(t);
18094
+ }
18095
+ });
18096
+ return filteredSet;
18097
+ }
18098
+
18031
18099
  // so eslint doesn't complain about nimbus
18032
18100
  /* global __nimbus */
18033
18101
  function setupObserver() {
@@ -18071,7 +18139,9 @@ function getRuntime() {
18071
18139
  // user id centric record ID generator
18072
18140
  const { newRecordId, isGenerated } = recordIdGenerator(userId);
18073
18141
  // non-draft-aware base services
18074
- const store = new InMemoryStore();
18142
+ const store = new InMemoryStore({
18143
+ customTrimPolicy: aggressiveTrim,
18144
+ });
18075
18145
  lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
18076
18146
  reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
18077
18147
  }));
@@ -18211,4 +18281,4 @@ register({
18211
18281
  });
18212
18282
 
18213
18283
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18214
- // version: 1.285.0-67d4d6869
18284
+ // version: 1.286.0-09e7e5207
@@ -0,0 +1,7 @@
1
+ import type { TrimTaskData, DeallocationFunction, TrimResult } from '@luvio/engine';
2
+ type TrimOptions = {
3
+ batchSize?: number;
4
+ maxStoreRecords?: number;
5
+ };
6
+ export declare function aggressiveTrim(data: TrimTaskData, deallocateFn: DeallocationFunction, options?: TrimOptions): Promise<TrimResult>;
7
+ export {};