From 2d6f455eb15c123a396c9cbfa31e90e5eaf25008 Mon Sep 17 00:00:00 2001 From: Ronald Chen Date: Tue, 27 Feb 2024 13:31:31 -0800 Subject: [PATCH] fixed github pages --- docs/assets/index-B0JOGk47.js | 1 - docs/assets/index-CadGmGpN.js | 1 + docs/index.html | 2 +- package.json | 5 ++--- vite.config.js | 8 +++++--- 5 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 docs/assets/index-B0JOGk47.js create mode 100644 docs/assets/index-CadGmGpN.js diff --git a/docs/assets/index-B0JOGk47.js b/docs/assets/index-B0JOGk47.js deleted file mode 100644 index 823cde0..0000000 --- a/docs/assets/index-B0JOGk47.js +++ /dev/null @@ -1 +0,0 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const l of c.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();const d="/assets/index-DEgk8qcE.wasm",f=document.body.querySelector("canvas"),r=f.getContext("2d"),u=await WebAssembly.compileStreaming(fetch(d)),i=(t,e)=>{const n=new Uint8Array(a.buffer,t,e);return new TextDecoder().decode(n)},m=t=>{const e=new TextEncoder().encode(t),n=g(e.length+1),s=new Uint8Array(a.buffer,n,e.length+1);return s.set(e),s[e.length]=0,n},{exports:{memory:a,_draw:p,allocUint8:g,free:y}}=await WebAssembly.instantiate(u,{app:{_allocPromptName(t,e){const n=i(t,e),s=window.prompt(n)??"Human";return m(s)}},env:{_throwError(t,e){const n=i(t,e);throw new Error(n)},_consoleLog(t,e){const n=i(t,e);console.log(n)}},ctx:{save:r.save.bind(r),restore:r.restore.bind(r),translate(t,e){r.translate(t,e)},scale(t,e){r.scale(t,e)},rotate(t){r.rotate(t)},beginPath(){r.beginPath()},moveTo(t,e){r.moveTo(t,e)},lineTo(t,e){r.lineTo(t,e)},_font(t,e){r.font=i(t,e)},_fillStyle(t,e){r.fillStyle=i(t,e)},_fillText(t,e,n,s){const o=i(t,e);r.fillText(o,n,s)},fill(){r.fill()},lineWidth(t){r.lineWidth=t},_lineCap(t,e){r.lineCap=i(t,e)},_strokeStyle(t,e){r.strokeStyle=i(t,e)},_strokeText(t,e,n,s){const o=i(t,e);r.strokeText(o,n,s)},stroke(){r.stroke()}}});p(); diff --git a/docs/assets/index-CadGmGpN.js b/docs/assets/index-CadGmGpN.js new file mode 100644 index 0000000..3563d71 --- /dev/null +++ b/docs/assets/index-CadGmGpN.js @@ -0,0 +1 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();const d="https://pyrolistical.github.io/zig-wasm-canvas/assets/index-DEgk8qcE.wasm",f=document.body.querySelector("canvas"),r=f.getContext("2d"),u=await WebAssembly.compileStreaming(fetch(d)),c=(t,e)=>{const n=new Uint8Array(a.buffer,t,e);return new TextDecoder().decode(n)},m=t=>{const e=new TextEncoder().encode(t),n=g(e.length+1),s=new Uint8Array(a.buffer,n,e.length+1);return s.set(e),s[e.length]=0,n},{exports:{memory:a,_draw:p,allocUint8:g,free:y}}=await WebAssembly.instantiate(u,{app:{_allocPromptName(t,e){const n=c(t,e),s=window.prompt(n)??"Human";return m(s)}},env:{_throwError(t,e){const n=c(t,e);throw new Error(n)},_consoleLog(t,e){const n=c(t,e);console.log(n)}},ctx:{save:r.save.bind(r),restore:r.restore.bind(r),translate(t,e){r.translate(t,e)},scale(t,e){r.scale(t,e)},rotate(t){r.rotate(t)},beginPath(){r.beginPath()},moveTo(t,e){r.moveTo(t,e)},lineTo(t,e){r.lineTo(t,e)},_font(t,e){r.font=c(t,e)},_fillStyle(t,e){r.fillStyle=c(t,e)},_fillText(t,e,n,s){const o=c(t,e);r.fillText(o,n,s)},fill(){r.fill()},lineWidth(t){r.lineWidth=t},_lineCap(t,e){r.lineCap=c(t,e)},_strokeStyle(t,e){r.strokeStyle=c(t,e)},_strokeText(t,e,n,s){const o=c(t,e);r.strokeText(o,n,s)},stroke(){r.stroke()}}});p(); diff --git a/docs/index.html b/docs/index.html index 9746b46..f48c58a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -19,7 +19,7 @@ } - + diff --git a/package.json b/package.json index b24629d..162d2fb 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,8 @@ "test": "vitest", "build:zig": "zig build-exe index.zig -target wasm32-freestanding -femit-bin=dist/index.wasm -fno-entry --export=_draw --export=allocUint8 --export=free", "build:vite": "vite build", - "prebuild": "rm -rf dist docs && mkdir dist docs", - "build": "npm run build:zig && npm run build:vite", - "postbuild": "cp -r dist/* docs/" + "prebuild": "rm -rf docs && mkdir docs", + "build": "npm run build:zig && npm run build:vite" }, "author": "Ronald Chen ", "license": "Apache-2.0", diff --git a/vite.config.js b/vite.config.js index 87a978a..ba32854 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,5 +1,7 @@ export default { - build: { - target: "esnext", - }, + base: "https://pyrolistical.github.io/zig-wasm-canvas", + build: { + outDir: "./docs", + target: "esnext", + }, };