lwc 4.0.0-alpha.0 → 4.0.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/index.d.ts +52 -20
- package/package.json +17 -17
package/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ declare module 'lwc' {
|
|
|
38
38
|
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
|
|
39
39
|
getElementsByTagName(tagNameOrWildCard: string): HTMLCollectionOf<Element>;
|
|
40
40
|
getElementsByClassName(names: string): HTMLCollectionOf<Element>;
|
|
41
|
+
attachInternals(): ElementInternals;
|
|
41
42
|
readonly tagName: string;
|
|
42
43
|
readonly classList: DOMTokenList;
|
|
43
44
|
|
|
@@ -189,44 +190,75 @@ declare module 'lwc' {
|
|
|
189
190
|
*/
|
|
190
191
|
export const track: PropertyDecorator;
|
|
191
192
|
|
|
193
|
+
type StringKeyedRecord = Record<string, any>;
|
|
192
194
|
/**
|
|
193
195
|
* Decorator factory to wire a property or method to a wire adapter data source
|
|
196
|
+
* Use generic types to allow type checking for wire adapters
|
|
197
|
+
* Default all the generic types to any to maintain backward compatibility
|
|
198
|
+
*
|
|
199
|
+
* For example, a wire adapter 'getRecord' can have the following type definition
|
|
200
|
+
*
|
|
201
|
+
* export const getRecord: WireAdapterConstructor<GetRecordConfig, RecordRepresentation>;
|
|
202
|
+
*
|
|
203
|
+
* in which 'GetRecordConfig' is the adapter config object type and 'RecordRepresentation'
|
|
204
|
+
* is the returned value.
|
|
205
|
+
*
|
|
194
206
|
* @param adapter the adapter used to provision data
|
|
195
207
|
* @param config configuration object for the adapter
|
|
196
208
|
*/
|
|
197
|
-
export function wire
|
|
198
|
-
|
|
199
|
-
|
|
209
|
+
export function wire<
|
|
210
|
+
Config extends StringKeyedRecord,
|
|
211
|
+
Value,
|
|
212
|
+
Context extends StringKeyedRecord = StringKeyedRecord
|
|
213
|
+
>(
|
|
214
|
+
adapter:
|
|
215
|
+
| WireAdapterConstructor<Config, Value, Context>
|
|
216
|
+
| LegacyWireAdapterConstructor<Config, Value>,
|
|
217
|
+
config?: WireConfigValue<Config>
|
|
200
218
|
): PropertyDecorator;
|
|
201
219
|
|
|
202
|
-
type LegacyWireAdapterConstructor = (config?:
|
|
203
|
-
type WireConfigValue =
|
|
204
|
-
|
|
220
|
+
type LegacyWireAdapterConstructor<Config, Value> = (config?: Config) => Value;
|
|
221
|
+
type WireConfigValue<Config extends StringKeyedRecord = StringKeyedRecord> = {
|
|
222
|
+
// wire reactive variables are strings prefixed with '$' so the config value can just be string
|
|
223
|
+
[K in keyof Config]: Config[K] | string;
|
|
224
|
+
};
|
|
225
|
+
type ContextValue<Context extends StringKeyedRecord = StringKeyedRecord> = Context;
|
|
205
226
|
|
|
206
|
-
interface WireAdapter {
|
|
207
|
-
update(config: WireConfigValue
|
|
227
|
+
interface WireAdapter<Config extends StringKeyedRecord, Context extends StringKeyedRecord> {
|
|
228
|
+
update(config: WireConfigValue<Config>, context?: ContextValue<Context>): void;
|
|
208
229
|
connect(): void;
|
|
209
230
|
disconnect(): void;
|
|
210
231
|
}
|
|
211
232
|
|
|
212
|
-
type WireDataCallback = (value:
|
|
233
|
+
type WireDataCallback<Value> = (value: Value) => void;
|
|
213
234
|
type WireAdapterSchemaValue = 'optional' | 'required';
|
|
214
235
|
|
|
215
|
-
interface ContextConsumer {
|
|
216
|
-
provide(newContext: ContextValue): void;
|
|
236
|
+
interface ContextConsumer<Context extends StringKeyedRecord> {
|
|
237
|
+
provide(newContext: ContextValue<Context>): void;
|
|
217
238
|
}
|
|
218
239
|
|
|
219
|
-
interface ContextProviderOptions {
|
|
220
|
-
consumerConnectedCallback: (consumer: ContextConsumer) => void;
|
|
221
|
-
consumerDisconnectedCallback?: (consumer: ContextConsumer) => void;
|
|
240
|
+
interface ContextProviderOptions<Context extends StringKeyedRecord> {
|
|
241
|
+
consumerConnectedCallback: (consumer: ContextConsumer<Context>) => void;
|
|
242
|
+
consumerDisconnectedCallback?: (consumer: ContextConsumer<Context>) => void;
|
|
222
243
|
}
|
|
223
244
|
|
|
224
|
-
interface WireAdapterConstructor
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
245
|
+
interface WireAdapterConstructor<
|
|
246
|
+
Config extends StringKeyedRecord,
|
|
247
|
+
Value,
|
|
248
|
+
Context extends StringKeyedRecord
|
|
249
|
+
> {
|
|
250
|
+
new (callback: WireDataCallback<Value>): WireAdapter<Config, Context>;
|
|
251
|
+
configSchema?: Record<keyof Config, WireAdapterSchemaValue>;
|
|
252
|
+
contextSchema?: Record<keyof Context, WireAdapterSchemaValue>;
|
|
228
253
|
}
|
|
229
254
|
|
|
230
|
-
type Contextualizer = (
|
|
231
|
-
|
|
255
|
+
type Contextualizer<Context extends StringKeyedRecord> = (
|
|
256
|
+
elm: EventTarget,
|
|
257
|
+
options: ContextProviderOptions<Context>
|
|
258
|
+
) => void;
|
|
259
|
+
export function createContextProvider<
|
|
260
|
+
Config extends StringKeyedRecord,
|
|
261
|
+
Value,
|
|
262
|
+
Context extends StringKeyedRecord = StringKeyedRecord
|
|
263
|
+
>(config: WireAdapterConstructor<Config, Value, Context>): Contextualizer<Context>;
|
|
232
264
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lwc",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Lightning Web Components (LWC)",
|
|
5
5
|
"homepage": "https://lwc.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -20,21 +20,21 @@
|
|
|
20
20
|
"*.d.ts"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lwc/aria-reflection": "4.0.0
|
|
24
|
-
"@lwc/babel-plugin-component": "4.0.0
|
|
25
|
-
"@lwc/compiler": "4.0.0
|
|
26
|
-
"@lwc/engine-core": "4.0.0
|
|
27
|
-
"@lwc/engine-dom": "4.0.0
|
|
28
|
-
"@lwc/engine-server": "4.0.0
|
|
29
|
-
"@lwc/errors": "4.0.0
|
|
30
|
-
"@lwc/features": "4.0.0
|
|
31
|
-
"@lwc/module-resolver": "4.0.0
|
|
32
|
-
"@lwc/rollup-plugin": "4.0.0
|
|
33
|
-
"@lwc/shared": "4.0.0
|
|
34
|
-
"@lwc/style-compiler": "4.0.0
|
|
35
|
-
"@lwc/synthetic-shadow": "4.0.0
|
|
36
|
-
"@lwc/template-compiler": "4.0.0
|
|
37
|
-
"@lwc/wire-service": "4.0.0
|
|
23
|
+
"@lwc/aria-reflection": "4.0.0",
|
|
24
|
+
"@lwc/babel-plugin-component": "4.0.0",
|
|
25
|
+
"@lwc/compiler": "4.0.0",
|
|
26
|
+
"@lwc/engine-core": "4.0.0",
|
|
27
|
+
"@lwc/engine-dom": "4.0.0",
|
|
28
|
+
"@lwc/engine-server": "4.0.0",
|
|
29
|
+
"@lwc/errors": "4.0.0",
|
|
30
|
+
"@lwc/features": "4.0.0",
|
|
31
|
+
"@lwc/module-resolver": "4.0.0",
|
|
32
|
+
"@lwc/rollup-plugin": "4.0.0",
|
|
33
|
+
"@lwc/shared": "4.0.0",
|
|
34
|
+
"@lwc/style-compiler": "4.0.0",
|
|
35
|
+
"@lwc/synthetic-shadow": "4.0.0",
|
|
36
|
+
"@lwc/template-compiler": "4.0.0",
|
|
37
|
+
"@lwc/wire-service": "4.0.0"
|
|
38
38
|
},
|
|
39
39
|
"lwc": {
|
|
40
40
|
"modules": [
|
|
@@ -70,4 +70,4 @@
|
|
|
70
70
|
"./template-compiler": "./template-compiler.js",
|
|
71
71
|
"./wire-service": "./wire-service.js"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|