@lwc/engine-core 7.2.0 → 7.3.0-alpha.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/framework/decorators/wire.d.ts +2 -2
- package/dist/framework/wiring/index.d.ts +1 -1
- package/dist/framework/wiring/types.d.ts +28 -0
- package/dist/index.cjs.js +3 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WireAdapterConstructor } from '../wiring';
|
|
1
|
+
import type { ConfigValue, ContextValue, ReplaceReactiveValues, WireAdapterConstructor, WireDecorator } from '../wiring';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator factory to wire a property or method to a wire adapter data source.
|
|
4
4
|
* @param adapter the adapter used to provision data
|
|
@@ -10,5 +10,5 @@ import { WireAdapterConstructor } from '../wiring';
|
|
|
10
10
|
* \@wire(getBook, { id: '$bookId'}) book;
|
|
11
11
|
* }
|
|
12
12
|
*/
|
|
13
|
-
export default function wire
|
|
13
|
+
export default function wire<ReactiveConfig extends ConfigValue = ConfigValue, Value = any, Context extends ContextValue = ContextValue>(adapter: WireAdapterConstructor<ReplaceReactiveValues<ReactiveConfig>, Value, Context>, config?: ReactiveConfig): WireDecorator<Value>;
|
|
14
14
|
export declare function internalWireFieldDecorator(key: string): PropertyDescriptor;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createContextProviderWithRegister, createContextWatcher } from './context';
|
|
2
|
-
export { ConfigCallback, ConfigValue, ContextConsumer, ContextProvider, ContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './types';
|
|
2
|
+
export { ConfigCallback, ConfigValue, ContextConsumer, ContextProvider, ContextValue, DataCallback, ReplaceReactiveValues, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, WireDecorator, } from './types';
|
|
3
3
|
export { connectWireAdapters, disconnectWireAdapters, installWireAdapters, storeWiredFieldMeta, storeWiredMethodMeta, } from './wiring';
|
|
@@ -16,6 +16,26 @@ export interface WireAdapterConstructor<Config extends ConfigValue = ConfigValue
|
|
|
16
16
|
configSchema?: Record<keyof Config, WireAdapterSchemaValue>;
|
|
17
17
|
contextSchema?: Record<keyof Context, WireAdapterSchemaValue>;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The decorator returned by `@wire()`; not the `wire` factory function.
|
|
21
|
+
*
|
|
22
|
+
* If you're using `@wire(adapter) property` and getting an opaque type error, ensure that the
|
|
23
|
+
* property is explicitly typed and the type matches the value used by the adapter. Note that one
|
|
24
|
+
* of the following conditions must always be true:
|
|
25
|
+
* - The adapter uses `undefined` as a possible value
|
|
26
|
+
* - The property is marked as optional
|
|
27
|
+
* - The property is assigned a default value (not provided by the adapter)
|
|
28
|
+
*/
|
|
29
|
+
export interface WireDecorator<Value = any> {
|
|
30
|
+
/** Property decorator for `"experimentalDecorators": false`. */
|
|
31
|
+
<Class extends LightningElement>(target: undefined, ctx: ClassFieldDecoratorContext<Class, Value>): void;
|
|
32
|
+
/** Method decorator for `"experimentalDecorators": false`. */
|
|
33
|
+
<Class extends LightningElement>(target: DataCallback<Value>, ctx: ClassMethodDecoratorContext<Class, DataCallback<Value>>): void | DataCallback<Value>;
|
|
34
|
+
/** Property decorator for `"experimentalDecorators": true`. */
|
|
35
|
+
<K extends string | symbol>(target: Record<K, Value>, propertyKey: K): void;
|
|
36
|
+
/** Method decorator for `"experimentalDecorators": true`. */
|
|
37
|
+
<K extends string | symbol>(target: Record<K, DataCallback<Value>>, propertyKey: K, descriptor: TypedPropertyDescriptor<DataCallback<Value>>): void;
|
|
38
|
+
}
|
|
19
39
|
export interface WireDef {
|
|
20
40
|
method?: (data: any) => void;
|
|
21
41
|
adapter: WireAdapterConstructor;
|
|
@@ -49,3 +69,11 @@ export interface ContextProviderOptions {
|
|
|
49
69
|
}
|
|
50
70
|
export type ContextProvider = (elmOrComponent: EventTarget, options: ContextProviderOptions) => void;
|
|
51
71
|
export type RegisterContextProviderFn = (element: HostElement, adapterContextToken: string, onContextSubscription: WireContextSubscriptionCallback) => void;
|
|
72
|
+
/**
|
|
73
|
+
* String values starting with "$" are reactive; they get replaced by values from the component.
|
|
74
|
+
* We don't have access to the component, and we don't expect all reactive strings to be typed as
|
|
75
|
+
* literals, so we just replace all strings with `any`.
|
|
76
|
+
*/
|
|
77
|
+
export type ReplaceReactiveValues<T> = {
|
|
78
|
+
[K in keyof T]: T[K] extends string ? any : T[K];
|
|
79
|
+
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -5345,14 +5345,14 @@ function i(iterable, factory) {
|
|
|
5345
5345
|
// TODO [#1276]: compiler should give us some sort of indicator when a vnodes collection is dynamic
|
|
5346
5346
|
sc(list);
|
|
5347
5347
|
const vmBeingRendered = getVMBeingRendered();
|
|
5348
|
-
if (shared.isUndefined(iterable) || iterable
|
|
5348
|
+
if (shared.isUndefined(iterable) || shared.isNull(iterable)) {
|
|
5349
5349
|
if (process.env.NODE_ENV !== 'production') {
|
|
5350
|
-
logError(`Invalid template iteration for value
|
|
5350
|
+
logError(`Invalid template iteration for value \`${shared.toString(iterable)}\` in ${vmBeingRendered}. It must be an array-like object.`, vmBeingRendered);
|
|
5351
5351
|
}
|
|
5352
5352
|
return list;
|
|
5353
5353
|
}
|
|
5354
5354
|
if (process.env.NODE_ENV !== 'production') {
|
|
5355
|
-
shared.assert.isFalse(shared.isUndefined(iterable[SymbolIterator]), `Invalid template iteration for value \`${shared.toString(iterable)}\` in ${vmBeingRendered}. It must be an array-like object
|
|
5355
|
+
shared.assert.isFalse(shared.isUndefined(iterable[SymbolIterator]), `Invalid template iteration for value \`${shared.toString(iterable)}\` in ${vmBeingRendered}. It must be an array-like object.`);
|
|
5356
5356
|
}
|
|
5357
5357
|
const iterator = iterable[SymbolIterator]();
|
|
5358
5358
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5489,9 +5489,6 @@ function k(compilerKey, obj) {
|
|
|
5489
5489
|
function gid(id) {
|
|
5490
5490
|
const vmBeingRendered = getVMBeingRendered();
|
|
5491
5491
|
if (shared.isUndefined(id) || id === '') {
|
|
5492
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5493
|
-
logError(`Invalid id value "${id}". The id attribute must contain a non-empty string.`, vmBeingRendered);
|
|
5494
|
-
}
|
|
5495
5492
|
return id;
|
|
5496
5493
|
}
|
|
5497
5494
|
// We remove attributes when they are assigned a value of null
|
|
@@ -5508,11 +5505,6 @@ function gid(id) {
|
|
|
5508
5505
|
function fid(url) {
|
|
5509
5506
|
const vmBeingRendered = getVMBeingRendered();
|
|
5510
5507
|
if (shared.isUndefined(url) || url === '') {
|
|
5511
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5512
|
-
if (shared.isUndefined(url)) {
|
|
5513
|
-
logError(`Undefined url value for "href" or "xlink:href" attribute. Expected a non-empty string.`, vmBeingRendered);
|
|
5514
|
-
}
|
|
5515
|
-
}
|
|
5516
5508
|
return url;
|
|
5517
5509
|
}
|
|
5518
5510
|
// We remove attributes when they are assigned a value of null
|