dirsql 0.4.38 → 0.4.40

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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Keep Ctrl-C fatal while the CLI runs in-process.
3
+ *
4
+ * The core installs tokio signal handlers for `dirsql server`, and
5
+ * signal-hook (which tokio uses) *chains*: it runs its own actions and then
6
+ * the handler installed before it. CPython installs `default_int_handler` at
7
+ * startup, so the pip launcher gets a terminating disposition for free —
8
+ * bare Node leaves `SIG_DFL`, which signal-hook does not emulate, so the
9
+ * signal is swallowed and the process becomes SIGKILL-only (measured: a
10
+ * probe ignored SIGTERM for 143 seconds).
11
+ *
12
+ * Registering a JS listener first gives signal-hook a real prior handler to
13
+ * chain to. This cannot be fixed after the fact: `removeAllListeners` only
14
+ * drops JS listeners and cannot touch a disposition installed by native
15
+ * code, and `unregister_signal` leaves the OS handler in place. One listener
16
+ * is the whole remedy — no `unsafe`, no `sigaction`.
17
+ */
18
+ export declare function keepSignalsFatal(): void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Keep Ctrl-C fatal while the CLI runs in-process.
3
+ *
4
+ * The core installs tokio signal handlers for `dirsql server`, and
5
+ * signal-hook (which tokio uses) *chains*: it runs its own actions and then
6
+ * the handler installed before it. CPython installs `default_int_handler` at
7
+ * startup, so the pip launcher gets a terminating disposition for free —
8
+ * bare Node leaves `SIG_DFL`, which signal-hook does not emulate, so the
9
+ * signal is swallowed and the process becomes SIGKILL-only (measured: a
10
+ * probe ignored SIGTERM for 143 seconds).
11
+ *
12
+ * Registering a JS listener first gives signal-hook a real prior handler to
13
+ * chain to. This cannot be fixed after the fact: `removeAllListeners` only
14
+ * drops JS listeners and cannot touch a disposition installed by native
15
+ * code, and `unregister_signal` leaves the OS handler in place. One listener
16
+ * is the whole remedy — no `unsafe`, no `sigaction`.
17
+ */
18
+ export function keepSignalsFatal() {
19
+ // While the core is running, its own handler drives shutdown and this
20
+ // listener is the tail of the chain; it matters for signals arriving
21
+ // outside that window, where exiting is exactly right.
22
+ process.on("SIGINT", () => process.exit(130));
23
+ process.on("SIGTERM", () => process.exit(143));
24
+ }
package/dist/cli/main.js CHANGED
@@ -6,51 +6,10 @@
6
6
  // `@dirsql/lib-*` addon the SDK loads carries the CLI, so a package ships one
7
7
  // copy of the core instead of two (#739).
8
8
  import { mainInProcess } from "bin-shim";
9
- import { loadNativeCore } from "../load-native-core.js";
10
9
  import { die } from "./die.js";
10
+ import { keepSignalsFatal } from "./keep-signals-fatal.js";
11
11
  import { withResolvedExtensions } from "./resolve-config-extensions.js";
12
- /**
13
- * Resolve `runCli` off the same addon the SDK loads.
14
- *
15
- * bin-shim can resolve an addon itself, but its default naming is
16
- * `@{scope}/lib-{platform}-{arch}`, which cannot express the ABI suffix
17
- * dirsql's packages carry (`@dirsql/lib-linux-x64-gnu`). Reusing
18
- * `loadNativeCore` keeps one resolution rule for the SDK and the CLI —
19
- * including its dev fallback to a locally built `dirsql.node` — so a
20
- * monorepo checkout and a published install take the same path.
21
- */
22
- function resolveRunCli() {
23
- const core = loadNativeCore();
24
- if (typeof core.runCli !== "function") {
25
- throw new Error("dirsql: the native addon has no callable `runCli` export; " +
26
- "it was built without the `cli` feature.");
27
- }
28
- return core.runCli;
29
- }
30
- /**
31
- * Keep Ctrl-C fatal while the CLI runs in-process.
32
- *
33
- * The core installs tokio signal handlers for `dirsql server`, and
34
- * signal-hook (which tokio uses) *chains*: it runs its own actions and then
35
- * the handler installed before it. CPython installs `default_int_handler` at
36
- * startup, so the pip launcher gets a terminating disposition for free —
37
- * bare Node leaves `SIG_DFL`, which signal-hook does not emulate, so the
38
- * signal is swallowed and the process becomes SIGKILL-only (measured: a
39
- * probe ignored SIGTERM for 143 seconds).
40
- *
41
- * Registering a JS listener first gives signal-hook a real prior handler to
42
- * chain to. This cannot be fixed after the fact: `removeAllListeners` only
43
- * drops JS listeners and cannot touch a disposition installed by native
44
- * code, and `unregister_signal` leaves the OS handler in place. One listener
45
- * is the whole remedy — no `unsafe`, no `sigaction`.
46
- */
47
- function keepSignalsFatal() {
48
- // While the core is running, its own handler drives shutdown and this
49
- // listener is the tail of the chain; it matters for signals arriving
50
- // outside that window, where exiting is exactly right.
51
- process.on("SIGINT", () => process.exit(130));
52
- process.on("SIGTERM", () => process.exit(143));
53
- }
12
+ import { resolveRunCli } from "./resolve-run-cli.js";
54
13
  export async function main(argv = process.argv.slice(2)) {
55
14
  keepSignalsFatal();
56
15
  // Resolve any package-name extensions in a TOML config here (the core
@@ -0,0 +1,13 @@
1
+ /** The addon's CLI entry point, as napi exports it. */
2
+ export type RunCli = (argv: readonly string[]) => number;
3
+ /**
4
+ * Resolve `runCli` off the same addon the SDK loads.
5
+ *
6
+ * bin-shim can resolve an addon itself, but its default naming is
7
+ * `@{scope}/lib-{platform}-{arch}`, which cannot express the ABI suffix
8
+ * dirsql's packages carry (`@dirsql/lib-linux-x64-gnu`). Reusing
9
+ * `loadNativeCore` keeps one resolution rule for the SDK and the CLI —
10
+ * including its dev fallback to a locally built `dirsql.node` — so a
11
+ * monorepo checkout and a published install take the same path.
12
+ */
13
+ export declare function resolveRunCli(): RunCli;
@@ -0,0 +1,19 @@
1
+ import { loadNativeCore } from "../load-native-core.js";
2
+ /**
3
+ * Resolve `runCli` off the same addon the SDK loads.
4
+ *
5
+ * bin-shim can resolve an addon itself, but its default naming is
6
+ * `@{scope}/lib-{platform}-{arch}`, which cannot express the ABI suffix
7
+ * dirsql's packages carry (`@dirsql/lib-linux-x64-gnu`). Reusing
8
+ * `loadNativeCore` keeps one resolution rule for the SDK and the CLI —
9
+ * including its dev fallback to a locally built `dirsql.node` — so a
10
+ * monorepo checkout and a published install take the same path.
11
+ */
12
+ export function resolveRunCli() {
13
+ const core = loadNativeCore();
14
+ if (typeof core.runCli !== "function") {
15
+ throw new Error("dirsql: the native addon has no callable `runCli` export; " +
16
+ "it was built without the `cli` feature.");
17
+ }
18
+ return core.runCli;
19
+ }
@@ -0,0 +1,8 @@
1
+ import type { Platform } from "./platforms.js";
2
+ /**
3
+ * Suffix used in the napi `.node` filename for a given triple. Follows the
4
+ * `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
5
+ * `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
6
+ * on-disk artifact name and the npm package name can't drift.
7
+ */
8
+ export declare function librarySlug(p: Platform): string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Suffix used in the napi `.node` filename for a given triple. Follows the
3
+ * `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
4
+ * `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
5
+ * on-disk artifact name and the npm package name can't drift.
6
+ */
7
+ export function librarySlug(p) {
8
+ const prefix = "@dirsql/lib-";
9
+ if (!p.libName.startsWith(prefix)) {
10
+ throw new Error(`libName ${p.libName} missing ${prefix} prefix`);
11
+ }
12
+ return p.libName.slice(prefix.length);
13
+ }
@@ -0,0 +1,2 @@
1
+ /** Loadable-file glob suffix(es) for the current platform. */
2
+ export declare function platformSuffixes(): string[];
@@ -0,0 +1,10 @@
1
+ /** Loadable-file glob suffix(es) for the current platform. */
2
+ export function platformSuffixes() {
3
+ if (process.platform === "darwin") {
4
+ return [".dylib", ".node"];
5
+ }
6
+ if (process.platform === "win32") {
7
+ return [".dll", ".node"];
8
+ }
9
+ return [".so", ".node"];
10
+ }
@@ -17,10 +17,3 @@ export interface Platform {
17
17
  export declare const PLATFORMS: readonly Platform[];
18
18
  /** Node `${platform}-${arch}` → `@dirsql/lib-*` napi sub-package name. */
19
19
  export declare function libTriples(): Record<string, string>;
20
- /**
21
- * Suffix used in the napi `.node` filename for a given triple. Follows the
22
- * `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
23
- * `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
24
- * on-disk artifact name and the npm package name can't drift.
25
- */
26
- export declare function librarySlug(p: Platform): string;
package/dist/platforms.js CHANGED
@@ -1,7 +1,11 @@
1
- // Single source of truth for the target platforms `dirsql` publishes.
1
+ // The target platforms `dirsql` publishes. The rows live in `platforms.json`,
2
+ // the one declarative copy of the table: this module types it, and the node
3
+ // distcheck flow (`internals/distcheck/.../node_flow/platforms.py`) reads the
4
+ // same file. The JSON sits under `src/` so `tsc` emits it into `dist/` and it
5
+ // ships with the package -- `loadNativeCore()` needs the map at runtime.
2
6
  //
3
7
  // Every target triple generates ONE npm sub-package: `@dirsql/lib-<slug>`,
4
- // holding the napi-rs `.node` addon. It backs both layers — the TypeScript
8
+ // holding the napi-rs `.node` addon. It backs both layers -- the TypeScript
5
9
  // SDK loads it via `loadNativeCore()`, and since #739 the `dirsql` CLI runs
6
10
  // in-process through its `runCli` export rather than spawning a binary. The
7
11
  // second family, `@dirsql/cli-<slug>`, shipped a redundant copy of the same
@@ -12,50 +16,11 @@
12
16
  //
13
17
  // `libTriples()` returns a `${process.platform}-${process.arch}` →
14
18
  // sub-package-name map.
15
- export const PLATFORMS = [
16
- {
17
- triple: "x86_64-unknown-linux-gnu",
18
- nodePlatform: "linux",
19
- nodeArch: "x64",
20
- libName: "@dirsql/lib-linux-x64-gnu",
21
- os: ["linux"],
22
- cpu: ["x64"],
23
- libc: ["glibc"],
24
- },
25
- {
26
- triple: "aarch64-unknown-linux-gnu",
27
- nodePlatform: "linux",
28
- nodeArch: "arm64",
29
- libName: "@dirsql/lib-linux-arm64-gnu",
30
- os: ["linux"],
31
- cpu: ["arm64"],
32
- libc: ["glibc"],
33
- },
34
- {
35
- triple: "x86_64-apple-darwin",
36
- nodePlatform: "darwin",
37
- nodeArch: "x64",
38
- libName: "@dirsql/lib-darwin-x64",
39
- os: ["darwin"],
40
- cpu: ["x64"],
41
- },
42
- {
43
- triple: "aarch64-apple-darwin",
44
- nodePlatform: "darwin",
45
- nodeArch: "arm64",
46
- libName: "@dirsql/lib-darwin-arm64",
47
- os: ["darwin"],
48
- cpu: ["arm64"],
49
- },
50
- {
51
- triple: "x86_64-pc-windows-msvc",
52
- nodePlatform: "win32",
53
- nodeArch: "x64",
54
- libName: "@dirsql/lib-win32-x64-msvc",
55
- os: ["win32"],
56
- cpu: ["x64"],
57
- },
58
- ];
19
+ import rows from "./platforms.json" with { type: "json" };
20
+ // JSON widens `nodePlatform` / `nodeArch` to `string`, which no data file can
21
+ // carry as `NodeJS.Platform` / `NodeJS.Architecture`. The cast is the only
22
+ // place the two vocabularies meet.
23
+ export const PLATFORMS = rows;
59
24
  /** Node `${platform}-${arch}` → `@dirsql/lib-*` napi sub-package name. */
60
25
  export function libTriples() {
61
26
  const out = {};
@@ -64,16 +29,3 @@ export function libTriples() {
64
29
  }
65
30
  return out;
66
31
  }
67
- /**
68
- * Suffix used in the napi `.node` filename for a given triple. Follows the
69
- * `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
70
- * `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
71
- * on-disk artifact name and the npm package name can't drift.
72
- */
73
- export function librarySlug(p) {
74
- const prefix = "@dirsql/lib-";
75
- if (!p.libName.startsWith(prefix)) {
76
- throw new Error(`libName ${p.libName} missing ${prefix} prefix`);
77
- }
78
- return p.libName.slice(prefix.length);
79
- }
@@ -0,0 +1,44 @@
1
+ [
2
+ {
3
+ "triple": "x86_64-unknown-linux-gnu",
4
+ "nodePlatform": "linux",
5
+ "nodeArch": "x64",
6
+ "libName": "@dirsql/lib-linux-x64-gnu",
7
+ "os": ["linux"],
8
+ "cpu": ["x64"],
9
+ "libc": ["glibc"]
10
+ },
11
+ {
12
+ "triple": "aarch64-unknown-linux-gnu",
13
+ "nodePlatform": "linux",
14
+ "nodeArch": "arm64",
15
+ "libName": "@dirsql/lib-linux-arm64-gnu",
16
+ "os": ["linux"],
17
+ "cpu": ["arm64"],
18
+ "libc": ["glibc"]
19
+ },
20
+ {
21
+ "triple": "x86_64-apple-darwin",
22
+ "nodePlatform": "darwin",
23
+ "nodeArch": "x64",
24
+ "libName": "@dirsql/lib-darwin-x64",
25
+ "os": ["darwin"],
26
+ "cpu": ["x64"]
27
+ },
28
+ {
29
+ "triple": "aarch64-apple-darwin",
30
+ "nodePlatform": "darwin",
31
+ "nodeArch": "arm64",
32
+ "libName": "@dirsql/lib-darwin-arm64",
33
+ "os": ["darwin"],
34
+ "cpu": ["arm64"]
35
+ },
36
+ {
37
+ "triple": "x86_64-pc-windows-msvc",
38
+ "nodePlatform": "win32",
39
+ "nodeArch": "x64",
40
+ "libName": "@dirsql/lib-win32-x64-msvc",
41
+ "os": ["win32"],
42
+ "cpu": ["x64"]
43
+ }
44
+ ]
@@ -2,16 +2,7 @@
2
2
  import { readdirSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { packageDir } from "./package-dir.js";
5
- /** Loadable-file glob suffix(es) for the current platform. */
6
- function platformSuffixes() {
7
- if (process.platform === "darwin") {
8
- return [".dylib", ".node"];
9
- }
10
- if (process.platform === "win32") {
11
- return [".dll", ".node"];
12
- }
13
- return [".so", ".node"];
14
- }
5
+ import { platformSuffixes } from "./platform-suffixes.js";
15
6
  /** Glob the platform loadable inside a bare name's package dir. */
16
7
  export function resolvePackage(name, resolver) {
17
8
  const dir = packageDir(name, resolver);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.4.38",
3
+ "version": "0.4.40",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -59,6 +59,7 @@
59
59
  "command": "tsc -p tsconfig.build.json",
60
60
  "files": [
61
61
  "src/**/*.ts",
62
+ "src/**/*.json",
62
63
  "tsconfig.json",
63
64
  "tsconfig.build.json"
64
65
  ],
@@ -74,6 +75,7 @@
74
75
  "files": [
75
76
  "tools/stage-platform.ts",
76
77
  "src/platforms.ts",
78
+ "src/platforms.json",
77
79
  "napi/src/**/*.rs",
78
80
  "napi/build.rs",
79
81
  "napi/Cargo.toml",
@@ -99,6 +101,7 @@
99
101
  "napi/Cargo.toml",
100
102
  "../rust/src/**/*.rs",
101
103
  "src/**/*.ts",
104
+ "src/**/*.json",
102
105
  "tsconfig.json",
103
106
  "tsconfig.build.json"
104
107
  ],
@@ -116,6 +119,7 @@
116
119
  ],
117
120
  "files": [
118
121
  "src/**/*.ts",
122
+ "src/**/*.json",
119
123
  "tools/**/*.ts",
120
124
  "tests/**/*.ts",
121
125
  "vitest.config.ts"
@@ -129,6 +133,7 @@
129
133
  ],
130
134
  "files": [
131
135
  "src/**/*.ts",
136
+ "src/**/*.json",
132
137
  "vitest.config.ts"
133
138
  ],
134
139
  "output": []
@@ -137,6 +142,7 @@
137
142
  "command": "vitest run --dir tests/integration/hermetic --passWithNoTests",
138
143
  "files": [
139
144
  "src/**/*.ts",
145
+ "src/**/*.json",
140
146
  "tests/integration/hermetic/**/*.ts",
141
147
  "vitest.config.ts"
142
148
  ],
@@ -150,6 +156,7 @@
150
156
  ],
151
157
  "files": [
152
158
  "src/**/*.ts",
159
+ "src/**/*.json",
153
160
  "tools/**/*.ts",
154
161
  "tests/integration/binding/**/*.ts",
155
162
  "tests/exists.ts",
@@ -164,6 +171,7 @@
164
171
  ],
165
172
  "files": [
166
173
  "src/**/*.ts",
174
+ "src/**/*.json",
167
175
  "tools/**/*.ts",
168
176
  "tests/e2e/**/*.ts",
169
177
  "vitest.config.ts",
@@ -179,6 +187,7 @@
179
187
  ],
180
188
  "files": [
181
189
  "src/**/*.ts",
190
+ "src/**/*.json",
182
191
  "tools/**/*.ts",
183
192
  "tests/integration/**/*.ts",
184
193
  "tests/exists.ts",
@@ -213,10 +222,10 @@
213
222
  ]
214
223
  },
215
224
  "optionalDependencies": {
216
- "@dirsql/lib-linux-x64-gnu": "0.4.38",
217
- "@dirsql/lib-linux-arm64-gnu": "0.4.38",
218
- "@dirsql/lib-darwin-x64": "0.4.38",
219
- "@dirsql/lib-darwin-arm64": "0.4.38",
220
- "@dirsql/lib-win32-x64-msvc": "0.4.38"
225
+ "@dirsql/lib-linux-x64-gnu": "0.4.40",
226
+ "@dirsql/lib-linux-arm64-gnu": "0.4.40",
227
+ "@dirsql/lib-darwin-x64": "0.4.40",
228
+ "@dirsql/lib-darwin-arm64": "0.4.40",
229
+ "@dirsql/lib-win32-x64-msvc": "0.4.40"
221
230
  }
222
231
  }