timepiece/node_modules/@lit-labs/ssr-dom-shim/index.js.map

1 line
8.6 KiB
Plaintext

{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,UAAU,GAAG,IAAI,OAAO,EAG3B,CAAC;AACJ,MAAM,oBAAoB,GAAG,CAC3B,OAA6C,EAC7C,EAAE;IACF,IAAI,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;KAC9C;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,2DAA2D;AAC3D,EAAE;AACF,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAC/E,sEAAsE;AACtE,0CAA0C;AAC1C,sEAAsE;AACtE,iFAAiF;AACjF,mEAAmE;AACnE,oDAAoD;AACpD,MAAM,WAAW,GAAG,MAAM,OAAO;IAAb;QAOV,qBAAgB,GAA0B,IAAI,CAAC;QAC7C,iBAAY,GAAsB,IAAI,CAAC;QACvC,gBAAW,GAA4B,IAAI,CAAC;IA0CxD,CAAC;IAlDC,IAAI,UAAU;QACZ,OAAO,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YACpE,IAAI;YACJ,KAAK;SACN,CAAC,CAAC,CAAC;IACN,CAAC;IAKD,IAAI,UAAU;QACZ,IAAI,IAAI,CAAC,gBAAgB,KAAK,QAAQ,EAAE;YACtC,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AAExE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,qCAAqC,EAAE,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport {ElementInternalsShim} from './lib/element-internals.js';\n\nexport {\n ariaMixinAttributes,\n ElementInternals,\n HYDRATE_INTERNALS_ATTR_PREFIX,\n} from './lib/element-internals.js';\n\nconst attributes = new WeakMap<\n InstanceType<typeof HTMLElementShim>,\n Map<string, string>\n>();\nconst attributesForElement = (\n element: InstanceType<typeof HTMLElementShim>\n) => {\n let attrs = attributes.get(element);\n if (attrs === undefined) {\n attributes.set(element, (attrs = new Map()));\n }\n return attrs;\n};\n\n// The typings around the exports below are a little funky:\n//\n// 1. We want the `name` of the shim classes to match the real ones at runtime,\n// hence e.g. `class Element`.\n// 2. We can't shadow the global types with a simple class declaration, because\n// then we can't reference the global types for casting, hence e.g.\n// `const ElementShim = class Element`.\n// 3. We want to export the classes typed as the real ones, hence e.g.\n// `const ElementShimWithRealType = ElementShim as object as typeof Element;`.\n// 4. We want the exported names to match the real ones, hence e.g.\n// `export {ElementShimWithRealType as Element}`.\nconst ElementShim = class Element {\n get attributes() {\n return Array.from(attributesForElement(this)).map(([name, value]) => ({\n name,\n value,\n }));\n }\n private __shadowRootMode: null | ShadowRootMode = null;\n protected __shadowRoot: null | ShadowRoot = null;\n protected __internals: null | ElementInternals = null;\n\n get shadowRoot() {\n if (this.__shadowRootMode === 'closed') {\n return null;\n }\n return this.__shadowRoot;\n }\n setAttribute(name: string, value: unknown): void {\n // Emulate browser behavior that silently casts all values to string. E.g.\n // `42` becomes `\"42\"` and `{}` becomes `\"[object Object]\"\"`.\n attributesForElement(this).set(name, String(value));\n }\n removeAttribute(name: string) {\n attributesForElement(this).delete(name);\n }\n hasAttribute(name: string) {\n return attributesForElement(this).has(name);\n }\n attachShadow(init: ShadowRootInit): ShadowRoot {\n const shadowRoot = {host: this} as object as ShadowRoot;\n this.__shadowRootMode = init.mode;\n if (init && init.mode === 'open') {\n this.__shadowRoot = shadowRoot;\n }\n return shadowRoot;\n }\n attachInternals(): ElementInternals {\n if (this.__internals !== null) {\n throw new Error(\n `Failed to execute 'attachInternals' on 'HTMLElement': ` +\n `ElementInternals for the specified element was already attached.`\n );\n }\n const internals = new ElementInternalsShim(this as unknown as HTMLElement);\n this.__internals = internals;\n return internals as ElementInternals;\n }\n getAttribute(name: string) {\n const value = attributesForElement(this).get(name);\n return value ?? null;\n }\n};\nconst ElementShimWithRealType = ElementShim as object as typeof Element;\nexport {ElementShimWithRealType as Element};\n\nconst HTMLElementShim = class HTMLElement extends ElementShim {};\nconst HTMLElementShimWithRealType =\n HTMLElementShim as object as typeof HTMLElement;\nexport {HTMLElementShimWithRealType as HTMLElement};\n\ninterface CustomHTMLElementConstructor {\n new (): HTMLElement;\n observedAttributes?: string[];\n}\n\ntype CustomElementRegistration = {\n ctor: {new (): HTMLElement};\n observedAttributes: string[];\n};\n\nconst CustomElementRegistryShim = class CustomElementRegistry {\n private __definitions = new Map<string, CustomElementRegistration>();\n\n define(name: string, ctor: CustomHTMLElementConstructor) {\n if (this.__definitions.has(name)) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `'CustomElementRegistry' already has \"${name}\" defined. ` +\n `This may have been caused by live reload or hot module ` +\n `replacement in which case it can be safely ignored.\\n` +\n `Make sure to test your application with a production build as ` +\n `repeat registrations will throw in production.`\n );\n } else {\n throw new Error(\n `Failed to execute 'define' on 'CustomElementRegistry': ` +\n `the name \"${name}\" has already been used with this registry`\n );\n }\n }\n this.__definitions.set(name, {\n ctor,\n // Note it's important we read `observedAttributes` in case it is a getter\n // with side-effects, as is the case in Lit, where it triggers class\n // finalization.\n //\n // TODO(aomarks) To be spec compliant, we should also capture the\n // registration-time lifecycle methods like `connectedCallback`. For them\n // to be actually accessible to e.g. the Lit SSR element renderer, though,\n // we'd need to introduce a new API for accessing them (since `get` only\n // returns the constructor).\n observedAttributes: ctor.observedAttributes ?? [],\n });\n }\n\n get(name: string) {\n const definition = this.__definitions.get(name);\n return definition?.ctor;\n }\n};\nconst CustomElementRegistryShimWithRealType =\n CustomElementRegistryShim as object as typeof CustomElementRegistry;\nexport {CustomElementRegistryShimWithRealType as CustomElementRegistry};\n\nexport const customElements = new CustomElementRegistryShimWithRealType();\n"]}