@puzzmo/sdk 1.0.81 → 1.0.83
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/analytics.d.ts.map +1 -1
- package/dist/bootstrapPayload.d.ts.map +1 -1
- package/dist/bootstrapPayload.spec.d.ts.map +1 -1
- package/dist/bundleChecks.d.ts +48 -0
- package/dist/bundleChecks.d.ts.map +1 -0
- package/dist/bundles.cjs +1 -1
- package/dist/bundles.cjs.map +1 -1
- package/dist/bundles.d.ts +10 -2
- package/dist/bundles.d.ts.map +1 -1
- package/dist/bundles.js +2 -2
- package/dist/bundles.js.map +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/createSimulator-CIE72Xs2.cjs +2233 -0
- package/dist/createSimulator-CIE72Xs2.cjs.map +1 -0
- package/dist/{createSimulator-2M7vXzRZ.js → createSimulator-Dz1KYZ25.js} +1579 -596
- package/dist/createSimulator-Dz1KYZ25.js.map +1 -0
- package/dist/easing.d.ts +6 -0
- package/dist/easing.d.ts.map +1 -0
- package/dist/editor.d.ts +25 -3
- package/dist/editor.d.ts.map +1 -1
- package/dist/fontFiles.gen.d.ts.map +1 -1
- package/dist/fonts-CP_kAAac.js +83 -0
- package/dist/fonts-CP_kAAac.js.map +1 -0
- package/dist/fonts-CS5qdLf3.cjs +3 -0
- package/dist/fonts-CS5qdLf3.cjs.map +1 -0
- package/dist/fonts.cjs +1 -3
- package/dist/fonts.d.ts +2 -0
- package/dist/fonts.d.ts.map +1 -1
- package/dist/fonts.js +2 -83
- package/dist/gameTracker.d.ts.map +1 -1
- package/dist/global.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inputs/decoder.d.ts.map +1 -1
- package/dist/inputs/encoder.d.ts.map +1 -1
- package/dist/inputs/encodings.d.ts.map +1 -1
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/inputStringEncoder.spec.d.ts.map +1 -1
- package/dist/inputs/migration.d.ts.map +1 -1
- package/dist/inputs/types.d.ts.map +1 -1
- package/dist/keyboard.d.ts.map +1 -1
- package/dist/keyboard.spec.d.ts.map +1 -1
- package/dist/{lua-DKb2Tu2V.js → lua-B8exrfmB.js} +1 -1
- package/dist/{lua-DKb2Tu2V.js.map → lua-B8exrfmB.js.map} +1 -1
- package/dist/{lua-CclI-QKD.cjs → lua-C5r7UXeR.cjs} +1 -1
- package/dist/{lua-CclI-QKD.cjs.map → lua-C5r7UXeR.cjs.map} +1 -1
- package/dist/pico8/channel.d.ts.map +1 -1
- package/dist/pico8/index.cjs +1 -1
- package/dist/pico8/index.d.ts.map +1 -1
- package/dist/pico8/index.js +1 -1
- package/dist/pico8/lua.d.ts.map +1 -1
- package/dist/pico8/palette.d.ts.map +1 -1
- package/dist/pico8/pico8.spec.d.ts.map +1 -1
- package/dist/pico8/protocol.d.ts.map +1 -1
- package/dist/pico8/vitePlugin.d.ts.map +1 -1
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.spec.d.ts.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.gameCompleted.spec.d.ts.map +1 -1
- package/dist/sdk.gameReady.spec.d.ts.map +1 -1
- package/dist/sdk.pause.spec.d.ts.map +1 -1
- package/dist/sdk.session.spec.d.ts.map +1 -1
- package/dist/settings.spec.d.ts.map +1 -1
- package/dist/simulator/checklistProgress.d.ts.map +1 -1
- package/dist/simulator/checklistProgress.spec.d.ts.map +1 -1
- package/dist/simulator/createSimulator.d.ts.map +1 -1
- package/dist/simulator/dockedKeyboard.d.ts.map +1 -1
- package/dist/simulator/fixtures.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2 -1
- package/dist/simulator/marker.d.ts.map +1 -1
- package/dist/simulator/messaging.d.ts.map +1 -1
- package/dist/simulator/normalizeThumbnail.d.ts.map +1 -1
- package/dist/simulator/pmmgOverlay.d.ts +36 -0
- package/dist/simulator/pmmgOverlay.d.ts.map +1 -0
- package/dist/simulator/pmmgOverlay.spec.d.ts +2 -0
- package/dist/simulator/pmmgOverlay.spec.d.ts.map +1 -0
- package/dist/simulator/pmmgRenderer.d.ts +86 -0
- package/dist/simulator/pmmgRenderer.d.ts.map +1 -0
- package/dist/simulator/pmmgRenderer.spec.d.ts +2 -0
- package/dist/simulator/pmmgRenderer.spec.d.ts.map +1 -0
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.cjs.map +1 -1
- package/dist/simulator/standalone.d.ts.map +1 -1
- package/dist/simulator/standalone.js +2 -1
- package/dist/simulator/standalone.js.map +1 -1
- package/dist/simulator/state.d.ts +19 -0
- package/dist/simulator/state.d.ts.map +1 -1
- package/dist/simulator/state.spec.d.ts.map +1 -1
- package/dist/simulator/styles.d.ts +1 -1
- package/dist/simulator/styles.d.ts.map +1 -1
- package/dist/simulator/types.d.ts +5 -0
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/AuthView.d.ts.map +1 -1
- package/dist/simulator/views/ChecklistView.d.ts.map +1 -1
- package/dist/simulator/views/CheckpointsView.d.ts.map +1 -1
- package/dist/simulator/views/CtrlView.d.ts.map +1 -1
- package/dist/simulator/views/DataView.d.ts.map +1 -1
- package/dist/simulator/views/DoneView.d.ts.map +1 -1
- package/dist/simulator/views/FeaturesView.d.ts.map +1 -1
- package/dist/simulator/views/HostView.d.ts.map +1 -1
- package/dist/simulator/views/KeyboardView.d.ts.map +1 -1
- package/dist/simulator/views/MsgsView.d.ts.map +1 -1
- package/dist/simulator/views/PmmgView.d.ts +7 -0
- package/dist/simulator/views/PmmgView.d.ts.map +1 -0
- package/dist/simulator/views/SettingsView.d.ts.map +1 -1
- package/dist/simulator/views/SoundView.d.ts.map +1 -1
- package/dist/simulator/views/ThemeView.d.ts.map +1 -1
- package/dist/simulator/views/ThumbView.d.ts.map +1 -1
- package/dist/simulator/views/index.d.ts +1 -0
- package/dist/simulator/views/index.d.ts.map +1 -1
- package/dist/svgJSX.d.ts.map +1 -1
- package/dist/tableBoard-B0I9wVQq.js +635 -0
- package/dist/tableBoard-B0I9wVQq.js.map +1 -0
- package/dist/tableBoard-CLDBwRYs.cjs +2 -0
- package/dist/tableBoard-CLDBwRYs.cjs.map +1 -0
- package/dist/tableBoard.cjs +1 -0
- package/dist/tableBoard.d.ts +138 -0
- package/dist/tableBoard.d.ts.map +1 -0
- package/dist/tableBoard.js +2 -0
- package/dist/tableBoardScene.d.ts +21 -0
- package/dist/tableBoardScene.d.ts.map +1 -0
- package/dist/themes.d.ts +16 -16
- package/dist/themes.d.ts.map +1 -1
- package/dist/types.d.ts +161 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.cjs +9 -5
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +20 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +249 -72
- package/dist/vite.js.map +1 -1
- package/package.json +5 -5
- package/dist/createSimulator-2M7vXzRZ.js.map +0 -1
- package/dist/createSimulator-B4QlohUV.cjs +0 -1930
- package/dist/createSimulator-B4QlohUV.cjs.map +0 -1
- package/dist/fonts.cjs.map +0 -1
- package/dist/fonts.js.map +0 -1
- package/dist/thumbnailMotion.cjs +0 -5
- package/dist/thumbnailMotion.cjs.map +0 -1
- package/dist/thumbnailMotion.d.ts +0 -119
- package/dist/thumbnailMotion.d.ts.map +0 -1
- package/dist/thumbnailMotion.js +0 -480
- package/dist/thumbnailMotion.js.map +0 -1
- package/dist/thumbnailMotion.spec.d.ts +0 -2
- package/dist/thumbnailMotion.spec.d.ts.map +0 -1
package/dist/vite.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export type GameInfo = {
|
|
|
54
54
|
displayName: string;
|
|
55
55
|
/** Vite-root-relative path to app bundle entry, if it exists */
|
|
56
56
|
appBundlePath: string | null;
|
|
57
|
+
/** Vite-root-relative path to the pmmg bundle entry, if it exists, for the simulator's Pmmg tab */
|
|
58
|
+
pmmgBundlePath?: string | null;
|
|
57
59
|
/** `integrations` from the puzzmo.json, passed to simulator tabs that preview them */
|
|
58
60
|
integrations?: SimulatorIntegrations;
|
|
59
61
|
};
|
|
@@ -113,6 +115,24 @@ export type ServerBundlePluginOptions = {
|
|
|
113
115
|
* `output.serverBundle`, since uploads refuse to send one file for more than one game.
|
|
114
116
|
*/
|
|
115
117
|
export declare const serverBundlePlugin: (options?: Partial<BundlePluginOptions>) => Plugin;
|
|
118
|
+
export type PmmgBundlePluginOptions = {
|
|
119
|
+
/** Entry file for the pmmg bundle (default: `src/pmmgBundle.js`, or `.ts`) */
|
|
120
|
+
entry?: string;
|
|
121
|
+
/** Output file name (default: `pmmg-bundle.js`) */
|
|
122
|
+
outputFile?: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Vite plugins for the game's pmmg bundle (see `PmmgBundle`), such as its boards at the table. After the main build
|
|
126
|
+
* they produce dist/pmmg-bundle.js, which is public and served with the rest of `dist`. In dev, `/pmmg-bundle.js` on
|
|
127
|
+
* the game's dev server is built from source on each request, so a Puzzmo page running with `?dev` draws boards from
|
|
128
|
+
* the code being worked on.
|
|
129
|
+
*
|
|
130
|
+
* Puzzmo imports it from an opaque-origin sandbox, so that one response answers any origin. It's a whole build rather
|
|
131
|
+
* than the dev server's modules, since letting `Origin: null` read those would let any page read the game's source.
|
|
132
|
+
*/
|
|
133
|
+
export declare const pmmgBundlePlugin: (options?: PmmgBundlePluginOptions) => Plugin[];
|
|
134
|
+
/** The pmmg bundle built as production builds it, as one file's source for the dev route */
|
|
135
|
+
export declare const buildPmmgBundleSource: (entry: string) => Promise<string>;
|
|
116
136
|
export type EditorBundlePluginOptions = {
|
|
117
137
|
/** Entry file for the editor bundle (default: `src/editorBundle.js`) */
|
|
118
138
|
entry?: string;
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sources":["../src/vite.ts"],"names":[],"mappings":"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"}
|
package/dist/vite.js
CHANGED
|
@@ -1,13 +1,126 @@
|
|
|
1
1
|
import { t as e } from "./objectWithoutProperties-54Cbyogk.js";
|
|
2
2
|
import { t } from "./objectSpread2-BJrS9rM5.js";
|
|
3
3
|
import { t as n } from "./asyncToGenerator-DSd3oTwb.js";
|
|
4
|
-
import { t as r } from "./lua-
|
|
4
|
+
import { t as r } from "./lua-B8exrfmB.js";
|
|
5
5
|
import { build as i } from "vite";
|
|
6
6
|
import a from "path";
|
|
7
7
|
import o from "fs";
|
|
8
8
|
import { execFileSync as s } from "child_process";
|
|
9
|
+
var c = 1024;
|
|
10
|
+
/** The limits for a bundle Puzzmo loads into its own pages, where every byte is on a player's page load */
|
|
11
|
+
const l = (e) => ({
|
|
12
|
+
loadedOn: e,
|
|
13
|
+
warnBytes: 200 * c,
|
|
14
|
+
maxBytes: 500 * c,
|
|
15
|
+
bannedPackages: [
|
|
16
|
+
"react",
|
|
17
|
+
"react-dom",
|
|
18
|
+
"scheduler",
|
|
19
|
+
"redux",
|
|
20
|
+
"react-redux",
|
|
21
|
+
"@reduxjs/toolkit"
|
|
22
|
+
]
|
|
23
|
+
}), u = (e, t) => {
|
|
24
|
+
var n;
|
|
25
|
+
let r = [], i = [], a = g(e), o = Buffer.byteLength(e.code), s = t.maxBytes !== void 0 && o > t.maxBytes, c = t.warnBytes !== void 0 && o > t.warnBytes;
|
|
26
|
+
if (s || c) {
|
|
27
|
+
let n = s ? t.maxBytes : t.warnBytes, c = t.loadedOn ? ` for a bundle loaded on ${t.loadedOn}` : "", l = Object.entries(e.modules).sort(([, e], [, t]) => t.size - e.size).slice(0, 5).map(([e, { size: t }]) => ` ${v(t).padStart(7)} ${a.module(e)}\n ${a.chain(e)}`), u = `${e.fileName} is ${v(o)}, over the ${v(n)} limit${c}. Its largest modules:\n${l.join("\n")}`;
|
|
28
|
+
(s ? r : i).push(u);
|
|
29
|
+
}
|
|
30
|
+
let l = new Set((n = t.bannedPackages) == null ? [] : n), u = /* @__PURE__ */ new Set();
|
|
31
|
+
for (let t of Object.keys(e.modules)) {
|
|
32
|
+
let n = _(t);
|
|
33
|
+
!n || !l.has(n) || u.has(n) || (u.add(n), r.push(`${n} can't be in ${e.fileName}, as Puzzmo calls it for strings and data. Imported by:\n ${a.chain(t)}`));
|
|
34
|
+
}
|
|
35
|
+
let d = p(e.code, e.modules);
|
|
36
|
+
if (d.length) {
|
|
37
|
+
let t = d.map(({ usage: e, count: t, moduleID: n }) => {
|
|
38
|
+
let r = t > 1 ? ` (x${t})` : "";
|
|
39
|
+
return n ? ` ${e}${r} in ${a.module(n)}\n ${a.chain(n)}` : ` ${e}${r}`;
|
|
40
|
+
});
|
|
41
|
+
i.push(`${e.fileName} uses Node globals, which don't exist where Puzzmo runs it, so each throws if reached:\n${t.join("\n")}`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
errors: r,
|
|
45
|
+
warnings: i
|
|
46
|
+
};
|
|
47
|
+
}, d = (e, t) => {
|
|
48
|
+
let n = process.cwd(), r = {};
|
|
49
|
+
return {
|
|
50
|
+
name: "puzzmo-bundle-checks",
|
|
51
|
+
api: r,
|
|
52
|
+
configResolved(e) {
|
|
53
|
+
n = e.root;
|
|
54
|
+
},
|
|
55
|
+
generateBundle(i, a) {
|
|
56
|
+
let o = Object.values(a).find((e) => e.type === "chunk" && e.isEntry);
|
|
57
|
+
if ((o == null ? void 0 : o.type) !== "chunk" || !o.facadeModuleId) return;
|
|
58
|
+
let s = Object.fromEntries(Object.entries(o.modules).map(([e, t]) => [e, {
|
|
59
|
+
size: t.renderedLength,
|
|
60
|
+
code: t.code
|
|
61
|
+
}])), c = h(o.facadeModuleId, (e) => this.getModuleInfo(e)), { errors: l, warnings: d } = u({
|
|
62
|
+
fileName: e,
|
|
63
|
+
code: o.code,
|
|
64
|
+
modules: s,
|
|
65
|
+
chains: c,
|
|
66
|
+
root: n
|
|
67
|
+
}, t);
|
|
68
|
+
for (let e of d) this.warn(e);
|
|
69
|
+
l.length && (r.failure = l.join("\n\n"), this.error(r.failure));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/** A Node-only global in use: `process.env.X`, `Buffer.from`, `require(`, never `obj.process.x` or `__require(` */
|
|
74
|
+
var f = /* @__PURE__ */ RegExp("(?<![\\w$.])(?:(?:process|global|Buffer)(?:\\.[\\w$]+){1,2}|require\\s*\\(|new\\s+Buffer\\s*\\(|__dirname\\b|__filename\\b)", "g"), p = (e, t) => {
|
|
75
|
+
let n = m(e), r = [];
|
|
76
|
+
for (let [e, i] of Object.entries(t)) if (i.code) for (let [t, a] of m(i.code)) n.has(t) && r.push({
|
|
77
|
+
usage: t,
|
|
78
|
+
count: a,
|
|
79
|
+
moduleID: e
|
|
80
|
+
});
|
|
81
|
+
let i = new Set(r.map(({ usage: e }) => e));
|
|
82
|
+
for (let [e, t] of n) i.has(e) || r.push({
|
|
83
|
+
usage: e,
|
|
84
|
+
count: t
|
|
85
|
+
});
|
|
86
|
+
return r;
|
|
87
|
+
}, m = (e) => {
|
|
88
|
+
let t = /* @__PURE__ */ new Map();
|
|
89
|
+
for (let r of e.matchAll(f)) {
|
|
90
|
+
var n;
|
|
91
|
+
let i = r[0].match(/process|global|Buffer|require|__dirname|__filename/)[0], a = e.slice(Math.max(0, r.index - 200), r.index);
|
|
92
|
+
if (/typeof\s+$/.test(a) || RegExp(`typeof\\s+${i}\\b`).test(a)) continue;
|
|
93
|
+
let o = r[0].replace(/\s*\($/, "(").replace(/\s+/g, " ");
|
|
94
|
+
t.set(o, ((n = t.get(o)) == null ? 0 : n) + 1);
|
|
95
|
+
}
|
|
96
|
+
return t;
|
|
97
|
+
}, h = (e, t) => {
|
|
98
|
+
let n = new Map([[e, [e]]]), r = [e];
|
|
99
|
+
for (let e = 0; e < r.length; e++) {
|
|
100
|
+
let i = t(r[e]);
|
|
101
|
+
if (i) for (let t of [...i.importedIds, ...i.dynamicallyImportedIds]) n.has(t) || (n.set(t, [...n.get(r[e]), t]), r.push(t));
|
|
102
|
+
}
|
|
103
|
+
return n;
|
|
104
|
+
}, g = ({ root: e, chains: t }) => {
|
|
105
|
+
let n = (t) => {
|
|
106
|
+
let n = t.replace(/^\0/, "").replace(/\?.*$/, ""), r = y(n.split("/node_modules/"));
|
|
107
|
+
return r === n ? a.isAbsolute(n) ? a.relative(e, n) : n : r;
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
module: n,
|
|
111
|
+
chain: (e) => {
|
|
112
|
+
var r;
|
|
113
|
+
return ((r = t.get(e)) == null ? [e] : r).map(n).join(" > ");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}, _ = (e) => {
|
|
117
|
+
let t = e.split("/node_modules/");
|
|
118
|
+
if (t.length < 2) return;
|
|
119
|
+
let n = y(t).split("/");
|
|
120
|
+
return n[0].startsWith("@") ? `${n[0]}/${n[1]}` : n[0];
|
|
121
|
+
}, v = (e) => `${Math.round(e / c)}KB`, y = (e) => e[e.length - 1];
|
|
9
122
|
/** @internal Finds the PICO-8 game served by the page in `dir`, if there is one. */
|
|
10
|
-
function
|
|
123
|
+
function b(e, t = {}) {
|
|
11
124
|
var n;
|
|
12
125
|
let r;
|
|
13
126
|
if (t.cart) r = a.resolve(e, t.cart);
|
|
@@ -31,7 +144,7 @@ function c(e, t = {}) {
|
|
|
31
144
|
* 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
145
|
* its runtime expects to find, and it changes between versions, so rather than keep a copy we adjust theirs.
|
|
33
146
|
*/
|
|
34
|
-
function
|
|
147
|
+
function x(e, t, n) {
|
|
35
148
|
let r = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = RegExp(`((?:\\.src\\s*=\\s*|\\ssrc=)["'])[^"']*${r}\\.js(["'])`);
|
|
36
149
|
if (!i.test(e)) throw Error(`[puzzmo-pico8] couldn't find where PICO-8's page loads ${t}.js`);
|
|
37
150
|
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, " ");
|
|
@@ -40,11 +153,11 @@ function l(e, t, n) {
|
|
|
40
153
|
return e.slice(0, a) + n.join("\n") + "\n" + e.slice(a);
|
|
41
154
|
}
|
|
42
155
|
/** Where PICO-8's own installers put it, for people who never added it to their PATH. */
|
|
43
|
-
var
|
|
156
|
+
var S = [
|
|
44
157
|
"/Applications/PICO-8.app/Contents/MacOS/pico8",
|
|
45
158
|
"C:\\Program Files (x86)\\PICO-8\\pico8.exe",
|
|
46
159
|
"C:\\Program Files\\PICO-8\\pico8.exe"
|
|
47
|
-
],
|
|
160
|
+
], C = (e) => {
|
|
48
161
|
var t, n;
|
|
49
162
|
if (e.includes("/") || e.includes("\\")) return o.existsSync(e) ? e : null;
|
|
50
163
|
for (let n of ((t = process.env.PATH) == null ? "" : t).split(a.delimiter)) for (let t of process.platform === "win32" ? [
|
|
@@ -55,8 +168,8 @@ var u = [
|
|
|
55
168
|
let r = a.join(n, e + t);
|
|
56
169
|
if (o.existsSync(r)) return r;
|
|
57
170
|
}
|
|
58
|
-
return e === "pico8" ? (n =
|
|
59
|
-
},
|
|
171
|
+
return e === "pico8" ? (n = S.find((e) => o.existsSync(e))) == null ? null : n : null;
|
|
172
|
+
}, w = (e) => o.existsSync(e) ? o.statSync(e).mtimeMs : 0;
|
|
60
173
|
/**
|
|
61
174
|
* Vite plugin for games written as PICO-8 carts. Your `index.html` only needs your own script tag, the plugin swaps
|
|
62
175
|
* in PICO-8's exported page around it, serves the PICO-8 runtime next to it, and copies it into the build.
|
|
@@ -64,16 +177,16 @@ var u = [
|
|
|
64
177
|
* When PICO-8 is installed it also re-exports the cart whenever it (or a `.lua` file next to it) changes, and reloads
|
|
65
178
|
* the page, so saving in PICO-8 is enough to see the change in the simulator.
|
|
66
179
|
*/
|
|
67
|
-
function
|
|
180
|
+
function T(e = {}) {
|
|
68
181
|
var t, n;
|
|
69
|
-
let i,
|
|
182
|
+
let i, c = /* @__PURE__ */ new Map(), l = e.pico8 === !1 ? null : (t = (n = e.pico8) == null ? process.env.PICO8 : n) == null ? "pico8" : t, u = (e) => i.logger.info(`\x1b[33m\x1b[1m PICO-8 \x1b[22m\x1b[39m${e}`), d = (t) => {
|
|
70
183
|
if (e.writeLua === !1) return;
|
|
71
184
|
let n = a.join(a.dirname(t.cart), "puzzmo.lua");
|
|
72
|
-
o.existsSync(n) && o.readFileSync(n, "utf8") === r || (o.writeFileSync(n, r),
|
|
73
|
-
},
|
|
74
|
-
let t = a.dirname(e.cart), n = Math.max(...o.readdirSync(t).filter((e) => /\.(p8|lua)$/.test(e)).map((e) =>
|
|
75
|
-
if (o.existsSync(e.exportJS) &&
|
|
76
|
-
let r =
|
|
185
|
+
o.existsSync(n) && o.readFileSync(n, "utf8") === r || (o.writeFileSync(n, r), u(`wrote ${a.relative(i.root, n)}`));
|
|
186
|
+
}, f = (e) => {
|
|
187
|
+
let t = a.dirname(e.cart), n = Math.max(...o.readdirSync(t).filter((e) => /\.(p8|lua)$/.test(e)).map((e) => w(a.join(t, e))));
|
|
188
|
+
if (o.existsSync(e.exportJS) && w(e.exportJS) >= n) return;
|
|
189
|
+
let r = l ? C(l) : null;
|
|
77
190
|
if (!r) {
|
|
78
191
|
if (o.existsSync(e.exportHTML)) {
|
|
79
192
|
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.`);
|
|
@@ -82,9 +195,9 @@ function p(e = {}) {
|
|
|
82
195
|
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
196
|
}
|
|
84
197
|
o.mkdirSync(a.dirname(e.exportHTML), { recursive: !0 });
|
|
85
|
-
let c =
|
|
198
|
+
let c = w(e.exportJS), d = "";
|
|
86
199
|
try {
|
|
87
|
-
|
|
200
|
+
d = s(r, [
|
|
88
201
|
e.cart,
|
|
89
202
|
"-export",
|
|
90
203
|
e.exportHTML
|
|
@@ -98,22 +211,22 @@ function p(e = {}) {
|
|
|
98
211
|
]
|
|
99
212
|
});
|
|
100
213
|
} catch (e) {
|
|
101
|
-
var
|
|
102
|
-
|
|
214
|
+
var f;
|
|
215
|
+
d = String((f = e.stdout) == null ? e : f);
|
|
103
216
|
}
|
|
104
|
-
if (
|
|
105
|
-
let t = /label/i.test(
|
|
106
|
-
throw Error(`[puzzmo-pico8] PICO-8 didn't export ${a.relative(i.root, e.cart)}:\n${
|
|
217
|
+
if (w(e.exportJS) === c) {
|
|
218
|
+
let t = /label/i.test(d) ? "\nHTML exports need a label: run the cart in PICO-8, press CTRL-7, and save." : "";
|
|
219
|
+
throw Error(`[puzzmo-pico8] PICO-8 didn't export ${a.relative(i.root, e.cart)}:\n${d.trim()}${t}`);
|
|
107
220
|
}
|
|
108
|
-
|
|
109
|
-
},
|
|
221
|
+
u(`exported ${a.relative(i.root, e.cart)}`);
|
|
222
|
+
}, p = (t) => {
|
|
110
223
|
let n = a.dirname(t);
|
|
111
|
-
if (!
|
|
112
|
-
let t =
|
|
224
|
+
if (!c.has(n)) {
|
|
225
|
+
let t = b(n, e);
|
|
113
226
|
if (!t) return null;
|
|
114
|
-
|
|
227
|
+
c.set(n, t);
|
|
115
228
|
}
|
|
116
|
-
return
|
|
229
|
+
return c.get(n);
|
|
117
230
|
};
|
|
118
231
|
return {
|
|
119
232
|
name: "puzzmo-pico8",
|
|
@@ -129,11 +242,11 @@ function p(e = {}) {
|
|
|
129
242
|
order: "pre",
|
|
130
243
|
handler(e, t) {
|
|
131
244
|
var n;
|
|
132
|
-
let r =
|
|
245
|
+
let r = p(t.filename);
|
|
133
246
|
if (!r) return;
|
|
134
|
-
|
|
247
|
+
d(r), f(r);
|
|
135
248
|
let i = (n = e.match(/<script\b[^>]*type=["']module["'][^>]*>[\s\S]*?<\/script>/gi)) == null ? [] : n;
|
|
136
|
-
return
|
|
249
|
+
return x(o.readFileSync(r.exportHTML, "utf8"), r.name, i);
|
|
137
250
|
}
|
|
138
251
|
},
|
|
139
252
|
configureServer(e) {
|
|
@@ -141,13 +254,13 @@ function p(e = {}) {
|
|
|
141
254
|
var r;
|
|
142
255
|
let s = decodeURIComponent(((r = e.url) == null ? "" : r).split("?")[0]);
|
|
143
256
|
if (!s.endsWith(".js")) return n();
|
|
144
|
-
let
|
|
145
|
-
if (!
|
|
146
|
-
t.setHeader("Content-Type", "text/javascript"), t.end(o.readFileSync(
|
|
257
|
+
let l = [...c.values()].find((e) => s === "/" + a.relative(i.root, a.join(e.dir, `${e.name}.js`)).split(a.sep).join("/"));
|
|
258
|
+
if (!l || !o.existsSync(l.exportJS)) return n();
|
|
259
|
+
t.setHeader("Content-Type", "text/javascript"), t.end(o.readFileSync(l.exportJS));
|
|
147
260
|
}), e.watcher.on("change", (t) => {
|
|
148
|
-
let n = [...
|
|
261
|
+
let n = [...c.values()].find((e) => a.dirname(t) === a.dirname(e.cart) && /\.(p8|lua)$/.test(t));
|
|
149
262
|
if (!(!n || a.basename(t) === "puzzmo.lua")) try {
|
|
150
|
-
|
|
263
|
+
f(n), e.ws.send({ type: "full-reload" });
|
|
151
264
|
} catch (t) {
|
|
152
265
|
let n = t instanceof Error ? t.message : String(t);
|
|
153
266
|
i.logger.error(n), e.ws.send({
|
|
@@ -161,7 +274,7 @@ function p(e = {}) {
|
|
|
161
274
|
});
|
|
162
275
|
},
|
|
163
276
|
generateBundle() {
|
|
164
|
-
for (let e of
|
|
277
|
+
for (let e of c.values()) {
|
|
165
278
|
let t = a.relative(i.root, a.join(e.dir, `${e.name}.js`)).split(a.sep).join("/");
|
|
166
279
|
this.emitFile({
|
|
167
280
|
type: "asset",
|
|
@@ -172,28 +285,27 @@ function p(e = {}) {
|
|
|
172
285
|
}
|
|
173
286
|
};
|
|
174
287
|
}
|
|
175
|
-
var
|
|
288
|
+
var E = ["fixturesGlob", "viewFactories"], D = "/@puzzmo-simulator-init.js", O = "virtual:puzzmo-simulator";
|
|
176
289
|
/**
|
|
177
290
|
* Discover all games from puzzmo.json files under a root directory.
|
|
178
291
|
*
|
|
179
292
|
* @internal
|
|
180
293
|
*/
|
|
181
|
-
function
|
|
182
|
-
let t = /* @__PURE__ */ new Map(), n =
|
|
294
|
+
function k(e) {
|
|
295
|
+
let t = /* @__PURE__ */ new Map(), n = U(e, 3);
|
|
183
296
|
o.existsSync(a.join(e, "puzzmo.json")) && n.unshift(e);
|
|
184
297
|
for (let i of n) try {
|
|
185
298
|
var r;
|
|
186
299
|
let n = JSON.parse(o.readFileSync(a.join(i, "puzzmo.json"), "utf-8"));
|
|
187
300
|
if (!(!(n == null || (r = n.game) == null) && r.slug)) continue;
|
|
188
|
-
let s =
|
|
189
|
-
s && (c = "/" + a.relative(e, s).split(a.sep).join("/"));
|
|
190
|
-
let l = n.integrations && typeof n.integrations == "object" ? n.integrations : void 0;
|
|
301
|
+
let s = n.integrations && typeof n.integrations == "object" ? n.integrations : void 0;
|
|
191
302
|
t.set(n.game.slug, {
|
|
192
303
|
dir: i,
|
|
193
304
|
slug: n.game.slug,
|
|
194
305
|
displayName: n.game.displayName,
|
|
195
|
-
appBundlePath:
|
|
196
|
-
|
|
306
|
+
appBundlePath: F(e, I(i, "src/appBundle")),
|
|
307
|
+
pmmgBundlePath: F(e, I(i, "src/pmmgBundle")),
|
|
308
|
+
integrations: s
|
|
197
309
|
});
|
|
198
310
|
} catch (e) {}
|
|
199
311
|
return t;
|
|
@@ -203,7 +315,7 @@ function _(e) {
|
|
|
203
315
|
*
|
|
204
316
|
* @internal
|
|
205
317
|
*/
|
|
206
|
-
function
|
|
318
|
+
function A(e, t, n) {
|
|
207
319
|
if (e) try {
|
|
208
320
|
let r = new URL(e).pathname;
|
|
209
321
|
for (let e of t.values()) {
|
|
@@ -218,42 +330,42 @@ function v(e, t, n) {
|
|
|
218
330
|
*
|
|
219
331
|
* @internal
|
|
220
332
|
*/
|
|
221
|
-
function
|
|
222
|
-
let { fixturesGlob: i, viewFactories: a } = n, o = e(n,
|
|
333
|
+
function j(n, r) {
|
|
334
|
+
let { fixturesGlob: i, viewFactories: a } = n, o = e(n, E), s = i === !1 ? null : i == null ? "/fixtures/puzzles/**/*.{json,toml}" : i, c = ["import { createSimulator } from \"@puzzmo/sdk/simulator\""];
|
|
223
335
|
for (let e of a == null ? [] : a) c.push(`import { ${e.export} } from ${JSON.stringify(e.module)}`);
|
|
224
336
|
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(() => {})"));
|
|
225
337
|
let l = t(t(t({}, o), r != null && r.slug ? { slug: r.slug } : {}), r != null && r.integrations ? { integrations: r.integrations } : {}), u = Object.entries(l).filter(([, e]) => e !== void 0).map(([e, t]) => `${e}: ${JSON.stringify(t)}`);
|
|
226
|
-
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");
|
|
338
|
+
return s && u.push("fixtures"), r != null && r.pmmgBundlePath && u.push(`pmmgBundle: () => import(${JSON.stringify(r.pmmgBundlePath)})`), a != null && a.length && u.push(`views: [${a.map((e) => `${e.export}()`).join(", ")}]`), c.push(`createSimulator({ ${u.join(", ")} })`), c.join("\n");
|
|
227
339
|
}
|
|
228
340
|
/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */
|
|
229
|
-
function
|
|
341
|
+
function M(e = {}) {
|
|
230
342
|
let t = /* @__PURE__ */ new Map(), r;
|
|
231
343
|
return {
|
|
232
344
|
name: "puzzmo-simulator",
|
|
233
345
|
apply: "serve",
|
|
234
346
|
configResolved(e) {
|
|
235
|
-
if (r = e.root, t =
|
|
347
|
+
if (r = e.root, t = k(r), t.size === 0) e.logger.info("\x1B[33m\x1B[1m PUZZMO \x1B[22m\x1B[39m\x1B[2m no puzzmo.json files found\x1B[22m");
|
|
236
348
|
else {
|
|
237
349
|
let n = [...t.values()].map((e) => `\x1b[36m${e.slug}\x1b[39m`), r = t.size === 1 ? "game" : "games";
|
|
238
350
|
e.logger.info(`\x1b[33m\x1b[1m PUZZMO \x1b[22m\x1b[39m found ${t.size} ${r}: ${n.join("\x1B[2m, \x1B[22m")}`);
|
|
239
351
|
}
|
|
240
352
|
},
|
|
241
353
|
resolveId(e) {
|
|
242
|
-
if (e ===
|
|
354
|
+
if (e === O || e.startsWith(O + "?")) return "\0" + e;
|
|
243
355
|
},
|
|
244
356
|
load(n) {
|
|
245
|
-
if (!n.startsWith("\0" +
|
|
357
|
+
if (!n.startsWith("\0" + O)) return;
|
|
246
358
|
let r = new URLSearchParams(n.split("?")[1] || "").get("game");
|
|
247
|
-
return
|
|
359
|
+
return j(e, r ? t.get(r) : t.size === 1 ? t.values().next().value : void 0);
|
|
248
360
|
},
|
|
249
361
|
configureServer(e) {
|
|
250
362
|
for (let n of t.values()) e.watcher.add(a.join(n.dir, "puzzmo.json"));
|
|
251
363
|
e.watcher.on("change", (n) => {
|
|
252
364
|
if (a.basename(n) === "puzzmo.json") {
|
|
253
|
-
t =
|
|
365
|
+
t = k(r);
|
|
254
366
|
for (let t of e.moduleGraph.idToModuleMap.values()) {
|
|
255
367
|
var i;
|
|
256
|
-
(i = t.id) != null && i.startsWith("\0" +
|
|
368
|
+
(i = t.id) != null && i.startsWith("\0" + O) && e.moduleGraph.invalidateModule(t);
|
|
257
369
|
}
|
|
258
370
|
e.ws.send({ type: "full-reload" });
|
|
259
371
|
}
|
|
@@ -262,8 +374,8 @@ function b(e = {}) {
|
|
|
262
374
|
}), e.middlewares.use(function() {
|
|
263
375
|
var i = n(function* (n, i, a) {
|
|
264
376
|
var o;
|
|
265
|
-
if (((o = n.url) == null ? void 0 : o.split("?")[0]) !==
|
|
266
|
-
let s =
|
|
377
|
+
if (((o = n.url) == null ? void 0 : o.split("?")[0]) !== D) return a();
|
|
378
|
+
let s = A(n.headers.referer, t, r), c = O + (s ? `?game=${s.slug}` : ""), l = yield e.transformRequest(c);
|
|
267
379
|
if (!l) return a();
|
|
268
380
|
i.setHeader("Content-Type", "application/javascript"), i.end(l.code);
|
|
269
381
|
});
|
|
@@ -277,39 +389,41 @@ function b(e = {}) {
|
|
|
277
389
|
tag: "script",
|
|
278
390
|
attrs: {
|
|
279
391
|
type: "module",
|
|
280
|
-
src:
|
|
392
|
+
src: D
|
|
281
393
|
},
|
|
282
394
|
injectTo: "head"
|
|
283
395
|
}];
|
|
284
396
|
}
|
|
285
397
|
};
|
|
286
398
|
}
|
|
287
|
-
function
|
|
288
|
-
return (
|
|
289
|
-
let { entry:
|
|
399
|
+
function N(e, r, o = {}) {
|
|
400
|
+
return (s = {}) => {
|
|
401
|
+
let { entry: c, outputFile: l, outDir: u } = t(t({}, r), s), f = a.relative(process.cwd(), a.resolve(u, l));
|
|
290
402
|
return {
|
|
291
403
|
name: e,
|
|
292
404
|
apply: "build",
|
|
293
405
|
closeBundle() {
|
|
294
406
|
return n(function* () {
|
|
295
407
|
var t;
|
|
296
|
-
let n =
|
|
408
|
+
let n = s.entry ? a.isAbsolute(c) ? c : a.resolve(process.cwd(), c) : (t = I(process.cwd(), P(c))) == null ? a.resolve(process.cwd(), c) : t, r = d(f, o);
|
|
297
409
|
try {
|
|
298
410
|
yield i({
|
|
299
411
|
configFile: !1,
|
|
300
412
|
logLevel: "warn",
|
|
413
|
+
define: W,
|
|
414
|
+
plugins: [r],
|
|
301
415
|
build: {
|
|
302
416
|
lib: {
|
|
303
417
|
entry: n,
|
|
304
418
|
formats: ["es"],
|
|
305
|
-
fileName: () =>
|
|
419
|
+
fileName: () => l
|
|
306
420
|
},
|
|
307
|
-
outDir:
|
|
421
|
+
outDir: u,
|
|
308
422
|
emptyOutDir: !1
|
|
309
423
|
}
|
|
310
424
|
});
|
|
311
425
|
} catch (t) {
|
|
312
|
-
throw console.error(`[${e}] build failed:`, t), t;
|
|
426
|
+
throw r.api.failure ? G(`[${e}] ${r.api.failure}`) : (console.error(`[${e}] build failed:`, t), t);
|
|
313
427
|
}
|
|
314
428
|
})();
|
|
315
429
|
}
|
|
@@ -317,7 +431,7 @@ function x(e, r) {
|
|
|
317
431
|
};
|
|
318
432
|
}
|
|
319
433
|
/** Strip the trailing extension from a default entry path so we can probe siblings. */
|
|
320
|
-
var
|
|
434
|
+
var P = (e) => e.replace(/\.[jt]sx?$/i, ""), F = (e, t) => t ? "/" + a.relative(e, t).split(a.sep).join("/") : null, I = (e, t) => {
|
|
321
435
|
for (let n of [
|
|
322
436
|
".js",
|
|
323
437
|
".ts",
|
|
@@ -336,19 +450,77 @@ var S = (e) => e.replace(/\.[jt]sx?$/i, ""), C = (e, t) => {
|
|
|
336
450
|
* returning the SVG and its dimensions (`{ svg, width, height }`), used by the Puzzmo
|
|
337
451
|
* platform for puzzle previews.
|
|
338
452
|
*/
|
|
339
|
-
const
|
|
453
|
+
const L = N("app-bundle", {
|
|
340
454
|
entry: "src/appBundle.js",
|
|
341
455
|
outputFile: "app-bundle.js",
|
|
342
456
|
outDir: "dist"
|
|
343
|
-
}),
|
|
457
|
+
}, l("Puzzmo's pages wherever the game's thumbnails show")), R = N("server-bundle", {
|
|
344
458
|
entry: "src/serverBundle.js",
|
|
345
459
|
outputFile: "server-bundle.js",
|
|
346
460
|
outDir: "dist-server"
|
|
347
|
-
})
|
|
461
|
+
});
|
|
462
|
+
var z = N("pmmg-bundle", {
|
|
463
|
+
entry: "src/pmmgBundle.js",
|
|
464
|
+
outputFile: "pmmg-bundle.js",
|
|
465
|
+
outDir: "dist"
|
|
466
|
+
}, l("Puzzmo's pages for every board at the table"));
|
|
467
|
+
/**
|
|
468
|
+
* Vite plugins for the game's pmmg bundle (see `PmmgBundle`), such as its boards at the table. After the main build
|
|
469
|
+
* they produce dist/pmmg-bundle.js, which is public and served with the rest of `dist`. In dev, `/pmmg-bundle.js` on
|
|
470
|
+
* the game's dev server is built from source on each request, so a Puzzmo page running with `?dev` draws boards from
|
|
471
|
+
* the code being worked on.
|
|
472
|
+
*
|
|
473
|
+
* Puzzmo imports it from an opaque-origin sandbox, so that one response answers any origin. It's a whole build rather
|
|
474
|
+
* than the dev server's modules, since letting `Origin: null` read those would let any page read the game's source.
|
|
475
|
+
*/
|
|
476
|
+
const B = (e = {}) => [z(e), {
|
|
477
|
+
name: "pmmg-bundle-dev",
|
|
478
|
+
apply: "serve",
|
|
479
|
+
configureServer(t) {
|
|
480
|
+
let n;
|
|
481
|
+
t.middlewares.use((r, i, o) => {
|
|
482
|
+
var s;
|
|
483
|
+
if (!/^\/pmmg-bundle\.js(?:\?.*)?$/.test(r.url || "")) return o();
|
|
484
|
+
let c = (s = e.entry) == null ? I(t.config.root, "src/pmmgBundle") : s;
|
|
485
|
+
if (!c) return o();
|
|
486
|
+
n != null || (n = V(a.resolve(t.config.root, c)).finally(() => n = void 0)), n.then((e) => {
|
|
487
|
+
i.setHeader("Content-Type", "text/javascript"), i.setHeader("Access-Control-Allow-Origin", "*"), i.setHeader("Cache-Control", "no-store"), i.end(e);
|
|
488
|
+
}, (e) => {
|
|
489
|
+
var n;
|
|
490
|
+
t.config.logger.error(`[pmmg-bundle] build failed: ${(n = e == null ? void 0 : e.message) == null ? e : n}`), i.statusCode = 500, i.end();
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}], V = function() {
|
|
495
|
+
var e = n(function* (e) {
|
|
496
|
+
let t = yield i({
|
|
497
|
+
configFile: !1,
|
|
498
|
+
logLevel: "warn",
|
|
499
|
+
define: W,
|
|
500
|
+
build: {
|
|
501
|
+
write: !1,
|
|
502
|
+
copyPublicDir: !1,
|
|
503
|
+
minify: !1,
|
|
504
|
+
sourcemap: "inline",
|
|
505
|
+
lib: {
|
|
506
|
+
entry: e,
|
|
507
|
+
formats: ["es"],
|
|
508
|
+
fileName: () => "pmmg-bundle.js"
|
|
509
|
+
},
|
|
510
|
+
rolldownOptions: { output: { codeSplitting: !1 } }
|
|
511
|
+
}
|
|
512
|
+
}), n = (Array.isArray(t) ? t : "output" in t ? [t] : []).flatMap((e) => e.output).find((e) => e.type === "chunk" && e.isEntry);
|
|
513
|
+
if (!n || n.type !== "chunk") throw Error(`Building ${e} made no bundle`);
|
|
514
|
+
return n.code;
|
|
515
|
+
});
|
|
516
|
+
return function(t) {
|
|
517
|
+
return e.apply(this, arguments);
|
|
518
|
+
};
|
|
519
|
+
}(), H = N("editor-bundle", {
|
|
348
520
|
entry: "src/editorBundle.js",
|
|
349
521
|
outputFile: "editor-bundle.js",
|
|
350
522
|
outDir: "dist"
|
|
351
|
-
}),
|
|
523
|
+
}), U = (e, t, n = 0) => {
|
|
352
524
|
if (n >= t) return [];
|
|
353
525
|
let r = [], i;
|
|
354
526
|
try {
|
|
@@ -359,10 +531,15 @@ const w = x("app-bundle", {
|
|
|
359
531
|
for (let s of i) {
|
|
360
532
|
if (!s.isDirectory() || s.name.startsWith(".") || s.name === "node_modules") continue;
|
|
361
533
|
let i = a.join(e, s.name);
|
|
362
|
-
o.existsSync(a.join(i, "puzzmo.json")) && r.push(i), r.push(...
|
|
534
|
+
o.existsSync(a.join(i, "puzzmo.json")) && r.push(i), r.push(...U(i, t, n + 1));
|
|
363
535
|
}
|
|
364
536
|
return r;
|
|
365
537
|
};
|
|
366
|
-
|
|
538
|
+
/**
|
|
539
|
+
* Lib mode leaves `process.env.*` for a consumer's bundler to replace, but these bundles are run as-is in browsers and
|
|
540
|
+
* isolates with no `process`, so a dependency's `NODE_ENV` check (immer, reselect, React) would throw on load
|
|
541
|
+
*/
|
|
542
|
+
var W = { "process.env.NODE_ENV": JSON.stringify("production") }, G = (e) => Object.assign(Error(e), { stack: e });
|
|
543
|
+
export { L as appBundlePlugin, V as buildPmmgBundleSource, k as discoverGames, H as editorBundlePlugin, U as findPuzzmoJsonDirs, j as generateSimulatorCode, B as pmmgBundlePlugin, T as puzzmoPico8, M as puzzmoSimulator, A as resolveGameFromReferer, R as serverBundlePlugin };
|
|
367
544
|
|
|
368
545
|
//# sourceMappingURL=vite.js.map
|