@salesforce/lds-runtime-aura 1.308.0-dev3 → 1.308.0-dev4

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.
@@ -26,7 +26,7 @@ import { BaseCommand, convertAuraResponseToData, convertFetchResponseToData } fr
26
26
  import { serviceBroker } from 'force/luvioServiceBroker5';
27
27
  import oneStoreEnabled from '@salesforce/gate/lds.oneStoreEnabled.ltng';
28
28
  import oneStoreUiapiEnabled from '@salesforce/gate/lds.oneStoreUiapiEnabled.ltng';
29
- import { getDefinition, executeGlobalControllerRawResponse } from 'aura';
29
+ import { unstable_loadComponentDefs, executeGlobalControllerRawResponse } from 'aura';
30
30
  import { buildJwtNetworkAdapter, instrument as instrument$2, setupLexJwtNetworkAdapter } from 'force/ldsNetworkFetchWithJwt';
31
31
  import auraNetworkAdapter, { dispatchAuraAction, defaultActionConfig, instrument as instrument$1, forceRecordTransactionsDisabled as forceRecordTransactionsDisabled$1, ldsNetworkAdapterInstrument, CrudEventState, CrudEventType, UIAPI_RECORDS_PATH, UIAPI_RELATED_LIST_RECORDS_BATCH_PATH, UIAPI_RELATED_LIST_RECORDS_PATH } from 'force/ldsNetwork';
32
32
  import { LRUCache, instrumentAdapter, instrumentLuvio, setupInstrumentation as setupInstrumentation$1, logObjectInfoChanged as logObjectInfoChanged$1, updatePercentileHistogramMetric, incrementCounterMetric, incrementGetRecordNotifyChangeAllowCount, incrementGetRecordNotifyChangeDropCount, incrementNotifyRecordUpdateAvailableAllowCount, incrementNotifyRecordUpdateAvailableDropCount, setLdsAdaptersUiapiInstrumentation, logError, setLdsNetworkAdapterInstrumentation, executeAsyncActivity, METRIC_KEYS, onIdleDetected } from 'force/ldsInstrumentation';
@@ -1833,10 +1833,12 @@ class RecordHomePage extends LexDefaultPage {
1833
1833
  return requestBuckets;
1834
1834
  }
1835
1835
  }
1836
- requestBuckets.push({
1837
- context: this.context,
1838
- request: matchingRequestStrategy.transformForSave(request),
1839
- });
1836
+ if (!matchingRequestStrategy.onlySavedInSimilar) {
1837
+ requestBuckets.push({
1838
+ context: this.context,
1839
+ request: matchingRequestStrategy.transformForSave(request),
1840
+ });
1841
+ }
1840
1842
  return requestBuckets;
1841
1843
  }
1842
1844
  resolveSimilarRequest(similarRequest) {
@@ -2030,7 +2032,7 @@ const TOTAL_ADAPTER_REQUEST_SUCCESS_COUNT = {
2030
2032
  },
2031
2033
  };
2032
2034
 
2033
- const { create, keys, hasOwnProperty } = Object;
2035
+ const { create, keys, hasOwnProperty, entries } = Object;
2034
2036
  const { isArray, from } = Array;
2035
2037
  const { stringify } = JSON;
2036
2038
 
@@ -2724,10 +2726,13 @@ class LexPredictivePrefetcher extends ApplicationPredictivePrefetcher {
2724
2726
  }
2725
2727
  getAllPageRequests() {
2726
2728
  const exactPageRequests = this.getExactPageRequest();
2729
+ let similarPageRequests = this.getSimilarPageRequests();
2727
2730
  if (exactPageRequests.length > 0 && this.options.useExactMatchesPlus === true) {
2728
- return exactPageRequests;
2731
+ similarPageRequests = similarPageRequests.filter((requestEntry) => {
2732
+ const strategy = this.requestStrategies[requestEntry.request.adapterName];
2733
+ return strategy && strategy.onlySavedInSimilar;
2734
+ });
2729
2735
  }
2730
- const similarPageRequests = this.getSimilarPageRequests();
2731
2736
  return [...exactPageRequests, ...similarPageRequests];
2732
2737
  }
2733
2738
  async predict() {
@@ -3013,6 +3018,14 @@ class RequestStrategy {
3013
3018
  isContextDependent(_context, _request) {
3014
3019
  return false;
3015
3020
  }
3021
+ /**
3022
+ * This tells PDL that requests of this strategy can only be saved in the similar bucket.
3023
+ *
3024
+ * @returns boolean
3025
+ */
3026
+ get onlySavedInSimilar() {
3027
+ return false;
3028
+ }
3016
3029
  }
3017
3030
 
3018
3031
  const noop = () => { };
@@ -3102,20 +3115,31 @@ const onePreloads = new Set([
3102
3115
  'markup://sfa:inspectionDesktopObjectHome',
3103
3116
  'markup://records:outputPhone',
3104
3117
  ]);
3118
+ function canPreloadDefinition(def) {
3119
+ return (def.startsWith('markup://') &&
3120
+ !(
3121
+ // some "virtual" components from flexipages are with `__` in the name, eg: design templates.
3122
+ // Not filtering out them will not cause errors, but will cause a server request that returns with error.
3123
+ (def.includes('__') ||
3124
+ // any generated template
3125
+ def.includes('forceGenerated') ||
3126
+ // part of onePreload
3127
+ def.includes('one:onePreloads') ||
3128
+ onePreloads.has(def))));
3129
+ }
3105
3130
  function requestComponents(config) {
3106
- try {
3107
- for (let index = 0, n = config.length; index < n; index++) {
3108
- const def = config[index];
3109
- if (def.startsWith('markup://') &&
3110
- !(def.includes('forceGenerated') ||
3111
- def.includes('one:onePreloads') ||
3112
- onePreloads.has(def))) {
3113
- getDefinition(def, noop);
3114
- }
3131
+ // Because { foo: undefined } can't be saved in indexedDB (serialization is {})
3132
+ // we need to manually save it as { "foo": "" }, and transform it to { foo: undefined }
3133
+ const descriptorsMap = {};
3134
+ let hasComponentsToLoad = false;
3135
+ for (const [def, uid] of entries(config)) {
3136
+ if (canPreloadDefinition(def)) {
3137
+ hasComponentsToLoad = true;
3138
+ descriptorsMap[def] = uid === '' ? undefined : uid;
3115
3139
  }
3116
3140
  }
3117
- catch (e) {
3118
- // dismiss the error.
3141
+ if (hasComponentsToLoad) {
3142
+ unstable_loadComponentDefs(descriptorsMap, noop);
3119
3143
  }
3120
3144
  }
3121
3145
  class GetComponentsDefStrategy extends RequestStrategy {
@@ -3132,7 +3156,14 @@ class GetComponentsDefStrategy extends RequestStrategy {
3132
3156
  };
3133
3157
  }
3134
3158
  transformForSave(request) {
3135
- const normalizedConfig = (request.config || []).map((def) => def.indexOf('://') === -1 ? 'markup://' + def : def);
3159
+ const normalizedConfig = {};
3160
+ for (const [def, uid] of entries(request.config || {})) {
3161
+ const normalizedDescriptorName = def.indexOf('://') === -1 ? 'markup://' + def : def;
3162
+ // uid can be a string, an object, or undefined.
3163
+ // when is an object or undefined, we can't say anything about the version,
3164
+ // and we can't save it as `undefined` as it can't be persisted to indexed db.
3165
+ normalizedConfig[normalizedDescriptorName] = typeof uid === 'string' ? uid : '';
3166
+ }
3136
3167
  return {
3137
3168
  ...request,
3138
3169
  config: normalizedConfig,
@@ -3142,18 +3173,21 @@ class GetComponentsDefStrategy extends RequestStrategy {
3142
3173
  return true;
3143
3174
  }
3144
3175
  combineRequests(reqA, reqB) {
3145
- const result = new Set(reqA);
3146
- reqB.forEach((c) => result.add(c));
3147
- // remove the ones that can't be preloaded.
3148
- return [...result].filter((def) => {
3149
- return (def.startsWith('markup://') &&
3150
- !(
3151
- // any generated template
3152
- (def.includes('forceGenerated') ||
3153
- // part of onePreload
3154
- def.includes('one:onePreloads') ||
3155
- onePreloads.has(def))));
3156
- });
3176
+ const combinedDescriptors = {};
3177
+ // Note the order is important [reqA, reqB], reqB is always after reqA, and we want to keep the last seen uid
3178
+ // of a specific component.
3179
+ for (const descriptorMap of [reqA, reqB]) {
3180
+ for (const [def, uid] of entries(descriptorMap)) {
3181
+ if (canPreloadDefinition(def)) {
3182
+ combinedDescriptors[def] = uid;
3183
+ }
3184
+ }
3185
+ }
3186
+ return combinedDescriptors;
3187
+ }
3188
+ get onlySavedInSimilar() {
3189
+ // Important: tells PDL to save this request only in the similar buckets.
3190
+ return true;
3157
3191
  }
3158
3192
  isContextDependent(_context, _request) {
3159
3193
  return true;
@@ -4023,7 +4057,7 @@ function getEnvironmentSetting(name) {
4023
4057
  }
4024
4058
  return undefined;
4025
4059
  }
4026
- // version: 1.308.0-dev3-5eb971dcf6
4060
+ // version: 1.308.0-dev4-f0bdc19646
4027
4061
 
4028
4062
  const forceRecordTransactionsDisabled = getEnvironmentSetting(EnvironmentSettings.ForceRecordTransactionsDisabled);
4029
4063
  //TODO: Some duplication here that can be most likely moved to a util class
@@ -4406,7 +4440,7 @@ function loadComponentsDefStartedOverride(...args) {
4406
4440
  const config = Array.prototype.shift.apply(args);
4407
4441
  const ret = config['fn'].apply(config['scope'], args);
4408
4442
  try {
4409
- const defs = keys(args[0] || {});
4443
+ const defs = args[0] || {};
4410
4444
  __lexPrefetcher.saveRequest({
4411
4445
  adapterName: 'getComponentsDef',
4412
4446
  config: defs,
@@ -4456,13 +4490,21 @@ function buildPredictorForContext(context) {
4456
4490
  watchPageLoadForPredictions() {
4457
4491
  // This chunk tells the prefetcher to receive events, send off any predictions we have from previous loads, then setup idle detection to stop predicting.
4458
4492
  __lexPrefetcher.startRecording();
4459
- if (useCmpDefPredictions.isOpen({ fallback: false })) {
4460
- window['$A'].installOverride('ComponentService.loadComponentDefsStarted', loadComponentsDefStartedOverride);
4493
+ // We only want to use cmpDef predictions on PROD code,
4494
+ // as in dev, it is assumed that the definitions will change often
4495
+ if (process.env.NODE_ENV === 'production') {
4496
+ if (useCmpDefPredictions.isOpen({ fallback: false })) {
4497
+ window['$A'].installOverride('ComponentService.loadComponentDefsStarted', loadComponentsDefStartedOverride);
4498
+ }
4461
4499
  }
4462
4500
  onIdleDetected(() => {
4463
4501
  __lexPrefetcher.stopRecording();
4464
- if (useCmpDefPredictions.isOpen({ fallback: false })) {
4465
- window['$A'].uninstallOverride('ComponentService.loadComponentDefsStarted', loadComponentsDefStartedOverride);
4502
+ // We only want to use cmpDef predictions on PROD code,
4503
+ // as in dev, it is assumed that the definitions will change often
4504
+ if (process.env.NODE_ENV === 'production') {
4505
+ if (useCmpDefPredictions.isOpen({ fallback: false })) {
4506
+ window['$A'].uninstallOverride('ComponentService.loadComponentDefsStarted', loadComponentsDefStartedOverride);
4507
+ }
4466
4508
  }
4467
4509
  });
4468
4510
  },
@@ -4578,4 +4620,4 @@ function ldsEngineCreator() {
4578
4620
  }
4579
4621
 
4580
4622
  export { buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore };
4581
- // version: 1.308.0-dev3-d47029eab2
4623
+ // version: 1.308.0-dev4-d65a66df4a
@@ -4,7 +4,12 @@ declare const create: {
4
4
  }, keys: {
5
5
  (o: object): string[];
6
6
  (o: {}): string[];
7
- }, hasOwnProperty: (v: PropertyKey) => boolean;
7
+ }, hasOwnProperty: (v: PropertyKey) => boolean, entries: {
8
+ <T>(o: {
9
+ [s: string]: T;
10
+ } | ArrayLike<T>): [string, T][];
11
+ (o: {}): [string, any][];
12
+ };
8
13
  declare const isArray: (arg: any) => arg is any[], from: {
9
14
  <T>(arrayLike: ArrayLike<T>): T[];
10
15
  <T_1, U>(arrayLike: ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
@@ -15,4 +20,4 @@ declare const stringify: {
15
20
  (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
16
21
  (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
17
22
  };
18
- export { create as ObjectCreate, keys as ObjectKeys, hasOwnProperty as ObjectHasOwnProperty, isArray as ArrayIsArray, from as ArrayFrom, stringify as JSONStringify, };
23
+ export { create as ObjectCreate, keys as ObjectKeys, hasOwnProperty as ObjectHasOwnProperty, entries as ObjectEntries, isArray as ArrayIsArray, from as ArrayFrom, stringify as JSONStringify, };
@@ -1,17 +1,25 @@
1
1
  import { RequestStrategy } from './request-strategy';
2
+ type DescriptorsMap = Record<string, unknown | string | undefined>;
3
+ type NormalizedDescriptorsMap = Record<string, string>;
2
4
  export type GetComponentsRequest = {
3
5
  adapterName: 'getComponentsDef';
4
- config: string[];
6
+ config: DescriptorsMap;
7
+ };
8
+ export type NormalizedGetComponentsRequest = {
9
+ adapterName: 'getComponentsDef';
10
+ config: NormalizedDescriptorsMap;
5
11
  };
6
12
  export type GetComponentsContext = {
7
13
  objectApiName: string;
8
14
  };
9
- export declare class GetComponentsDefStrategy extends RequestStrategy<string[], GetComponentsRequest, GetComponentsContext> {
15
+ export declare class GetComponentsDefStrategy extends RequestStrategy<DescriptorsMap, GetComponentsRequest, GetComponentsContext> {
10
16
  adapterName: string;
11
- execute(config: string[]): void;
17
+ execute(config: NormalizedDescriptorsMap): void;
12
18
  buildConcreteRequest(similarRequest: GetComponentsRequest, _context: GetComponentsContext): GetComponentsRequest;
13
- transformForSave(request: GetComponentsRequest): GetComponentsRequest;
19
+ transformForSave(request: GetComponentsRequest): NormalizedGetComponentsRequest;
14
20
  canCombine(): boolean;
15
- combineRequests(reqA: string[], reqB: string[]): string[];
21
+ combineRequests(reqA: NormalizedDescriptorsMap, reqB: NormalizedDescriptorsMap): NormalizedDescriptorsMap;
22
+ get onlySavedInSimilar(): boolean;
16
23
  isContextDependent(_context: GetComponentsContext, _request: GetComponentsRequest): boolean;
17
24
  }
25
+ export {};
@@ -65,4 +65,10 @@ export declare abstract class RequestStrategy<Config, Request extends BaseAdapte
65
65
  * @returns
66
66
  */
67
67
  isContextDependent(_context: Context, _request: Request): boolean;
68
+ /**
69
+ * This tells PDL that requests of this strategy can only be saved in the similar bucket.
70
+ *
71
+ * @returns boolean
72
+ */
73
+ get onlySavedInSimilar(): boolean;
68
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.308.0-dev3",
3
+ "version": "1.308.0-dev4",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Aura runtime",
6
6
  "main": "dist/ldsEngineCreator.js",
@@ -35,15 +35,15 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@luvio/service-broker": "5.3.1",
38
- "@salesforce/lds-adapters-apex": "^1.308.0-dev3",
39
- "@salesforce/lds-adapters-uiapi": "^1.308.0-dev3",
38
+ "@salesforce/lds-adapters-apex": "^1.308.0-dev4",
39
+ "@salesforce/lds-adapters-uiapi": "^1.308.0-dev4",
40
40
  "@salesforce/lds-adapters-uiapi-lex": "^1.302.0",
41
- "@salesforce/lds-ads-bridge": "^1.308.0-dev3",
42
- "@salesforce/lds-aura-storage": "^1.308.0-dev3",
43
- "@salesforce/lds-bindings": "^1.308.0-dev3",
44
- "@salesforce/lds-instrumentation": "^1.308.0-dev3",
45
- "@salesforce/lds-network-aura": "^1.308.0-dev3",
46
- "@salesforce/lds-network-fetch-with-jwt": "^1.308.0-dev3"
41
+ "@salesforce/lds-ads-bridge": "^1.308.0-dev4",
42
+ "@salesforce/lds-aura-storage": "^1.308.0-dev4",
43
+ "@salesforce/lds-bindings": "^1.308.0-dev4",
44
+ "@salesforce/lds-instrumentation": "^1.308.0-dev4",
45
+ "@salesforce/lds-network-aura": "^1.308.0-dev4",
46
+ "@salesforce/lds-network-fetch-with-jwt": "^1.308.0-dev4"
47
47
  },
48
48
  "dependencies": {
49
49
  "@luvio/command-aura-network": "5.3.1",
@@ -64,7 +64,7 @@
64
64
  "@luvio/service-subscription": "5.3.1",
65
65
  "@luvio/service-type-registry": "5.3.1",
66
66
  "@luvio/utils": "5.3.1",
67
- "@salesforce/lds-adapters-uiapi-lex": "^1.308.0-dev3"
67
+ "@salesforce/lds-adapters-uiapi-lex": "^1.308.0-dev4"
68
68
  },
69
69
  "luvioBundlesize": [
70
70
  {
@@ -72,7 +72,7 @@
72
72
  "maxSize": {
73
73
  "none": "175 kB",
74
74
  "min": "75 kB",
75
- "compressed": "31 kB"
75
+ "compressed": "32 kB"
76
76
  }
77
77
  }
78
78
  ],