Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,33 @@ jobs:
- run: pnpm test:engine
env:
H5P_TEST_BROWSER: ${{ matrix.browser }}

# The VS Code extension in a real VS Code, on a display Xvfb gives it, and the .vsix the owner
# publishes, built from what the tests ran against. The unit tests run in the job above.
vscode:
name: VS Code extension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
# The player and the runtime, which the extension carries.
- run: pnpm build
# The editor the tests download, about 150 MB, a new stable a month: kept a week at a time.
- id: week
run: echo "week=$(date -u +%G-%V)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v6
with:
path: packages/vscode/.vscode-test
key: vscode-test-${{ steps.week.outputs.week }}
restore-keys: vscode-test-
- run: xvfb-run -a pnpm --filter h5p-preview test:vscode
- run: pnpm --filter h5p-preview package
- uses: actions/upload-artifact@v4
with:
name: h5p-preview-vsix
path: packages/vscode/*.vsix
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ packages/verify/LICENSE
packages/cmi5/LICENSE
packages/embed/LICENSE

# The VS Code extension's build: the player, runtime and library pack it carries, the licence and
# notice written for its .vsix, the .vsix itself, and the VS Code its tests download.
packages/vscode/assets/
packages/vscode/LICENSE
packages/vscode/NOTICE.txt
*.vsix
.vscode-test/

# h5p-verify writes its report and screenshot to <package>.verify/ beside the package by default.
*.verify/

Expand Down
146 changes: 143 additions & 3 deletions AGENTS.md

Large diffs are not rendered by default.

Binary file modified apps/demo/app/icons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/demo/app/icons/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/demo/app/icons/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/demo/app/icons/icon-maskable-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/demo/app/screenshots/narrow-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/demo/app/screenshots/narrow-quiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 19 additions & 3 deletions apps/demo/demo/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/demo/demo/og-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 22 additions & 23 deletions apps/demo/scripts/build-app-icons.mjs
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
import { mkdir, writeFile } from 'node:fs/promises'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import { resolve } from 'node:path'
import { chromium } from 'playwright'

/**
* Renders the installable app's icons into `app/icons/`: the site's "H5P" mark at 192 and 512,
* and a maskable 512 whose mark sits inside the safe zone, the centre 80%, since a launcher may
* crop it to a circle, and a 180 for iOS, which ignores the manifest's icons for the home screen
* and draws a screenshot of the page without one. Rasterized in Chromium for the same reason as the social card — no image
* tooling in the repository. The output is committed; run this when the mark changes.
* Renders the installable app's icons into `app/icons/` from the site's logo, `demo/favicon.svg`,
* which the tab and the bar's mark show too: the logo at 192 and 512 on a transparent ground; a
* maskable 512, opaque, whose logo sits inside the safe zone, the circle in the centre 80%, since a
* launcher may crop it to one; and a 180 for iOS, which ignores the manifest's icons for the home
* screen and draws a screenshot of the page without one. Rasterized in Chromium for the same reason
* as the social card — no image tooling in the repository. The output is committed; run this when
* the logo changes.
*/

const rootDir = resolve(import.meta.dirname, '..')
const outDir = resolve(rootDir, 'app', 'icons')
const logo = await readFile(resolve(rootDir, 'demo', 'favicon.svg'), 'utf8')

/** `inset` is the share of the canvas the tile leaves empty on each side. */
const page = (size, { inset, radius }) => `<!doctype html>
/** `inset` is the share of the canvas left empty around the logo's square on each side; `ground` the colour under it. */
const page = (size, { inset, ground }) => `<!doctype html>
<html><head><meta charset="utf-8" /><style>
html, body { margin: 0; width: ${size}px; height: ${size}px; background: ${inset ? '#2f6df6' : 'transparent'}; }
.tile {
position: absolute; inset: ${inset * size}px;
display: grid; place-items: center;
border-radius: ${radius * size}px; background: #2f6df6; color: #fff;
font: 700 ${(1 - 2 * inset) * size * 0.38}px / 1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: -0.02em;
}
</style></head><body><div class="tile">H5P</div></body></html>`
html, body { margin: 0; width: ${size}px; height: ${size}px; background: ${ground ?? 'transparent'}; }
svg { position: absolute; left: ${inset * size}px; top: ${inset * size}px; width: ${(1 - 2 * inset) * size}px; height: ${(1 - 2 * inset) * size}px; }
</style></head><body>${logo}</body></html>`

const icons = [
{ name: 'icon-192.png', size: 192, inset: 0, radius: 0.22 },
{ name: 'icon-512.png', size: 512, inset: 0, radius: 0.22 },
// Full bleed: the launcher supplies the shape. The mark stays within the centre 80%.
{ name: 'icon-maskable-512.png', size: 512, inset: 0.1, radius: 0 },
// The logo as drawn, with the margin it has.
{ name: 'icon-192.png', size: 192, inset: 0 },
{ name: 'icon-512.png', size: 512, inset: 0 },
// Full bleed: the launcher supplies the shape. At 70% of the canvas the logo's farthest point
// from the centre stays inside the safe zone's circle.
{ name: 'icon-maskable-512.png', size: 512, inset: 0.15, ground: '#ffffff' },
// `apple-touch-icon`: opaque and square, since iOS rounds the corners itself and draws any
// transparent pixel black.
{ name: 'apple-touch-icon.png', size: 180, inset: 0.08, radius: 0 }
{ name: 'apple-touch-icon.png', size: 180, inset: 0.1, ground: '#ffffff' }
]

await mkdir(outDir, { recursive: true })
const browser = await chromium.launch()
for (const icon of icons) {
const tab = await browser.newPage({ viewport: { width: icon.size, height: icon.size }, deviceScaleFactor: 1 })
await tab.setContent(page(icon.size, icon))
const png = await tab.screenshot({ type: 'png', omitBackground: icon.inset === 0 })
const png = await tab.screenshot({ type: 'png', omitBackground: !icon.ground })
await writeFile(resolve(outDir, icon.name), png)
console.log(`[app-icons] ${icon.name} ${(png.length / 1024).toFixed(1)} kB`)
await tab.close()
Expand Down
Loading
Loading