@salesforce/lds-default-luvio 0.1.0-dev1
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/LICENSE.txt +82 -0
- package/dist/es/es2018/main.js +138 -0
- package/dist/es/es2018/types/src/main.d.ts +30 -0
- package/dist/es/es2018/types/src/registry.d.ts +58 -0
- package/dist/es/es2018/types/src/sfdc.d.ts +2 -0
- package/package.json +73 -0
- package/sfdc/ldsEngine.d.ts +1 -0
- package/sfdc/ldsEngine.js +187 -0
- package/sfdc/ldsEngineNoAura.d.ts +1 -0
- package/sfdc/ldsEngineNoAura.js +144 -0
- package/sfdc/types/main.d.ts +30 -0
- package/sfdc/types/registry.d.ts +58 -0
- package/sfdc/types/sfdc.d.ts +2 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2022, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* ATTENTION!
|
|
9
|
+
* THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
|
|
10
|
+
* If you would like to contribute to LDS, please follow the steps outlined in the git repo.
|
|
11
|
+
* Any changes made to this file in p4 will be automatically overwritten.
|
|
12
|
+
* *******************************************************************************************
|
|
13
|
+
*/
|
|
14
|
+
/* proxy-compat-disable */
|
|
15
|
+
import { Luvio, Environment, InMemoryStore } from '@luvio/engine';
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
19
|
+
* All rights reserved.
|
|
20
|
+
* For full license text, see the LICENSE.txt file
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Callbacks to be invoked when registrations happen,
|
|
24
|
+
*/
|
|
25
|
+
const callbacks$1 = [];
|
|
26
|
+
/**
|
|
27
|
+
* Registrations that have already occurred.
|
|
28
|
+
*
|
|
29
|
+
* Note that Registrations are maintained as a list rather than a map to allow
|
|
30
|
+
* the same id to be registered multiple times with potentially different
|
|
31
|
+
* data.
|
|
32
|
+
*/
|
|
33
|
+
const registrations = [];
|
|
34
|
+
/**
|
|
35
|
+
* Invokes callback for each Registration, both past & future. That is, callback
|
|
36
|
+
* will be invoked exactly as many times as register() is called.
|
|
37
|
+
*
|
|
38
|
+
* Note that Registration ids are not guaranteed to be unique. The meaning of
|
|
39
|
+
* multiple Registrations with the same id is determined by the caller(s) of
|
|
40
|
+
* register().
|
|
41
|
+
*/
|
|
42
|
+
function forEachRegistration(callback) {
|
|
43
|
+
callbacks$1.push(callback);
|
|
44
|
+
registrations.forEach((r) => callback(r));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Invokes callback when the specified id is registered.
|
|
48
|
+
*
|
|
49
|
+
* Note that callback may be invoked:
|
|
50
|
+
*
|
|
51
|
+
* - multiple times if multiple calls to register() specify the id
|
|
52
|
+
* - never if the specified id is never registered
|
|
53
|
+
*/
|
|
54
|
+
function withRegistration(id, callback) {
|
|
55
|
+
forEachRegistration((r) => {
|
|
56
|
+
if (r.id === id) {
|
|
57
|
+
callback(r);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Register an id and associated data.
|
|
63
|
+
*
|
|
64
|
+
* Callers of register() should make types available that include:
|
|
65
|
+
*
|
|
66
|
+
* - the id they will register
|
|
67
|
+
* - definitions for any additional properties on their Registration objects
|
|
68
|
+
*
|
|
69
|
+
* For example:
|
|
70
|
+
*
|
|
71
|
+
* export type MyRegistration = {
|
|
72
|
+
* id: 'myRegistrationId',
|
|
73
|
+
*
|
|
74
|
+
* // some value that others might need
|
|
75
|
+
* myValue: string,
|
|
76
|
+
*
|
|
77
|
+
* // some function that others might want to call
|
|
78
|
+
* myFunction: () => void,
|
|
79
|
+
* };
|
|
80
|
+
* register({ id: 'myRegistrationId', myValue: 'foo', myFunction: () => {} } as MyRegistration);
|
|
81
|
+
*
|
|
82
|
+
* The registry itself does not dictate the format of ids nor attempt to coordinate
|
|
83
|
+
* uniqueness of id values.
|
|
84
|
+
*
|
|
85
|
+
* The same id can be registered multiple times with different Registration
|
|
86
|
+
* objects.
|
|
87
|
+
*/
|
|
88
|
+
function register(r) {
|
|
89
|
+
registrations.push(r);
|
|
90
|
+
callbacks$1.forEach((callback) => callback(r));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
95
|
+
* All rights reserved.
|
|
96
|
+
* For full license text, see the LICENSE.txt file
|
|
97
|
+
*/
|
|
98
|
+
// most recently set default Luvio instance
|
|
99
|
+
let defaultLuvio;
|
|
100
|
+
// callbacks to be invoked when default luvio instance is set/changed
|
|
101
|
+
let callbacks = [];
|
|
102
|
+
/**
|
|
103
|
+
* Constructs/sets the default Luvio instance. Any previously-set default luvio instance
|
|
104
|
+
* is overwritten.
|
|
105
|
+
*/
|
|
106
|
+
function setDefaultLuvio(params) {
|
|
107
|
+
const newLuvio = 'luvio' in params
|
|
108
|
+
? params.luvio
|
|
109
|
+
: 'environment' in params
|
|
110
|
+
? new Luvio(params.environment)
|
|
111
|
+
: 'networkAdapter' in params
|
|
112
|
+
? new Luvio(new Environment(params.store || new InMemoryStore(), params.networkAdapter))
|
|
113
|
+
: undefined;
|
|
114
|
+
if (newLuvio === undefined) {
|
|
115
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
116
|
+
throw new Error('unable to construct default Luvio instance from supplied parameters');
|
|
117
|
+
}
|
|
118
|
+
defaultLuvio = newLuvio;
|
|
119
|
+
// inform observers
|
|
120
|
+
for (let i = 0; i < callbacks.length; ++i) {
|
|
121
|
+
callbacks[i](defaultLuvio);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Registers a callback to be invoked with the default Luvio instance. Note that the
|
|
126
|
+
* callback may be invoked multiple times if the default Luvio changes.
|
|
127
|
+
*
|
|
128
|
+
* @param callback callback to be invoked with default Luvio instance
|
|
129
|
+
*/
|
|
130
|
+
function withDefaultLuvio(callback) {
|
|
131
|
+
if (defaultLuvio) {
|
|
132
|
+
callback(defaultLuvio);
|
|
133
|
+
}
|
|
134
|
+
callbacks.push(callback);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { forEachRegistration, register, setDefaultLuvio, withDefaultLuvio, withRegistration };
|
|
138
|
+
// version: 0.1.0-dev1-54c03dd38c
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { NetworkAdapter } from '@luvio/engine';
|
|
2
|
+
import { Environment, Luvio, InMemoryStore } from '@luvio/engine';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters accepted by setDefaultLuvio.
|
|
5
|
+
*/
|
|
6
|
+
export type SetDefaultLuvioParameters = {
|
|
7
|
+
luvio: Luvio;
|
|
8
|
+
} | {
|
|
9
|
+
environment: Environment;
|
|
10
|
+
} | {
|
|
11
|
+
store?: InMemoryStore;
|
|
12
|
+
networkAdapter: NetworkAdapter;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Callback used to inform interested parties that a new default Luvio has been set.
|
|
16
|
+
*/
|
|
17
|
+
export type Callback = (luvio: Luvio) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Constructs/sets the default Luvio instance. Any previously-set default luvio instance
|
|
20
|
+
* is overwritten.
|
|
21
|
+
*/
|
|
22
|
+
export declare function setDefaultLuvio(params: SetDefaultLuvioParameters): void;
|
|
23
|
+
/**
|
|
24
|
+
* Registers a callback to be invoked with the default Luvio instance. Note that the
|
|
25
|
+
* callback may be invoked multiple times if the default Luvio changes.
|
|
26
|
+
*
|
|
27
|
+
* @param callback callback to be invoked with default Luvio instance
|
|
28
|
+
*/
|
|
29
|
+
export declare function withDefaultLuvio(callback: Callback): void;
|
|
30
|
+
export * from './registry';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration information. Actual Registration objects will typically contain
|
|
3
|
+
* additional fields. Id values and additional fields in the Registration should
|
|
4
|
+
* be specified in types exported by the code that calls register().
|
|
5
|
+
*/
|
|
6
|
+
export type Registration = {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Callback used to inform interested parties that something has been registered.
|
|
11
|
+
*/
|
|
12
|
+
export type RegistrationCallback<R = Registration> = (registration: R) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Invokes callback for each Registration, both past & future. That is, callback
|
|
15
|
+
* will be invoked exactly as many times as register() is called.
|
|
16
|
+
*
|
|
17
|
+
* Note that Registration ids are not guaranteed to be unique. The meaning of
|
|
18
|
+
* multiple Registrations with the same id is determined by the caller(s) of
|
|
19
|
+
* register().
|
|
20
|
+
*/
|
|
21
|
+
export declare function forEachRegistration(callback: RegistrationCallback): void;
|
|
22
|
+
/**
|
|
23
|
+
* Invokes callback when the specified id is registered.
|
|
24
|
+
*
|
|
25
|
+
* Note that callback may be invoked:
|
|
26
|
+
*
|
|
27
|
+
* - multiple times if multiple calls to register() specify the id
|
|
28
|
+
* - never if the specified id is never registered
|
|
29
|
+
*/
|
|
30
|
+
export declare function withRegistration<R extends Registration>(id: R['id'], callback: RegistrationCallback<R>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Register an id and associated data.
|
|
33
|
+
*
|
|
34
|
+
* Callers of register() should make types available that include:
|
|
35
|
+
*
|
|
36
|
+
* - the id they will register
|
|
37
|
+
* - definitions for any additional properties on their Registration objects
|
|
38
|
+
*
|
|
39
|
+
* For example:
|
|
40
|
+
*
|
|
41
|
+
* export type MyRegistration = {
|
|
42
|
+
* id: 'myRegistrationId',
|
|
43
|
+
*
|
|
44
|
+
* // some value that others might need
|
|
45
|
+
* myValue: string,
|
|
46
|
+
*
|
|
47
|
+
* // some function that others might want to call
|
|
48
|
+
* myFunction: () => void,
|
|
49
|
+
* };
|
|
50
|
+
* register({ id: 'myRegistrationId', myValue: 'foo', myFunction: () => {} } as MyRegistration);
|
|
51
|
+
*
|
|
52
|
+
* The registry itself does not dictate the format of ids nor attempt to coordinate
|
|
53
|
+
* uniqueness of id values.
|
|
54
|
+
*
|
|
55
|
+
* The same id can be registered multiple times with different Registration
|
|
56
|
+
* objects.
|
|
57
|
+
*/
|
|
58
|
+
export declare function register<R extends Registration = Registration>(r: R): void;
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/lds-default-luvio",
|
|
3
|
+
"version": "0.1.0-dev1",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
+
"description": "rendezvous point for producers & consumers of the default luvio instance",
|
|
6
|
+
"bugs": "This software is provided as-is with no support provided.",
|
|
7
|
+
"main": "dist/es/es2018/main.js",
|
|
8
|
+
"module": "dist/es/es2018/main.js",
|
|
9
|
+
"types": "dist/es/es2018/types/src/main.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"LICENSE.txt",
|
|
13
|
+
"sfdc"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/es/es2018/types/src/main.d.ts",
|
|
18
|
+
"import": "./dist/es/es2018/main.js",
|
|
19
|
+
"require": "./dist/es/es2018/main.js"
|
|
20
|
+
},
|
|
21
|
+
"./sfdc": {
|
|
22
|
+
"types": "./sfdc/ldsEngine.d.ts",
|
|
23
|
+
"import": "./sfdc/ldsEngine.js",
|
|
24
|
+
"default": "./sfdc/ldsEngine.js"
|
|
25
|
+
},
|
|
26
|
+
"./sfdcNoAura": {
|
|
27
|
+
"types": "./sfdc/ldsEngineNoAura.d.ts",
|
|
28
|
+
"import": "./sfdc/ldsEngineNoAura.js",
|
|
29
|
+
"default": "./sfdc/ldsEngineNoAura.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"sfdc": {
|
|
33
|
+
"srcOverride": "sfdc/ldsEngine.js",
|
|
34
|
+
"path": "forcelds/ldsEngine/",
|
|
35
|
+
"publishedFileName": "ldsEngine.js",
|
|
36
|
+
"overrides": {
|
|
37
|
+
"outputModuleName": "ldsEngine",
|
|
38
|
+
"artifacts": {
|
|
39
|
+
"ldsEngineNoAura.js": {
|
|
40
|
+
"output": {
|
|
41
|
+
"path": "ui-bridge-components/modules/native/ldsEngineMobile/ldsEngineMobile.js"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"prepare": "yarn build",
|
|
49
|
+
"build": "rollup --bundleConfigAsCjs --config rollup.config.js",
|
|
50
|
+
"clean": "rm -rf dist sfdc",
|
|
51
|
+
"test:unit": "jest",
|
|
52
|
+
"test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand",
|
|
53
|
+
"release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-default-luvio"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@luvio/engine": "0.158.7"
|
|
57
|
+
},
|
|
58
|
+
"nx": {
|
|
59
|
+
"targets": {
|
|
60
|
+
"build": {
|
|
61
|
+
"outputs": [
|
|
62
|
+
"{projectRoot}/dist",
|
|
63
|
+
"{projectRoot}/sfdc"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"build:raml": {
|
|
67
|
+
"outputs": [
|
|
68
|
+
"{projectRoot}/src/generated"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/sfdc';
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
9
|
+
* All rights reserved.
|
|
10
|
+
* For full license text, see the LICENSE.txt file
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* ATTENTION!
|
|
15
|
+
* THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
|
|
16
|
+
* If you would like to contribute to LDS, please follow the steps outlined in the git repo.
|
|
17
|
+
* Any changes made to this file in p4 will be automatically overwritten.
|
|
18
|
+
* *******************************************************************************************
|
|
19
|
+
*/
|
|
20
|
+
/* proxy-compat-disable */
|
|
21
|
+
import { Luvio, Environment, InMemoryStore } from 'force/luvioEngine';
|
|
22
|
+
export { Environment, GraphNode, HttpStatusCode, InMemoryStore, Luvio, Reader, StoreResolveResultState, adapterToNetworkPriority, coerceAdapterRequestContext, createCustomAdapterEventEmitter, emitAdapterEvent } from 'force/luvioEngine';
|
|
23
|
+
import networkAdapter from 'force/ldsNetwork';
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
27
|
+
* All rights reserved.
|
|
28
|
+
* For full license text, see the LICENSE.txt file
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Callbacks to be invoked when registrations happen,
|
|
32
|
+
*/
|
|
33
|
+
const callbacks$1 = [];
|
|
34
|
+
/**
|
|
35
|
+
* Registrations that have already occurred.
|
|
36
|
+
*
|
|
37
|
+
* Note that Registrations are maintained as a list rather than a map to allow
|
|
38
|
+
* the same id to be registered multiple times with potentially different
|
|
39
|
+
* data.
|
|
40
|
+
*/
|
|
41
|
+
const registrations = [];
|
|
42
|
+
/**
|
|
43
|
+
* Invokes callback for each Registration, both past & future. That is, callback
|
|
44
|
+
* will be invoked exactly as many times as register() is called.
|
|
45
|
+
*
|
|
46
|
+
* Note that Registration ids are not guaranteed to be unique. The meaning of
|
|
47
|
+
* multiple Registrations with the same id is determined by the caller(s) of
|
|
48
|
+
* register().
|
|
49
|
+
*/
|
|
50
|
+
function forEachRegistration(callback) {
|
|
51
|
+
callbacks$1.push(callback);
|
|
52
|
+
registrations.forEach((r) => callback(r));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Invokes callback when the specified id is registered.
|
|
56
|
+
*
|
|
57
|
+
* Note that callback may be invoked:
|
|
58
|
+
*
|
|
59
|
+
* - multiple times if multiple calls to register() specify the id
|
|
60
|
+
* - never if the specified id is never registered
|
|
61
|
+
*/
|
|
62
|
+
function withRegistration(id, callback) {
|
|
63
|
+
forEachRegistration((r) => {
|
|
64
|
+
if (r.id === id) {
|
|
65
|
+
callback(r);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Register an id and associated data.
|
|
71
|
+
*
|
|
72
|
+
* Callers of register() should make types available that include:
|
|
73
|
+
*
|
|
74
|
+
* - the id they will register
|
|
75
|
+
* - definitions for any additional properties on their Registration objects
|
|
76
|
+
*
|
|
77
|
+
* For example:
|
|
78
|
+
*
|
|
79
|
+
* export type MyRegistration = {
|
|
80
|
+
* id: 'myRegistrationId',
|
|
81
|
+
*
|
|
82
|
+
* // some value that others might need
|
|
83
|
+
* myValue: string,
|
|
84
|
+
*
|
|
85
|
+
* // some function that others might want to call
|
|
86
|
+
* myFunction: () => void,
|
|
87
|
+
* };
|
|
88
|
+
* register({ id: 'myRegistrationId', myValue: 'foo', myFunction: () => {} } as MyRegistration);
|
|
89
|
+
*
|
|
90
|
+
* The registry itself does not dictate the format of ids nor attempt to coordinate
|
|
91
|
+
* uniqueness of id values.
|
|
92
|
+
*
|
|
93
|
+
* The same id can be registered multiple times with different Registration
|
|
94
|
+
* objects.
|
|
95
|
+
*/
|
|
96
|
+
function register(r) {
|
|
97
|
+
registrations.push(r);
|
|
98
|
+
callbacks$1.forEach((callback) => callback(r));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
103
|
+
* All rights reserved.
|
|
104
|
+
* For full license text, see the LICENSE.txt file
|
|
105
|
+
*/
|
|
106
|
+
// most recently set default Luvio instance
|
|
107
|
+
let defaultLuvio;
|
|
108
|
+
// callbacks to be invoked when default luvio instance is set/changed
|
|
109
|
+
let callbacks = [];
|
|
110
|
+
/**
|
|
111
|
+
* Constructs/sets the default Luvio instance. Any previously-set default luvio instance
|
|
112
|
+
* is overwritten.
|
|
113
|
+
*/
|
|
114
|
+
function setDefaultLuvio(params) {
|
|
115
|
+
const newLuvio = 'luvio' in params
|
|
116
|
+
? params.luvio
|
|
117
|
+
: 'environment' in params
|
|
118
|
+
? new Luvio(params.environment)
|
|
119
|
+
: 'networkAdapter' in params
|
|
120
|
+
? new Luvio(new Environment(params.store || new InMemoryStore(), params.networkAdapter))
|
|
121
|
+
: undefined;
|
|
122
|
+
if (newLuvio === undefined) {
|
|
123
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
124
|
+
throw new Error('unable to construct default Luvio instance from supplied parameters');
|
|
125
|
+
}
|
|
126
|
+
defaultLuvio = newLuvio;
|
|
127
|
+
// inform observers
|
|
128
|
+
for (let i = 0; i < callbacks.length; ++i) {
|
|
129
|
+
callbacks[i](defaultLuvio);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Registers a callback to be invoked with the default Luvio instance. Note that the
|
|
134
|
+
* callback may be invoked multiple times if the default Luvio changes.
|
|
135
|
+
*
|
|
136
|
+
* @param callback callback to be invoked with default Luvio instance
|
|
137
|
+
*/
|
|
138
|
+
function withDefaultLuvio(callback) {
|
|
139
|
+
if (defaultLuvio) {
|
|
140
|
+
callback(defaultLuvio);
|
|
141
|
+
}
|
|
142
|
+
callbacks.push(callback);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/*
|
|
146
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
147
|
+
* All rights reserved.
|
|
148
|
+
* For full license text, see the LICENSE.txt file
|
|
149
|
+
*/
|
|
150
|
+
// bundling of lds-default-luvio and @luvio/engine for core
|
|
151
|
+
// The code in lds-runtime-aura (force/ldsEngineCreator) depends on Aura module
|
|
152
|
+
// services to invoke its LDS initialization logic. Unfortunately, Aura component
|
|
153
|
+
// tests do not support module services and have no analogous function. The net
|
|
154
|
+
// result is that LDS is never initialized in the iframe that loads the Aura
|
|
155
|
+
// component test & any attempts to create an LWC component that uses an LDS
|
|
156
|
+
// adapter fail because the wire adapter constructors are undefined (W-9233247).
|
|
157
|
+
//
|
|
158
|
+
// The code below is the least offensive workaround we could come up with. When
|
|
159
|
+
// this code (force/ldsEngine) is loaded via static imports in an Aura component
|
|
160
|
+
// test iframe, it will perform a minimal initialization of LDS that allows
|
|
161
|
+
// the test to run and access data on the server. The instrumentation and
|
|
162
|
+
// configuration initialization steps from lds-runtime-aura are skipped to
|
|
163
|
+
// keep the logic simpler & faster.
|
|
164
|
+
//
|
|
165
|
+
// For future reference, here are the values we see from getApp():
|
|
166
|
+
//
|
|
167
|
+
// - for a regular .app, the name of the app, e.g. "one:one"
|
|
168
|
+
// - for the top-level iframe of a .app loaded in JSTEST mode, "aurajstest:jstest"
|
|
169
|
+
// - for the top-level iframe of a .cmp loaded in JSTEST mode, undefined
|
|
170
|
+
// - for a test iframe of a .cmp or .app test loaded via
|
|
171
|
+
// /auratest/test.app?testName=..&aura.mode=AUTOJSTEST, undefined
|
|
172
|
+
// - for a test iframe loaded via /aura?... (no clue where/how these are
|
|
173
|
+
// generated), undefined
|
|
174
|
+
if (typeof $A !== 'undefined' &&
|
|
175
|
+
$A.getContext().getMode().indexOf('AUTOJSTEST') > -1 &&
|
|
176
|
+
$A.getContext().getApp() === undefined) {
|
|
177
|
+
const storeOptions = {
|
|
178
|
+
scheduler: () => { },
|
|
179
|
+
};
|
|
180
|
+
const store = new InMemoryStore(storeOptions);
|
|
181
|
+
const environment = new Environment(store, networkAdapter);
|
|
182
|
+
const luvio = new Luvio(environment);
|
|
183
|
+
setDefaultLuvio({ luvio });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { forEachRegistration, register, setDefaultLuvio, withDefaultLuvio, withRegistration };
|
|
187
|
+
// version: 0.1.0-dev1-54c03dd38c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/main';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
9
|
+
* All rights reserved.
|
|
10
|
+
* For full license text, see the LICENSE.txt file
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* ATTENTION!
|
|
15
|
+
* THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
|
|
16
|
+
* If you would like to contribute to LDS, please follow the steps outlined in the git repo.
|
|
17
|
+
* Any changes made to this file in p4 will be automatically overwritten.
|
|
18
|
+
* *******************************************************************************************
|
|
19
|
+
*/
|
|
20
|
+
/* proxy-compat-disable */
|
|
21
|
+
import { Luvio, Environment, InMemoryStore } from 'force/luvioEngine';
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
25
|
+
* All rights reserved.
|
|
26
|
+
* For full license text, see the LICENSE.txt file
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Callbacks to be invoked when registrations happen,
|
|
30
|
+
*/
|
|
31
|
+
const callbacks$1 = [];
|
|
32
|
+
/**
|
|
33
|
+
* Registrations that have already occurred.
|
|
34
|
+
*
|
|
35
|
+
* Note that Registrations are maintained as a list rather than a map to allow
|
|
36
|
+
* the same id to be registered multiple times with potentially different
|
|
37
|
+
* data.
|
|
38
|
+
*/
|
|
39
|
+
const registrations = [];
|
|
40
|
+
/**
|
|
41
|
+
* Invokes callback for each Registration, both past & future. That is, callback
|
|
42
|
+
* will be invoked exactly as many times as register() is called.
|
|
43
|
+
*
|
|
44
|
+
* Note that Registration ids are not guaranteed to be unique. The meaning of
|
|
45
|
+
* multiple Registrations with the same id is determined by the caller(s) of
|
|
46
|
+
* register().
|
|
47
|
+
*/
|
|
48
|
+
function forEachRegistration(callback) {
|
|
49
|
+
callbacks$1.push(callback);
|
|
50
|
+
registrations.forEach((r) => callback(r));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Invokes callback when the specified id is registered.
|
|
54
|
+
*
|
|
55
|
+
* Note that callback may be invoked:
|
|
56
|
+
*
|
|
57
|
+
* - multiple times if multiple calls to register() specify the id
|
|
58
|
+
* - never if the specified id is never registered
|
|
59
|
+
*/
|
|
60
|
+
function withRegistration(id, callback) {
|
|
61
|
+
forEachRegistration((r) => {
|
|
62
|
+
if (r.id === id) {
|
|
63
|
+
callback(r);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Register an id and associated data.
|
|
69
|
+
*
|
|
70
|
+
* Callers of register() should make types available that include:
|
|
71
|
+
*
|
|
72
|
+
* - the id they will register
|
|
73
|
+
* - definitions for any additional properties on their Registration objects
|
|
74
|
+
*
|
|
75
|
+
* For example:
|
|
76
|
+
*
|
|
77
|
+
* export type MyRegistration = {
|
|
78
|
+
* id: 'myRegistrationId',
|
|
79
|
+
*
|
|
80
|
+
* // some value that others might need
|
|
81
|
+
* myValue: string,
|
|
82
|
+
*
|
|
83
|
+
* // some function that others might want to call
|
|
84
|
+
* myFunction: () => void,
|
|
85
|
+
* };
|
|
86
|
+
* register({ id: 'myRegistrationId', myValue: 'foo', myFunction: () => {} } as MyRegistration);
|
|
87
|
+
*
|
|
88
|
+
* The registry itself does not dictate the format of ids nor attempt to coordinate
|
|
89
|
+
* uniqueness of id values.
|
|
90
|
+
*
|
|
91
|
+
* The same id can be registered multiple times with different Registration
|
|
92
|
+
* objects.
|
|
93
|
+
*/
|
|
94
|
+
function register(r) {
|
|
95
|
+
registrations.push(r);
|
|
96
|
+
callbacks$1.forEach((callback) => callback(r));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
101
|
+
* All rights reserved.
|
|
102
|
+
* For full license text, see the LICENSE.txt file
|
|
103
|
+
*/
|
|
104
|
+
// most recently set default Luvio instance
|
|
105
|
+
let defaultLuvio;
|
|
106
|
+
// callbacks to be invoked when default luvio instance is set/changed
|
|
107
|
+
let callbacks = [];
|
|
108
|
+
/**
|
|
109
|
+
* Constructs/sets the default Luvio instance. Any previously-set default luvio instance
|
|
110
|
+
* is overwritten.
|
|
111
|
+
*/
|
|
112
|
+
function setDefaultLuvio(params) {
|
|
113
|
+
const newLuvio = 'luvio' in params
|
|
114
|
+
? params.luvio
|
|
115
|
+
: 'environment' in params
|
|
116
|
+
? new Luvio(params.environment)
|
|
117
|
+
: 'networkAdapter' in params
|
|
118
|
+
? new Luvio(new Environment(params.store || new InMemoryStore(), params.networkAdapter))
|
|
119
|
+
: undefined;
|
|
120
|
+
if (newLuvio === undefined) {
|
|
121
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
122
|
+
throw new Error('unable to construct default Luvio instance from supplied parameters');
|
|
123
|
+
}
|
|
124
|
+
defaultLuvio = newLuvio;
|
|
125
|
+
// inform observers
|
|
126
|
+
for (let i = 0; i < callbacks.length; ++i) {
|
|
127
|
+
callbacks[i](defaultLuvio);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Registers a callback to be invoked with the default Luvio instance. Note that the
|
|
132
|
+
* callback may be invoked multiple times if the default Luvio changes.
|
|
133
|
+
*
|
|
134
|
+
* @param callback callback to be invoked with default Luvio instance
|
|
135
|
+
*/
|
|
136
|
+
function withDefaultLuvio(callback) {
|
|
137
|
+
if (defaultLuvio) {
|
|
138
|
+
callback(defaultLuvio);
|
|
139
|
+
}
|
|
140
|
+
callbacks.push(callback);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { forEachRegistration, register, setDefaultLuvio, withDefaultLuvio, withRegistration };
|
|
144
|
+
// version: 0.1.0-dev1-54c03dd38c
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { NetworkAdapter } from '@luvio/engine';
|
|
2
|
+
import { Environment, Luvio, InMemoryStore } from '@luvio/engine';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters accepted by setDefaultLuvio.
|
|
5
|
+
*/
|
|
6
|
+
export type SetDefaultLuvioParameters = {
|
|
7
|
+
luvio: Luvio;
|
|
8
|
+
} | {
|
|
9
|
+
environment: Environment;
|
|
10
|
+
} | {
|
|
11
|
+
store?: InMemoryStore;
|
|
12
|
+
networkAdapter: NetworkAdapter;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Callback used to inform interested parties that a new default Luvio has been set.
|
|
16
|
+
*/
|
|
17
|
+
export type Callback = (luvio: Luvio) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Constructs/sets the default Luvio instance. Any previously-set default luvio instance
|
|
20
|
+
* is overwritten.
|
|
21
|
+
*/
|
|
22
|
+
export declare function setDefaultLuvio(params: SetDefaultLuvioParameters): void;
|
|
23
|
+
/**
|
|
24
|
+
* Registers a callback to be invoked with the default Luvio instance. Note that the
|
|
25
|
+
* callback may be invoked multiple times if the default Luvio changes.
|
|
26
|
+
*
|
|
27
|
+
* @param callback callback to be invoked with default Luvio instance
|
|
28
|
+
*/
|
|
29
|
+
export declare function withDefaultLuvio(callback: Callback): void;
|
|
30
|
+
export * from './registry';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration information. Actual Registration objects will typically contain
|
|
3
|
+
* additional fields. Id values and additional fields in the Registration should
|
|
4
|
+
* be specified in types exported by the code that calls register().
|
|
5
|
+
*/
|
|
6
|
+
export type Registration = {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Callback used to inform interested parties that something has been registered.
|
|
11
|
+
*/
|
|
12
|
+
export type RegistrationCallback<R = Registration> = (registration: R) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Invokes callback for each Registration, both past & future. That is, callback
|
|
15
|
+
* will be invoked exactly as many times as register() is called.
|
|
16
|
+
*
|
|
17
|
+
* Note that Registration ids are not guaranteed to be unique. The meaning of
|
|
18
|
+
* multiple Registrations with the same id is determined by the caller(s) of
|
|
19
|
+
* register().
|
|
20
|
+
*/
|
|
21
|
+
export declare function forEachRegistration(callback: RegistrationCallback): void;
|
|
22
|
+
/**
|
|
23
|
+
* Invokes callback when the specified id is registered.
|
|
24
|
+
*
|
|
25
|
+
* Note that callback may be invoked:
|
|
26
|
+
*
|
|
27
|
+
* - multiple times if multiple calls to register() specify the id
|
|
28
|
+
* - never if the specified id is never registered
|
|
29
|
+
*/
|
|
30
|
+
export declare function withRegistration<R extends Registration>(id: R['id'], callback: RegistrationCallback<R>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Register an id and associated data.
|
|
33
|
+
*
|
|
34
|
+
* Callers of register() should make types available that include:
|
|
35
|
+
*
|
|
36
|
+
* - the id they will register
|
|
37
|
+
* - definitions for any additional properties on their Registration objects
|
|
38
|
+
*
|
|
39
|
+
* For example:
|
|
40
|
+
*
|
|
41
|
+
* export type MyRegistration = {
|
|
42
|
+
* id: 'myRegistrationId',
|
|
43
|
+
*
|
|
44
|
+
* // some value that others might need
|
|
45
|
+
* myValue: string,
|
|
46
|
+
*
|
|
47
|
+
* // some function that others might want to call
|
|
48
|
+
* myFunction: () => void,
|
|
49
|
+
* };
|
|
50
|
+
* register({ id: 'myRegistrationId', myValue: 'foo', myFunction: () => {} } as MyRegistration);
|
|
51
|
+
*
|
|
52
|
+
* The registry itself does not dictate the format of ids nor attempt to coordinate
|
|
53
|
+
* uniqueness of id values.
|
|
54
|
+
*
|
|
55
|
+
* The same id can be registered multiple times with different Registration
|
|
56
|
+
* objects.
|
|
57
|
+
*/
|
|
58
|
+
export declare function register<R extends Registration = Registration>(r: R): void;
|