@lwc/engine-core 7.3.0-alpha.0 → 7.3.0-alpha.2

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.
@@ -1,8 +1,9 @@
1
+ import { LightningElement } from '../base-lightning-element';
1
2
  /**
2
3
  * The `@api` decorator marks public fields and public methods in
3
4
  * LWC Components. This function implements the internals of this
4
5
  * decorator.
5
6
  */
6
- export default function api(value: unknown, context: ClassMemberDecoratorContext | string | symbol): void;
7
+ export default function api<Class extends LightningElement>(value: unknown, context: ClassFieldDecoratorContext<Class, unknown> | ClassMethodDecoratorContext<Class, (this: Class, ...args: any) => any> | ClassGetterDecoratorContext<Class, unknown> | ClassSetterDecoratorContext<Class, unknown>): void;
7
8
  export declare function createPublicPropertyDescriptor(key: string): PropertyDescriptor;
8
9
  export declare function createPublicAccessorDescriptor(key: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor;
@@ -1,7 +1,9 @@
1
+ import { LightningElement } from '../base-lightning-element';
1
2
  /**
2
3
  * The `@track` decorator function marks field values as reactive in
3
4
  * LWC Components. This function can also be invoked directly
4
5
  * with any value to obtain the trackable version of the value.
5
6
  */
6
- export default function track(value: unknown, context: ClassMemberDecoratorContext | string | symbol): void;
7
+ export default function track<Class extends LightningElement>(target: undefined, context: ClassFieldDecoratorContext<Class>): void;
8
+ export default function track<T>(target: T, context?: never): T;
7
9
  export declare function internalTrackDecorator(key: string): PropertyDescriptor;
@@ -1,4 +1,5 @@
1
- import type { ConfigValue, ContextValue, ReplaceReactiveValues, WireAdapterConstructor, WireDecorator } from '../wiring';
1
+ import type { LightningElement } from '../base-lightning-element';
2
+ import type { ConfigValue, ContextValue, DataCallback, ReplaceReactiveValues, WireAdapterConstructor } from '../wiring';
2
3
  /**
3
4
  * Decorator factory to wire a property or method to a wire adapter data source.
4
5
  * @param adapter the adapter used to provision data
@@ -10,5 +11,5 @@ import type { ConfigValue, ContextValue, ReplaceReactiveValues, WireAdapterConst
10
11
  * \@wire(getBook, { id: '$bookId'}) book;
11
12
  * }
12
13
  */
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
+ export default function wire<ReactiveConfig extends ConfigValue = ConfigValue, Value = any, Context extends ContextValue = ContextValue, Class extends LightningElement = LightningElement>(adapter: WireAdapterConstructor<ReplaceReactiveValues<ReactiveConfig, Class>, Value, Context>, config?: ReactiveConfig): (target: unknown, context: ClassFieldDecoratorContext<Class, Value | undefined> | ClassMethodDecoratorContext<Class, DataCallback<Value>>) => void;
14
15
  export declare function internalWireFieldDecorator(key: string): PropertyDescriptor;
@@ -12,7 +12,7 @@ export type Stylesheet = (stylesheetToken: string | undefined, useActualHostSele
12
12
  */
13
13
  export type Stylesheets = Array<Stylesheet | Stylesheets>;
14
14
  export declare function updateStylesheetToken(vm: VM, template: Template, legacy: boolean): void;
15
- export declare function getStylesheetsContent(vm: VM, template: Template): string[];
15
+ export declare function getStylesheetsContent(vm: VM, template: Template): ReadonlyArray<string>;
16
16
  /**
17
17
  * If the component that is currently being rendered uses scoped styles,
18
18
  * this returns the unique token for that scoped stylesheet. Otherwise
@@ -29,5 +29,5 @@ export declare function getScopeTokenClass(owner: VM, legacy: boolean): string |
29
29
  * @param vnode
30
30
  */
31
31
  export declare function getStylesheetTokenHost(vnode: VCustomElement): string | null;
32
- export declare function createStylesheet(vm: VM, stylesheets: string[]): VNode[] | null;
32
+ export declare function createStylesheet(vm: VM, stylesheets: ReadonlyArray<string>): VNode[] | null;
33
33
  export declare function unrenderStylesheet(stylesheet: Stylesheet): void;
@@ -1,3 +1,3 @@
1
1
  export { createContextProviderWithRegister, createContextWatcher } from './context';
2
- export { ConfigCallback, ConfigValue, ContextConsumer, ContextProvider, ContextValue, DataCallback, ReplaceReactiveValues, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, WireDecorator, } 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';
@@ -16,26 +16,6 @@ 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
- }
39
19
  export interface WireDef {
40
20
  method?: (data: any) => void;
41
21
  adapter: WireAdapterConstructor;
@@ -69,11 +49,14 @@ export interface ContextProviderOptions {
69
49
  }
70
50
  export type ContextProvider = (elmOrComponent: EventTarget, options: ContextProviderOptions) => void;
71
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<Target, Keys> = Keys extends keyof Target ? Target[Keys] : Keys extends `${infer K}.${infer Rest}` ? K extends keyof Target ? ResolveReactiveValue<Target[K], Rest> : undefined : undefined;
72
54
  /**
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`.
55
+ * Detects if the `Value` type is a property chain starting with "$". If so, it resolves the
56
+ * properties to the corresponding value on the target type.
76
57
  */
77
- export type ReplaceReactiveValues<T> = {
78
- [K in keyof T]: T[K] extends string ? any : T[K];
58
+ type ResolveValueIfReactive<Value, Target> = Value extends string ? string extends Value ? any : Value extends `$${infer Keys}` ? ResolveReactiveValue<Target, Keys> : Value : Value;
59
+ export type ReplaceReactiveValues<Config extends ConfigValue, Component extends LightningElement> = {
60
+ [K in keyof Config]: ResolveValueIfReactive<Config[K], Component>;
79
61
  };
62
+ export {};
package/dist/index.cjs.js CHANGED
@@ -2378,8 +2378,8 @@ 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) {
2382
- if (arguments.length === 1) {
2381
+ function track(target, context) {
2382
+ if (shared.isUndefined(context)) {
2383
2383
  return getReactiveProxy(target);
2384
2384
  }
2385
2385
  if (process.env.NODE_ENV !== 'production') {
@@ -3133,15 +3133,22 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3133
3133
  function getStylesheetsContent(vm, template) {
3134
3134
  const { stylesheets, stylesheetToken } = template;
3135
3135
  const { stylesheets: vmStylesheets } = vm;
3136
- let content = [];
3137
- if (hasStyles(stylesheets)) {
3138
- content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
3136
+ const hasTemplateStyles = hasStyles(stylesheets);
3137
+ const hasVmStyles = hasStyles(vmStylesheets);
3138
+ if (hasTemplateStyles) {
3139
+ const content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
3140
+ if (hasVmStyles) {
3141
+ // Slow path – merge the template styles and vm styles
3142
+ shared.ArrayPush.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
3143
+ }
3144
+ return content;
3139
3145
  }
3140
- // VM (component) stylesheets apply after template stylesheets
3141
- if (hasStyles(vmStylesheets)) {
3142
- shared.ArrayPush.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
3146
+ if (hasVmStyles) {
3147
+ // No template styles, so return vm styles directly
3148
+ return evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm);
3143
3149
  }
3144
- return content;
3150
+ // Fastest path - no styles, so return an empty array
3151
+ return EmptyArray;
3145
3152
  }
3146
3153
  // It might be worth caching this to avoid doing the lookup repeatedly, but
3147
3154
  // perf testing has not shown it to be a huge improvement yet:
@@ -6544,6 +6551,8 @@ function computeShadowMode(def, owner, renderer, hydrated) {
6544
6551
  // on, but components running in actual native shadow mode
6545
6552
  (process.env.NODE_ENV === 'test-karma-lwc' &&
6546
6553
  process.env.FORCE_NATIVE_SHADOW_MODE_FOR_TEST) ||
6554
+ // If synthetic shadow is explicitly disabled, use pure-native
6555
+ lwcRuntimeFlags.DISABLE_SYNTHETIC_SHADOW ||
6547
6556
  // hydration only supports native shadow
6548
6557
  shared.isTrue(hydrated)) {
6549
6558
  return 0 /* ShadowMode.Native */;
@@ -8083,5 +8092,5 @@ exports.swapTemplate = swapTemplate;
8083
8092
  exports.track = track;
8084
8093
  exports.unwrap = unwrap;
8085
8094
  exports.wire = wire;
8086
- /** version: 7.2.0 */
8095
+ /** version: 7.3.0-alpha.2 */
8087
8096
  //# sourceMappingURL=index.cjs.js.map