@salesforce/lds-runtime-aura 1.309.0-dev14 → 1.309.0-dev16
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/ldsEngineCreator.js +75 -7
- package/dist/types/main.d.ts +2 -1
- package/dist/types/predictive-loading/lex/index.d.ts +1 -0
- package/dist/types/predictive-loading/lex/predictions-ready-manager.d.ts +32 -0
- package/dist/types/predictive-loading/storage/aura-prefetch-storage.d.ts +4 -2
- package/package.json +13 -13
package/dist/ldsEngineCreator.js
CHANGED
|
@@ -3998,18 +3998,19 @@ const DEFAULT_STORAGE_OPTIONS = {
|
|
|
3998
3998
|
version: 3,
|
|
3999
3999
|
};
|
|
4000
4000
|
function buildAuraPrefetchStorage(options = {}) {
|
|
4001
|
+
const { onPredictionsReadyCallback, ...storageOptions } = options;
|
|
4001
4002
|
const auraStorage = createStorage({
|
|
4002
4003
|
...DEFAULT_STORAGE_OPTIONS,
|
|
4003
|
-
...
|
|
4004
|
+
...storageOptions,
|
|
4004
4005
|
});
|
|
4005
4006
|
const inMemoryStorage = new InMemoryPrefetchStorage();
|
|
4006
4007
|
if (auraStorage === null) {
|
|
4007
4008
|
return inMemoryStorage;
|
|
4008
4009
|
}
|
|
4009
|
-
return new AuraPrefetchStorage(auraStorage, inMemoryStorage);
|
|
4010
|
+
return new AuraPrefetchStorage(auraStorage, inMemoryStorage, onPredictionsReadyCallback);
|
|
4010
4011
|
}
|
|
4011
4012
|
class AuraPrefetchStorage {
|
|
4012
|
-
constructor(auraStorage, inMemoryStorage) {
|
|
4013
|
+
constructor(auraStorage, inMemoryStorage, onPredictionsReadyCallback = () => { }) {
|
|
4013
4014
|
this.auraStorage = auraStorage;
|
|
4014
4015
|
this.inMemoryStorage = inMemoryStorage;
|
|
4015
4016
|
/**
|
|
@@ -4026,6 +4027,7 @@ class AuraPrefetchStorage {
|
|
|
4026
4027
|
*/
|
|
4027
4028
|
auraStorage.getAll().then((results) => {
|
|
4028
4029
|
keys(results).forEach((key) => this.inMemoryStorage.set(key, results[key]));
|
|
4030
|
+
onPredictionsReadyCallback();
|
|
4029
4031
|
});
|
|
4030
4032
|
}
|
|
4031
4033
|
set(key, value) {
|
|
@@ -4099,7 +4101,7 @@ function getEnvironmentSetting(name) {
|
|
|
4099
4101
|
}
|
|
4100
4102
|
return undefined;
|
|
4101
4103
|
}
|
|
4102
|
-
// version: 1.309.0-
|
|
4104
|
+
// version: 1.309.0-dev16-189d0681ed
|
|
4103
4105
|
|
|
4104
4106
|
const forceRecordTransactionsDisabled = getEnvironmentSetting(EnvironmentSettings.ForceRecordTransactionsDisabled);
|
|
4105
4107
|
//TODO: Some duplication here that can be most likely moved to a util class
|
|
@@ -4394,6 +4396,53 @@ function setupMetadataWatcher(luvio) {
|
|
|
4394
4396
|
});
|
|
4395
4397
|
}
|
|
4396
4398
|
|
|
4399
|
+
/**
|
|
4400
|
+
* Manages the state of predictions and notifies registered callbacks when predictions are ready.
|
|
4401
|
+
*/
|
|
4402
|
+
class PredictionsReadyManager {
|
|
4403
|
+
constructor() {
|
|
4404
|
+
/**
|
|
4405
|
+
* Array of callbacks to be executed when predictions are ready.
|
|
4406
|
+
* @private
|
|
4407
|
+
*/
|
|
4408
|
+
this.predictionsReadyCallbacks = [];
|
|
4409
|
+
/**
|
|
4410
|
+
* Indicates whether the predictions are ready.
|
|
4411
|
+
* @private
|
|
4412
|
+
*/
|
|
4413
|
+
this.predictionsReady = false;
|
|
4414
|
+
}
|
|
4415
|
+
/**
|
|
4416
|
+
* Registers a callback to be called when predictions are ready.
|
|
4417
|
+
* If predictions are already ready, the callback is invoked immediately.
|
|
4418
|
+
*
|
|
4419
|
+
* @param {() => void} callback - The callback function to be executed when predictions are ready.
|
|
4420
|
+
*/
|
|
4421
|
+
whenPredictionsReady(callback) {
|
|
4422
|
+
if (this.predictionsReady) {
|
|
4423
|
+
callback();
|
|
4424
|
+
}
|
|
4425
|
+
else {
|
|
4426
|
+
this.predictionsReadyCallbacks.push(callback);
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4429
|
+
/**
|
|
4430
|
+
* Notifies that predictions are ready by invoking all registered callbacks.
|
|
4431
|
+
*/
|
|
4432
|
+
notifyPredictionsReady() {
|
|
4433
|
+
this.predictionsReady = true;
|
|
4434
|
+
this.predictionsReadyCallbacks.forEach((cb) => cb());
|
|
4435
|
+
}
|
|
4436
|
+
/**
|
|
4437
|
+
* Retrieves the list of callbacks registered to be executed when predictions are ready.
|
|
4438
|
+
*
|
|
4439
|
+
* @returns {Array<() => void>} Array of callback functions.
|
|
4440
|
+
*/
|
|
4441
|
+
getCallbacks() {
|
|
4442
|
+
return this.predictionsReadyCallbacks;
|
|
4443
|
+
}
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4397
4446
|
// This code *should* be in lds-network-adapter, but when combined with the Aura
|
|
4398
4447
|
// component test workaround in lds-default-luvio it creates a circular dependecy
|
|
4399
4448
|
// between lds-default-luvio and lds-network-adapter. We do the register on behalf
|
|
@@ -4430,8 +4479,14 @@ function getInflightRequestLimit() {
|
|
|
4430
4479
|
return HARDCODED_REQUEST_LIMIT;
|
|
4431
4480
|
}
|
|
4432
4481
|
}
|
|
4482
|
+
const predictionsReadyManager = new PredictionsReadyManager();
|
|
4483
|
+
function whenPredictionsReady(callback) {
|
|
4484
|
+
predictionsReadyManager.whenPredictionsReady(callback);
|
|
4485
|
+
}
|
|
4433
4486
|
function setupPredictivePrefetcher(luvio) {
|
|
4434
|
-
const storage = buildAuraPrefetchStorage(
|
|
4487
|
+
const storage = buildAuraPrefetchStorage({
|
|
4488
|
+
onPredictionsReadyCallback: () => predictionsReadyManager.notifyPredictionsReady(),
|
|
4489
|
+
});
|
|
4435
4490
|
const requestRunner = new LexRequestRunner(luvio);
|
|
4436
4491
|
const repository = new PrefetchRepository(storage, {
|
|
4437
4492
|
modifyBeforeSaveHook: (requests) => requestRunner.reduceRequests(requests),
|
|
@@ -4523,6 +4578,16 @@ function buildPredictorForContext(context) {
|
|
|
4523
4578
|
if (__lexPrefetcher === undefined) {
|
|
4524
4579
|
return;
|
|
4525
4580
|
}
|
|
4581
|
+
const currentContext = __lexPrefetcher.context;
|
|
4582
|
+
let isSameContext = false;
|
|
4583
|
+
if (currentContext && currentContext.type === 'recordPage') {
|
|
4584
|
+
const rhPageContext = currentContext;
|
|
4585
|
+
isSameContext =
|
|
4586
|
+
rhPageContext.actionName === context.actionName &&
|
|
4587
|
+
rhPageContext.objectApiName === context.objectApiName &&
|
|
4588
|
+
rhPageContext.recordId === context.recordId &&
|
|
4589
|
+
rhPageContext.type === context.type;
|
|
4590
|
+
}
|
|
4526
4591
|
// // This chunk configures which page we're going to use to try and preload.
|
|
4527
4592
|
__lexPrefetcher.context = context;
|
|
4528
4593
|
return {
|
|
@@ -4551,6 +4616,9 @@ function buildPredictorForContext(context) {
|
|
|
4551
4616
|
});
|
|
4552
4617
|
},
|
|
4553
4618
|
runPredictions() {
|
|
4619
|
+
if (isSameContext) {
|
|
4620
|
+
return Promise.resolve();
|
|
4621
|
+
}
|
|
4554
4622
|
return executeAsyncActivity(METRIC_KEYS.PREDICTIVE_DATA_LOADING_PREDICT, (_act) => __lexPrefetcher.predict(), PDL_EXECUTE_ASYNC_OPTIONS);
|
|
4555
4623
|
},
|
|
4556
4624
|
getPredictionSummary() {
|
|
@@ -4661,5 +4729,5 @@ function ldsEngineCreator() {
|
|
|
4661
4729
|
return { name: 'ldsEngineCreator' };
|
|
4662
4730
|
}
|
|
4663
4731
|
|
|
4664
|
-
export { buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore };
|
|
4665
|
-
// version: 1.309.0-
|
|
4732
|
+
export { buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, whenPredictionsReady };
|
|
4733
|
+
// version: 1.309.0-dev16-7409c81567
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type RecordHomePageContext } from './predictive-loading';
|
|
2
|
+
export declare function whenPredictionsReady(callback: () => void): void;
|
|
2
3
|
/**
|
|
3
4
|
* @typedef {Object} RecordHomePageContext
|
|
4
5
|
* @property {string} objectApiName - The API name of the object.
|
|
@@ -27,7 +28,7 @@ import { type RecordHomePageContext } from './predictive-loading';
|
|
|
27
28
|
export declare function buildPredictorForContext(context: RecordHomePageContext): {
|
|
28
29
|
hasPredictions(): boolean;
|
|
29
30
|
watchPageLoadForPredictions(): void;
|
|
30
|
-
runPredictions(): Promise<void
|
|
31
|
+
runPredictions(): Promise<void>;
|
|
31
32
|
getPredictionSummary(): {
|
|
32
33
|
exact: number;
|
|
33
34
|
similar: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PredictionsReadyManager } from './predictions-ready-manager';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages the state of predictions and notifies registered callbacks when predictions are ready.
|
|
3
|
+
*/
|
|
4
|
+
export declare class PredictionsReadyManager {
|
|
5
|
+
/**
|
|
6
|
+
* Array of callbacks to be executed when predictions are ready.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
private predictionsReadyCallbacks;
|
|
10
|
+
/**
|
|
11
|
+
* Indicates whether the predictions are ready.
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
private predictionsReady;
|
|
15
|
+
/**
|
|
16
|
+
* Registers a callback to be called when predictions are ready.
|
|
17
|
+
* If predictions are already ready, the callback is invoked immediately.
|
|
18
|
+
*
|
|
19
|
+
* @param {() => void} callback - The callback function to be executed when predictions are ready.
|
|
20
|
+
*/
|
|
21
|
+
whenPredictionsReady(callback: () => void): void;
|
|
22
|
+
/**
|
|
23
|
+
* Notifies that predictions are ready by invoking all registered callbacks.
|
|
24
|
+
*/
|
|
25
|
+
notifyPredictionsReady(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the list of callbacks registered to be executed when predictions are ready.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Array<() => void>} Array of callback functions.
|
|
30
|
+
*/
|
|
31
|
+
getCallbacks(): Array<() => void>;
|
|
32
|
+
}
|
|
@@ -11,11 +11,13 @@ export declare const DEFAULT_STORAGE_OPTIONS: {
|
|
|
11
11
|
debugLogging: boolean;
|
|
12
12
|
version: number;
|
|
13
13
|
};
|
|
14
|
-
export declare function buildAuraPrefetchStorage(options?: Partial<AuraStorageConfig>
|
|
14
|
+
export declare function buildAuraPrefetchStorage(options?: Partial<AuraStorageConfig> & {
|
|
15
|
+
onPredictionsReadyCallback?: () => void;
|
|
16
|
+
}): PrefetchStorage;
|
|
15
17
|
export declare class AuraPrefetchStorage implements PrefetchStorage {
|
|
16
18
|
private auraStorage;
|
|
17
19
|
private inMemoryStorage;
|
|
18
|
-
constructor(auraStorage: AuraStorage, inMemoryStorage: InMemoryPrefetchStorage);
|
|
20
|
+
constructor(auraStorage: AuraStorage, inMemoryStorage: InMemoryPrefetchStorage, onPredictionsReadyCallback?: () => void);
|
|
19
21
|
set<T>(key: string, value: T): Promise<void>;
|
|
20
22
|
get<T>(key: string): T | undefined;
|
|
21
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-aura",
|
|
3
|
-
"version": "1.309.0-
|
|
3
|
+
"version": "1.309.0-dev16",
|
|
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.2-dev2",
|
|
38
|
-
"@salesforce/lds-adapters-apex": "^1.309.0-
|
|
39
|
-
"@salesforce/lds-adapters-uiapi": "^1.309.0-
|
|
38
|
+
"@salesforce/lds-adapters-apex": "^1.309.0-dev16",
|
|
39
|
+
"@salesforce/lds-adapters-uiapi": "^1.309.0-dev16",
|
|
40
40
|
"@salesforce/lds-adapters-uiapi-lex": "^1.302.0",
|
|
41
|
-
"@salesforce/lds-ads-bridge": "^1.309.0-
|
|
42
|
-
"@salesforce/lds-aura-storage": "^1.309.0-
|
|
43
|
-
"@salesforce/lds-bindings": "^1.309.0-
|
|
44
|
-
"@salesforce/lds-instrumentation": "^1.309.0-
|
|
45
|
-
"@salesforce/lds-network-aura": "^1.309.0-
|
|
46
|
-
"@salesforce/lds-network-fetch-with-jwt": "^1.309.0-
|
|
41
|
+
"@salesforce/lds-ads-bridge": "^1.309.0-dev16",
|
|
42
|
+
"@salesforce/lds-aura-storage": "^1.309.0-dev16",
|
|
43
|
+
"@salesforce/lds-bindings": "^1.309.0-dev16",
|
|
44
|
+
"@salesforce/lds-instrumentation": "^1.309.0-dev16",
|
|
45
|
+
"@salesforce/lds-network-aura": "^1.309.0-dev16",
|
|
46
|
+
"@salesforce/lds-network-fetch-with-jwt": "^1.309.0-dev16"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@luvio/command-aura-network": "5.3.2-dev2",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"@luvio/command-network": "5.3.2-dev2",
|
|
52
52
|
"@luvio/command-sse": "5.3.2-dev2",
|
|
53
53
|
"@luvio/command-streaming": "5.3.2-dev2",
|
|
54
|
-
"@luvio/network-adapter-composable": "0.156.4-
|
|
55
|
-
"@luvio/network-adapter-fetch": "0.156.4-
|
|
54
|
+
"@luvio/network-adapter-composable": "0.156.4-dev2",
|
|
55
|
+
"@luvio/network-adapter-fetch": "0.156.4-dev2",
|
|
56
56
|
"@luvio/runtime": "5.3.2-dev2",
|
|
57
57
|
"@luvio/service-aura-network": "5.3.2-dev2",
|
|
58
58
|
"@luvio/service-cache-inclusion-policy": "5.3.2-dev2",
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
"@luvio/service-subscription": "5.3.2-dev2",
|
|
65
65
|
"@luvio/service-type-registry": "5.3.2-dev2",
|
|
66
66
|
"@luvio/utils": "5.3.2-dev2",
|
|
67
|
-
"@salesforce/lds-adapters-uiapi-lex": "^1.309.0-
|
|
67
|
+
"@salesforce/lds-adapters-uiapi-lex": "^1.309.0-dev16"
|
|
68
68
|
},
|
|
69
69
|
"luvioBundlesize": [
|
|
70
70
|
{
|
|
71
71
|
"path": "./dist/ldsEngineCreator.js",
|
|
72
72
|
"maxSize": {
|
|
73
|
-
"none": "
|
|
73
|
+
"none": "178 kB",
|
|
74
74
|
"min": "75 kB",
|
|
75
75
|
"compressed": "32 kB"
|
|
76
76
|
}
|