From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../vendor/lit/0001-disable-terser-step.patch | 79 +++++++++++++++ .../lit/0002-use-DOMParser-not-innerHTML.patch | 43 ++++++++ .../vendor/lit/0003-Disable-source-maps.patch | 88 +++++++++++++++++ .../lit/0004-Remove-the-bundled-warning.patch | 28 ++++++ ...-Do-not-set-style-attributes-when-using-s.patch | 109 +++++++++++++++++++++ toolkit/content/vendor/lit/LICENSE | 28 ++++++ toolkit/content/vendor/lit/README.md | 46 +++++++++ toolkit/content/vendor/lit/bundle-lit.sh | 9 ++ toolkit/content/vendor/lit/lit/LICENSE | 28 ++++++ toolkit/content/vendor/lit/moz.yaml | 33 +++++++ 10 files changed, 491 insertions(+) create mode 100644 toolkit/content/vendor/lit/0001-disable-terser-step.patch create mode 100644 toolkit/content/vendor/lit/0002-use-DOMParser-not-innerHTML.patch create mode 100644 toolkit/content/vendor/lit/0003-Disable-source-maps.patch create mode 100644 toolkit/content/vendor/lit/0004-Remove-the-bundled-warning.patch create mode 100644 toolkit/content/vendor/lit/0005-Bug-1808741-Do-not-set-style-attributes-when-using-s.patch create mode 100644 toolkit/content/vendor/lit/LICENSE create mode 100644 toolkit/content/vendor/lit/README.md create mode 100755 toolkit/content/vendor/lit/bundle-lit.sh create mode 100644 toolkit/content/vendor/lit/lit/LICENSE create mode 100644 toolkit/content/vendor/lit/moz.yaml (limited to 'toolkit/content/vendor') diff --git a/toolkit/content/vendor/lit/0001-disable-terser-step.patch b/toolkit/content/vendor/lit/0001-disable-terser-step.patch new file mode 100644 index 0000000000..6bef4a33ef --- /dev/null +++ b/toolkit/content/vendor/lit/0001-disable-terser-step.patch @@ -0,0 +1,79 @@ +From d4897981e63b8be81453088cd9ab3a6edaf8fcaf Mon Sep 17 00:00:00 2001 +From: Mark Striemer +Date: Wed, 16 Nov 2022 22:54:20 -0600 +Subject: [PATCH 1/5] disable terser step + +--- + rollup-common.js | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/rollup-common.js b/rollup-common.js +index b2187328..88d222d1 100644 +--- a/rollup-common.js ++++ b/rollup-common.js +@@ -5,7 +5,7 @@ + */ + + import summary from 'rollup-plugin-summary'; +-import {terser} from 'rollup-plugin-terser'; ++// import {terser} from 'rollup-plugin-terser'; + import copy from 'rollup-plugin-copy'; + import nodeResolve from '@rollup/plugin-node-resolve'; + import sourcemaps from 'rollup-plugin-sourcemaps'; +@@ -321,7 +321,7 @@ export function litProdConfig({ + (name) => `console.log(window.${name});` + ), + ].join('\n'); +- const nameCacheSeederTerserOptions = generateTerserOptions(nameCache); ++ // const nameCacheSeederTerserOptions = generateTerserOptions(nameCache); + + const terserOptions = generateTerserOptions( + nameCache, +@@ -345,7 +345,7 @@ export function litProdConfig({ + virtual({ + [nameCacheSeederInfile]: nameCacheSeederContents, + }), +- terser(nameCacheSeederTerserOptions), ++ // terser(nameCacheSeederTerserOptions), + skipBundleOutput, + ], + }, +@@ -395,7 +395,7 @@ export function litProdConfig({ + // This plugin automatically composes the existing TypeScript -> raw JS + // sourcemap with the raw JS -> minified JS one that we're generating here. + sourcemaps(), +- terser(terserOptions), ++ // terser(terserOptions), + summary({ + showBrotliSize: true, + showGzippedSize: true, +@@ -466,7 +466,7 @@ export function litProdConfig({ + // references properties from reactive-element which will + // otherwise have different names. The default export that + // lit-element will use is minified. +- terser(terserOptions), ++ // terser(terserOptions), + summary({ + showBrotliSize: true, + showGzippedSize: true, +@@ -524,7 +524,7 @@ const litMonoBundleConfig = ({ + file, + output, + name, +- terserOptions, ++ // terserOptions, + format = 'umd', + sourcemapPathTransform, + // eslint-disable-next-line no-undef +@@ -563,7 +563,7 @@ const litMonoBundleConfig = ({ + // This plugin automatically composes the existing TypeScript -> raw JS + // sourcemap with the raw JS -> minified JS one that we're generating here. + sourcemaps(), +- terser(terserOptions), ++ // terser(terserOptions), + summary({ + showBrotliSize: true, + showGzippedSize: true, +-- +2.37.1 (Apple Git-137.1) + diff --git a/toolkit/content/vendor/lit/0002-use-DOMParser-not-innerHTML.patch b/toolkit/content/vendor/lit/0002-use-DOMParser-not-innerHTML.patch new file mode 100644 index 0000000000..11afcf6328 --- /dev/null +++ b/toolkit/content/vendor/lit/0002-use-DOMParser-not-innerHTML.patch @@ -0,0 +1,43 @@ +From 0d300a2e703fdcc575ce36dfd62f6c3a9887a3ff Mon Sep 17 00:00:00 2001 +From: Mark Striemer +Date: Wed, 16 Nov 2022 23:07:57 -0600 +Subject: [PATCH 2/5] use DOMParser not innerHTML= + +--- + packages/lit-html/src/lit-html.ts | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/packages/lit-html/src/lit-html.ts b/packages/lit-html/src/lit-html.ts +index 896d298b..994c24e2 100644 +--- a/packages/lit-html/src/lit-html.ts ++++ b/packages/lit-html/src/lit-html.ts +@@ -14,6 +14,8 @@ const NODE_MODE = false; + // Use window for browser builds because IE11 doesn't have globalThis. + const global = NODE_MODE ? globalThis : window; + ++const __moz_domParser = new DOMParser(); ++ + /** + * Contains types that are part of the unstable debug API. + * +@@ -1017,9 +1019,14 @@ class Template { + // Overridden via `litHtmlPolyfillSupport` to provide platform support. + /** @nocollapse */ + static createElement(html: TrustedHTML, _options?: RenderOptions) { +- const el = d.createElement('template'); +- el.innerHTML = html as unknown as string; +- return el; ++ const doc = __moz_domParser.parseFromString( ++ ``, ++ 'text/html' ++ ); ++ return document.importNode( ++ doc.querySelector('template') as HTMLTemplateElement, ++ true ++ ); + } + } + +-- +2.37.1 (Apple Git-137.1) + diff --git a/toolkit/content/vendor/lit/0003-Disable-source-maps.patch b/toolkit/content/vendor/lit/0003-Disable-source-maps.patch new file mode 100644 index 0000000000..50a44aab32 --- /dev/null +++ b/toolkit/content/vendor/lit/0003-Disable-source-maps.patch @@ -0,0 +1,88 @@ +From 28ad29d3496d10193de7a52bd8e104e183f5df7c Mon Sep 17 00:00:00 2001 +From: Mark Striemer +Date: Tue, 22 Nov 2022 18:17:01 -0600 +Subject: [PATCH 3/5] Disable source maps + +--- + rollup-common.js | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/rollup-common.js b/rollup-common.js +index 88d222d1..3f9e13b2 100644 +--- a/rollup-common.js ++++ b/rollup-common.js +@@ -8,7 +8,7 @@ import summary from 'rollup-plugin-summary'; + // import {terser} from 'rollup-plugin-terser'; + import copy from 'rollup-plugin-copy'; + import nodeResolve from '@rollup/plugin-node-resolve'; +-import sourcemaps from 'rollup-plugin-sourcemaps'; ++// import sourcemaps from 'rollup-plugin-sourcemaps'; + import replace from '@rollup/plugin-replace'; + import virtual from '@rollup/plugin-virtual'; + +@@ -358,7 +358,7 @@ export function litProdConfig({ + // Preserve existing module structure (e.g. preserve the "directives/" + // directory). + preserveModules: true, +- sourcemap: !CHECKSIZE, ++ // sourcemap: !CHECKSIZE, + }, + external, + plugins: [ +@@ -394,7 +394,7 @@ export function litProdConfig({ + }), + // This plugin automatically composes the existing TypeScript -> raw JS + // sourcemap with the raw JS -> minified JS one that we're generating here. +- sourcemaps(), ++ // sourcemaps(), + // terser(terserOptions), + summary({ + showBrotliSize: true, +@@ -434,7 +434,7 @@ export function litProdConfig({ + dir: `${outputDir}/node`, + format: 'esm', + preserveModules: true, +- sourcemap: !CHECKSIZE, ++ // sourcemap: !CHECKSIZE, + }, + external, + plugins: [ +@@ -453,7 +453,7 @@ export function litProdConfig({ + 'const ENABLE_SHADYDOM_NOPATCH = false', + }, + }), +- sourcemaps(), ++ // sourcemaps(), + // We want the production Node build to be minified because: + // + // 1. It should be very slightly faster, even in Node where bytes +@@ -496,7 +496,7 @@ export function litProdConfig({ + 'const NODE_MODE = false': 'const NODE_MODE = true', + }, + }), +- sourcemaps(), ++ // sourcemaps(), + summary({ + showBrotliSize: true, + showGzippedSize: true, +@@ -534,7 +534,7 @@ const litMonoBundleConfig = ({ + file: `${output || file}.js`, + format, + name, +- sourcemap: !CHECKSIZE, ++ // sourcemap: !CHECKSIZE, + sourcemapPathTransform, + }, + plugins: [ +@@ -562,7 +562,7 @@ const litMonoBundleConfig = ({ + }), + // This plugin automatically composes the existing TypeScript -> raw JS + // sourcemap with the raw JS -> minified JS one that we're generating here. +- sourcemaps(), ++ // sourcemaps(), + // terser(terserOptions), + summary({ + showBrotliSize: true, +-- +2.37.1 (Apple Git-137.1) + diff --git a/toolkit/content/vendor/lit/0004-Remove-the-bundled-warning.patch b/toolkit/content/vendor/lit/0004-Remove-the-bundled-warning.patch new file mode 100644 index 0000000000..0dfd669b69 --- /dev/null +++ b/toolkit/content/vendor/lit/0004-Remove-the-bundled-warning.patch @@ -0,0 +1,28 @@ +From db47e472d6f2393c58c1691d21e9bbc753b3d9da Mon Sep 17 00:00:00 2001 +From: Mark Striemer +Date: Tue, 22 Nov 2022 18:20:46 -0600 +Subject: [PATCH 4/5] Remove the bundled warning + +--- + packages/lit/src/index.all.ts | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/packages/lit/src/index.all.ts b/packages/lit/src/index.all.ts +index 1f8e5499..2bccd703 100644 +--- a/packages/lit/src/index.all.ts ++++ b/packages/lit/src/index.all.ts +@@ -37,11 +37,3 @@ export { + unsafeStatic, + withStatic, + } from './static-html.js'; +- +-if (!window.litDisableBundleWarning) { +- console.warn( +- 'Lit has been loaded from a bundle that combines all core features into ' + +- 'a single file. To reduce transfer size and parsing cost, consider ' + +- 'using the `lit` npm package directly in your project.' +- ); +-} +-- +2.37.1 (Apple Git-137.1) + diff --git a/toolkit/content/vendor/lit/0005-Bug-1808741-Do-not-set-style-attributes-when-using-s.patch b/toolkit/content/vendor/lit/0005-Bug-1808741-Do-not-set-style-attributes-when-using-s.patch new file mode 100644 index 0000000000..01a3f7eb30 --- /dev/null +++ b/toolkit/content/vendor/lit/0005-Bug-1808741-Do-not-set-style-attributes-when-using-s.patch @@ -0,0 +1,109 @@ +From 5f0afd7c556938cbf2693acf31656e9bcc01a3a5 Mon Sep 17 00:00:00 2001 +From: Mark Striemer +Date: Wed, 14 Dec 2022 15:34:57 -0600 +Subject: [PATCH 5/5] Bug 1808741 - Do not set style attributes when using + styleMap + +--- + packages/lit-html/src/directives/style-map.ts | 21 +--------- + .../src/test/directives/style-map_test.ts | 38 +------------------ + 2 files changed, 3 insertions(+), 56 deletions(-) + +diff --git a/packages/lit-html/src/directives/style-map.ts b/packages/lit-html/src/directives/style-map.ts +index 5a77c676..cd7df040 100644 +--- a/packages/lit-html/src/directives/style-map.ts ++++ b/packages/lit-html/src/directives/style-map.ts +@@ -43,21 +43,8 @@ class StyleMapDirective extends Directive { + + render(styleInfo: Readonly) { + return Object.keys(styleInfo).reduce((style, prop) => { +- const value = styleInfo[prop]; +- if (value == null) { +- return style; +- } +- // Convert property names from camel-case to dash-case, i.e.: +- // `backgroundColor` -> `background-color` +- // Vendor-prefixed names need an extra `-` appended to front: +- // `webkitAppearance` -> `-webkit-appearance` +- // Exception is any property name containing a dash, including +- // custom properties; we assume these are already dash-cased i.e.: +- // `--my-button-color` --> `--my-button-color` +- prop = prop +- .replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, '-$&') +- .toLowerCase(); +- return style + `${prop}:${value};`; ++ // Make sure we use `styleInfo` so the TypeScript checker is happy. This is really a no-op. ++ return style + prop.slice(0, 0); + }, ''); + } + +@@ -66,10 +53,6 @@ class StyleMapDirective extends Directive { + + if (this._previousStyleProperties === undefined) { + this._previousStyleProperties = new Set(); +- for (const name in styleInfo) { +- this._previousStyleProperties.add(name); +- } +- return this.render(styleInfo); + } + + // Remove old properties that no longer exist in styleInfo +diff --git a/packages/lit-html/src/test/directives/style-map_test.ts b/packages/lit-html/src/test/directives/style-map_test.ts +index 6f607e88..913f8a9e 100644 +--- a/packages/lit-html/src/test/directives/style-map_test.ts ++++ b/packages/lit-html/src/test/directives/style-map_test.ts +@@ -4,8 +4,7 @@ + * SPDX-License-Identifier: BSD-3-Clause + */ + +-import {AttributePart, html, render} from 'lit-html'; +-import {directive} from 'lit-html/directive.js'; ++import {html, render} from 'lit-html'; + import {StyleInfo, styleMap} from 'lit-html/directives/style-map.js'; + import {assert} from '@esm-bundle/chai'; + +@@ -33,41 +32,6 @@ suite('styleMap', () => { + container = document.createElement('div'); + }); + +- test('render() only properties', () => { +- // Get the StyleMapDirective class indirectly, since it's not exported +- const result = styleMap({}); +- // This property needs to remain unminified. +- const StyleMapDirective = result['_$litDirective$']; +- +- // Extend StyleMapDirective so we can test its render() method +- class TestStyleMapDirective extends StyleMapDirective { +- override update( +- _part: AttributePart, +- [styleInfo]: Parameters +- ) { +- return this.render(styleInfo); +- } +- } +- const testStyleMap = directive(TestStyleMapDirective); +- render( +- html`
`, +- container +- ); +- const div = container.firstElementChild as HTMLDivElement; +- const style = div.style; +- assert.equal(style.color, 'red'); +- assert.equal(style.backgroundColor, 'blue'); +- assert.include(['none', undefined], style.webkitAppearance); +- assert.equal(style.paddingLeft, '4px'); +- }); +- + test('first render skips undefined properties', () => { + renderStyleMap({marginTop: undefined, marginBottom: null}); + const el = container.firstElementChild as HTMLElement; +-- +2.37.1 (Apple Git-137.1) + diff --git a/toolkit/content/vendor/lit/LICENSE b/toolkit/content/vendor/lit/LICENSE new file mode 100644 index 0000000000..be7a97b60d --- /dev/null +++ b/toolkit/content/vendor/lit/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2017 Google LLC. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/toolkit/content/vendor/lit/README.md b/toolkit/content/vendor/lit/README.md new file mode 100644 index 0000000000..138c28a8b0 --- /dev/null +++ b/toolkit/content/vendor/lit/README.md @@ -0,0 +1,46 @@ +# Vendoring for lit + +[lit](https://lit.dev/) can be used to help create Web Components. + +## The lit.all.mjs bundle + +The lit package is imported in a vendoring step and the contents are extracted +into the lit.all.mjs file. This has some differences from using lit in a regular +npm project. Imports that would normally be into a specific file are pulled +directly from the lit.all.mjs file. + +eg. + +``` +// Standard npm package: +import { LitElement } from "lit"; +import { classMap } from "lit/directives/class-map.js"; + +// Using lit.all.mjs (pathing to lit.all.mjs may differ) +import { classMap, LitElement } from "../vendor/lit.all.mjs"; + +## To update the lit bundle + +Vendoring runs off of the latest tag in the https://github.com/lit/lit repo. If +the latest tag is a lit@ tag then running the vendor command will update to that +version. If the latest tag isn't for lit@, you may need to bundle manually. See +the moz.yaml file for instructions. + +### Using mach vendor + +``` +./mach vendor toolkit/content/vendor/lit/moz.yaml +hg ci -m "Update to lit@" +``` + +### Manually updating the bundle + +To manually update, you'll need to checkout a copy of lit/lit, find the tag you +want and manually run our import commands. + + 1. Clone https://github.com/lit/lit outside of moz-central + 2. Copy *.patch from this directory into the lit repo + 3. git apply *.patch + 4. npm install && npm run build + 5. Copy packages/lit/lit-all.min.js to toolkit/content/widgets/vendor/lit.all.mjs + 6. hg ci -m "Update to lit@" diff --git a/toolkit/content/vendor/lit/bundle-lit.sh b/toolkit/content/vendor/lit/bundle-lit.sh new file mode 100755 index 0000000000..532b48337f --- /dev/null +++ b/toolkit/content/vendor/lit/bundle-lit.sh @@ -0,0 +1,9 @@ +#!/bin/bash +cp *.patch lit/ +cd lit +git apply *.patch +../../../../../mach npm install +../../../../../mach npm run build +cp packages/lit/lit-all.min.js ../../../widgets/vendor/lit.all.mjs +rm -rf * .* +cp ../LICENSE . diff --git a/toolkit/content/vendor/lit/lit/LICENSE b/toolkit/content/vendor/lit/lit/LICENSE new file mode 100644 index 0000000000..be7a97b60d --- /dev/null +++ b/toolkit/content/vendor/lit/lit/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2017 Google LLC. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/toolkit/content/vendor/lit/moz.yaml b/toolkit/content/vendor/lit/moz.yaml new file mode 100644 index 0000000000..db1b7f259a --- /dev/null +++ b/toolkit/content/vendor/lit/moz.yaml @@ -0,0 +1,33 @@ +schema: 1 + +bugzilla: + product: "Toolkit" + component: "UI Widgets" + +origin: + name: "lit" + description: + "Lit is a simple library for building fast, lightweight web components." + url: "https://github.com/lit/lit" + license: "BSD-3-Clause" + release: lit@2.5.0 (2022-12-14T16:42:02-06:00). + revision: lit@2.5.0 + + +# Since this tracks the latest tag, it's possible that lit isn't the latest tag +# in lit/lit. In that case we may need to manually update lit. See README.md for +# more info. +vendoring: + url: "https://github.com/lit/lit" + source-hosting: github + tracking: tag + # lit/lit is a monorepo that publishes multiple packages. The tags for lit + # are formatted as "lit@2.5.0". + # tag-prefix: 'lit@' + + vendor-directory: toolkit/content/vendor/lit/lit + + update-actions: + - action: run-script + script: '{yaml_dir}/bundle-lit.sh' + cwd: '{yaml_dir}' -- cgit v1.2.3