@lit/reactive-element
Advanced tools
+1
-1
@@ -59,3 +59,3 @@ /** | ||
| * available but `adoptedStyleSheets` is not, styles are appended to the | ||
| * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets). | ||
| * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets). | ||
| * Note, when shimming is used, any styles that are subsequently placed into | ||
@@ -62,0 +62,0 @@ * the shadowRoot should be placed *before* any shimmed adopted styles. This |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"css-tag.d.ts","sourceRoot":"","sources":["../src/css-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAIJ,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,iBAAiB,GAAG,cAAc,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAMhE;;;;;;GAMG;AACH,qBAAa,SAAS;IAEpB,CAAC,cAAc,CAAC,UAAQ;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAmC;IAEnD,OAAO;IAgBP,IAAI,UAAU,IAAI,aAAa,GAAG,SAAS,CAoB1C;IAED,QAAQ,IAAI,MAAM;CAGnB;AAyBD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,cAKrC,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,YACL,oBAAoB,aAClB,CAAC,cAAc,GAAG,MAAM,CAAC,EAAE,KACrC,SAaF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,eACV,UAAU,UACd,MAAM,iBAAiB,CAAC,SAkBjC,CAAC;AAUF,eAAO,MAAM,kBAAkB,MAGrB,iBAAiB,sBAEwC,CAAC"} | ||
| {"version":3,"file":"css-tag.d.ts","sourceRoot":"","sources":["../src/css-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAIJ,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,iBAAiB,GAAG,cAAc,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAMhE;;;;;;GAMG;AACH,qBAAa,SAAS;IAEpB,CAAC,cAAc,CAAC,UAAQ;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAmC;IAEnD,OAAO;IAgBP,IAAI,UAAU,IAAI,aAAa,GAAG,SAAS,CAoB1C;IAED,QAAQ,IAAI,MAAM;CAGnB;AAyBD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,cAKrC,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,YACL,oBAAoB,aAClB,CAAC,cAAc,GAAG,MAAM,CAAC,EAAE,KACrC,SAaF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,eACV,UAAU,UACd,KAAK,CAAC,iBAAiB,CAAC,SAkBjC,CAAC;AAUF,eAAO,MAAM,kBAAkB,MAGrB,iBAAiB,sBAEwC,CAAC"} |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"css-tag.js","sources":["src/css-tag.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n"],"names":["global","globalThis","supportsAdoptingStyleSheets","ShadowRoot","undefined","ShadyCSS","nativeShadow","Document","prototype","CSSStyleSheet","constructionToken","Symbol","cssTagCache","WeakMap","CSSResult","constructor","cssText","strings","safeToken","this","Error","_strings","styleSheet","_styleSheet","cacheable","length","get","replaceSync","set","toString","unsafeCSS","value","String","css","values","reduce","acc","v","idx","textFromCSSResult","adoptStyles","renderRoot","styles","adoptedStyleSheets","map","s","style","document","createElement","nonce","setAttribute","textContent","appendChild","getCompatibleStyle","sheet","rule","cssRules","cssResultFromStyleSheet"],"mappings":";;;;;AAMA,MAGMA,EAASC,WAKFC,EACXF,EAAOG,kBACcC,I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,EAAQ,CACtB,MAAMI,EAAQC,SAASC,cAAc,SAE/BC,EAASjD,EAAyB,cAC1BI,IAAV6C,GACFH,EAAMI,aAAa,QAASD,GAE9BH,EAAMK,YAAeN,EAAgB7B,QACrCyB,EAAWW,YAAYN,EACxB,CACF,EAWUO,EACXnD,EAEK2C,GAAyBA,EACzBA,GACCA,aAAapC,cAbW,CAAC6C,IAC/B,IAAItC,EAAU,GACd,IAAK,MAAMuC,KAAQD,EAAME,SACvBxC,GAAWuC,EAAKvC,QAElB,OAAOc,EAAUd,EAAQ,EAQUyC,CAAwBZ,GAAKA"} | ||
| {"version":3,"file":"css-tag.js","sources":["src/css-tag.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n"],"names":["global","globalThis","supportsAdoptingStyleSheets","ShadowRoot","undefined","ShadyCSS","nativeShadow","Document","prototype","CSSStyleSheet","constructionToken","Symbol","cssTagCache","WeakMap","CSSResult","constructor","cssText","strings","safeToken","this","Error","_strings","styleSheet","_styleSheet","cacheable","length","get","replaceSync","set","toString","unsafeCSS","value","String","css","values","reduce","acc","v","idx","textFromCSSResult","adoptStyles","renderRoot","styles","adoptedStyleSheets","map","s","style","document","createElement","nonce","setAttribute","textContent","appendChild","getCompatibleStyle","sheet","rule","cssRules","cssResultFromStyleSheet"],"mappings":";;;;;AAMA,MAGMA,EAASC,WAKFC,EACXF,EAAOG,kBACcC,IAApBJ,EAAOK,UAA0BL,EAAOK,SAASC,eAClD,uBAAwBC,SAASC,WACjC,YAAaC,cAAcD,UAkBvBE,EAAoBC,SAEpBC,EAAc,IAAIC,cASXC,EAOX,WAAAC,CACEC,EACAC,EACAC,GAEA,GAVFC,KAAe,cAAI,EAUbD,IAAcR,EAChB,MAAUU,MACR,qEAGJD,KAAKH,QAAUA,EACfG,KAAKE,EAAWJ,CACjB,CAID,cAAIK,GAGF,IAAIA,EAAaH,KAAKI,EACtB,MAAMN,EAAUE,KAAKE,EACrB,GAAInB,QAA8CE,IAAfkB,EAA0B,CAC3D,MAAME,OAAwBpB,IAAZa,GAA4C,IAAnBA,EAAQQ,OAC/CD,IACFF,EAAaV,EAAYc,IAAIT,SAEZb,IAAfkB,KACDH,KAAKI,EAAcD,EAAa,IAAIb,eAAiBkB,YACpDR,KAAKH,SAEHQ,GACFZ,EAAYgB,IAAIX,EAASK,GAG9B,CACD,OAAOA,CACR,CAED,QAAAO,GACE,OAAOV,KAAKH,OACb,EAWH,MAsBac,EAAaC,GACxB,IAAKjB,EACc,iBAAViB,EAAqBA,EAAeA,EAAPC,QACpC5B,EACAM,GAWSuB,EAAM,CACjBhB,KACGiB,KAEH,MAAMlB,EACe,IAAnBC,EAAQQ,OACJR,EAAQ,GACRiB,EAAOC,QACL,CAACC,EAAKC,EAAGC,IAAQF,EA7CD,CAACL,IAEzB,IAA6C,IAAxCA,EAAkC,aACrC,OAAQA,EAAoBf,QACvB,GAAqB,iBAAVe,EAChB,OAAOA,EAEP,MAAUX,MACR,mEACKW,EADL,uFAIH,EAiC8BQ,CAAkBF,GAAKpB,EAAQqB,EAAM,IAC5DrB,EAAQ,IAEhB,OAAO,IAAKH,EACVE,EACAC,EACAP,EACD,EAYU8B,EAAc,CACzBC,EACAC,KAEA,GAAIxC,EACDuC,EAA0BE,mBAAqBD,EAAOE,KAAKC,GAC1DA,aAAapC,cAAgBoC,EAAIA,EAAEvB,kBAGrC,IAAK,MAAMuB,KAAKH,EAAQ,CACtB,MAAMI,EAAQC,SAASC,cAAc,SAE/BC,EAASjD,EAAyB,cAC1BI,IAAV6C,GACFH,EAAMI,aAAa,QAASD,GAE9BH,EAAMK,YAAeN,EAAgB7B,QACrCyB,EAAWW,YAAYN,EACxB,CACF,EAWUO,EACXnD,EAEK2C,GAAyBA,EACzBA,GACCA,aAAapC,cAbW,CAAC6C,IAC/B,IAAItC,EAAU,GACd,IAAK,MAAMuC,KAAQD,EAAME,SACvBxC,GAAWuC,EAAKvC,QAElB,OAAOc,EAAUd,EAAQ,EAQUyC,CAAwBZ,GAAKA"} |
@@ -20,3 +20,3 @@ /** | ||
| */ | ||
| export declare const standardProperty: <C extends Interface<ReactiveElement>, V>(options: PropertyDeclaration<unknown, unknown> | undefined, target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void), context: StandardPropertyContext<C, V>) => ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void); | ||
| export declare const standardProperty: <C extends Interface<ReactiveElement>, V>(options: PropertyDeclaration | undefined, target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void), context: StandardPropertyContext<C, V>) => ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void); | ||
| /** | ||
@@ -23,0 +23,0 @@ * A class field or accessor decorator which creates a reactive property that |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../src/decorators/property.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAGrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAyBzC,MAAM,MAAM,iBAAiB,GAAG;IAE9B,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1C,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAGtC,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAC1B,OAAO,EAAE,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,GACzC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAG/B,CACE,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAE9B,GAAG,CAAC;CACR,CAAC;AAkCF,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CACjC,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GACnC,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,CACpC,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC;AAEvB;;;GAGG;AACH,eAAO,MAAM,gBAAgB,oKAEiC,IAAI,2GAEF,IAAI,CAoDnE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;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AC7D,mBAAmB,sBACpB,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,WACxD,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,KACrC,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAwDnE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CA4BzE"} |
@@ -6,3 +6,3 @@ import{defaultConverter as t,notEqual as e}from"../reactive-element.js"; | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),"accessor"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error("Unsupported decorator location: "+n)};function n(t){return(e,o)=>"object"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty}; | ||
| */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=!0),s.set(r.name,t),"accessor"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error("Unsupported decorator location: "+n)};function n(t){return(e,o)=>"object"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty}; | ||
| //# sourceMappingURL=property.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"property.js","sources":["../src/decorators/property.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(\n name,\n hasOwnProperty ? {...options, wrapped: true} : options\n );\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"],"names":["defaultPropertyDeclaration","attribute","type","String","converter","defaultConverter","reflect","hasChanged","notEqual","standardProperty","options","target","context","kind","metadata","properties","globalThis","litPropertyMetadata","get","undefined","set","Map","name","v","oldValue","call","this","requestUpdate","init","_$changeProperty","value","Error","property","protoOrTarget","nameOrContext","proto","hasOwnProperty","constructor","createProperty","wrapped","Object","getOwnPropertyDescriptor","legacyProperty"],"mappings":";;;;;GAkEA,MAuBMA,EAAkD,CACtDC,WAAW,EACXC,KAAMC,OACNC,UAAWC,EACXC,SAAS,EACTC,WAAYC,GAaDC,EAAmB,CAC9BC,EAA+BV,EAC/BW,EACAC,KAEA,MAAMC,KAACA,EAAIC,SAAEA,GAAYF,EAazB,IAAIG,EAAaC,WAAWC,oBAAoBC,IAAIJ,GAMpD,QALmBK,IAAfJ,GACFC,WAAWC,oBAAoBG,IAAIN,EAAWC,EAAa,IAAIM,KAEjEN,EAAWK,IAAIR,EAAQU,KAAMZ,GAEhB,aAATG,EAAqB,CAIvB,MAAMS,KAACA,GAAQV,EACf,MAAO,CACL,GAAAQ,CAA2BG,GACzB,MAAMC,EACJb,EACAO,IAAIO,KAAKC,MACVf,EAA8CS,IAAIK,KACjDC,KACAH,GAEFG,KAAKC,cAAcL,EAAME,EAAUd,EACpC,EACD,IAAAkB,CAA4BL,GAI1B,YAHUJ,IAANI,GACFG,KAAKG,EAAiBP,OAAMH,EAAWT,GAElCa,CACR,EAEJ,CAAM,GAAa,WAATV,EAAmB,CAC5B,MAAMS,KAACA,GAAQV,EACf,OAAO,SAAiCkB,GACtC,MAAMN,EAAWE,KAAKJ,GACrBX,EAA8Bc,KAAKC,KAAMI,GAC1CJ,KAAKC,cAAcL,EAAME,EAAUd,EACrC,CACD,CACD,MAAUqB,MAAM,mCAAmClB,EAAO,EAmCtD,SAAUmB,EAAStB,GACvB,MAAO,CACLuB,EAIAC,IAO2B,iBAAlBA,EACHzB,EACEC,EACAuB,EAGAC,GAtJW,EACrBxB,EACAyB,EACAb,KAEA,MAAMc,EAAiBD,EAAMC,eAAed,GAU5C,OATCa,EAAME,YAAuCC,eAC5ChB,EACAc,EAAiB,IAAI1B,EAAS6B,SAAS,GAAQ7B,GAO1C0B,EACHI,OAAOC,yBAAyBN,EAAOb,QACvCH,CAAS,EAuILuB,CACEhC,EACAuB,EACAC,EAIZ"} | ||
| {"version":3,"file":"property.js","sources":["../src/decorators/property.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(name, options);\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n if (kind === 'setter') {\n options = Object.create(options);\n options.wrapped = true;\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options, v);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"],"names":["defaultPropertyDeclaration","attribute","type","String","converter","defaultConverter","reflect","hasChanged","notEqual","standardProperty","options","target","context","kind","metadata","properties","globalThis","litPropertyMetadata","get","undefined","set","Map","Object","create","wrapped","name","v","oldValue","call","this","requestUpdate","init","_$changeProperty","value","Error","property","protoOrTarget","nameOrContext","proto","hasOwnProperty","constructor","createProperty","getOwn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EAIZ"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"query-async.d.ts","sourceRoot":"","sources":["../../src/decorators/query-async.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG;IAEhC,CACE,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAG9B,IAAI,GAAG,GAAG,CAAC;IAGd,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EACtE,KAAK,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAOF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,uBAY1C"} | ||
| {"version":3,"file":"query-async.d.ts","sourceRoot":"","sources":["../../src/decorators/query-async.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG;IAEhC,CACE,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAG9B,IAAI,GAAG,GAAG,CAAC;IAGd,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EACtE,KAAK,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAOF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAWnC,mBAAmB,CAC1B"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/decorators/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,WAAW,CAAC;AAwB/C,MAAM,MAAM,cAAc,GAAG;IAE3B,CACE,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAG9B,IAAI,GAAG,GAAG,CAAC;IAGd,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,IAAI,EAC7D,KAAK,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,cAAc,CA4EvE"} | ||
| {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/decorators/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,WAAW,CAAC;AA8B/C,MAAM,MAAM,cAAc,GAAG;IAE3B,CACE,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAG9B,IAAI,GAAG,GAAG,CAAC;IAGd,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,IAAI,EAC7D,KAAK,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,cAAc,CA4EvE"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"query.js","sources":["../src/decorators/query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"],"names":["query","selector","cache","protoOrTarget","nameOrContext","descriptor","doQuery","el","renderRoot","querySelector","get","set","key","Symbol","this","v","desc","result","call","undefined","hasUpdated"],"mappings":";;;;;GA+EgB,SAAAA,EAAMC,EAAkBC,GACtC,OACEC,EACAC,EACAC,KAEA,MAAMC,EAAWC,GACCA,EAAGC,YAAYC,cAAcR,IAAa,KAoB5D,GAAIC,EAAO,CAOT,MAAMQ,IAACA,EAAGC,IAAEA,GACe,iBAAlBP,EACHD,EACAE,GACA,MACE,MAAMO,EAEFC,SAIJ,MAAO,CACL,GAAAH,GACE,OAAQI,KAAmBF,EAC5B,EACD,GAAAD,CAAII,GACDD,KAAmBF,GAAOG,CAC5B,EAEJ,EAfD,GAgBN,OAAOC,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,IAAIO,EAAYP,EAAKQ,KAAKJ,MAO1B,YANeK,IAAXF,IACFA,EAASX,EAAQQ,OACF,OAAXG,GAAmBH,KAAKM,aAC1BT,EAAKO,KAAKJ,KAAMG,IAGbA,CACR,GAEJ,CAGC,OAAOD,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,OAAOJ,EAAQQ,KAChB,GAGN,CACH"} | ||
| {"version":3,"file":"query.js","sources":["../src/decorators/query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"],"names":["query","selector","cache","protoOrTarget","nameOrContext","descriptor","doQuery","el","renderRoot","querySelector","get","set","key","Symbol","this","v","desc","result","call","undefined","hasUpdated"],"mappings":";;;;;GAqFgB,SAAAA,EAAMC,EAAkBC,GACtC,OACEC,EACAC,EACAC,KAEA,MAAMC,EAAWC,GACCA,EAAGC,YAAYC,cAAcR,IAAa,KAoB5D,GAAIC,EAAO,CAOT,MAAMQ,IAACA,EAAGC,IAAEA,GACe,iBAAlBP,EACHD,EACAE,GACA,MACE,MAAMO,EAEFC,SAIJ,MAAO,CACL,GAAAH,GACE,OAAQI,KAAmBF,EAC5B,EACD,GAAAD,CAAII,GACDD,KAAmBF,GAAOG,CAC5B,EAEJ,EAfD,GAgBN,OAAOC,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,IAAIO,EAAYP,EAAKQ,KAAKJ,MAO1B,YANeK,IAAXF,IACFA,EAASX,EAAQQ,OACF,OAAXG,GAAmBH,KAAKM,aAC1BT,EAAKO,KAAKJ,KAAMG,IAGbA,CACR,GAEJ,CAGC,OAAOD,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,OAAOJ,EAAQQ,KAChB,GAGN,CACH"} |
@@ -59,3 +59,3 @@ /** | ||
| * available but `adoptedStyleSheets` is not, styles are appended to the | ||
| * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets). | ||
| * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets). | ||
| * Note, when shimming is used, any styles that are subsequently placed into | ||
@@ -62,0 +62,0 @@ * the shadowRoot should be placed *before* any shimmed adopted styles. This |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"css-tag.d.ts","sourceRoot":"","sources":["../src/css-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAIJ,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,iBAAiB,GAAG,cAAc,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAMhE;;;;;;GAMG;AACH,qBAAa,SAAS;IAEpB,CAAC,cAAc,CAAC,UAAQ;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAmC;IAEnD,OAAO;IAgBP,IAAI,UAAU,IAAI,aAAa,GAAG,SAAS,CAoB1C;IAED,QAAQ,IAAI,MAAM;CAGnB;AAyBD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,cAKrC,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,YACL,oBAAoB,aAClB,CAAC,cAAc,GAAG,MAAM,CAAC,EAAE,KACrC,SAaF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,eACV,UAAU,UACd,MAAM,iBAAiB,CAAC,SAkBjC,CAAC;AAUF,eAAO,MAAM,kBAAkB,MAGrB,iBAAiB,sBAEwC,CAAC"} | ||
| {"version":3,"file":"css-tag.d.ts","sourceRoot":"","sources":["../src/css-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAIJ,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,iBAAiB,GAAG,cAAc,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAMhE;;;;;;GAMG;AACH,qBAAa,SAAS;IAEpB,CAAC,cAAc,CAAC,UAAQ;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAmC;IAEnD,OAAO;IAgBP,IAAI,UAAU,IAAI,aAAa,GAAG,SAAS,CAoB1C;IAED,QAAQ,IAAI,MAAM;CAGnB;AAyBD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,cAKrC,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,YACL,oBAAoB,aAClB,CAAC,cAAc,GAAG,MAAM,CAAC,EAAE,KACrC,SAaF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,eACV,UAAU,UACd,KAAK,CAAC,iBAAiB,CAAC,SAkBjC,CAAC;AAUF,eAAO,MAAM,kBAAkB,MAGrB,iBAAiB,sBAEwC,CAAC"} |
@@ -99,3 +99,3 @@ /** | ||
| * available but `adoptedStyleSheets` is not, styles are appended to the | ||
| * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets). | ||
| * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets). | ||
| * Note, when shimming is used, any styles that are subsequently placed into | ||
@@ -102,0 +102,0 @@ * the shadowRoot should be placed *before* any shimmed adopted styles. This |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"css-tag.js","sourceRoot":"","sources":["../src/css-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,SAAS,GAAG,KAAK,CAA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AAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAC7B,2BAA2B;IAC3B,CAAC,SAAS,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,CAAC;IAC/C,CAAC,CAAC,CAAC,CAAoB,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC,CAAoB,EAAE,EAAE,CACvB,CAAC,YAAY,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n"]} | ||
| {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,QAAQ,EAAE,CAAC;QAClC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IAC1B,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAC7B,2BAA2B;IAC3B,CAAC,SAAS,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,CAAC;IAC/C,CAAC,CAAC,CAAC,CAAoB,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC,CAAoB,EAAE,EAAE,CACvB,CAAC,YAAY,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n"]} |
@@ -20,3 +20,3 @@ /** | ||
| */ | ||
| export declare const standardProperty: <C extends Interface<ReactiveElement>, V>(options: PropertyDeclaration<unknown, unknown> | undefined, target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void), context: StandardPropertyContext<C, V>) => ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void); | ||
| export declare const standardProperty: <C extends Interface<ReactiveElement>, V>(options: PropertyDeclaration | undefined, target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void), context: StandardPropertyContext<C, V>) => ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void); | ||
| /** | ||
@@ -23,0 +23,0 @@ * A class field or accessor decorator which creates a reactive property that |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../src/decorators/property.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAGrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAyBzC,MAAM,MAAM,iBAAiB,GAAG;IAE9B,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1C,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAGtC,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAC1B,OAAO,EAAE,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,GACzC,CAAC,IAAI,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GACzC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAG/B,CACE,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAE9B,GAAG,CAAC;CACR,CAAC;AA+BF,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CACjC,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GACnC,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,CACpC,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC;AAEvB;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,WAC7D,mBAAmB,sBACpB,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,WACxD,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,KACrC,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAwDnE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CA4BzE"} |
@@ -18,9 +18,14 @@ /** | ||
| // are loaded. | ||
| const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set()); | ||
| // Issue a warning, if we haven't already. | ||
| globalThis.litIssuedWarnings ??= new Set(); | ||
| /** | ||
| * Issue a warning if we haven't already, based either on `code` or `warning`. | ||
| * Warnings are disabled automatically only by `warning`; disabling via `code` | ||
| * can be done by users. | ||
| */ | ||
| issueWarning = (code, warning) => { | ||
| warning += ` See https://lit.dev/msg/${code} for more information.`; | ||
| if (!issuedWarnings.has(warning)) { | ||
| if (!globalThis.litIssuedWarnings.has(warning) && | ||
| !globalThis.litIssuedWarnings.has(code)) { | ||
| console.warn(warning); | ||
| issuedWarnings.add(warning); | ||
| globalThis.litIssuedWarnings.add(warning); | ||
| } | ||
@@ -31,3 +36,3 @@ }; | ||
| const hasOwnProperty = proto.hasOwnProperty(name); | ||
| proto.constructor.createProperty(name, hasOwnProperty ? { ...options, wrapped: true } : options); | ||
| proto.constructor.createProperty(name, options); | ||
| // For accessors (which have a descriptor on the prototype) we need to | ||
@@ -69,2 +74,6 @@ // return a descriptor, otherwise TypeScript overwrites the descriptor we | ||
| } | ||
| if (kind === 'setter') { | ||
| options = Object.create(options); | ||
| options.wrapped = true; | ||
| } | ||
| properties.set(context.name, options); | ||
@@ -84,3 +93,3 @@ if (kind === 'accessor') { | ||
| if (v !== undefined) { | ||
| this._$changeProperty(name, undefined, options); | ||
| this._$changeProperty(name, undefined, options, v); | ||
| } | ||
@@ -87,0 +96,0 @@ return v; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"property.js","sourceRoot":"","sources":["../../src/decorators/property.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,OAAO,EAGL,gBAAgB,EAChB,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAGhC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,IAAI,YAAqD,CAAC;AAE1D,IAAI,QAAQ,EAAE,CAAC;IACb,uEAAuE;IACvE,cAAc;IACd,MAAM,cAAc,GAClB,CAAC,UAAU,CAAC,iBAAiB,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;IAE/C,0CAA0C;IAC1C,YAAY,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE;QAC/C,OAAO,IAAI,4BAA4B,IAAI,wBAAwB,CAAC;QACpE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC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C;IAC9C,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,QAAQ,CAAC,OAA6B;IACpD,OAAO,CACL,aAGwB,EACxB,aAGqC;IACrC,8DAA8D;MACzD,EAAE;QACP,OAAO,CACL,OAAO,aAAa,KAAK,QAAQ;YAC/B,CAAC,CAAC,gBAAgB,CACd,OAAO,EACP,aAEwB,EACxB,aAA8C,CAC/C;YACH,CAAC,CAAC,cAAc,CACZ,OAAO,EACP,aAAuB,EACvB,aAA4B,CAC7B,CACe,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(\n name,\n hasOwnProperty ? {...options, wrapped: true} : options\n );\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"]} | ||
| {"version":3,"file":"property.js","sourceRoot":"","sources":["../../src/decorators/property.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,OAAO,EAGL,gBAAgB,EAChB,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAGhC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,IAAI,YAAqD,CAAC;AAE1D,IAAI,QAAQ,EAAE,CAAC;IACb,uEAAuE;IACvE,cAAc;IACd,UAAU,CAAC,iBAAiB,KAAK,IAAI,GAAG,EAAE,CAAC;IAE3C;;;;OAIG;IACH,YAAY,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE;QAC/C,OAAO,IAAI,4BAA4B,IAAI,wBAAwB,CAAC;QACpE,IACE,CAAC,UAAU,CAAC,iBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC;YAC3C,CAAC,UAAU,CAAC,iBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EACxC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC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C;YACjD,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,CAA2C,CAAC;IAC9C,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,QAAQ,CAAC,OAA6B;IACpD,OAAO,CACL,aAGwB,EACxB,aAGqC;IACrC,8DAA8D;MACzD,EAAE;QACP,OAAO,CACL,OAAO,aAAa,KAAK,QAAQ;YAC/B,CAAC,CAAC,gBAAgB,CACd,OAAO,EACP,aAEwB,EACxB,aAA8C,CAC/C;YACH,CAAC,CAAC,cAAc,CACZ,OAAO,EACP,aAAuB,EACvB,aAA4B,CAC7B,CACe,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(name, options);\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n if (kind === 'setter') {\n options = Object.create(options);\n options.wrapped = true;\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options, v);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"query-async.d.ts","sourceRoot":"","sources":["../../src/decorators/query-async.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG;IAEhC,CACE,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAG9B,IAAI,GAAG,GAAG,CAAC;IAGd,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EACtE,KAAK,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAOF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,uBAY1C"} | ||
| {"version":3,"file":"query-async.d.ts","sourceRoot":"","sources":["../../src/decorators/query-async.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG;IAEhC,CACE,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,kBAAkB,GAG9B,IAAI,GAAG,GAAG,CAAC;IAGd,CAAC,CAAC,SAAS,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EACtE,KAAK,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3C,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAOF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAWnC,mBAAmB,CAC1B"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/decorators/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAC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BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,cAAc,CA4EvE"} |
@@ -12,4 +12,8 @@ /** | ||
| // are loaded. | ||
| const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set()); | ||
| // Issue a warning, if we haven't already. | ||
| globalThis.litIssuedWarnings ??= new Set(); | ||
| /** | ||
| * Issue a warning if we haven't already, based either on `code` or `warning`. | ||
| * Warnings are disabled automatically only by `warning`; disabling via `code` | ||
| * can be done by users. | ||
| */ | ||
| issueWarning = (code, warning) => { | ||
@@ -19,5 +23,6 @@ warning += code | ||
| : ''; | ||
| if (!issuedWarnings.has(warning)) { | ||
| if (!globalThis.litIssuedWarnings.has(warning) && | ||
| !globalThis.litIssuedWarnings.has(code)) { | ||
| console.warn(warning); | ||
| issuedWarnings.add(warning); | ||
| globalThis.litIssuedWarnings.add(warning); | ||
| } | ||
@@ -24,0 +29,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/decorators/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAC,IAAI,EAAiB,MAAM,WAAW,CAAC;AAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,IAAI,YAAqD,CAAC;AAE1D,IAAI,QAAQ,EAAE,CAAC;IACb,uEAAuE;IACvE,cAAc;IACd,MAAM,cAAc,GAClB,CAAC,UAAU,CAAC,iBAAiB,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;IAE/C,0CAA0C;IAC1C,YAAY,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE;QAC/C,OAAO,IAAI,IAAI;YACb,CAAC,CAAC,4BAA4B,IAAI,wBAAwB;YAC1D,CAAC,CAAC,EAAE,CAAC;QACP,IA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CAAC,CAAC,UAAU;oBACV,CAAC,GAAG,EAAE;wBACJ,MAAM,GAAG,GAAG,QAAQ;4BAClB,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC;4BACrD,CAAC,CAAC,MAAM,EAAE,CAAC;wBAIb,OAAO;4BACL,GAAG;gCACD,OAAQ,IAAkB,CAAC,GAAG,CAAC,CAAC;4BAClC,CAAC;4BACD,GAAG,CAAC,CAAC;gCACF,IAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;4BAC/B,CAAC;yBACF,CAAC;oBACJ,CAAC,CAAC,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE;gBACxC,GAAG;oBACD,IAAI,MAAM,GAAM,GAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAChC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;wBACzB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;wBACvB,IAAI,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;4BACvC,GAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;wBAC1B,CAAC;oBACH,CAAC;oBACD,OAAO,MAAM,CAAC;gBAChB,CAAC;aACF,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,2BAA2B;YAC3B,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE;gBACxC,GAAG;oBACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;gBACvB,CAAC;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAmB,CAAC;AACvB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"]} | ||
| {"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/decorators/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAC,IAAI,EAAiB,MAAM,WAAW,CAAC;AAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,IAAI,YAAqD,CAAC;AAE1D,IAAI,QAAQ,EAAE,CAAC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B,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE;gBACxC,GAAG;oBACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;gBACvB,CAAC;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAmB,CAAC;AACvB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"]} |
@@ -119,2 +119,20 @@ /** | ||
| readonly noAccessor?: boolean; | ||
| /** | ||
| * When `true`, uses the initial value of the property as the default value, | ||
| * which changes how attributes are handled: | ||
| * - The initial value does *not* reflect, even if the `reflect` option is `true`. | ||
| * Subsequent changes to the property will reflect, even if they are equal to the | ||
| * default value. | ||
| * - When the attribute is removed, the property is set to the default value | ||
| * - The initial value will not trigger an old value in the `changedProperties` map | ||
| * argument to update lifecycle methods. | ||
| * | ||
| * When set, properties must be initialized, either with a field initializer, or an | ||
| * assignment in the constructor. Not initializing the property may lead to | ||
| * improper handling of subsequent property assignments. | ||
| * | ||
| * While this behavior is opt-in, most properties that reflect to attributes should | ||
| * use `useDefault: true` so that their initial values do not reflect. | ||
| */ | ||
| useDefault?: boolean; | ||
| } | ||
@@ -494,2 +512,7 @@ /** | ||
| /** | ||
| * Records property default values when the | ||
| * `useDefault` option is used. | ||
| */ | ||
| private __defaultValues?; | ||
| /** | ||
| * Properties that should be reflected when updated. | ||
@@ -531,9 +554,3 @@ */ | ||
| * The properties are stored in a Map which is played back after the | ||
| * constructor runs. Note, on very old versions of Safari (<=9) or Chrome | ||
| * (<=41), properties created for native platform properties like (`id` or | ||
| * `name`) may not have default values set in the element constructor. On | ||
| * these browsers native properties appear on instances and therefore their | ||
| * default value will overwrite any element default (e.g. if the element sets | ||
| * this.id = 'id' in the constructor, the 'id' will become '' since this is | ||
| * the native platform default). | ||
| * constructor runs. | ||
| */ | ||
@@ -579,3 +596,3 @@ private __saveInstanceProperties; | ||
| * | ||
| * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks) | ||
| * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes) | ||
| * on MDN for more information about the `attributeChangedCallback`. | ||
@@ -582,0 +599,0 @@ * @category attributes |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"reactive-element.d.ts","sourceRoot":"","sources":["../src/reactive-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAGL,cAAc,EACd,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAKlC,cAAc,cAAc,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAiFlC;;;;;GAKG;AAEH,yBAAiB,gBAAgB,CAAC;IAChC;;;;;;;;OAQG;IAEH,UAAiB,QAAQ,CAAC;QACxB,KAAY,KAAK,GAAG,MAAM,CAAC;QAC3B,UAAiB,MAAM;YACrB,IAAI,EAAE,QAAQ,CAAC;SAChB;KACF;CACF;AAyCD;;GAEG;AACH,MAAM,WAAW,yBAAyB,CAAC,IAAI,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO;IAC3E;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAE5D;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CACrD;AAED,KAAK,kBAAkB,CAAC,IAAI,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO,IACtD,yBAAyB,CAAC,IAAI,CAAC,GAC/B,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAC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F/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,SAAS,CAAC,UAAU,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IA6B9D,OAAO,CAAC,aAAa;IAKrB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAErC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,CAAC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/C;;;;;;;OAOG;IACH,SAAS,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,GAAG,OAAO;IAInE;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,CAAC,kBAAkB,EAAE,cAAc;IAUnD;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,CAAC,kBAAkB,EAAE,cAAc;IAEpD;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc;CAC1D"} |
@@ -40,18 +40,24 @@ /** | ||
| // are loaded. | ||
| const issuedWarnings = (global.litIssuedWarnings ??= | ||
| new Set()); | ||
| // Issue a warning, if we haven't already. | ||
| global.litIssuedWarnings ??= new Set(); | ||
| /** | ||
| * Issue a warning if we haven't already, based either on `code` or `warning`. | ||
| * Warnings are disabled automatically only by `warning`; disabling via `code` | ||
| * can be done by users. | ||
| */ | ||
| issueWarning = (code, warning) => { | ||
| warning += ` See https://lit.dev/msg/${code} for more information.`; | ||
| if (!issuedWarnings.has(warning)) { | ||
| if (!global.litIssuedWarnings.has(warning) && | ||
| !global.litIssuedWarnings.has(code)) { | ||
| console.warn(warning); | ||
| issuedWarnings.add(warning); | ||
| global.litIssuedWarnings.add(warning); | ||
| } | ||
| }; | ||
| issueWarning('dev-mode', `Lit is in dev mode. Not recommended for production!`); | ||
| // Issue polyfill support warning. | ||
| if (global.ShadyDOM?.inUse && polyfillSupport === undefined) { | ||
| issueWarning('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` + | ||
| `the \`polyfill-support\` module has not been loaded.`); | ||
| } | ||
| queueMicrotask(() => { | ||
| issueWarning('dev-mode', `Lit is in dev mode. Not recommended for production!`); | ||
| // Issue polyfill support warning. | ||
| if (global.ShadyDOM?.inUse && polyfillSupport === undefined) { | ||
| issueWarning('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` + | ||
| `the \`polyfill-support\` module has not been loaded.`); | ||
| } | ||
| }); | ||
| } | ||
@@ -134,2 +140,3 @@ /** | ||
| reflect: false, | ||
| useDefault: false, | ||
| hasChanged: notEqual, | ||
@@ -242,2 +249,8 @@ }; | ||
| this.__prepare(); | ||
| // Whether this property is wrapping accessors. | ||
| // Helps control the initial value change and reflection logic. | ||
| if (this.prototype.hasOwnProperty(name)) { | ||
| options = Object.create(options); | ||
| options.wrapped = true; | ||
| } | ||
| this.elementProperties.set(name, options); | ||
@@ -305,8 +318,6 @@ if (!options.noAccessor) { | ||
| return { | ||
| get() { | ||
| return get?.call(this); | ||
| }, | ||
| get, | ||
| set(value) { | ||
| const oldValue = get?.call(this); | ||
| set.call(this, value); | ||
| set?.call(this, value); | ||
| this.requestUpdate(name, oldValue, options); | ||
@@ -494,3 +505,3 @@ }, | ||
| this._$changedProperties = new Map(); | ||
| // This enqueues a microtask that ust run before the first update, so it | ||
| // This enqueues a microtask that must run before the first update, so it | ||
| // must be called before requestUpdate() | ||
@@ -533,9 +544,3 @@ this.__saveInstanceProperties(); | ||
| * The properties are stored in a Map which is played back after the | ||
| * constructor runs. Note, on very old versions of Safari (<=9) or Chrome | ||
| * (<=41), properties created for native platform properties like (`id` or | ||
| * `name`) may not have default values set in the element constructor. On | ||
| * these browsers native properties appear on instances and therefore their | ||
| * default value will overwrite any element default (e.g. if the element sets | ||
| * this.id = 'id' in the constructor, the 'id' will become '' since this is | ||
| * the native platform default). | ||
| * constructor runs. | ||
| */ | ||
@@ -607,3 +612,3 @@ __saveInstanceProperties() { | ||
| * | ||
| * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks) | ||
| * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes) | ||
| * on MDN for more information about the `attributeChangedCallback`. | ||
@@ -669,5 +674,7 @@ * @category attributes | ||
| this.__reflectingProperty = propName; | ||
| this[propName] = converter.fromAttribute(value, options.type | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| ); | ||
| this[propName] = | ||
| converter.fromAttribute(value, options.type) ?? | ||
| this.__defaultValues?.get(propName) ?? | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| null; | ||
| // mark state not reflecting | ||
@@ -697,6 +704,17 @@ this.__reflectingProperty = null; | ||
| } | ||
| options ??= this.constructor.getPropertyOptions(name); | ||
| const hasChanged = options.hasChanged ?? notEqual; | ||
| const ctor = this.constructor; | ||
| const newValue = this[name]; | ||
| if (hasChanged(newValue, oldValue)) { | ||
| options ??= ctor.getPropertyOptions(name); | ||
| const changed = (options.hasChanged ?? notEqual)(newValue, oldValue) || | ||
| // When there is no change, check a corner case that can occur when | ||
| // 1. there's a initial value which was not reflected | ||
| // 2. the property is subsequently set to this value. | ||
| // For example, `prop: {useDefault: true, reflect: true}` | ||
| // and el.prop = 'foo'. This should be considered a change if the | ||
| // attribute is not set because we will now reflect the property to the attribute. | ||
| (options.useDefault && | ||
| options.reflect && | ||
| newValue === this.__defaultValues?.get(name) && | ||
| !this.hasAttribute(ctor.__attributeNameForProperty(name, options))); | ||
| if (changed) { | ||
| this._$changeProperty(name, oldValue, options); | ||
@@ -716,6 +734,21 @@ } | ||
| */ | ||
| _$changeProperty(name, oldValue, options) { | ||
| _$changeProperty(name, oldValue, { useDefault, reflect, wrapped }, initializeValue) { | ||
| // Record default value when useDefault is used. This allows us to | ||
| // restore this value when the attribute is removed. | ||
| if (useDefault && !(this.__defaultValues ??= new Map()).has(name)) { | ||
| this.__defaultValues.set(name, initializeValue ?? oldValue ?? this[name]); | ||
| // if this is not wrapping an accessor, it must be an initial setting | ||
| // and in this case we do not want to record the change or reflect. | ||
| if (wrapped !== true || initializeValue !== undefined) { | ||
| return; | ||
| } | ||
| } | ||
| // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set( | ||
| // vs just Map.set() | ||
| if (!this._$changedProperties.has(name)) { | ||
| // On the initial change, the old value should be `undefined`, except | ||
| // with `useDefault` | ||
| if (!this.hasUpdated && !useDefault) { | ||
| oldValue = undefined; | ||
| } | ||
| this._$changedProperties.set(name, oldValue); | ||
@@ -727,3 +760,3 @@ } | ||
| // attribute + property reflects correctly. | ||
| if (options.reflect === true && this.__reflectingProperty !== name) { | ||
| if (reflect === true && this.__reflectingProperty !== name) { | ||
| (this.__reflectingProperties ??= new Set()).add(name); | ||
@@ -837,10 +870,9 @@ } | ||
| // Trigger initial value reflection and populate the initial | ||
| // changedProperties map, but only for the case of experimental | ||
| // decorators on accessors, which will not have already populated the | ||
| // changedProperties map. We can't know if these accessors had | ||
| // initializers, so we just set them anyway - a difference from | ||
| // experimental decorators on fields and standard decorators on | ||
| // auto-accessors. | ||
| // For context why experimentalDecorators with auto accessors are handled | ||
| // specifically also see: | ||
| // `changedProperties` map, but only for the case of properties created | ||
| // via `createProperty` on accessors, which will not have already | ||
| // populated the `changedProperties` map since they are not set. | ||
| // We can't know if these accessors had initializers, so we just set | ||
| // them anyway - a difference from experimental decorators on fields and | ||
| // standard decorators on auto-accessors. | ||
| // For context see: | ||
| // https://github.com/lit/lit/pull/4183#issuecomment-1711959635 | ||
@@ -851,6 +883,8 @@ const elementProperties = this.constructor | ||
| for (const [p, options] of elementProperties) { | ||
| if (options.wrapped === true && | ||
| const { wrapped } = options; | ||
| const value = this[p]; | ||
| if (wrapped === true && | ||
| !this._$changedProperties.has(p) && | ||
| this[p] !== undefined) { | ||
| this._$changeProperty(p, this[p], options); | ||
| value !== undefined) { | ||
| this._$changeProperty(p, undefined, options, value); | ||
| } | ||
@@ -997,3 +1031,3 @@ } | ||
| update(_changedProperties) { | ||
| // The forEach() expression will only run when when __reflectingProperties is | ||
| // The forEach() expression will only run when __reflectingProperties is | ||
| // defined, and it returns undefined, setting __reflectingProperties to | ||
@@ -1086,7 +1120,9 @@ // undefined | ||
| // This line will be used in regexes to search for ReactiveElement usage. | ||
| (global.reactiveElementVersions ??= []).push('2.0.4'); | ||
| (global.reactiveElementVersions ??= []).push('2.1.0'); | ||
| if (DEV_MODE && global.reactiveElementVersions.length > 1) { | ||
| issueWarning('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` + | ||
| `is not recommended.`); | ||
| queueMicrotask(() => { | ||
| issueWarning('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` + | ||
| `is not recommended.`); | ||
| }); | ||
| } | ||
| //# sourceMappingURL=reactive-element.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"css-tag.js","sources":["../src/css-tag.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n"],"names":["global","globalThis","supportsAdoptingStyleSheets","ShadowRoot","undefined","ShadyCSS","nativeShadow","Document","prototype","CSSStyleSheet","constructionToken","Symbol","cssTagCache","WeakMap","CSSResult","constructor","cssText","strings","safeToken","this","Error","_strings","styleSheet","_styleSheet","cacheable","length","get","replaceSync","set","toString","unsafeCSS","value","String","css","values","reduce","acc","v","idx","textFromCSSResult","adoptStyles","renderRoot","styles","adoptedStyleSheets","map","s","style","document","createElement","nonce","setAttribute","textContent","appendChild","getCompatibleStyle","sheet","rule","cssRules","cssResultFromStyleSheet"],"mappings":";;;;;AASA,MAAMA,EAASC,WAKFC,EACXF,EAAOG,kBACcC,IAApBJ,EAAOK,UAA0BL,EAAOK,SAASC,eAClD,uBAAwBC,SAASC,WACjC,YAAaC,cAAcD,UAkBvBE,EAAoBC,SAEpBC,EAAc,IAAIC,cASXC,EAOX,WAAAC,CACEC,EACAC,EACAC,GAEA,GAVFC,KAAe,cAAI,EAUbD,IAAcR,EAChB,MAAUU,MACR,qEAGJD,KAAKH,QAAUA,EACfG,KAAKE,EAAWJ,CACjB,CAID,cAAIK,GAGF,IAAIA,EAAaH,KAAKI,EACtB,MAAMN,EAAUE,KAAKE,EACrB,GAAInB,QAA8CE,IAAfkB,EAA0B,CAC3D,MAAME,OAAwBpB,IAAZa,GAA4C,IAAnBA,EAAQQ,OAC/CD,IACFF,EAAaV,EAAYc,IAAIT,SAEZb,IAAfkB,KACDH,KAAKI,EAAcD,EAAa,IAAIb,eAAiBkB,YACpDR,KAAKH,SAEHQ,GACFZ,EAAYgB,IAAIX,EAASK,GAG9B,CACD,OAAOA,CACR,CAED,QAAAO,GACE,OAAOV,KAAKH,OACb,EAWH,MAsBac,EAAaC,GACxB,IAAKjB,EACc,iBAAViB,EAAqBA,EAAeA,EAAPC,QACpC5B,EACAM,GAWSuB,EAAM,CACjBhB,KACGiB,KAEH,MAAMlB,EACe,IAAnBC,EAAQQ,OACJR,EAAQ,GACRiB,EAAOC,QACL,CAACC,EAAKC,EAAGC,IAAQF,EA7CD,CAACL,IAEzB,IAA6C,IAAxCA,EAAkC,aACrC,OAAQA,EAAoBf,QACvB,GAAqB,iBAAVe,EAChB,OAAOA,EAEP,MAAUX,MACR,mEACKW,EADL,uFAIH,EAiC8BQ,CAAkBF,GAAKpB,EAAQqB,EAAM,IAC5DrB,EAAQ,IAEhB,OAAO,IAAKH,EACVE,EACAC,EACAP,EACD,EAYU8B,EAAc,CACzBC,EACAC,KAEA,GAAIxC,EACDuC,EAA0BE,mBAAqBD,EAAOE,KAAKC,GAC1DA,aAAapC,cAAgBoC,EAAIA,EAAEvB,kBAGrC,IAAK,MAAMuB,KAAKH,EAAQ,CACtB,MAAMI,EAAQC,SAASC,cAAc,SAE/BC,EAASjD,EAAyB,cAC1BI,IAAV6C,GACFH,EAAMI,aAAa,QAASD,GAE9BH,EAAMK,YAAeN,EAAgB7B,QACrCyB,EAAWW,YAAYN,EACxB,CACF,EAWUO,EACXnD,QACuCE,IAAzBJ,EAAOS,cAChBoC,GAAyBA,EACzBA,GACCA,aAAapC,cAbW,CAAC6C,IAC/B,IAAItC,EAAU,GACd,IAAK,MAAMuC,KAAQD,EAAME,SACvBxC,GAAWuC,EAAKvC,QAElB,OAAOc,EAAUd,EAAQ,EAQUyC,CAAwBZ,GAAKA"} | ||
| {"version":3,"file":"css-tag.js","sources":["../src/css-tag.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n"],"names":["global","globalThis","supportsAdoptingStyleSheets","ShadowRoot","undefined","ShadyCSS","nativeShadow","Document","prototype","CSSStyleSheet","constructionToken","Symbol","cssTagCache","WeakMap","CSSResult","constructor","cssText","strings","safeToken","this","Error","_strings","styleSheet","_styleSheet","cacheable","length","get","replaceSync","set","toString","unsafeCSS","value","String","css","values","reduce","acc","v","idx","textFromCSSResult","adoptStyles","renderRoot","styles","adoptedStyleSheets","map","s","style","document","createElement","nonce","setAttribute","textContent","appendChild","getCompatibleStyle","sheet","rule","cssRules","cssResultFromStyleSheet"],"mappings":";;;;;AASA,MAAMA,EAASC,WAKFC,EACXF,EAAOG,kBACcC,IAApBJ,EAAOK,UAA0BL,EAAOK,SAASC,e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Ac,SAE/BC,EAASjD,EAAyB,cAC1BI,IAAV6C,GACFH,EAAMI,aAAa,QAASD,GAE9BH,EAAMK,YAAeN,EAAgB7B,QACrCyB,EAAWW,YAAYN,EACxB,CACF,EAWUO,EACXnD,QACuCE,IAAzBJ,EAAOS,cAChBoC,GAAyBA,EACzBA,GACCA,aAAapC,cAbW,CAAC6C,IAC/B,IAAItC,EAAU,GACd,IAAK,MAAMuC,KAAQD,EAAME,SACvBxC,GAAWuC,EAAKvC,QAElB,OAAOc,EAAUd,EAAQ,EAQUyC,CAAwBZ,GAAKA"} |
@@ -6,3 +6,3 @@ import{defaultConverter as t,notEqual as e}from"../reactive-element.js"; | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),"accessor"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error("Unsupported decorator location: "+n)};function n(t){return(e,o)=>"object"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty}; | ||
| */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=!0),s.set(r.name,t),"accessor"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error("Unsupported decorator location: "+n)};function n(t){return(e,o)=>"object"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty}; | ||
| //# sourceMappingURL=property.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"property.js","sources":["../../src/decorators/property.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(\n name,\n hasOwnProperty ? {...options, wrapped: true} : options\n );\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"],"names":["defaultPropertyDeclaration","attribute","type","String","converter","defaultConverter","reflect","hasChanged","notEqual","standardProperty","options","target","context","kind","metadata","properties","globalThis","litPropertyMetadata","get","undefined","set","Map","name","v","oldValue","call","this","requestUpdate","init","_$changeProperty","value","Error","property","protoOrTarget","nameOrContext","proto","hasOwnProperty","constructor","createProperty","wrapped","Object","getOwnPropertyDescriptor","legacyProperty"],"mappings":";;;;;GAkEA,MAuBMA,EAAkD,CACtDC,WAAW,EACXC,KAAMC,OACNC,UAAWC,EACXC,SAAS,EACTC,WAAYC,GAaDC,EAAmB,CAC9BC,EAA+BV,EAC/BW,EACAC,KAEA,MAAMC,KAACA,EAAIC,SAAEA,GAAYF,EAazB,IAAIG,EAAaC,WAAWC,oBAAoBC,IAAIJ,GAMpD,QALmBK,IAAfJ,GACFC,WAAWC,oBAAoBG,IAAIN,EAAWC,EAAa,IAAIM,KAEjEN,EAAWK,IAAIR,EAAQU,KAAMZ,GAEhB,aAATG,EAAqB,CAIvB,MAAMS,KAACA,GAAQV,EACf,MAAO,CACL,GAAAQ,CAA2BG,GACzB,MAAMC,EACJb,EACAO,IAAIO,KAAKC,MACVf,EAA8CS,IAAIK,KACjDC,KACAH,GAEFG,KAAKC,cAAcL,EAAME,EAAUd,EACpC,EACD,IAAAkB,CAA4BL,GAI1B,YAHUJ,IAANI,GACFG,KAAKG,EAAiBP,OAAMH,EAAWT,GAElCa,CACR,EAEJ,CAAM,GAAa,WAATV,EAAmB,CAC5B,MAAMS,KAACA,GAAQV,EACf,OAAO,SAAiCkB,GACtC,MAAMN,EAAWE,KAAKJ,GACrBX,EAA8Bc,KAAKC,KAAMI,GAC1CJ,KAAKC,cAAcL,EAAME,EAAUd,EACrC,CACD,CACD,MAAUqB,MAAM,mCAAmClB,EAAO,EAmCtD,SAAUmB,EAAStB,GACvB,MAAO,CACLuB,EAIAC,IAO2B,iBAAlBA,EACHzB,EACEC,EACAuB,EAGAC,GAtJW,EACrBxB,EACAyB,EACAb,KAEA,MAAMc,EAAiBD,EAAMC,eAAed,GAU5C,OATCa,EAAME,YAAuCC,eAC5ChB,EACAc,EAAiB,IAAI1B,EAAS6B,SAAS,GAAQ7B,GAO1C0B,EACHI,OAAOC,yBAAyBN,EAAOb,QACvCH,CAAS,EAuILuB,CACEhC,EACAuB,EACAC,EAIZ"} | ||
| {"version":3,"file":"property.js","sources":["../../src/decorators/property.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(name, options);\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n if (kind === 'setter') {\n options = Object.create(options);\n options.wrapped = true;\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options, v);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"],"names":["defaultPropertyDeclaration","attribute","type","String","converter","defaultConverter","reflect","hasChanged","notEqual","standardProperty","options","target","context","kind","metadata","properties","globalThis","litPropertyMetadata","get","undefined","set","Map","Object","create","wrapped","name","v","oldValue","call","this","requestUpdate","init","_$changeProperty","value","Error","property","protoOrTarget","nameOrContext","proto","hasOwnProperty","constructor","createProperty","getOwnPropertyDescriptor","legacyProperty"],"mappings":";;;;;GAwEA,MAoBMA,EAAkD,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["../../src/decorators/query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"],"names":["query","selector","cache","protoOrTarget","nameOrContext","descriptor","doQuery","el","renderRoot","querySelector","get","set","key","Symbol","this","v","desc","result","call","undefined","hasUpdated"],"mappings":";;;;;GA+EgB,SAAAA,EAAMC,EAAkBC,GACtC,OACEC,EACAC,EACAC,KAEA,MAAMC,EAAWC,GACCA,EAAGC,YAAYC,cAAcR,IAAa,KAoB5D,GAAIC,EAAO,CAOT,MAAMQ,IAACA,EAAGC,IAAEA,GACe,iBAAlBP,EACHD,EACAE,GACA,MACE,MAAMO,EAEFC,SAIJ,MAAO,CACL,GAAAH,GACE,OAAQI,KAAmBF,EAC5B,EACD,GAAAD,CAAII,GACDD,KAAmBF,GAAOG,CAC5B,EAEJ,EAfD,GAgBN,OAAOC,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,IAAIO,EAAYP,EAAKQ,KAAKJ,MAO1B,YANeK,IAAXF,IACFA,EAASX,EAAQQ,OACF,OAAXG,GAAmBH,KAAKM,aAC1BT,EAAKO,KAAKJ,KAAMG,IAGbA,CACR,GAEJ,CAGC,OAAOD,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,OAAOJ,EAAQQ,KAChB,GAGN,CACH"} | ||
| {"version":3,"file":"query.js","sources":["../../src/decorators/query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"],"names":["query","selector","cache","protoOrTarget","nameOrContext","descriptor","doQuery","el","renderRoot","querySelector","get","set","key","Symbol","this","v","desc","result","call","undefined","hasUpdated"],"mappings":";;;;;GAqFgB,SAAAA,EAAMC,EAAkBC,GACtC,OACEC,EACAC,EACAC,KAEA,MAAMC,EAAWC,GACCA,EAAGC,YAAYC,cAAcR,IAAa,KAoB5D,GAAIC,EAAO,CAOT,MAAMQ,IAACA,EAAGC,IAAEA,GACe,iBAAlBP,EACHD,EACAE,GACA,MACE,MAAMO,EAEFC,SAIJ,MAAO,CACL,GAAAH,GACE,OAAQI,KAAmBF,EAC5B,EACD,GAAAD,CAAII,GACDD,KAAmBF,GAAOG,CAC5B,EAEJ,EAfD,GAgBN,OAAOC,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,IAAIO,EAAYP,EAAKQ,KAAKJ,MAO1B,YANeK,IAAXF,IACFA,EAASX,EAAQQ,OACF,OAAXG,GAAmBH,KAAKM,aAC1BT,EAAKO,KAAKJ,KAAMG,IAGbA,CACR,GAEJ,CAGC,OAAOD,EAAKb,EAAeC,EAAe,CACxC,GAAAM,GACE,OAAOJ,EAAQQ,KAChB,GAGN,CACH"} |
@@ -98,3 +98,3 @@ /** | ||
| * available but `adoptedStyleSheets` is not, styles are appended to the | ||
| * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets). | ||
| * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets). | ||
| * Note, when shimming is used, any styles that are subsequently placed into | ||
@@ -101,0 +101,0 @@ * the shadowRoot should be placed *before* any shimmed adopted styles. This |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"css-tag.js","sources":["../../src/css-tag.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n"],"names":[],"mappings":"AAAA;;;;AAIG;AAIH;AACA,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B;;AAEG;AACU,MAAA,2BAA2B,GACtC,MAAM,CAAC,UAAU;KAChB,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC/D,oBAAoB,IAAI,QAAQ,CAAC,SAAS;AAC1C,IAAA,SAAS,IAAI,aAAa,CAAC,UAAU;AAkBvC,MAAM,iBAAiB,GAAG,MAAM,EAAE,CAAC;AAEnC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAuC,CAAC;AAEvE;;;;;;AAMG;MACU,SAAS,CAAA;AAOpB,IAAA,WAAA,CACE,OAAe,EACf,OAAyC,EACzC,SAAiB,EAAA;;AARnB,QAAA,IAAA,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;AAUtB,QAAA,IAAI,SAAS,KAAK,iBAAiB,EAAE;AACnC,YAAA,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;SACH;AACD,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;KACzB;;;AAID,IAAA,IAAI,UAAU,GAAA;;;AAGZ,QAAA,IAAI,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;AAClC,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;AAC9B,QAAA,IAAI,2BAA2B,IAAI,UAAU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OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;KACzB;AACD,IAAA,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAC7B,2BAA2B;AAC3B,KAAc,MAAM,CAAC,aAAa,KAAK,SAAS,CAAC;AAC/C,MAAE,CAAC,CAAoB,KAAK,CAAC;MAC3B,CAAC,CAAoB,KACnB,CAAC,YAAY,aAAa,GAAG,uBAAuB,CAAC,CAAC,CAAC,GAAG;;;;"} | ||
| {"version":3,"file":"css-tag.js","sources":["../../src/css-tag.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof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CAAC,YAAY,aAAa,GAAG,uBAAuB,CAAC,CAAC,CAAC,GAAG;;;;"} |
@@ -8,2 +8,8 @@ import { defaultConverter, notEqual } from '../reactive-element.js'; | ||
| */ | ||
| /* | ||
| * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all | ||
| * property decorators (but not class decorators) in this file that have | ||
| * an @ExportDecoratedItems annotation must be defined as a regular function, | ||
| * not an arrow function. | ||
| */ | ||
| let issueWarning; | ||
@@ -13,9 +19,14 @@ { | ||
| // are loaded. | ||
| const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set()); | ||
| // Issue a warning, if we haven't already. | ||
| globalThis.litIssuedWarnings ??= new Set(); | ||
| /** | ||
| * Issue a warning if we haven't already, based either on `code` or `warning`. | ||
| * Warnings are disabled automatically only by `warning`; disabling via `code` | ||
| * can be done by users. | ||
| */ | ||
| issueWarning = (code, warning) => { | ||
| warning += ` See https://lit.dev/msg/${code} for more information.`; | ||
| if (!issuedWarnings.has(warning)) { | ||
| if (!globalThis.litIssuedWarnings.has(warning) && | ||
| !globalThis.litIssuedWarnings.has(code)) { | ||
| console.warn(warning); | ||
| issuedWarnings.add(warning); | ||
| globalThis.litIssuedWarnings.add(warning); | ||
| } | ||
@@ -26,3 +37,3 @@ }; | ||
| const hasOwnProperty = proto.hasOwnProperty(name); | ||
| proto.constructor.createProperty(name, hasOwnProperty ? { ...options, wrapped: true } : options); | ||
| proto.constructor.createProperty(name, options); | ||
| // For accessors (which have a descriptor on the prototype) we need to | ||
@@ -64,2 +75,6 @@ // return a descriptor, otherwise TypeScript overwrites the descriptor we | ||
| } | ||
| if (kind === 'setter') { | ||
| options = Object.create(options); | ||
| options.wrapped = true; | ||
| } | ||
| properties.set(context.name, options); | ||
@@ -79,3 +94,3 @@ if (kind === 'accessor') { | ||
| if (v !== undefined) { | ||
| this._$changeProperty(name, undefined, options); | ||
| this._$changeProperty(name, undefined, options, v); | ||
| } | ||
@@ -82,0 +97,0 @@ return v; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"property.js","sources":["../../../src/decorators/property.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(\n name,\n hasOwnProperty ? {...options, wrapped: true} : options\n );\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AAmBH,IAAI,YAAqD,CAAC;AAE5C;;;IAGZ,MAAM,cAAc,IACjB,UAAU,CAAC,iBAAiB,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;;AAG/C,IAAA,YAAY,GAAG,CAAC,IAAY,EAAE,OAAe,KAAI;AAC/C,QAAA,OAAO,IAAI,CAAA,yBAAA,EAA4B,IAAI,CAAA,sBAAA,CAAwB,CAAC;QACpE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;AAChC,YAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtB,YAAA,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SAC7B;AACH,KAAC,CAAC;AACJ,CAAC;AA2BD,MAAM,cAAc,GAAG,CACrB,OAAwC,EACxC,KAAa,EACb,IAAiB,KACf;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACjD,KAAK,CAAC,WAAsC,CAAC,cAAc,CAC1D,IAAI,EACJ,cAAc,GAAG,EAAC,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,GAAG,OAAO,CACvD,CAAC;;;;;;AAMF,IAAA,OAAO,cAAc;UACjB,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC;UAC5C,SAAS,CAAC;AAChB,CAAC,CAAC;AAEF;AACA;AACA;AACA,MAAM,0BAA0B,GAAwB;AACtD,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,SAAS,EAAE,gBAAgB;AAC3B,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,UAAU,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AC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;iBACjD;AACD,gBAAA,OAAO,CAAC,CAAC;aACV;SAC+C,CAAC;KACpD;AAAM,SAAA,IAAI,IAAI,KAAK,QAAQ,EAAE;AAC5B,QAAA,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,CAAC;AACvB,QAAA,OAAO,UAAiC,KAAQ,EAAA;AAC9C,YAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAA6B,CAAC,CAAC;AACpD,YAAA,MAA6B,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACjD,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,SAA2C,CAAC;KAC7C;AACD,IAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,CAAA,CAAE,CAAC,CAAC;AAC7D,EAAE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACG,SAAU,QAAQ,CAAC,OAA6B,EAAA;IACpD,OAAO,CACL,aAGwB,EACxB,aAGqC;;SAE9B;AACP,QAAA,QACE,OAAO,aAAa,KAAK,QAAQ;cAC7B,gBAAgB,CACd,OAAO,EACP,aAEwB,EACxB,aAA8C,CAC/C;cACD,cAAc,CACZ,OAAO,EACP,aAAuB,EACvB,aAA4B,CAC7B,EACgB;AACzB,KAAC,CAAC;AACJ;;;;"} | ||
| {"version":3,"file":"property.js","sources":["../../../src/decorators/property.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(name, options);\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n if (kind === 'setter') {\n options = Object.create(options);\n options.wrapped = true;\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options, v);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AAEH;;;;;AAKG;AAYH,IAAI,YAAqD,CAAC;AAE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,CAAC,CAAC;iBACpD;AACD,gBAAA,OAAO,CAAC,CAAC;aACV;SAC+C,CAAC;KACpD;AAAM,SAAA,IAAI,IAAI,KAAK,QAAQ,EAAE;AAC5B,QAAA,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,CAAC;AACvB,QAAA,OAAO,UAAiC,KAAQ,EAAA;AAC9C,YAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAA6B,CAAC,CAAC;AACpD,YAAA,MAA6B,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACjD,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,SAA2C,CAAC;KAC7C;AACD,IAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,CAAA,CAAE,CAAC,CAAC;AAC7D,EAAE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACG,SAAU,QAAQ,CAAC,OAA6B,EAAA;IACpD,OAAO,CACL,aAGwB,EACxB,aAGqC;;SAE9B;AACP,QAAA,QACE,OAAO,aAAa,KAAK,QAAQ;cAC7B,gBAAgB,CACd,OAAO,EACP,aAEwB,EACxB,aAA8C,CAC/C;cACD,cAAc,CACZ,OAAO,EACP,aAAuB,EACvB,aAA4B,CAC7B,EACgB;AACzB,KAAC,CAAC;AACJ;;;;"} |
@@ -12,4 +12,8 @@ import { desc } from './base.js'; | ||
| // are loaded. | ||
| const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set()); | ||
| // Issue a warning, if we haven't already. | ||
| globalThis.litIssuedWarnings ??= new Set(); | ||
| /** | ||
| * Issue a warning if we haven't already, based either on `code` or `warning`. | ||
| * Warnings are disabled automatically only by `warning`; disabling via `code` | ||
| * can be done by users. | ||
| */ | ||
| issueWarning = (code, warning) => { | ||
@@ -19,5 +23,6 @@ warning += code | ||
| : ''; | ||
| if (!issuedWarnings.has(warning)) { | ||
| if (!globalThis.litIssuedWarnings.has(warning) && | ||
| !globalThis.litIssuedWarnings.has(code)) { | ||
| console.warn(warning); | ||
| issuedWarnings.add(warning); | ||
| globalThis.litIssuedWarnings.add(warning); | ||
| } | ||
@@ -24,0 +29,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"query.js","sources":["../../../src/decorators/query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AAaH,IAAI,YAAqD,CAAC;AAE5C;;;IAGZ,MAAM,cAAc,IACjB,UAAU,CAAC,iBAAiB,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;;AAG/C,IAAA,YAAY,GAAG,CAAC,IAAY,EAAE,OAAe,KAAI;AAC/C,QAAA,OAAO,IAAI,IAAI;cACX,CAA4B,yBAAA,EAAA,IAAI,CAAwB,sBAAA,CAAA;cACxD,EAAE,CAAC;QACP,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;AAChC,YAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtB,YAAA,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SAC7B;AACH,KAAC,CAAC;AACJ,CAAC;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACa,SAAA,KAAK,CAAC,QAAgB,EAAE,KAAe,EAAA;IACrD,QAAQ,CACN,aAAiD,EACjD,aAAgE,EAChE,UAA+B,KAC7B;AACF,QAAA,MAAM,OAAO,GAAG,CAAC,EAA8B,KAAO;AACpD,YAAA,MAAM,MAAM,IAAI,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAM,CAAC;AACrE,YAAA,IAAgB,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE;AAC1D,gBAAA,MAAM,IAAI,GACR,OAAO,aAAa,KAAK,QAAQ;sBAC7B,aAAa,CAAC,IAAI;sBAClB,aAAa,CAAC;AACpB,gBAAA,YAAY,CACV,EAAE,EACF,CAAA,eAAA,EAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,I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CAAC,aAAa,EAAE,aAAa,EAAE;gBACxC,GAAG,GAAA;AACD,oBAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;iBACtB;AACF,aAAA,CAAC,CAAC;SACJ;AACH,KAAC,EAAoB;AACvB;;;;"} | ||
| {"version":3,"file":"query.js","sources":["../../../src/decorators/query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport type {ReactiveElement} from '../reactive-element.js';\nimport {desc, type Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\nexport type QueryDecorator = {\n // legacy\n (\n proto: Interface<ReactiveElement>,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any;\n\n // standard\n <C extends Interface<ReactiveElement>, V extends Element | null>(\n value: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n};\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean): QueryDecorator {\n return (<C extends Interface<ReactiveElement>, V extends Element | null>(\n protoOrTarget: ClassAccessorDecoratorTarget<C, V>,\n nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>,\n descriptor?: PropertyDescriptor\n ) => {\n const doQuery = (el: Interface<ReactiveElement>): V => {\n const result = (el.renderRoot?.querySelector(selector) ?? null) as V;\n if (DEV_MODE && result === null && cache && !el.hasUpdated) {\n const name =\n typeof nameOrContext === 'object'\n ? nameOrContext.name\n : nameOrContext;\n issueWarning(\n '',\n `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +\n `flag set for selector '${selector}' has been accessed before ` +\n `the first update and returned null. This is expected if the ` +\n `renderRoot tree has not been provided beforehand (e.g. via ` +\n `Declarative Shadow DOM). Therefore the value hasn't been cached.`\n );\n }\n // TODO: if we want to allow users to assert that the query will never\n // return null, we need a new option and to throw here if the result\n // is null.\n return result;\n };\n if (cache) {\n // Accessors to wrap from either:\n // 1. The decorator target, in the case of standard decorators\n // 2. The property descriptor, in the case of experimental decorators\n // on auto-accessors.\n // 3. Functions that access our own cache-key property on the instance,\n // in the case of experimental decorators on fields.\n const {get, set} =\n typeof nameOrContext === 'object'\n ? protoOrTarget\n : descriptor ??\n (() => {\n const key = DEV_MODE\n ? Symbol(`${String(nameOrContext)} (@query() cache)`)\n : Symbol();\n type WithCache = ReactiveElement & {\n [key: symbol]: Element | null;\n };\n return {\n get() {\n return (this as WithCache)[key];\n },\n set(v) {\n (this as WithCache)[key] = v;\n },\n };\n })();\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement): V {\n let result: V = get!.call(this);\n if (result === undefined) {\n result = doQuery(this);\n if (result !== null || this.hasUpdated) {\n set!.call(this, result);\n }\n }\n return result;\n },\n });\n } else {\n // This object works as the return type for both standard and\n // experimental decorators.\n return desc(protoOrTarget, nameOrContext, {\n get(this: ReactiveElement) {\n return doQuery(this);\n },\n });\n }\n }) as QueryDecorator;\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AAaH,IAAI,YAAqD,CAAC;AAE5C;;;AAGZ,IAAA,UAAU,CAAC,iBAAiB,KAAK,IAAI,GAAG,EAAE,CAAC;AAE3C;;;;AAIG;AACH,IAAA,YAAY,GAAG,CAAC,IAAY,EAAE,OAAe,KAAI;AAC/C,QAAA,OAAO,IAAI,IAAI;cACX,CAA4B,yBAAA,EAAA,IAAI,CAAwB,sBAAA,CAAA;cACxD,EAAE,CAAC;QACP,IACE,CAAC,UAAU,CAAC,iBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC;YAC3C,CAAC,UAAU,CAAC,iBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EACxC;AACA,YAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtB,YAAA,UAAU,CAAC,iBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SAC5C;AACH,KAAC,CAAC;AACJ,CAAC;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACa,SAAA,KAAK,CAAC,QAAgB,EAAE,KAAe,EAAA;IACrD,QAAQ,CACN,aAAiD,EACjD,aAAgE,EAChE,UAA+B,KAC7B;AACF,QAAA,MAAM,OAAO,GAAG,CAAC,EAA8B,KAAO;AACpD,YAAA,MAAM,MAAM,IAAI,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAM,CAAC;AACrE,YAAA,IAAgB,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE;AAC1D,g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,EAAE;AACtC,4BAAA,GAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;yBACzB;qBACF;AACD,oBAAA,OAAO,MAAM,CAAC;iBACf;AACF,aAAA,CAAC,CAAC;SACJ;aAAM;;;AAGL,YAAA,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE;gBACxC,GAAG,GAAA;AACD,oBAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;iBACtB;AACF,aAAA,CAAC,CAAC;SACJ;AACH,KAAC,EAAoB;AACvB;;;;"} |
@@ -8,2 +8,8 @@ import { property } from './property.js'; | ||
| */ | ||
| /* | ||
| * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all | ||
| * property decorators (but not class decorators) in this file that have | ||
| * an @ExportDecoratedItems annotation must be defined as a regular function, | ||
| * not an arrow function. | ||
| */ | ||
| /** | ||
@@ -10,0 +16,0 @@ * Declares a private or protected reactive property that still triggers |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"state.js","sources":["../../../src/decorators/state.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {property} from './property.js';\n\nexport interface StateDeclaration<Type = unknown> {\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n}\n\n/**\n * @deprecated use StateDeclaration\n */\nexport type InternalPropertyDeclaration<Type = unknown> =\n StateDeclaration<Type>;\n\n/**\n * Declares a private or protected reactive property that still triggers\n * updates to the element when it changes. It does not reflect from the\n * corresponding attribute.\n *\n * Properties declared this way must not be used from HTML or HTML templating\n * systems, they're solely for properties internal to the element. These\n * properties may be renamed by optimization tools like closure compiler.\n * @category Decorator\n */\nexport function state(options?: StateDeclaration) {\n return property({\n ...options,\n // Add both `state` and `attribute` because we found a third party\n // controller that is keying off of PropertyOptions.state to determine\n // whether a field is a private internal property or not.\n state: true,\n attribute: false,\n });\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AA0BH;;;;;;;;;AASG;AACG,SAAU,KAAK,CAAC,OAA0B,EAAA;AAC9C,IAAA,OAAO,QAAQ,CAAC;AACd,QAAA,GAAG,OAAO;;;;AAIV,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,SAAS,EAAE,KAAK;AACjB,KAAA,CAAC,CAAC;AACL;;;;"} | ||
| {"version":3,"file":"state.js","sources":["../../../src/decorators/state.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {property} from './property.js';\n\nexport interface StateDeclaration<Type = unknown> {\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n}\n\n/**\n * @deprecated use StateDeclaration\n */\nexport type InternalPropertyDeclaration<Type = unknown> =\n StateDeclaration<Type>;\n\n/**\n * Declares a private or protected reactive property that still triggers\n * updates to the element when it changes. It does not reflect from the\n * corresponding attribute.\n *\n * Properties declared this way must not be used from HTML or HTML templating\n * systems, they're solely for properties internal to the element. These\n * properties may be renamed by optimization tools like closure compiler.\n * @category Decorator\n */\nexport function state(options?: StateDeclaration) {\n return property({\n ...options,\n // Add both `state` and `attribute` because we found a third party\n // controller that is keying off of PropertyOptions.state to determine\n // whether a field is a private internal property or not.\n state: true,\n attribute: false,\n });\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AAEH;;;;;AAKG;AAmBH;;;;;;;;;AASG;AACG,SAAU,KAAK,CAAC,OAA0B,EAAA;AAC9C,IAAA,OAAO,QAAQ,CAAC;AACd,QAAA,GAAG,OAAO;;;;AAIV,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,SAAS,EAAE,KAAK;AACjB,KAAA,CAAC,CAAC;AACL;;;;"} |
| import { customElements, HTMLElement } from '@lit-labs/ssr-dom-shim'; | ||
| import { getCompatibleStyle, adoptStyles } from './css-tag.js'; | ||
| export { CSSResult, adoptStyles, css, getCompatibleStyle, supportsAdoptingStyleSheets, unsafeCSS } from './css-tag.js'; | ||
| export { CSSResult, css, supportsAdoptingStyleSheets, unsafeCSS } from './css-tag.js'; | ||
@@ -27,18 +27,24 @@ // TODO (justinfagnani): Add `hasOwn` here when we ship ES2022 | ||
| // are loaded. | ||
| const issuedWarnings = (global.litIssuedWarnings ??= | ||
| new Set()); | ||
| // Issue a warning, if we haven't already. | ||
| global.litIssuedWarnings ??= new Set(); | ||
| /** | ||
| * Issue a warning if we haven't already, based either on `code` or `warning`. | ||
| * Warnings are disabled automatically only by `warning`; disabling via `code` | ||
| * can be done by users. | ||
| */ | ||
| issueWarning = (code, warning) => { | ||
| warning += ` See https://lit.dev/msg/${code} for more information.`; | ||
| if (!issuedWarnings.has(warning)) { | ||
| if (!global.litIssuedWarnings.has(warning) && | ||
| !global.litIssuedWarnings.has(code)) { | ||
| console.warn(warning); | ||
| issuedWarnings.add(warning); | ||
| global.litIssuedWarnings.add(warning); | ||
| } | ||
| }; | ||
| issueWarning('dev-mode', `Lit is in dev mode. Not recommended for production!`); | ||
| // Issue polyfill support warning. | ||
| if (global.ShadyDOM?.inUse && polyfillSupport === undefined) { | ||
| issueWarning('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` + | ||
| `the \`polyfill-support\` module has not been loaded.`); | ||
| } | ||
| queueMicrotask(() => { | ||
| issueWarning('dev-mode', `Lit is in dev mode. Not recommended for production!`); | ||
| // Issue polyfill support warning. | ||
| if (global.ShadyDOM?.inUse && polyfillSupport === undefined) { | ||
| issueWarning('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` + | ||
| `the \`polyfill-support\` module has not been loaded.`); | ||
| } | ||
| }); | ||
| } | ||
@@ -120,2 +126,3 @@ /** | ||
| reflect: false, | ||
| useDefault: false, | ||
| hasChanged: notEqual, | ||
@@ -228,2 +235,8 @@ }; | ||
| this.__prepare(); | ||
| // Whether this property is wrapping accessors. | ||
| // Helps control the initial value change and reflection logic. | ||
| if (this.prototype.hasOwnProperty(name)) { | ||
| options = Object.create(options); | ||
| options.wrapped = true; | ||
| } | ||
| this.elementProperties.set(name, options); | ||
@@ -290,8 +303,6 @@ if (!options.noAccessor) { | ||
| return { | ||
| get() { | ||
| return get?.call(this); | ||
| }, | ||
| get, | ||
| set(value) { | ||
| const oldValue = get?.call(this); | ||
| set.call(this, value); | ||
| set?.call(this, value); | ||
| this.requestUpdate(name, oldValue, options); | ||
@@ -479,3 +490,3 @@ }, | ||
| this._$changedProperties = new Map(); | ||
| // This enqueues a microtask that ust run before the first update, so it | ||
| // This enqueues a microtask that must run before the first update, so it | ||
| // must be called before requestUpdate() | ||
@@ -518,9 +529,3 @@ this.__saveInstanceProperties(); | ||
| * The properties are stored in a Map which is played back after the | ||
| * constructor runs. Note, on very old versions of Safari (<=9) or Chrome | ||
| * (<=41), properties created for native platform properties like (`id` or | ||
| * `name`) may not have default values set in the element constructor. On | ||
| * these browsers native properties appear on instances and therefore their | ||
| * default value will overwrite any element default (e.g. if the element sets | ||
| * this.id = 'id' in the constructor, the 'id' will become '' since this is | ||
| * the native platform default). | ||
| * constructor runs. | ||
| */ | ||
@@ -592,3 +597,3 @@ __saveInstanceProperties() { | ||
| * | ||
| * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks) | ||
| * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes) | ||
| * on MDN for more information about the `attributeChangedCallback`. | ||
@@ -653,5 +658,7 @@ * @category attributes | ||
| this.__reflectingProperty = propName; | ||
| this[propName] = converter.fromAttribute(value, options.type | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| ); | ||
| this[propName] = | ||
| converter.fromAttribute(value, options.type) ?? | ||
| this.__defaultValues?.get(propName) ?? | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| null; | ||
| // mark state not reflecting | ||
@@ -681,6 +688,17 @@ this.__reflectingProperty = null; | ||
| } | ||
| options ??= this.constructor.getPropertyOptions(name); | ||
| const hasChanged = options.hasChanged ?? notEqual; | ||
| const ctor = this.constructor; | ||
| const newValue = this[name]; | ||
| if (hasChanged(newValue, oldValue)) { | ||
| options ??= ctor.getPropertyOptions(name); | ||
| const changed = (options.hasChanged ?? notEqual)(newValue, oldValue) || | ||
| // When there is no change, check a corner case that can occur when | ||
| // 1. there's a initial value which was not reflected | ||
| // 2. the property is subsequently set to this value. | ||
| // For example, `prop: {useDefault: true, reflect: true}` | ||
| // and el.prop = 'foo'. This should be considered a change if the | ||
| // attribute is not set because we will now reflect the property to the attribute. | ||
| (options.useDefault && | ||
| options.reflect && | ||
| newValue === this.__defaultValues?.get(name) && | ||
| !this.hasAttribute(ctor.__attributeNameForProperty(name, options))); | ||
| if (changed) { | ||
| this._$changeProperty(name, oldValue, options); | ||
@@ -700,6 +718,21 @@ } | ||
| */ | ||
| _$changeProperty(name, oldValue, options) { | ||
| _$changeProperty(name, oldValue, { useDefault, reflect, wrapped }, initializeValue) { | ||
| // Record default value when useDefault is used. This allows us to | ||
| // restore this value when the attribute is removed. | ||
| if (useDefault && !(this.__defaultValues ??= new Map()).has(name)) { | ||
| this.__defaultValues.set(name, initializeValue ?? oldValue ?? this[name]); | ||
| // if this is not wrapping an accessor, it must be an initial setting | ||
| // and in this case we do not want to record the change or reflect. | ||
| if (wrapped !== true || initializeValue !== undefined) { | ||
| return; | ||
| } | ||
| } | ||
| // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set( | ||
| // vs just Map.set() | ||
| if (!this._$changedProperties.has(name)) { | ||
| // On the initial change, the old value should be `undefined`, except | ||
| // with `useDefault` | ||
| if (!this.hasUpdated && !useDefault) { | ||
| oldValue = undefined; | ||
| } | ||
| this._$changedProperties.set(name, oldValue); | ||
@@ -711,3 +744,3 @@ } | ||
| // attribute + property reflects correctly. | ||
| if (options.reflect === true && this.__reflectingProperty !== name) { | ||
| if (reflect === true && this.__reflectingProperty !== name) { | ||
| (this.__reflectingProperties ??= new Set()).add(name); | ||
@@ -820,10 +853,9 @@ } | ||
| // Trigger initial value reflection and populate the initial | ||
| // changedProperties map, but only for the case of experimental | ||
| // decorators on accessors, which will not have already populated the | ||
| // changedProperties map. We can't know if these accessors had | ||
| // initializers, so we just set them anyway - a difference from | ||
| // experimental decorators on fields and standard decorators on | ||
| // auto-accessors. | ||
| // For context why experimentalDecorators with auto accessors are handled | ||
| // specifically also see: | ||
| // `changedProperties` map, but only for the case of properties created | ||
| // via `createProperty` on accessors, which will not have already | ||
| // populated the `changedProperties` map since they are not set. | ||
| // We can't know if these accessors had initializers, so we just set | ||
| // them anyway - a difference from experimental decorators on fields and | ||
| // standard decorators on auto-accessors. | ||
| // For context see: | ||
| // https://github.com/lit/lit/pull/4183#issuecomment-1711959635 | ||
@@ -834,6 +866,8 @@ const elementProperties = this.constructor | ||
| for (const [p, options] of elementProperties) { | ||
| if (options.wrapped === true && | ||
| const { wrapped } = options; | ||
| const value = this[p]; | ||
| if (wrapped === true && | ||
| !this._$changedProperties.has(p) && | ||
| this[p] !== undefined) { | ||
| this._$changeProperty(p, this[p], options); | ||
| value !== undefined) { | ||
| this._$changeProperty(p, undefined, options, value); | ||
| } | ||
@@ -979,3 +1013,3 @@ } | ||
| update(_changedProperties) { | ||
| // The forEach() expression will only run when when __reflectingProperties is | ||
| // The forEach() expression will only run when __reflectingProperties is | ||
| // defined, and it returns undefined, setting __reflectingProperties to | ||
@@ -1068,9 +1102,11 @@ // undefined | ||
| // This line will be used in regexes to search for ReactiveElement usage. | ||
| (global.reactiveElementVersions ??= []).push('2.0.4'); | ||
| (global.reactiveElementVersions ??= []).push('2.1.0'); | ||
| if (global.reactiveElementVersions.length > 1) { | ||
| issueWarning('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` + | ||
| `is not recommended.`); | ||
| queueMicrotask(() => { | ||
| issueWarning('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` + | ||
| `is not recommended.`); | ||
| }); | ||
| } | ||
| export { ReactiveElement, defaultConverter, notEqual }; | ||
| export { ReactiveElement, adoptStyles, defaultConverter, getCompatibleStyle, notEqual }; | ||
| //# sourceMappingURL=reactive-element.js.map |
@@ -1,2 +0,2 @@ | ||
| import{customElements as t,HTMLElement as s}from"@lit-labs/ssr-dom-shim";import{getCompatibleStyle as i,adoptStyles as e}from"./css-tag.js";export{CSSResult,adoptStyles,css,getCompatibleStyle,supportsAdoptingStyleSheets,unsafeCSS}from"./css-tag.js";const{is:r,defineProperty:h,getOwnPropertyDescriptor:o,getOwnPropertyNames:n,getOwnPropertySymbols:a,getPrototypeOf:c}=Object,l=globalThis;l.customElements??=t;const p=l.trustedTypes,d=p?p.emptyScript:"",u=l.reactiveElementPolyfillSupport,f=(t,s)=>t,b={toAttribute(t,s){switch(s){case Boolean:t=t?d:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},y=(t,s)=>!r(t,s),m={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),l.litPropertyMetadata??=new WeakMap;class g extends(globalThis.HTMLElement??s){static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=m){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),e=this.getPropertyDescriptor(t,i,s);void 0!==e&&h(this.prototype,t,e)}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=o(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t}};return{get(){return e?.call(this)},set(s){const h=e?.call(this);r.call(this,s),this.requestUpdate(t,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??m}static _$Ei(){if(this.hasOwnProperty(f("elementProperties")))return;const t=c(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(f("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(f("properties"))){const t=this.properties,s=[...n(t),...a(t)];for(const i of s)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const s=[];if(Array.isArray(t)){const e=new Set(t.flat(1/0).reverse());for(const t of e)s.unshift(i(t))}else void 0!==t&&s.push(i(t));return s}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return e(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:b).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:b;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??y)(this[t],s))return;this.P(t,s,i)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i)}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}}g.elementStyles=[],g.shadowRootOptions={mode:"open"},g[f("elementProperties")]=new Map,g[f("finalized")]=new Map,u?.({ReactiveElement:g}),(l.reactiveElementVersions??=[]).push("2.0.4");export{g as ReactiveElement,b as defaultConverter,y as notEqual}; | ||
| import{customElements as t,HTMLElement as s}from"@lit-labs/ssr-dom-shim";import{getCompatibleStyle as i,adoptStyles as e}from"./css-tag.js";export{CSSResult,css,supportsAdoptingStyleSheets,unsafeCSS}from"./css-tag.js";const{is:h,defineProperty:r,getOwnPropertyDescriptor:o,getOwnPropertyNames:n,getOwnPropertySymbols:a,getPrototypeOf:c}=Object,l=globalThis;l.customElements??=t;const p=l.trustedTypes,d=p?p.emptyScript:"",u=l.reactiveElementPolyfillSupport,f=(t,s)=>t,b={toAttribute(t,s){switch(s){case Boolean:t=t?d:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},m=(t,s)=>!h(t,s),y={attribute:!0,type:String,converter:b,reflect:!1,useDefault:!1,hasChanged:m};Symbol.metadata??=Symbol("metadata"),l.litPropertyMetadata??=new WeakMap;class g extends(globalThis.HTMLElement??s){static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),e=this.getPropertyDescriptor(t,i,s);void 0!==e&&r(this.prototype,t,e)}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=o(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t}};return{get:e,set(s){const r=e?.call(this);h?.call(this,s),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y}static _$Ei(){if(this.hasOwnProperty(f("elementProperties")))return;const t=c(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(f("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(f("properties"))){const t=this.properties,s=[...n(t),...a(t)];for(const i of s)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const s=[];if(Array.isArray(t)){const e=new Set(t.flat(1/0).reverse());for(const t of e)s.unshift(i(t))}else void 0!==t&&s.push(i(t));return s}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return e(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:b).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:b;this._$Em=e,this[e]=h.fromAttribute(s,t.type)??this._$Ej?.get(e)??null,this._$Em=null}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??m)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),!0!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),!0===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];!0!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e)}}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM()}updated(t){}firstUpdated(t){}}g.elementStyles=[],g.shadowRootOptions={mode:"open"},g[f("elementProperties")]=new Map,g[f("finalized")]=new Map,u?.({ReactiveElement:g}),(l.reactiveElementVersions??=[]).push("2.1.0");export{g as ReactiveElement,e as adoptStyles,b as defaultConverter,i as getCompatibleStyle,m as notEqual}; | ||
| //# sourceMappingURL=reactive-element.js.map |
+18
-5
| { | ||
| "name": "@lit/reactive-element", | ||
| "version": "2.0.4", | ||
| "version": "2.1.0", | ||
| "publishConfig": { | ||
@@ -11,3 +11,3 @@ "access": "public" | ||
| "type": "git", | ||
| "url": "https://github.com/lit/lit.git", | ||
| "url": "git+https://github.com/lit/lit.git", | ||
| "directory": "packages/reactive-element" | ||
@@ -224,2 +224,3 @@ }, | ||
| "build:babel": "wireit", | ||
| "build:esbuild": "wireit", | ||
| "check-version": "wireit", | ||
@@ -322,6 +323,6 @@ "checksize": "wireit", | ||
| "build:babel": { | ||
| "command": "babel --extensions .ts src/test/std-decorators --out-dir development/test/decorators-babel", | ||
| "command": "babel --extensions .ts src/test/decorators-modern --out-dir development/test/decorators-babel", | ||
| "files": [ | ||
| ".babelrc", | ||
| "src/test/decorators/**/*.ts" | ||
| "src/test/decorators-modern/**/*.ts" | ||
| ], | ||
@@ -332,2 +333,11 @@ "output": [ | ||
| }, | ||
| "build:esbuild": { | ||
| "command": "esbuild src/test/decorators-modern/**/*.ts --outdir=development/test/decorators-esbuild --target=es2022", | ||
| "files": [ | ||
| "src/test/decorators-modern/**/*.ts" | ||
| ], | ||
| "output": [ | ||
| "development/test/decorators-esbuild" | ||
| ] | ||
| }, | ||
| "checksize": { | ||
@@ -368,2 +378,4 @@ "command": "rollup -c --environment=CHECKSIZE", | ||
| "build:ts", | ||
| "build:babel", | ||
| "build:esbuild", | ||
| "build:ts:std-decorators-tests", | ||
@@ -461,3 +473,4 @@ "../tests:build" | ||
| "@webcomponents/template": "^1.4.4", | ||
| "@webcomponents/webcomponentsjs": "^2.8.0" | ||
| "@webcomponents/webcomponentsjs": "^2.8.0", | ||
| "esbuild": "^0.21.3" | ||
| }, | ||
@@ -464,0 +477,0 @@ "typings": "reactive-element.d.ts", |
@@ -119,2 +119,20 @@ /** | ||
| readonly noAccessor?: boolean; | ||
| /** | ||
| * When `true`, uses the initial value of the property as the default value, | ||
| * which changes how attributes are handled: | ||
| * - The initial value does *not* reflect, even if the `reflect` option is `true`. | ||
| * Subsequent changes to the property will reflect, even if they are equal to the | ||
| * default value. | ||
| * - When the attribute is removed, the property is set to the default value | ||
| * - The initial value will not trigger an old value in the `changedProperties` map | ||
| * argument to update lifecycle methods. | ||
| * | ||
| * When set, properties must be initialized, either with a field initializer, or an | ||
| * assignment in the constructor. Not initializing the property may lead to | ||
| * improper handling of subsequent property assignments. | ||
| * | ||
| * While this behavior is opt-in, most properties that reflect to attributes should | ||
| * use `useDefault: true` so that their initial values do not reflect. | ||
| */ | ||
| useDefault?: boolean; | ||
| } | ||
@@ -494,2 +512,7 @@ /** | ||
| /** | ||
| * Records property default values when the | ||
| * `useDefault` option is used. | ||
| */ | ||
| private __defaultValues?; | ||
| /** | ||
| * Properties that should be reflected when updated. | ||
@@ -531,9 +554,3 @@ */ | ||
| * The properties are stored in a Map which is played back after the | ||
| * constructor runs. Note, on very old versions of Safari (<=9) or Chrome | ||
| * (<=41), properties created for native platform properties like (`id` or | ||
| * `name`) may not have default values set in the element constructor. On | ||
| * these browsers native properties appear on instances and therefore their | ||
| * default value will overwrite any element default (e.g. if the element sets | ||
| * this.id = 'id' in the constructor, the 'id' will become '' since this is | ||
| * the native platform default). | ||
| * constructor runs. | ||
| */ | ||
@@ -579,3 +596,3 @@ private __saveInstanceProperties; | ||
| * | ||
| * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks) | ||
| * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes) | ||
| * on MDN for more information about the `attributeChangedCallback`. | ||
@@ -582,0 +599,0 @@ * @category attributes |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"reactive-element.d.ts","sourceRoot":"","sources":["../src/reactive-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAGL,cAAc,EACd,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAKlC,cAAc,cAAc,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAiFlC;;;;;GAKG;AAEH,yBAAiB,gBAAgB,CAAC;IAChC;;;;;;;;OAQG;IAEH,UAAiB,QAAQ,CAAC;QACxB,KAAY,KAAK,GAAG,MAAM,CAAC;QAC3B,UAAiB,MA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optStyles as s}from"./css-tag.js";export{CSSResult,adoptStyles,css,getCompatibleStyle,supportsAdoptingStyleSheets,unsafeCSS}from"./css-tag.js"; | ||
| import{getCompatibleStyle as t,adoptStyles as s}from"./css-tag.js";export{CSSResult,css,supportsAdoptingStyleSheets,unsafeCSS}from"./css-tag.js"; | ||
| /** | ||
@@ -6,3 +6,3 @@ * @license | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */const{is:i,defineProperty:e,getOwnPropertyDescriptor:r,getOwnPropertyNames:h,getOwnPropertySymbols:o,getPrototypeOf:n}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:"",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},f=(t,s)=>!i(t,s),y={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:f};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e(this.prototype,t,r)}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t}};return{get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y}static _$Ei(){if(this.hasOwnProperty(d("elementProperties")))return;const t=n(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(d("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d("properties"))){const t=this.properties,s=[...h(t),...o(t)];for(const i of s)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(t(s))}else void 0!==s&&i.push(t(s));return i}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f)(this[t],s))return;this.P(t,s,i)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i)}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}}b.elementStyles=[],b.shadowRootOptions={mode:"open"},b[d("elementProperties")]=new Map,b[d("finalized")]=new Map,p?.({ReactiveElement:b}),(a.reactiveElementVersions??=[]).push("2.0.4");export{b as ReactiveElement,u as defaultConverter,f as notEqual}; | ||
| */const{is:i,defineProperty:e,getOwnPropertyDescriptor:h,getOwnPropertyNames:r,getOwnPropertySymbols:o,getPrototypeOf:n}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:"",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},f=(t,s)=>!i(t,s),b={attribute:!0,type:String,converter:u,reflect:!1,useDefault:!1,hasChanged:f};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e(this.prototype,t,h)}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t}};return{get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d("elementProperties")))return;const t=n(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(d("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d("properties"))){const t=this.properties,s=[...r(t),...o(t)];for(const i of s)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(t(s))}else void 0!==s&&i.push(t(s));return i}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e,this[e]=h.fromAttribute(s,t.type)??this._$Ej?.get(e)??null,this._$Em=null}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),!0!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),!0===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];!0!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e)}}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM()}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[d("elementProperties")]=new Map,y[d("finalized")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push("2.1.0");export{y as ReactiveElement,s as adoptStyles,u as defaultConverter,t as getCompatibleStyle,f as notEqual}; | ||
| //# sourceMappingURL=reactive-element.js.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
862132
2.95%6700
2.29%27
-12.9%11
10%