@goodpuppies/workman 0.0.0-stage → 0.7.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/LICENSE +21 -0
- package/README.md +6 -2
- package/bin/resolve.cjs +33 -0
- package/bin/wm.cjs +17 -0
- package/package.json +53 -4
- package/src/integrations/bun.d.mts +17 -0
- package/src/integrations/bun.mjs +19 -0
- package/src/integrations/compile.mjs +22 -0
- package/src/integrations/vite.d.mts +12 -0
- package/src/integrations/vite.mjs +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Good Puppies
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Workman
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Experimental Workman 0.7.0. Includes the compiler, TypeScript 7.1 content mapper, and Vite/Bun integrations.
|
|
4
|
+
|
|
5
|
+
Install optional dependencies to obtain the platform binary. Node is required for the CLI and mapper launcher; Bun can use the integration directly.
|
|
6
|
+
|
|
7
|
+
JS/TS reflection may still require a separate Deno installation. Runtime commands (run/watch/repl/pakman/problems/test and executable generation) are not enabled in this experimental standalone build; use the source-based Deno/JSR installation for those.
|
package/bin/resolve.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const path = require("node:path");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const manifest = require("../package.json");
|
|
4
|
+
|
|
5
|
+
exports.resolveBinary = function () {
|
|
6
|
+
const key = `${process.platform}-${process.arch}`;
|
|
7
|
+
const names = {
|
|
8
|
+
"linux-x64": "linux-x64",
|
|
9
|
+
"linux-arm64": "linux-arm64",
|
|
10
|
+
"darwin-x64": "darwin-x64",
|
|
11
|
+
"darwin-arm64": "darwin-arm64",
|
|
12
|
+
"win32-x64": "win32-x64",
|
|
13
|
+
"win32-arm64": "win32-arm64",
|
|
14
|
+
};
|
|
15
|
+
const suffix = names[key];
|
|
16
|
+
if (!suffix) throw new Error(`Workman has no prebuilt binary for ${key}`);
|
|
17
|
+
const name = `${manifest.name}-${suffix}`;
|
|
18
|
+
let metadata;
|
|
19
|
+
try {
|
|
20
|
+
metadata = require.resolve(`${name}/package.json`);
|
|
21
|
+
} catch {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Missing ${name}@${manifest.version}. Install optional dependencies; Linux binaries require glibc.`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const platform = JSON.parse(fs.readFileSync(metadata, "utf8"));
|
|
27
|
+
if (platform.version !== manifest.version) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Workman binary version mismatch: expected ${manifest.version}, found ${platform.version}`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return path.join(path.dirname(metadata), "bin", process.platform === "win32" ? "wm.exe" : "wm");
|
|
33
|
+
};
|
package/bin/wm.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require("node:child_process");
|
|
3
|
+
try {
|
|
4
|
+
const binary = require("./resolve.cjs").resolveBinary();
|
|
5
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
6
|
+
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => child.kill(signal));
|
|
7
|
+
child.on("error", (error) => {
|
|
8
|
+
console.error(error.message);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
|
11
|
+
child.on("exit", (code, signal) => {
|
|
12
|
+
process.exitCode = code ?? (signal === "SIGINT" ? 130 : 1);
|
|
13
|
+
});
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error(error.message);
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodpuppies/workman",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Workman language tools and experimental TypeScript content mapper",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/goodpuppies/workman.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"wm": "./bin/wm.cjs"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
"./vite": {
|
|
16
|
+
"types": "./src/integrations/vite.d.mts",
|
|
17
|
+
"import": "./src/integrations/vite.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./bun": {
|
|
20
|
+
"types": "./src/integrations/bun.d.mts",
|
|
21
|
+
"import": "./src/integrations/bun.mjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin",
|
|
26
|
+
"src/integrations",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20"
|
|
35
|
+
},
|
|
36
|
+
"typescript": {
|
|
37
|
+
"contentMapper": {
|
|
38
|
+
"exec": [
|
|
39
|
+
"node",
|
|
40
|
+
"./bin/wm.cjs",
|
|
41
|
+
"content-mapper"
|
|
42
|
+
],
|
|
43
|
+
"compilerOptions": [],
|
|
44
|
+
"dynamicConfig": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"optionalDependencies": {
|
|
48
|
+
"@goodpuppies/workman-linux-x64": "0.7.0",
|
|
49
|
+
"@goodpuppies/workman-linux-arm64": "0.7.0",
|
|
50
|
+
"@goodpuppies/workman-darwin-x64": "0.7.0",
|
|
51
|
+
"@goodpuppies/workman-darwin-arm64": "0.7.0",
|
|
52
|
+
"@goodpuppies/workman-win32-x64": "0.7.0",
|
|
53
|
+
"@goodpuppies/workman-win32-arm64": "0.7.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface WorkmanOptions {
|
|
2
|
+
compilerPath?: string;
|
|
3
|
+
}
|
|
4
|
+
/** Bun runtime/bundler plugin; register at startup before importing WM. */
|
|
5
|
+
export function workman(options?: WorkmanOptions): {
|
|
6
|
+
name: string;
|
|
7
|
+
setup(build: {
|
|
8
|
+
onLoad(
|
|
9
|
+
options: { filter: RegExp },
|
|
10
|
+
callback: (args: { path: string }) => Promise<{
|
|
11
|
+
contents: string;
|
|
12
|
+
loader: "js";
|
|
13
|
+
resolveDir: string;
|
|
14
|
+
}>,
|
|
15
|
+
): void;
|
|
16
|
+
}): void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { compileWorkman } from "./compile.mjs";
|
|
3
|
+
|
|
4
|
+
/** Use with Bun.plugin() in a preload, or in Bun.build({ plugins: [...] }). */
|
|
5
|
+
export function workman(options = {}) {
|
|
6
|
+
return {
|
|
7
|
+
name: "workman",
|
|
8
|
+
setup(build) {
|
|
9
|
+
build.onLoad({ filter: /\.wm$/ }, async ({ path }) => {
|
|
10
|
+
const result = await compileWorkman(path, options);
|
|
11
|
+
return {
|
|
12
|
+
contents: result.code,
|
|
13
|
+
loader: "js",
|
|
14
|
+
resolveDir: dirname(path),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
const run = promisify(execFile);
|
|
5
|
+
const { resolveBinary } = createRequire(import.meta.url)("../../bin/resolve.cjs");
|
|
6
|
+
|
|
7
|
+
export async function compileWorkman(path, options = {}) {
|
|
8
|
+
try {
|
|
9
|
+
const { stdout } = await run(options.compilerPath ?? resolveBinary(), [
|
|
10
|
+
"compile-library-json",
|
|
11
|
+
path,
|
|
12
|
+
], {
|
|
13
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
14
|
+
timeout: 60_000,
|
|
15
|
+
});
|
|
16
|
+
return JSON.parse(stdout);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new Error(`Workman compilation failed for ${path}\n${error.stderr || error.message}`, {
|
|
19
|
+
cause: error,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface WorkmanOptions {
|
|
2
|
+
compilerPath?: string;
|
|
3
|
+
}
|
|
4
|
+
/** Vite plugin. Compiles WM library entries and watches their transitive WM dependencies. */
|
|
5
|
+
export function workman(options?: WorkmanOptions): {
|
|
6
|
+
name: string;
|
|
7
|
+
enforce: "pre";
|
|
8
|
+
load(
|
|
9
|
+
this: { addWatchFile(path: string): void },
|
|
10
|
+
id: string,
|
|
11
|
+
): Promise<{ code: string; map: null } | null>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { compileWorkman } from "./compile.mjs";
|
|
2
|
+
|
|
3
|
+
export function workman(options = {}) {
|
|
4
|
+
const dependencies = new Map();
|
|
5
|
+
return {
|
|
6
|
+
name: "workman",
|
|
7
|
+
enforce: "pre",
|
|
8
|
+
async load(id) {
|
|
9
|
+
// Leave Vite's explicit asset/text queries to Vite.
|
|
10
|
+
if (!id.endsWith(".wm")) return null;
|
|
11
|
+
const result = await compileWorkman(id, options);
|
|
12
|
+
dependencies.set(id, new Set(result.dependencies));
|
|
13
|
+
for (const path of result.dependencies) this.addWatchFile(path);
|
|
14
|
+
return { code: result.code, map: null };
|
|
15
|
+
},
|
|
16
|
+
hotUpdate(context) {
|
|
17
|
+
const modules = new Set(context.modules);
|
|
18
|
+
for (const [entry, paths] of dependencies) {
|
|
19
|
+
if (!paths.has(context.file)) continue;
|
|
20
|
+
for (const module of this.environment.moduleGraph.getModulesByFile(entry) ?? []) {
|
|
21
|
+
this.environment.moduleGraph.invalidateModule(module, new Set(), context.timestamp, true);
|
|
22
|
+
modules.add(module);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return [...modules];
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|