Skip to content

Commit

Permalink
build into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Mar 22, 2024
1 parent b89fa2b commit 0d4085b
Show file tree
Hide file tree
Showing 314 changed files with 2,319 additions and 47,494 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Deploy
on:
push:
tags:
- v*
permissions:
contents: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: deploy
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Use Node.js 😂
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install and Build 🔧
run: |
npm ci
npm run build-ci
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: .

- name: Publish to NPM 📖
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@

# -- clip-for-deploy-start --

/docs
/dist
index.html

# -- clip-for-deploy-end --


/.pnp
.pnp.js

*.pyc
.DS_Store
node_modules
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*


113 changes: 113 additions & 0 deletions build/templates/index.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!DOCTYPE html>
<!-- this file is auto-generated from %(srcFileName)s. Do not edited directly -->
<!--
%(license)s
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Language" content="en">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta property="og:title" content="%(title)s" />
<meta property="og:type" content="website" />
<meta property="og:image" content="https://wgpu-matrix.org/resources/images/wgpu-matrix.png" />
<meta property="og:description" content="wgpu-matrix, a fast WebGPU math library" />
<meta property="og:url" content="https://wgpu-matrix.org/" />

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@greggman">
<meta name="twitter:creator" content="@greggman">
<meta name="twitter:domain" content="wgpu-matrix.org">
<meta name="twitter:title" content="wgpu-matrix">
<meta name="twitter:url" content="https://wgpu-matrix.org/">
<meta name="twitter:description" content="wgpu-matrix, a fast WebGPU math library">
<meta name="twitter:image:src" content="https://wgpu-matrix.org/resources/images/wgpu-matrix.png">

<title>%(title)s</title>

<link rel="stylesheet" href="resources/css/style.css" type="text/css" />
<link href="resources/images/wgpu-matrix-icon.png" rel="shortcut icon" type="image/png">
</head>
<body>
<div id="frame">
<!--
<div class="nav">
<ul>
<li><a href="https://greggman.github.io/webgpu-utils/docs/">Docs</a></li>
<li><a href="#examples">Examples</a></li>
<li><a href="#download">Download</a></li>
</ul>
</div>
-->
<div id="content">
%(content)s
</div>
</div>
<style>
#forkongithub a {
background: #000;
color: #fff;
text-decoration: none;
font-family: arial,sans-serif;
text-align: center;
font-weight: bold;
padding: 5px 40px;
font-size: 12px;
line-height: 24px;
position: relative;
transition: 0.5s;
display: block;
}
#forkongithub a:hover {
background: #c11;
color: #fff;
}
#forkongithub a::before,#forkongithub a::after {
content: "";
width: 100%;
display: block;
position: absolute;
top: 1px;
left: 0;
height: 1px;
background: #fff;
}
#forkongithub a::after {
bottom: 1px;
top: auto;
}

@media screen and (min-width: 400px){
#forkongithub{
position: fixed;
display: block;
top: 0;
right: 0;
width: 200px;
overflow: hidden;
height: 200px;
z-index: 9999;
}
#forkongithub a{
width: 200px;
position: absolute;
top: 40px;
right: -40px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
box-shadow: 4px 4px 10px rgba(0,0,0,0.8);
}
}

</style>
<div id="forkongithub"><a href="https://github.com/greggman/wgpu-matrix">Fork me on GitHub</a></div>
</body>
<script src="resources/3rdparty/prettify.js"></script>
<script type="module" src="resources/js/index.js"></script>
</html>


File renamed without changes.
93 changes: 93 additions & 0 deletions build/tools/makeindex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import fs from 'fs';
import path from 'path';
import showdown from 'showdown';
import * as url from 'url';
const dirname = url.fileURLToPath(new URL('.', import.meta.url));

const converter = new showdown.Converter({
openLinksInNewWindow: true,
ghCodeBlocks: true,
simplifiedAutoLink: true,
});

const pkg = JSON.parse(fs.readFileSync(path.join(dirname, '..', '..', 'package.json'), {encoding: 'utf8'}));

function getLicense(pkg) {
return `@license wgpu-matrix ${pkg.version} Copyright (c) 2023, Gregg Tavares All Rights Reserved.
Available via the MIT license.
see: http://github.com/greggman/wgpu-matrix for details`;
}

/**
* Replace %(id)s in strings with values in objects(s)
*
* Given a string like `"Hello %(name)s from %(user.country)s"`
* and an object like `{name:"Joe",user:{country:"USA"}}` would
* return `"Hello Joe from USA"`.
*
* @param {string} str string to do replacements in
* @param {Object|Object[]} params one or more objects.
* @returns {string} string with replaced parts
*/
const replaceParams = (function () {
const replaceParamsRE = /%\(([^)]+)\)s/g;

return function (str, params) {
if (!params.length) {
params = [params];
}

return str.replace(replaceParamsRE, function (match, key) {
const colonNdx = key.indexOf(':');
if (colonNdx >= 0) {
/*
try {
const args = hanson.parse("{" + key + "}");
const handlerName = Object.keys(args)[0];
const handler = replaceHandlers[handlerName];
if (handler) {
return handler(args[handlerName]);
}
console.error("unknown substitution handler: " + handlerName);
} catch (e) {
console.error(e);
console.error("bad substitution: %(" + key + ")s");
}
*/
throw new Error('unsupported');
} else {
// handle normal substitutions.
const keys = key.split('.');
for (let ii = 0; ii < params.length; ++ii) {
let obj = params[ii];
for (let jj = 0; jj < keys.length; ++jj) {
const key = keys[jj];
obj = obj[key];
if (obj === undefined) {
break;
}
}
if (obj !== undefined) {
return obj;
}
}
}
console.error('unknown key: ' + key);
return '%(' + key + ')s';
});
};
}());

const html = converter.makeHtml(fs.readFileSync('README.md', {encoding: 'utf8'}));
const template = fs.readFileSync('build/templates/index.template', {encoding: 'utf8'});
let content = replaceParams(template, {
content: html,
license: getLicense(pkg),
srcFileName: 'README.md',
title: 'wgpu-matrix, a fast WebGPU math library',
version: pkg.version,
});
content = content.replace(/href="https:\/\/greggman\.github\.io\/wgpu-matrix\//g, 'href="./');
fs.writeFileSync('index.html', content);


9 changes: 9 additions & 0 deletions build/tools/prep-for-deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import fs from 'fs';
import path from 'path';
import * as url from 'url';
const dirname = url.fileURLToPath(new URL('.', import.meta.url));

const ignoreFilename = path.join(dirname, '..', '..', '.gitignore');
const ignore = fs.readFileSync(ignoreFilename, {encoding: 'utf8'});
const newIgnore = ignore.replace(/# -- clip-for-deploy-start --[\s\S]*?# -- clip-for-deploy-end --/, '');
fs.writeFileSync(ignoreFilename, newIgnore);
8 changes: 0 additions & 8 deletions dist/2.x/array-like.d.ts

This file was deleted.

Loading

0 comments on commit 0d4085b

Please sign in to comment.