Compare commits
6
Commits
ef20b0d6c3
..
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad66bbf6be | ||
|
|
243c975cec | ||
|
|
536e09dff4 | ||
|
|
d22dc28af3 | ||
|
|
4f4c2b6b91 | ||
|
|
d7b95dbac8 |
+29
-59
@@ -11,28 +11,41 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: https://github.com/actions/checkout@v4
|
- uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
- name: Install bison
|
- name: Install build dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y bison
|
sudo apt-get install -y bison cmake curl python3
|
||||||
|
|
||||||
|
# Gitea Actions doesn't support the built-in hashFiles() expression
|
||||||
|
# function (unlike GitHub Actions) - it silently evaluates to an empty
|
||||||
|
# string, which turned every cache key below into the same constant
|
||||||
|
# string regardless of what actually changed, so a cache entry from
|
||||||
|
# before a dependency-version or patch change would still be reused
|
||||||
|
# forever. Hash the same inputs by hand instead.
|
||||||
|
- name: Compute cache keys
|
||||||
|
id: cache-keys
|
||||||
|
run: |
|
||||||
|
echo "emsdk=$(sha256sum scripts/versions.sh | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "deps-wasm32=$(cat scripts/versions.sh $(find patches -type f | sort) | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "libwinevbs=$(cat scripts/versions.sh $(find patches/libwinevbs -type f | sort) | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Cache emsdk
|
- name: Cache emsdk
|
||||||
uses: https://github.com/actions/cache@v4
|
uses: https://github.com/actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: emsdk
|
path: emsdk
|
||||||
key: emsdk-${{ hashFiles('scripts/versions.sh') }}
|
key: emsdk-${{ steps.cache-keys.outputs.emsdk }}
|
||||||
|
|
||||||
- name: Cache wasm32 dependency builds
|
- name: Cache wasm32 dependency builds
|
||||||
uses: https://github.com/actions/cache@v4
|
uses: https://github.com/actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: build/deps-wasm32
|
path: build/deps-wasm32
|
||||||
key: deps-wasm32-${{ hashFiles('scripts/versions.sh', 'patches/**') }}
|
key: deps-wasm32-${{ steps.cache-keys.outputs.deps-wasm32 }}
|
||||||
|
|
||||||
- name: Cache libwinevbs build
|
- name: Cache libwinevbs build
|
||||||
uses: https://github.com/actions/cache@v4
|
uses: https://github.com/actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: vendor/libwinevbs/build
|
path: vendor/libwinevbs/build
|
||||||
key: libwinevbs-wasm32-${{ hashFiles('scripts/versions.sh', 'patches/libwinevbs/**') }}
|
key: libwinevbs-wasm32-${{ steps.cache-keys.outputs.libwinevbs }}
|
||||||
|
|
||||||
- name: Setup (fetch + patch vendor sources)
|
- name: Setup (fetch + patch vendor sources)
|
||||||
run: ./scripts/setup.sh
|
run: ./scripts/setup.sh
|
||||||
@@ -59,70 +72,27 @@ jobs:
|
|||||||
npm install --no-save typescript
|
npm install --no-save typescript
|
||||||
npx tsc -p package/tsconfig.json
|
npx tsc -p package/tsconfig.json
|
||||||
|
|
||||||
- uses: https://github.com/actions/upload-artifact@v4
|
# Everything below only runs on a tag push (a release) - reuses the
|
||||||
with:
|
# exact build just done above instead of the previous separate
|
||||||
name: vpinball-wasm-dist
|
# "publish" job, which had `needs: build` but still redundantly
|
||||||
path: dist/
|
# re-ran the *entire* checkout/cache/setup/build-deps/build/wrapper
|
||||||
|
# pipeline from scratch, doubling CI time on every release for no
|
||||||
publish:
|
# benefit (Gitea Actions' artifact-passing story is also awkward
|
||||||
name: Publish to npm registry
|
# here - upload-artifact@v4+/download-artifact@v4+ aren't supported
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
# on Gitea at all, see the upload-artifact removal above).
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install bison
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y bison
|
|
||||||
|
|
||||||
- name: Cache emsdk
|
|
||||||
uses: https://github.com/actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: emsdk
|
|
||||||
key: emsdk-${{ hashFiles('scripts/versions.sh') }}
|
|
||||||
|
|
||||||
- name: Cache wasm32 dependency builds
|
|
||||||
uses: https://github.com/actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: build/deps-wasm32
|
|
||||||
key: deps-wasm32-${{ hashFiles('scripts/versions.sh', 'patches/**') }}
|
|
||||||
|
|
||||||
- name: Cache libwinevbs build
|
|
||||||
uses: https://github.com/actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: vendor/libwinevbs/build
|
|
||||||
key: libwinevbs-wasm32-${{ hashFiles('scripts/versions.sh', 'patches/libwinevbs/**') }}
|
|
||||||
|
|
||||||
- name: Setup (fetch + patch vendor sources)
|
|
||||||
run: ./scripts/setup.sh
|
|
||||||
|
|
||||||
- name: Build wasm32 dependencies
|
|
||||||
run: |
|
|
||||||
source emsdk/emsdk_env.sh
|
|
||||||
./scripts/build-deps.sh
|
|
||||||
|
|
||||||
- name: Build vpinball
|
|
||||||
run: |
|
|
||||||
source emsdk/emsdk_env.sh
|
|
||||||
./scripts/build.sh
|
|
||||||
|
|
||||||
- name: Build npm wrapper
|
|
||||||
run: |
|
|
||||||
npm install --no-save typescript
|
|
||||||
npx tsc -p package/tsconfig.json
|
|
||||||
|
|
||||||
- name: Set package version from the tag
|
- name: Set package version from the tag
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: npm pkg set version="${GITHUB_REF_NAME#v}"
|
run: npm pkg set version="${GITHUB_REF_NAME#v}"
|
||||||
|
|
||||||
# Scoped to this one registry host+path (via publishConfig.registry in
|
# Scoped to this one registry host+path (via publishConfig.registry in
|
||||||
# package.json) rather than actions/setup-node's registry-url, which
|
# package.json) rather than actions/setup-node's registry-url, which
|
||||||
# would set it as the *default* registry for every install.
|
# would set it as the *default* registry for every install.
|
||||||
- name: Configure registry auth for publish
|
- name: Configure registry auth for publish
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: npm config set "//dev.pivoine.art/api/packages/valknar/npm/:_authToken" "$PACKAGE_TOKEN"
|
run: npm config set "//dev.pivoine.art/api/packages/valknar/npm/:_authToken" "$PACKAGE_TOKEN"
|
||||||
env:
|
env:
|
||||||
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||||
|
|
||||||
- name: Publish to Gitea npm registry
|
- name: Publish to Gitea npm registry
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: npm publish
|
run: npm publish
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ source emsdk/emsdk_env.sh
|
|||||||
## npm usage
|
## npm usage
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { loadPinball, attachTouchControls } from '@valknar/vpinball-wasm';
|
import { loadPinball, attachTouchControls } from 'vpinball-wasm';
|
||||||
|
|
||||||
const canvas = document.querySelector('canvas');
|
const canvas = document.querySelector('canvas');
|
||||||
const pinball = await loadPinball({
|
const pinball = await loadPinball({
|
||||||
@@ -128,7 +128,7 @@ startButton.addEventListener('click', () => {
|
|||||||
pinball.evalScript('DMDWidth = 128 : DMDHeight = 32');
|
pinball.evalScript('DMDWidth = 128 : DMDHeight = 32');
|
||||||
```
|
```
|
||||||
|
|
||||||
See `examples/basic/index.html` for a complete working page (loading progress, file upload, touch controls, fullscreen). The published package name/registry (`@valknar/vpinball-wasm` on this project's Gitea npm registry) is a placeholder pending the first real release — see `package.json`.
|
See `examples/basic/index.html` for a complete working page (loading progress, file upload, touch controls, fullscreen). Published as `vpinball-wasm` on this project's Gitea npm registry — see `package.json`.
|
||||||
|
|
||||||
## Known limitations
|
## Known limitations
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<!--
|
<!--
|
||||||
Full usage example for @valknar/vpinball-wasm: loading progress, a
|
Full usage example for vpinball-wasm: loading progress, a
|
||||||
user-gesture "Start" button (required for audio autoplay and fullscreen
|
user-gesture "Start" button (required for audio autoplay and fullscreen
|
||||||
to work), an optional file picker for a self-contained .vpx table, touch
|
to work), an optional file picker for a self-contained .vpx table, touch
|
||||||
controls on touch-capable devices, and a fullscreen button.
|
controls on touch-capable devices, and a fullscreen button.
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@valknar/vpinball-wasm",
|
"name": "vpinball-wasm",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"description": "Visual Pinball's engine compiled to WebAssembly - real .vpx tables, real VBScript, WebGL2 rendering, in the browser",
|
"description": "Visual Pinball's engine compiled to WebAssembly - real .vpx tables, real VBScript, WebGL2 rendering, in the browser",
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Public TypeScript surface for @valknar/vpinball-wasm.
|
* Public TypeScript surface for vpinball-wasm.
|
||||||
*
|
*
|
||||||
* This wraps the raw Emscripten-generated module (dist/vpinball.js) so
|
* This wraps the raw Emscripten-generated module (dist/vpinball.js) so
|
||||||
* consumers don't need to know about ccall/cwrap/FS internals directly.
|
* consumers don't need to know about ccall/cwrap/FS internals directly.
|
||||||
|
|||||||
Reference in New Issue
Block a user