@n3rdw1z4rd/core 0.24.0 → 0.26.0
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 +45 -0
- package/dist/astar.js +3 -3
- package/dist/desktop.d.ts +37 -0
- package/dist/desktop.js +14 -0
- package/dist/dungeon-generator.js +4 -4
- package/dist/electron/after-pack.cjs +17 -0
- package/dist/electron/index.d.ts +110 -0
- package/dist/electron/index.js +257 -0
- package/dist/electron/preload.cjs +12 -0
- package/dist/electron/updater.d.ts +81 -0
- package/dist/electron/updater.js +133 -0
- package/dist/electron.cjs +416 -0
- package/dist/electron.d.cts +189 -0
- package/dist/graph/index.d.ts +21 -0
- package/dist/graph/subgraph.js +1 -1
- package/dist/graph.cjs +2 -2
- package/dist/graph.d.cts +21 -0
- package/dist/index.cjs +25 -11
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +2 -1
- package/dist/map2d.js +2 -2
- package/dist/math.js +2 -2
- package/dist/{rng-edL6atS3.cjs → rng-BtvhTJmM.cjs} +2 -2
- package/dist/{spatial-partition-3d-D1uyJVhM.cjs → spatial-partition-3d-qhjqIpcy.cjs} +1 -1
- package/dist/three/adaptive-grid.d.ts +1 -1
- package/dist/three/adaptive-grid.js +1 -1
- package/dist/three/asteroid-mesh.d.ts +1 -1
- package/dist/three/camera-rig.js +1 -1
- package/dist/three/cube-sphere-geometry.d.ts +1 -1
- package/dist/three/index.d.ts +13 -2
- package/dist/three/particle-system-3d.js +1 -1
- package/dist/three/picking.d.ts +1 -1
- package/dist/three/picking.js +1 -1
- package/dist/three/starfield.js +4 -4
- package/dist/three/texture-atlas.d.ts +1 -1
- package/dist/three/texture-atlas.js +1 -1
- package/dist/three/texture-utils.js +2 -4
- package/dist/three/voxel-geometry.d.ts +44 -10
- package/dist/three/voxel-geometry.js +282 -77
- package/dist/three/voxel-mesh.d.ts +1 -1
- package/dist/three/voxel-mesh.js +1 -1
- package/dist/three/world.d.ts +1 -1
- package/dist/three/world.js +1 -1
- package/dist/three.cjs +290 -87
- package/dist/three.d.cts +55 -10
- package/dist/vite.cjs +124 -0
- package/dist/vite.d.cts +53 -2
- package/dist/vite.d.ts +53 -2
- package/dist/vite.js +122 -1
- package/dist/webgl.js +2 -2
- package/package.json +23 -3
- package/dist/input/_input.d.ts +0 -23
- package/dist/input/_input.js +0 -96
package/dist/vite.cjs
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let node_child_process = require("node:child_process");
|
|
3
|
+
let node_crypto = require("node:crypto");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let node_path = require("node:path");
|
|
2
6
|
// src/vite.ts
|
|
7
|
+
/**
|
|
8
|
+
* Vite plugins: `decorators()` lowers standard (TC39) decorators such as `@field` / `@component`
|
|
9
|
+
* with esbuild; `buildManifest()` writes the `version.json` the desktop app
|
|
10
|
+
* (`@n3rdw1z4rd/core/electron`) updates itself from.
|
|
11
|
+
*
|
|
12
|
+
* Vite 8 compiles TypeScript with Oxc, which only lowers legacy `experimentalDecorators` and
|
|
13
|
+
* passes standard decorators through untouched — no browser can run that yet. This runs
|
|
14
|
+
* first on any source file that uses a decorator; Oxc then sees plain TS/JS.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* // vite.config.ts
|
|
18
|
+
* import { decorators } from '@n3rdw1z4rd/core/vite';
|
|
19
|
+
* export default defineConfig({ plugins: [decorators()] });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Requires `esbuild` to be installed alongside Vite. Node-only: not exported from the
|
|
23
|
+
* package root.
|
|
24
|
+
*
|
|
25
|
+
* @packageDocumentation
|
|
26
|
+
* @module @n3rdw1z4rd/core/vite
|
|
27
|
+
*/
|
|
3
28
|
/** @category Build */
|
|
4
29
|
function decorators() {
|
|
5
30
|
const file = /\.[cm]?[jt]sx?$/;
|
|
@@ -36,4 +61,103 @@ function decorators() {
|
|
|
36
61
|
}
|
|
37
62
|
};
|
|
38
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The commit a build is made from, 7 characters: from the environment (`GIT_COMMIT`,
|
|
66
|
+
* `SOURCE_COMMIT`, `COMMIT_SHA` or `GITHUB_SHA`, as Docker builds and CI pass it), else git, else
|
|
67
|
+
* the `.git` folder's own files. Without any of those, `local.HHMM` (UTC), so two builds on one
|
|
68
|
+
* day still differ.
|
|
69
|
+
*
|
|
70
|
+
* @category Build
|
|
71
|
+
*/
|
|
72
|
+
function buildCommit(cwd = process.cwd()) {
|
|
73
|
+
const env = process.env.GIT_COMMIT || process.env.SOURCE_COMMIT || process.env.COMMIT_SHA || process.env.GITHUB_SHA;
|
|
74
|
+
if (env) return env.slice(0, 7);
|
|
75
|
+
try {
|
|
76
|
+
return (0, node_child_process.execSync)("git rev-parse --short=7 HEAD", {
|
|
77
|
+
cwd,
|
|
78
|
+
stdio: [
|
|
79
|
+
"ignore",
|
|
80
|
+
"pipe",
|
|
81
|
+
"ignore"
|
|
82
|
+
]
|
|
83
|
+
}).toString().trim();
|
|
84
|
+
} catch {}
|
|
85
|
+
try {
|
|
86
|
+
const git = (0, node_path.join)(cwd, ".git");
|
|
87
|
+
const head = (0, node_fs.readFileSync)((0, node_path.join)(git, "HEAD"), "utf8").trim();
|
|
88
|
+
if (!head.startsWith("ref: ")) return head.slice(0, 7);
|
|
89
|
+
const ref = head.slice(5);
|
|
90
|
+
try {
|
|
91
|
+
return (0, node_fs.readFileSync)((0, node_path.join)(git, ref), "utf8").trim().slice(0, 7);
|
|
92
|
+
} catch {}
|
|
93
|
+
const line = (0, node_fs.readFileSync)((0, node_path.join)(git, "packed-refs"), "utf8").split("\n").find((l) => l.endsWith(` ${ref}`));
|
|
94
|
+
if (line) return line.slice(0, 7);
|
|
95
|
+
} catch {}
|
|
96
|
+
const now = /* @__PURE__ */ new Date();
|
|
97
|
+
return `local.${String(now.getUTCHours()).padStart(2, "0")}${String(now.getUTCMinutes()).padStart(2, "0")}`;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A build's id: package.json's version and the commit it's built from, e.g. "0.7.0-6ae4707"
|
|
101
|
+
* (letters, digits, dots and dashes only: the desktop app names a folder after it).
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* // vite.config.ts: the page can show it, too
|
|
105
|
+
* export default defineConfig({ define: { __BUILD_ID__: JSON.stringify(buildId()) }, plugins: [buildManifest()] });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @category Build
|
|
109
|
+
*/
|
|
110
|
+
function buildId(cwd = process.cwd()) {
|
|
111
|
+
return `${JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(cwd, "package.json"), "utf8")).version ?? "0.0.0"}-${buildCommit(cwd)}`.replace(/[^\w.-]/g, "-");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Vite plugin: after a build, writes `version.json` into the output folder: the build's id, when
|
|
115
|
+
* it was built, the desktop API level it needs, and every file in it with its size and SHA-256.
|
|
116
|
+
* The desktop app (`@n3rdw1z4rd/core/electron`) reads its own copy to know what it's running, and
|
|
117
|
+
* the site's copy to update itself.
|
|
118
|
+
*
|
|
119
|
+
* @category Build
|
|
120
|
+
*/
|
|
121
|
+
function buildManifest(options = {}) {
|
|
122
|
+
let outDir = (0, node_path.resolve)("dist");
|
|
123
|
+
let root = process.cwd();
|
|
124
|
+
return {
|
|
125
|
+
name: "n3rdw1z4rd:build-manifest",
|
|
126
|
+
apply: "build",
|
|
127
|
+
configResolved(config) {
|
|
128
|
+
root = config.root;
|
|
129
|
+
outDir = (0, node_path.resolve)(config.root, config.build.outDir);
|
|
130
|
+
},
|
|
131
|
+
closeBundle(error) {
|
|
132
|
+
if (error || !(0, node_fs.existsSync)(outDir)) return;
|
|
133
|
+
const files = [];
|
|
134
|
+
const walk = (dir) => {
|
|
135
|
+
for (const name of (0, node_fs.readdirSync)(dir)) {
|
|
136
|
+
const full = (0, node_path.join)(dir, name);
|
|
137
|
+
if ((0, node_fs.statSync)(full).isDirectory()) walk(full);
|
|
138
|
+
else if (full !== (0, node_path.join)(outDir, "version.json")) {
|
|
139
|
+
const data = (0, node_fs.readFileSync)(full);
|
|
140
|
+
files.push({
|
|
141
|
+
path: (0, node_path.relative)(outDir, full).split(node_path.sep).join("/"),
|
|
142
|
+
size: data.length,
|
|
143
|
+
sha256: (0, node_crypto.createHash)("sha256").update(data).digest("hex")
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
walk(outDir);
|
|
149
|
+
files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
150
|
+
const manifest = {
|
|
151
|
+
version: options.version ?? buildId(root),
|
|
152
|
+
builtAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
153
|
+
needs: options.needs ?? 1,
|
|
154
|
+
files
|
|
155
|
+
};
|
|
156
|
+
(0, node_fs.writeFileSync)((0, node_path.join)(outDir, "version.json"), JSON.stringify(manifest, null, 1));
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
exports.buildCommit = buildCommit;
|
|
161
|
+
exports.buildId = buildId;
|
|
162
|
+
exports.buildManifest = buildManifest;
|
|
39
163
|
exports.decorators = decorators;
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vite
|
|
2
|
+
* Vite plugins: `decorators()` lowers standard (TC39) decorators such as `@field` / `@component`
|
|
3
|
+
* with esbuild; `buildManifest()` writes the `version.json` the desktop app
|
|
4
|
+
* (`@n3rdw1z4rd/core/electron`) updates itself from.
|
|
3
5
|
*
|
|
4
6
|
* Vite 8 compiles TypeScript with Oxc, which only lowers legacy `experimentalDecorators` and
|
|
5
7
|
* passes standard decorators through untouched — no browser can run that yet. This runs
|
|
@@ -30,4 +32,53 @@ export interface DecoratorsPlugin {
|
|
|
30
32
|
} | null>;
|
|
31
33
|
}
|
|
32
34
|
/** @category Build */
|
|
33
|
-
export declare function decorators(): DecoratorsPlugin;
|
|
35
|
+
export declare function decorators(): DecoratorsPlugin;
|
|
36
|
+
/**
|
|
37
|
+
* The commit a build is made from, 7 characters: from the environment (`GIT_COMMIT`,
|
|
38
|
+
* `SOURCE_COMMIT`, `COMMIT_SHA` or `GITHUB_SHA`, as Docker builds and CI pass it), else git, else
|
|
39
|
+
* the `.git` folder's own files. Without any of those, `local.HHMM` (UTC), so two builds on one
|
|
40
|
+
* day still differ.
|
|
41
|
+
*
|
|
42
|
+
* @category Build
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildCommit(cwd?: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* A build's id: package.json's version and the commit it's built from, e.g. "0.7.0-6ae4707"
|
|
47
|
+
* (letters, digits, dots and dashes only: the desktop app names a folder after it).
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* // vite.config.ts: the page can show it, too
|
|
51
|
+
* export default defineConfig({ define: { __BUILD_ID__: JSON.stringify(buildId()) }, plugins: [buildManifest()] });
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @category Build
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildId(cwd?: string): string;
|
|
57
|
+
/** Options for {@link buildManifest}. */
|
|
58
|
+
export interface BuildManifestOptions {
|
|
59
|
+
/** the build's id; default {@link buildId} */
|
|
60
|
+
version?: string;
|
|
61
|
+
/** the desktop API level the build needs (the app's `update.api` must be at least this); default 1 */
|
|
62
|
+
needs?: number;
|
|
63
|
+
}
|
|
64
|
+
/** The part of Vite's `Plugin` {@link buildManifest} uses (structurally compatible: pass it to `plugins`). */
|
|
65
|
+
export interface BuildManifestPlugin {
|
|
66
|
+
name: string;
|
|
67
|
+
apply: 'build';
|
|
68
|
+
configResolved(config: {
|
|
69
|
+
root: string;
|
|
70
|
+
build: {
|
|
71
|
+
outDir: string;
|
|
72
|
+
};
|
|
73
|
+
}): void;
|
|
74
|
+
closeBundle(error?: Error): void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Vite plugin: after a build, writes `version.json` into the output folder: the build's id, when
|
|
78
|
+
* it was built, the desktop API level it needs, and every file in it with its size and SHA-256.
|
|
79
|
+
* The desktop app (`@n3rdw1z4rd/core/electron`) reads its own copy to know what it's running, and
|
|
80
|
+
* the site's copy to update itself.
|
|
81
|
+
*
|
|
82
|
+
* @category Build
|
|
83
|
+
*/
|
|
84
|
+
export declare function buildManifest(options?: BuildManifestOptions): BuildManifestPlugin;
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vite
|
|
2
|
+
* Vite plugins: `decorators()` lowers standard (TC39) decorators such as `@field` / `@component`
|
|
3
|
+
* with esbuild; `buildManifest()` writes the `version.json` the desktop app
|
|
4
|
+
* (`@n3rdw1z4rd/core/electron`) updates itself from.
|
|
3
5
|
*
|
|
4
6
|
* Vite 8 compiles TypeScript with Oxc, which only lowers legacy `experimentalDecorators` and
|
|
5
7
|
* passes standard decorators through untouched — no browser can run that yet. This runs
|
|
@@ -30,4 +32,53 @@ export interface DecoratorsPlugin {
|
|
|
30
32
|
} | null>;
|
|
31
33
|
}
|
|
32
34
|
/** @category Build */
|
|
33
|
-
export declare function decorators(): DecoratorsPlugin;
|
|
35
|
+
export declare function decorators(): DecoratorsPlugin;
|
|
36
|
+
/**
|
|
37
|
+
* The commit a build is made from, 7 characters: from the environment (`GIT_COMMIT`,
|
|
38
|
+
* `SOURCE_COMMIT`, `COMMIT_SHA` or `GITHUB_SHA`, as Docker builds and CI pass it), else git, else
|
|
39
|
+
* the `.git` folder's own files. Without any of those, `local.HHMM` (UTC), so two builds on one
|
|
40
|
+
* day still differ.
|
|
41
|
+
*
|
|
42
|
+
* @category Build
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildCommit(cwd?: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* A build's id: package.json's version and the commit it's built from, e.g. "0.7.0-6ae4707"
|
|
47
|
+
* (letters, digits, dots and dashes only: the desktop app names a folder after it).
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* // vite.config.ts: the page can show it, too
|
|
51
|
+
* export default defineConfig({ define: { __BUILD_ID__: JSON.stringify(buildId()) }, plugins: [buildManifest()] });
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @category Build
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildId(cwd?: string): string;
|
|
57
|
+
/** Options for {@link buildManifest}. */
|
|
58
|
+
export interface BuildManifestOptions {
|
|
59
|
+
/** the build's id; default {@link buildId} */
|
|
60
|
+
version?: string;
|
|
61
|
+
/** the desktop API level the build needs (the app's `update.api` must be at least this); default 1 */
|
|
62
|
+
needs?: number;
|
|
63
|
+
}
|
|
64
|
+
/** The part of Vite's `Plugin` {@link buildManifest} uses (structurally compatible: pass it to `plugins`). */
|
|
65
|
+
export interface BuildManifestPlugin {
|
|
66
|
+
name: string;
|
|
67
|
+
apply: 'build';
|
|
68
|
+
configResolved(config: {
|
|
69
|
+
root: string;
|
|
70
|
+
build: {
|
|
71
|
+
outDir: string;
|
|
72
|
+
};
|
|
73
|
+
}): void;
|
|
74
|
+
closeBundle(error?: Error): void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Vite plugin: after a build, writes `version.json` into the output folder: the build's id, when
|
|
78
|
+
* it was built, the desktop API level it needs, and every file in it with its size and SHA-256.
|
|
79
|
+
* The desktop app (`@n3rdw1z4rd/core/electron`) reads its own copy to know what it's running, and
|
|
80
|
+
* the site's copy to update itself.
|
|
81
|
+
*
|
|
82
|
+
* @category Build
|
|
83
|
+
*/
|
|
84
|
+
export declare function buildManifest(options?: BuildManifestOptions): BuildManifestPlugin;
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
1
5
|
// src/vite.ts
|
|
6
|
+
/**
|
|
7
|
+
* Vite plugins: `decorators()` lowers standard (TC39) decorators such as `@field` / `@component`
|
|
8
|
+
* with esbuild; `buildManifest()` writes the `version.json` the desktop app
|
|
9
|
+
* (`@n3rdw1z4rd/core/electron`) updates itself from.
|
|
10
|
+
*
|
|
11
|
+
* Vite 8 compiles TypeScript with Oxc, which only lowers legacy `experimentalDecorators` and
|
|
12
|
+
* passes standard decorators through untouched — no browser can run that yet. This runs
|
|
13
|
+
* first on any source file that uses a decorator; Oxc then sees plain TS/JS.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* // vite.config.ts
|
|
17
|
+
* import { decorators } from '@n3rdw1z4rd/core/vite';
|
|
18
|
+
* export default defineConfig({ plugins: [decorators()] });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Requires `esbuild` to be installed alongside Vite. Node-only: not exported from the
|
|
22
|
+
* package root.
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
* @module @n3rdw1z4rd/core/vite
|
|
26
|
+
*/
|
|
2
27
|
/** @category Build */
|
|
3
28
|
function decorators() {
|
|
4
29
|
const file = /\.[cm]?[jt]sx?$/;
|
|
@@ -35,4 +60,100 @@ function decorators() {
|
|
|
35
60
|
}
|
|
36
61
|
};
|
|
37
62
|
}
|
|
38
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The commit a build is made from, 7 characters: from the environment (`GIT_COMMIT`,
|
|
65
|
+
* `SOURCE_COMMIT`, `COMMIT_SHA` or `GITHUB_SHA`, as Docker builds and CI pass it), else git, else
|
|
66
|
+
* the `.git` folder's own files. Without any of those, `local.HHMM` (UTC), so two builds on one
|
|
67
|
+
* day still differ.
|
|
68
|
+
*
|
|
69
|
+
* @category Build
|
|
70
|
+
*/
|
|
71
|
+
function buildCommit(cwd = process.cwd()) {
|
|
72
|
+
const env = process.env.GIT_COMMIT || process.env.SOURCE_COMMIT || process.env.COMMIT_SHA || process.env.GITHUB_SHA;
|
|
73
|
+
if (env) return env.slice(0, 7);
|
|
74
|
+
try {
|
|
75
|
+
return execSync("git rev-parse --short=7 HEAD", {
|
|
76
|
+
cwd,
|
|
77
|
+
stdio: [
|
|
78
|
+
"ignore",
|
|
79
|
+
"pipe",
|
|
80
|
+
"ignore"
|
|
81
|
+
]
|
|
82
|
+
}).toString().trim();
|
|
83
|
+
} catch {}
|
|
84
|
+
try {
|
|
85
|
+
const git = join(cwd, ".git");
|
|
86
|
+
const head = readFileSync(join(git, "HEAD"), "utf8").trim();
|
|
87
|
+
if (!head.startsWith("ref: ")) return head.slice(0, 7);
|
|
88
|
+
const ref = head.slice(5);
|
|
89
|
+
try {
|
|
90
|
+
return readFileSync(join(git, ref), "utf8").trim().slice(0, 7);
|
|
91
|
+
} catch {}
|
|
92
|
+
const line = readFileSync(join(git, "packed-refs"), "utf8").split("\n").find((l) => l.endsWith(` ${ref}`));
|
|
93
|
+
if (line) return line.slice(0, 7);
|
|
94
|
+
} catch {}
|
|
95
|
+
const now = /* @__PURE__ */ new Date();
|
|
96
|
+
return `local.${String(now.getUTCHours()).padStart(2, "0")}${String(now.getUTCMinutes()).padStart(2, "0")}`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A build's id: package.json's version and the commit it's built from, e.g. "0.7.0-6ae4707"
|
|
100
|
+
* (letters, digits, dots and dashes only: the desktop app names a folder after it).
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* // vite.config.ts: the page can show it, too
|
|
104
|
+
* export default defineConfig({ define: { __BUILD_ID__: JSON.stringify(buildId()) }, plugins: [buildManifest()] });
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @category Build
|
|
108
|
+
*/
|
|
109
|
+
function buildId(cwd = process.cwd()) {
|
|
110
|
+
return `${JSON.parse(readFileSync(join(cwd, "package.json"), "utf8")).version ?? "0.0.0"}-${buildCommit(cwd)}`.replace(/[^\w.-]/g, "-");
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Vite plugin: after a build, writes `version.json` into the output folder: the build's id, when
|
|
114
|
+
* it was built, the desktop API level it needs, and every file in it with its size and SHA-256.
|
|
115
|
+
* The desktop app (`@n3rdw1z4rd/core/electron`) reads its own copy to know what it's running, and
|
|
116
|
+
* the site's copy to update itself.
|
|
117
|
+
*
|
|
118
|
+
* @category Build
|
|
119
|
+
*/
|
|
120
|
+
function buildManifest(options = {}) {
|
|
121
|
+
let outDir = resolve("dist");
|
|
122
|
+
let root = process.cwd();
|
|
123
|
+
return {
|
|
124
|
+
name: "n3rdw1z4rd:build-manifest",
|
|
125
|
+
apply: "build",
|
|
126
|
+
configResolved(config) {
|
|
127
|
+
root = config.root;
|
|
128
|
+
outDir = resolve(config.root, config.build.outDir);
|
|
129
|
+
},
|
|
130
|
+
closeBundle(error) {
|
|
131
|
+
if (error || !existsSync(outDir)) return;
|
|
132
|
+
const files = [];
|
|
133
|
+
const walk = (dir) => {
|
|
134
|
+
for (const name of readdirSync(dir)) {
|
|
135
|
+
const full = join(dir, name);
|
|
136
|
+
if (statSync(full).isDirectory()) walk(full);
|
|
137
|
+
else if (full !== join(outDir, "version.json")) {
|
|
138
|
+
const data = readFileSync(full);
|
|
139
|
+
files.push({
|
|
140
|
+
path: relative(outDir, full).split(sep).join("/"),
|
|
141
|
+
size: data.length,
|
|
142
|
+
sha256: createHash("sha256").update(data).digest("hex")
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
walk(outDir);
|
|
148
|
+
files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
149
|
+
const manifest = {
|
|
150
|
+
version: options.version ?? buildId(root),
|
|
151
|
+
builtAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
152
|
+
needs: options.needs ?? 1,
|
|
153
|
+
files
|
|
154
|
+
};
|
|
155
|
+
writeFileSync(join(outDir, "version.json"), JSON.stringify(manifest, null, 1));
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export { buildCommit, buildId, buildManifest, decorators };
|
package/dist/webgl.js
CHANGED
|
@@ -383,7 +383,7 @@ function CreateVertexArray(gl, info, attributes, indices) {
|
|
|
383
383
|
vao,
|
|
384
384
|
buffers: []
|
|
385
385
|
};
|
|
386
|
-
let vertexCount =
|
|
386
|
+
let vertexCount = 1e400;
|
|
387
387
|
gl.bindVertexArray(vao);
|
|
388
388
|
for (const name in attributes) {
|
|
389
389
|
const attribute = info.attributes[name];
|
|
@@ -423,7 +423,7 @@ function CreateVertexArray(gl, info, attributes, indices) {
|
|
|
423
423
|
if (!result.buffers.includes(indices.buffer)) result.buffers.push(indices.buffer);
|
|
424
424
|
}
|
|
425
425
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, result.indexBuffer);
|
|
426
|
-
} else if (vertexCount <
|
|
426
|
+
} else if (vertexCount < 1e400) result.count = vertexCount;
|
|
427
427
|
gl.bindVertexArray(null);
|
|
428
428
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
429
429
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n3rdw1z4rd/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "core library",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -46,6 +46,18 @@
|
|
|
46
46
|
"default": "./dist/vite.cjs"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
+
"./electron": {
|
|
50
|
+
"import": {
|
|
51
|
+
"types": "./dist/electron/index.d.ts",
|
|
52
|
+
"default": "./dist/electron/index.js"
|
|
53
|
+
},
|
|
54
|
+
"require": {
|
|
55
|
+
"types": "./dist/electron.d.cts",
|
|
56
|
+
"default": "./dist/electron.cjs"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"./electron/preload.cjs": "./dist/electron/preload.cjs",
|
|
60
|
+
"./electron/after-pack.cjs": "./dist/electron/after-pack.cjs",
|
|
49
61
|
"./css/*": "./dist/css/*",
|
|
50
62
|
"./dist/*": "./dist/*",
|
|
51
63
|
"./package.json": "./package.json"
|
|
@@ -63,6 +75,7 @@
|
|
|
63
75
|
"prepublishOnly": "npm test && npm run build",
|
|
64
76
|
"test:browser": "node scripts/test-browser.mjs",
|
|
65
77
|
"test:browser:headless": "node scripts/test-browser-headless.mjs",
|
|
78
|
+
"test:electron": "node scripts/test-electron.mjs",
|
|
66
79
|
"docs": "typedoc",
|
|
67
80
|
"docs:watch": "typedoc --watch"
|
|
68
81
|
},
|
|
@@ -85,7 +98,8 @@
|
|
|
85
98
|
"procedural-generation",
|
|
86
99
|
"pathfinding",
|
|
87
100
|
"voxel",
|
|
88
|
-
"particle-system"
|
|
101
|
+
"particle-system",
|
|
102
|
+
"electron"
|
|
89
103
|
],
|
|
90
104
|
"author": "",
|
|
91
105
|
"license": "MIT",
|
|
@@ -98,15 +112,21 @@
|
|
|
98
112
|
"heap-js": "^2.7.1"
|
|
99
113
|
},
|
|
100
114
|
"peerDependencies": {
|
|
101
|
-
"three": "^0.187.0"
|
|
115
|
+
"three": "^0.187.0",
|
|
116
|
+
"electron": ">=38"
|
|
102
117
|
},
|
|
103
118
|
"peerDependenciesMeta": {
|
|
104
119
|
"three": {
|
|
105
120
|
"optional": true
|
|
121
|
+
},
|
|
122
|
+
"electron": {
|
|
123
|
+
"optional": true
|
|
106
124
|
}
|
|
107
125
|
},
|
|
108
126
|
"devDependencies": {
|
|
127
|
+
"@types/node": "^24.19.4",
|
|
109
128
|
"@types/three": "^0.187.0",
|
|
129
|
+
"electron": "^45.5.0",
|
|
110
130
|
"esbuild": "^0.28.2",
|
|
111
131
|
"playwright-core": "^1.56.1",
|
|
112
132
|
"three": "^0.187.0",
|
package/dist/input/_input.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Emitter } from "../emitter.js";
|
|
2
|
-
export interface InputState {
|
|
3
|
-
state: number;
|
|
4
|
-
timeStamp: number;
|
|
5
|
-
}
|
|
6
|
-
export declare class Input extends Emitter {
|
|
7
|
-
private static _instance;
|
|
8
|
-
static get instance(): Input;
|
|
9
|
-
private _state;
|
|
10
|
-
inputThreshold: number;
|
|
11
|
-
private constructor();
|
|
12
|
-
disableContextMenu(): void;
|
|
13
|
-
private _onKeyDown;
|
|
14
|
-
private _onKeyUp;
|
|
15
|
-
private _onPointerDown;
|
|
16
|
-
private _onPointerUp;
|
|
17
|
-
private _onPointerMove;
|
|
18
|
-
private _onWheel;
|
|
19
|
-
isKeyDown(keyCode: string): boolean;
|
|
20
|
-
getKeyState(keyCode: string): number;
|
|
21
|
-
isButtonDown(buttonNumber: number): boolean;
|
|
22
|
-
getButtonState(buttonNumber: number): number;
|
|
23
|
-
}
|
package/dist/input/_input.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Emitter } from "../emitter.js";
|
|
2
|
-
// src/input/_input.ts
|
|
3
|
-
var Input = class Input extends Emitter {
|
|
4
|
-
static _instance;
|
|
5
|
-
static get instance() {
|
|
6
|
-
if (!Input._instance) Input._instance = new Input();
|
|
7
|
-
return Input._instance;
|
|
8
|
-
}
|
|
9
|
-
_state = {};
|
|
10
|
-
inputThreshold = 200;
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
window.addEventListener("keydown", this._onKeyDown.bind(this));
|
|
14
|
-
window.addEventListener("keyup", this._onKeyUp.bind(this));
|
|
15
|
-
window.addEventListener("pointerdown", this._onPointerDown.bind(this));
|
|
16
|
-
window.addEventListener("pointerup", this._onPointerUp.bind(this));
|
|
17
|
-
window.addEventListener("mousemove", this._onPointerMove.bind(this));
|
|
18
|
-
window.addEventListener("wheel", this._onWheel.bind(this));
|
|
19
|
-
}
|
|
20
|
-
disableContextMenu() {
|
|
21
|
-
window.addEventListener("contextmenu", (ev) => {
|
|
22
|
-
ev.preventDefault();
|
|
23
|
-
this.emit("contextmenu");
|
|
24
|
-
return false;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
_onKeyDown(ev) {
|
|
28
|
-
const { code, timeStamp } = ev;
|
|
29
|
-
if (!ev.repeat) {
|
|
30
|
-
this._state[code] = {
|
|
31
|
-
state: 1,
|
|
32
|
-
timeStamp
|
|
33
|
-
};
|
|
34
|
-
this.emit("key_down", ev);
|
|
35
|
-
this.emit(`${code.toLowerCase()}_down`, ev);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
_onKeyUp(ev) {
|
|
39
|
-
const { code, timeStamp } = ev;
|
|
40
|
-
this._state[code] = {
|
|
41
|
-
state: 0,
|
|
42
|
-
timeStamp
|
|
43
|
-
};
|
|
44
|
-
this.emit("key_up", ev);
|
|
45
|
-
this.emit(`${code.toLowerCase()}_up`, ev);
|
|
46
|
-
if (timeStamp - (this._state[code]?.timeStamp ?? 0) <= this.inputThreshold) {
|
|
47
|
-
this.emit("key_pressed", ev);
|
|
48
|
-
this.emit(`${code.toLowerCase()}_pressed`, ev);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
_onPointerDown(ev) {
|
|
52
|
-
const { button, timeStamp } = ev;
|
|
53
|
-
const code = `button${button}`;
|
|
54
|
-
if (!this._state[code]?.state) {
|
|
55
|
-
this._state[code] = {
|
|
56
|
-
state: 1,
|
|
57
|
-
timeStamp
|
|
58
|
-
};
|
|
59
|
-
this.emit("button_down", ev);
|
|
60
|
-
this.emit(`${code}_down`, ev);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
_onPointerUp(ev) {
|
|
64
|
-
const { button, timeStamp } = ev;
|
|
65
|
-
const code = `button${button}`;
|
|
66
|
-
this._state[code] = {
|
|
67
|
-
state: 0,
|
|
68
|
-
timeStamp
|
|
69
|
-
};
|
|
70
|
-
this.emit("button_up", ev);
|
|
71
|
-
this.emit(`${code}_up`, ev);
|
|
72
|
-
if (timeStamp - (this._state[button]?.timeStamp ?? 0) < this.inputThreshold) {
|
|
73
|
-
this.emit("button_clicked", ev);
|
|
74
|
-
this.emit(`${code}_clicked`, ev);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
_onPointerMove(ev) {
|
|
78
|
-
this.emit("pointer_move", ev);
|
|
79
|
-
}
|
|
80
|
-
_onWheel(ev) {
|
|
81
|
-
this.emit("mouse_wheel", ev);
|
|
82
|
-
}
|
|
83
|
-
isKeyDown(keyCode) {
|
|
84
|
-
return this._state[keyCode]?.state === 1 ? true : false;
|
|
85
|
-
}
|
|
86
|
-
getKeyState(keyCode) {
|
|
87
|
-
return this._state[keyCode]?.state ?? 0;
|
|
88
|
-
}
|
|
89
|
-
isButtonDown(buttonNumber) {
|
|
90
|
-
return this._state[`button${buttonNumber}`]?.state === 1 ? true : false;
|
|
91
|
-
}
|
|
92
|
-
getButtonState(buttonNumber) {
|
|
93
|
-
return this._state[`button${buttonNumber}`]?.state ?? 0;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
export { Input };
|