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

SSR #80

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open

SSR #80

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
47ad49d
feat: first working setup for ssr
tpluscode Jan 25, 2023
b1ad666
fix: invalid selector sometimes
tpluscode Jan 25, 2023
8962c7b
make it build-able
tpluscode Jan 26, 2023
fa5100a
simplify vite package
tpluscode Jan 27, 2023
2d8f3c9
more prototyping
tpluscode Jan 28, 2023
dd86885
chore: will release 0.0.1
tpluscode Jan 28, 2023
4c950af
lint: broken config
tpluscode Jan 28, 2023
97f81d7
build: broken imports/deps
tpluscode Jan 28, 2023
4a1fb5c
lint: exclude storybook
tpluscode Jan 28, 2023
61a3aca
ci: playwright
tpluscode Jan 28, 2023
0b58e31
test: fix
tpluscode Jan 28, 2023
74e56d2
test: fix
tpluscode Jan 28, 2023
c3290ac
chore: wikibus example
tpluscode Jan 29, 2023
7fc39e6
wip
tpluscode Jan 30, 2023
fc71ad1
build(deps-dev): update eslint config
tpluscode Jan 30, 2023
40c4ae2
demo: load linked pages with schema:mainEntity
tpluscode Feb 1, 2023
11a2ce8
demo: flex-wrap main items
tpluscode Feb 1, 2023
a03c730
demo: description field
tpluscode Feb 2, 2023
458d833
fix: order properties
tpluscode Feb 3, 2023
fbb190d
wip
tpluscode Mar 16, 2023
6bd880f
chore: update deps to esm
tpluscode Mar 31, 2023
556f751
feat: default uri viewer
tpluscode Mar 31, 2023
b38d907
feat: reuse props with sh:and
tpluscode Mar 31, 2023
eb15f42
build: no longer needed?
tpluscode Mar 31, 2023
c3139ce
fix: large generated queries
tpluscode Apr 26, 2023
d382111
demo: hacked together n3-powered generated queries
tpluscode Apr 28, 2023
05b02e9
demo: vehicles page and removes n3
tpluscode Apr 29, 2023
3ba87e7
spike: viewer chains
tpluscode May 4, 2023
85c7849
feat: fallback images
tpluscode May 5, 2023
92a59c8
feat: filter brands
tpluscode May 15, 2023
55d51dd
feat: chain
tpluscode May 19, 2023
0e58ce9
feat: paging by page index
tpluscode May 20, 2023
3806367
chore: log Q
tpluscode May 20, 2023
1e899e8
adding hydra pager, ssr build
tpluscode Jun 18, 2023
549e150
build: patch masonry layout
tpluscode Jun 18, 2023
1a14050
prepare build
tpluscode Jun 24, 2023
9f57323
build(deps): update lit-ssr
tpluscode Jun 24, 2023
26c57ec
chore: remove old package
tpluscode Jul 3, 2023
2e6ed53
fix: loose namespace builders
tpluscode Jul 3, 2023
c2aae10
styleL unused ignores
tpluscode Jul 3, 2023
cbbb5e6
ci: remove storybook builds
tpluscode Jul 3, 2023
007759c
fix: slot
tpluscode Jul 5, 2023
271c617
build(deps): update typescript
tpluscode Jul 7, 2023
8471751
test: playwright
tpluscode Jul 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .changeset/wise-balloons-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hydrofoil/roadshow": minor
"@hydrofoil/roadshow-ssr": patch
"@hydrofoil/roadshow-vite": patch
---

Rewrite to put emphasis on server-side rendering
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

12 changes: 11 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"no-param-reassign": ["error", { "props": false }]
},
"overrides": [{
"files": "**/test/**/*.ts",
"files": ["**/*.test.ts", "**/*.spec.ts"],
"rules": {
"no-unused-expressions": "warn",
"babel/no-unused-expressions": "off"
Expand All @@ -31,5 +31,15 @@
"rules": {
"require-extensions/require-extensions": "error"
}
}, {
"files": "apps/ssr-example/**",
"rules": {
"import/no-extraneous-dependencies": "warn"
}
}, {
"files": "apps/wikibus-ssr/**",
"globals": {
"JQueryStatic": "readonly"
}
}]
}
17 changes: 0 additions & 17 deletions .github/workflows/heroku.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/netlify.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Playwright Tests

on: [push, pull_request]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn test:ssr
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: apps/ssr-example/playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ dist/
*.d.ts
*.map
coverage/
/test-results/
playwright-report/
playwright/.cache/
yarn-error.log
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

12 changes: 12 additions & 0 deletions apps/ssr-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<base href="/">
</head>
<body>

<!--ssr-outlet-->

<script src="./src/client.ts" type="module"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions apps/ssr-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "ssr-test",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"start": "node --loader ts-node/esm server.ts",
"test": "playwright test",
"build:client": "vite build --outDir dist/client",
"build:server": "vite build --outDir dist/server --ssr src/server.ts"
},
"dependencies": {
"@hydrofoil/roadshow-ssr": "^0.0.0",
"@hydrofoil/roadshow-vite": "^0.0.0",
"@tpluscode/rdf-ns-builders": "^4",
"@vaadin/vaadin": "^23.2.15",
"clownface": "^1.5.1",
"express": "^4.18.2",
"lit": "^2.6.1",
"rdf-ext": "^2",
"test-data": "*"
},
"devDependencies": {
"@playwright/test": "^1.29.2",
"@types/express": "^4"
}
}
73 changes: 73 additions & 0 deletions apps/ssr-example/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* eslint-disable import/no-extraneous-dependencies */
import type { PlaywrightTestConfig } from '@playwright/test'
import { devices } from '@playwright/test'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './test',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},

{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
},
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',

/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run start',
port: 3000,
},
}

export default config
28 changes: 28 additions & 0 deletions apps/ssr-example/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import path from 'path'
import { fileURLToPath } from 'url'
import express from 'express'
import config from '@hydrofoil/roadshow-vite/config'
import * as roadshow from '@hydrofoil/roadshow-vite/server'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

async function createServer() {
const app = express()

app.use(await roadshow.middleware({
vite: config,
production: {
modulePath: path.resolve(__dirname, './src/server.ts'),
indexPath: path.resolve(__dirname, 'index.html'),
clientBuildPath: '',
},
dev: {
modulePath: path.resolve(__dirname, './src/server.ts'),
indexPath: path.resolve(__dirname, 'index.html'),
},
}))

app.listen(3000)
}

createServer()
3 changes: 3 additions & 0 deletions apps/ssr-example/src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '@hydrofoil/roadshow-ssr/client'
import '@hydrofoil/roadshow/rs-view'
import './viewers.js'
17 changes: 17 additions & 0 deletions apps/ssr-example/src/element/ex-layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { html, LitElement } from 'lit'
import { customElement } from 'lit/decorators.js'
import '@vaadin/app-layout/vaadin-app-layout.js'
import { ex } from 'test-data/ns.js'
import { defineViewer } from '@hydrofoil/roadshow'

@customElement('ex-layout')
export class ExLayout extends LitElement {
render() {
return html`<vaadin-app-layout>
<slot name="header" slot="navbar"></slot>
</vaadin-app-layout>
`
}
}

defineViewer(ex.LayoutViewer, 'ex-layout')
29 changes: 29 additions & 0 deletions apps/ssr-example/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as roadshow from '@hydrofoil/roadshow-ssr'
import { loadData } from 'test-data'
import { dash } from '@tpluscode/rdf-ns-builders'
import './viewers.js'
import express from 'express'
import $rdf from 'rdf-ext'
import clownface from 'clownface'
import isGraphPointer from 'is-graph-pointer'

export async function render({ req }: { req: express.Request }) {
const id = req.originalUrl.substring(1)

const stream = loadData(id)
if (!stream) {
return undefined
}
const dataset = await $rdf.dataset().import(stream)
const pointer = clownface({ dataset }).namedNode(id)

const shape = pointer.out(dash.shape)
if (isGraphPointer.isNamedNode(shape)) {
const shapeStream = loadData(shape.value)
if (shapeStream) {
await dataset.import(shapeStream)
}
}

return roadshow.render({ pointer })
}
2 changes: 2 additions & 0 deletions apps/ssr-example/src/viewers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '@hydrofoil/roadshow/viewers'
import './element/ex-layout.js'
9 changes: 9 additions & 0 deletions apps/ssr-example/test/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from '@playwright/test'

test('simple page', async ({ page }) => {
await page.goto('/example/page')

const h1 = page.locator('h1')

await expect(h1).toHaveAttribute('slot', 'header')
})
20 changes: 0 additions & 20 deletions apps/storybook/.storybook/main.js

This file was deleted.

5 changes: 0 additions & 5 deletions apps/storybook/.storybook/preview.js

This file was deleted.

Loading