@lwc/engine-core 7.3.0-alpha.1 → 7.3.0-alpha.3

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.
@@ -3,6 +3,6 @@
3
3
  * LWC Components. This function implements the internals of this
4
4
  * decorator.
5
5
  */
6
- export default function api(value: unknown, context: ClassMemberDecoratorContext | string | symbol): void;
6
+ export default function api(value: unknown, context: ClassMemberDecoratorContext): void;
7
7
  export declare function createPublicPropertyDescriptor(key: string): PropertyDescriptor;
8
8
  export declare function createPublicAccessorDescriptor(key: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor;
@@ -3,5 +3,6 @@
3
3
  * LWC Components. This function can also be invoked directly
4
4
  * with any value to obtain the trackable version of the value.
5
5
  */
6
- export default function track(value: unknown, context: ClassMemberDecoratorContext | string | symbol): void;
6
+ export default function track(target: undefined, context: ClassFieldDecoratorContext): void;
7
+ export default function track<T>(target: T, context?: never): T;
7
8
  export declare function internalTrackDecorator(key: string): PropertyDescriptor;
@@ -1,4 +1,18 @@
1
- import { WireAdapterConstructor } from '../wiring';
1
+ import type { LightningElement } from '../base-lightning-element';
2
+ import type { ConfigValue, ContextValue, ReplaceReactiveValues, WireAdapterConstructor } from '../wiring';
3
+ /**
4
+ * The decorator returned by `@wire()`; not the `wire` function.
5
+ *
6
+ * For TypeScript users:
7
+ * - If you are seeing an unclear error message, ensure that both the type of the decorated prop and
8
+ * the config used match the types expected by the wire adapter.
9
+ * - String literal types in the config are resolved to the corresponding prop on the component.
10
+ * For example, a component with `id = 555` and `@wire(getBook, {id: "$id"} as const) book` will
11
+ * have `"$id"` resolve to type `number`.
12
+ */
13
+ interface WireDecorator<Value, Class> {
14
+ (target: unknown, context: ClassFieldDecoratorContext<Class, Value | undefined> | ClassMethodDecoratorContext<Class, Value extends (value: any) => any ? Value : (this: Class, value: Value) => void> | ClassGetterDecoratorContext<Class, Value | undefined> | ClassSetterDecoratorContext<Class, Value>): void;
15
+ }
2
16
  /**
3
17
  * Decorator factory to wire a property or method to a wire adapter data source.
4
18
  * @param adapter the adapter used to provision data
@@ -10,5 +24,6 @@ import { WireAdapterConstructor } from '../wiring';
10
24
  * \@wire(getBook, { id: '$bookId'}) book;
11
25
  * }
12
26
  */
13
- export default function wire(adapter: WireAdapterConstructor, config?: Record<string, any>): (value: unknown, context: ClassMemberDecoratorContext | string | symbol) => void;
27
+ export default function wire<ReactiveConfig extends ConfigValue = ConfigValue, Value = any, Context extends ContextValue = ContextValue, Class = LightningElement>(adapter: WireAdapterConstructor<ReplaceReactiveValues<ReactiveConfig, Class>, Value, Context>, config?: ReactiveConfig): WireDecorator<Value, Class>;
14
28
  export declare function internalWireFieldDecorator(key: string): PropertyDescriptor;
29
+ export {};
@@ -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, } from './types';
3
3
  export { connectWireAdapters, disconnectWireAdapters, installWireAdapters, storeWiredFieldMeta, storeWiredMethodMeta, } from './wiring';
@@ -49,3 +49,18 @@ export interface ContextProviderOptions {
49
49
  }
50
50
  export type ContextProvider = (elmOrComponent: EventTarget, options: ContextProviderOptions) => void;
51
51
  export type RegisterContextProviderFn = (element: HostElement, adapterContextToken: string, onContextSubscription: WireContextSubscriptionCallback) => void;
52
+ /** Resolves a property chain to the corresponding value on the target type. */
53
+ type ResolveReactiveValue<
54
+ /** The object to search for properties; initially the component. */
55
+ Target,
56
+ /** A string representing a chain of of property keys, e.g. "data.user.name". */
57
+ Keys extends string> = Keys extends `${infer FirstKey}.${infer Rest}` ? FirstKey extends keyof Target ? ResolveReactiveValue<Target[FirstKey], Rest> : undefined : Keys extends keyof Target ? Target[Keys] : undefined;
58
+ /**
59
+ * Detects if the `Value` type is a property chain starting with "$". If so, it resolves the
60
+ * properties to the corresponding value on the target type.
61
+ */
62
+ type ResolveValueIfReactive<Value, Target> = Value extends string ? string extends Value ? any : Value extends `$${infer Keys}` ? ResolveReactiveValue<Target, Keys> : Value : Value;
63
+ export type ReplaceReactiveValues<Config extends ConfigValue, Component> = {
64
+ [K in keyof Config]: ResolveValueIfReactive<Config[K], Component>;
65
+ };
66
+ export {};
package/dist/index.cjs.js CHANGED
@@ -2378,7 +2378,9 @@ function createPublicAccessorDescriptor(key, descriptor) {
2378
2378
  * SPDX-License-Identifier: MIT
2379
2379
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2380
2380
  */
2381
- function track(target) {
2381
+ function track(target,
2382
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2383
+ context) {
2382
2384
  if (arguments.length === 1) {
2383
2385
  return getReactiveProxy(target);
2384
2386
  }
@@ -6551,6 +6553,8 @@ function computeShadowMode(def, owner, renderer, hydrated) {
6551
6553
  // on, but components running in actual native shadow mode
6552
6554
  (process.env.NODE_ENV === 'test-karma-lwc' &&
6553
6555
  process.env.FORCE_NATIVE_SHADOW_MODE_FOR_TEST) ||
6556
+ // If synthetic shadow is explicitly disabled, use pure-native
6557
+ lwcRuntimeFlags.DISABLE_SYNTHETIC_SHADOW ||
6554
6558
  // hydration only supports native shadow
6555
6559
  shared.isTrue(hydrated)) {
6556
6560
  return 0 /* ShadowMode.Native */;