@goodpuppies/workman 0.7.0 → 0.9.1
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 +3 -3
- package/package.json +11 -7
- package/src/integrations/interop.d.mts +52 -0
- package/src/integrations/interop.mjs +61 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Workman
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Workman 0.9.1: the compiler, language server, REPL, test runner, TypeScript 7.1 content mapper and Vite/Bun integrations.
|
|
4
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.
|
|
5
|
+
Install optional dependencies to obtain the platform binary, which embeds the Deno runtime, tsrs (TypeScript 7.1 reflection), and esbuild (for running programs that import `node_modules` packages); no separate Deno installation is needed. Node is required for the CLI and mapper launcher; Bun can use the integration directly.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This build supports local `node_modules` package imports (via `package.json`). Deno-specific `npm:`, `jsr:`, and remote URL specifiers, as well as building standalone executables with `--executable`, require the Deno/JSR installation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodpuppies/workman",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Workman language tools and experimental TypeScript content mapper",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./src/integrations/vite.d.mts",
|
|
17
17
|
"import": "./src/integrations/vite.mjs"
|
|
18
18
|
},
|
|
19
|
+
"./interop": {
|
|
20
|
+
"types": "./src/integrations/interop.d.mts",
|
|
21
|
+
"import": "./src/integrations/interop.mjs"
|
|
22
|
+
},
|
|
19
23
|
"./bun": {
|
|
20
24
|
"types": "./src/integrations/bun.d.mts",
|
|
21
25
|
"import": "./src/integrations/bun.mjs"
|
|
@@ -45,11 +49,11 @@
|
|
|
45
49
|
}
|
|
46
50
|
},
|
|
47
51
|
"optionalDependencies": {
|
|
48
|
-
"@goodpuppies/workman-linux-x64": "0.
|
|
49
|
-
"@goodpuppies/workman-linux-arm64": "0.
|
|
50
|
-
"@goodpuppies/workman-darwin-x64": "0.
|
|
51
|
-
"@goodpuppies/workman-darwin-arm64": "0.
|
|
52
|
-
"@goodpuppies/workman-win32-x64": "0.
|
|
53
|
-
"@goodpuppies/workman-win32-arm64": "0.
|
|
52
|
+
"@goodpuppies/workman-linux-x64": "0.9.1",
|
|
53
|
+
"@goodpuppies/workman-linux-arm64": "0.9.1",
|
|
54
|
+
"@goodpuppies/workman-darwin-x64": "0.9.1",
|
|
55
|
+
"@goodpuppies/workman-darwin-arm64": "0.9.1",
|
|
56
|
+
"@goodpuppies/workman-win32-x64": "0.9.1",
|
|
57
|
+
"@goodpuppies/workman-win32-arm64": "0.9.1"
|
|
54
58
|
}
|
|
55
59
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
declare const optionBrand: unique symbol;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Workman `Option`. Opaque: construct it with `Some`/`None`/`fromNullable` and read it with
|
|
5
|
+
* `isSome`, `getOr`, `match`, or `toNullable`. Nested Options and `Some(undefined)` stay distinct.
|
|
6
|
+
*/
|
|
7
|
+
export interface Option<out T> {
|
|
8
|
+
readonly [optionBrand]: T;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const jsErrorBrand: unique symbol;
|
|
12
|
+
|
|
13
|
+
/** A Workman `Js.Error`: a failure caught at a safe JS FFI boundary. Opaque. */
|
|
14
|
+
export interface JsError {
|
|
15
|
+
readonly [jsErrorBrand]: true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const unprojectableBrand: unique symbol;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The type of a Workman export that has no TypeScript form yet; `Reason` says why. Nothing
|
|
22
|
+
* can be done with it, so TypeScript reports the reason where the export is used.
|
|
23
|
+
*/
|
|
24
|
+
export interface Unprojectable<Reason extends string> {
|
|
25
|
+
readonly [unprojectableBrand]: Reason;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A Workman `Result`, as a discriminated union. */
|
|
29
|
+
export type Result<T, E> =
|
|
30
|
+
| { readonly ok: true; readonly value: T }
|
|
31
|
+
| { readonly ok: false; readonly error: E };
|
|
32
|
+
|
|
33
|
+
/** A Workman `Task`: eager, and an ordinary WM `Err` resolves rather than rejects. */
|
|
34
|
+
export type Task<T, E> = Promise<Result<T, E>>;
|
|
35
|
+
|
|
36
|
+
export const None: Option<never>;
|
|
37
|
+
export function Some<T>(value: T): Option<T>;
|
|
38
|
+
export function isSome<T>(option: Option<T>): boolean;
|
|
39
|
+
export function isNone<T>(option: Option<T>): boolean;
|
|
40
|
+
export function getOr<T>(option: Option<T>, fallback: T): T;
|
|
41
|
+
export function match<T, R>(
|
|
42
|
+
option: Option<T>,
|
|
43
|
+
cases: { readonly some: (value: T) => R; readonly none: () => R },
|
|
44
|
+
): R;
|
|
45
|
+
/** `null` and `undefined` become `None`; any other value, `Some(value)`. */
|
|
46
|
+
export function fromNullable<T>(value: T | null | undefined): Option<T>;
|
|
47
|
+
/** `None` becomes `undefined`. Loses the distinction for `Option<undefined>` and nested Options. */
|
|
48
|
+
export function toNullable<T>(option: Option<T>): T | undefined;
|
|
49
|
+
export function Ok<T>(value: T): Result<T, never>;
|
|
50
|
+
export function Err<E>(error: E): Result<never, E>;
|
|
51
|
+
/** The message of a `Js.Error`, or `undefined` for `Js.Unknown` (a thrown non-Error value). */
|
|
52
|
+
export function jsErrorMessage(error: JsError): string | undefined;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// TypeScript/JavaScript helpers for values crossing the Workman library boundary.
|
|
2
|
+
//
|
|
3
|
+
// Option values are opaque WM values. Nullary basis constructors are shared through
|
|
4
|
+
// globalThis, so a None built here is the same object every compiled WM library matches.
|
|
5
|
+
|
|
6
|
+
const NONE_ID = -1;
|
|
7
|
+
const SOME_ID = -2;
|
|
8
|
+
|
|
9
|
+
/** The shared None, as the WM runtime prelude registers it. Keep in sync with emit_prelude.ts. */
|
|
10
|
+
export const None = (globalThis[Symbol.for(`workman.basis.ctor.${NONE_ID}`)] ??= Object.freeze({
|
|
11
|
+
ctor: NONE_ID,
|
|
12
|
+
name: "None",
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
export function Some(value) {
|
|
16
|
+
return { ctor: SOME_ID, name: "Some", a0: value };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function checked(option) {
|
|
20
|
+
if (option === None || option?.ctor === SOME_ID) return option;
|
|
21
|
+
throw new TypeError("Expected a Workman Option");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isSome(option) {
|
|
25
|
+
return checked(option) !== None;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isNone(option) {
|
|
29
|
+
return checked(option) === None;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getOr(option, fallback) {
|
|
33
|
+
return checked(option) === None ? fallback : option.a0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function match(option, cases) {
|
|
37
|
+
return checked(option) === None ? cases.none() : cases.some(option.a0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function fromNullable(value) {
|
|
41
|
+
return value == null ? None : Some(value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function toNullable(option) {
|
|
45
|
+
return checked(option) === None ? undefined : option.a0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function Ok(value) {
|
|
49
|
+
return { ok: true, value };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function Err(error) {
|
|
53
|
+
return { ok: false, error };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const JS_ERROR_ID = -7;
|
|
57
|
+
|
|
58
|
+
/** The message of a WM Js.Error, or undefined for Js.Unknown (a thrown non-Error value). */
|
|
59
|
+
export function jsErrorMessage(error) {
|
|
60
|
+
return error?.ctor === JS_ERROR_ID ? error.a0 : undefined;
|
|
61
|
+
}
|