@puzzmo/sdk 1.0.18 → 1.0.20

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/types.d.ts CHANGED
@@ -15,8 +15,10 @@ export type Theme = {
15
15
  keyStrong: string;
16
16
  /** A lighter version of the bright pink */
17
17
  keyLight: string;
18
- /** A variant of the key which is always above a certain level of brightness so that you
19
- * can show dark text on it for games */
18
+ /**
19
+ * A variant of the key which is always above a certain level of brightness so that you
20
+ * can show dark text on it for games
21
+ */
20
22
  g_key: string;
21
23
  /** A secondary color for the brand, in Puzzmo's case this is the puzzmo yellow */
22
24
  subBrand: string;
@@ -34,7 +36,7 @@ export type Theme = {
34
36
  alt2: string;
35
37
  /** Alt color 3, this one is a cute purple */
36
38
  alt3: string;
37
- /** The foreground body text color */
39
+ /** The foreground body text color */
38
40
  fg: string;
39
41
  /** The red for showing errors */
40
42
  error: string;
@@ -154,7 +156,7 @@ export type BootstrapGameData = {
154
156
  appRuntimeContract: string;
155
157
  };
156
158
  export type AppBundle = {
157
- /** Renders a puzzle and optional state string into an SVG */
159
+ /** Renders a puzzle and optional state string into an SVG */
158
160
  renderThumbnail(puzzleStr: string, inputStr?: string, config?: ThumbnailConfig): string;
159
161
  /** Takes an input string, and backtracks to a version somewhere between 0-1 for its completion */
160
162
  interpolateInputString?: (inputStr: string, puzzleStr: string, value: number) => {
@@ -197,39 +199,39 @@ export type ThumbnailConfig = {
197
199
  * with letter input. Map those characters to display labels via `symbols`.
198
200
  *
199
201
  * @example
200
- * // Simple QWERTY keyboard — a good starting point for word games
202
+ * // Simple QWERTY keyboard — a good starting point for word games
201
203
  *
202
- * const config: KeyboardConfig = {
203
- * layout: ["qwertyuiop", "asdfghjkl", "↵zxcvbnm⌫", undefined],
204
- * symbols: { "↵": "Enter", "⌫": "bsp" },
205
- * highlight: ["↵", "⌫"],
206
- * disabled: [],
207
- * xl: [],
208
- * l: ["↵", "⌫"],
209
- * supportsDragCursor: false,
210
- * }
204
+ * const config: KeyboardConfig = {
205
+ * layout: ["qwertyuiop", "asdfghjkl", "↵zxcvbnm⌫", undefined],
206
+ * symbols: { "↵": "Enter", "⌫": "bsp" },
207
+ * highlight: ["↵", "⌫"],
208
+ * disabled: [],
209
+ * xl: [],
210
+ * l: ["↵", "⌫"],
211
+ * supportsDragCursor: false,
212
+ * }
211
213
  *
212
214
  * @example
213
- * // Crossword keyboard — complex layout with two panels, direction controls, and drag cursor.
214
- * // Special characters are used as action key tokens; symbols maps them to display labels.
215
- * // The "∂" key flips cursor direction; "≤"/"≥" move between cells; "✱" switches panels.
215
+ * // Crossword keyboard — complex layout with two panels, direction controls, and drag cursor.
216
+ * // Special characters are used as action key tokens; symbols maps them to display labels.
217
+ * // The "∂" key flips cursor direction; "≤"/"≥" move between cells; "✱" switches panels.
216
218
  *
217
- * const crosswordConfig: KeyboardConfig = {
218
- * layout: ["qwertyuiop", "∂asdfghjkl⟳", "≤✱zxcvbnm⌫≥"],
219
- * symbols: {
220
- * "∂": "flip-down", // switches cursor direction (emitted as key press "∂")
221
- * "⟳": "flip-across", // alternate direction flip
222
- * "≤": "prev", // move cursor to previous cell
223
- * "≥": "next", // move cursor to next cell
224
- * "✱": "123", // switch to number/rebus panel
225
- * "⌫": "bsp", // backspace
226
- * },
227
- * highlight: ["∂", "⟳", "≤", "≥", "✱", "⌫"],
228
- * disabled: [],
229
- * xl: [],
230
- * l: [],
231
- * supportsDragCursor: true, // enables the drag-to-position cursor feature
232
- * }
219
+ * const crosswordConfig: KeyboardConfig = {
220
+ * layout: ["qwertyuiop", "∂asdfghjkl⟳", "≤✱zxcvbnm⌫≥"],
221
+ * symbols: {
222
+ * "∂": "flip-down", // switches cursor direction (emitted as key press "∂")
223
+ * "⟳": "flip-across", // alternate direction flip
224
+ * "≤": "prev", // move cursor to previous cell
225
+ * "≥": "next", // move cursor to next cell
226
+ * "✱": "123", // switch to number/rebus panel
227
+ * "⌫": "bsp", // backspace
228
+ * },
229
+ * highlight: ["∂", "⟳", "≤", "≥", "✱", "⌫"],
230
+ * disabled: [],
231
+ * xl: [],
232
+ * l: [],
233
+ * supportsDragCursor: true, // enables the drag-to-position cursor feature
234
+ * }
233
235
  */
234
236
  export type KeyboardConfig = {
235
237
  /**
@@ -240,7 +242,8 @@ export type KeyboardConfig = {
240
242
  * Accepts either a 4-tuple `[row1, row2, row3, row4 | undefined]` or a plain array of
241
243
  * strings/nulls (null renders an empty row).
242
244
  *
243
- * @example ["qwertyuiop", "asdfghjkl", "↵zxcvbnm⌫", undefined]
245
+ * @example
246
+ * ;["qwertyuiop", "asdfghjkl", "↵zxcvbnm⌫", undefined]
244
247
  */
245
248
  layout: [string, string, string, string | undefined] | (string | null)[];
246
249
  /**
@@ -248,7 +251,8 @@ export type KeyboardConfig = {
248
251
  * The token character is what the game receives in a `keyboardKeyPress` event;
249
252
  * the label is purely visual.
250
253
  *
251
- * @example { "⌫": "bsp", "↵": "Enter", "✱": "123" }
254
+ * @example
255
+ * { "⌫": "bsp", "↵": "Enter", "✱": "123" }
252
256
  */
253
257
  symbols: Record<string, string>;
254
258
  /**
@@ -256,7 +260,8 @@ export type KeyboardConfig = {
256
260
  * Typically used for action keys (backspace, enter, direction keys) so they
257
261
  * stand out from the letter keys.
258
262
  *
259
- * @example ["↵", "⌫"]
263
+ * @example
264
+ * ;["↵", "⌫"]
260
265
  */
261
266
  highlight: string[];
262
267
  /**
@@ -264,21 +269,24 @@ export type KeyboardConfig = {
264
269
  * Update this array dynamically to disable letters that are no longer valid
265
270
  * for the current game state (e.g. letters already placed in a word game).
266
271
  *
267
- * @example ["q", "z", "x"] // letters unavailable given current board state
272
+ * @example
273
+ * ;["q", "z", "x"] // letters unavailable given current board state
268
274
  */
269
275
  disabled: string[];
270
276
  /**
271
277
  * Keys that should render at extra-large width (~17.85% of the keyboard row).
272
278
  * Use for high-priority action keys like spacebar or a main confirm key.
273
279
  *
274
- * @example ["␣"]
280
+ * @example
281
+ * ;["␣"]
275
282
  */
276
283
  xl: string[];
277
284
  /**
278
285
  * Keys that should render at large width (~14.7% of the keyboard row).
279
286
  * Use for secondary action keys like Enter and Backspace that need more touch area.
280
287
  *
281
- * @example ["↵", "⌫"]
288
+ * @example
289
+ * ;["↵", "⌫"]
282
290
  */
283
291
  l: string[];
284
292
  /**
@@ -294,21 +302,24 @@ export type KeyboardConfig = {
294
302
  * Controls horizontal alignment for each row. Index matches the `layout` row index.
295
303
  * Defaults to `"center"` for any row not listed.
296
304
  *
297
- * @example ["center", "center", "end", "center"]
305
+ * @example
306
+ * ;["center", "center", "end", "center"]
298
307
  */
299
308
  rowPositioning?: ("end" | "start" | "center" | undefined)[];
300
309
  /**
301
310
  * Keys that expand to fill remaining horizontal space in their row (flex-grow).
302
311
  * Useful for a spacebar key that should stretch across the bottom row.
303
312
  *
304
- * @example ["␣"]
313
+ * @example
314
+ * ;["␣"]
305
315
  */
306
316
  flexGrowSymbols?: string[];
307
317
  /**
308
318
  * CSS properties applied to every key face. Use for font overrides or color tweaks
309
319
  * that apply uniformly across the keyboard.
310
320
  *
311
- * @example { textTransform: "lowercase", color: "#888" }
321
+ * @example
322
+ * { textTransform: "lowercase", color: "#888" }
312
323
  */
313
324
  keyStyles?: Record<string, string>;
314
325
  /**
@@ -370,7 +381,10 @@ export type MessagesSentFromEmbed = {
370
381
  * Sent automatically by the SDK every 10 seconds.
371
382
  */
372
383
  TIMER_SYNC: number;
373
- /** Show or update the on-screen keyboard. Pass the full config each time — the host replaces its entire state. To hide, call `sdk.keyboard.hide()`. */
384
+ /**
385
+ * Show or update the on-screen keyboard. Pass the full config each time — the host replaces its entire state. To hide, call
386
+ * `sdk.keyboard.hide()`.
387
+ */
374
388
  KEYBOARD_UPDATE_CONFIG: KeyboardConfig;
375
389
  /** Notify the host that a named checkpoint was reached (e.g. completing a sub-puzzle or bonus round). */
376
390
  HIT_CHECKPOINT: {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":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AAgB,CAAA;QAClC,SAAS,EAAE,kBAAkB,CAAA;KAC9B,CAAA;CACF,CAAA;AAED,wCAAwC;AACxC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yHAAyH;IACzH,UAAU,EAAE,iBAAiB,CAAA;IAC7B,0GAA0G;IAC1G,UAAU,EAAE;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,CAAA;IACzB,iGAAiG;IACjG,YAAY,EAAE,MAAM,CAAA;IACpB,mFAAiF;IACjF,UAAU,EAAE,SAAS,CAAA;IACrB,yHAAyH;IACzH,UAAU,EAAE,MAAM,CAAA;IAClB,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAA;IACnB,wGAAwG;IACxG,eAAe,EAAE,GAAG,CAAA;IACpB,oGAAoG;IACpG,kBAAkB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACnC,sIAAsI;IACtI,sBAAsB,EAAE;QAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;IACtD,oHAAoH;IACpH,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA"}
package/dist/vite.cjs CHANGED
@@ -1,4 +1,4 @@
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(`./asyncToGenerator-BlxRHn40.cjs`),l=require(`./objectSpread2-B6tAAMuy.cjs`);let u=require(`vite`),d=require(`path`);d=s(d);let f=require(`fs`);f=s(f);function p(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function m(e,t){if(e==null)return{};var n,r,i=p(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var h=[`fixturesGlob`],g=`/@puzzmo-simulator-init.js`,_=`virtual:puzzmo-simulator`;function v(e){let t=new Map,n=T(e,3);f.default.existsSync(d.default.join(e,`puzzmo.json`))&&n.unshift(e);for(let i of n)try{var r;let n=JSON.parse(f.default.readFileSync(d.default.join(i,`puzzmo.json`),`utf-8`));if(!(!(n==null||(r=n.game)==null)&&r.slug))continue;let a=d.default.join(i,`src`,`appBundle.js`),o=null;f.default.existsSync(a)&&(o=`/`+d.default.relative(e,a).split(d.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 y(e,t,n){if(e)try{let r=new URL(e).pathname;for(let e of t.values()){let t=`/`+d.default.relative(n,e.dir).split(d.default.sep).join(`/`);if(r.startsWith(t+`/`)||r===t)return e}}catch(e){}if(t.size===1)return t.values().next().value}function b(e,t){let{fixturesGlob:n}=e,r=m(e,h),i=n===!1?null:n==null?`/fixtures/puzzles/**/*.json`:n,a=[`import { createSimulator } from "@puzzmo/sdk/simulator"`];i&&a.push(`const fixtures = import.meta.glob(${JSON.stringify(i)}, { eager: true })`),t!=null&&t.appBundlePath&&(a.push(`import(${JSON.stringify(t.appBundlePath)}).then(m => {`),a.push(` if (m.renderThumbnail) globalThis.renderThumbnail = m.renderThumbnail`),a.push(`}).catch(() => {})`));let o=l.t(l.t({},r),t!=null&&t.slug?{slug:t.slug}:{}),s=Object.entries(o).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${JSON.stringify(t)}`);return i&&s.push(`fixtures`),a.push(`createSimulator({ ${s.join(`, `)} })`),a.join(`
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(`./asyncToGenerator-BlxRHn40.cjs`),l=require(`./objectSpread2-B6tAAMuy.cjs`);let u=require(`vite`),d=require(`path`);d=s(d);let f=require(`fs`);f=s(f);function p(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function m(e,t){if(e==null)return{};var n,r,i=p(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var h=[`fixturesGlob`],g=`/@puzzmo-simulator-init.js`,_=`virtual:puzzmo-simulator`;function v(e){let t=new Map,n=D(e,3);f.default.existsSync(d.default.join(e,`puzzmo.json`))&&n.unshift(e);for(let i of n)try{var r;let n=JSON.parse(f.default.readFileSync(d.default.join(i,`puzzmo.json`),`utf-8`));if(!(!(n==null||(r=n.game)==null)&&r.slug))continue;let a=w(i,`src/appBundle`),o=null;a&&(o=`/`+d.default.relative(e,a).split(d.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 y(e,t,n){if(e)try{let r=new URL(e).pathname;for(let e of t.values()){let t=`/`+d.default.relative(n,e.dir).split(d.default.sep).join(`/`);if(r.startsWith(t+`/`)||r===t)return e}}catch(e){}if(t.size===1)return t.values().next().value}function b(e,t){let{fixturesGlob:n}=e,r=m(e,h),i=n===!1?null:n==null?`/fixtures/puzzles/**/*.json`:n,a=[`import { createSimulator } from "@puzzmo/sdk/simulator"`];i&&a.push(`const fixtures = import.meta.glob(${JSON.stringify(i)}, { eager: true })`),t!=null&&t.appBundlePath&&(a.push(`import(${JSON.stringify(t.appBundlePath)}).then(m => {`),a.push(` if (m.renderThumbnail) globalThis.renderThumbnail = m.renderThumbnail`),a.push(`}).catch(() => {})`));let o=l.t(l.t({},r),t!=null&&t.slug?{slug:t.slug}:{}),s=Object.entries(o).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${JSON.stringify(t)}`);return i&&s.push(`fixtures`),a.push(`createSimulator({ ${s.join(`, `)} })`),a.join(`
2
2
  `)}function x(e={}){let t=new Map,n;return{name:`puzzmo-simulator`,apply:`serve`,configResolved(e){if(n=e.root,t=v(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===_||e.startsWith(_+`?`))return`\0`+e},load(n){if(!n.startsWith(`\0`+_))return;let r=new URLSearchParams(n.split(`?`)[1]||``).get(`game`);return b(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
3
  <html><head><title>Puzzmo OAuth</title></head>
4
4
  <body><script>
@@ -7,5 +7,5 @@ var returnUrl = sessionStorage.getItem("oauth_return_url") || "/";
7
7
  var url = new URL(returnUrl);
8
8
  params.forEach(function(v, k) { url.searchParams.set(k, v); });
9
9
  window.location.href = url.toString();
10
- <\/script></body></html>`)}),e.middlewares.use(function(){var r=c.t(function*(r,i,a){var o;if(((o=r.url)==null?void 0:o.split(`?`)[0])!==g)return a();let s=y(r.headers.referer,t,n),c=_+(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:g},injectTo:`head`}]}}}function S(e,t){return(n={})=>{let{entry:r,outputFile:i}=l.t(l.t({},t),n);return{name:e,apply:`build`,closeBundle(){return c.t(function*(){try{yield(0,u.build)({configFile:!1,logLevel:`warn`,build:{lib:{entry:d.default.isAbsolute(r)?r:d.default.resolve(process.cwd(),r),formats:[`es`],fileName:()=>i},outDir:`dist`,emptyOutDir:!1}})}catch(t){throw console.error(`[${e}] build failed:`,t),t}})()}}}}const C=S(`app-bundle`,{entry:`src/appBundle.js`,outputFile:`app-bundle.js`}),w=S(`editor-bundle`,{entry:`src/editorBundle.js`,outputFile:`editor-bundle.js`}),T=(e,t,n=0)=>{if(n>=t)return[];let r=[],i;try{i=f.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=d.default.join(e,a.name);f.default.existsSync(d.default.join(i,`puzzmo.json`))&&r.push(i),r.push(...T(i,t,n+1))}return r};exports.appBundlePlugin=C,exports.discoverGames=v,exports.editorBundlePlugin=w,exports.findPuzzmoJsonDirs=T,exports.generateSimulatorCode=b,exports.puzzmoSimulator=x,exports.resolveGameFromReferer=y,exports.t=s;
10
+ <\/script></body></html>`)}),e.middlewares.use(function(){var r=c.t(function*(r,i,a){var o;if(((o=r.url)==null?void 0:o.split(`?`)[0])!==g)return a();let s=y(r.headers.referer,t,n),c=_+(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:g},injectTo:`head`}]}}}function S(e,t){return(n={})=>{let{entry:r,outputFile:i}=l.t(l.t({},t),n);return{name:e,apply:`build`,closeBundle(){return c.t(function*(){var t;let a=n.entry?d.default.isAbsolute(r)?r:d.default.resolve(process.cwd(),r):(t=w(process.cwd(),C(r)))==null?d.default.resolve(process.cwd(),r):t;try{yield(0,u.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 C=e=>e.replace(/\.[jt]sx?$/i,``),w=(e,t)=>{for(let n of[`.js`,`.ts`]){let r=d.default.join(e,t+n);if(f.default.existsSync(r))return r}return null};const T=S(`app-bundle`,{entry:`src/appBundle.js`,outputFile:`app-bundle.js`}),E=S(`editor-bundle`,{entry:`src/editorBundle.js`,outputFile:`editor-bundle.js`}),D=(e,t,n=0)=>{if(n>=t)return[];let r=[],i;try{i=f.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=d.default.join(e,a.name);f.default.existsSync(d.default.join(i,`puzzmo.json`))&&r.push(i),r.push(...D(i,t,n+1))}return r};exports.appBundlePlugin=T,exports.discoverGames=v,exports.editorBundlePlugin=E,exports.findPuzzmoJsonDirs=D,exports.generateSimulatorCode=b,exports.puzzmoSimulator=x,exports.resolveGameFromReferer=y,exports.t=s;
11
11
  //# 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\"\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 /** Glob pattern for fixture files, passed to import.meta.glob which is relative to the closest puzzmo.json. Defaults to \"/fixtures/puzzles/**\\/*.json\". Pass false to disable. */\n fixturesGlob?: string | false\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 * @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 = path.join(dir, \"src\", \"appBundle.js\")\n let appBundle: string | null = null\n if (fs.existsSync(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 * @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 * @internal\n */\nexport function generateSimulatorCode(options: PuzzmoSimulatorPluginOptions, game: GameInfo | undefined): string {\n const { fixturesGlob: fixturesOpt, ...config } = options\n const fixturesGlob = fixturesOpt === false ? null : (fixturesOpt ?? \"/fixtures/puzzles/**/*.json\")\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { 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(`}).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\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 try {\n await build({\n configFile: false,\n logLevel: \"warn\",\n build: {\n lib: {\n entry: path.isAbsolute(entry) ? entry : path.resolve(process.cwd(), entry),\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\nexport type AppBundlePluginOptions = Partial<BundlePluginOptions>\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(puzzleStr, inputStr?, config?)` — a pure\n * SVG-string renderer used by the Puzzmo platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = Partial<BundlePluginOptions>\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 * @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":"yjCAgFU,eAAA,CAlEJ,EAAe,6BACf,EAAY,2BAgBlB,SAAgB,EAAc,EAAyC,CACrE,IAAM,EAAQ,IAAI,IACZ,EAAa,EAAmB,EAAU,EAAE,CAC9C,EAAA,QAAG,WAAW,EAAA,QAAK,KAAK,EAAU,cAA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d,CACF,CAAC,OACK,EAAO,CAEd,MADA,QAAQ,MAAM,IAAI,EAAW,iBAAkB,EAAM,CAC/C,QAGX,EAYL,MAAa,EAAkB,EAAmB,aAAc,CAAE,MAAO,mBAAoB,WAAY,gBAAiB,CAAC,CAK9G,EAAqB,EAAmB,gBAAiB,CAAE,MAAO,sBAAuB,WAAY,mBAAoB,CAAC,CAM1H,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/vite.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from \"vite\"\nimport { build } from \"vite\"\nimport path from \"path\"\nimport fs from \"fs\"\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 to\n * `\"/fixtures/puzzles/**\\/*.json\"`. Pass false to disable.\n */\n fixturesGlob?: string | false\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, ...config } = options\n const fixturesGlob = fixturesOpt === false ? null : (fixturesOpt ?? \"/fixtures/puzzles/**/*.json\")\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { 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(`}).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\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 for (const ext of [\".js\", \".ts\"]) {\n const candidate = path.join(dir, baseRelative + ext)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nexport type AppBundlePluginOptions = Partial<BundlePluginOptions>\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(puzzleStr, inputStr?, config?)` — a pure\n * SVG-string renderer used by the Puzzmo platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = Partial<BundlePluginOptions>\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":"yjCAsFU,eAAA,CArEJ,EAAe,6BACf,EAAY,2BAiBlB,SAAgB,EAAc,EAAyC,CACrE,IAAM,EAAQ,IAAI,IACZ,EAAa,E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type PuzzmoSimulatorPluginOptions = {
4
4
  autoStart?: boolean;
5
5
  /** Initial collapsed state (default: true) */
6
6
  collapsed?: boolean;
7
- /** Glob pattern for fixture files, passed to import.meta.glob which is relative to the closest puzzmo.json. Defaults to "/fixtures/puzzles/**\/*.json". Pass false to disable. */
7
+ /**
8
+ * Glob pattern for fixture files, passed to import.meta.glob which is relative to the closest puzzmo.json. Defaults to
9
+ * `"/fixtures/puzzles/**\/*.json"`. Pass false to disable.
10
+ */
8
11
  fixturesGlob?: string | false;
9
12
  };
10
13
  /** @internal */
@@ -18,16 +21,19 @@ export type GameInfo = {
18
21
  };
19
22
  /**
20
23
  * Discover all games from puzzmo.json files under a root directory.
24
+ *
21
25
  * @internal
22
26
  */
23
27
  export declare function discoverGames(viteRoot: string): Map<string, GameInfo>;
24
28
  /**
25
29
  * Resolve which game a request belongs to using the referer URL.
30
+ *
26
31
  * @internal
27
32
  */
28
33
  export declare function resolveGameFromReferer(referer: string | undefined, games: Map<string, GameInfo>, viteRoot: string): GameInfo | undefined;
29
34
  /**
30
35
  * Generate the virtual module code for the simulator.
36
+ *
31
37
  * @internal
32
38
  */
33
39
  export declare function generateSimulatorCode(options: PuzzmoSimulatorPluginOptions, game: GameInfo | undefined): string;
@@ -52,6 +58,7 @@ export type EditorBundlePluginOptions = Partial<BundlePluginOptions>;
52
58
  export declare const editorBundlePlugin: (options?: Partial<BundlePluginOptions>) => Plugin<any>;
53
59
  /**
54
60
  * Recursively find directories containing puzzmo.json, up to `maxDepth` levels deep.
61
+ *
55
62
  * @internal
56
63
  */
57
64
  export declare const findPuzzmoJsonDirs: (root: string, maxDepth: number, depth?: number) => string[];
@@ -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;AAKlD,MAAM,MAAM,4BAA4B,GAAG;IACzC,iEAAiE;IACjE,SAAS,CAAC,EAAE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D,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,yDAA+F,CAAA;AAE3H,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEpE,0GAA0G;AAC1G,eAAO,MAAM,kBAAkB,yDAAwG,CAAA;AAEvI;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,8DAkB9B,CAAA"}
package/dist/vite.js CHANGED
@@ -24,17 +24,18 @@ function o(e, t) {
24
24
  var s = ["fixturesGlob"], c = "/@puzzmo-simulator-init.js", l = "virtual:puzzmo-simulator";
25
25
  /**
26
26
  * Discover all games from puzzmo.json files under a root directory.
27
+ *
27
28
  * @internal
28
29
  */
29
30
  function u(e) {
30
- let t = /* @__PURE__ */ new Map(), n = _(e, 3);
31
+ let t = /* @__PURE__ */ new Map(), n = y(e, 3);
31
32
  i.existsSync(r.join(e, "puzzmo.json")) && n.unshift(e);
32
33
  for (let o of n) try {
33
34
  var a;
34
35
  let n = JSON.parse(i.readFileSync(r.join(o, "puzzmo.json"), "utf-8"));
35
36
  if (!(!(n == null || (a = n.game) == null) && a.slug)) continue;
36
- let s = r.join(o, "src", "appBundle.js"), c = null;
37
- i.existsSync(s) && (c = "/" + r.relative(e, s).split(r.sep).join("/")), t.set(n.game.slug, {
37
+ let s = g(o, "src/appBundle"), c = null;
38
+ s && (c = "/" + r.relative(e, s).split(r.sep).join("/")), t.set(n.game.slug, {
38
39
  dir: o,
39
40
  slug: n.game.slug,
40
41
  displayName: n.game.displayName,
@@ -45,6 +46,7 @@ function u(e) {
45
46
  }
46
47
  /**
47
48
  * Resolve which game a request belongs to using the referer URL.
49
+ *
48
50
  * @internal
49
51
  */
50
52
  function d(e, t, n) {
@@ -59,6 +61,7 @@ function d(e, t, n) {
59
61
  }
60
62
  /**
61
63
  * Generate the virtual module code for the simulator.
64
+ *
62
65
  * @internal
63
66
  */
64
67
  function f(e, n) {
@@ -124,13 +127,15 @@ function m(i, a) {
124
127
  apply: "build",
125
128
  closeBundle() {
126
129
  return e(function* () {
130
+ var e;
131
+ let t = o.entry ? r.isAbsolute(s) ? s : r.resolve(process.cwd(), s) : (e = g(process.cwd(), h(s))) == null ? r.resolve(process.cwd(), s) : e;
127
132
  try {
128
133
  yield n({
129
134
  configFile: !1,
130
135
  logLevel: "warn",
131
136
  build: {
132
137
  lib: {
133
- entry: r.isAbsolute(s) ? s : r.resolve(process.cwd(), s),
138
+ entry: t,
134
139
  formats: ["es"],
135
140
  fileName: () => c
136
141
  },
@@ -146,19 +151,27 @@ function m(i, a) {
146
151
  };
147
152
  };
148
153
  }
154
+ /** Strip the trailing extension from a default entry path so we can probe siblings. */
155
+ var h = (e) => e.replace(/\.[jt]sx?$/i, ""), g = (e, t) => {
156
+ for (let n of [".js", ".ts"]) {
157
+ let a = r.join(e, t + n);
158
+ if (i.existsSync(a)) return a;
159
+ }
160
+ return null;
161
+ };
149
162
  /**
150
163
  * Vite plugin that produces dist/app-bundle.js after the main build for app-level integrations.
151
164
  *
152
165
  * The bundle exports `renderThumbnail(puzzleStr, inputStr?, config?)` — a pure
153
166
  * SVG-string renderer used by the Puzzmo platform for puzzle previews.
154
167
  */
155
- const h = m("app-bundle", {
168
+ const _ = m("app-bundle", {
156
169
  entry: "src/appBundle.js",
157
170
  outputFile: "app-bundle.js"
158
- }), g = m("editor-bundle", {
171
+ }), v = m("editor-bundle", {
159
172
  entry: "src/editorBundle.js",
160
173
  outputFile: "editor-bundle.js"
161
- }), _ = (e, t, n = 0) => {
174
+ }), y = (e, t, n = 0) => {
162
175
  if (n >= t) return [];
163
176
  let a = [], o;
164
177
  try {
@@ -169,10 +182,10 @@ const h = m("app-bundle", {
169
182
  for (let s of o) {
170
183
  if (!s.isDirectory() || s.name.startsWith(".") || s.name === "node_modules") continue;
171
184
  let o = r.join(e, s.name);
172
- i.existsSync(r.join(o, "puzzmo.json")) && a.push(o), a.push(..._(o, t, n + 1));
185
+ i.existsSync(r.join(o, "puzzmo.json")) && a.push(o), a.push(...y(o, t, n + 1));
173
186
  }
174
187
  return a;
175
188
  };
176
- export { h as appBundlePlugin, u as discoverGames, g as editorBundlePlugin, _ as findPuzzmoJsonDirs, f as generateSimulatorCode, p as puzzmoSimulator, d as resolveGameFromReferer };
189
+ export { _ as appBundlePlugin, u as discoverGames, v as editorBundlePlugin, y as findPuzzmoJsonDirs, f as generateSimulatorCode, p as puzzmoSimulator, d as resolveGameFromReferer };
177
190
 
178
191
  //# sourceMappingURL=vite.js.map
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from \"vite\"\nimport { build } from \"vite\"\nimport path from \"path\"\nimport fs from \"fs\"\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 /** Glob pattern for fixture files, passed to import.meta.glob which is relative to the closest puzzmo.json. Defaults to \"/fixtures/puzzles/**\\/*.json\". Pass false to disable. */\n fixturesGlob?: string | false\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 * @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 = path.join(dir, \"src\", \"appBundle.js\")\n let appBundle: string | null = null\n if (fs.existsSync(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 * @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 * @internal\n */\nexport function generateSimulatorCode(options: PuzzmoSimulatorPluginOptions, game: GameInfo | undefined): string {\n const { fixturesGlob: fixturesOpt, ...config } = options\n const fixturesGlob = fixturesOpt === false ? null : (fixturesOpt ?? \"/fixtures/puzzles/**/*.json\")\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { 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(`}).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\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 try {\n await build({\n configFile: false,\n logLevel: \"warn\",\n build: {\n lib: {\n entry: path.isAbsolute(entry) ? entry : path.resolve(process.cwd(), entry),\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\nexport type AppBundlePluginOptions = Partial<BundlePluginOptions>\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(puzzleStr, inputStr?, config?)` — a pure\n * SVG-string renderer used by the Puzzmo platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = Partial<BundlePluginOptions>\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 * @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":";;;;;;;;;;;;;;;;;;;;;;;SAgFU,eAAA,EAlEJ,IAAe,8BACf,IAAY;;;;;AAgBlB,SAAgB,EAAc,GAAyC;CACrE,IAAM,oBAAQ,IAAI,KAAuB,EACnC,IAAa,EAAmB,GAAU,EAAE;AAClD,CAAI,EAAG,WAAW,EAAK,KAAK,GAAU,cAAc,CAAC,IACnD,EAAW,QAAQ,EAAS;AAE9B,MAAK,IAAM,KAAO,EAChB,KAAI;;EACF,IAAM,IAAO,KAAK,MAAM,EAAG,aAAa,EAAK,KAAK,GAAK,cAAc,EAAE,QAAQ,CAAC;AAChF,MAAI,EAAA,OAAA,SAAA,IAAC,EAAM,SAAA,SAAA,EAAM,MAAM;EACvB,IAAM,IAAc,EAAK,KAAK,GAAK,OAAO,eAAe,EACrD,IAA2B;AAK/B,EAJI,EAAG,WAAW,EAAY,KAE5B,IAAY,MADK,EAAK,SAAS,GAAU,EAAY,CAC1B,MAAM,EAAK,IAAI,CAAC,KAAK,IAAI,GAEtD,EAAM,IAAI,EAAK,KAAK,MAAM;GAAE;GAAK,MAAM,EAAK,KAAK;GAAM,aAAa,EAAK,KAAK;GAAa,eAAe;GAAW,CAAC;aAChH;AAIV,QAAO;;;;;;AAOT,SAAgB,EAAuB,GAA6B,GAA8B,GAAwC;AACxI,KAAI,EACF,KAAI;EACF,IAAM,IAAU,IAAI,IAAI,EAAQ,CAAC;AACjC,OAAK,IAAM,KAAK,EAAM,QAAQ,EAAE;GAC9B,IAAM,IAA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C;;AAE/D,QAAO"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from \"vite\"\nimport { build } from \"vite\"\nimport path from \"path\"\nimport fs from \"fs\"\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 to\n * `\"/fixtures/puzzles/**\\/*.json\"`. Pass false to disable.\n */\n fixturesGlob?: string | false\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, ...config } = options\n const fixturesGlob = fixturesOpt === false ? null : (fixturesOpt ?? \"/fixtures/puzzles/**/*.json\")\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { 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(`}).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\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 for (const ext of [\".js\", \".ts\"]) {\n const candidate = path.join(dir, baseRelative + ext)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nexport type AppBundlePluginOptions = Partial<BundlePluginOptions>\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(puzzleStr, inputStr?, config?)` — a pure\n * SVG-string renderer used by the Puzzmo platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = Partial<BundlePluginOptions>\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":";;;;;;;;;;;;;;;;;;;;;;;SAsFU,eAAA,EArEJ,IAAe,8BACf,IAAY;;;;;;AAiBlB,SAAgB,EAAc,GAAyC;CACrE,IAAM,oBAAQ,IAAI,KAAuB,EACnC,IAAa,EAAmB,GAAU,EAAE;AAClD,CAAI,EAAG,WAAW,EAAK,KAAK,GAAU,cAAc,CAAC,IACnD,EAAW,QAAQ,EAAS;AAE9B,MAAK,IAAM,KAAO,EAChB,KAAI;;EACF,IAAM,IAAO,KAAK,MAAM,EAAG,aAAa,EAAK,KAAK,GAAK,cAAc,EAAE,QAAQ,CAAC;AAChF,MAAI,EAAA,OAAA,SAAA,IAAC,EAAM,SAAA,SAAA,EAAM,MAAM;EACvB,IAAM,IAAc,EAAmB,GAAK,gBAAgB,EACxD,IAA2B;AAK/B,EAJI,MAEF,IAAY,MADK,EAAK,SAAS,GAAU,EAAY,CAC1B,MAAM,EAAK,IAAI,CAAC,KAAK,IAAI,GAEtD,EAAM,IAAI,EAAK,KAAK,MAAM;GAAE;GAAK,MAAM,EAAK,KAAK;GAAM,aAAa,EAAK,KAAK;GAAa,eAAe;GAAW,CAAC;aAChH;AAIV,QAAO;;;;;;;AAQT,SAAgB,EAAuB,GAA6B,GAA8B,GAAwC;AACxI,KAAI,EACF,KAAI;EACF,IAAM,IAAU,IAAI,IAAI,EAAQ,CAAC;AACjC,OAAK,IAAM,KAAK,EAA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M,IAAoB,EAAE,EACxB;AACJ,KAAI;AACF,MAAU,EAAG,YAAY,GAAM,EAAE,eAAe,IAAM,CAAC;aACjD;AACN,SAAO;;AAET,MAAK,IAAM,KAAS,GAAS;AAC3B,MAAI,CAAC,EAAM,aAAa,IAAI,EAAM,KAAK,WAAW,IAAI,IAAI,EAAM,SAAS,eAAgB;EACzF,IAAM,IAAM,EAAK,KAAK,GAAM,EAAM,KAAK;AAIvC,EAHI,EAAG,WAAW,EAAK,KAAK,GAAK,cAAc,CAAC,IAC9C,EAAQ,KAAK,EAAI,EAEnB,EAAQ,KAAK,GAAG,EAAmB,GAAK,GAAU,IAAQ,EAAE,CAAC;;AAE/D,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puzzmo/sdk",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Puzzmo runtime SDK for game developers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",