diff --git a/examples/framework-lit/.codesandbox/Dockerfile b/examples/framework-lit/.codesandbox/Dockerfile deleted file mode 100644 index c3b5c81a121d..000000000000 --- a/examples/framework-lit/.codesandbox/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM node:18-bullseye diff --git a/examples/framework-lit/.gitignore b/examples/framework-lit/.gitignore deleted file mode 100644 index 16d54bb13c8a..000000000000 --- a/examples/framework-lit/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# build output -dist/ -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# jetbrains setting folder -.idea/ diff --git a/examples/framework-lit/.npmrc b/examples/framework-lit/.npmrc deleted file mode 100644 index b417e450e18c..000000000000 --- a/examples/framework-lit/.npmrc +++ /dev/null @@ -1 +0,0 @@ -public-hoist-pattern[]=*lit* diff --git a/examples/framework-lit/.vscode/extensions.json b/examples/framework-lit/.vscode/extensions.json deleted file mode 100644 index 22a15055d638..000000000000 --- a/examples/framework-lit/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/framework-lit/.vscode/launch.json b/examples/framework-lit/.vscode/launch.json deleted file mode 100644 index d6422097621f..000000000000 --- a/examples/framework-lit/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/framework-lit/README.md b/examples/framework-lit/README.md deleted file mode 100644 index 714d179da2c3..000000000000 --- a/examples/framework-lit/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Astro + Lit Example - -```sh -npm create astro@latest -- --template framework-lit -``` - -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/framework-lit) -[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/framework-lit) -[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/framework-lit/devcontainer.json) - -This example showcases Astro working with [Lit](https://lit.dev/). diff --git a/examples/framework-lit/astro.config.mjs b/examples/framework-lit/astro.config.mjs deleted file mode 100644 index 99733e933767..000000000000 --- a/examples/framework-lit/astro.config.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { defineConfig } from 'astro/config'; -import lit from '@astrojs/lit'; - -// https://astro.build/config -export default defineConfig({ - // Enable Lit to support LitHTML components and templates. - integrations: [lit()], -}); diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json deleted file mode 100644 index cdb7d272a4e7..000000000000 --- a/examples/framework-lit/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@example/framework-lit", - "type": "module", - "version": "0.0.1", - "private": true, - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro build", - "preview": "astro preview", - "astro": "astro" - }, - "dependencies": { - "@astrojs/lit": "^4.3.0", - "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.14.2", - "lit": "^3.2.0" - } -} diff --git a/examples/framework-lit/public/assets/logo.svg b/examples/framework-lit/public/assets/logo.svg deleted file mode 100644 index d751556b2309..000000000000 --- a/examples/framework-lit/public/assets/logo.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/examples/framework-lit/public/favicon.svg b/examples/framework-lit/public/favicon.svg deleted file mode 100644 index f157bd1c5e28..000000000000 --- a/examples/framework-lit/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/framework-lit/src/components/Lorem.astro b/examples/framework-lit/src/components/Lorem.astro deleted file mode 100644 index d742ef6a52d7..000000000000 --- a/examples/framework-lit/src/components/Lorem.astro +++ /dev/null @@ -1,106 +0,0 @@ -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi quam arcu, rhoncus et dui at, - volutpat viverra augue. Suspendisse placerat libero tellus, ut consequat ligula rutrum id. - Vestibulum lectus libero, viverra in lacus eget, porttitor tincidunt leo. Integer sit amet turpis - et felis fringilla lacinia in id nibh. Proin vitae dapibus odio. Mauris ornare eget urna id - volutpat. Duis tellus nisi, hendrerit id sodales in, rutrum a quam. Proin tempor velit turpis, et - tempor lacus sagittis in. Sed congue mauris quis nibh posuere, nec semper lacus auctor. Morbi sit - amet enim sit amet arcu ullamcorper sollicitudin. Donec dignissim posuere tincidunt. Donec - ultrices quam nec orci venenatis suscipit. Maecenas sapien quam, pretium sit amet ullamcorper at, - vulputate sit amet urna. Suspendisse potenti. Integer in sapien turpis. Nulla accumsan viverra - diam, quis convallis magna finibus eget. Integer sed eros bibendum, consequat velit sit amet, - tincidunt orci. Mauris varius id metus in fringilla. Vestibulum dignissim massa eget erat luctus, - ac congue mauris pellentesque. In et tempor dolor. Cras blandit congue lorem at facilisis. Aenean - vel lacinia quam. Pellentesque luctus metus ut scelerisque efficitur. Mauris laoreet sodales - libero eget luctus. Proin at congue dui, a cursus risus. Pellentesque lorem sem, rhoncus fermentum - arcu ut, euismod fermentum ligula. Nullam eu orci posuere, laoreet leo in, commodo dolor. Fusce at - felis elementum, commodo justo at, placerat justo. Nam feugiat scelerisque arcu, ut fermentum - tellus elementum in. Sed ut vulputate ante. Morbi cursus arcu quis odio convallis egestas. Donec - vulputate vestibulum dolor eget tristique. Nullam tempor semper augue, vitae lobortis neque tempor - ac. Pellentesque massa leo, congue id ligula auctor, sollicitudin pharetra lorem. Curabitur a - lacus porttitor, venenatis est quis, mattis velit. Fusce hendrerit lobortis mi ac efficitur. - Mauris ornare, lorem sed varius faucibus, nisi dui pretium urna, sit amet lacinia nibh ligula in - ipsum. Phasellus gravida, metus eget ornare ultrices, dolor ipsum consectetur erat, ac aliquet - eros metus sed lectus. Nullam eleifend posuere rhoncus. Curabitur semper ligula vel ante posuere, - at blandit orci accumsan. Vivamus accumsan metus in lorem laoreet, a luctus arcu tempus. Donec - posuere sollicitudin nulla at vulputate. Nulla condimentum imperdiet purus, et lobortis ligula - iaculis in. Donec suscipit viverra neque, ut elementum eros lacinia ut. Fusce at odio enim. Donec - rutrum lectus sit amet est auctor, ac rhoncus lorem imperdiet. Curabitur commodo ex est, non - tempus massa pulvinar nec. Sed fermentum, lectus eget ultricies luctus, enim sem sodales quam, sed - laoreet tortor sem feugiat nisi. Morbi molestie vehicula viverra. Integer accumsan mi in orci - ultrices posuere. Integer mi quam, faucibus et aliquet imperdiet, ornare ac ex. Nunc mattis - molestie nisi, eu venenatis nibh vehicula at. Aliquam ut elit consectetur, finibus lorem sed, - condimentum sapien. Praesent fermentum iaculis orci, vitae tincidunt est viverra nec. Morbi semper - turpis sed lectus ornare tristique. Sed congue dui ex. Maecenas orci ligula, imperdiet sit amet - accumsan et, finibus a velit. Ut vitae blandit eros. Nam gravida nec ipsum non volutpat. Integer - quam metus, porttitor id ante sed, rutrum porta quam. Aenean at mattis ante. Morbi id libero eget - risus sagittis gravida. Proin consequat sapien a dignissim posuere. Ut luctus sed metus ut - elementum. Mauris tincidunt condimentum risus at bibendum. Aenean a sapien justo. Morbi vel neque - in eros venenatis scelerisque vitae nec justo. Vestibulum lacinia, dui eu sollicitudin ornare, est - elit vestibulum arcu, nec ultrices augue turpis in massa. Duis commodo lectus sed est posuere, et - mollis nisi dapibus. Sed id ultrices arcu. Praesent tempor sodales aliquet. Donec suscipit ipsum - eu odio cursus, quis sodales metus sodales. Nunc vestibulum massa at felis ullamcorper cursus. - Pellentesque facilisis ante ut lectus vulputate vestibulum. Nullam pharetra felis ac lacus - sodales, vel suscipit metus faucibus. Donec facilisis imperdiet risus, in volutpat odio tincidunt - a. Aliquam vitae leo lorem. Proin scelerisque efficitur velit, vel cursus ipsum accumsan id. Morbi - nibh nulla, pretium quis venenatis et, pharetra et sapien. Cras lobortis, massa sit amet blandit - pulvinar, mi magna condimentum ex, quis commodo ipsum est quis metus. Maecenas pulvinar, leo sit - amet congue pulvinar, neque magna ultrices mi, et rhoncus massa sapien quis libero. Etiam a nunc - et ipsum faucibus pretium. Nulla facilisi. Nunc nec dolor velit. In semper semper mi non - condimentum. Pellentesque vehicula volutpat odio, a semper sem porta a. In sit amet lectus rutrum, - sollicitudin augue auctor, maximus quam. Mauris congue, nisl non fermentum iaculis, leo erat - interdum lorem, quis bibendum arcu eros et elit. Fusce tortor ante, gravida a arcu in, lacinia - finibus ante. Phasellus facilisis lectus vitae sapien feugiat laoreet. Curabitur ultricies libero - sit amet condimentum suscipit. Duis at vestibulum mi. Suspendisse at neque augue. Duis ornare a - mauris id efficitur. Suspendisse in dui nec dolor dignissim venenatis. Curabitur a magna turpis. - Aliquam at commodo tellus. In id sem interdum, suscipit felis at, mattis velit. Proin accumsan - sodales felis a lacinia. Curabitur at magna a massa varius maximus. Vestibulum in auctor ante. - Donec aliquam tortor sed nulla rutrum, et egestas mi efficitur. Sed viverra quam tellus, quis - vulputate felis ultrices sed. Mauris sagittis, neque quis laoreet gravida, nisi est ultrices mi, - at tempus nunc justo non dui. Suspendisse porttitor tortor nulla, eget luctus quam finibus id. - Proin sodales eros mollis tellus euismod luctus a eu mi. Quisque consectetur iaculis nibh, at - mollis tellus volutpat eu. Aenean a nulla vel lectus rhoncus aliquam. Donec vitae lacinia neque. - Donec non lectus eget sem finibus ultrices vel nec felis. Proin fringilla mi a leo rhoncus aliquam - sit amet quis augue. Duis congue ligula at est suscipit fringilla. Proin aliquam erat ut consequat - dapibus. Suspendisse non nisi orci. Donec ac erat vel libero egestas laoreet. Nullam felis odio, - tincidunt eget eleifend a, porttitor eu nisi. Suspendisse tristique eros at dolor scelerisque - hendrerit. Etiam id dignissim lectus. Fusce lacinia metus eu risus placerat, et eleifend nunc - ultrices. Ut gravida a dui sed volutpat. Sed semper quis erat sed ornare. Pellentesque sapien sem, - fermentum vel nunc at, auctor posuere nisl. Maecenas aliquet lobortis leo. Vivamus tellus urna, - dignissim consectetur sapien vitae, hendrerit varius sem. Nunc dictum tristique fermentum. Duis eu - suscipit odio. Curabitur quis egestas neque. Fusce eu fringilla orci, vitae euismod sapien. Donec - sit amet iaculis urna. Phasellus maximus nisl in libero bibendum volutpat. Nulla at vehicula - lorem. Phasellus varius, elit ac suscipit pretium, turpis ipsum porttitor lectus, vitae - ullamcorper orci velit ut ligula. Proin mollis, orci vel commodo auctor, sapien ipsum vulputate - enim, sit amet aliquam nulla sapien ut sapien. Proin tincidunt ex non massa aliquet, quis aliquam - nulla egestas. Maecenas mollis turpis dapibus, dignissim lectus tincidunt, egestas ligula. - Suspendisse in lobortis purus. Sed tellus tellus, mollis eget tempor sed, interdum ut lectus. - Nulla sed ex efficitur, porta dui cursus, tristique elit. Maecenas tincidunt tortor vitae massa - laoreet ultricies. Mauris ac elit vitae orci eleifend ornare non eu ligula. Curabitur venenatis - nulla ut neque tristique, non tincidunt justo pretium. Suspendisse mattis semper dui, eget - vestibulum risus elementum sed. In consequat nisi sit amet nulla euismod, at convallis tortor - tincidunt. Aliquam hendrerit venenatis risus in interdum. Duis ullamcorper imperdiet elit sit amet - blandit. Mauris placerat lacinia velit id pharetra. Nam nec iaculis dui. Etiam odio mi, fringilla - in rutrum in, viverra quis tellus. Aliquam egestas mauris id nisi facilisis, in laoreet nibh - malesuada. Ut eu dui laoreet, venenatis tellus ac, feugiat mauris. Nunc in velit laoreet, - venenatis tellus quis, blandit dolor. Nulla ultrices et neque id placerat. Nulla eu interdum - nulla. Aliquam molestie enim quis rutrum finibus. Nulla bibendum orci vel scelerisque posuere. - Praesent quis magna molestie, luctus tortor tincidunt, gravida neque. Quisque et ligula eget magna - viverra interdum at a sapien. Mauris ornare efficitur nunc sed vulputate. Praesent laoreet mollis - tincidunt. Vestibulum id arcu vulputate, eleifend enim vel, accumsan turpis. Morbi faucibus - convallis tellus, semper laoreet justo lacinia nec. Sed sodales ligula consectetur dui rhoncus, et - convallis metus accumsan. Sed ullamcorper non ex sit amet ultricies. Donec finibus nulla nec - blandit porttitor. Etiam aliquam quis leo a imperdiet. Cras at lobortis est. In convallis semper - enim, ac porta ligula fringilla at. Donec augue est, facilisis et odio sit amet, viverra - ullamcorper nisl. Ut porta velit nec sem lacinia, sit amet mollis magna auctor. Nulla lobortis - lacinia mauris nec sagittis. Suspendisse rutrum ex vel nisi interdum hendrerit et ut purus. Sed - consectetur sodales nibh eget tempus. Aenean egestas luctus viverra. Integer fermentum tincidunt - tellus, nec rhoncus velit hendrerit vitae. Proin quis neque porttitor, scelerisque risus gravida, - volutpat sem. Fusce nec ex rhoncus, tempor libero nec, pellentesque ex. Integer quis iaculis - purus. Nullam vitae imperdiet orci. Sed sit amet eros condimentum, scelerisque turpis facilisis, - dignissim ante. Proin quis tristique lacus, sed sagittis nisl. Cras pharetra ultrices purus, sed - ullamcorper nisi fringilla eu. Praesent risus turpis, auctor in fringilla a, fringilla eu dolor. - Phasellus auctor tristique enim, eleifend molestie diam venenatis ut. Mauris dapibus, enim eget - pharetra semper, nulla dui porttitor mi, auctor hendrerit augue nulla quis urna. Aliquam in cursus - justo. -

diff --git a/examples/framework-lit/src/components/calc-add.js b/examples/framework-lit/src/components/calc-add.js deleted file mode 100644 index b0b3978bf759..000000000000 --- a/examples/framework-lit/src/components/calc-add.js +++ /dev/null @@ -1,17 +0,0 @@ -import { LitElement, html } from 'lit'; - -export class CalcAdd extends LitElement { - static get properties() { - return { - num: { - type: Number, - }, - }; - } - - render() { - return html`
Number: ${this.num}
`; - } -} - -customElements.define('calc-add', CalcAdd); diff --git a/examples/framework-lit/src/components/my-counter.js b/examples/framework-lit/src/components/my-counter.js deleted file mode 100644 index adc9e4a3d4bc..000000000000 --- a/examples/framework-lit/src/components/my-counter.js +++ /dev/null @@ -1,32 +0,0 @@ -import { LitElement, html } from 'lit'; - -export class MyCounter extends LitElement { - static get properties() { - return { - count: { - type: Number, - }, - }; - } - - constructor() { - super(); - this.count = 0; - } - - increment() { - this.count++; - } - - render() { - return html` -
-

Count: ${this.count}

- - -
- `; - } -} - -customElements.define('my-counter', MyCounter); diff --git a/examples/framework-lit/src/env.d.ts b/examples/framework-lit/src/env.d.ts deleted file mode 100644 index e16c13c6952a..000000000000 --- a/examples/framework-lit/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/framework-lit/src/pages/index.astro b/examples/framework-lit/src/pages/index.astro deleted file mode 100644 index 5fa6fed67f22..000000000000 --- a/examples/framework-lit/src/pages/index.astro +++ /dev/null @@ -1,35 +0,0 @@ ---- -import Lorem from '../components/Lorem.astro'; -import { CalcAdd } from '../components/calc-add.js'; -import { MyCounter } from '../components/my-counter.js'; - -// Full Astro Component Syntax: -// https://docs.astro.build/basics/astro-components/ ---- - - - - - - - - Demo - - -

Test app

- - - - { - ( - /** - * Our editor tooling does not currently properly typecheck attributes on imported Lit components. As such, without a - * pragma directive telling TypeScript to ignore the error, the line below will result in an error in the editor. - * Nonetheless, this code works in Astro itself! - */ - // @ts-expect-error - - ) - } - - diff --git a/examples/framework-lit/tsconfig.json b/examples/framework-lit/tsconfig.json deleted file mode 100644 index d78f81ec4e8e..000000000000 --- a/examples/framework-lit/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/base" -} diff --git a/examples/integration/index.ts b/examples/integration/index.ts index 8b34afd2334a..1fafd4e15752 100644 --- a/examples/integration/index.ts +++ b/examples/integration/index.ts @@ -11,8 +11,8 @@ export default function createIntegration(): AstroIntegration { // https://github.com/withastro/astro/blob/main/packages/integrations/react/src/index.ts }, 'astro:build:setup': () => { - // See the @astrojs/lit integration for an example - // https://github.com/withastro/astro/blob/main/packages/integrations/lit/src/index.ts + // See the @astrojs/react integration for an example + // https://github.com/withastro/astro/blob/main/packages/integrations/react/src/index.ts }, 'astro:build:done': () => { // See the @astrojs/partytown integration for an example diff --git a/packages/astro/e2e/fixtures/lit-component/astro.config.mjs b/packages/astro/e2e/fixtures/lit-component/astro.config.mjs deleted file mode 100644 index 24de2f1b5a5c..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/astro.config.mjs +++ /dev/null @@ -1,10 +0,0 @@ -import lit from '@astrojs/lit'; -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({ - integrations: [lit()], - devToolbar: { - enabled: false, - } -}); diff --git a/packages/astro/e2e/fixtures/lit-component/package.json b/packages/astro/e2e/fixtures/lit-component/package.json deleted file mode 100644 index 0db0d411181c..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@e2e/lit-component", - "version": "0.0.0", - "private": true, - "dependencies": { - "@astrojs/lit": "workspace:*", - "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "workspace:*", - "lit": "^3.2.0" - } -} diff --git a/packages/astro/e2e/fixtures/lit-component/src/components/ClientOnlyComponent.js b/packages/astro/e2e/fixtures/lit-component/src/components/ClientOnlyComponent.js deleted file mode 100644 index 0fd16b50af01..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/src/components/ClientOnlyComponent.js +++ /dev/null @@ -1,9 +0,0 @@ -import { LitElement, html } from 'lit'; - -export default class ClientOnlyComponent extends LitElement { - render() { - return html`
Shadow dom default content should not be visible
`; - } -} - -customElements.define('client-only-component', ClientOnlyComponent); diff --git a/packages/astro/e2e/fixtures/lit-component/src/components/Counter.js b/packages/astro/e2e/fixtures/lit-component/src/components/Counter.js deleted file mode 100644 index 1ccd020ed49c..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/src/components/Counter.js +++ /dev/null @@ -1,38 +0,0 @@ -import { LitElement, html } from 'lit'; - -export default class Counter extends LitElement { - static get properties() { - return { - count: { - type: Number, - }, - }; - } - - constructor() { - super(); - this.count = 0; - } - - increment() { - this.count++; - } - - render() { - return html` -
-

Count: ${this.count}

- - - - -
- `; - } -} - -// Since this fixture is ran in both dev and build, this could register twice. Wrap with a try..catch for now. -try { - customElements.define('my-counter', Counter); -} catch {} - diff --git a/packages/astro/e2e/fixtures/lit-component/src/components/NonDeferredCounter.js b/packages/astro/e2e/fixtures/lit-component/src/components/NonDeferredCounter.js deleted file mode 100644 index 409d3e9a54d9..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/src/components/NonDeferredCounter.js +++ /dev/null @@ -1,38 +0,0 @@ -import { LitElement, html } from 'lit'; - -export default class NonDeferredCounter extends LitElement { - static get properties() { - return { - count: { - type: Number, - // All set properties are reflected to attributes so its hydration is - // not deferred. - reflect: true, - }, - }; - } - - constructor() { - super(); - this.count = 0; - } - - increment() { - this.count++; - } - - render() { - return html` -
-

Count: ${this.count}

- - -
- `; - } -} - -// Since this fixture is ran in both dev and build, this could register twice. Wrap with a try..catch for now. -try { - customElements.define('non-deferred-counter', NonDeferredCounter); -} catch {} diff --git a/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro b/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro deleted file mode 100644 index 1d9511057b4a..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro +++ /dev/null @@ -1,38 +0,0 @@ ---- -import ClientOnlyComponent from '../components/ClientOnlyComponent.js'; -import MyCounter from '../components/Counter.js'; -import NonDeferredCounter from '../components/NonDeferredCounter.js'; - -const someProps = { - count: 10, -}; ---- - - - - - - - -

Hello, client:idle!

-
- - - - - -

Hello, client:load!

-
- - -

Hello, client:visible!

-
- - - Framework - client:only - component - Should not be visible - - - diff --git a/packages/astro/e2e/fixtures/lit-component/src/pages/media.astro b/packages/astro/e2e/fixtures/lit-component/src/pages/media.astro deleted file mode 100644 index 69e1d7005c7b..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/src/pages/media.astro +++ /dev/null @@ -1,18 +0,0 @@ ---- -import MyCounter from '../components/Counter.js'; - -const someProps = { - count: 10, -}; ---- - - - - - - - -

Hello, client:media!

-
- - diff --git a/packages/astro/e2e/fixtures/lit-component/src/pages/solo.astro b/packages/astro/e2e/fixtures/lit-component/src/pages/solo.astro deleted file mode 100644 index c9dfe0ba0996..000000000000 --- a/packages/astro/e2e/fixtures/lit-component/src/pages/solo.astro +++ /dev/null @@ -1,18 +0,0 @@ ---- -import MyCounter from '../components/Counter.js'; - -const someProps = { - count: 10, -}; ---- - - - - - - - -

Hello, client:idle!

-
- - diff --git a/packages/astro/e2e/fixtures/multiple-frameworks/package.json b/packages/astro/e2e/fixtures/multiple-frameworks/package.json index b05763561ebb..8bf507751f47 100644 --- a/packages/astro/e2e/fixtures/multiple-frameworks/package.json +++ b/packages/astro/e2e/fixtures/multiple-frameworks/package.json @@ -3,7 +3,6 @@ "version": "0.0.0", "private": true, "devDependencies": { - "@astrojs/lit": "workspace:*", "@astrojs/preact": "workspace:*", "@astrojs/react": "workspace:*", "@astrojs/solid-js": "workspace:*", diff --git a/packages/astro/e2e/fixtures/multiple-frameworks/src/components/LitCounter.js b/packages/astro/e2e/fixtures/multiple-frameworks/src/components/LitCounter.js deleted file mode 100644 index 883a7581da9a..000000000000 --- a/packages/astro/e2e/fixtures/multiple-frameworks/src/components/LitCounter.js +++ /dev/null @@ -1,33 +0,0 @@ -import { LitElement, html } from 'lit'; - -export const tagName = 'my-counter'; - -class Counter extends LitElement { - static get properties() { - return { - count: { - type: Number, - }, - }; - } - - constructor() { - super(); - this.count = 0; - } - - increment() { - this.count++; - } - - render() { - return html` -
-

Count: ${this.count}

- -
- `; - } -} - -customElements.define(tagName, Counter); diff --git a/packages/astro/e2e/lit-component.test.js b/packages/astro/e2e/lit-component.test.js deleted file mode 100644 index d68f5f7b8069..000000000000 --- a/packages/astro/e2e/lit-component.test.js +++ /dev/null @@ -1,183 +0,0 @@ -import { expect } from '@playwright/test'; -import { testFactory, waitForHydrate } from './test-utils.js'; - -const test = testFactory({ - root: './fixtures/lit-component/', -}); - -// TODO: configure playwright to handle web component APIs -// https://github.com/microsoft/playwright/issues/14241 -test.describe('Lit components', () => { - test.describe('Development', () => { - let devServer; - - test.beforeAll(async ({ astro }) => { - devServer = await astro.startDevServer(); - }); - - test.afterAll(async () => { - await devServer.stop(); - }); - - test('client:idle', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); - - const counter = page.locator('#client-idle'); - await expect(counter, 'component is visible').toBeVisible(); - await expect(counter).toHaveCount(1); - - const count = counter.locator('p'); - await expect(count, 'initial count is 10').toHaveText('Count: 10'); - - await waitForHydrate(page, counter); - - const inc = counter.locator('button'); - await inc.click(); - - await expect(count, 'count incremented by 1').toHaveText('Count: 11'); - }); - - test('non-deferred attribute serialization', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); - - const counter = page.locator('#non-deferred'); - const count = counter.locator('p'); - await expect(count, 'initial count is 10').toHaveText('Count: 10'); - - await waitForHydrate(page, counter); - - const inc = counter.locator('button'); - await inc.click(); - - await expect(count, 'count incremented by 1').toHaveText('Count: 11'); - }); - - test('client:load', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); - - const counter = page.locator('#client-load'); - await expect(counter, 'component is visible').toBeVisible(); - - const count = counter.locator('p'); - await expect(count, 'initial count is 10').toHaveText('Count: 10'); - - await waitForHydrate(page, counter); - - const inc = counter.locator('button'); - await inc.click(); - - await expect(count, 'count incremented by 1').toHaveText('Count: 11'); - }); - - test('client:visible', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); - - // Make sure the component is on screen to trigger hydration - const counter = page.locator('#client-visible'); - await counter.scrollIntoViewIfNeeded(); - await expect(counter, 'component is visible').toBeVisible(); - - const count = counter.locator('p'); - await expect(count, 'initial count is 10').toHaveText('Count: 10'); - - await waitForHydrate(page, counter); - - const inc = counter.locator('button'); - await inc.click(); - - await expect(count, 'count incremented by 1').toHaveText('Count: 11'); - }); - - test('client:media', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/media')); - - const counter = page.locator('#client-media'); - await expect(counter, 'component is visible').toBeVisible(); - - const count = counter.locator('p'); - await expect(count, 'initial count is 10').toHaveText('Count: 10'); - - const inc = counter.locator('button'); - await inc.click(); - - await expect(count, 'component not hydrated yet').toHaveText('Count: 10'); - - // Reset the viewport to hydrate the component (max-width: 50rem) - await page.setViewportSize({ width: 414, height: 1124 }); - await waitForHydrate(page, counter); - - await inc.click(); - await expect(count, 'count incremented by 1').toHaveText('Count: 11'); - }); - - test('client:only', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); - - const label = page.locator('#client-only'); - await expect(label, 'component is visible').toBeVisible(); - - // Light DOM reconstructed correctly (slots are rendered alphabetically) and shadow dom content rendered - await expect(label, 'slotted text is in DOM').toHaveText( - 'Framework client:only component Should not be visible Shadow dom default content should not be visible', - ); - - // Projected content should be visible - await expect( - page.locator('#client-only .default'), - 'slotted element is visible', - ).toBeVisible(); - await expect(page.locator('#client-only .foo1'), 'slotted element is visible').toBeVisible(); - await expect(page.locator('#client-only .foo2'), 'slotted element is visible').toBeVisible(); - - // Non-projected content should not be visible - await expect( - page.locator('#client-only [slot="quux"]'), - 'element without slot is not visible', - ).toBeHidden(); - - // Default slot content should not be visible - await expect( - page.locator('#client-only .defaultContent'), - 'element without slot is not visible', - ).toBeHidden(); - }); - - test.skip('HMR', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/')); - - const counter = page.locator('#client-idle'); - const label = counter.locator('h1'); - - await astro.editFile('./src/pages/index.astro', (original) => - original.replace('Hello, client:idle!', 'Hello, updated client:idle!'), - ); - - await expect(label, 'slot text updated').toHaveText('Hello, updated client:idle!'); - await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid'); - }); - }); - - test.describe('Production', () => { - let previewServer; - - test.beforeAll(async ({ astro }) => { - // Playwright's Node version doesn't have these functions, so stub them. - process.stdout.clearLine = () => {}; - process.stdout.cursorTo = () => {}; - await astro.build(); - previewServer = await astro.preview(); - }); - - test.afterAll(async () => { - await previewServer.stop(); - }); - - test('Only one component in prod', async ({ page, astro }) => { - await page.goto(astro.resolveUrl('/solo')); - - const counter = page.locator('my-counter'); - await expect(counter, 'component is visible').toBeVisible(); - await expect(counter, 'there is only one counter').toHaveCount(1); - }); - }); -}); diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 300911acdaca..017594e75184 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -32,7 +32,7 @@ import { formatList, internalSpreadAttributes, renderElement, voidElementNames } const needsHeadRenderingSymbol = Symbol.for('astro.needsHeadRendering'); const rendererAliases = new Map([['solid', 'solid-js']]); -const clientOnlyValues = new Set(['solid-js', 'react', 'preact', 'vue', 'svelte', 'lit']); +const clientOnlyValues = new Set(['solid-js', 'react', 'preact', 'vue', 'svelte']); function guessRenderers(componentUrl?: string): string[] { const extname = componentUrl?.split('.').pop(); @@ -51,7 +51,6 @@ function guessRenderers(componentUrl?: string): string[] { '@astrojs/solid-js', '@astrojs/vue', '@astrojs/svelte', - '@astrojs/lit', ]; } } @@ -285,24 +284,6 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr } } - // HACK! The lit renderer doesn't include a clientEntrypoint for custom elements, allow it - // to render here until we find a better way to recognize when a client entrypoint isn't required. - if ( - renderer && - !renderer.clientEntrypoint && - renderer.name !== '@astrojs/lit' && - metadata.hydrate - ) { - throw new AstroError({ - ...AstroErrorData.NoClientEntrypoint, - message: AstroErrorData.NoClientEntrypoint.message( - displayName, - metadata.hydrate, - renderer.name, - ), - }); - } - // This is a custom element without a renderer. Because of that, render it // as a string and the user is responsible for adding a script tag for the component definition. if (!html && typeof Component === 'string') { diff --git a/packages/astro/test/fixtures/lit-element/astro.config.mjs b/packages/astro/test/fixtures/lit-element/astro.config.mjs deleted file mode 100644 index 0ddc1e5d0d32..000000000000 --- a/packages/astro/test/fixtures/lit-element/astro.config.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import lit from '@astrojs/lit'; -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({ - integrations: [lit()], -}); \ No newline at end of file diff --git a/packages/astro/test/fixtures/lit-element/package.json b/packages/astro/test/fixtures/lit-element/package.json deleted file mode 100644 index fdfb79ab7687..000000000000 --- a/packages/astro/test/fixtures/lit-element/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@test/lit-element", - "version": "0.0.0", - "private": true, - "dependencies": { - "@astrojs/lit": "workspace:*", - "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "workspace:*", - "lit": "^3.2.0" - } -} diff --git a/packages/astro/test/fixtures/lit-element/src/components/my-element.ts b/packages/astro/test/fixtures/lit-element/src/components/my-element.ts deleted file mode 100644 index b4c98b010104..000000000000 --- a/packages/astro/test/fixtures/lit-element/src/components/my-element.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { LitElement, html } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; - -@customElement('my-element') -export class MyElement extends LitElement { - @property({ type: Boolean }) - bool = 0; - - static properties = { - str: {type: String, attribute: 'str-attr'}, - obj: {type: Object}, - reflectedBool: {type: Boolean, reflect: true}, - reflectedStr: {type: String, reflect: true, attribute: 'reflected-str'}, - reflectedStrProp: {type: String, reflect: true, attribute: 'reflected-str-prop'}, - } - - constructor() { - super(); - this.bool = true; - this.str = 'not initialized'; - this.obj = {data: null}; - // not a reactive property - this.foo = 'not initialized'; - // reflected props - this.reflectedBool = true; - this.reflectedStr = 'default reflected string'; - } - render() { - return html` -
Testing...
-
${this.bool ? 'A' : 'B'}
-
${this.str}
-
data: ${this.obj.data}
- - -
-
- `; - } -} diff --git a/packages/astro/test/fixtures/lit-element/src/components/non-deferred-element.ts b/packages/astro/test/fixtures/lit-element/src/components/non-deferred-element.ts deleted file mode 100644 index f5c36a7d3114..000000000000 --- a/packages/astro/test/fixtures/lit-element/src/components/non-deferred-element.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { LitElement, html } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; - -@customElement('non-deferred-counter') -export class NonDeferredCounter extends LitElement { - // All set properties are reflected to attributes so its hydration is not - // hydration-deferred should always be set. - @property({ type: Number, reflect: true }) count = 0; - - increment() { - this.count++; - } - - render() { - return html` -
-

Count: ${this.count}

- - -
- `; - } -} diff --git a/packages/astro/test/fixtures/lit-element/src/pages/[page].astro b/packages/astro/test/fixtures/lit-element/src/pages/[page].astro deleted file mode 100644 index 52a791272f22..000000000000 --- a/packages/astro/test/fixtures/lit-element/src/pages/[page].astro +++ /dev/null @@ -1,30 +0,0 @@ ---- -import {MyElement} from '../components/my-element.js'; -export async function getStaticPaths() { - return [ - { - params: { page: 1 }, - }, - { - params: { page: 2 }, - }, - { - params: { page: 3 } - } - ] -}; - -const { page } = Astro.params ---- - - - - - - Posts Page {page} - - -

Welcome to page {page}

- - - diff --git a/packages/astro/test/fixtures/lit-element/src/pages/index.astro b/packages/astro/test/fixtures/lit-element/src/pages/index.astro deleted file mode 100644 index 394885fcae61..000000000000 --- a/packages/astro/test/fixtures/lit-element/src/pages/index.astro +++ /dev/null @@ -1,25 +0,0 @@ ---- -import {MyElement} from '../components/my-element.js'; -import {NonDeferredCounter} from '../components/non-deferred-element.js'; ---- - - - - LitElements - - - - - - - - diff --git a/packages/astro/test/fixtures/lit-element/src/pages/slots.astro b/packages/astro/test/fixtures/lit-element/src/pages/slots.astro deleted file mode 100644 index 6ef0cd1832a7..000000000000 --- a/packages/astro/test/fixtures/lit-element/src/pages/slots.astro +++ /dev/null @@ -1,39 +0,0 @@ ---- -import {MyElement} from '../components/my-element.js'; ---- - - - - LitElement | Slot - - - -
my-element default 1
-
my-element default 2
- -

my-element named 1

-

my-element named 2

- -
    -
  • Custom elements
  • -
  • Shadow DOM
  • -
  • HTML templates
  • -
- - -

slotted my-element default

- -
slotted my-element named 1
-
slotted my-element named 2
- - -

slotted slotted my-element default 1

-
slotted slotted my-element default 2
- -
slotted slotted my-element named 1
-
slotted slotted my-element named 2
-
-
-
- - diff --git a/packages/astro/test/fixtures/lit-element/src/skipped-pages/ctr.astro b/packages/astro/test/fixtures/lit-element/src/skipped-pages/ctr.astro deleted file mode 100644 index d41e9645f3d6..000000000000 --- a/packages/astro/test/fixtures/lit-element/src/skipped-pages/ctr.astro +++ /dev/null @@ -1,12 +0,0 @@ ---- -import { MyElement } from '../components/my-element.js'; ---- - - - - LitElements - - - - - diff --git a/packages/astro/test/fixtures/lit-element/tsconfig.json b/packages/astro/test/fixtures/lit-element/tsconfig.json deleted file mode 100644 index 504cd646e149..000000000000 --- a/packages/astro/test/fixtures/lit-element/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true - } -} diff --git a/packages/astro/test/lit-element.test.js b/packages/astro/test/lit-element.test.js deleted file mode 100644 index 0522b8c71ce9..000000000000 --- a/packages/astro/test/lit-element.test.js +++ /dev/null @@ -1,154 +0,0 @@ -import assert from 'node:assert/strict'; -import { before, describe, it } from 'node:test'; -import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; - -describe( - 'LitElement test', - { timeout: 300000, skip: 'This goes in conflict with ssr-lit test file' }, - () => { - let fixture; - - const NODE_VERSION = parseFloat(process.versions.node); - const stripExpressionMarkers = (html) => html.replace(//g, ''); - - before(async () => { - // @lit-labs/ssr/ requires Node 13.9 or higher - if (NODE_VERSION < 13.9) { - return; - } - fixture = await loadFixture({ - root: './fixtures/lit-element/', - }); - await fixture.build(); - }); - - it('Renders a custom element by Constructor', async () => { - // @lit-labs/ssr/ requires Node 13.9 or higher - if (NODE_VERSION < 13.9) { - return; - } - const html = await fixture.readFile('/index.html'); - const $ = cheerio.load(html); - - // test 1: attributes rendered – non reactive properties - assert.equal($('#default').attr('foo'), 'bar'); - - // test 2: shadow rendered - assert.equal($('#default').html().includes('
Testing...
'), true); - - // test 3: string reactive property set - assert.equal( - stripExpressionMarkers($('#default').html()).includes(`
initialized
`), - true, - ); - - // test 4: boolean reactive property correctly set - // Lit will equate to true because it uses - // this.hasAttribute to determine its value - assert.equal( - stripExpressionMarkers($('#default').html()).includes(`
B
`), - true, - ); - - // test 5: object reactive property set - // by default objects will be stringified to [object Object] - assert.equal( - stripExpressionMarkers($('#default').html()).includes(`
data: 1
`), - true, - ); - - // test 6: reactive properties are not rendered as attributes - assert.equal($('#default').attr('obj'), undefined); - assert.equal($('#default').attr('bool'), undefined); - assert.equal($('#default').attr('str'), undefined); - - // test 7: reflected reactive props are rendered as attributes - assert.equal($('#default').attr('reflectedbool'), ''); - assert.equal($('#default').attr('reflected-str'), 'default reflected string'); - assert.equal($('#default').attr('reflected-str-prop'), 'initialized reflected'); - }); - - it('Sets defer-hydration on element only when necessary', async () => { - // @lit-labs/ssr/ requires Node 13.9 or higher - if (NODE_VERSION < 13.9) { - return; - } - const html = await fixture.readFile('/index.html'); - const $ = cheerio.load(html); - - // test 1: reflected reactive props are rendered as attributes - assert.equal($('#non-deferred').attr('count'), '10'); - - // test 2: non-reactive props are set as attributes - assert.equal($('#non-deferred').attr('foo'), 'bar'); - - // test 3: components with only reflected reactive props set are not - // deferred because their state can be completely serialized via attributes - assert.equal($('#non-deferred').attr('defer-hydration'), undefined); - - // test 4: components with non-reflected reactive props set are deferred because - // their state needs to be synced with the server on the client. - assert.equal($('#default').attr('defer-hydration'), ''); - }); - - it('Correctly passes child slots', async () => { - // @lit-labs/ssr/ requires Node 13.9 or higher - if (NODE_VERSION < 13.9) { - return; - } - const html = await fixture.readFile('/slots/index.html'); - const $ = cheerio.load(html); - - const $rootMyElement = $('#root'); - const $slottedMyElement = $('#slotted'); - const $slottedSlottedMyElement = $('#slotted-slotted'); - - assert.equal($('#default').length, 3); - - // Root my-element - assert.equal($rootMyElement.children('.default').length, 2); - assert.equal($rootMyElement.children('.default').eq(1).text(), 'my-element default 2'); - - assert.equal($rootMyElement.children('[slot="named"]').length, 4); - assert.equal($rootMyElement.children('[slot="named"]').eq(1).text(), 'my-element named 2'); - assert.equal($rootMyElement.children('[slot="named"]').eq(2).attr('id'), 'list'); - assert.equal($rootMyElement.children('[slot="named"]').eq(3).attr('id'), 'slotted'); - - // Slotted my-element first level - assert.equal($slottedMyElement.children('.default').length, 1); - assert.equal( - $slottedMyElement.children('.default').eq(0).text(), - 'slotted my-element default', - ); - - assert.equal($slottedMyElement.children('[slot="named"]').length, 3); - assert.equal( - $slottedMyElement.children('[slot="named"]').eq(1).text(), - 'slotted my-element named 2', - ); - assert.equal( - $slottedMyElement.children('[slot="named"]').eq(2).attr('id'), - 'slotted-slotted', - ); - - // Slotted my-element second level - assert.equal($slottedSlottedMyElement.children('.default').length, 2); - assert.equal( - $slottedSlottedMyElement.children('.default').eq(1).text(), - 'slotted slotted my-element default 2', - ); - - assert.equal($slottedSlottedMyElement.children('[slot="named"]').length, 2); - assert.equal( - $slottedSlottedMyElement.children('[slot="named"]').eq(1).text(), - 'slotted slotted my-element named 2', - ); - }); - - it('Is able to build when behind getStaticPaths', async () => { - const dynamicPage = await fixture.readFile('/1/index.html'); - assert.equal(dynamicPage.length > 0, true); - }); - }, -); diff --git a/packages/astro/test/ssr-lit.test.js b/packages/astro/test/ssr-lit.test.js deleted file mode 100644 index 40057cf218aa..000000000000 --- a/packages/astro/test/ssr-lit.test.js +++ /dev/null @@ -1,33 +0,0 @@ -import assert from 'node:assert/strict'; -import { before, describe, it } from 'node:test'; -import { load as cheerioLoad } from 'cheerio'; -import testAdapter from './test-adapter.js'; -import { loadFixture } from './test-utils.js'; - -describe('Lit integration in SSR', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - - before(async () => { - fixture = await loadFixture({ - root: './fixtures/lit-element/', - output: 'server', - adapter: testAdapter(), - }); - await fixture.build(); - }); - - async function fetchHTML(path) { - const app = await fixture.loadTestAdapterApp(); - const request = new Request('http://example.com' + path); - const response = await app.render(request); - const html = await response.text(); - return html; - } - - it('Is able to load', async () => { - const html = await fetchHTML('/'); - const $ = cheerioLoad(html); - assert.equal($('#str').text(), 'initialized'); - }); -}); diff --git a/packages/integrations/lit/.gitignore b/packages/integrations/lit/.gitignore deleted file mode 100644 index 40b878db5b1c..000000000000 --- a/packages/integrations/lit/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ \ No newline at end of file diff --git a/packages/integrations/lit/CHANGELOG.md b/packages/integrations/lit/CHANGELOG.md deleted file mode 100644 index 0aa8f4f71177..000000000000 --- a/packages/integrations/lit/CHANGELOG.md +++ /dev/null @@ -1,306 +0,0 @@ -# @astrojs/lit - -## 4.3.0 - -### Minor Changes - -- [#11234](https://github.com/withastro/astro/pull/11234) [`4385bf7`](https://github.com/withastro/astro/commit/4385bf7a4dc9c65bff53a30c660f7a909fcabfc9) Thanks [@ematipico](https://github.com/ematipico)! - Adds a new function called `addServerRenderer` to the Container API. Use this function to manually store renderers inside the instance of your container. - - This new function should be preferred when using the Container API in environments like on-demand pages: - - ```ts - import type { APIRoute } from 'astro'; - import { experimental_AstroContainer } from 'astro/container'; - import reactRenderer from '@astrojs/react/server.js'; - import vueRenderer from '@astrojs/vue/server.js'; - import ReactComponent from '../components/button.jsx'; - import VueComponent from '../components/button.vue'; - - // MDX runtime is contained inside the Astro core - import mdxRenderer from 'astro/jsx/server.js'; - - // In case you need to import a custom renderer - import customRenderer from '../renderers/customRenderer.js'; - - export const GET: APIRoute = async (ctx) => { - const container = await experimental_AstroContainer.create(); - container.addServerRenderer({ renderer: reactRenderer }); - container.addServerRenderer({ renderer: vueRenderer }); - container.addServerRenderer({ renderer: customRenderer }); - // You can pass a custom name too - container.addServerRenderer({ - name: 'customRenderer', - renderer: customRenderer, - }); - const vueComponent = await container.renderToString(VueComponent); - return await container.renderToResponse(Component); - }; - ``` - -## 4.2.0 - -### Minor Changes - -- [#11144](https://github.com/withastro/astro/pull/11144) [`803dd80`](https://github.com/withastro/astro/commit/803dd8061df02138b4928442bcb76e77dcf6f5e7) Thanks [@ematipico](https://github.com/ematipico)! - The integration now exposes a function called `getContainerRenderer`, that can be used inside the Container APIs to load the relative renderer. - - ```js - import { experimental_AstroContainer as AstroContainer } from 'astro/container'; - import ReactWrapper from '../src/components/ReactWrapper.astro'; - import { loadRenderers } from 'astro:container'; - import { getContainerRenderer } from '@astrojs/react'; - - test('ReactWrapper with react renderer', async () => { - const renderers = await loadRenderers([getContainerRenderer()]); - const container = await AstroContainer.create({ - renderers, - }); - const result = await container.renderToString(ReactWrapper); - - expect(result).toContain('Counter'); - expect(result).toContain('Count: 5'); - }); - ``` - -## 4.1.0 - -### Minor Changes - -- [#11164](https://github.com/withastro/astro/pull/11164) [`cf9b2ff`](https://github.com/withastro/astro/commit/cf9b2ff7967c4287ab26ec65fc4bb2eed525a235) Thanks [@scottnath](https://github.com/scottnath)! - Removes deprecated `template` attribute and replaces deprecated domparser function - -## 4.0.1 - -### Patch Changes - -- [#9479](https://github.com/withastro/astro/pull/9479) [`1baf0b0d3cbd0564954c2366a7278794fad6726e`](https://github.com/withastro/astro/commit/1baf0b0d3cbd0564954c2366a7278794fad6726e) Thanks [@sarah11918](https://github.com/sarah11918)! - Updates README - -## 4.0.0 - -### Major Changes - -- [#8822](https://github.com/withastro/astro/pull/8822) [`b0a71946f`](https://github.com/withastro/astro/commit/b0a71946f4320d4e76f31e990fe5821f823f0e12) Thanks [@Geoffrey-Pliez](https://github.com/Geoffrey-Pliez)! - Upgrade to Lit 3.0 - -## 3.0.3 - -### Patch Changes - -- [#9018](https://github.com/withastro/astro/pull/9018) [`23c9a30ad`](https://github.com/withastro/astro/commit/23c9a30ad859398d62a013d639b5b2716b583331) Thanks [@augustjk](https://github.com/augustjk)! - Fix hydration ordering of nested custom elements. Child components will now wait for their parents to hydrate before hydrating themselves. - -## 3.0.2 - -### Patch Changes - -- [#8826](https://github.com/withastro/astro/pull/8826) [`754c40f6e`](https://github.com/withastro/astro/commit/754c40f6ed941a61362d221915568c04ae85d6ad) Thanks [@lilnasy](https://github.com/lilnasy)! - Fixed an issue where an incompatible version of lit was installed. - -## 3.0.1 - -### Patch Changes - -- [#8737](https://github.com/withastro/astro/pull/8737) [`6f60da805`](https://github.com/withastro/astro/commit/6f60da805e0014bc50dd07bef972e91c73560c3c) Thanks [@ematipico](https://github.com/ematipico)! - Add provenance statement when publishing the library from CI - -## 3.0.0 - -### Major Changes - -- [#8188](https://github.com/withastro/astro/pull/8188) [`d0679a666`](https://github.com/withastro/astro/commit/d0679a666f37da0fca396d42b9b32bbb25d29312) Thanks [@ematipico](https://github.com/ematipico)! - Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023. - -- [#8179](https://github.com/withastro/astro/pull/8179) [`6011d52d3`](https://github.com/withastro/astro/commit/6011d52d38e43c3e3d52bc3bc41a60e36061b7b7) Thanks [@matthewp](https://github.com/matthewp)! - Astro 3.0 Release Candidate - -## 3.0.0-rc.1 - -### Major Changes - -- [#8179](https://github.com/withastro/astro/pull/8179) [`6011d52d3`](https://github.com/withastro/astro/commit/6011d52d38e43c3e3d52bc3bc41a60e36061b7b7) Thanks [@matthewp](https://github.com/matthewp)! - Astro 3.0 Release Candidate - -## 3.0.0-beta.0 - -### Major Changes - -- [`1eae2e3f7`](https://github.com/withastro/astro/commit/1eae2e3f7d693c9dfe91c8ccfbe606d32bf2fb81) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023. - -## 2.1.1 - -### Patch Changes - -- [#7985](https://github.com/withastro/astro/pull/7985) [`ec06dd9bb`](https://github.com/withastro/astro/commit/ec06dd9bbb29cc38e891517fbf884cb7083b3240) Thanks [@delucis](https://github.com/delucis)! - Fix formatting in Lit README - -## 2.1.0 - -### Minor Changes - -- [#7373](https://github.com/withastro/astro/pull/7373) [`0986a44dd`](https://github.com/withastro/astro/commit/0986a44ddd2b48edbe318f6fceb7f4ce4670ce05) Thanks [@matthewp](https://github.com/matthewp)! - Upgrade lit dependencies - -## 2.0.2 - -### Patch Changes - -- [#7104](https://github.com/withastro/astro/pull/7104) [`826e02890`](https://github.com/withastro/astro/commit/826e0289005f645b902375b98d5549c6a95ccafa) Thanks [@bluwy](https://github.com/bluwy)! - Specify `"files"` field to only publish necessary files - -## 2.0.1 - -### Patch Changes - -- [#6752](https://github.com/withastro/astro/pull/6752) [`c7eb0d431`](https://github.com/withastro/astro/commit/c7eb0d431032edc5d4af72726d84e1c52ef36575) Thanks [@augustjk](https://github.com/augustjk)! - Provide `renderInfo` when rendering Lit components. Fixes issue with rendering nested components. - -## 2.0.0 - -### Major Changes - -- [#6681](https://github.com/withastro/astro/pull/6681) [`4b077318f`](https://github.com/withastro/astro/commit/4b077318fbc21c4350cc21c380d96b54d302759c) Thanks [@e111077](https://github.com/e111077)! - Update to use `@lit-labs/ssr@^3` - **[BREAKING]** DOM shim required for Lit SSR has been greatly reduced. `window`, `document`, and other objects are no longer available in global. Most SSR-ready component code should not be affected but, if so, they can be fixed with optional chaining or by using the `isServer` environment checker from the `lit` package. See [lit.dev docs on authoring components for SSR].(https://lit.dev/docs/ssr/authoring/#browser-only-code) - **[BREAKING]** Adds compatibility with `lit@2.7.0` hydration behavior. Do not update if you're using `lit@2.6.1` or lower. - Includes support for template[shadowrootmode] support. - -## 1.3.0 - -### Minor Changes - -- [#6213](https://github.com/withastro/astro/pull/6213) [`afbbc4d5b`](https://github.com/withastro/astro/commit/afbbc4d5bfafc1779bac00b41c2a1cb1c90f2808) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Updated compilation settings to disable downlevelling for Node 14 - -## 1.2.1 - -### Patch Changes - -- [#6351](https://github.com/withastro/astro/pull/6351) [`26bf12ef3`](https://github.com/withastro/astro/commit/26bf12ef3c7ab874a23ac753f841f7bb329c9361) Thanks [@hrmcdonald](https://github.com/hrmcdonald)! - Render DSD attributes based on `shadowRootOptions` - -## 1.2.0 - -### Minor Changes - -- [#6111](https://github.com/withastro/astro/pull/6111) [`ec38a8921`](https://github.com/withastro/astro/commit/ec38a8921f02a275949abcababe1b8afdf8184a2) Thanks [@e111077](https://github.com/e111077)! - Implement client:only functionality in Lit and add lit to the client:only warning - -## 1.1.2 - -### Patch Changes - -- [#6080](https://github.com/withastro/astro/pull/6080) [`0db220415`](https://github.com/withastro/astro/commit/0db22041531d981a813a07f4c4e00cfb7ebddd51) Thanks [@e111077](https://github.com/e111077)! - Fixes Lit hydration not having the same reactive values as server (losing state upon hydration) - -- [#6055](https://github.com/withastro/astro/pull/6055) [`2567aa48b`](https://github.com/withastro/astro/commit/2567aa48bba8751cf7e10429555f1e85830c9169) Thanks [@e111077](https://github.com/e111077)! - Add forwards compatibility for streaming Declarative Shadow DOM - -## 1.1.1 - -### Patch Changes - -- [#5478](https://github.com/withastro/astro/pull/5478) [`1c7eef308`](https://github.com/withastro/astro/commit/1c7eef308e808aa5ed4662b53e67ec8d1b814d1f) Thanks [@nemo0](https://github.com/nemo0)! - Update READMEs for consistency - -## 1.1.0 - -### Minor Changes - -- [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Only shim fetch if not already present - -- [#5791](https://github.com/withastro/astro/pull/5791) [`f7aa1ec25`](https://github.com/withastro/astro/commit/f7aa1ec25d1584f7abd421903fbef66b1c050e2a) Thanks [@ba55ie](https://github.com/ba55ie)! - Fix Lit slotted content - -## 1.0.2 - -### Patch Changes - -- [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Only shim fetch if not already present - -- [#5776](https://github.com/withastro/astro/pull/5776) [`6a31433ed`](https://github.com/withastro/astro/commit/6a31433ed79c7f84fd3ce602005b42ad95007d84) & [#5791](https://github.com/withastro/astro/pull/5791) [`f7aa1ec25`](https://github.com/withastro/astro/commit/f7aa1ec25d1584f7abd421903fbef66b1c050e2a) Thanks [@ba55ie](https://github.com/ba55ie)! - Fix Lit slotted content - -## 1.0.2-beta.0 - -
-See changes in 1.0.2-beta.0 - -### Patch Changes - -- [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Only shim fetch if not already present - -- [#5791](https://github.com/withastro/astro/pull/5791) [`f7aa1ec25`](https://github.com/withastro/astro/commit/f7aa1ec25d1584f7abd421903fbef66b1c050e2a) Thanks [@ba55ie](https://github.com/ba55ie)! - Fix Lit slotted content - -
- -## 1.0.1 - -### Patch Changes - -- [#4503](https://github.com/withastro/astro/pull/4503) [`1222ab954`](https://github.com/withastro/astro/commit/1222ab9540d17e4e7e811240b8a2a039acc333cb) Thanks [@matthewp](https://github.com/matthewp)! - Allow using Lit's decorators - -## 1.0.0 - -### Major Changes - -- [`04ad44563`](https://github.com/withastro/astro/commit/04ad445632c67bdd60c1704e1e0dcbcaa27b9308) - > Astro v1.0 is out! Read the [official announcement post](https://astro.build/blog/astro-1/). - - **No breaking changes**. This package is now officially stable and compatible with `astro@1.0.0`! - -## 0.3.2 - -### Patch Changes - -- [#4009](https://github.com/withastro/astro/pull/4009) [`01ba07d8f`](https://github.com/withastro/astro/commit/01ba07d8fa7eb67530b47b8530d65906f1aebf6e) Thanks [@matthewp](https://github.com/matthewp)! - Fixes Lit compat with Vite 3.0.1 - -## 0.3.1 - -### Patch Changes - -- [#3854](https://github.com/withastro/astro/pull/3854) [`b012ee55`](https://github.com/withastro/astro/commit/b012ee55b107dea0730286263b27d83e530fad5d) Thanks [@bholmesdev](https://github.com/bholmesdev)! - [astro add] Support adapters and third party packages - -## 0.3.0 - -### Minor Changes - -- [#3652](https://github.com/withastro/astro/pull/3652) [`7373d61c`](https://github.com/withastro/astro/commit/7373d61cdcaedd64bf5fd60521b157cfa4343558) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Adds support for passing named slots from `.astro` => Lit components. - - All slots are treated as Light DOM content. - -## 0.2.0 - -### Minor Changes - -- [#3625](https://github.com/withastro/astro/pull/3625) [`f5afaf24`](https://github.com/withastro/astro/commit/f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e) Thanks [@matthewp](https://github.com/matthewp)! - Conform to Constructor based rendering - - This changes `@astrojs/lit` to conform to the way rendering happens in all other frameworks. Instead of using the tag name `` you use the imported constructor function, `` like you would do with any other framework. - - Support for `tag-name` syntax had to be removed due to the fact that it was a runtime feature that was not statically analyzable. To improve build performance, we have removed all runtime based component discovery. Using the imported Constructor name allows Astro to discover what components need to be built and bundled for production without ever running your file. - -## 0.1.5 - -### Patch Changes - -- [#3511](https://github.com/withastro/astro/pull/3511) [`2fedb974`](https://github.com/withastro/astro/commit/2fedb974899b37a8d9ddabc476764a6d35d1e446) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Patch Lit's server shim to allow for `sass` compatibility - -## 0.1.4 - -### Patch Changes - -- [#3484](https://github.com/withastro/astro/pull/3484) [`55820fa7`](https://github.com/withastro/astro/commit/55820fa784d6d4f66a45092321a47c8ce9de5546) Thanks [@matthewp](https://github.com/matthewp)! - Wait for DOMCOntentLoaded to polyfill in Lit - -## 0.1.3 - -### Patch Changes - -- [#3375](https://github.com/withastro/astro/pull/3375) [`fe61e469`](https://github.com/withastro/astro/commit/fe61e469b243c27781112499f151782baf9004a4) Thanks [@jdvivar](https://github.com/jdvivar)! - Added tests and fix a small edge case for when you call render with no props/attrs - -## 0.1.2 - -### Patch Changes - -- [#3164](https://github.com/withastro/astro/pull/3164) [`e85b16e2`](https://github.com/withastro/astro/commit/e85b16e2b3d846333f542139c82640de19bfd2f5) Thanks [@matthewp](https://github.com/matthewp)! - Fixes lit when running in SSR - -## 0.1.1 - -### Patch Changes - -- [`815d62f1`](https://github.com/withastro/astro/commit/815d62f151a36fef7d09590d4962ca71bda61b32) Thanks [@FredKSchott](https://github.com/FredKSchott)! - no changes. - -## 0.1.0 - -### Minor Changes - -- [#2979](https://github.com/withastro/astro/pull/2979) [`9d7a4b59`](https://github.com/withastro/astro/commit/9d7a4b59b53f8cb274266f5036d1cef841750252) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Welcome to the Astro v1.0.0 Beta! Read the [official announcement](https://astro.build/blog/astro-1-beta-release/) for more details. - -## 0.0.2 - -### Patch Changes - -- [#2885](https://github.com/withastro/astro/pull/2885) [`6b004363`](https://github.com/withastro/astro/commit/6b004363f99f27e581d1e2d53a2ebff39d7afb8a) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Add README across Astro built-in integrations - -* [#2847](https://github.com/withastro/astro/pull/2847) [`3b621f7a`](https://github.com/withastro/astro/commit/3b621f7a613b45983b090794fa7c015f23ed6140) Thanks [@tony-sull](https://github.com/tony-sull)! - Adds keywords to the official integrations to support discoverability on Astro's Integrations site - -## 0.0.2-next.0 - -### Patch Changes - -- [#2847](https://github.com/withastro/astro/pull/2847) [`3b621f7a`](https://github.com/withastro/astro/commit/3b621f7a613b45983b090794fa7c015f23ed6140) Thanks [@tony-sull](https://github.com/tony-sull)! - Adds keywords to the official integrations to support discoverability on Astro's Integrations site diff --git a/packages/integrations/lit/README.md b/packages/integrations/lit/README.md deleted file mode 100644 index 5d0acb5ed00a..000000000000 --- a/packages/integrations/lit/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# @astrojs/lit đŸ”¥ - -This **[Astro integration][astro-integration]** enables server-side rendering and client-side hydration for your [Lit](https://lit.dev/) custom elements. - -## Documentation - -Read the [`@astrojs/lit` docs][docs] - -## Support - -- Get help in the [Astro Discord][discord]. Post questions in our `#support` forum, or visit our dedicated `#dev` channel to discuss current development and more! - -- Check our [Astro Integration Documentation][astro-integration] for more on integrations. - -- Submit bug reports and feature requests as [GitHub issues][issues]. - -## Contributing - -This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! These links will help you get started: - -- [Contributor Manual][contributing] -- [Code of Conduct][coc] -- [Community Guide][community] - -## License - -MIT - -Copyright (c) 2023–present [Astro][astro] - -[astro]: https://astro.build/ -[docs]: https://docs.astro.build/en/guides/integrations-guide/lit/ -[contributing]: https://github.com/withastro/astro/blob/main/CONTRIBUTING.md -[coc]: https://github.com/withastro/.github/blob/main/CODE_OF_CONDUCT.md -[community]: https://github.com/withastro/.github/blob/main/COMMUNITY_GUIDE.md -[discord]: https://astro.build/chat/ -[issues]: https://github.com/withastro/astro/issues -[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/ diff --git a/packages/integrations/lit/client-shim.js b/packages/integrations/lit/client-shim.js deleted file mode 100644 index c28ee5edf32c..000000000000 --- a/packages/integrations/lit/client-shim.js +++ /dev/null @@ -1,16 +0,0 @@ -async function polyfill() { - const { hydrateShadowRoots } = await import( - '@webcomponents/template-shadowroot/template-shadowroot.js' - ); - window.addEventListener('DOMContentLoaded', () => hydrateShadowRoots(document.body), { - once: true, - }); -} - -const polyfillCheckEl = Document.parseHTMLUnsafe( - `

`, -).querySelector('p'); - -if (!polyfillCheckEl?.shadowRoot) { - polyfill(); -} diff --git a/packages/integrations/lit/client-shim.min.js b/packages/integrations/lit/client-shim.min.js deleted file mode 100644 index 0ec44c3faf9b..000000000000 --- a/packages/integrations/lit/client-shim.min.js +++ /dev/null @@ -1,85 +0,0 @@ -/** @license Copyright 2020 Google LLC (BSD-3-Clause) */ -/** Bundled JS generated from "@astrojs/lit/client-shim.js" */ -var N = 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 }); -}; -function s() { - if (d === void 0) { - let t = document.createElement('div'); - (t.innerHTML = '
'), - (d = !!t.firstElementChild.shadowRoot); - } - return d; -} -var d, - m = i(() => {}); -var p, - c, - f, - u = i(() => { - (p = (t) => t.parentElement === null), - (c = (t) => t.tagName === 'TEMPLATE'), - (f = (t) => t.nodeType === Node.ELEMENT_NODE); - }); -var h, - E = i(() => { - m(); - u(); - h = (t) => { - var n; - if (s()) return; - let a = [], - e = t.firstElementChild; - for (; e !== t && e !== null; ) - if (c(e)) a.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(); - let r = o.parentElement, - l = o.getAttribute('shadowroot'); - if (((e = o), l === 'open' || l === 'closed')) { - let y = o.hasAttribute('shadowrootdelegatesfocus'); - try { - r.attachShadow({ mode: l, delegatesFocus: y }).append(o.content); - } catch {} - } else o = void 0; - } else { - let r = e.nextElementSibling; - if (r != null) { - (e = r), o !== void 0 && o.parentElement.removeChild(o); - break; - } - let l = - (n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling; - if (l != null) { - (e = l), o !== void 0 && o.parentElement.removeChild(o); - break; - } - (e = e.parentElement), o !== void 0 && (o.parentElement.removeChild(o), (o = void 0)); - } - } - }; - }); -var w = i(() => { - E(); -}); -var v = {}; -b(v, { hasNativeDeclarativeShadowRoots: () => s, hydrateShadowRoots: () => h }); -var S = i(() => { - m(); - w(); -}); -async function g() { - let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v)); - window.addEventListener('DOMContentLoaded', () => t(document.body), { once: true }); -} -var x = Document.parseHTMLUnsafe( - '

', -).querySelector('p'); -(!x || !x.shadowRoot) && g(); diff --git a/packages/integrations/lit/hydration-support.js b/packages/integrations/lit/hydration-support.js deleted file mode 100644 index 0f367ae0ba70..000000000000 --- a/packages/integrations/lit/hydration-support.js +++ /dev/null @@ -1,2 +0,0 @@ -// @ts-check -import '@lit-labs/ssr-client/lit-element-hydrate-support.js'; diff --git a/packages/integrations/lit/package.json b/packages/integrations/lit/package.json deleted file mode 100644 index 6f6bcacb34dc..000000000000 --- a/packages/integrations/lit/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@astrojs/lit", - "version": "4.3.0", - "description": "Use Lit components within Astro", - "type": "module", - "types": "./dist/index.d.ts", - "author": "withastro", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/withastro/astro.git", - "directory": "packages/integrations/lit" - }, - "keywords": [ - "astro-integration", - "astro-component", - "renderer", - "lit" - ], - "bugs": "https://github.com/withastro/astro/issues", - "homepage": "https://docs.astro.build/en/guides/integrations-guide/lit/", - "exports": { - ".": "./dist/index.js", - "./server.js": { - "default": "./server.js", - "types": "./server.d.ts" - }, - "./client-shim.js": "./client-shim.js", - "./dist/client.js": "./dist/client.js", - "./hydration-support.js": "./hydration-support.js", - "./package.json": "./package.json" - }, - "files": [ - "dist", - "client-shim.js", - "client-shim.min.js", - "hydration-support.js", - "server.js", - "server.d.ts", - "server-shim.js" - ], - "scripts": { - "build": "astro-scripts build \"src/**/*.ts\" && tsc", - "build:ci": "astro-scripts build \"src/**/*.ts\"", - "dev": "astro-scripts dev \"src/**/*.ts\"", - "test": "astro-scripts test \"test/**/*.test.js\"" - }, - "dependencies": { - "@lit-labs/ssr": "^3.2.2", - "@lit-labs/ssr-client": "^1.1.7", - "@lit-labs/ssr-dom-shim": "^1.2.1", - "parse5": "^7.1.2" - }, - "overrides": { - "@lit-labs/ssr": { - "@lit-labs/ssr-client": "1.1.7" - } - }, - "devDependencies": { - "astro": "workspace:*", - "astro-scripts": "workspace:*", - "cheerio": "1.0.0", - "lit": "^3.2.0", - "sass": "^1.77.8" - }, - "peerDependencies": { - "@webcomponents/template-shadowroot": "^0.2.1", - "lit": "^3.1.0" - }, - "publishConfig": { - "provenance": true - } -} diff --git a/packages/integrations/lit/server-shim.js b/packages/integrations/lit/server-shim.js deleted file mode 100644 index d777382f2ce8..000000000000 --- a/packages/integrations/lit/server-shim.js +++ /dev/null @@ -1,35 +0,0 @@ -import { customElements as litCE, HTMLElement as litShimHTMLElement } from '@lit-labs/ssr-dom-shim'; - -// Something at build time injects document.currentScript = undefined instead of -// document.currentScript = null. This causes Sass build to fail because it -// seems to be expecting `=== null`. This set to `undefined` doesn't seem to be -// caused by Lit and only happens at build / test time, but not in dev or -// preview time. -if (globalThis.document) { - document.currentScript = null; -} - -if (globalThis.HTMLElement) { - // Seems Astro's Element shim does nothing when `.setAttribute` is called - // and subsequently `.getAttribute` is called. Causes Lit to not SSR attrs - globalThis.HTMLElement = litShimHTMLElement; -} - -// Astro seems to have a DOM shim and the only real difference that we need out -// of the Lit DOM shim is that the Lit DOM shim reads -// `HTMLElement.observedAttributes` which is meant to trigger -// `ReactiveElement.finalize()`. So this is the only thing we will re-shim since -// Lit will try to respect other global DOM shims. -globalThis.customElements = litCE; - -const litCeDefine = customElements.define; - -// We need to patch customElements.define to keep track of the tagName on the -// class itself so that we can transform JSX custom element class definition to -// a DSD string on the server, because there is no way to get the tagName from a -// CE class otherwise. Not an issue on client:only because the browser supports -// appending a class instance directly to the DOM. -customElements.define = function (tagName, Ctr) { - Ctr[Symbol.for('tagName')] = tagName; - return litCeDefine.call(this, tagName, Ctr); -}; diff --git a/packages/integrations/lit/server.d.ts b/packages/integrations/lit/server.d.ts deleted file mode 100644 index bb2f29556c14..000000000000 --- a/packages/integrations/lit/server.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { NamedSSRLoadedRendererValue } from 'astro'; -export default NamedSSRLoadedRendererValue; diff --git a/packages/integrations/lit/server.js b/packages/integrations/lit/server.js deleted file mode 100644 index d1da3c6c9195..000000000000 --- a/packages/integrations/lit/server.js +++ /dev/null @@ -1,118 +0,0 @@ -// Separate import from the rest so it doesn't get re-organized after other imports -import './server-shim.js'; - -import { LitElementRenderer } from '@lit-labs/ssr/lib/lit-element-renderer.js'; -import * as parse5 from 'parse5'; - -function isCustomElementTag(name) { - return typeof name === 'string' && name.includes('-'); -} - -function getCustomElementConstructor(name) { - if (typeof customElements !== 'undefined' && isCustomElementTag(name)) { - return customElements.get(name) || null; - } else if (typeof name === 'function') { - return name; - } - return null; -} - -async function isLitElement(Component) { - const Ctr = getCustomElementConstructor(Component); - return !!Ctr?._$litElement$; -} - -async function check(Component) { - // Lit doesn't support getting a tagName from a Constructor at this time. - // So this must be a string at the moment. - return !!(await isLitElement(Component)); -} - -function* render(Component, attrs, slots) { - let tagName = Component; - if (typeof tagName !== 'string') { - tagName = Component[Symbol.for('tagName')]; - } - const instance = new LitElementRenderer(tagName); - - // LitElementRenderer creates a new element instance, so copy over. - const Ctr = getCustomElementConstructor(tagName); - let shouldDeferHydration = false; - - if (attrs) { - for (let [name, value] of Object.entries(attrs)) { - const isReactiveProperty = name in Ctr.prototype; - const isReflectedReactiveProperty = Ctr.elementProperties.get(name)?.reflect; - - // Only defer hydration if we are setting a reactive property that cannot - // be reflected / serialized as a property. - shouldDeferHydration ||= isReactiveProperty && !isReflectedReactiveProperty; - - if (isReactiveProperty) { - instance.setProperty(name, value); - } else { - instance.setAttribute(name, value); - } - } - } - - instance.connectedCallback(); - - yield `<${tagName}${shouldDeferHydration ? ' defer-hydration' : ''}`; - yield* instance.renderAttributes(); - yield `>`; - const shadowContents = instance.renderShadow({ - elementRenderers: [LitElementRenderer], - customElementInstanceStack: [instance], - customElementHostStack: [instance], - deferHydration: false, - }); - if (shadowContents !== undefined) { - const { mode = 'open', delegatesFocus } = instance.shadowRootOptions ?? {}; - // `delegatesFocus` is intentionally allowed to coerce to boolean to - // match web platform behavior. - const delegatesfocusAttr = delegatesFocus ? ' shadowrootdelegatesfocus' : ''; - yield `'; - } - if (slots) { - for (let [slot, value = ''] of Object.entries(slots)) { - if (slot !== 'default' && value) { - // Parse the value as a concatenated string - const fragment = parse5.parseFragment(`${value}`); - - // Add the missing slot attribute to child Element nodes - for (const node of fragment.childNodes) { - if (node.tagName && !node.attrs.some(({ name }) => name === 'slot')) { - node.attrs.push({ name: 'slot', value: slot }); - } - } - - value = parse5.serialize(fragment); - } - - yield value; - } - } - yield ``; -} - -async function renderToStaticMarkup(Component, props, slots) { - let tagName = Component; - - let out = ''; - for (let chunk of render(tagName, props, slots)) { - out += chunk; - } - - return { - html: out, - }; -} - -export default { - name: '@astrojs/lit', - check, - renderToStaticMarkup, -}; diff --git a/packages/integrations/lit/src/client.ts b/packages/integrations/lit/src/client.ts deleted file mode 100644 index 9a573d8eefbd..000000000000 --- a/packages/integrations/lit/src/client.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Adds the appropriate slot attribute to each top-level node in the given HTML - * string. - * - * @example - * addSlotAttrsToHtmlString('foo', '
bar
baz
'); - * // '
bar
baz
' - * - * @param slotName Name of slot to apply to HTML string. - * @param html Stringified HTML that should be projected into the given slotname. - * @returns A stringified HTML string with the slot attribute applied to each top-level node. - */ -const addSlotAttrsToHtmlString = (slotName: string, html: string) => { - const templ = document.createElement('template'); - templ.innerHTML = html; - Array.from(templ.content.children).forEach((node) => { - node.setAttribute('slot', slotName); - }); - return templ.innerHTML; -}; - -export default (element: HTMLElement) => - async ( - Component: any, - props: Record, - { default: defaultChildren, ...slotted }: { default: string; [slotName: string]: string }, - ) => { - // Get the LitElement element instance. - let component = element.children[0]; - // Check if hydration model is client:only - const isClientOnly = element.getAttribute('client') === 'only'; - - // We need to attach the element and it's children to the DOM since it's not - // SSR'd. - if (isClientOnly) { - component = new Component(); - - const otherSlottedChildren = Object.entries(slotted) - .map(([slotName, htmlStr]) => addSlotAttrsToHtmlString(slotName, htmlStr)) - .join(''); - - // defaultChildren can actually be undefined, but TS will complain if we - // type it as so, make sure we don't render undefined. - component.innerHTML = `${defaultChildren ?? ''}${otherSlottedChildren}`; - element.appendChild(component); - - // Set props bound to non-reactive properties as attributes. - for (let [name, value] of Object.entries(props)) { - if (!(name in Component.prototype)) { - component.setAttribute(name, value); - } - } - } - - // If there is no deferral of hydration, then all reactive properties are - // already serialized as reflected attributes, or no reactive props were set - // Alternatively, if hydration is client:only proceed to set props. - if (!component || !(component.hasAttribute('defer-hydration') || isClientOnly)) { - return; - } - - // Set properties on the LitElement instance for resuming hydration. - for (let [name, value] of Object.entries(props)) { - // Check if reactive property or class property. - if (name in Component.prototype) { - (component as any)[name] = value; - } - } - - // Tell LitElement to resume hydration. - component.removeAttribute('defer-hydration'); - }; diff --git a/packages/integrations/lit/src/index.ts b/packages/integrations/lit/src/index.ts deleted file mode 100644 index 94a6d683a502..000000000000 --- a/packages/integrations/lit/src/index.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { readFileSync } from 'node:fs'; -import type { AstroIntegration, ContainerRenderer } from 'astro'; - -function getViteConfiguration() { - return { - optimizeDeps: { - include: [ - '@astrojs/lit/dist/client.js', - '@astrojs/lit/client-shim.js', - '@astrojs/lit/hydration-support.js', - '@webcomponents/template-shadowroot/template-shadowroot.js', - '@lit-labs/ssr-client/lit-element-hydrate-support.js', - ], - exclude: ['@astrojs/lit/server.js'], - }, - ssr: { - external: ['lit-element', '@lit-labs/ssr', '@astrojs/lit', 'lit/decorators.js'], - }, - }; -} - -export function getContainerRenderer(): ContainerRenderer { - return { - name: '@astrojs/lit', - serverEntrypoint: '@astrojs/lit/server.js', - }; -} - -export default function (): AstroIntegration { - return { - name: '@astrojs/lit', - hooks: { - 'astro:config:setup': ({ updateConfig, addRenderer, injectScript }) => { - // Inject the necessary polyfills on every page (inlined for speed). - injectScript( - 'head-inline', - readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' }), - ); - // Inject the hydration code, before a component is hydrated. - injectScript('before-hydration', `import '@astrojs/lit/hydration-support.js';`); - // Add the lit renderer so that Astro can understand lit components. - addRenderer({ - name: '@astrojs/lit', - serverEntrypoint: '@astrojs/lit/server.js', - clientEntrypoint: '@astrojs/lit/dist/client.js', - }); - // Update the vite configuration. - updateConfig({ - vite: getViteConfiguration(), - }); - }, - 'astro:build:setup': ({ vite, target }) => { - if (target === 'server') { - if (!vite.ssr) { - vite.ssr = {}; - } - if (!vite.ssr.noExternal) { - vite.ssr.noExternal = []; - } - if (Array.isArray(vite.ssr.noExternal)) { - vite.ssr.noExternal.push('lit'); - } - } - }, - }, - }; -} diff --git a/packages/integrations/lit/test/sass.test.js b/packages/integrations/lit/test/sass.test.js deleted file mode 100644 index a6cbfae8bc43..000000000000 --- a/packages/integrations/lit/test/sass.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import * as assert from 'node:assert/strict'; -import { describe, it } from 'node:test'; - -describe('check', () => { - it('should be able to load sass', async () => { - let error = null; - try { - await import(new URL('../server-shim.js', import.meta.url)); - await import('sass'); - } catch (e) { - error = e; - } - assert.equal(error, null); - }); -}); diff --git a/packages/integrations/lit/test/server.test.js b/packages/integrations/lit/test/server.test.js deleted file mode 100644 index bcecef2f681d..000000000000 --- a/packages/integrations/lit/test/server.test.js +++ /dev/null @@ -1,134 +0,0 @@ -import * as assert from 'node:assert/strict'; -import { describe, it } from 'node:test'; -import * as cheerio from 'cheerio'; -import { LitElement, html } from 'lit'; -// Must come after lit import because @lit/reactive-element defines -// globalThis.customElements which the server shim expects to be defined. -import server from '../server.js'; - -const { check, renderToStaticMarkup } = server; - -describe('check', () => { - it('should be false with no component', async () => { - assert.equal(await check(), false); - }); - - it('should be false with a registered non-lit component', async () => { - const tagName = 'non-lit-component'; - // Lit no longer shims HTMLElement globally, so we need to do it ourselves. - if (!globalThis.HTMLElement) { - globalThis.HTMLElement = class {}; - } - customElements.define(tagName, class TestComponent extends HTMLElement {}); - assert.equal(await check(tagName), false); - }); - - it('should be true with a registered lit component', async () => { - const tagName = 'lit-component'; - customElements.define(tagName, class extends LitElement {}); - assert.equal(await check(tagName), true); - }); -}); - -describe('renderToStaticMarkup', () => { - it('should throw error if trying to render an unregistered component', async () => { - const tagName = 'non-registrered-component'; - try { - await renderToStaticMarkup(tagName); - } catch (e) { - assert.equal(e instanceof TypeError, true); - } - }); - - it('should render empty component with default markup', async () => { - const tagName = 'nothing-component'; - customElements.define(tagName, class extends LitElement {}); - const render = await renderToStaticMarkup(tagName); - assert.deepEqual(render, { - html: `<${tagName}>`, - }); - }); - - it('should render component with default markup', async () => { - const tagName = 'simple-component'; - customElements.define( - tagName, - class extends LitElement { - render() { - return html`

hola

`; - } - }, - ); - const render = await renderToStaticMarkup(tagName); - const $ = cheerio.load(render.html); - assert.equal($(`${tagName} template`).html().includes('

hola

'), true); - }); - - it('should render component with properties and attributes', async () => { - const tagName = 'props-and-attrs-component'; - const attr1 = 'test'; - const prop1 = 'Daniel'; - customElements.define( - tagName, - class extends LitElement { - static properties = { - prop1: { type: String }, - }; - - constructor() { - super(); - this.prop1 = 'someone'; - } - - render() { - return html`

Hello ${this.prop1}

`; - } - }, - ); - const render = await renderToStaticMarkup(tagName, { prop1, attr1 }); - const $ = cheerio.load(render.html); - assert.equal($(tagName).attr('attr1'), attr1); - assert.equal($(`${tagName} template`).text().includes(`Hello ${prop1}`), true); - }); - - it('should render nested components', async () => { - const tagName = 'parent-component'; - const childTagName = 'child-component'; - customElements.define( - childTagName, - class extends LitElement { - render() { - return html`

child

`; - } - }, - ); - customElements.define( - tagName, - class extends LitElement { - render() { - return html``; - } - }, - ); - const render = await renderToStaticMarkup(tagName); - const $ = cheerio.load(render.html); - assert.equal($(`${tagName} template`).text().includes('child'), true); - // Child component should have `defer-hydration` attribute so it'll only - // hydrate after the parent hydrates - assert.equal($(childTagName).attr('defer-hydration'), ''); - }); - - it('should render DSD attributes based on shadowRootOptions', async () => { - const tagName = 'shadow-root-options-component'; - customElements.define( - tagName, - class extends LitElement { - static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true }; - }, - ); - const render = await renderToStaticMarkup(tagName); - assert.deepEqual(render, { - html: `<${tagName}>`, - }); - }); -}); diff --git a/packages/integrations/lit/tsconfig.json b/packages/integrations/lit/tsconfig.json deleted file mode 100644 index 1504b4b6dfa4..000000000000 --- a/packages/integrations/lit/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "outDir": "./dist" - } -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 64c206e7e8f1..4a86db9fbb85 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -180,21 +180,6 @@ importers: specifier: ^4.14.2 version: link:../../packages/astro - examples/framework-lit: - dependencies: - '@astrojs/lit': - specifier: ^4.3.0 - version: link:../../packages/integrations/lit - '@webcomponents/template-shadowroot': - specifier: ^0.2.1 - version: 0.2.1 - astro: - specifier: ^4.14.2 - version: link:../../packages/astro - lit: - specifier: ^3.2.0 - version: 3.2.0 - examples/framework-multiple: dependencies: '@astrojs/preact': @@ -1176,21 +1161,6 @@ importers: specifier: workspace:* version: link:../../.. - packages/astro/e2e/fixtures/lit-component: - dependencies: - '@astrojs/lit': - specifier: workspace:* - version: link:../../../../integrations/lit - '@webcomponents/template-shadowroot': - specifier: ^0.2.1 - version: 0.2.1 - astro: - specifier: workspace:* - version: link:../../.. - lit: - specifier: ^3.2.0 - version: 3.2.0 - packages/astro/e2e/fixtures/multiple-frameworks: dependencies: '@webcomponents/template-shadowroot': @@ -1218,9 +1188,6 @@ importers: specifier: ^3.4.37 version: 3.4.37(typescript@5.5.4) devDependencies: - '@astrojs/lit': - specifier: workspace:* - version: link:../../../../integrations/lit '@astrojs/preact': specifier: workspace:* version: link:../../../../integrations/preact @@ -3361,21 +3328,6 @@ importers: specifier: workspace:* version: link:../../.. - packages/astro/test/fixtures/lit-element: - dependencies: - '@astrojs/lit': - specifier: workspace:* - version: link:../../../../integrations/lit - '@webcomponents/template-shadowroot': - specifier: ^0.2.1 - version: 0.2.1 - astro: - specifier: workspace:* - version: link:../../.. - lit: - specifier: ^3.2.0 - version: 3.2.0 - packages/astro/test/fixtures/markdown: dependencies: '@astrojs/preact': @@ -4538,37 +4490,6 @@ importers: packages/integrations/cloudflare: {} - packages/integrations/lit: - dependencies: - '@lit-labs/ssr': - specifier: ^3.2.2 - version: 3.2.2 - '@lit-labs/ssr-client': - specifier: ^1.1.7 - version: 1.1.7 - '@lit-labs/ssr-dom-shim': - specifier: ^1.2.1 - version: 1.2.1 - parse5: - specifier: ^7.1.2 - version: 7.1.2 - devDependencies: - astro: - specifier: workspace:* - version: link:../../astro - astro-scripts: - specifier: workspace:* - version: link:../../../scripts - cheerio: - specifier: 1.0.0 - version: 1.0.0 - lit: - specifier: ^3.2.0 - version: 3.2.0 - sass: - specifier: ^1.77.8 - version: 1.77.8 - packages/integrations/markdoc: dependencies: '@astrojs/internal-helpers': @@ -7121,16 +7042,9 @@ packages: cpu: [x64] os: [win32] - '@lit-labs/ssr-client@1.1.7': - resolution: {integrity: sha512-VvqhY/iif3FHrlhkzEPsuX/7h/NqnfxLwVf0p8ghNIlKegRyRqgeaJevZ57s/u/LiFyKgqksRP5n+LmNvpxN+A==} - '@lit-labs/ssr-dom-shim@1.2.1': resolution: {integrity: sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==} - '@lit-labs/ssr@3.2.2': - resolution: {integrity: sha512-He5TzeNPM9ECmVpgXRYmVlz0UA5YnzHlT43kyLi2Lu6mUidskqJVonk9W5K699+2DKhoXp8Ra4EJmHR6KrcW1Q==} - engines: {node: '>=13.9.0'} - '@lit/reactive-element@2.0.4': resolution: {integrity: sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==} @@ -7234,9 +7148,6 @@ packages: '@oslojs/encoding@0.4.1': resolution: {integrity: sha512-hkjo6MuIK/kQR5CrGNdAPZhS01ZCXuWDRJ187zh6qqF2+yMHZpD9fAYpX8q2bOO6Ryhl3XpCT6kUX76N8hhm4Q==} - '@parse5/tools@0.3.0': - resolution: {integrity: sha512-zxRyTHkqb7WQMV8kTNBKWb1BeOFUKXBXTBWuxg9H9hfvQB3IwP6Iw2U75Ia5eyRxPNltmY7E8YAlz6zWwUnjKg==} - '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -7538,9 +7449,6 @@ packages: '@types/node@12.20.55': resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} - '@types/node@16.18.96': - resolution: {integrity: sha512-84iSqGXoO+Ha16j8pRZ/L90vDMKX04QTYMTfYeE1WrjWaZXuchBehGUZEpNgx7JnmlrIHdnABmpjrQjhCnNldQ==} - '@types/node@17.0.45': resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} @@ -8676,10 +8584,6 @@ packages: encoding-sniffer@0.2.0: resolution: {integrity: sha512-ju7Wq1kg04I3HtiYIOrUrdfdDvkyO9s5XM8QAj/bN61Yo/Vb4vgJxy5vi4Yxk01gWHbrofpPtpxM8bKger9jhg==} - enhanced-resolve@5.16.0: - resolution: {integrity: sha512-O+QWCviPNSSLAD9Ucn8Awv+poAkqn3T1XY5/N7kR7rQO9yfSGWkYZDwpJ+iKF7B8rxaQKWngSqACpgzeapSyoA==} - engines: {node: '>=10.13.0'} - enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} @@ -11113,10 +11017,6 @@ packages: engines: {node: '>=14.0.0'} hasBin: true - tapable@2.2.1: - resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} - engines: {node: '>=6'} - tar@6.2.1: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} @@ -13018,28 +12918,8 @@ snapshots: '@libsql/win32-x64-msvc@0.4.1': optional: true - '@lit-labs/ssr-client@1.1.7': - dependencies: - '@lit/reactive-element': 2.0.4 - lit: 3.2.0 - lit-html: 3.2.0 - '@lit-labs/ssr-dom-shim@1.2.1': {} - '@lit-labs/ssr@3.2.2': - dependencies: - '@lit-labs/ssr-client': 1.1.7 - '@lit-labs/ssr-dom-shim': 1.2.1 - '@lit/reactive-element': 2.0.4 - '@parse5/tools': 0.3.0 - '@types/node': 16.18.96 - enhanced-resolve: 5.16.0 - lit: 3.2.0 - lit-element: 4.1.0 - lit-html: 3.2.0 - node-fetch: 3.3.2 - parse5: 7.1.2 - '@lit/reactive-element@2.0.4': dependencies: '@lit-labs/ssr-dom-shim': 1.2.1 @@ -13194,10 +13074,6 @@ snapshots: '@oslojs/encoding@0.4.1': {} - '@parse5/tools@0.3.0': - dependencies: - parse5: 7.1.2 - '@pkgjs/parseargs@0.11.0': optional: true @@ -13497,8 +13373,6 @@ snapshots: '@types/node@12.20.55': {} - '@types/node@16.18.96': {} - '@types/node@17.0.45': {} '@types/node@18.19.31': @@ -14675,11 +14549,6 @@ snapshots: iconv-lite: 0.6.3 whatwg-encoding: 3.1.1 - enhanced-resolve@5.16.0: - dependencies: - graceful-fs: 4.2.11 - tapable: 2.2.1 - enquirer@2.4.1: dependencies: ansi-colors: 4.1.3 @@ -17784,8 +17653,6 @@ snapshots: transitivePeerDependencies: - ts-node - tapable@2.2.1: {} - tar@6.2.1: dependencies: chownr: 2.0.0