@yaks/process 0.0.0-stage → 0.2.36
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 +202 -0
- package/README.md +249 -2
- package/_dist/clock.d.ts +5 -0
- package/_dist/clock.d.ts.map +1 -0
- package/_dist/command.d.ts +43 -0
- package/_dist/command.d.ts.map +1 -0
- package/_dist/comp.d.ts +49 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/env.d.ts +8 -0
- package/_dist/env.d.ts.map +1 -0
- package/_dist/graph.d.ts +3 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/http.d.ts +11 -0
- package/_dist/http.d.ts.map +1 -0
- package/_dist/isolate.d.ts +11 -0
- package/_dist/isolate.d.ts.map +1 -0
- package/_dist/mod.d.ts +49 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/modules.d.ts +31 -0
- package/_dist/modules.d.ts.map +1 -0
- package/_dist/platform.d.ts +7 -0
- package/_dist/platform.d.ts.map +1 -0
- package/_dist/plugin.d.ts +15 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/run.d.ts +219 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/self.d.ts +32 -0
- package/_dist/self.d.ts.map +1 -0
- package/_dist/socket.d.ts +11 -0
- package/_dist/socket.d.ts.map +1 -0
- package/_dist/store.d.ts +22 -0
- package/_dist/store.d.ts.map +1 -0
- package/_dist/system.d.ts +64 -0
- package/_dist/system.d.ts.map +1 -0
- package/_dist/trash.d.ts +6 -0
- package/_dist/trash.d.ts.map +1 -0
- package/_dist/views.d.ts +4 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +8 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/wind.d.ts +35 -0
- package/_dist/wind.d.ts.map +1 -0
- package/clock.js +11 -0
- package/clock.js.map +1 -0
- package/clock.ts +11 -0
- package/command.js +172 -0
- package/command.js.map +1 -0
- package/command.ts +215 -0
- package/comp.js +54 -0
- package/comp.js.map +1 -0
- package/comp.ts +123 -0
- package/deno.json +1 -0
- package/detached.js +60 -0
- package/detached.js.map +1 -0
- package/detached.ts +92 -0
- package/detached_worker.ts +22 -0
- package/env.js +13 -0
- package/env.js.map +1 -0
- package/env.ts +24 -0
- package/graph.js +7 -0
- package/graph.js.map +1 -0
- package/graph.ts +8 -0
- package/http.js +158 -0
- package/http.js.map +1 -0
- package/http.ts +184 -0
- package/isolate.js +41 -0
- package/isolate.js.map +1 -0
- package/isolate.ts +52 -0
- package/mod.js +49 -0
- package/mod.js.map +1 -0
- package/mod.ts +50 -0
- package/modules.js +41 -0
- package/modules.js.map +1 -0
- package/modules.ts +69 -0
- package/package.json +81 -4
- package/platform.js +9 -0
- package/platform.js.map +1 -0
- package/platform.ts +9 -0
- package/plugin.js +27 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +28 -0
- package/run.js +899 -0
- package/run.js.map +1 -0
- package/run.ts +1139 -0
- package/self.js +93 -0
- package/self.js.map +1 -0
- package/self.ts +144 -0
- package/socket.js +38 -0
- package/socket.js.map +1 -0
- package/socket.ts +49 -0
- package/store.js +30 -0
- package/store.js.map +1 -0
- package/store.ts +50 -0
- package/system.js +161 -0
- package/system.js.map +1 -0
- package/system.ts +216 -0
- package/testing.ts +39 -0
- package/tidy.ts +28 -0
- package/trash.js +117 -0
- package/trash.js.map +1 -0
- package/trash.ts +117 -0
- package/views.js +28 -0
- package/views.js.map +1 -0
- package/views.ts +30 -0
- package/vocab.js +16 -0
- package/vocab.js.map +1 -0
- package/vocab.json +154 -0
- package/vocab.ts +18 -0
- package/wind.js +88 -0
- package/wind.js.map +1 -0
- package/wind.ts +114 -0
package/mod.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/process — a running program as an entity, so whatever needs one can
|
|
3
|
+
* point at it instead of keeping a pid of its own.
|
|
4
|
+
*
|
|
5
|
+
* - `service{command, cwd, restart, attempts}` — a program that should run,
|
|
6
|
+
* stored on the same entity its process lands on. The supervisor acts on
|
|
7
|
+
* this component, and a `stop` component beside it means the program is no
|
|
8
|
+
* longer wanted.
|
|
9
|
+
* - `process{pid, command, cwd}` — a program running on this machine;
|
|
10
|
+
* `command` and `cwd` are present exactly when we launched it.
|
|
11
|
+
* - `exit{code}` — it is over, and how. Absent means running.
|
|
12
|
+
* - output stays in the run's stdout and stderr files, never the graph:
|
|
13
|
+
* {@link tail} reads their last lines, {@link clean} removes them, and
|
|
14
|
+
* {@link sweep} removes every run's that ended long enough ago.
|
|
15
|
+
*
|
|
16
|
+
* The program doing the launching is one too: {@link started} and
|
|
17
|
+
* {@link ended} return the components a process writes about itself on the way
|
|
18
|
+
* in and the way out (./self.ts). That is the entity the server signs its
|
|
19
|
+
* writes with, and the one a start-up effect handler fires on.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { launch, store, supervise, tail, watch } from '@yaks/process'
|
|
23
|
+
*
|
|
24
|
+
* // let processes = store(graph)
|
|
25
|
+
* // let run = await launch(processes, { command: 'sh', args: ['-c', 'echo hi'] })
|
|
26
|
+
* // await run.done // 0
|
|
27
|
+
* // await tail(run.eid, 40) // ['hi']
|
|
28
|
+
* // await watch(processes) // at start-up: pick the unfinished ones back up
|
|
29
|
+
* // let pass = supervise(processes) // then drive it from your own timer
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Four entry points over one loop: {@link launch} starts a process detached
|
|
33
|
+
* (a wrapper in a session of its own, beyond the host's service manager, a
|
|
34
|
+
* pidfile, a stdout file and a stderr file), {@link adopt} tracks one nobody
|
|
35
|
+
* here started, {@link watch} adopts every row with no `exit` again at
|
|
36
|
+
* start-up and records an exit code for the ones already gone, and
|
|
37
|
+
* {@link supervise} makes the machine match the `service` rows — start, start
|
|
38
|
+
* again with a bounded backoff, stop. The server can restart without taking
|
|
39
|
+
* any of those processes with it, which is the only reason the launcher is
|
|
40
|
+
* shaped the way it is, and exactly one supervisor sits above it (see
|
|
41
|
+
* ./run.ts).
|
|
42
|
+
*
|
|
43
|
+
* @module
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
export * from './comp.js'
|
|
47
|
+
export * from './self.js'
|
|
48
|
+
export * from './store.js'
|
|
49
|
+
export * from './plugin.js'
|
|
50
|
+
export * from './run.js'
|
package/modules.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// The module graph Deno resolves from a set of roots, at the process
|
|
2
|
+
// boundary: `deno info`, run in a tree under that tree's own config.
|
|
3
|
+
import { copyFile, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { command } from "./command.js";
|
|
6
|
+
import { cwd as here, execPath } from "./system.js";
|
|
7
|
+
// A root as the entry imports it. A JSON module wants its attribute: without
|
|
8
|
+
// it Deno lists the file as an error with no local path, the same entry as
|
|
9
|
+
// where the graph reaches it properly, so the file drops out of the graph.
|
|
10
|
+
let root = (url)=>`import ${JSON.stringify(url)}${/\.json$/.test(new URL(url).pathname) ? " with { type: 'json' }" : ''}`;
|
|
11
|
+
/** The module graph reached from `roots` (URLs) in the tree at `cwd`, a
|
|
12
|
+
* dynamic import of a literal specifier included, or undefined when deno
|
|
13
|
+
* cannot say. Deno resolves it by the tree's lock, and writes what it
|
|
14
|
+
* resolved anew (a module's `/// <reference types>`) to a copy, so the tree
|
|
15
|
+
* is never written. */ export let modules = async (roots, cwd = here())=>{
|
|
16
|
+
let dir = await mkdtemp(`${tmpdir()}/yaks-modules-`);
|
|
17
|
+
try {
|
|
18
|
+
let entry = `${dir}/entry.ts`;
|
|
19
|
+
await writeFile(entry, roots.map(root).join('\n'));
|
|
20
|
+
let lock = await copyFile(`${cwd}/deno.lock`, `${dir}/deno.lock`).then(()=>`--lock=${dir}/deno.lock`, ()=>'--no-lock');
|
|
21
|
+
let out = await command(execPath(), {
|
|
22
|
+
args: [
|
|
23
|
+
'info',
|
|
24
|
+
'--json',
|
|
25
|
+
lock,
|
|
26
|
+
'--frozen=false',
|
|
27
|
+
entry
|
|
28
|
+
],
|
|
29
|
+
cwd,
|
|
30
|
+
stdout: 'piped',
|
|
31
|
+
stderr: 'null'
|
|
32
|
+
}).output();
|
|
33
|
+
return out.success ? JSON.parse(new TextDecoder().decode(out.stdout)) : undefined;
|
|
34
|
+
} finally{
|
|
35
|
+
await rm(dir, {
|
|
36
|
+
recursive: true,
|
|
37
|
+
force: true
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=modules.js.map
|
package/modules.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","sources":["./modules.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,qEAAqE;AACrE,SAAS,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,QAAQ,mBAAkB;AACnE,SAAS,MAAM,QAAQ,UAAS;AAChC,SAAS,OAAO,uBAAsB;AACtC,SAAS,OAAO,IAAI,EAAE,QAAQ,sBAAqB;AAyBnD,6EAA6E;AAC7E,2EAA2E;AAC3E,2EAA2E;AAC3E,IAAI,OAAO,CAAC,MACV,CAAC,OAAO,EAAE,KAAK,SAAS,CAAC,OACvB,UAAU,IAAI,CAAC,IAAI,IAAI,KAAK,QAAQ,IAAI,2BAA2B,IACnE;AAEJ;;;;qBAIqB,GACrB,OAAO,IAAI,UAAU,OACnB,OACA,MAAc,MAAM;EAEpB,IAAI,MAAM,MAAM,QAAQ,GAAG,SAAS,cAAc,CAAC;EACnD,IAAI;IACF,IAAI,QAAQ,GAAG,IAAI,SAAS,CAAC;IAC7B,MAAM,UACJ,OACA,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC;IAEvB,IAAI,OAAO,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,EAAE,GAAG,IAAI,UAAU,CAAC,EAC7D,IAAI,CAAC,IAAM,CAAC,OAAO,EAAE,IAAI,UAAU,CAAC,EAAE,IAAM;IAC/C,IAAI,MAAM,MAAM,QAAQ,YAAY;MAClC,MAAM;QAAC;QAAQ;QAAU;QAAM;QAAkB;OAAM;MACvD;MACA,QAAQ;MACR,QAAQ;IACV,GAAG,MAAM;IACT,OAAO,IAAI,OAAO,GACd,KAAK,KAAK,CAAC,IAAI,cAAc,MAAM,CAAC,IAAI,MAAM,KAC9C;EACN,SAAU;IACR,MAAM,GAAG,KAAK;MAAE,WAAW;MAAM,OAAO;IAAK;EAC/C;AACF,EAAC"}
|
package/modules.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// The module graph Deno resolves from a set of roots, at the process
|
|
2
|
+
// boundary: `deno info`, run in a tree under that tree's own config.
|
|
3
|
+
import { copyFile, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { command } from './command.js'
|
|
6
|
+
import { cwd as here, execPath } from './system.js'
|
|
7
|
+
|
|
8
|
+
/** A module graph, as `deno info --json` says one. */
|
|
9
|
+
export type Info = {
|
|
10
|
+
modules: {
|
|
11
|
+
specifier: string
|
|
12
|
+
local?: string
|
|
13
|
+
kind?: string
|
|
14
|
+
mediaType?: string
|
|
15
|
+
npmPackage?: string
|
|
16
|
+
dependencies?: {
|
|
17
|
+
specifier?: string
|
|
18
|
+
code?: { specifier?: string }
|
|
19
|
+
type?: { specifier?: string }
|
|
20
|
+
isDynamic?: boolean
|
|
21
|
+
}[]
|
|
22
|
+
}[]
|
|
23
|
+
redirects: Record<string, string>
|
|
24
|
+
npmPackages?: Record<string, {
|
|
25
|
+
name: string
|
|
26
|
+
dependencies: string[]
|
|
27
|
+
localPath: string
|
|
28
|
+
}>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// A root as the entry imports it. A JSON module wants its attribute: without
|
|
32
|
+
// it Deno lists the file as an error with no local path, the same entry as
|
|
33
|
+
// where the graph reaches it properly, so the file drops out of the graph.
|
|
34
|
+
let root = (url: string) =>
|
|
35
|
+
`import ${JSON.stringify(url)}${
|
|
36
|
+
/\.json$/.test(new URL(url).pathname) ? " with { type: 'json' }" : ''
|
|
37
|
+
}`
|
|
38
|
+
|
|
39
|
+
/** The module graph reached from `roots` (URLs) in the tree at `cwd`, a
|
|
40
|
+
* dynamic import of a literal specifier included, or undefined when deno
|
|
41
|
+
* cannot say. Deno resolves it by the tree's lock, and writes what it
|
|
42
|
+
* resolved anew (a module's `/// <reference types>`) to a copy, so the tree
|
|
43
|
+
* is never written. */
|
|
44
|
+
export let modules = async (
|
|
45
|
+
roots: string[],
|
|
46
|
+
cwd: string = here(),
|
|
47
|
+
): Promise<Info | undefined> => {
|
|
48
|
+
let dir = await mkdtemp(`${tmpdir()}/yaks-modules-`)
|
|
49
|
+
try {
|
|
50
|
+
let entry = `${dir}/entry.ts`
|
|
51
|
+
await writeFile(
|
|
52
|
+
entry,
|
|
53
|
+
roots.map(root).join('\n'),
|
|
54
|
+
)
|
|
55
|
+
let lock = await copyFile(`${cwd}/deno.lock`, `${dir}/deno.lock`)
|
|
56
|
+
.then(() => `--lock=${dir}/deno.lock`, () => '--no-lock')
|
|
57
|
+
let out = await command(execPath(), {
|
|
58
|
+
args: ['info', '--json', lock, '--frozen=false', entry],
|
|
59
|
+
cwd,
|
|
60
|
+
stdout: 'piped',
|
|
61
|
+
stderr: 'null',
|
|
62
|
+
}).output()
|
|
63
|
+
return out.success
|
|
64
|
+
? JSON.parse(new TextDecoder().decode(out.stdout))
|
|
65
|
+
: undefined
|
|
66
|
+
} finally {
|
|
67
|
+
await rm(dir, { recursive: true, force: true })
|
|
68
|
+
}
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaks/process",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.36",
|
|
4
|
+
"homepage": "https://jsr.io/@yaks/process",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./_dist/mod.d.ts",
|
|
9
|
+
"default": "./mod.js"
|
|
10
|
+
},
|
|
11
|
+
"./vocab": {
|
|
12
|
+
"types": "./_dist/vocab.d.ts",
|
|
13
|
+
"default": "./vocab.js"
|
|
14
|
+
},
|
|
15
|
+
"./graph": {
|
|
16
|
+
"types": "./_dist/graph.d.ts",
|
|
17
|
+
"default": "./graph.js"
|
|
18
|
+
},
|
|
19
|
+
"./self": {
|
|
20
|
+
"types": "./_dist/self.d.ts",
|
|
21
|
+
"default": "./self.js"
|
|
22
|
+
},
|
|
23
|
+
"./wind": {
|
|
24
|
+
"types": "./_dist/wind.d.ts",
|
|
25
|
+
"default": "./wind.js"
|
|
26
|
+
},
|
|
27
|
+
"./isolate": {
|
|
28
|
+
"types": "./_dist/isolate.d.ts",
|
|
29
|
+
"default": "./isolate.js"
|
|
30
|
+
},
|
|
31
|
+
"./views": {
|
|
32
|
+
"types": "./_dist/views.d.ts",
|
|
33
|
+
"default": "./views.js"
|
|
34
|
+
},
|
|
35
|
+
"./http": {
|
|
36
|
+
"types": "./_dist/http.d.ts",
|
|
37
|
+
"default": "./http.js"
|
|
38
|
+
},
|
|
39
|
+
"./system": {
|
|
40
|
+
"types": "./_dist/system.d.ts",
|
|
41
|
+
"default": "./system.js"
|
|
42
|
+
},
|
|
43
|
+
"./env": {
|
|
44
|
+
"types": "./_dist/env.d.ts",
|
|
45
|
+
"default": "./env.js"
|
|
46
|
+
},
|
|
47
|
+
"./platform": {
|
|
48
|
+
"types": "./_dist/platform.d.ts",
|
|
49
|
+
"default": "./platform.js"
|
|
50
|
+
},
|
|
51
|
+
"./command": {
|
|
52
|
+
"types": "./_dist/command.d.ts",
|
|
53
|
+
"default": "./command.js"
|
|
54
|
+
},
|
|
55
|
+
"./modules": {
|
|
56
|
+
"types": "./_dist/modules.d.ts",
|
|
57
|
+
"default": "./modules.js"
|
|
58
|
+
},
|
|
59
|
+
"./socket": {
|
|
60
|
+
"types": "./_dist/socket.d.ts",
|
|
61
|
+
"default": "./socket.js"
|
|
62
|
+
},
|
|
63
|
+
"./clock": {
|
|
64
|
+
"types": "./_dist/clock.d.ts",
|
|
65
|
+
"default": "./clock.js"
|
|
66
|
+
},
|
|
67
|
+
"./trash": {
|
|
68
|
+
"types": "./_dist/trash.d.ts",
|
|
69
|
+
"default": "./trash.js"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"license": "Apache-2.0",
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@yaks/fp": "0.2.36",
|
|
75
|
+
"@yaks/graph": "0.2.36",
|
|
76
|
+
"@yaks/query": "0.2.36",
|
|
77
|
+
"@yaks/render": "0.2.36",
|
|
78
|
+
"@yaks/vocab": "0.2.36",
|
|
79
|
+
"undici": "^7.28.0"
|
|
80
|
+
},
|
|
81
|
+
"description": "Starts, adopts and supervises operating-system processes, recording each one as a graph entity with its pid and exit code.",
|
|
82
|
+
"repository": "https://github.com/yak-sh/yak.git"
|
|
83
|
+
}
|
package/platform.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Platform metadata without loading operating-system or terminal operations.
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
export let os = process.platform == 'win32' ? 'windows' : process.platform;
|
|
4
|
+
export let build = {
|
|
5
|
+
os,
|
|
6
|
+
arch: process.arch,
|
|
7
|
+
target: `${process.arch}-${process.platform}`
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=platform.js.map
|
package/platform.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sources":["./platform.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,OAAO,aAAa,eAAc;AAElC,OAAO,IAAI,KAAK,QAAQ,QAAQ,IAAI,UAAU,YAAY,QAAQ,QAAQ,CAAA;AAC1E,OAAO,IAAI,QAAQ;EACjB;EACA,MAAM,QAAQ,IAAI;EAClB,QAAQ,GAAG,QAAQ,IAAI,CAAC,CAAC,EAAE,QAAQ,QAAQ,EAAE;AAC/C,EAAC"}
|
package/platform.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Platform metadata without loading operating-system or terminal operations.
|
|
2
|
+
import process from 'node:process'
|
|
3
|
+
|
|
4
|
+
export let os = process.platform == 'win32' ? 'windows' : process.platform
|
|
5
|
+
export let build = {
|
|
6
|
+
os,
|
|
7
|
+
arch: process.arch,
|
|
8
|
+
target: `${process.arch}-${process.platform}`,
|
|
9
|
+
}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The package as a graph plugin: the vocabulary, and nothing else.
|
|
2
|
+
//
|
|
3
|
+
// There is no hook here on purpose. Everything this package decides is decided
|
|
4
|
+
// by the process that can see pids — whether a process is alive is not a fact
|
|
5
|
+
// about the transaction being written, and a rule that pretended otherwise
|
|
6
|
+
// would be guessing. The graph holds what was observed; ./run.ts is what
|
|
7
|
+
// observes.
|
|
8
|
+
import { processDoc } from "./comp.js";
|
|
9
|
+
/**
|
|
10
|
+
* The process plugin: `process{pid, command, cwd}` and `exit{code}`.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { graph } from '@yaks/graph'
|
|
14
|
+
* import { ram } from '@yaks/ram'
|
|
15
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
16
|
+
* import { processDoc, processes } from '@yaks/process'
|
|
17
|
+
*
|
|
18
|
+
* let vocab = loadVocab([processDoc])
|
|
19
|
+
* let g = graph({ storage: ram(vocab), vocab, plugins: [processes()] })
|
|
20
|
+
* ```
|
|
21
|
+
*/ export let processes = ()=>({
|
|
22
|
+
name: '@yaks/process',
|
|
23
|
+
vocab: [
|
|
24
|
+
processDoc
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=plugin.js.map
|
package/plugin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["./plugin.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,yEAAyE;AACzE,YAAY;AAGZ,SAAS,UAAU,oBAAmB;AAEtC;;;;;;;;;;;;CAYC,GACD,OAAO,IAAI,YAAY,IAAc,CAAC;IACpC,MAAM;IACN,OAAO;MAAC;KAAW;EACrB,CAAC,EAAC"}
|
package/plugin.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The package as a graph plugin: the vocabulary, and nothing else.
|
|
2
|
+
//
|
|
3
|
+
// There is no hook here on purpose. Everything this package decides is decided
|
|
4
|
+
// by the process that can see pids — whether a process is alive is not a fact
|
|
5
|
+
// about the transaction being written, and a rule that pretended otherwise
|
|
6
|
+
// would be guessing. The graph holds what was observed; ./run.ts is what
|
|
7
|
+
// observes.
|
|
8
|
+
|
|
9
|
+
import type { Plugin } from 'jsr:@yaks/graph@0.2.36'
|
|
10
|
+
import { processDoc } from './comp.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The process plugin: `process{pid, command, cwd}` and `exit{code}`.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { graph } from '@yaks/graph'
|
|
17
|
+
* import { ram } from '@yaks/ram'
|
|
18
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
19
|
+
* import { processDoc, processes } from '@yaks/process'
|
|
20
|
+
*
|
|
21
|
+
* let vocab = loadVocab([processDoc])
|
|
22
|
+
* let g = graph({ storage: ram(vocab), vocab, plugins: [processes()] })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export let processes = (): Plugin => ({
|
|
26
|
+
name: '@yaks/process',
|
|
27
|
+
vocab: [processDoc],
|
|
28
|
+
})
|