@gws-emul/vite
v0.2.0
Published
Vite plugin for gws-emul — runs a GAS backend in the dev server, injects google.script.run/history, mounts the dashboard.
Maintainers
Readme
@gws-emul/vite
Vite plugin for gws-emul: runs your Apps Script backend inside the dev server and wires the browser to it.
pnpm add -D @gws-emul/viteimport { gwsEmul } from "@gws-emul/vite";
export default {
plugins: [
gwsEmul({
backend: { entry: "./src/appscript/index.ts" },
persist: {}, // writes .gws-emul/state.json, restored on restart
stubs: { chat: true },
picker: true, // account-picker interstitial for switching identities
}),
],
};What it does:
- boots your GAS entry point on the emulator and exposes it at
POST /gws-emul/rpc, injected into the page aswindow.google.script.run - injects
google.script.history(replace/push/setChangeHandler), recording each call so URL mirroring is visible instead of silent - injects
google.script.host(setHeight/setWidth/close/editor.focus/origin), recorded the same way — nothing to resize in dev, but the attempt is visible - drives
doGet/doPostthrough/gws-emul/exec - serves an account picker and a
dev-usercookie, soSession.getActiveUser()answers per browser session - mounts the dashboard at
/__gws-emul/ - serves stored Drive file bytes at
/gws-emul/files/<id>
@gws-emul/vite/client is a bundle-safe browser facade: gasRunner() returns
the real google.script.run in production and the dev shim locally, so the same
code ships to GAS unmodified.
MIT © Juhyeon Lee
