@puzzmo/sdk 1.0.58 → 1.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{createSimulator-5inYnxKU.js → createSimulator-Dory7qUL.js} +2 -2
- package/dist/{createSimulator-5inYnxKU.js.map → createSimulator-Dory7qUL.js.map} +1 -1
- package/dist/{createSimulator-BCzgWYMQ.cjs → createSimulator-kGIstLy9.cjs} +2 -2
- package/dist/{createSimulator-BCzgWYMQ.cjs.map → createSimulator-kGIstLy9.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/inputs/index.cjs +1 -1
- package/dist/inputs/index.js +1 -1
- package/dist/lua-C3M-mB0u.js +11 -0
- package/dist/lua-C3M-mB0u.js.map +1 -0
- package/dist/lua-D5xtGGen.cjs +135 -0
- package/dist/lua-D5xtGGen.cjs.map +1 -0
- package/dist/{objectSpread2-COovHPnD.js → objectSpread2-C8x7fbpH.js} +1 -1
- package/dist/{objectSpread2-CuluYLUL.cjs → objectSpread2-DLgRiGrq.cjs} +1 -1
- package/dist/pico8/channel.d.ts +45 -0
- package/dist/pico8/channel.d.ts.map +1 -0
- package/dist/pico8/index.cjs +2 -0
- package/dist/pico8/index.cjs.map +1 -0
- package/dist/pico8/index.d.ts +89 -0
- package/dist/pico8/index.d.ts.map +1 -0
- package/dist/pico8/index.js +454 -0
- package/dist/pico8/index.js.map +1 -0
- package/dist/pico8/lua.d.ts +9 -0
- package/dist/pico8/lua.d.ts.map +1 -0
- package/dist/pico8/palette.d.ts +17 -0
- package/dist/pico8/palette.d.ts.map +1 -0
- package/dist/pico8/pico8.spec.d.ts +2 -0
- package/dist/pico8/pico8.spec.d.ts.map +1 -0
- package/dist/pico8/protocol.d.ts +61 -0
- package/dist/pico8/protocol.d.ts.map +1 -0
- package/dist/pico8/vitePlugin.d.ts +42 -0
- package/dist/pico8/vitePlugin.d.ts.map +1 -0
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.js +1 -1
- package/dist/vite.cjs +7 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +215 -47
- package/dist/vite.js.map +1 -1
- package/package.json +6 -1
package/dist/simulator/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "../createSimulator-
|
|
1
|
+
import { n as e, r as t, t as n } from "../createSimulator-Dory7qUL.js";
|
|
2
2
|
export { n as createSimulator, e as createSoundView, t as simulatorBuildMarker };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../createSimulator-
|
|
1
|
+
const e=require(`../createSimulator-kGIstLy9.cjs`);var t=()=>{var t;e.t((t=window.SIMULATOR_CONFIG)==null?{}:t)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,t):t();
|
|
2
2
|
//# sourceMappingURL=standalone.cjs.map
|
package/dist/vite.cjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./objectSpread2-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./objectSpread2-DLgRiGrq.cjs`),l=require(`./asyncToGenerator-DANjdFmB.cjs`),u=require(`./objectWithoutProperties-ChRmjIUS.cjs`),d=require(`./lua-D5xtGGen.cjs`);let f=require(`vite`),p=require(`path`);p=s(p);let m=require(`fs`);m=s(m);let h=require(`child_process`);function g(e,t={}){var n;let r;if(t.cart)r=p.default.resolve(e,t.cart);else{let t=p.default.join(e,`cart`),n=m.default.existsSync(t)?m.default.readdirSync(t).filter(e=>e.endsWith(`.p8`)):[];if(n.length>1)throw Error(`[puzzmo-pico8] found ${n.length} carts in ${t}, pick one with the \`cart\` option`);n.length===1&&(r=p.default.join(t,n[0]))}if(!r||!m.default.existsSync(r))return null;let i=p.default.basename(r,`.p8`),a=p.default.resolve(e,(n=t.exportDir)==null?`export`:n);return{dir:e,cart:r,name:i,exportHTML:p.default.join(a,`${i}.html`),exportJS:p.default.join(a,`${i}.js`)}}function _(e,t,n){let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=RegExp(`((?:\\.src\\s*=\\s*|\\ssrc=)["'])[^"']*${r}\\.js(["'])`);if(!i.test(e))throw Error(`[puzzmo-pico8] couldn't find where PICO-8's page loads ${t}.js`);e=e.replace(i,`$1./${t}.js$2`),e=e.replace(/var\s+p8_autoplay\s*=\s*false/,`var p8_autoplay = true`),/var\s+pico8_gpio\s*=/.test(e)||(e=e.replace(/<head>/i,`<head>
|
|
2
|
+
<script>var pico8_gpio = new Array(128)<\/script>`)),e=e.replace(/(<style[^>]*>)([\s\S]*?)(<\/style>)/gi,(e,t,n,r)=>t+n.replace(/<!--|-->/g,``).replace(/^[ \t]*-repeat[^;\n]*;[ \t]*$/gm,``)+r),e=e.replace(/ (?!;)/g,` `);let a=e.lastIndexOf(`</body>`);if(a===-1)throw Error(`[puzzmo-pico8] that doesn't look like a PICO-8 export, it has no </body>`);return e.slice(0,a)+n.join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`+e.slice(a)}var v=[`/Applications/PICO-8.app/Contents/MacOS/pico8`,`C:\\Program Files (x86)\\PICO-8\\pico8.exe`,`C:\\Program Files\\PICO-8\\pico8.exe`],y=e=>{var t,n;if(e.includes(`/`)||e.includes(`\\`))return m.default.existsSync(e)?e:null;for(let n of((t=process.env.PATH)==null?``:t).split(p.default.delimiter))for(let t of process.platform===`win32`?[`.exe`,`.cmd`,``]:[``]){let r=p.default.join(n,e+t);if(m.default.existsSync(r))return r}return e===`pico8`?(n=v.find(e=>m.default.existsSync(e)))==null?null:n:null},b=e=>m.default.existsSync(e)?m.default.statSync(e).mtimeMs:0;function x(e={}){var t,n;let r,i=new Map,a=e.pico8===!1?null:(t=(n=e.pico8)==null?process.env.PICO8:n)==null?`pico8`:t,o=e=>r.logger.info(`\x1b[33m\x1b[1m PICO-8 \x1b[22m\x1b[39m${e}`),s=t=>{if(e.writeLua===!1)return;let n=p.default.join(p.default.dirname(t.cart),`puzzmo.lua`);m.default.existsSync(n)&&m.default.readFileSync(n,`utf8`)===d.t||(m.default.writeFileSync(n,d.t),o(`wrote ${p.default.relative(r.root,n)}`))},c=e=>{let t=p.default.dirname(e.cart),n=Math.max(...m.default.readdirSync(t).filter(e=>/\.(p8|lua)$/.test(e)).map(e=>b(p.default.join(t,e))));if(m.default.existsSync(e.exportJS)&&b(e.exportJS)>=n)return;let i=a?y(a):null;if(!i){if(m.default.existsSync(e.exportHTML)){r.logger.warn(`[puzzmo-pico8] ${p.default.relative(r.root,e.cart)} is newer than its export, and PICO-8 isn't around to re-export it. Using the old export.`);return}throw Error(`[puzzmo-pico8] there's no export of ${p.default.relative(r.root,e.cart)} yet, and PICO-8 isn't on your PATH to make one.\nExport it inside PICO-8 with EXPORT ${e.name}.html into ${p.default.relative(r.root,p.default.dirname(e.exportHTML))}/, or set PICO8=/path/to/pico8.`)}m.default.mkdirSync(p.default.dirname(e.exportHTML),{recursive:!0});let s=b(e.exportJS),c=``;try{c=(0,h.execFileSync)(i,[e.cart,`-export`,e.exportHTML],{encoding:`utf8`,timeout:6e4,stdio:[`ignore`,`pipe`,`pipe`]})}catch(e){var l;c=String((l=e.stdout)==null?e:l)}if(b(e.exportJS)===s){let t=/label/i.test(c)?`
|
|
5
|
+
HTML exports need a label: run the cart in PICO-8, press CTRL-7, and save.`:``;throw Error(`[puzzmo-pico8] PICO-8 didn't export ${p.default.relative(r.root,e.cart)}:\n${c.trim()}${t}`)}o(`exported ${p.default.relative(r.root,e.cart)}`)},l=t=>{let n=p.default.dirname(t);if(!i.has(n)){let t=g(n,e);if(!t)return null;i.set(n,t)}return i.get(n)};return{name:`puzzmo-pico8`,config(){var t;let n=(t=e.exportDir)==null?`export`:t;return{server:{watch:{ignored:[e=>/\.(html|js)$/.test(e)&&p.default.basename(p.default.dirname(e))===p.default.basename(n)&&m.default.existsSync(p.default.join(p.default.dirname(p.default.dirname(e)),`cart`))]}}}},configResolved(e){r=e},transformIndexHtml:{order:`pre`,handler(e,t){var n;let r=l(t.filename);if(!r)return;s(r),c(r);let i=(n=e.match(/<script\b[^>]*type=["']module["'][^>]*>[\s\S]*?<\/script>/gi))==null?[]:n;return _(m.default.readFileSync(r.exportHTML,`utf8`),r.name,i)}},configureServer(e){e.middlewares.use((e,t,n)=>{var a;let o=decodeURIComponent(((a=e.url)==null?``:a).split(`?`)[0]);if(!o.endsWith(`.js`))return n();let s=[...i.values()].find(e=>o===`/`+p.default.relative(r.root,p.default.join(e.dir,`${e.name}.js`)).split(p.default.sep).join(`/`));if(!s||!m.default.existsSync(s.exportJS))return n();t.setHeader(`Content-Type`,`text/javascript`),t.end(m.default.readFileSync(s.exportJS))}),e.watcher.on(`change`,t=>{let n=[...i.values()].find(e=>p.default.dirname(t)===p.default.dirname(e.cart)&&/\.(p8|lua)$/.test(t));if(!(!n||p.default.basename(t)===`puzzmo.lua`))try{c(n),e.ws.send({type:`full-reload`})}catch(t){let n=t instanceof Error?t.message:String(t);r.logger.error(n),e.ws.send({type:`error`,err:{message:n,stack:``}})}})},generateBundle(){for(let e of i.values()){let t=p.default.relative(r.root,p.default.join(e.dir,`${e.name}.js`)).split(p.default.sep).join(`/`);this.emitFile({type:`asset`,fileName:t,source:m.default.readFileSync(e.exportJS)})}}}}var S=[`fixturesGlob`,`viewFactories`],C=`/@puzzmo-simulator-init.js`,w=`virtual:puzzmo-simulator`;function T(e){let t=new Map,n=P(e,3);m.default.existsSync(p.default.join(e,`puzzmo.json`))&&n.unshift(e);for(let i of n)try{var r;let n=JSON.parse(m.default.readFileSync(p.default.join(i,`puzzmo.json`),`utf-8`));if(!(!(n==null||(r=n.game)==null)&&r.slug))continue;let a=j(i,`src/appBundle`),o=null;a&&(o=`/`+p.default.relative(e,a).split(p.default.sep).join(`/`)),t.set(n.game.slug,{dir:i,slug:n.game.slug,displayName:n.game.displayName,appBundlePath:o})}catch(e){}return t}function E(e,t,n){if(e)try{let r=new URL(e).pathname;for(let e of t.values()){let t=`/`+p.default.relative(n,e.dir).split(p.default.sep).join(`/`);if(r.startsWith(t+`/`)||r===t)return e}}catch(e){}if(t.size===1)return t.values().next().value}function D(e,t){let{fixturesGlob:n,viewFactories:r}=e,i=u.t(e,S),a=n===!1?null:n==null?`/fixtures/puzzles/**/*.{json,toml}`:n,o=[`import { createSimulator } from "@puzzmo/sdk/simulator"`];for(let e of r==null?[]:r)o.push(`import { ${e.export} } from ${JSON.stringify(e.module)}`);a&&o.push(`const fixtures = import.meta.glob(${JSON.stringify(a)}, { query: "?raw", import: "default", eager: true })`),t!=null&&t.appBundlePath&&(o.push(`import(${JSON.stringify(t.appBundlePath)}).then(m => {`),o.push(` if (m.renderThumbnail) globalThis.renderThumbnail = m.renderThumbnail`),o.push(` if (m.getShareString) globalThis.getShareString = m.getShareString`),o.push(`}).catch(() => {})`));let s=c.t(c.t({},i),t!=null&&t.slug?{slug:t.slug}:{}),l=Object.entries(s).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${JSON.stringify(t)}`);return a&&l.push(`fixtures`),r!=null&&r.length&&l.push(`views: [${r.map(e=>`${e.export}()`).join(`, `)}]`),o.push(`createSimulator({ ${l.join(`, `)} })`),o.join(`
|
|
6
|
+
`)}function O(e={}){let t=new Map,n;return{name:`puzzmo-simulator`,apply:`serve`,configResolved(e){if(n=e.root,t=T(n),t.size===0)e.logger.info(`\x1B[33m\x1B[1m PUZZMO \x1B[22m\x1B[39m\x1B[2m no puzzmo.json files found\x1B[22m`);else{let n=[...t.values()].map(e=>`\x1b[36m${e.slug}\x1b[39m`),r=t.size===1?`game`:`games`;e.logger.info(`\x1b[33m\x1b[1m PUZZMO \x1b[22m\x1b[39m found ${t.size} ${r}: ${n.join(`\x1B[2m, \x1B[22m`)}`)}},resolveId(e){if(e===w||e.startsWith(w+`?`))return`\0`+e},load(n){if(!n.startsWith(`\0`+w))return;let r=new URLSearchParams(n.split(`?`)[1]||``).get(`game`);return D(e,r?t.get(r):t.size===1?t.values().next().value:void 0)},configureServer(e){e.middlewares.use(`/oauth/callback`,(e,t)=>{t.setHeader(`Content-Type`,`text/html`),t.end(`<!DOCTYPE html>
|
|
3
7
|
<html><head><title>Puzzmo OAuth</title></head>
|
|
4
8
|
<body><script>
|
|
5
9
|
var params = new URLSearchParams(window.location.search);
|
|
@@ -7,5 +11,5 @@ var returnUrl = sessionStorage.getItem("oauth_return_url") || "/";
|
|
|
7
11
|
var url = new URL(returnUrl);
|
|
8
12
|
params.forEach(function(v, k) { url.searchParams.set(k, v); });
|
|
9
13
|
window.location.href = url.toString();
|
|
10
|
-
<\/script></body></html>`)}),e.middlewares.use(function(){var r=l.t(function*(r,i,a){var o;if(((o=r.url)==null?void 0:o.split(`?`)[0])!==
|
|
14
|
+
<\/script></body></html>`)}),e.middlewares.use(function(){var r=l.t(function*(r,i,a){var o;if(((o=r.url)==null?void 0:o.split(`?`)[0])!==C)return a();let s=E(r.headers.referer,t,n),c=w+(s?`?game=${s.slug}`:``),l=yield e.transformRequest(c);if(!l)return a();i.setHeader(`Content-Type`,`application/javascript`),i.end(l.code)});return function(e,t,n){return r.apply(this,arguments)}}())},transformIndexHtml(){return[{tag:`script`,attrs:{type:`module`,src:C},injectTo:`head`}]}}}function k(e,t){return(n={})=>{let{entry:r,outputFile:i}=c.t(c.t({},t),n);return{name:e,apply:`build`,closeBundle(){return l.t(function*(){var t;let a=n.entry?p.default.isAbsolute(r)?r:p.default.resolve(process.cwd(),r):(t=j(process.cwd(),A(r)))==null?p.default.resolve(process.cwd(),r):t;try{yield(0,f.build)({configFile:!1,logLevel:`warn`,build:{lib:{entry:a,formats:[`es`],fileName:()=>i},outDir:`dist`,emptyOutDir:!1}})}catch(t){throw console.error(`[${e}] build failed:`,t),t}})()}}}}var A=e=>e.replace(/\.[jt]sx?$/i,``),j=(e,t)=>{for(let n of[`.js`,`.ts`,`.tsx`,`.jsx`]){let r=p.default.join(e,t+n);if(m.default.existsSync(r))return r}return null};const M=k(`app-bundle`,{entry:`src/appBundle.js`,outputFile:`app-bundle.js`}),N=k(`editor-bundle`,{entry:`src/editorBundle.js`,outputFile:`editor-bundle.js`}),P=(e,t,n=0)=>{if(n>=t)return[];let r=[],i;try{i=m.default.readdirSync(e,{withFileTypes:!0})}catch(e){return r}for(let a of i){if(!a.isDirectory()||a.name.startsWith(`.`)||a.name===`node_modules`)continue;let i=p.default.join(e,a.name);m.default.existsSync(p.default.join(i,`puzzmo.json`))&&r.push(i),r.push(...P(i,t,n+1))}return r};exports.appBundlePlugin=M,exports.discoverGames=T,exports.editorBundlePlugin=N,exports.findPuzzmoJsonDirs=P,exports.generateSimulatorCode=D,exports.puzzmoPico8=x,exports.puzzmoSimulator=O,exports.resolveGameFromReferer=E,exports.t=s;
|
|
11
15
|
//# sourceMappingURL=vite.cjs.map
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from \"vite\"\nimport { build } from \"vite\"\nimport path from \"path\"\nimport fs from \"fs\"\nimport type { HostContext } from \"./types\"\nimport type { HostContextPreset } from \"./simulator/types\"\n\nexport type PuzzmoSimulatorPluginOptions = {\n /** Whether to auto-start the game after READY (default: true) */\n autoStart?: boolean\n /** Initial collapsed state (default: true) */\n collapsed?: boolean\n /**\n * Glob pattern for fixture files, passed to import.meta.glob which is relative to the closest puzzmo.json. Defaults\n * to `\"/fixtures/puzzles/**\\/*.{json,toml}\"`. Fixtures are loaded as raw strings (any text format works — JSON,\n * TOML, or a custom format) and delivered to the game verbatim, so the game parses them itself. Pass false to disable.\n */\n fixturesGlob?: string | false\n /**\n * The `hostContext` array the simulator sends in READY_DATA, so host-context-dependent features\n * (embed settings, sandbox mode, mobile layout, …) can be exercised locally. Must be\n * JSON-serializable. Defaults to a single desktop \"app\" context; the simulator's Host tab can\n * override it at runtime (persisted per-browser, applied on restart).\n *\n * @internal\n */\n hostContext?: HostContext[]\n /**\n * Extra named `hostContext` presets for the simulator's Host tab, alongside the generic\n * built-ins — how a game ships its own scenarios (e.g. crossword's partner-embed toolbar\n * settings). Must be JSON-serializable.\n *\n * @internal\n */\n hostContextPresets?: HostContextPreset[]\n /**\n * Plugin-provided simulator tabs, named rather than passed directly because this config is\n * serialized into a virtual module. Each entry is imported and called with no arguments, so the\n * export must be a `() => SimulatorView` factory — e.g.\n * `{ module: \"@puzzmo-com/shared/sdkPlugins\", export: \"createCollabSimulatorView\" }`.\n */\n viewFactories?: { module: string; export: string }[]\n}\n\nconst simulatorURL = \"/@puzzmo-simulator-init.js\"\nconst virtualID = \"virtual:puzzmo-simulator\"\n\n/** @internal */\nexport type GameInfo = {\n /** Directory containing the puzzmo.json */\n dir: string\n slug: string\n displayName: string\n /** Vite-root-relative path to app bundle entry, if it exists */\n appBundlePath: string | null\n}\n\n/**\n * Discover all games from puzzmo.json files under a root directory.\n *\n * @internal\n */\nexport function discoverGames(viteRoot: string): Map<string, GameInfo> {\n const games = new Map<string, GameInfo>()\n const candidates = findPuzzmoJsonDirs(viteRoot, 3)\n if (fs.existsSync(path.join(viteRoot, \"puzzmo.json\"))) {\n candidates.unshift(viteRoot)\n }\n for (const dir of candidates) {\n try {\n const data = JSON.parse(fs.readFileSync(path.join(dir, \"puzzmo.json\"), \"utf-8\"))\n if (!data?.game?.slug) continue\n const bundleEntry = resolveBundleEntry(dir, \"src/appBundle\")\n let appBundle: string | null = null\n if (bundleEntry) {\n const relative = path.relative(viteRoot, bundleEntry)\n appBundle = \"/\" + relative.split(path.sep).join(\"/\")\n }\n games.set(data.game.slug, { dir, slug: data.game.slug, displayName: data.game.displayName, appBundlePath: appBundle })\n } catch {\n // skip invalid files\n }\n }\n return games\n}\n\n/**\n * Resolve which game a request belongs to using the referer URL.\n *\n * @internal\n */\nexport function resolveGameFromReferer(referer: string | undefined, games: Map<string, GameInfo>, viteRoot: string): GameInfo | undefined {\n if (referer) {\n try {\n const refPath = new URL(referer).pathname\n for (const g of games.values()) {\n const relDir = \"/\" + path.relative(viteRoot, g.dir).split(path.sep).join(\"/\")\n if (refPath.startsWith(relDir + \"/\") || refPath === relDir) return g\n }\n } catch {\n // ignore malformed referer\n }\n }\n if (games.size === 1) return games.values().next().value\n return undefined\n}\n\n/**\n * Generate the virtual module code for the simulator.\n *\n * @internal\n */\nexport function generateSimulatorCode(options: PuzzmoSimulatorPluginOptions, game: GameInfo | undefined): string {\n const { fixturesGlob: fixturesOpt, viewFactories, ...config } = options\n const fixturesGlob = fixturesOpt === false ? null : (fixturesOpt ?? \"/fixtures/puzzles/**/*.{json,toml}\")\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n for (const view of viewFactories ?? []) {\n lines.push(`import { ${view.export} } from ${JSON.stringify(view.module)}`)\n }\n\n // Load fixtures as raw strings so any text format reaches the game verbatim; the game does its own parsing.\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { query: \"?raw\", import: \"default\", eager: true })`)\n }\n\n if (game?.appBundlePath) {\n lines.push(`import(${JSON.stringify(game.appBundlePath)}).then(m => {`)\n lines.push(` if (m.renderThumbnail) globalThis.renderThumbnail = m.renderThumbnail`)\n lines.push(` if (m.getShareString) globalThis.getShareString = m.getShareString`)\n lines.push(`}).catch(() => {})`)\n }\n\n const simConfig = { ...config, ...(game?.slug ? { slug: game.slug } : {}) }\n const configEntries = Object.entries(simConfig).filter(([, v]) => v !== undefined)\n const configParts = configEntries.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)\n if (fixturesGlob) configParts.push(\"fixtures\")\n if (viewFactories?.length) configParts.push(`views: [${viewFactories.map((v) => `${v.export}()`).join(\", \")}]`)\n\n lines.push(`createSimulator({ ${configParts.join(\", \")} })`)\n\n return lines.join(\"\\n\")\n}\n\n/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */\nexport function puzzmoSimulator(options: PuzzmoSimulatorPluginOptions = {}): Plugin {\n let games = new Map<string, GameInfo>()\n let viteRoot: string\n\n return {\n name: \"puzzmo-simulator\",\n apply: \"serve\",\n\n configResolved(config: ResolvedConfig) {\n viteRoot = config.root\n games = discoverGames(viteRoot)\n\n if (games.size === 0) {\n config.logger.info(`\\x1b[33m\\x1b[1m PUZZMO \\x1b[22m\\x1b[39m\\x1b[2m no puzzmo.json files found\\x1b[22m`)\n } else {\n const names = [...games.values()].map((g) => `\\x1b[36m${g.slug}\\x1b[39m`)\n const label = games.size === 1 ? \"game\" : \"games\"\n config.logger.info(`\\x1b[33m\\x1b[1m PUZZMO \\x1b[22m\\x1b[39m found ${games.size} ${label}: ${names.join(\"\\x1b[2m, \\x1b[22m\")}`)\n }\n },\n\n resolveId(id) {\n if (id === virtualID || id.startsWith(virtualID + \"?\")) return \"\\0\" + id\n },\n\n load(id) {\n if (!id.startsWith(\"\\0\" + virtualID)) return\n const params = new URLSearchParams(id.split(\"?\")[1] || \"\")\n const gameSlug = params.get(\"game\")\n const game = gameSlug ? games.get(gameSlug) : games.size === 1 ? games.values().next().value : undefined\n return generateSimulatorCode(options, game)\n },\n\n configureServer(server) {\n server.middlewares.use(\"/oauth/callback\", (_req, res) => {\n res.setHeader(\"Content-Type\", \"text/html\")\n res.end(`<!DOCTYPE html>\n<html><head><title>Puzzmo OAuth</title></head>\n<body><script>\nvar params = new URLSearchParams(window.location.search);\nvar returnUrl = sessionStorage.getItem(\"oauth_return_url\") || \"/\";\nvar url = new URL(returnUrl);\nparams.forEach(function(v, k) { url.searchParams.set(k, v); });\nwindow.location.href = url.toString();\n</script></body></html>`)\n })\n\n // Serve the simulator init module, resolving the game from the referer\n server.middlewares.use(async (req, res, next) => {\n if (req.url?.split(\"?\")[0] !== simulatorURL) return next()\n\n const game = resolveGameFromReferer(req.headers.referer, games, viteRoot)\n const moduleID = virtualID + (game ? `?game=${game.slug}` : \"\")\n const result = await server.transformRequest(moduleID)\n if (!result) return next()\n res.setHeader(\"Content-Type\", \"application/javascript\")\n res.end(result.code)\n })\n },\n\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n attrs: { type: \"module\", src: simulatorURL },\n injectTo: \"head\",\n },\n ]\n },\n }\n}\n\ntype BundlePluginOptions = {\n /** Entry file for the bundle */\n entry: string\n /** Output file name */\n outputFile: string\n}\n\nfunction createBundlePlugin(pluginName: string, defaults: BundlePluginOptions) {\n return (options: Partial<BundlePluginOptions> = {}): Plugin => {\n const { entry, outputFile } = { ...defaults, ...options }\n return {\n name: pluginName,\n apply: \"build\",\n async closeBundle() {\n // If the caller overrode `entry`, honor it as-is. Otherwise try `.js` first, then `.ts`.\n const resolvedEntry = options.entry\n ? path.isAbsolute(entry)\n ? entry\n : path.resolve(process.cwd(), entry)\n : (resolveBundleEntry(process.cwd(), stripBundleExt(entry)) ?? path.resolve(process.cwd(), entry))\n try {\n await build({\n configFile: false,\n logLevel: \"warn\",\n build: {\n lib: {\n entry: resolvedEntry,\n formats: [\"es\"],\n fileName: () => outputFile,\n },\n outDir: \"dist\",\n emptyOutDir: false,\n },\n })\n } catch (error) {\n console.error(`[${pluginName}] build failed:`, error)\n throw error\n }\n },\n }\n }\n}\n\n/** Strip the trailing extension from a default entry path so we can probe siblings. */\nconst stripBundleExt = (p: string) => p.replace(/\\.[jt]sx?$/i, \"\")\n\n/** Returns the absolute path to the first matching extension under `dir`, or null. */\nconst resolveBundleEntry = (dir: string, baseRelative: string): string | null => {\n // JSX last: a bundle written as JSX still needs the plain entry to win if both somehow exist.\n for (const ext of [\".js\", \".ts\", \".tsx\", \".jsx\"]) {\n const candidate = path.join(dir, baseRelative + ext)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nexport type AppBundlePluginOptions = {\n /** Entry file for the app bundle (default: `src/appBundle.js`) */\n entry?: string\n /** Output file name (default: `app-bundle.js`) */\n outputFile?: string\n}\n\n/**\n * Vite plugin that produces dist/app-bundle.js after the main build for app-level integrations.\n *\n * The bundle exports `renderThumbnail(puzzleString, inputString?, config?)` — a pure renderer\n * returning the SVG and its dimensions (`{ svg, width, height }`), used by the Puzzmo\n * platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = {\n /** Entry file for the editor bundle (default: `src/editorBundle.js`) */\n entry?: string\n /** Output file name (default: `editor-bundle.js`) */\n outputFile?: string\n}\n\n/** Vite plugin that produces dist/editor-bundle.js after the main build for editor-level integrations. */\nexport const editorBundlePlugin = createBundlePlugin(\"editor-bundle\", { entry: \"src/editorBundle.js\", outputFile: \"editor-bundle.js\" })\n\n/**\n * Recursively find directories containing puzzmo.json, up to `maxDepth` levels deep.\n *\n * @internal\n */\nexport const findPuzzmoJsonDirs = (root: string, maxDepth: number, depth = 0): string[] => {\n if (depth >= maxDepth) return []\n const results: string[] = []\n let entries: fs.Dirent[]\n try {\n entries = fs.readdirSync(root, { withFileTypes: true })\n } catch {\n return results\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue\n const dir = path.join(root, entry.name)\n if (fs.existsSync(path.join(dir, \"puzzmo.json\"))) {\n results.push(dir)\n }\n results.push(...findPuzzmoJsonDirs(dir, maxDepth, depth + 1))\n }\n return results\n}\n"],"mappings":"mwBAiHU,eAA2B,gBAAA,CArE/B,EAAe,6BACf,EAAY,2BAiBlB,SAAgB,EAAc,EAAyC,CACrE,IAAM,EAAQ,IAAI,IACZ,EAAa,EAAmB,EAAU,EAAE,CAC9C,EAAA,QAAG,WAAW,EAAA,QAAK,KAAK,EAAU,cAAc,CAAC,EACnD,EAAW,QAAQ,EAAS,CAE9B,IAAK,IAAM,KAAO,EAChB,GAAI,OACF,IAAM,EAAO,KAAK,MAAM,EAAA,QAAG,aAAa,EAAA,QAAK,KAAK,EAAK,cAAc,CAAE,QAAQ,CAAC,CAChF,GAAI,EAAA,KAAA,OAAA,EAAC,EAAM,OAAA,OAAA,EAAM,MAAM,SACvB,IAAM,EAAc,EAAmB,EAAK,gBAAgB,CACxD,EAA2B,KAC3B,IAEF,EAAY,IADK,EAAA,QAAK,SAAS,EAAU,EAAY,CAC1B,MAAM,EAAA,QAAK,IAAI,CAAC,KAAK,IAAI,EAEtD,EAAM,IAAI,EAAK,KAAK,KAAM,CAAE,MAAK,KAAM,EAAK,KAAK,KAAM,YAAa,EAAK,KAAK,YAAa,cAAe,EAAW,CAAC,SAChH,EAIV,OAAO,EAQT,SAAgB,EAAuB,EAA6B,EAA8B,EAAwC,CACxI,GAAI,EACF,GAAI,CACF,IAAM,EAAU,IAAI,IAAI,EAAQ,CAAC,SACj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M,EAAY,EAAA,QAAK,KAAK,EAAK,EAAe,EAAI,CACpD,GAAI,EAAA,QAAG,WAAW,EAAU,CAAE,OAAO,EAEvC,OAAO,MAiBT,MAAa,EAAkB,EAAmB,aAAc,CAAE,MAAO,mBAAoB,WAAY,gBAAiB,CAAC,CAU9G,EAAqB,EAAmB,gBAAiB,CAAE,MAAO,sBAAuB,WAAY,mBAAoB,CAAC,CAO1H,GAAsB,EAAc,EAAkB,EAAQ,IAAgB,CACzF,GAAI,GAAS,EAAU,MAAO,EAAE,CAChC,IAAM,EAAoB,EAAE,CACxB,EACJ,GAAI,CACF,EAAU,EAAA,QAAG,YAAY,EAAM,CAAE,cAAe,GAAM,CAAC,SACjD,CACN,OAAO,EAET,IAAK,IAAM,KAAS,EAAS,CAC3B,GAAI,CAAC,EAAM,aAAa,EAAI,EAAM,KAAK,WAAW,IAAI,EAAI,EAAM,OAAS,eAAgB,SACzF,IAAM,EAAM,EAAA,QAAK,KAAK,EAAM,EAAM,KAAK,CACnC,EAAA,QAAG,WAAW,EAAA,QAAK,KAAK,EAAK,cAAc,CAAC,EAC9C,EAAQ,KAAK,EAAI,CAEnB,EAAQ,KAAK,GAAG,EAAmB,EAAK,EAAU,EAAQ,EAAE,CAAC,CAE/D,OAAO"}
|
|
1
|
+
{"version":3,"file":"vite.cjs","names":[],"sources":["../src/pico8/vitePlugin.ts","../src/vite.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from \"vite\"\nimport { execFileSync } from \"child_process\"\nimport path from \"path\"\nimport fs from \"fs\"\nimport { puzzmoLua } from \"./lua\"\n\nexport type PuzzmoPico8PluginOptions = {\n /** The cart, relative to the page. Defaults to the only `.p8` file in `cart/`. */\n cart?: string\n /** Where PICO-8's HTML export lives, relative to the page. Defaults to `export`. Commit it, so builds don't need PICO-8. */\n exportDir?: string\n /**\n * The PICO-8 binary used to re-export the cart when it changes. Defaults to `$PICO8`, then `pico8` on your PATH,\n * then where PICO-8's installers put it. When it can't be found the committed export is used as-is. Pass false to\n * never export.\n */\n pico8?: string | false\n /** Keep `puzzmo.lua` next to the cart up to date. Defaults to true. */\n writeLua?: boolean\n}\n\n/** @internal */\nexport type Pico8Game = {\n /** The directory holding the page */\n dir: string\n cart: string\n /** The cart's name, which PICO-8 also uses for its export */\n name: string\n exportHTML: string\n exportJS: string\n}\n\n/** @internal Finds the PICO-8 game served by the page in `dir`, if there is one. */\nexport function findPico8Game(dir: string, options: PuzzmoPico8PluginOptions = {}): Pico8Game | null {\n let cart: string | undefined\n if (options.cart) cart = path.resolve(dir, options.cart)\n else {\n const cartDir = path.join(dir, \"cart\")\n const carts = fs.existsSync(cartDir) ? fs.readdirSync(cartDir).filter((f) => f.endsWith(\".p8\")) : []\n if (carts.length > 1) throw new Error(`[puzzmo-pico8] found ${carts.length} carts in ${cartDir}, pick one with the \\`cart\\` option`)\n if (carts.length === 1) cart = path.join(cartDir, carts[0])\n }\n if (!cart || !fs.existsSync(cart)) return null\n const name = path.basename(cart, \".p8\")\n const exportDir = path.resolve(dir, options.exportDir ?? \"export\")\n return { dir, cart, name, exportHTML: path.join(exportDir, `${name}.html`), exportJS: path.join(exportDir, `${name}.js`) }\n}\n\n/**\n * @internal\n * Turns PICO-8's exported page into a Puzzmo game's page. PICO-8's shell is a thousand lines of globals and handlers\n * its runtime expects to find, and it changes between versions, so rather than keep a copy we adjust theirs.\n */\nexport function patchPico8Export(html: string, name: string, scripts: string[]): string {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n\n // PICO-8 loads its runtime from a script element it builds itself. Point it at the copy we serve next to the page,\n // relative because Puzzmo serves games from a subfolder.\n const runtime = new RegExp(`((?:\\\\.src\\\\s*=\\\\s*|\\\\ssrc=)[\"'])[^\"']*${escaped}\\\\.js([\"'])`)\n if (!runtime.test(html)) throw new Error(`[puzzmo-pico8] couldn't find where PICO-8's page loads ${name}.js`)\n html = html.replace(runtime, `$1./${name}.js$2`)\n\n // Boot straight away. Otherwise the cart waits for a click on PICO-8's play button and the host never hears that\n // the game loaded. (Browsers which need a tap before audio can start, like iOS Safari, still show the button.)\n html = html.replace(/var\\s+p8_autoplay\\s*=\\s*false/, \"var p8_autoplay = true\")\n\n // The GPIO array, for shells old enough not to declare it themselves.\n if (!/var\\s+pico8_gpio\\s*=/.test(html)) html = html.replace(/<head>/i, \"<head>\\n<script>var pico8_gpio = new Array(128)</script>\")\n\n // Things a browser shrugs off and Vite doesn't: an HTML comment wrapped around the stylesheet, a stray\n // `-repeat center;` in it, and an ` ` without its semicolon.\n html = html.replace(\n /(<style[^>]*>)([\\s\\S]*?)(<\\/style>)/gi,\n (_, open: string, css: string, close: string) =>\n open + css.replace(/<!--|-->/g, \"\").replace(/^[ \\t]*-repeat[^;\\n]*;[ \\t]*$/gm, \"\") + close,\n )\n html = html.replace(/ (?!;)/g, \" \")\n\n const bodyEnd = html.lastIndexOf(\"</body>\")\n if (bodyEnd === -1) throw new Error(\"[puzzmo-pico8] that doesn't look like a PICO-8 export, it has no </body>\")\n return html.slice(0, bodyEnd) + scripts.join(\"\\n\") + \"\\n\" + html.slice(bodyEnd)\n}\n\n/** Where PICO-8's own installers put it, for people who never added it to their PATH. */\nconst usualPico8Locations = [\n \"/Applications/PICO-8.app/Contents/MacOS/pico8\",\n \"C:\\\\Program Files (x86)\\\\PICO-8\\\\pico8.exe\",\n \"C:\\\\Program Files\\\\PICO-8\\\\pico8.exe\",\n]\n\n/** Finds an executable on the PATH without running it: `pico8` with no export arguments opens the whole app. */\nconst findExecutable = (bin: string): string | null => {\n if (bin.includes(\"/\") || bin.includes(\"\\\\\")) return fs.existsSync(bin) ? bin : null\n for (const dir of (process.env.PATH ?? \"\").split(path.delimiter)) {\n for (const ext of process.platform === \"win32\" ? [\".exe\", \".cmd\", \"\"] : [\"\"]) {\n const candidate = path.join(dir, bin + ext)\n if (fs.existsSync(candidate)) return candidate\n }\n }\n if (bin === \"pico8\") return usualPico8Locations.find((p) => fs.existsSync(p)) ?? null\n return null\n}\n\nconst mtime = (file: string) => (fs.existsSync(file) ? fs.statSync(file).mtimeMs : 0)\n\n/**\n * Vite plugin for games written as PICO-8 carts. Your `index.html` only needs your own script tag, the plugin swaps\n * in PICO-8's exported page around it, serves the PICO-8 runtime next to it, and copies it into the build.\n *\n * When PICO-8 is installed it also re-exports the cart whenever it (or a `.lua` file next to it) changes, and reloads\n * the page, so saving in PICO-8 is enough to see the change in the simulator.\n */\nexport function puzzmoPico8(options: PuzzmoPico8PluginOptions = {}): Plugin {\n let config: ResolvedConfig\n const games = new Map<string, Pico8Game>()\n const binary = options.pico8 === false ? null : (options.pico8 ?? process.env.PICO8 ?? \"pico8\")\n\n const log = (message: string) => config.logger.info(`\\x1b[33m\\x1b[1m PICO-8 \\x1b[22m\\x1b[39m${message}`)\n\n const writeLua = (game: Pico8Game) => {\n if (options.writeLua === false) return\n const file = path.join(path.dirname(game.cart), \"puzzmo.lua\")\n if (fs.existsSync(file) && fs.readFileSync(file, \"utf8\") === puzzmoLua) return\n fs.writeFileSync(file, puzzmoLua)\n log(`wrote ${path.relative(config.root, file)}`)\n }\n\n /** Re-exports the cart when it's newer than the export and PICO-8 is around to do it. */\n const exportIfStale = (game: Pico8Game) => {\n const cartDir = path.dirname(game.cart)\n const newest = Math.max(\n ...fs\n .readdirSync(cartDir)\n .filter((f) => /\\.(p8|lua)$/.test(f))\n .map((f) => mtime(path.join(cartDir, f))),\n )\n if (fs.existsSync(game.exportJS) && mtime(game.exportJS) >= newest) return\n\n const pico8 = binary ? findExecutable(binary) : null\n if (!pico8) {\n if (fs.existsSync(game.exportHTML)) {\n config.logger.warn(\n `[puzzmo-pico8] ${path.relative(config.root, game.cart)} is newer than its export, and PICO-8 isn't around to re-export it. Using the old export.`,\n )\n return\n }\n throw new Error(\n `[puzzmo-pico8] there's no export of ${path.relative(config.root, game.cart)} yet, and PICO-8 isn't on your PATH to make one.\\n` +\n `Export it inside PICO-8 with EXPORT ${game.name}.html into ${path.relative(config.root, path.dirname(game.exportHTML))}/, or set PICO8=/path/to/pico8.`,\n )\n }\n\n fs.mkdirSync(path.dirname(game.exportHTML), { recursive: true })\n const before = mtime(game.exportJS)\n let output = \"\"\n try {\n output = execFileSync(pico8, [game.cart, \"-export\", game.exportHTML], {\n encoding: \"utf8\",\n timeout: 60_000,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n })\n } catch (error) {\n output = String((error as { stdout?: string }).stdout ?? error)\n }\n if (mtime(game.exportJS) === before) {\n const hint = /label/i.test(output) ? \"\\nHTML exports need a label: run the cart in PICO-8, press CTRL-7, and save.\" : \"\"\n throw new Error(`[puzzmo-pico8] PICO-8 didn't export ${path.relative(config.root, game.cart)}:\\n${output.trim()}${hint}`)\n }\n log(`exported ${path.relative(config.root, game.cart)}`)\n }\n\n const gameForPage = (htmlFile: string) => {\n const dir = path.dirname(htmlFile)\n if (!games.has(dir)) {\n const game = findPico8Game(dir, options)\n if (!game) return null\n games.set(dir, game)\n }\n return games.get(dir)!\n }\n\n return {\n name: \"puzzmo-pico8\",\n\n config() {\n // The export is rewritten on every save, and Vite reloads the page for any .html it sees change. The plugin\n // reloads once the export is done, so Vite reloading too would boot the cart twice.\n const exportDir = options.exportDir ?? \"export\"\n const isExport = (file: string) =>\n /\\.(html|js)$/.test(file) &&\n path.basename(path.dirname(file)) === path.basename(exportDir) &&\n fs.existsSync(path.join(path.dirname(path.dirname(file)), \"cart\"))\n return { server: { watch: { ignored: [isExport] } } }\n },\n\n configResolved(resolved) {\n config = resolved\n },\n\n transformIndexHtml: {\n order: \"pre\",\n handler(html, ctx) {\n const game = gameForPage(ctx.filename)\n if (!game) return\n writeLua(game)\n exportIfStale(game)\n // Keep the page's own module scripts: that's the game code.\n const scripts = html.match(/<script\\b[^>]*type=[\"']module[\"'][^>]*>[\\s\\S]*?<\\/script>/gi) ?? []\n return patchPico8Export(fs.readFileSync(game.exportHTML, \"utf8\"), game.name, scripts)\n },\n },\n\n configureServer(devServer) {\n // Serve the runtime next to the page, untouched by Vite's transforms: it is a megabyte of emscripten output\n // which only works exactly as PICO-8 wrote it.\n devServer.middlewares.use((req, res, next) => {\n const url = decodeURIComponent((req.url ?? \"\").split(\"?\")[0])\n if (!url.endsWith(\".js\")) return next()\n const game = [...games.values()].find(\n (g) =>\n url ===\n \"/\" +\n path\n .relative(config.root, path.join(g.dir, `${g.name}.js`))\n .split(path.sep)\n .join(\"/\"),\n )\n if (!game || !fs.existsSync(game.exportJS)) return next()\n res.setHeader(\"Content-Type\", \"text/javascript\")\n res.end(fs.readFileSync(game.exportJS))\n })\n\n // Saving the cart in PICO-8 re-exports it and reloads the page.\n devServer.watcher.on(\"change\", (file) => {\n const game = [...games.values()].find((g) => path.dirname(file) === path.dirname(g.cart) && /\\.(p8|lua)$/.test(file))\n if (!game || path.basename(file) === \"puzzmo.lua\") return\n try {\n exportIfStale(game)\n devServer.ws.send({ type: \"full-reload\" })\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n config.logger.error(message)\n devServer.ws.send({ type: \"error\", err: { message, stack: \"\" } })\n }\n })\n },\n\n generateBundle() {\n for (const game of games.values()) {\n const fileName = path\n .relative(config.root, path.join(game.dir, `${game.name}.js`))\n .split(path.sep)\n .join(\"/\")\n this.emitFile({ type: \"asset\", fileName, source: fs.readFileSync(game.exportJS) })\n }\n },\n }\n}\n","import type { Plugin, ResolvedConfig } from \"vite\"\nimport { build } from \"vite\"\nimport path from \"path\"\nimport fs from \"fs\"\nimport type { HostContext } from \"./types\"\nimport type { HostContextPreset } from \"./simulator/types\"\n\nexport { puzzmoPico8, type PuzzmoPico8PluginOptions } from \"./pico8/vitePlugin\"\n\nexport type PuzzmoSimulatorPluginOptions = {\n /** Whether to auto-start the game after READY (default: true) */\n autoStart?: boolean\n /** Initial collapsed state (default: true) */\n collapsed?: boolean\n /**\n * Glob pattern for fixture files, passed to import.meta.glob which is relative to the closest puzzmo.json. Defaults\n * to `\"/fixtures/puzzles/**\\/*.{json,toml}\"`. Fixtures are loaded as raw strings (any text format works — JSON,\n * TOML, or a custom format) and delivered to the game verbatim, so the game parses them itself. Pass false to disable.\n */\n fixturesGlob?: string | false\n /**\n * The `hostContext` array the simulator sends in READY_DATA, so host-context-dependent features\n * (embed settings, sandbox mode, mobile layout, …) can be exercised locally. Must be\n * JSON-serializable. Defaults to a single desktop \"app\" context; the simulator's Host tab can\n * override it at runtime (persisted per-browser, applied on restart).\n *\n * @internal\n */\n hostContext?: HostContext[]\n /**\n * Extra named `hostContext` presets for the simulator's Host tab, alongside the generic\n * built-ins — how a game ships its own scenarios (e.g. crossword's partner-embed toolbar\n * settings). Must be JSON-serializable.\n *\n * @internal\n */\n hostContextPresets?: HostContextPreset[]\n /**\n * Plugin-provided simulator tabs, named rather than passed directly because this config is\n * serialized into a virtual module. Each entry is imported and called with no arguments, so the\n * export must be a `() => SimulatorView` factory — e.g.\n * `{ module: \"@puzzmo-com/shared/sdkPlugins\", export: \"createCollabSimulatorView\" }`.\n */\n viewFactories?: { module: string; export: string }[]\n}\n\nconst simulatorURL = \"/@puzzmo-simulator-init.js\"\nconst virtualID = \"virtual:puzzmo-simulator\"\n\n/** @internal */\nexport type GameInfo = {\n /** Directory containing the puzzmo.json */\n dir: string\n slug: string\n displayName: string\n /** Vite-root-relative path to app bundle entry, if it exists */\n appBundlePath: string | null\n}\n\n/**\n * Discover all games from puzzmo.json files under a root directory.\n *\n * @internal\n */\nexport function discoverGames(viteRoot: string): Map<string, GameInfo> {\n const games = new Map<string, GameInfo>()\n const candidates = findPuzzmoJsonDirs(viteRoot, 3)\n if (fs.existsSync(path.join(viteRoot, \"puzzmo.json\"))) {\n candidates.unshift(viteRoot)\n }\n for (const dir of candidates) {\n try {\n const data = JSON.parse(fs.readFileSync(path.join(dir, \"puzzmo.json\"), \"utf-8\"))\n if (!data?.game?.slug) continue\n const bundleEntry = resolveBundleEntry(dir, \"src/appBundle\")\n let appBundle: string | null = null\n if (bundleEntry) {\n const relative = path.relative(viteRoot, bundleEntry)\n appBundle = \"/\" + relative.split(path.sep).join(\"/\")\n }\n games.set(data.game.slug, { dir, slug: data.game.slug, displayName: data.game.displayName, appBundlePath: appBundle })\n } catch {\n // skip invalid files\n }\n }\n return games\n}\n\n/**\n * Resolve which game a request belongs to using the referer URL.\n *\n * @internal\n */\nexport function resolveGameFromReferer(referer: string | undefined, games: Map<string, GameInfo>, viteRoot: string): GameInfo | undefined {\n if (referer) {\n try {\n const refPath = new URL(referer).pathname\n for (const g of games.values()) {\n const relDir = \"/\" + path.relative(viteRoot, g.dir).split(path.sep).join(\"/\")\n if (refPath.startsWith(relDir + \"/\") || refPath === relDir) return g\n }\n } catch {\n // ignore malformed referer\n }\n }\n if (games.size === 1) return games.values().next().value\n return undefined\n}\n\n/**\n * Generate the virtual module code for the simulator.\n *\n * @internal\n */\nexport function generateSimulatorCode(options: PuzzmoSimulatorPluginOptions, game: GameInfo | undefined): string {\n const { fixturesGlob: fixturesOpt, viewFactories, ...config } = options\n const fixturesGlob = fixturesOpt === false ? null : (fixturesOpt ?? \"/fixtures/puzzles/**/*.{json,toml}\")\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n for (const view of viewFactories ?? []) {\n lines.push(`import { ${view.export} } from ${JSON.stringify(view.module)}`)\n }\n\n // Load fixtures as raw strings so any text format reaches the game verbatim; the game does its own parsing.\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { query: \"?raw\", import: \"default\", eager: true })`)\n }\n\n if (game?.appBundlePath) {\n lines.push(`import(${JSON.stringify(game.appBundlePath)}).then(m => {`)\n lines.push(` if (m.renderThumbnail) globalThis.renderThumbnail = m.renderThumbnail`)\n lines.push(` if (m.getShareString) globalThis.getShareString = m.getShareString`)\n lines.push(`}).catch(() => {})`)\n }\n\n const simConfig = { ...config, ...(game?.slug ? { slug: game.slug } : {}) }\n const configEntries = Object.entries(simConfig).filter(([, v]) => v !== undefined)\n const configParts = configEntries.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)\n if (fixturesGlob) configParts.push(\"fixtures\")\n if (viewFactories?.length) configParts.push(`views: [${viewFactories.map((v) => `${v.export}()`).join(\", \")}]`)\n\n lines.push(`createSimulator({ ${configParts.join(\", \")} })`)\n\n return lines.join(\"\\n\")\n}\n\n/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */\nexport function puzzmoSimulator(options: PuzzmoSimulatorPluginOptions = {}): Plugin {\n let games = new Map<string, GameInfo>()\n let viteRoot: string\n\n return {\n name: \"puzzmo-simulator\",\n apply: \"serve\",\n\n configResolved(config: ResolvedConfig) {\n viteRoot = config.root\n games = discoverGames(viteRoot)\n\n if (games.size === 0) {\n config.logger.info(`\\x1b[33m\\x1b[1m PUZZMO \\x1b[22m\\x1b[39m\\x1b[2m no puzzmo.json files found\\x1b[22m`)\n } else {\n const names = [...games.values()].map((g) => `\\x1b[36m${g.slug}\\x1b[39m`)\n const label = games.size === 1 ? \"game\" : \"games\"\n config.logger.info(`\\x1b[33m\\x1b[1m PUZZMO \\x1b[22m\\x1b[39m found ${games.size} ${label}: ${names.join(\"\\x1b[2m, \\x1b[22m\")}`)\n }\n },\n\n resolveId(id) {\n if (id === virtualID || id.startsWith(virtualID + \"?\")) return \"\\0\" + id\n },\n\n load(id) {\n if (!id.startsWith(\"\\0\" + virtualID)) return\n const params = new URLSearchParams(id.split(\"?\")[1] || \"\")\n const gameSlug = params.get(\"game\")\n const game = gameSlug ? games.get(gameSlug) : games.size === 1 ? games.values().next().value : undefined\n return generateSimulatorCode(options, game)\n },\n\n configureServer(server) {\n server.middlewares.use(\"/oauth/callback\", (_req, res) => {\n res.setHeader(\"Content-Type\", \"text/html\")\n res.end(`<!DOCTYPE html>\n<html><head><title>Puzzmo OAuth</title></head>\n<body><script>\nvar params = new URLSearchParams(window.location.search);\nvar returnUrl = sessionStorage.getItem(\"oauth_return_url\") || \"/\";\nvar url = new URL(returnUrl);\nparams.forEach(function(v, k) { url.searchParams.set(k, v); });\nwindow.location.href = url.toString();\n</script></body></html>`)\n })\n\n // Serve the simulator init module, resolving the game from the referer\n server.middlewares.use(async (req, res, next) => {\n if (req.url?.split(\"?\")[0] !== simulatorURL) return next()\n\n const game = resolveGameFromReferer(req.headers.referer, games, viteRoot)\n const moduleID = virtualID + (game ? `?game=${game.slug}` : \"\")\n const result = await server.transformRequest(moduleID)\n if (!result) return next()\n res.setHeader(\"Content-Type\", \"application/javascript\")\n res.end(result.code)\n })\n },\n\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n attrs: { type: \"module\", src: simulatorURL },\n injectTo: \"head\",\n },\n ]\n },\n }\n}\n\ntype BundlePluginOptions = {\n /** Entry file for the bundle */\n entry: string\n /** Output file name */\n outputFile: string\n}\n\nfunction createBundlePlugin(pluginName: string, defaults: BundlePluginOptions) {\n return (options: Partial<BundlePluginOptions> = {}): Plugin => {\n const { entry, outputFile } = { ...defaults, ...options }\n return {\n name: pluginName,\n apply: \"build\",\n async closeBundle() {\n // If the caller overrode `entry`, honor it as-is. Otherwise try `.js` first, then `.ts`.\n const resolvedEntry = options.entry\n ? path.isAbsolute(entry)\n ? entry\n : path.resolve(process.cwd(), entry)\n : (resolveBundleEntry(process.cwd(), stripBundleExt(entry)) ?? path.resolve(process.cwd(), entry))\n try {\n await build({\n configFile: false,\n logLevel: \"warn\",\n build: {\n lib: {\n entry: resolvedEntry,\n formats: [\"es\"],\n fileName: () => outputFile,\n },\n outDir: \"dist\",\n emptyOutDir: false,\n },\n })\n } catch (error) {\n console.error(`[${pluginName}] build failed:`, error)\n throw error\n }\n },\n }\n }\n}\n\n/** Strip the trailing extension from a default entry path so we can probe siblings. */\nconst stripBundleExt = (p: string) => p.replace(/\\.[jt]sx?$/i, \"\")\n\n/** Returns the absolute path to the first matching extension under `dir`, or null. */\nconst resolveBundleEntry = (dir: string, baseRelative: string): string | null => {\n // JSX last: a bundle written as JSX still needs the plain entry to win if both somehow exist.\n for (const ext of [\".js\", \".ts\", \".tsx\", \".jsx\"]) {\n const candidate = path.join(dir, baseRelative + ext)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nexport type AppBundlePluginOptions = {\n /** Entry file for the app bundle (default: `src/appBundle.js`) */\n entry?: string\n /** Output file name (default: `app-bundle.js`) */\n outputFile?: string\n}\n\n/**\n * Vite plugin that produces dist/app-bundle.js after the main build for app-level integrations.\n *\n * The bundle exports `renderThumbnail(puzzleString, inputString?, config?)` — a pure renderer\n * returning the SVG and its dimensions (`{ svg, width, height }`), used by the Puzzmo\n * platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = {\n /** Entry file for the editor bundle (default: `src/editorBundle.js`) */\n entry?: string\n /** Output file name (default: `editor-bundle.js`) */\n outputFile?: string\n}\n\n/** Vite plugin that produces dist/editor-bundle.js after the main build for editor-level integrations. */\nexport const editorBundlePlugin = createBundlePlugin(\"editor-bundle\", { entry: \"src/editorBundle.js\", outputFile: \"editor-bundle.js\" })\n\n/**\n * Recursively find directories containing puzzmo.json, up to `maxDepth` levels deep.\n *\n * @internal\n */\nexport const findPuzzmoJsonDirs = (root: string, maxDepth: number, depth = 0): string[] => {\n if (depth >= maxDepth) return []\n const results: string[] = []\n let entries: fs.Dirent[]\n try {\n entries = fs.readdirSync(root, { withFileTypes: true })\n } catch {\n return results\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue\n const dir = path.join(root, entry.name)\n if (fs.existsSync(path.join(dir, \"puzzmo.json\"))) {\n results.push(dir)\n }\n results.push(...findPuzzmoJsonDirs(dir, maxDepth, depth + 1))\n }\n return results\n}\n"],"mappings":"2zBAiCA,SAAgB,EAAc,EAAa,EAAoC,EAAE,CAAoB,OACnG,IAAI,EACJ,GAAI,EAAQ,KAAM,EAAO,EAAA,QAAK,QAAQ,EAAK,EAAQ,KAAK,KACnD,CACH,IAAM,EAAU,EAA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AS,EAAU,MAAO,EAAE,CAChC,IAAM,EAAoB,EAAE,CACxB,EACJ,GAAI,CACF,EAAU,EAAA,QAAG,YAAY,EAAM,CAAE,cAAe,GAAM,CAAC,SACjD,CACN,OAAO,EAET,IAAK,IAAM,KAAS,EAAS,CAC3B,GAAI,CAAC,EAAM,aAAa,EAAI,EAAM,KAAK,WAAW,IAAI,EAAI,EAAM,OAAS,eAAgB,SACzF,IAAM,EAAM,EAAA,QAAK,KAAK,EAAM,EAAM,KAAK,CACnC,EAAA,QAAG,WAAW,EAAA,QAAK,KAAK,EAAK,cAAc,CAAC,EAC9C,EAAQ,KAAK,EAAI,CAEnB,EAAQ,KAAK,GAAG,EAAmB,EAAK,EAAU,EAAQ,EAAE,CAAC,CAE/D,OAAO"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
import type { HostContext } from "./types";
|
|
3
3
|
import type { HostContextPreset } from "./simulator/types";
|
|
4
|
+
export { puzzmoPico8, type PuzzmoPico8PluginOptions } from "./pico8/vitePlugin";
|
|
4
5
|
export type PuzzmoSimulatorPluginOptions = {
|
|
5
6
|
/** Whether to auto-start the game after READY (default: true) */
|
|
6
7
|
autoStart?: boolean;
|
|
@@ -103,5 +104,4 @@ export declare const editorBundlePlugin: (options?: Partial<BundlePluginOptions>
|
|
|
103
104
|
* @internal
|
|
104
105
|
*/
|
|
105
106
|
export declare const findPuzzmoJsonDirs: (root: string, maxDepth: number, depth?: number) => string[];
|
|
106
|
-
export {};
|
|
107
107
|
//# sourceMappingURL=vite.d.ts.map
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAA;AAIlD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,C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AAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,aA9DT,OAAO,CAAC,mBAAmB,CAAC,KAAQ,MA8DoE,CAAA;AAE3H,MAAM,MAAM,yBAAyB,GAAG;IACtC,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,0GAA0G;AAC1G,eAAO,MAAM,kBAAkB,aAxEZ,OAAO,CAAC,mBAAmB,CAAC,KAAQ,MAwEgF,CAAA;AAEvI;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,EAAE,cAAS,KAAG,MAAM,EAkBpF,CAAA"}
|
package/dist/vite.js
CHANGED
|
@@ -1,25 +1,193 @@
|
|
|
1
|
-
import { t as e } from "./objectSpread2-
|
|
1
|
+
import { t as e } from "./objectSpread2-C8x7fbpH.js";
|
|
2
2
|
import { t } from "./asyncToGenerator-Dn36a-ch.js";
|
|
3
3
|
import { t as n } from "./objectWithoutProperties-BVU0RRck.js";
|
|
4
|
-
import {
|
|
5
|
-
import i from "
|
|
6
|
-
import a from "
|
|
7
|
-
|
|
4
|
+
import { t as r } from "./lua-C3M-mB0u.js";
|
|
5
|
+
import { build as i } from "vite";
|
|
6
|
+
import a from "path";
|
|
7
|
+
import o from "fs";
|
|
8
|
+
import { execFileSync as s } from "child_process";
|
|
9
|
+
/** @internal Finds the PICO-8 game served by the page in `dir`, if there is one. */
|
|
10
|
+
function c(e, t = {}) {
|
|
11
|
+
var n;
|
|
12
|
+
let r;
|
|
13
|
+
if (t.cart) r = a.resolve(e, t.cart);
|
|
14
|
+
else {
|
|
15
|
+
let t = a.join(e, "cart"), n = o.existsSync(t) ? o.readdirSync(t).filter((e) => e.endsWith(".p8")) : [];
|
|
16
|
+
if (n.length > 1) throw Error(`[puzzmo-pico8] found ${n.length} carts in ${t}, pick one with the \`cart\` option`);
|
|
17
|
+
n.length === 1 && (r = a.join(t, n[0]));
|
|
18
|
+
}
|
|
19
|
+
if (!r || !o.existsSync(r)) return null;
|
|
20
|
+
let i = a.basename(r, ".p8"), s = a.resolve(e, (n = t.exportDir) == null ? "export" : n);
|
|
21
|
+
return {
|
|
22
|
+
dir: e,
|
|
23
|
+
cart: r,
|
|
24
|
+
name: i,
|
|
25
|
+
exportHTML: a.join(s, `${i}.html`),
|
|
26
|
+
exportJS: a.join(s, `${i}.js`)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
* Turns PICO-8's exported page into a Puzzmo game's page. PICO-8's shell is a thousand lines of globals and handlers
|
|
32
|
+
* its runtime expects to find, and it changes between versions, so rather than keep a copy we adjust theirs.
|
|
33
|
+
*/
|
|
34
|
+
function l(e, t, n) {
|
|
35
|
+
let r = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = RegExp(`((?:\\.src\\s*=\\s*|\\ssrc=)["'])[^"']*${r}\\.js(["'])`);
|
|
36
|
+
if (!i.test(e)) throw Error(`[puzzmo-pico8] couldn't find where PICO-8's page loads ${t}.js`);
|
|
37
|
+
e = e.replace(i, `$1./${t}.js$2`), e = e.replace(/var\s+p8_autoplay\s*=\s*false/, "var p8_autoplay = true"), /var\s+pico8_gpio\s*=/.test(e) || (e = e.replace(/<head>/i, "<head>\n<script>var pico8_gpio = new Array(128)<\/script>")), e = e.replace(/(<style[^>]*>)([\s\S]*?)(<\/style>)/gi, (e, t, n, r) => t + n.replace(/<!--|-->/g, "").replace(/^[ \t]*-repeat[^;\n]*;[ \t]*$/gm, "") + r), e = e.replace(/ (?!;)/g, " ");
|
|
38
|
+
let a = e.lastIndexOf("</body>");
|
|
39
|
+
if (a === -1) throw Error("[puzzmo-pico8] that doesn't look like a PICO-8 export, it has no </body>");
|
|
40
|
+
return e.slice(0, a) + n.join("\n") + "\n" + e.slice(a);
|
|
41
|
+
}
|
|
42
|
+
/** Where PICO-8's own installers put it, for people who never added it to their PATH. */
|
|
43
|
+
var u = [
|
|
44
|
+
"/Applications/PICO-8.app/Contents/MacOS/pico8",
|
|
45
|
+
"C:\\Program Files (x86)\\PICO-8\\pico8.exe",
|
|
46
|
+
"C:\\Program Files\\PICO-8\\pico8.exe"
|
|
47
|
+
], d = (e) => {
|
|
48
|
+
var t, n;
|
|
49
|
+
if (e.includes("/") || e.includes("\\")) return o.existsSync(e) ? e : null;
|
|
50
|
+
for (let n of ((t = process.env.PATH) == null ? "" : t).split(a.delimiter)) for (let t of process.platform === "win32" ? [
|
|
51
|
+
".exe",
|
|
52
|
+
".cmd",
|
|
53
|
+
""
|
|
54
|
+
] : [""]) {
|
|
55
|
+
let r = a.join(n, e + t);
|
|
56
|
+
if (o.existsSync(r)) return r;
|
|
57
|
+
}
|
|
58
|
+
return e === "pico8" ? (n = u.find((e) => o.existsSync(e))) == null ? null : n : null;
|
|
59
|
+
}, f = (e) => o.existsSync(e) ? o.statSync(e).mtimeMs : 0;
|
|
60
|
+
/**
|
|
61
|
+
* Vite plugin for games written as PICO-8 carts. Your `index.html` only needs your own script tag, the plugin swaps
|
|
62
|
+
* in PICO-8's exported page around it, serves the PICO-8 runtime next to it, and copies it into the build.
|
|
63
|
+
*
|
|
64
|
+
* When PICO-8 is installed it also re-exports the cart whenever it (or a `.lua` file next to it) changes, and reloads
|
|
65
|
+
* the page, so saving in PICO-8 is enough to see the change in the simulator.
|
|
66
|
+
*/
|
|
67
|
+
function p(e = {}) {
|
|
68
|
+
var t, n;
|
|
69
|
+
let i, u = /* @__PURE__ */ new Map(), p = e.pico8 === !1 ? null : (t = (n = e.pico8) == null ? process.env.PICO8 : n) == null ? "pico8" : t, m = (e) => i.logger.info(`\x1b[33m\x1b[1m PICO-8 \x1b[22m\x1b[39m${e}`), h = (t) => {
|
|
70
|
+
if (e.writeLua === !1) return;
|
|
71
|
+
let n = a.join(a.dirname(t.cart), "puzzmo.lua");
|
|
72
|
+
o.existsSync(n) && o.readFileSync(n, "utf8") === r || (o.writeFileSync(n, r), m(`wrote ${a.relative(i.root, n)}`));
|
|
73
|
+
}, g = (e) => {
|
|
74
|
+
let t = a.dirname(e.cart), n = Math.max(...o.readdirSync(t).filter((e) => /\.(p8|lua)$/.test(e)).map((e) => f(a.join(t, e))));
|
|
75
|
+
if (o.existsSync(e.exportJS) && f(e.exportJS) >= n) return;
|
|
76
|
+
let r = p ? d(p) : null;
|
|
77
|
+
if (!r) {
|
|
78
|
+
if (o.existsSync(e.exportHTML)) {
|
|
79
|
+
i.logger.warn(`[puzzmo-pico8] ${a.relative(i.root, e.cart)} is newer than its export, and PICO-8 isn't around to re-export it. Using the old export.`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
throw Error(`[puzzmo-pico8] there's no export of ${a.relative(i.root, e.cart)} yet, and PICO-8 isn't on your PATH to make one.\nExport it inside PICO-8 with EXPORT ${e.name}.html into ${a.relative(i.root, a.dirname(e.exportHTML))}/, or set PICO8=/path/to/pico8.`);
|
|
83
|
+
}
|
|
84
|
+
o.mkdirSync(a.dirname(e.exportHTML), { recursive: !0 });
|
|
85
|
+
let c = f(e.exportJS), l = "";
|
|
86
|
+
try {
|
|
87
|
+
l = s(r, [
|
|
88
|
+
e.cart,
|
|
89
|
+
"-export",
|
|
90
|
+
e.exportHTML
|
|
91
|
+
], {
|
|
92
|
+
encoding: "utf8",
|
|
93
|
+
timeout: 6e4,
|
|
94
|
+
stdio: [
|
|
95
|
+
"ignore",
|
|
96
|
+
"pipe",
|
|
97
|
+
"pipe"
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
} catch (e) {
|
|
101
|
+
var u;
|
|
102
|
+
l = String((u = e.stdout) == null ? e : u);
|
|
103
|
+
}
|
|
104
|
+
if (f(e.exportJS) === c) {
|
|
105
|
+
let t = /label/i.test(l) ? "\nHTML exports need a label: run the cart in PICO-8, press CTRL-7, and save." : "";
|
|
106
|
+
throw Error(`[puzzmo-pico8] PICO-8 didn't export ${a.relative(i.root, e.cart)}:\n${l.trim()}${t}`);
|
|
107
|
+
}
|
|
108
|
+
m(`exported ${a.relative(i.root, e.cart)}`);
|
|
109
|
+
}, _ = (t) => {
|
|
110
|
+
let n = a.dirname(t);
|
|
111
|
+
if (!u.has(n)) {
|
|
112
|
+
let t = c(n, e);
|
|
113
|
+
if (!t) return null;
|
|
114
|
+
u.set(n, t);
|
|
115
|
+
}
|
|
116
|
+
return u.get(n);
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
name: "puzzmo-pico8",
|
|
120
|
+
config() {
|
|
121
|
+
var t;
|
|
122
|
+
let n = (t = e.exportDir) == null ? "export" : t;
|
|
123
|
+
return { server: { watch: { ignored: [(e) => /\.(html|js)$/.test(e) && a.basename(a.dirname(e)) === a.basename(n) && o.existsSync(a.join(a.dirname(a.dirname(e)), "cart"))] } } };
|
|
124
|
+
},
|
|
125
|
+
configResolved(e) {
|
|
126
|
+
i = e;
|
|
127
|
+
},
|
|
128
|
+
transformIndexHtml: {
|
|
129
|
+
order: "pre",
|
|
130
|
+
handler(e, t) {
|
|
131
|
+
var n;
|
|
132
|
+
let r = _(t.filename);
|
|
133
|
+
if (!r) return;
|
|
134
|
+
h(r), g(r);
|
|
135
|
+
let i = (n = e.match(/<script\b[^>]*type=["']module["'][^>]*>[\s\S]*?<\/script>/gi)) == null ? [] : n;
|
|
136
|
+
return l(o.readFileSync(r.exportHTML, "utf8"), r.name, i);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
configureServer(e) {
|
|
140
|
+
e.middlewares.use((e, t, n) => {
|
|
141
|
+
var r;
|
|
142
|
+
let s = decodeURIComponent(((r = e.url) == null ? "" : r).split("?")[0]);
|
|
143
|
+
if (!s.endsWith(".js")) return n();
|
|
144
|
+
let c = [...u.values()].find((e) => s === "/" + a.relative(i.root, a.join(e.dir, `${e.name}.js`)).split(a.sep).join("/"));
|
|
145
|
+
if (!c || !o.existsSync(c.exportJS)) return n();
|
|
146
|
+
t.setHeader("Content-Type", "text/javascript"), t.end(o.readFileSync(c.exportJS));
|
|
147
|
+
}), e.watcher.on("change", (t) => {
|
|
148
|
+
let n = [...u.values()].find((e) => a.dirname(t) === a.dirname(e.cart) && /\.(p8|lua)$/.test(t));
|
|
149
|
+
if (!(!n || a.basename(t) === "puzzmo.lua")) try {
|
|
150
|
+
g(n), e.ws.send({ type: "full-reload" });
|
|
151
|
+
} catch (t) {
|
|
152
|
+
let n = t instanceof Error ? t.message : String(t);
|
|
153
|
+
i.logger.error(n), e.ws.send({
|
|
154
|
+
type: "error",
|
|
155
|
+
err: {
|
|
156
|
+
message: n,
|
|
157
|
+
stack: ""
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
generateBundle() {
|
|
164
|
+
for (let e of u.values()) {
|
|
165
|
+
let t = a.relative(i.root, a.join(e.dir, `${e.name}.js`)).split(a.sep).join("/");
|
|
166
|
+
this.emitFile({
|
|
167
|
+
type: "asset",
|
|
168
|
+
fileName: t,
|
|
169
|
+
source: o.readFileSync(e.exportJS)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
var m = ["fixturesGlob", "viewFactories"], h = "/@puzzmo-simulator-init.js", g = "virtual:puzzmo-simulator";
|
|
8
176
|
/**
|
|
9
177
|
* Discover all games from puzzmo.json files under a root directory.
|
|
10
178
|
*
|
|
11
179
|
* @internal
|
|
12
180
|
*/
|
|
13
|
-
function
|
|
14
|
-
let t = /* @__PURE__ */ new Map(), n =
|
|
15
|
-
|
|
16
|
-
for (let
|
|
181
|
+
function _(e) {
|
|
182
|
+
let t = /* @__PURE__ */ new Map(), n = E(e, 3);
|
|
183
|
+
o.existsSync(a.join(e, "puzzmo.json")) && n.unshift(e);
|
|
184
|
+
for (let i of n) try {
|
|
17
185
|
var r;
|
|
18
|
-
let n = JSON.parse(
|
|
186
|
+
let n = JSON.parse(o.readFileSync(a.join(i, "puzzmo.json"), "utf-8"));
|
|
19
187
|
if (!(!(n == null || (r = n.game) == null) && r.slug)) continue;
|
|
20
|
-
let s =
|
|
21
|
-
s && (c = "/" +
|
|
22
|
-
dir:
|
|
188
|
+
let s = C(i, "src/appBundle"), c = null;
|
|
189
|
+
s && (c = "/" + a.relative(e, s).split(a.sep).join("/")), t.set(n.game.slug, {
|
|
190
|
+
dir: i,
|
|
23
191
|
slug: n.game.slug,
|
|
24
192
|
displayName: n.game.displayName,
|
|
25
193
|
appBundlePath: c
|
|
@@ -32,11 +200,11 @@ function l(e) {
|
|
|
32
200
|
*
|
|
33
201
|
* @internal
|
|
34
202
|
*/
|
|
35
|
-
function
|
|
203
|
+
function v(e, t, n) {
|
|
36
204
|
if (e) try {
|
|
37
205
|
let r = new URL(e).pathname;
|
|
38
206
|
for (let e of t.values()) {
|
|
39
|
-
let t = "/" +
|
|
207
|
+
let t = "/" + a.relative(n, e.dir).split(a.sep).join("/");
|
|
40
208
|
if (r.startsWith(t + "/") || r === t) return e;
|
|
41
209
|
}
|
|
42
210
|
} catch (e) {}
|
|
@@ -47,33 +215,33 @@ function u(e, t, n) {
|
|
|
47
215
|
*
|
|
48
216
|
* @internal
|
|
49
217
|
*/
|
|
50
|
-
function
|
|
51
|
-
let { fixturesGlob: i, viewFactories: a } = t,
|
|
52
|
-
for (let e of a == null ? [] : a)
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
return
|
|
218
|
+
function y(t, r) {
|
|
219
|
+
let { fixturesGlob: i, viewFactories: a } = t, o = n(t, m), s = i === !1 ? null : i == null ? "/fixtures/puzzles/**/*.{json,toml}" : i, c = ["import { createSimulator } from \"@puzzmo/sdk/simulator\""];
|
|
220
|
+
for (let e of a == null ? [] : a) c.push(`import { ${e.export} } from ${JSON.stringify(e.module)}`);
|
|
221
|
+
s && c.push(`const fixtures = import.meta.glob(${JSON.stringify(s)}, { query: "?raw", import: "default", eager: true })`), r != null && r.appBundlePath && (c.push(`import(${JSON.stringify(r.appBundlePath)}).then(m => {`), c.push(" if (m.renderThumbnail) globalThis.renderThumbnail = m.renderThumbnail"), c.push(" if (m.getShareString) globalThis.getShareString = m.getShareString"), c.push("}).catch(() => {})"));
|
|
222
|
+
let l = e(e({}, o), r != null && r.slug ? { slug: r.slug } : {}), u = Object.entries(l).filter(([, e]) => e !== void 0).map(([e, t]) => `${e}: ${JSON.stringify(t)}`);
|
|
223
|
+
return s && u.push("fixtures"), a != null && a.length && u.push(`views: [${a.map((e) => `${e.export}()`).join(", ")}]`), c.push(`createSimulator({ ${u.join(", ")} })`), c.join("\n");
|
|
56
224
|
}
|
|
57
225
|
/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */
|
|
58
|
-
function
|
|
226
|
+
function b(e = {}) {
|
|
59
227
|
let n = /* @__PURE__ */ new Map(), r;
|
|
60
228
|
return {
|
|
61
229
|
name: "puzzmo-simulator",
|
|
62
230
|
apply: "serve",
|
|
63
231
|
configResolved(e) {
|
|
64
|
-
if (r = e.root, n =
|
|
232
|
+
if (r = e.root, n = _(r), n.size === 0) e.logger.info("\x1B[33m\x1B[1m PUZZMO \x1B[22m\x1B[39m\x1B[2m no puzzmo.json files found\x1B[22m");
|
|
65
233
|
else {
|
|
66
234
|
let t = [...n.values()].map((e) => `\x1b[36m${e.slug}\x1b[39m`), r = n.size === 1 ? "game" : "games";
|
|
67
235
|
e.logger.info(`\x1b[33m\x1b[1m PUZZMO \x1b[22m\x1b[39m found ${n.size} ${r}: ${t.join("\x1B[2m, \x1B[22m")}`);
|
|
68
236
|
}
|
|
69
237
|
},
|
|
70
238
|
resolveId(e) {
|
|
71
|
-
if (e ===
|
|
239
|
+
if (e === g || e.startsWith(g + "?")) return "\0" + e;
|
|
72
240
|
},
|
|
73
241
|
load(t) {
|
|
74
|
-
if (!t.startsWith("\0" +
|
|
242
|
+
if (!t.startsWith("\0" + g)) return;
|
|
75
243
|
let r = new URLSearchParams(t.split("?")[1] || "").get("game");
|
|
76
|
-
return
|
|
244
|
+
return y(e, r ? n.get(r) : n.size === 1 ? n.values().next().value : void 0);
|
|
77
245
|
},
|
|
78
246
|
configureServer(e) {
|
|
79
247
|
e.middlewares.use("/oauth/callback", (e, t) => {
|
|
@@ -81,10 +249,10 @@ function f(e = {}) {
|
|
|
81
249
|
}), e.middlewares.use(function() {
|
|
82
250
|
var i = t(function* (t, i, a) {
|
|
83
251
|
var o;
|
|
84
|
-
if (((o = t.url) == null ? void 0 : o.split("?")[0]) !==
|
|
85
|
-
let
|
|
86
|
-
if (!
|
|
87
|
-
i.setHeader("Content-Type", "application/javascript"), i.end(
|
|
252
|
+
if (((o = t.url) == null ? void 0 : o.split("?")[0]) !== h) return a();
|
|
253
|
+
let s = v(t.headers.referer, n, r), c = g + (s ? `?game=${s.slug}` : ""), l = yield e.transformRequest(c);
|
|
254
|
+
if (!l) return a();
|
|
255
|
+
i.setHeader("Content-Type", "application/javascript"), i.end(l.code);
|
|
88
256
|
});
|
|
89
257
|
return function(e, t, n) {
|
|
90
258
|
return i.apply(this, arguments);
|
|
@@ -96,25 +264,25 @@ function f(e = {}) {
|
|
|
96
264
|
tag: "script",
|
|
97
265
|
attrs: {
|
|
98
266
|
type: "module",
|
|
99
|
-
src:
|
|
267
|
+
src: h
|
|
100
268
|
},
|
|
101
269
|
injectTo: "head"
|
|
102
270
|
}];
|
|
103
271
|
}
|
|
104
272
|
};
|
|
105
273
|
}
|
|
106
|
-
function
|
|
274
|
+
function x(n, r) {
|
|
107
275
|
return (o = {}) => {
|
|
108
|
-
let { entry: s, outputFile: c } = e(e({},
|
|
276
|
+
let { entry: s, outputFile: c } = e(e({}, r), o);
|
|
109
277
|
return {
|
|
110
278
|
name: n,
|
|
111
279
|
apply: "build",
|
|
112
280
|
closeBundle() {
|
|
113
281
|
return t(function* () {
|
|
114
282
|
var e;
|
|
115
|
-
let t = o.entry ?
|
|
283
|
+
let t = o.entry ? a.isAbsolute(s) ? s : a.resolve(process.cwd(), s) : (e = C(process.cwd(), S(s))) == null ? a.resolve(process.cwd(), s) : e;
|
|
116
284
|
try {
|
|
117
|
-
yield
|
|
285
|
+
yield i({
|
|
118
286
|
configFile: !1,
|
|
119
287
|
logLevel: "warn",
|
|
120
288
|
build: {
|
|
@@ -136,15 +304,15 @@ function p(n, a) {
|
|
|
136
304
|
};
|
|
137
305
|
}
|
|
138
306
|
/** Strip the trailing extension from a default entry path so we can probe siblings. */
|
|
139
|
-
var
|
|
307
|
+
var S = (e) => e.replace(/\.[jt]sx?$/i, ""), C = (e, t) => {
|
|
140
308
|
for (let n of [
|
|
141
309
|
".js",
|
|
142
310
|
".ts",
|
|
143
311
|
".tsx",
|
|
144
312
|
".jsx"
|
|
145
313
|
]) {
|
|
146
|
-
let r =
|
|
147
|
-
if (
|
|
314
|
+
let r = a.join(e, t + n);
|
|
315
|
+
if (o.existsSync(r)) return r;
|
|
148
316
|
}
|
|
149
317
|
return null;
|
|
150
318
|
};
|
|
@@ -155,27 +323,27 @@ var m = (e) => e.replace(/\.[jt]sx?$/i, ""), h = (e, t) => {
|
|
|
155
323
|
* returning the SVG and its dimensions (`{ svg, width, height }`), used by the Puzzmo
|
|
156
324
|
* platform for puzzle previews.
|
|
157
325
|
*/
|
|
158
|
-
const
|
|
326
|
+
const w = x("app-bundle", {
|
|
159
327
|
entry: "src/appBundle.js",
|
|
160
328
|
outputFile: "app-bundle.js"
|
|
161
|
-
}),
|
|
329
|
+
}), T = x("editor-bundle", {
|
|
162
330
|
entry: "src/editorBundle.js",
|
|
163
331
|
outputFile: "editor-bundle.js"
|
|
164
|
-
}),
|
|
332
|
+
}), E = (e, t, n = 0) => {
|
|
165
333
|
if (n >= t) return [];
|
|
166
|
-
let r = [],
|
|
334
|
+
let r = [], i;
|
|
167
335
|
try {
|
|
168
|
-
|
|
336
|
+
i = o.readdirSync(e, { withFileTypes: !0 });
|
|
169
337
|
} catch (e) {
|
|
170
338
|
return r;
|
|
171
339
|
}
|
|
172
|
-
for (let s of
|
|
340
|
+
for (let s of i) {
|
|
173
341
|
if (!s.isDirectory() || s.name.startsWith(".") || s.name === "node_modules") continue;
|
|
174
|
-
let
|
|
175
|
-
|
|
342
|
+
let i = a.join(e, s.name);
|
|
343
|
+
o.existsSync(a.join(i, "puzzmo.json")) && r.push(i), r.push(...E(i, t, n + 1));
|
|
176
344
|
}
|
|
177
345
|
return r;
|
|
178
346
|
};
|
|
179
|
-
export {
|
|
347
|
+
export { w as appBundlePlugin, _ as discoverGames, T as editorBundlePlugin, E as findPuzzmoJsonDirs, y as generateSimulatorCode, p as puzzmoPico8, b as puzzmoSimulator, v as resolveGameFromReferer };
|
|
180
348
|
|
|
181
349
|
//# sourceMappingURL=vite.js.map
|