@bluewombat/isolator 0.1.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 +94 -0
- package/SPECS.md +294 -0
- package/dist/args/parse-args.d.ts +6 -0
- package/dist/args/parse-args.d.ts.map +1 -0
- package/dist/args/parse-args.js +223 -0
- package/dist/args/parse-args.js.map +1 -0
- package/dist/child/run-child.d.ts +39 -0
- package/dist/child/run-child.d.ts.map +1 -0
- package/dist/child/run-child.js +132 -0
- package/dist/child/run-child.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +99 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/isolate/backend.d.ts +31 -0
- package/dist/isolate/backend.d.ts.map +1 -0
- package/dist/isolate/backend.js +2 -0
- package/dist/isolate/backend.js.map +1 -0
- package/dist/isolate/create-child.d.ts +26 -0
- package/dist/isolate/create-child.d.ts.map +1 -0
- package/dist/isolate/create-child.js +62 -0
- package/dist/isolate/create-child.js.map +1 -0
- package/dist/isolate/stop.d.ts +7 -0
- package/dist/isolate/stop.d.ts.map +1 -0
- package/dist/isolate/stop.js +17 -0
- package/dist/isolate/stop.js.map +1 -0
- package/dist/progress/emit.d.ts +5 -0
- package/dist/progress/emit.d.ts.map +1 -0
- package/dist/progress/emit.js +17 -0
- package/dist/progress/emit.js.map +1 -0
- package/dist/run/run-isolator.d.ts +35 -0
- package/dist/run/run-isolator.d.ts.map +1 -0
- package/dist/run/run-isolator.js +164 -0
- package/dist/run/run-isolator.js.map +1 -0
- package/dist/status/announce.d.ts +14 -0
- package/dist/status/announce.d.ts.map +1 -0
- package/dist/status/announce.js +28 -0
- package/dist/status/announce.js.map +1 -0
- package/dist/status/make-status.d.ts +7 -0
- package/dist/status/make-status.d.ts.map +1 -0
- package/dist/status/make-status.js +19 -0
- package/dist/status/make-status.js.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createChild } from "../isolate/create-child.js";
|
|
2
|
+
import { announceStatus } from "../status/announce.js";
|
|
3
|
+
import { makeStatus } from "../status/make-status.js";
|
|
4
|
+
function exitCodeFor(outcome) {
|
|
5
|
+
switch (outcome) {
|
|
6
|
+
case "isolated":
|
|
7
|
+
return 0;
|
|
8
|
+
case "failed":
|
|
9
|
+
return 1;
|
|
10
|
+
case "invalid-invocation":
|
|
11
|
+
return 2;
|
|
12
|
+
case "interrupted":
|
|
13
|
+
return 130;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function withId(id, line) {
|
|
17
|
+
if (id !== undefined) {
|
|
18
|
+
line.id = id;
|
|
19
|
+
}
|
|
20
|
+
return line;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Run one Isolator invocation to an Isolation outcome.
|
|
24
|
+
*/
|
|
25
|
+
export async function runIsolator(options) {
|
|
26
|
+
const { invocation, backend } = options;
|
|
27
|
+
const write = options.write ?? (() => { });
|
|
28
|
+
const now = options.now ?? (() => Date.now());
|
|
29
|
+
const interruptState = options.interruptFlag ?? { interrupted: false };
|
|
30
|
+
const shouldInterrupt = () => interruptState.interrupted;
|
|
31
|
+
return await runIsolation({
|
|
32
|
+
invocation,
|
|
33
|
+
backend,
|
|
34
|
+
write,
|
|
35
|
+
now,
|
|
36
|
+
shouldInterrupt,
|
|
37
|
+
cwd: options.cwd,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async function runIsolation(input) {
|
|
41
|
+
const { invocation, backend, write, now, shouldInterrupt, cwd } = input;
|
|
42
|
+
await announceStatus({
|
|
43
|
+
onStatusArgv: invocation.onStatusArgv,
|
|
44
|
+
status: makeStatus({ phase: "isolating", id: invocation.id }),
|
|
45
|
+
write,
|
|
46
|
+
shouldInterrupt,
|
|
47
|
+
cwd,
|
|
48
|
+
});
|
|
49
|
+
write(withId(invocation.id, {
|
|
50
|
+
event: "isolation-started",
|
|
51
|
+
}));
|
|
52
|
+
const deadlineMs = now() + invocation.durationMs;
|
|
53
|
+
const created = await createChild({
|
|
54
|
+
parent: invocation.parent,
|
|
55
|
+
child: invocation.child,
|
|
56
|
+
backend,
|
|
57
|
+
...(invocation.id === undefined ? {} : { id: invocation.id }),
|
|
58
|
+
deadlineMs,
|
|
59
|
+
now,
|
|
60
|
+
shouldInterrupt,
|
|
61
|
+
});
|
|
62
|
+
if (created.ok) {
|
|
63
|
+
return finishIsolation({
|
|
64
|
+
invocation,
|
|
65
|
+
write,
|
|
66
|
+
outcome: "isolated",
|
|
67
|
+
child: invocation.child,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if ("stop" in created && created.stop === "interrupt") {
|
|
71
|
+
return finishIsolation({
|
|
72
|
+
invocation,
|
|
73
|
+
write,
|
|
74
|
+
outcome: "interrupted",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if ("stop" in created && created.stop === "clock") {
|
|
78
|
+
if (shouldInterrupt()) {
|
|
79
|
+
return finishIsolation({
|
|
80
|
+
invocation,
|
|
81
|
+
write,
|
|
82
|
+
outcome: "interrupted",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return finishIsolation({
|
|
86
|
+
invocation,
|
|
87
|
+
write,
|
|
88
|
+
outcome: "failed",
|
|
89
|
+
report: "The Isolation clock fired.",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const detail = "detail" in created ? created.detail : "Isolation could not complete.";
|
|
93
|
+
if (shouldInterrupt()) {
|
|
94
|
+
return finishIsolation({
|
|
95
|
+
invocation,
|
|
96
|
+
write,
|
|
97
|
+
outcome: "interrupted",
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return finishIsolation({
|
|
101
|
+
invocation,
|
|
102
|
+
write,
|
|
103
|
+
outcome: "failed",
|
|
104
|
+
report: detail,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async function finishIsolation(input) {
|
|
108
|
+
const { invocation, write, outcome } = input;
|
|
109
|
+
await announceStatus({
|
|
110
|
+
onStatusArgv: invocation.onStatusArgv,
|
|
111
|
+
status: makeStatus({ phase: outcome, id: invocation.id }),
|
|
112
|
+
write,
|
|
113
|
+
shouldInterrupt: () => false,
|
|
114
|
+
cwd: input.cwd,
|
|
115
|
+
});
|
|
116
|
+
const finished = {
|
|
117
|
+
event: "isolation-finished",
|
|
118
|
+
outcome,
|
|
119
|
+
};
|
|
120
|
+
if (outcome === "isolated" && input.child !== undefined) {
|
|
121
|
+
finished.child = input.child;
|
|
122
|
+
}
|
|
123
|
+
if (outcome === "failed" && input.report !== undefined) {
|
|
124
|
+
finished.report = input.report;
|
|
125
|
+
}
|
|
126
|
+
write(withId(invocation.id, finished));
|
|
127
|
+
const result = {
|
|
128
|
+
outcome,
|
|
129
|
+
exitCode: exitCodeFor(outcome),
|
|
130
|
+
};
|
|
131
|
+
if (input.child !== undefined) {
|
|
132
|
+
result.child = input.child;
|
|
133
|
+
}
|
|
134
|
+
if (input.report !== undefined) {
|
|
135
|
+
result.report = input.report;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
export async function invalidInvocationResult(input) {
|
|
140
|
+
const statusInput = { phase: "invalid" };
|
|
141
|
+
if (input.id !== undefined) {
|
|
142
|
+
statusInput.id = input.id;
|
|
143
|
+
}
|
|
144
|
+
const status = makeStatus(statusInput);
|
|
145
|
+
await announceStatus({
|
|
146
|
+
onStatusArgv: input.onStatusArgv,
|
|
147
|
+
status,
|
|
148
|
+
write: input.write,
|
|
149
|
+
shouldInterrupt: () => false,
|
|
150
|
+
cwd: input.cwd,
|
|
151
|
+
});
|
|
152
|
+
input.write(withId(input.id, {
|
|
153
|
+
event: "isolation-finished",
|
|
154
|
+
outcome: "invalid-invocation",
|
|
155
|
+
report: input.reason,
|
|
156
|
+
}));
|
|
157
|
+
const result = {
|
|
158
|
+
outcome: "invalid-invocation",
|
|
159
|
+
report: input.reason,
|
|
160
|
+
exitCode: exitCodeFor("invalid-invocation"),
|
|
161
|
+
};
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=run-isolator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-isolator.js","sourceRoot":"","sources":["../../src/run/run-isolator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAuBtD,SAAS,WAAW,CAAC,OAAyB;IAC5C,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,UAAU;YACb,OAAO,CAAC,CAAC;QACX,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC;QACX,KAAK,oBAAoB;YACvB,OAAO,CAAC,CAAC;QACX,KAAK,aAAa;YAChB,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,EAAsB,EAAE,IAA6B;IACnE,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAmB;IACnD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GA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,CAAC,CAAC;IACvC,MAAM,cAAc,CAAC;QACnB,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,MAAM;QACN,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,eAAe,EAAE,GAAG,EAAE,CAAC,KAAK;QAC5B,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,CACT,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;QACf,KAAK,EAAE,oBAAoB;QAC3B,OAAO,EAAE,oBAAoB;QAC7B,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CACH,CAAC;IACF,MAAM,MAAM,GAAc;QACxB,OAAO,EAAE,oBAAoB;QAC7B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,WAAW,CAAC,oBAAoB,CAAC;KAC5C,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ProgressWriter } from "../progress/emit.js";
|
|
2
|
+
import type { Status } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Announce Status on stdout (and optionally via --on-status).
|
|
5
|
+
* --on-status never affects the Isolation outcome.
|
|
6
|
+
*/
|
|
7
|
+
export declare function announceStatus(input: {
|
|
8
|
+
onStatusArgv: string[] | undefined;
|
|
9
|
+
status: Status;
|
|
10
|
+
write: ProgressWriter;
|
|
11
|
+
shouldInterrupt: () => boolean;
|
|
12
|
+
cwd: string | undefined;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=announce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../../src/status/announce.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE;IAC1C,YAAY,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,cAAc,CAAC;IACtB,eAAe,EAAE,MAAM,OAAO,CAAC;IAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { runChild } from "../child/run-child.js";
|
|
2
|
+
import { emitStatusEvent } from "../progress/emit.js";
|
|
3
|
+
/**
|
|
4
|
+
* Announce Status on stdout (and optionally via --on-status).
|
|
5
|
+
* --on-status never affects the Isolation outcome.
|
|
6
|
+
*/
|
|
7
|
+
export async function announceStatus(input) {
|
|
8
|
+
const { status, write, shouldInterrupt, cwd } = input;
|
|
9
|
+
emitStatusEvent(write, status);
|
|
10
|
+
const onStatus = input.onStatusArgv;
|
|
11
|
+
if (onStatus === undefined) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const argv = [...onStatus];
|
|
15
|
+
if (status.id !== undefined) {
|
|
16
|
+
argv.push("--id", status.id);
|
|
17
|
+
}
|
|
18
|
+
argv.push("--label", status.label, "--phase", status.phase);
|
|
19
|
+
// Soft cap only: a hang or non-zero exit must not change the Isolation outcome.
|
|
20
|
+
await runChild({
|
|
21
|
+
argv,
|
|
22
|
+
cwd,
|
|
23
|
+
timeoutMs: 5_000,
|
|
24
|
+
timeoutClock: "isolation",
|
|
25
|
+
shouldInterrupt,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=announce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announce.js","sourceRoot":"","sources":["../../src/status/announce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAMpC;IACC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IACtD,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE/B,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC;IACpC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC3B,IAAI,MAAM,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAE5D,gFAAgF;IAChF,MAAM,QAAQ,CAAC;QACb,IAAI;QACJ,GAAG;QACH,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,WAAW;QACzB,eAAe;KAChB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Status, StatusPhase } from "../types.js";
|
|
2
|
+
export declare function buildStatusLabel(phase: StatusPhase, id: string | undefined): string;
|
|
3
|
+
export declare function makeStatus(input: {
|
|
4
|
+
phase: StatusPhase;
|
|
5
|
+
id?: string;
|
|
6
|
+
}): Status;
|
|
7
|
+
//# sourceMappingURL=make-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-status.d.ts","sourceRoot":"","sources":["../../src/status/make-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQnF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQ7E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function buildStatusLabel(phase, id) {
|
|
2
|
+
if (phase === "invalid") {
|
|
3
|
+
return "invalid";
|
|
4
|
+
}
|
|
5
|
+
if (id === undefined) {
|
|
6
|
+
throw new Error(`Status phase "${phase}" requires id.`);
|
|
7
|
+
}
|
|
8
|
+
return `${phase}:${id}`;
|
|
9
|
+
}
|
|
10
|
+
export function makeStatus(input) {
|
|
11
|
+
const { phase, id } = input;
|
|
12
|
+
const label = buildStatusLabel(phase, id);
|
|
13
|
+
const status = { phase, label };
|
|
14
|
+
if (id !== undefined) {
|
|
15
|
+
status.id = id;
|
|
16
|
+
}
|
|
17
|
+
return status;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=make-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-status.js","sourceRoot":"","sources":["../../src/status/make-status.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,KAAkB,EAAE,EAAsB;IACzE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,gBAAgB,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,GAAG,KAAK,IAAI,EAAE,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAA0C;IACnE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAC5B,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACxC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Domain types owned by Isolator. Names match the Transformer perimeter only. */
|
|
2
|
+
export type IsolationOutcome = "invalid-invocation" | "isolated" | "failed" | "interrupted";
|
|
3
|
+
export type StatusPhase = "isolating" | "isolated" | "failed" | "interrupted" | "invalid";
|
|
4
|
+
export type ClockName = "isolation";
|
|
5
|
+
export type Status = {
|
|
6
|
+
phase: StatusPhase;
|
|
7
|
+
id?: string;
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
export type Invocation = {
|
|
11
|
+
id: string;
|
|
12
|
+
parent: string;
|
|
13
|
+
child: string;
|
|
14
|
+
durationMs: number;
|
|
15
|
+
onStatusArgv?: string[];
|
|
16
|
+
};
|
|
17
|
+
export type ParseFailure = {
|
|
18
|
+
ok: false;
|
|
19
|
+
reason: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
onStatusArgv?: string[];
|
|
22
|
+
};
|
|
23
|
+
export type ParseResult = {
|
|
24
|
+
ok: true;
|
|
25
|
+
invocation: Invocation;
|
|
26
|
+
strategy: string;
|
|
27
|
+
} | ParseFailure;
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE5F,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;AAE1F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC;AAEpC,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,WAAW,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kFAAkF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bluewombat/isolator",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Transformer: snapshot a Parent directory into a new independent Child.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"mason",
|
|
8
|
+
"bluewombat"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"homepage": "https://github.com/tilap/bluewombat/tree/main/packages/kernel/isolator#readme",
|
|
12
|
+
"bugs": "https://github.com/tilap/bluewombat/issues",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/tilap/bluewombat.git",
|
|
16
|
+
"directory": "packages/kernel/isolator"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"bin": {
|
|
26
|
+
"isolator": "./dist/cli.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"SPECS.md"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24.20.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"lint": "biome check .",
|
|
41
|
+
"format": "biome check --write .",
|
|
42
|
+
"tsc": "tsc --noEmit",
|
|
43
|
+
"test": "tsx --test $(find src -name '*.test.ts')",
|
|
44
|
+
"build": "tsc -p tsconfig.build.json"
|
|
45
|
+
}
|
|
46
|
+
}
|