@lwc/engine-core 6.7.2 → 7.0.0-alpha.1

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.
@@ -46,6 +46,16 @@ export type SanitizeHtmlContentHook = (content: unknown) => string;
46
46
  */
47
47
  export declare function setSanitizeHtmlContentHook(newHookImpl: SanitizeHtmlContentHook): void;
48
48
  declare function shc(content: unknown): string;
49
+ /**
50
+ * [ncls] - Normalize class name attribute.
51
+ *
52
+ * Transforms the provided class property value from an object/string into a string the diffing algo
53
+ * can operate on.
54
+ *
55
+ * This implementation is borrowed from Vue:
56
+ * https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
57
+ */
58
+ declare function ncls(value: unknown): string;
49
59
  declare const api: Readonly<{
50
60
  s: typeof s;
51
61
  h: typeof h;
@@ -67,6 +77,7 @@ declare const api: Readonly<{
67
77
  ssf: typeof ssf;
68
78
  ddc: typeof ddc;
69
79
  sp: typeof sp;
80
+ ncls: typeof ncls;
70
81
  }>;
71
82
  export default api;
72
83
  export type RenderAPI = typeof api;
@@ -10,7 +10,7 @@ import { AccessibleElementProperties } from '@lwc/shared';
10
10
  import { ShadowSupportMode } from './vm';
11
11
  import { Template } from './template';
12
12
  import { HTMLElementConstructor } from './base-bridge-element';
13
- import { TemplateStylesheetFactories } from './stylesheet';
13
+ import { Stylesheets } from './stylesheet';
14
14
  export interface LightningElementConstructor {
15
15
  new (): LightningElement;
16
16
  readonly prototype: LightningElement;
@@ -19,18 +19,26 @@ export interface LightningElementConstructor {
19
19
  renderMode?: 'light' | 'shadow';
20
20
  formAssociated?: boolean;
21
21
  shadowSupportMode?: ShadowSupportMode;
22
- stylesheets: TemplateStylesheetFactories;
22
+ stylesheets: Stylesheets;
23
23
  }
24
24
  type HTMLElementTheGoodParts = {
25
25
  toString: () => string;
26
- } & Pick<HTMLElement, 'accessKey' | 'addEventListener' | 'attachInternals' | 'children' | 'childNodes' | 'classList' | 'dir' | 'dispatchEvent' | 'draggable' | 'firstChild' | 'firstElementChild' | 'getAttribute' | 'getAttributeNS' | 'getBoundingClientRect' | 'getElementsByClassName' | 'getElementsByTagName' | 'hasAttribute' | 'hasAttributeNS' | 'hidden' | 'id' | 'isConnected' | 'lang' | 'lastChild' | 'lastElementChild' | 'ownerDocument' | 'querySelector' | 'querySelectorAll' | 'removeAttribute' | 'removeAttributeNS' | 'removeEventListener' | 'setAttribute' | 'setAttributeNS' | 'shadowRoot' | 'spellcheck' | 'tabIndex' | 'tagName' | 'title'>;
26
+ } & Pick<HTMLElement, 'accessKey' | 'addEventListener' | 'attachInternals' | 'children' | 'childNodes' | 'classList' | 'dir' | 'dispatchEvent' | 'draggable' | 'firstChild' | 'firstElementChild' | 'getAttribute' | 'getAttributeNS' | 'getBoundingClientRect' | 'getElementsByClassName' | 'getElementsByTagName' | 'hasAttribute' | 'hasAttributeNS' | 'hidden' | 'id' | 'isConnected' | 'lang' | 'lastChild' | 'lastElementChild' | 'ownerDocument' | 'querySelector' | 'querySelectorAll' | 'removeAttribute' | 'removeAttributeNS' | 'removeEventListener' | 'setAttribute' | 'setAttributeNS' | 'shadowRoot' | 'spellcheck' | 'tabIndex' | 'tagName' | 'title' | 'style'>;
27
27
  type RefNodes = {
28
28
  [name: string]: Element;
29
29
  };
30
+ /**
31
+ * A `LightningElement` will always be attached to an [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement),
32
+ * rather than the more broad `Element` used by the generic shadow root interface.
33
+ */
34
+ export interface LightningElementShadowRoot extends ShadowRoot {
35
+ readonly host: HTMLElement;
36
+ }
30
37
  export interface LightningElement extends HTMLElementTheGoodParts, AccessibleElementProperties {
31
38
  constructor: LightningElementConstructor;
32
- template: ShadowRoot | null;
39
+ template: LightningElementShadowRoot | null;
33
40
  refs: RefNodes | undefined;
41
+ hostElement: Element;
34
42
  render(): Template;
35
43
  connectedCallback?(): void;
36
44
  disconnectedCallback?(): void;
@@ -1,5 +1,5 @@
1
1
  import { Template } from './template';
2
- import { StylesheetFactory } from './stylesheet';
2
+ import { Stylesheet } from './stylesheet';
3
3
  import { LightningElementConstructor } from './base-lightning-element';
4
4
  /**
5
5
  * Validate a template, stylesheet, or component to make sure that its compiled version matches
@@ -9,5 +9,5 @@ import { LightningElementConstructor } from './base-lightning-element';
9
9
  * @param type
10
10
  */
11
11
  export declare function checkVersionMismatch(func: Template, type: 'template'): void;
12
- export declare function checkVersionMismatch(func: StylesheetFactory, type: 'stylesheet'): void;
12
+ export declare function checkVersionMismatch(func: Stylesheet, type: 'stylesheet'): void;
13
13
  export declare function checkVersionMismatch(func: LightningElementConstructor, type: 'component'): void;
@@ -1,11 +1,8 @@
1
1
  /**
2
- * The @api decorator marks public fields and public methods in
2
+ * The `@api` decorator marks public fields and public methods in
3
3
  * LWC Components. This function implements the internals of this
4
4
  * decorator.
5
- * @param target
6
- * @param propertyKey
7
- * @param descriptor
8
5
  */
9
- export default function api(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
6
+ export default function api(value: unknown, context: ClassMemberDecoratorContext | string | symbol): void;
10
7
  export declare function createPublicPropertyDescriptor(key: string): PropertyDescriptor;
11
8
  export declare function createPublicAccessorDescriptor(key: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor;
@@ -1,10 +1,7 @@
1
1
  /**
2
- * The @track decorator function marks field values as reactive in
2
+ * The `@track` decorator function marks field values as reactive in
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
- * @param target
6
- * @param propertyKey
7
- * @param descriptor
8
5
  */
9
- export default function track(target: any, propertyKey: string, descriptor: PropertyDescriptor): any;
6
+ export default function track(value: unknown, context: ClassMemberDecoratorContext | string | symbol): void;
10
7
  export declare function internalTrackDecorator(key: string): PropertyDescriptor;
@@ -1,10 +1,14 @@
1
1
  import { WireAdapterConstructor } from '../wiring';
2
2
  /**
3
- * The @wire decorator wires fields and methods to a wire adapter in
4
- * LWC Components. This function implements the internals of this
5
- * decorator.
6
- * @param _adapter
7
- * @param _config
3
+ * Decorator factory to wire a property or method to a wire adapter data source.
4
+ * @param adapter the adapter used to provision data
5
+ * @param config configuration object for the adapter
6
+ * @returns A decorator function
7
+ * @example
8
+ * export default class WireExample extends LightningElement {
9
+ * \@api bookId;
10
+ * \@wire(getBook, { id: '$bookId'}) book;
11
+ * }
8
12
  */
9
- export default function wire(_adapter: WireAdapterConstructor, _config?: Record<string, any>): PropertyDecorator | MethodDecorator;
13
+ export default function wire(adapter: WireAdapterConstructor, config?: Record<string, any>): (value: unknown, context: ClassMemberDecoratorContext | string | symbol) => void;
10
14
  export declare function internalWireFieldDecorator(key: string): PropertyDescriptor;
@@ -41,12 +41,9 @@ export interface ComponentDef {
41
41
  export declare function isComponentConstructor(ctor: unknown): ctor is LightningElementConstructor;
42
42
  export declare function getComponentInternalDef(Ctor: unknown): ComponentDef;
43
43
  export declare function getComponentHtmlPrototype(Ctor: unknown): HTMLElementConstructor;
44
- declare const enum PropDefType {
45
- any = "any"
46
- }
47
44
  interface PropDef {
48
45
  config: number;
49
- type: PropDefType;
46
+ type: 'any';
50
47
  attr: string;
51
48
  }
52
49
  type PublicMethod = (...args: any[]) => any;
@@ -1,11 +1,11 @@
1
1
  import { VM } from './vm';
2
2
  import { LightningElementConstructor } from './base-lightning-element';
3
3
  import { Template } from './template';
4
- import { StylesheetFactory } from './stylesheet';
4
+ import { Stylesheet } from './stylesheet';
5
5
  export declare function getTemplateOrSwappedTemplate(tpl: Template): Template;
6
6
  export declare function getComponentOrSwappedComponent(Ctor: LightningElementConstructor): LightningElementConstructor;
7
- export declare function getStyleOrSwappedStyle(style: StylesheetFactory): StylesheetFactory;
7
+ export declare function getStyleOrSwappedStyle(style: Stylesheet): Stylesheet;
8
8
  export declare function setActiveVM(vm: VM): void;
9
9
  export declare function swapTemplate(oldTpl: Template, newTpl: Template): boolean;
10
10
  export declare function swapComponent(oldComponent: LightningElementConstructor, newComponent: LightningElementConstructor): boolean;
11
- export declare function swapStyle(oldStyle: StylesheetFactory, newStyle: StylesheetFactory): boolean;
11
+ export declare function swapStyle(oldStyle: Stylesheet, newStyle: Stylesheet): boolean;
@@ -18,7 +18,9 @@ export { getComponentAPIVersion } from './component';
18
18
  export { shouldBeFormAssociated } from './utils';
19
19
  export { getComponentConstructor } from './get-component-constructor';
20
20
  export type { RendererAPI, LifecycleCallback } from './renderer';
21
- export type { ConfigValue as WireConfigValue, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './wiring';
21
+ export type { Stylesheets } from './stylesheet';
22
+ export type { Template } from './template';
23
+ export type { ConfigValue as WireConfigValue, ContextConsumer as WireContextConsumer, ContextProvider as WireContextProvider, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './wiring';
22
24
  export type { FormRestoreState, FormRestoreReason } from './vm';
23
25
  export { LightningElement } from './base-lightning-element';
24
26
  export { default as api } from './decorators/api';
@@ -40,6 +40,7 @@ export interface RendererAPI {
40
40
  getLastChild: (element: E) => N | null;
41
41
  getLastElementChild: (element: E) => E | null;
42
42
  getTagName: (element: E) => string;
43
+ getStyle: (elm: E) => CSSStyleDeclaration;
43
44
  isConnected: (node: N) => boolean;
44
45
  insertStylesheet: (content: string, target: ShadowRoot | undefined, signal: AbortSignal | undefined) => void;
45
46
  assertInstanceOfHTMLElement: (elm: any, msg: string) => void;
@@ -5,13 +5,12 @@ import { VCustomElement, VNode } from './vnodes';
5
5
  * Function producing style based on a host and a shadow selector. This function is invoked by
6
6
  * the engine with different values depending on the mode that the component is running on.
7
7
  */
8
- export type StylesheetFactory = (stylesheetToken: string | undefined, useActualHostSelector: boolean, useNativeDirPseudoclass: boolean) => string;
8
+ export type Stylesheet = (stylesheetToken: string | undefined, useActualHostSelector: boolean, useNativeDirPseudoclass: boolean) => string;
9
9
  /**
10
- * The list of stylesheets associated with a template. Each entry is either a StylesheetFactory or a
11
- * TemplateStylesheetFactory a given stylesheet depends on other external stylesheets (via
12
- * the @import CSS declaration).
10
+ * The list of stylesheets associated with a template. Each entry is either a `Stylesheet` or
11
+ * an array of stylesheets that a given stylesheet depends on via CSS `@import` declarations.
13
12
  */
14
- export type TemplateStylesheetFactories = Array<StylesheetFactory | TemplateStylesheetFactories>;
13
+ export type Stylesheets = Array<Stylesheet | Stylesheets>;
15
14
  export declare function updateStylesheetToken(vm: VM, template: Template, legacy: boolean): void;
16
15
  export declare function getStylesheetsContent(vm: VM, template: Template): string[];
17
16
  /**
@@ -31,4 +30,4 @@ export declare function getScopeTokenClass(owner: VM, legacy: boolean): string |
31
30
  */
32
31
  export declare function getStylesheetTokenHost(vnode: VCustomElement): string | null;
33
32
  export declare function createStylesheet(vm: VM, stylesheets: string[]): VNode[] | null;
34
- export declare function unrenderStylesheet(stylesheet: StylesheetFactory): void;
33
+ export declare function unrenderStylesheet(stylesheet: Stylesheet): void;
@@ -1,13 +1,13 @@
1
1
  import { RenderAPI } from './api';
2
2
  import { SlotSet, TemplateCache, VM } from './vm';
3
- import { TemplateStylesheetFactories } from './stylesheet';
3
+ import { Stylesheets } from './stylesheet';
4
4
  import { VNodes } from './vnodes';
5
5
  export interface Template {
6
6
  (api: RenderAPI, cmp: object, slotSet: SlotSet, cache: TemplateCache): VNodes;
7
7
  /** The list of slot names used in the template. */
8
8
  slots?: string[];
9
9
  /** The stylesheet associated with the template. */
10
- stylesheets?: TemplateStylesheetFactories;
10
+ stylesheets?: Stylesheets;
11
11
  /** The string used for synthetic shadow style scoping and light DOM style scoping. */
12
12
  stylesheetToken?: string;
13
13
  /** Same as the above, but for legacy use cases (pre-LWC v3.0.0) */
@@ -24,4 +24,4 @@ export declare const parseFragment: (strings: string[], ...keys: (string | numbe
24
24
  export declare const parseSVGFragment: (strings: string[], ...keys: (string | number)[]) => () => Element;
25
25
  export declare function evaluateTemplate(vm: VM, html: Template): VNodes;
26
26
  export declare function computeHasScopedStyles(template: Template, vm: VM | undefined): boolean;
27
- export declare function hasStyles(stylesheets: TemplateStylesheetFactories | undefined | null): stylesheets is TemplateStylesheetFactories;
27
+ export declare function hasStyles(stylesheets: Stylesheets | undefined | null): stylesheets is Stylesheets;
@@ -1,4 +1,4 @@
1
- import { StylesheetFactory, TemplateStylesheetFactories } from './stylesheet';
1
+ import { Stylesheet, Stylesheets } from './stylesheet';
2
2
  import { LightningElementConstructor } from './base-lightning-element';
3
3
  type Callback = () => void;
4
4
  export declare const SPACE_CHAR = 32;
@@ -15,7 +15,7 @@ export declare function cloneAndOmitKey(object: {
15
15
  }, keyToOmit: string): {
16
16
  [key: string]: any;
17
17
  };
18
- export declare function flattenStylesheets(stylesheets: TemplateStylesheetFactories): StylesheetFactory[];
18
+ export declare function flattenStylesheets(stylesheets: Stylesheets): Stylesheet[];
19
19
  export declare function assertNotProd(): void;
20
20
  export declare function shouldBeFormAssociated(Ctor: LightningElementConstructor): boolean;
21
21
  export {};
@@ -2,10 +2,10 @@ import { APIVersion } from '@lwc/shared';
2
2
  import { HostNode, HostElement, RendererAPI } from './renderer';
3
3
  import { Template } from './template';
4
4
  import { ComponentDef } from './def';
5
- import { LightningElement, LightningElementConstructor } from './base-lightning-element';
5
+ import { LightningElement, LightningElementConstructor, LightningElementShadowRoot } from './base-lightning-element';
6
6
  import { ReactiveObserver } from './mutation-tracker';
7
7
  import { VNodes, VCustomElement, VNode, VBaseElement, VStaticPartElement } from './vnodes';
8
- import { TemplateStylesheetFactories } from './stylesheet';
8
+ import { Stylesheets } from './stylesheet';
9
9
  type ShadowRootMode = 'open' | 'closed';
10
10
  export interface TemplateCache {
11
11
  [key: string]: any;
@@ -29,14 +29,7 @@ export declare const enum ShadowMode {
29
29
  Native = 0,
30
30
  Synthetic = 1
31
31
  }
32
- export declare const enum ShadowSupportMode {
33
- Any = "any",
34
- Default = "reset",
35
- Native = "native"
36
- }
37
- export declare const enum LwcDomMode {
38
- Manual = "manual"
39
- }
32
+ export type ShadowSupportMode = 'any' | 'reset' | 'native';
40
33
  export interface Context {
41
34
  /** The string used for synthetic shadow DOM and light DOM style scoping. */
42
35
  stylesheetToken: string | undefined;
@@ -126,12 +119,12 @@ export interface VM<N = HostNode, E = HostElement> {
126
119
  /** The component instance. */
127
120
  component: LightningElement;
128
121
  /** The custom element shadow root. */
129
- shadowRoot: ShadowRoot | null;
122
+ shadowRoot: LightningElementShadowRoot | null;
130
123
  /**
131
124
  * The component render root. If the component is a shadow DOM component, it is its shadow
132
125
  * root. If the component is a light DOM component it the element itself.
133
126
  */
134
- renderRoot: ShadowRoot | HostElement;
127
+ renderRoot: LightningElementShadowRoot | HostElement;
135
128
  /** The template reactive observer. */
136
129
  tro: ReactiveObserver;
137
130
  /**
@@ -160,7 +153,7 @@ export interface VM<N = HostNode, E = HostElement> {
160
153
  /**
161
154
  * Any stylesheets associated with the component
162
155
  */
163
- stylesheets: TemplateStylesheetFactories | null;
156
+ stylesheets: Stylesheets | null;
164
157
  /**
165
158
  * API version associated with this VM
166
159
  */
@@ -118,6 +118,11 @@ export interface VElementData extends VNodeData {
118
118
  readonly ref?: string;
119
119
  readonly slotData?: any;
120
120
  readonly slotAssignment?: string;
121
+ readonly context?: {
122
+ lwc?: {
123
+ dom?: 'manual';
124
+ };
125
+ };
121
126
  }
122
127
  export declare function isVBaseElement(vnode: VNode): vnode is VElement | VCustomElement;
123
128
  export declare function isSameVnode(vnode1: VNode, vnode2: VNode): boolean;
@@ -1,3 +1,3 @@
1
1
  export { createContextProviderWithRegister, createContextWatcher } from './context';
2
- export { ConfigCallback, ConfigValue, ContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './types';
2
+ export { ConfigCallback, ConfigValue, ContextConsumer, ContextProvider, ContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './types';
3
3
  export { connectWireAdapters, disconnectWireAdapters, installWireAdapters, storeWiredFieldMeta, storeWiredMethodMeta, } from './wiring';
@@ -1,20 +1,20 @@
1
1
  import type { LightningElement } from '../base-lightning-element';
2
2
  import type { HostElement } from '../renderer';
3
- export type DataCallback = (value: any) => void;
3
+ export type DataCallback<T = any> = (value: T) => void;
4
4
  export type ConfigValue = Record<string, any>;
5
5
  export type WireAdapterSchemaValue = 'optional' | 'required';
6
6
  export type ContextValue = Record<string, any>;
7
- export interface WireAdapter {
8
- update(config: ConfigValue, context?: ContextValue): void;
7
+ export interface WireAdapter<Config extends ConfigValue = ConfigValue, Context extends ContextValue = ContextValue> {
8
+ update(config: Config, context?: Context): void;
9
9
  connect(): void;
10
10
  disconnect(): void;
11
11
  }
12
- export interface WireAdapterConstructor {
13
- new (callback: DataCallback, sourceContext?: {
12
+ export interface WireAdapterConstructor<Config extends ConfigValue = ConfigValue, Value = any, Context extends ContextValue = ContextValue> {
13
+ new (callback: DataCallback<Value>, sourceContext?: {
14
14
  tagName: string;
15
- }): WireAdapter;
16
- configSchema?: Record<string, WireAdapterSchemaValue>;
17
- contextSchema?: Record<string, WireAdapterSchemaValue>;
15
+ }): WireAdapter<Config, Context>;
16
+ configSchema?: Record<keyof Config, WireAdapterSchemaValue>;
17
+ contextSchema?: Record<keyof Context, WireAdapterSchemaValue>;
18
18
  }
19
19
  export interface WireDef {
20
20
  method?: (data: any) => void;
package/dist/index.cjs.js CHANGED
@@ -1517,7 +1517,7 @@ function applyShadowMigrateMode(shadowRoot) {
1517
1517
  }
1518
1518
 
1519
1519
  /*
1520
- * Copyright (c) 2018, salesforce.com, inc.
1520
+ * Copyright (c) 2024, Salesforce, Inc.
1521
1521
  * All rights reserved.
1522
1522
  * SPDX-License-Identifier: MIT
1523
1523
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -1784,6 +1784,25 @@ LightningElement.prototype = {
1784
1784
  }
1785
1785
  return vm.shadowRoot;
1786
1786
  },
1787
+ get hostElement() {
1788
+ const vm = getAssociatedVM(this);
1789
+ if (!process.env.IS_BROWSER) {
1790
+ shared.assert.fail('this.hostElement is not supported in this environment');
1791
+ }
1792
+ const apiVersion = getComponentAPIVersion(vm.def.ctor);
1793
+ if (!shared.isAPIFeatureEnabled(9 /* APIFeature.ENABLE_THIS_DOT_HOST_ELEMENT */, apiVersion)) {
1794
+ if (process.env.NODE_ENV !== 'production') {
1795
+ logWarnOnce('The `this.hostElement` API within LightningElement is ' +
1796
+ 'only supported in API version 62 and above. Increase the API version to use it.');
1797
+ }
1798
+ // Simulate the old behavior for `this.hostElement` to avoid a breaking change
1799
+ return undefined;
1800
+ }
1801
+ if (process.env.NODE_ENV !== 'production') {
1802
+ shared.assert.isTrue(vm.elm instanceof Element, `this.hostElement should be an Element, found: ${vm.elm}`);
1803
+ }
1804
+ return vm.elm;
1805
+ },
1787
1806
  get refs() {
1788
1807
  const vm = getAssociatedVM(this);
1789
1808
  if (isUpdatingTemplate) {
@@ -1910,6 +1929,19 @@ LightningElement.prototype = {
1910
1929
  const { elm, renderer } = getAssociatedVM(this);
1911
1930
  return renderer.getTagName(elm);
1912
1931
  },
1932
+ get style() {
1933
+ const { elm, renderer, def } = getAssociatedVM(this);
1934
+ const apiVersion = getComponentAPIVersion(def.ctor);
1935
+ if (!shared.isAPIFeatureEnabled(10 /* APIFeature.ENABLE_THIS_DOT_STYLE */, apiVersion)) {
1936
+ if (process.env.NODE_ENV !== 'production') {
1937
+ logWarnOnce('The `this.style` API within LightningElement returning the CSSStyleDeclaration is ' +
1938
+ 'only supported in API version 62 and above. Increase the API version to use it.');
1939
+ }
1940
+ // Simulate the old behavior for `this.style` to avoid a breaking change
1941
+ return undefined;
1942
+ }
1943
+ return renderer.getStyle(elm);
1944
+ },
1913
1945
  render() {
1914
1946
  const vm = getAssociatedVM(this);
1915
1947
  return vm.def.template;
@@ -2262,12 +2294,21 @@ function disconnectWireAdapters(vm) {
2262
2294
  }
2263
2295
 
2264
2296
  /*
2265
- * Copyright (c) 2018, salesforce.com, inc.
2297
+ * Copyright (c) 2024, Salesforce, Inc.
2266
2298
  * All rights reserved.
2267
2299
  * SPDX-License-Identifier: MIT
2268
2300
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2269
2301
  */
2270
- function api$1() {
2302
+ /**
2303
+ * The `@api` decorator marks public fields and public methods in
2304
+ * LWC Components. This function implements the internals of this
2305
+ * decorator.
2306
+ */
2307
+ function api$1(
2308
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2309
+ value,
2310
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2311
+ context) {
2271
2312
  if (process.env.NODE_ENV !== 'production') {
2272
2313
  shared.assert.fail(`@api decorator can only be used as a decorator function.`);
2273
2314
  }
@@ -2340,7 +2381,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2340
2381
  }
2341
2382
 
2342
2383
  /*
2343
- * Copyright (c) 2018, salesforce.com, inc.
2384
+ * Copyright (c) 2024, Salesforce, Inc.
2344
2385
  * All rights reserved.
2345
2386
  * SPDX-License-Identifier: MIT
2346
2387
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -2382,19 +2423,27 @@ function internalTrackDecorator(key) {
2382
2423
  }
2383
2424
 
2384
2425
  /*
2385
- * Copyright (c) 2018, salesforce.com, inc.
2426
+ * Copyright (c) 2024, Salesforce, Inc.
2386
2427
  * All rights reserved.
2387
2428
  * SPDX-License-Identifier: MIT
2388
2429
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2389
2430
  */
2390
2431
  /**
2391
- * The @wire decorator wires fields and methods to a wire adapter in
2392
- * LWC Components. This function implements the internals of this
2393
- * decorator.
2394
- * @param _adapter
2395
- * @param _config
2432
+ * Decorator factory to wire a property or method to a wire adapter data source.
2433
+ * @param adapter the adapter used to provision data
2434
+ * @param config configuration object for the adapter
2435
+ * @returns A decorator function
2436
+ * @example
2437
+ * export default class WireExample extends LightningElement {
2438
+ * \@api bookId;
2439
+ * \@wire(getBook, { id: '$bookId'}) book;
2440
+ * }
2396
2441
  */
2397
- function wire(_adapter, _config) {
2442
+ function wire(
2443
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2444
+ adapter,
2445
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2446
+ config) {
2398
2447
  if (process.env.NODE_ENV !== 'production') {
2399
2448
  shared.assert.fail('@wire(adapter, config?) may only be used as a decorator.');
2400
2449
  }
@@ -2430,13 +2479,13 @@ function internalWireFieldDecorator(key) {
2430
2479
  */
2431
2480
  function getClassDescriptorType(descriptor) {
2432
2481
  if (shared.isFunction(descriptor.value)) {
2433
- return "method" /* DescriptorType.Method */;
2482
+ return 'method';
2434
2483
  }
2435
2484
  else if (shared.isFunction(descriptor.set) || shared.isFunction(descriptor.get)) {
2436
- return "accessor" /* DescriptorType.Accessor */;
2485
+ return 'accessor';
2437
2486
  }
2438
2487
  else {
2439
- return "field" /* DescriptorType.Field */;
2488
+ return 'field';
2440
2489
  }
2441
2490
  }
2442
2491
  function validateObservedField(Ctor, fieldName, descriptor) {
@@ -2666,9 +2715,7 @@ function checkVersionMismatch(func, type) {
2666
2715
  const versionMatcher = func.toString().match(shared.LWC_VERSION_COMMENT_REGEX);
2667
2716
  if (!shared.isNull(versionMatcher) && !warned) {
2668
2717
  const version = versionMatcher[1];
2669
- const [major, minor] = version.split('.');
2670
- const [expectedMajor, expectedMinor] = shared.LWC_VERSION.split('.');
2671
- if (major !== expectedMajor || minor !== expectedMinor) {
2718
+ if (version !== shared.LWC_VERSION) {
2672
2719
  warned = true; // only warn once to avoid flooding the console
2673
2720
  // stylesheets and templates do not have user-meaningful names, but components do
2674
2721
  const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
@@ -3301,7 +3348,7 @@ let swappedComponentMap =
3301
3348
  let swappedStyleMap = /*@__PURE__@*/ new WeakMap();
3302
3349
  // The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
3303
3350
  // so we don't want to create strong references to them.
3304
- // The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
3351
+ // The weak keys are kind of useless, because Templates, LightningElementConstructors, and Stylesheets are
3305
3352
  // never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
3306
3353
  // The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
3307
3354
  let activeTemplates = /*@__PURE__@*/ new WeakMultiMap();
@@ -3534,13 +3581,13 @@ function createComponentDef(Ctor) {
3534
3581
  logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3535
3582
  }
3536
3583
  if (!shared.isUndefined(ctorShadowSupportMode) &&
3537
- ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ &&
3538
- ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */ &&
3539
- ctorShadowSupportMode !== "native" /* ShadowSupportMode.Native */) {
3584
+ ctorShadowSupportMode !== 'any' &&
3585
+ ctorShadowSupportMode !== 'reset' &&
3586
+ ctorShadowSupportMode !== 'native') {
3540
3587
  logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3541
3588
  }
3542
3589
  // TODO [#3971]: Completely remove shadowSupportMode "any"
3543
- if (ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */) {
3590
+ if (ctorShadowSupportMode === 'any') {
3544
3591
  logWarn(`Invalid value 'any' for static property shadowSupportMode. 'any' is deprecated and will be removed in a future release--use 'native' instead.`);
3545
3592
  }
3546
3593
  if (!shared.isUndefined(ctorRenderMode) &&
@@ -3574,8 +3621,7 @@ function createComponentDef(Ctor) {
3574
3621
  if (!shared.isUndefined(ctorShadowSupportMode)) {
3575
3622
  shadowSupportMode = ctorShadowSupportMode;
3576
3623
  if (isReportingEnabled() &&
3577
- (shadowSupportMode === "any" /* ShadowSupportMode.Any */ ||
3578
- shadowSupportMode === "native" /* ShadowSupportMode.Native */)) {
3624
+ (shadowSupportMode === 'any' || shadowSupportMode === 'native')) {
3579
3625
  report("ShadowSupportModeUsage" /* ReportingEventId.ShadowSupportModeUsage */, {
3580
3626
  tagName: Ctor.name,
3581
3627
  mode: shadowSupportMode,
@@ -3690,7 +3736,7 @@ const lightingElementDef = {
3690
3736
  propsConfig: EmptyObject,
3691
3737
  methods: EmptyObject,
3692
3738
  renderMode: 1 /* RenderMode.Shadow */,
3693
- shadowSupportMode: "reset" /* ShadowSupportMode.Default */,
3739
+ shadowSupportMode: 'reset',
3694
3740
  formAssociated: undefined,
3695
3741
  wire: EmptyObject,
3696
3742
  bridge: BaseBridgeElement,
@@ -3714,7 +3760,7 @@ function getComponentDef(Ctor) {
3714
3760
  // avoid leaking the reference to the public props descriptors
3715
3761
  publicProps[key] = {
3716
3762
  config: propsConfig[key] || 0, // a property by default
3717
- type: "any" /* PropDefType.any */, // no type inference for public services
3763
+ type: 'any', // no type inference for public services
3718
3764
  attr: shared.htmlPropertyToAttribute(key),
3719
3765
  };
3720
3766
  }
@@ -4691,14 +4737,14 @@ function applyStyleScoping(elm, owner, renderer) {
4691
4737
  }
4692
4738
  function applyDomManual(elm, vnode) {
4693
4739
  const { owner, data: { context }, } = vnode;
4694
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && context?.lwc?.dom === "manual" /* LwcDomMode.Manual */) {
4740
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && context?.lwc?.dom === 'manual') {
4695
4741
  elm.$domManual$ = true;
4696
4742
  }
4697
4743
  }
4698
4744
  function applyElementRestrictions(elm, vnode) {
4699
4745
  if (process.env.NODE_ENV !== 'production') {
4700
4746
  const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
4701
- const isPortal = vnode.type === 2 /* VNodeType.Element */ && vnode.data.context?.lwc?.dom === "manual" /* LwcDomMode.Manual */;
4747
+ const isPortal = vnode.type === 2 /* VNodeType.Element */ && vnode.data.context?.lwc?.dom === 'manual';
4702
4748
  const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4703
4749
  patchElementWithRestrictions(elm, {
4704
4750
  isPortal,
@@ -5583,6 +5629,37 @@ function setSanitizeHtmlContentHook(newHookImpl) {
5583
5629
  function shc(content) {
5584
5630
  return sanitizeHtmlContentHook(content);
5585
5631
  }
5632
+ /**
5633
+ * [ncls] - Normalize class name attribute.
5634
+ *
5635
+ * Transforms the provided class property value from an object/string into a string the diffing algo
5636
+ * can operate on.
5637
+ *
5638
+ * This implementation is borrowed from Vue:
5639
+ * https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
5640
+ */
5641
+ function ncls(value) {
5642
+ let res = '';
5643
+ if (shared.isString(value)) {
5644
+ res = value;
5645
+ }
5646
+ else if (shared.isArray(value)) {
5647
+ for (let i = 0; i < value.length; i++) {
5648
+ const normalized = ncls(value[i]);
5649
+ if (normalized) {
5650
+ res += normalized + ' ';
5651
+ }
5652
+ }
5653
+ }
5654
+ else if (shared.isObject(value)) {
5655
+ for (const key in value) {
5656
+ if (value[key]) {
5657
+ res += key + ' ';
5658
+ }
5659
+ }
5660
+ }
5661
+ return shared.StringTrim.call(res);
5662
+ }
5586
5663
  const api = shared.freeze({
5587
5664
  s,
5588
5665
  h,
@@ -5604,6 +5681,7 @@ const api = shared.freeze({
5604
5681
  ssf,
5605
5682
  ddc,
5606
5683
  sp,
5684
+ ncls,
5607
5685
  });
5608
5686
 
5609
5687
  /*
@@ -6485,7 +6563,7 @@ function computeShadowMode(def, owner, renderer, hydrated) {
6485
6563
  // everything defaults to native when the synthetic shadow polyfill is unavailable.
6486
6564
  shadowMode = 0 /* ShadowMode.Native */;
6487
6565
  }
6488
- else if (def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
6566
+ else if (def.shadowSupportMode === 'native') {
6489
6567
  shadowMode = 0 /* ShadowMode.Native */;
6490
6568
  }
6491
6569
  else {
@@ -7280,7 +7358,7 @@ function hydrateElement(elm, vnode, renderer) {
7280
7358
  vnode.elm = elm;
7281
7359
  const { owner } = vnode;
7282
7360
  const { context } = vnode.data;
7283
- const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual" /* LwcDomMode.Manual */);
7361
+ const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === 'manual');
7284
7362
  if (isDomManual) {
7285
7363
  // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
7286
7364
  // remove the innerHTML from props so it reuses the existing dom elements.
@@ -7998,5 +8076,5 @@ exports.swapTemplate = swapTemplate;
7998
8076
  exports.track = track;
7999
8077
  exports.unwrap = unwrap;
8000
8078
  exports.wire = wire;
8001
- /** version: 6.7.2 */
8079
+ /** version: 7.0.0-alpha.0 */
8002
8080
  //# sourceMappingURL=index.cjs.js.map