@playcademy/sandbox 0.1.0 → 0.1.2
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/README.md +128 -1
- package/dist/cli.js +20472 -12106
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.js +150 -0
- package/dist/config/mutators.d.ts +4 -0
- package/dist/config/timeback.d.ts +10 -0
- package/dist/config/types.d.ts +23 -0
- package/dist/constants.d.ts +13 -0
- package/dist/lib/auth.d.ts +7 -2
- package/dist/server.d.ts +1 -1
- package/dist/server.js +20309 -12035
- package/dist/types.d.ts +3 -0
- package/package.json +7 -1
- package/dist/utils/port.d.ts +0 -18
- package/dist/utils/port.js +0 -54
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { User } from '@playcademy/data/types';
|
|
2
|
+
import type { TimebackConfig } from './config';
|
|
2
3
|
import type { setupDatabase } from './database';
|
|
3
4
|
export type HonoEnv = {
|
|
4
5
|
Variables: {
|
|
@@ -19,8 +20,10 @@ export interface ServerOptions {
|
|
|
19
20
|
quiet?: boolean;
|
|
20
21
|
seed?: boolean;
|
|
21
22
|
memoryOnly?: boolean;
|
|
23
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
22
24
|
realtime?: {
|
|
23
25
|
enabled?: boolean;
|
|
24
26
|
port?: number;
|
|
25
27
|
};
|
|
28
|
+
timeback?: Partial<TimebackConfig>;
|
|
26
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/sandbox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Local development server for Playcademy game development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"./ports": {
|
|
16
16
|
"import": "./dist/utils/port.js",
|
|
17
17
|
"types": "./dist/utils/port.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./config": {
|
|
20
|
+
"import": "./dist/config/index.js",
|
|
21
|
+
"types": "./dist/config/index.d.ts"
|
|
18
22
|
}
|
|
19
23
|
},
|
|
20
24
|
"bin": {
|
|
@@ -33,6 +37,7 @@
|
|
|
33
37
|
"dependencies": {
|
|
34
38
|
"@electric-sql/pglite": "^0.3.2",
|
|
35
39
|
"@hono/node-server": "^1.14.2",
|
|
40
|
+
"@playcademy/constants": "0.0.1",
|
|
36
41
|
"commander": "^12.1.0",
|
|
37
42
|
"drizzle-kit": "^0.31.0",
|
|
38
43
|
"drizzle-orm": "^0.42.0",
|
|
@@ -43,6 +48,7 @@
|
|
|
43
48
|
"devDependencies": {
|
|
44
49
|
"@inquirer/prompts": "^7.8.6",
|
|
45
50
|
"@playcademy/api-core": "0.1.0",
|
|
51
|
+
"@playcademy/constants": "0.0.1",
|
|
46
52
|
"@playcademy/data": "0.0.1",
|
|
47
53
|
"@playcademy/realtime": "0.1.0",
|
|
48
54
|
"@playcademy/timeback": "0.0.1",
|
package/dist/utils/port.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare function findAvailablePort(startPort?: number): Promise<number>;
|
|
2
|
-
/**
|
|
3
|
-
* Allocate a pair of ports for the sandbox: one for the main HTTP API server
|
|
4
|
-
* and one for the realtime WebSocket server.
|
|
5
|
-
*
|
|
6
|
-
* • We first look for an available port starting from `preferred` (defaults to
|
|
7
|
-
* 4321). That becomes the API port.
|
|
8
|
-
* • We then look for the next available port **after** the chosen API port for
|
|
9
|
-
* the realtime server. This guarantees the two ports are distinct and
|
|
10
|
-
* stable for the lifetime of the sandbox.
|
|
11
|
-
*
|
|
12
|
-
* The helper centralises the port-allocation logic so that the sandbox CLI,
|
|
13
|
-
* integration-test harness and Vite plugin all follow the exact same rules.
|
|
14
|
-
*/
|
|
15
|
-
export declare function allocateSandboxPorts(preferred?: number): Promise<{
|
|
16
|
-
apiPort: number;
|
|
17
|
-
realtimePort: number;
|
|
18
|
-
}>;
|
package/dist/utils/port.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
-
var __export = (target, all) => {
|
|
20
|
-
for (var name in all)
|
|
21
|
-
__defProp(target, name, {
|
|
22
|
-
get: all[name],
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
set: (newValue) => all[name] = () => newValue
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
-
|
|
31
|
-
// src/utils/port.ts
|
|
32
|
-
import { createServer } from "node:net";
|
|
33
|
-
async function findAvailablePort(startPort = 4321) {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
const server = createServer();
|
|
36
|
-
server.listen(startPort, () => {
|
|
37
|
-
const address = server.address();
|
|
38
|
-
const port = address && typeof address === "object" ? address.port : startPort;
|
|
39
|
-
server.close(() => resolve(port));
|
|
40
|
-
});
|
|
41
|
-
server.on("error", () => {
|
|
42
|
-
findAvailablePort(startPort + 1).then(resolve).catch(reject);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
async function allocateSandboxPorts(preferred = 4321) {
|
|
47
|
-
const apiPort = await findAvailablePort(preferred);
|
|
48
|
-
const realtimePort = await findAvailablePort(apiPort + 1);
|
|
49
|
-
return { apiPort, realtimePort };
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
findAvailablePort,
|
|
53
|
-
allocateSandboxPorts
|
|
54
|
-
};
|