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
12 changes: 1 addition & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ jobs:
workspaces: packages/stream
- run: npm ci
- run: npm run build
# The same page as a Samsung TV package, unsigned: a set only installs a package signed
# for its own DUID, so each owner signs their copy (Apps2Samsung, or the CLI route on the
# install page), and this job needs no Tizen SDK. The wasm is the one `npm run build` made.
- run: npm run build:tizen -w punktfunk-web
# The packed library, installed into an empty Vite project: the consumer's view.
- run: ./scripts/pack-gate.sh
- uses: actions/upload-artifact@v7
Expand All @@ -116,20 +112,14 @@ jobs:
with:
name: punktfunk-web
path: apps/web/dist/
- uses: actions/upload-artifact@v7
with:
name: punktfunk-tizen
path: apps/web/punktfunk-tizen-*.wgt
# The `.wgt` rides the release beside the tarball; its name is what the Apps2Samsung
# catalog entry matches (`^punktfunk-tizen-.*\.wgt$`).
- name: Release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ github.token }}
run: |
tarball="punktfunk-client-web-${GITHUB_REF_NAME}.tar.gz"
tar -czf "$tarball" -C apps/web/dist .
gh release create "$GITHUB_REF_NAME" "$tarball" apps/web/punktfunk-tizen-*.wgt --verify-tag --generate-notes
gh release create "$GITHUB_REF_NAME" "$tarball" --verify-tag --generate-notes

# The container: the server compiled natively on each architecture's runner, the client from the
# build job. Pushed to git.unom.io from main (`edge`) and from v* tags (`X.Y.Z` and `latest`);
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ node_modules/
/packages/stream/wasm/*.js
/packages/stream/wasm/*.wasm
/apps/web/dist
/apps/web/dist-tizen
/apps/web/*.wgt
/apps/web/storybook-static
/apps/web/screenshots
/target
Expand Down
1 change: 0 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"build:tizen": "vite build --mode tizen && node tools/wgt.mjs",
"check": "tsc --noEmit",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
Expand Down
36 changes: 0 additions & 36 deletions apps/web/tizen/config.xml

This file was deleted.

Binary file removed apps/web/tizen/icon.png
Binary file not shown.
29 changes: 0 additions & 29 deletions apps/web/tools/tizen-icon.mjs

This file was deleted.

116 changes: 0 additions & 116 deletions apps/web/tools/wgt.mjs

This file was deleted.

123 changes: 42 additions & 81 deletions apps/web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
// The app's bundler. The wasm module is `@punktfunk/stream`'s concern: the engine imports
// emscripten's glue lazily, and the glue finds its `.wasm` through `new URL(…, import.meta.url)`,
// which Vite turns into an emitted asset. Nothing here names either file.
//
// `--mode tizen` builds the same page as a Samsung TV package: `dist-tizen/` with the widget's
// `config.xml` and icon beside `index.html`, no source maps, and Samsung's `webapis.js` on the
// page. `tools/wgt.mjs` zips that directory into the `.wgt`.

import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig, type Plugin } from "vite";
import { defineConfig } from "vite";

const devHost = process.env["PF_HOST"];

Expand All @@ -24,80 +19,46 @@ function version(): string {
}
}

/** The numeric part of the version, which is all a widget's `version` may hold: `0.3.0` from
* `v0.3.0-12-gabcdef`, and `0.0.1` for a build with no tag behind it. */
function widgetVersion(described: string = version()): string {
return /\d+\.\d+\.\d+/.exec(described)?.[0] ?? "0.0.1";
}

/** The package's own files beside the page: `config.xml` at this build's version, the icon, and
* Samsung's `webapis.js`, whose path exists only on the set and so is never bundled. */
function tizenPackage(): Plugin {
const here = (p: string) => fileURLToPath(new URL(p, import.meta.url));
return {
name: "punktfunk-tizen",
transformIndexHtml: {
order: "post",
handler: (html) => ({
html,
tags: [{ tag: "script", attrs: { src: "$WEBAPIS/webapis/webapis.js" }, injectTo: "head-prepend" }],
}),
},
generateBundle() {
const config = readFileSync(here("./tizen/config.xml"), "utf8").replace(
/version="[^"]*"/,
`version="${widgetVersion()}"`,
);
this.emitFile({ type: "asset", fileName: "config.xml", source: config });
this.emitFile({ type: "asset", fileName: "icon.png", source: readFileSync(here("./tizen/icon.png")) });
},
};
}

export default defineConfig(({ mode }) => {
const tizen = mode === "tizen";
return {
// Relative asset URLs, so the same `dist/` works at a host's root, under a path, or packaged.
base: "./",
plugins: [react(), tailwindcss(), ...(tizen ? [tizenPackage()] : [])],
// Through the dev proxy the API answers on the page's origin but the WebTransport plane does
// not; this tells the engine where it is. Undefined in a real build, so the address the user
// typed is used — exactly as designed.
define: {
__PF_VERSION__: JSON.stringify(version()),
__PF_TRANSPORT_HOST__: JSON.stringify(devHost ? new URL(devHost).hostname : undefined),
},
resolve: {
alias: {
// The library from source, as `tsconfig.json` does for the types: the workspace's own
// consumer follows the engine without a build in between.
"@punktfunk/stream": fileURLToPath(new URL("../../packages/stream/src/index.ts", import.meta.url)),
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
build: {
outDir: tizen ? "dist-tizen" : "dist",
emptyOutDir: true,
// What the wasm and WebCodecs already require; nothing older can run this page anyway.
target: "es2022",
// A package ships to a set with no devtools to read a map, and the maps are half its size.
sourcemap: !tizen,
},
server: {
port: 5173,
strictPort: true,
// Development against a real host without accepting its certificate first: `PF_HOST` names
// it, and the dev server answers `/api` on the page's own origin. Only the dev server does
// this — a built page talks to the host it was pointed at, cross-origin, as designed.
...(devHost
? {
proxy: {
"/api": { target: devHost, changeOrigin: true, secure: false },
// The end-to-end harness posts its findings here; a collector listens during a run.
"/report": { target: "http://127.0.0.1:8099" },
},
}
: {}),
export default defineConfig({
// Relative asset URLs, so the same `dist/` works at a host's root, under a path, or packaged.
base: "./",
plugins: [react(), tailwindcss()],
// Through the dev proxy the API answers on the page's origin but the WebTransport plane does
// not; this tells the engine where it is. Undefined in a real build, so the address the user
// typed is used — exactly as designed.
define: {
__PF_VERSION__: JSON.stringify(version()),
__PF_TRANSPORT_HOST__: JSON.stringify(devHost ? new URL(devHost).hostname : undefined),
},
resolve: {
alias: {
// The library from source, as `tsconfig.json` does for the types: the workspace's own
// consumer follows the engine without a build in between.
"@punktfunk/stream": fileURLToPath(new URL("../../packages/stream/src/index.ts", import.meta.url)),
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
};
},
build: {
outDir: "dist",
emptyOutDir: true,
// What the wasm and WebCodecs already require; nothing older can run this page anyway.
target: "es2022",
sourcemap: true,
},
server: {
port: 5173,
strictPort: true,
// Development against a real host without accepting its certificate first: `PF_HOST` names
// it, and the dev server answers `/api` on the page's own origin. Only the dev server does
// this — a built page talks to the host it was pointed at, cross-origin, as designed.
...(devHost
? {
proxy: {
"/api": { target: devHost, changeOrigin: true, secure: false },
// The end-to-end harness posts its findings here; a collector listens during a run.
"/report": { target: "http://127.0.0.1:8099" },
},
}
: {}),
},
});
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"scripts": {
"build": "npm run build -w @punktfunk/stream && npm run build -w punktfunk-web",
"build:tizen": "npm run build -w @punktfunk/stream && npm run build:tizen -w punktfunk-web",
"check": "npm run check --workspaces",
"test": "npm run test --workspaces --if-present",
"dev": "npm run dev -w punktfunk-web",
Expand Down
Loading