Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] docs: try some ssr #4057

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@
"wireit": "^0.14.3",
"yargs": "^17.2.1"
},
"resolutions": {
"@lit-labs/observers": "2.0.2",
"@lit/reactive-element": "1.6.3",
"lit": "2.8.0",
"lit-element": "3.3.3",
"lit-html": "2.8.0"
},
"wireit": {
"build:css:watch": {
"command": "node ./tasks/watch-css.js",
Expand Down
4 changes: 3 additions & 1 deletion packages/action-button/src/ActionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ export class ActionButton extends SizedMixin(ButtonBase, {

constructor() {
super();
this.addEventListener('click', this.onClick);
if ('addEventListener' in this) {
this.addEventListener('click', this.onClick);
}
}

private onClick = (): void => {
Expand Down
8 changes: 5 additions & 3 deletions packages/button/src/ButtonBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ export class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), '', [
super();
this.proxyFocus = this.proxyFocus.bind(this);

this.addEventListener('click', this.handleClickCapture, {
capture: true,
});
if ('addEventListener' in this) {
this.addEventListener('click', this.handleClickCapture, {
capture: true,
});
}
}

public override click(): void {
Expand Down
6 changes: 5 additions & 1 deletion packages/overlay/src/slottable-request-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

export class SlottableRequestEvent extends Event {
const EventBaseClass = (typeof Event !== 'undefined'
? Event
: class {}) as unknown as typeof Event;

export class SlottableRequestEvent extends EventBaseClass {
readonly data: unknown;
readonly name: string;
readonly slotName: string;
Expand Down
8 changes: 8 additions & 0 deletions patches/@lit-labs+observers+2.0.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
diff --git a/node_modules/@lit-labs/observers/mutation-controller.js b/node_modules/@lit-labs/observers/mutation-controller.js
index 65d9a23..c41fa07 100644
--- a/node_modules/@lit-labs/observers/mutation-controller.js
+++ b/node_modules/@lit-labs/observers/mutation-controller.js
@@ -1,2 +1,2 @@
-class t{constructor(t,{target:s,config:i,callback:h,skipInitial:o}){this.t=new Set,this.o=!1,this.i=!1,this.h=t,null!==s&&this.t.add(s??t),this.l=i,this.o=o??this.o,this.callback=h,window.MutationObserver?(this.u=new MutationObserver((t=>{this.handleChanges(t),this.h.requestUpdate()})),t.addController(this)):console.warn("MutationController error: browser does not support MutationObserver.")}handleChanges(t){this.value=this.callback?.(t,this.u)}hostConnected(){for(const t of this.t)this.observe(t)}hostDisconnected(){this.disconnect()}async hostUpdated(){const t=this.u.takeRecords();(t.length||!this.o&&this.i)&&this.handleChanges(t),this.i=!1}observe(t){this.t.add(t),this.u.observe(t,this.l),this.i=!0,this.h.requestUpdate()}disconnect(){this.u.disconnect()}}export{t as MutationController};
+class t{constructor(t,{target:s,config:i,callback:h,skipInitial:o}){this.t=new Set,this.o=!1,this.i=!1,this.h=t,null!==s&&this.t.add(s??t),this.l=i,this.o=o??this.o,this.callback=h,globalThis.MutationObserver?(this.u=new MutationObserver((t=>{this.handleChanges(t),this.h.requestUpdate()})),t.addController(this)):console.warn("MutationController error: browser does not support MutationObserver.")}handleChanges(t){this.value=this.callback?.(t,this.u)}hostConnected(){for(const t of this.t)this.observe(t)}hostDisconnected(){this.disconnect()}async hostUpdated(){const t=this.u.takeRecords();(t.length||!this.o&&this.i)&&this.handleChanges(t),this.i=!1}observe(t){this.t.add(t),this.u.observe(t,this.l),this.i=!0,this.h.requestUpdate()}disconnect(){this.u.disconnect()}}export{t as MutationController};
//# sourceMappingURL=mutation-controller.js.map
22 changes: 14 additions & 8 deletions projects/documentation/.eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ governing permissions and limitations under the License.
import syntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight';
import markdownIt from 'markdown-it';
import markdownItAnchors from 'markdown-it-anchor';
import litPlugin from '@lit-labs/eleventy-plugin-lit';

const packageVersion = async function (packageName) {
let packageJSON = {};
Expand Down Expand Up @@ -39,14 +40,14 @@ export default function (eleventyConfig) {
eleventyConfig.addShortcode('packageVersion', packageVersion);
eleventyConfig.addNunjucksGlobal('WATCH_MODE', process.env.WATCH_MODE);
eleventyConfig.setUseGitIgnore(false);
eleventyConfig.addPassthroughCopy('./content/favicon.ico');
eleventyConfig.addPassthroughCopy('./content/typekit/*.woff2');
eleventyConfig.addPassthroughCopy('./content/favicon.svg');
eleventyConfig.addPassthroughCopy('./content/404.html');
eleventyConfig.addPassthroughCopy('./content/serviceWorker.js');
eleventyConfig.addPassthroughCopy('./content/images/**/*');
eleventyConfig.addPassthroughCopy('./content/manifest.webmanifest');
eleventyConfig.addPassthroughCopy('../src/**/*.css');
eleventyConfig.addPassthroughCopy('content/favicon.ico');
eleventyConfig.addPassthroughCopy('content/typekit/*.woff2');
eleventyConfig.addPassthroughCopy('content/favicon.svg');
eleventyConfig.addPassthroughCopy('content/404.html');
eleventyConfig.addPassthroughCopy('content/serviceWorker.js');
eleventyConfig.addPassthroughCopy('content/images/**/*');
eleventyConfig.addPassthroughCopy('content/manifest.webmanifest');
eleventyConfig.addPassthroughCopy('src/**/*.css');
eleventyConfig.addPlugin(syntaxHighlight, {
init: function ({ Prism }) {
Prism.languages['html-live'] = Prism.languages.html;
Expand Down Expand Up @@ -185,6 +186,11 @@ export default function (eleventyConfig) {
});
});

eleventyConfig.addPlugin(litPlugin, {
mode: 'vm',
componentModules: ['_site/src/components/layout-element.js'],
});

return {
dir: { input: 'content', output: '_site' },
passthroughFileCopy: true,
Expand Down
3 changes: 3 additions & 0 deletions projects/documentation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ src/custom-elements.json
dist/
!web-dev-server.config.js
stats.html

!src/components/*.css.ts
!**/*.css
10 changes: 6 additions & 4 deletions projects/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"devDependencies": {
"@11ty/eleventy": "^3.0.0-alpha.4",
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@lit-labs/eleventy-plugin-lit": "1.0.1",
"@open-wc/building-rollup": "^3.0.2",
"@rollup/plugin-alias": "^5.0.1",
"@rollup/plugin-commonjs": "^25.0.7",
Expand Down Expand Up @@ -80,9 +81,6 @@
},
"build:assets": {
"dependencies": [
{
"script": "build:ts"
},
{
"script": "build:move-css"
},
Expand All @@ -92,8 +90,12 @@
]
},
"build:eleventy": {
"command": "eleventy --config=.eleventy.js --incremental --quiet",
"command": "NODE_OPTIONS=--experimental-vm-modules eleventy --config=.eleventy.js --incremental --quiet",
"dependencies": [
{
"script": "build:ts",
"cascade": false
},
{
"script": "copy-docs"
}
Expand Down
1 change: 1 addition & 0 deletions projects/documentation/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default async () => {
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
minifyCSS: true,
ignoreCustomComments: [/lit-/],
/** @param {string} code */
minifyJS: (code) => Terser.minify(code).code,
}),
Expand Down
10 changes: 6 additions & 4 deletions projects/documentation/scripts/build-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const nodeModulesDir = path.resolve(
async function main() {
await build({
entryPoints: [
'./src/components/layout-element.ts',
'./src/components.ts',
'./src/getting-started.ts',
'./src/index.ts',
Expand Down Expand Up @@ -73,11 +74,12 @@ async function main() {
}),
],
external: [
'@spectrum-web-components/*',
'lit-html',
'lit-element',
'lit',
'@lit/reactive-element',
'lit',
'lit-element',
'lit-html',
'@spectrum-web-components/*',
'./layout-element.js',
],
});
process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion projects/documentation/src/components/code-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared';
import '@spectrum-web-components/action-button/sp-action-button.js';
import '@spectrum-web-components/icons-workflow/icons/sp-icon-copy.js';
import { copyNode } from './copy-to-clipboard.js';
import { TrackTheme } from './layout.js';
import { TrackTheme } from './layout-element.js';
import { Color } from '@spectrum-web-components/theme';

@customElement('code-example')
Expand Down