mirror of
https://github.com/withastro/astro.git
synced 2025-03-17 23:11:29 -05:00
Adds support to regenerate client-shim.min.js
This commit is contained in:
parent
30acdcbb0d
commit
dacfbf69c5
3 changed files with 79 additions and 37 deletions
5
.changeset/four-walls-tease.md
Normal file
5
.changeset/four-walls-tease.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/lit": patch
|
||||
---
|
||||
|
||||
Adds support to regenerate client-shim.min.js
|
82
packages/integrations/lit/client-shim.min.js
vendored
82
packages/integrations/lit/client-shim.min.js
vendored
|
@ -1,19 +1,29 @@
|
|||
/** @license Copyright 2020 Google LLC (BSD-3-Clause) */
|
||||
/** Bundled JS generated from "@astrojs/lit/client-shim.js" */
|
||||
var N = Object.defineProperty;
|
||||
var g = Object.defineProperty;
|
||||
var i = (t, n) => () => (t && (n = t((t = 0))), n);
|
||||
var b = (t, n) => {
|
||||
for (var a in n) N(t, a, { get: n[a], enumerable: !0 });
|
||||
var y = (t, n) => {
|
||||
for (var l in n) g(t, l, { get: n[l], enumerable: !0 });
|
||||
};
|
||||
function s() {
|
||||
if (d === void 0) {
|
||||
let t = document.createElement('div');
|
||||
(t.innerHTML = '<div><template shadowroot="open" shadowrootmode="open"></template></div>'),
|
||||
(d = !!t.firstElementChild.shadowRoot);
|
||||
}
|
||||
return d;
|
||||
function d() {
|
||||
var t;
|
||||
return (
|
||||
s === void 0 &&
|
||||
(s = !!(
|
||||
!(
|
||||
(t = new DOMParser()
|
||||
.parseFromString(
|
||||
'<div><template shadowrootmode="open"></template></div>',
|
||||
'text/html',
|
||||
{ includeShadowRoots: !0 }
|
||||
)
|
||||
.querySelector('div')) === null || t === void 0
|
||||
) && t.shadowRoot
|
||||
)),
|
||||
s
|
||||
);
|
||||
}
|
||||
var d,
|
||||
var s,
|
||||
m = i(() => {});
|
||||
var p,
|
||||
c,
|
||||
|
@ -24,29 +34,29 @@ var p,
|
|||
(f = (t) => t.nodeType === Node.ELEMENT_NODE);
|
||||
});
|
||||
var h,
|
||||
E = i(() => {
|
||||
w = i(() => {
|
||||
m();
|
||||
u();
|
||||
h = (t) => {
|
||||
var n;
|
||||
if (s()) return;
|
||||
let a = [],
|
||||
if (d()) return;
|
||||
let l = [],
|
||||
e = t.firstElementChild;
|
||||
for (; e !== t && e !== null; )
|
||||
if (c(e)) a.push(e), (e = e.content);
|
||||
if (c(e)) l.push(e), (e = e.content);
|
||||
else if (e.firstElementChild !== null) e = e.firstElementChild;
|
||||
else if (f(e) && e.nextElementSibling !== null) e = e.nextElementSibling;
|
||||
else {
|
||||
let o;
|
||||
for (; e !== t && e !== null; )
|
||||
if (p(e)) {
|
||||
o = a.pop();
|
||||
o = l.pop();
|
||||
let r = o.parentElement,
|
||||
l = o.getAttribute('shadowroot');
|
||||
if (((e = o), l === 'open' || l === 'closed')) {
|
||||
let y = o.hasAttribute('shadowrootdelegatesfocus');
|
||||
a = o.getAttribute('shadowrootmode');
|
||||
if (((e = o), a === 'open' || a === 'closed')) {
|
||||
let x = o.hasAttribute('shadowrootdelegatesfocus');
|
||||
try {
|
||||
r.attachShadow({ mode: l, delegatesFocus: y }).append(o.content);
|
||||
r.attachShadow({ mode: a, delegatesFocus: x }).append(o.content);
|
||||
} catch {}
|
||||
} else o = void 0;
|
||||
} else {
|
||||
|
@ -55,10 +65,10 @@ var h,
|
|||
(e = r), o !== void 0 && o.parentElement.removeChild(o);
|
||||
break;
|
||||
}
|
||||
let l =
|
||||
let a =
|
||||
(n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling;
|
||||
if (l != null) {
|
||||
(e = l), o !== void 0 && o.parentElement.removeChild(o);
|
||||
if (a != null) {
|
||||
(e = a), o !== void 0 && o.parentElement.removeChild(o);
|
||||
break;
|
||||
}
|
||||
(e = e.parentElement), o !== void 0 && (o.parentElement.removeChild(o), (o = void 0));
|
||||
|
@ -66,26 +76,24 @@ var h,
|
|||
}
|
||||
};
|
||||
});
|
||||
var w = i(() => {
|
||||
E();
|
||||
});
|
||||
var v = {};
|
||||
b(v, { hasNativeDeclarativeShadowRoots: () => s, hydrateShadowRoots: () => h });
|
||||
var S = i(() => {
|
||||
m();
|
||||
var E = i(() => {
|
||||
w();
|
||||
});
|
||||
async function g() {
|
||||
var v = {};
|
||||
y(v, { hasNativeDeclarativeShadowRoots: () => d, hydrateShadowRoots: () => h });
|
||||
var S = i(() => {
|
||||
m();
|
||||
E();
|
||||
});
|
||||
async function N() {
|
||||
let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v));
|
||||
window.addEventListener('DOMContentLoaded', () => t(document.body), { once: true });
|
||||
window.addEventListener('DOMContentLoaded', () => t(document.body), { once: !0 });
|
||||
}
|
||||
var x = new DOMParser()
|
||||
var R = new DOMParser()
|
||||
.parseFromString(
|
||||
'<p><template shadowroot="open" shadowrootmode="open"></template></p>',
|
||||
'text/html',
|
||||
{
|
||||
includeShadowRoots: !0,
|
||||
}
|
||||
{ includeShadowRoots: !0 }
|
||||
)
|
||||
.querySelector('p');
|
||||
(!x || !x.shadowRoot) && g();
|
||||
R?.shadowRoot || N();
|
||||
|
|
29
packages/integrations/lit/scripts/gen.sh
Executable file
29
packages/integrations/lit/scripts/gen.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Originally, client-shim.min.sh was generated from client-shim.js and then changed manually.
|
||||
# This script regenerates client-shim.min.js. Regeneration with current dependencies shows two
|
||||
# missing changes that have been made to the bundled files since the original generation. See below.
|
||||
|
||||
# If you regenerate, check copyright & license for up-to-dateness
|
||||
# and diffs for correctness before committing the result.
|
||||
|
||||
pnpm exec esbuild --bundle --minify --format=esm < client-shim.js > client-shim.tmp.js
|
||||
COPYRIGHT=$(grep -o "Copyright 2..." client-shim.tmp.js | sort | tail -n 1 )
|
||||
sed -n '/Copyright/{N;/License/{s/\n/ /p}}'< client-shim.tmp.js | sort -u
|
||||
pnpm exec prettier -w --log-level warn client-shim.tmp.js
|
||||
sed -i '/\/\*/,$d' client-shim.tmp.js
|
||||
cat > client-shim.min.js - client-shim.tmp.js << ENDCOMMENT
|
||||
/** @license $COPYRIGHT Google LLC (BSD-3-Clause) */
|
||||
/** Bundled JS generated from "@astrojs/lit/client-shim.js" */
|
||||
ENDCOMMENT
|
||||
rm client-shim.tmp.js
|
||||
exit
|
||||
|
||||
The diff against d7f36720d4683c6c1da389a15c5ab04a6de351b4 shows different minified identifiers
|
||||
and two other diffs that come from updates of the bundled files.
|
||||
- Updated feature check:
|
||||
https://github.com/webcomponents/template-shadowroot/pull/22
|
||||
- Renaming of shadowroot to shadowrootmode:
|
||||
https://github.com/webcomponents/template-shadowroot/pull/43.
|
||||
See also [Lit] Forwards compatiblity for streaming Declarative Shadow DOM (#6055)
|
||||
|
Loading…
Add table
Reference in a new issue