@dikolab/kbdb 0.1.1 → 0.1.2

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.
@@ -30,19 +30,30 @@ function resolveBaseDir(entryUrl, entryDirname) {
30
30
  return { scriptDir, cwd: process.cwd() };
31
31
  }
32
32
 
33
- // src/shared/dir-resolver/functions/resolve-worker-script.function.ts
33
+ // src/shared/dir-resolver/functions/join-path.function.ts
34
34
  import { join } from "node:path";
35
+ function isRemoteUrl(path) {
36
+ return path.startsWith("http://") || path.startsWith("https://");
37
+ }
38
+ function joinPath(base, ...segments) {
39
+ if (isRemoteUrl(base)) {
40
+ const trailing = base.endsWith("/") ? "" : "/";
41
+ return base + trailing + segments.join("/");
42
+ }
43
+ return join(base, ...segments);
44
+ }
45
+
46
+ // src/shared/dir-resolver/functions/resolve-worker-script.function.ts
35
47
  function resolveWorkerScript(scriptDir, runtime) {
36
48
  if (runtime === "deno") {
37
- return join(scriptDir, "worker.ts");
49
+ return joinPath(scriptDir, "worker.ts");
38
50
  }
39
- return join(scriptDir, "kbdb-worker.cjs");
51
+ return joinPath(scriptDir, "kbdb-worker.cjs");
40
52
  }
41
53
 
42
54
  // src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts
43
- import { join as join2 } from "node:path";
44
55
  function resolveWasmDir(scriptDir) {
45
- return join2(scriptDir, "wasm");
56
+ return joinPath(scriptDir, "wasm");
46
57
  }
47
58
 
48
59
  // src/shared/hash/functions/compute-sha256.ts
@@ -54,7 +65,7 @@ async function computeSha256(input) {
54
65
  }
55
66
 
56
67
  // src/shared/platform/functions/get-ipc-path.function.ts
57
- import { join as join3 } from "node:path";
68
+ import { join as join2 } from "node:path";
58
69
 
59
70
  // src/shared/platform/functions/get-tmpdir.function.ts
60
71
  import { tmpdir } from "node:os";
@@ -67,16 +78,18 @@ function getIpcPath(ctx) {
67
78
  if (process.platform === "win32") {
68
79
  return `\\\\.\\pipe\\kbdb-${ctx}`;
69
80
  }
70
- return join3(getTmpdir(), `kbdb-${ctx}.sock`);
81
+ return join2(getTmpdir(), `kbdb-${ctx}.sock`);
71
82
  }
72
83
 
73
84
  export {
74
85
  detectRuntime,
75
86
  getArgs,
76
87
  resolveBaseDir,
88
+ isRemoteUrl,
89
+ joinPath,
77
90
  resolveWorkerScript,
78
91
  resolveWasmDir,
79
92
  computeSha256,
80
93
  getIpcPath
81
94
  };
82
- //# sourceMappingURL=chunk-QCCN7OZH.mjs.map
95
+ //# sourceMappingURL=chunk-JG2UCKLI.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/shared/runtime/functions/detect-runtime.ts", "../src/shared/runtime/functions/get-args.ts", "../src/shared/dir-resolver/functions/resolve-base-dir.function.ts", "../src/shared/dir-resolver/functions/join-path.function.ts", "../src/shared/dir-resolver/functions/resolve-worker-script.function.ts", "../src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts", "../src/shared/hash/functions/compute-sha256.ts", "../src/shared/platform/functions/get-ipc-path.function.ts", "../src/shared/platform/functions/get-tmpdir.function.ts"],
4
+ "sourcesContent": ["import type { Runtime } from '../typings/runtime.ts';\n\n/**\n * Detects the current JavaScript runtime environment.\n *\n * Returns `'deno'` when the global `Deno` object is present,\n * otherwise returns `'node'`.\n */\nexport function detectRuntime(): Runtime {\n if (typeof globalThis !== 'undefined' && 'Deno' in globalThis) {\n return 'deno';\n }\n return 'node';\n}\n", "import { detectRuntime } from './detect-runtime.ts';\n\n/**\n * Returns the command-line arguments for the current runtime.\n *\n * In Deno, reads `Deno.args`; in Node.js, slices `process.argv`\n * past the interpreter and script entries.\n */\nexport function getArgs(): string[] {\n if (detectRuntime() === 'deno') {\n const g = globalThis as Record<string, unknown>;\n const deno = g['Deno'] as { args: string[] } | undefined;\n return deno?.args ?? [];\n }\n return process.argv.slice(2);\n}\n", "import { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { BaseDir } from '../typings/base-dir.interface.ts';\n\nexport function resolveScriptDir(\n entryUrl: string,\n entryDirname?: string,\n): string {\n if (entryDirname) return entryDirname;\n if (entryUrl.startsWith('file:'))\n return dirname(fileURLToPath(entryUrl));\n return dirname(entryUrl);\n}\n\nexport function resolveBaseDir(\n entryUrl: string,\n entryDirname?: string,\n): BaseDir {\n const scriptDir =\n typeof __dirname !== 'undefined'\n ? __dirname\n : resolveScriptDir(entryUrl, entryDirname);\n return { scriptDir, cwd: process.cwd() };\n}\n", "import { join } from 'node:path';\n\nexport function isRemoteUrl(path: string): boolean {\n return path.startsWith('http://') || path.startsWith('https://');\n}\n\nexport function joinPath(base: string, ...segments: string[]): string {\n if (isRemoteUrl(base)) {\n const trailing = base.endsWith('/') ? '' : '/';\n return base + trailing + segments.join('/');\n }\n return join(base, ...segments);\n}\n", "import { joinPath } from './join-path.function.ts';\n\nimport type { Runtime } from '../../runtime/typings/runtime.ts';\n\nexport function resolveWorkerScript(\n scriptDir: string,\n runtime: Runtime,\n): string {\n if (runtime === 'deno') {\n return joinPath(scriptDir, 'worker.ts');\n }\n return joinPath(scriptDir, 'kbdb-worker.cjs');\n}\n", "import { joinPath } from './join-path.function.ts';\n\nexport function resolveWasmDir(scriptDir: string): string {\n return joinPath(scriptDir, 'wasm');\n}\n", "/**\n * Computes the SHA-256 hash of a UTF-8 string.\n *\n * Uses the Web Crypto API (`crypto.subtle`), which is available\n * in both Deno and Node.js >= 20 without additional imports.\n *\n * @param input - the string to hash\n * @returns lowercase hex-encoded SHA-256 digest (64 characters)\n */\nexport async function computeSha256(input: string): Promise<string> {\n const data = new TextEncoder().encode(input);\n const hash = await crypto.subtle.digest('SHA-256', data);\n const bytes = new Uint8Array(hash);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n", "import { join } from 'node:path';\nimport { getTmpdir } from './get-tmpdir.function.ts';\n\n/**\n * Returns the platform-appropriate IPC socket path for a given\n * context identifier.\n *\n * On Windows, returns a named pipe path (`\\\\.\\pipe\\kbdb-<ctx>`).\n * On POSIX systems, returns a Unix domain socket path under the\n * system temp directory (`<tmpdir>/kbdb-<ctx>.sock`).\n *\n * @param ctx - unique context identifier embedded in the path\n */\nexport function getIpcPath(ctx: string): string {\n if (process.platform === 'win32') {\n return `\\\\\\\\.\\\\pipe\\\\kbdb-${ctx}`;\n }\n return join(getTmpdir(), `kbdb-${ctx}.sock`);\n}\n", "import { tmpdir } from 'node:os';\n\n/**\n * Returns the operating system's default temporary directory path.\n */\nexport function getTmpdir(): string {\n return tmpdir();\n}\n"],
5
+ "mappings": ";AAQO,SAAS,gBAAyB;AACtC,MAAI,OAAO,eAAe,eAAe,UAAU,YAAY;AAC5D,WAAO;AAAA,EACV;AACA,SAAO;AACV;;;ACLO,SAAS,UAAoB;AACjC,MAAI,cAAc,MAAM,QAAQ;AAC7B,UAAM,IAAI;AACV,UAAM,OAAO,EAAE,MAAM;AACrB,WAAO,MAAM,QAAQ,CAAC;AAAA,EACzB;AACA,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC9B;;;ACfA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAIvB,SAAS,iBACb,UACA,cACO;AACP,MAAI,aAAc,QAAO;AACzB,MAAI,SAAS,WAAW,OAAO;AAC5B,WAAO,QAAQ,cAAc,QAAQ,CAAC;AACzC,SAAO,QAAQ,QAAQ;AAC1B;AAEO,SAAS,eACb,UACA,cACQ;AACR,QAAM,YACH,OAAO,cAAc,cAChB,YACA,iBAAiB,UAAU,YAAY;AAC/C,SAAO,EAAE,WAAW,KAAK,QAAQ,IAAI,EAAE;AAC1C;;;ACxBA,SAAS,YAAY;AAEd,SAAS,YAAY,MAAuB;AAChD,SAAO,KAAK,WAAW,SAAS,KAAK,KAAK,WAAW,UAAU;AAClE;AAEO,SAAS,SAAS,SAAiB,UAA4B;AACnE,MAAI,YAAY,IAAI,GAAG;AACpB,UAAM,WAAW,KAAK,SAAS,GAAG,IAAI,KAAK;AAC3C,WAAO,OAAO,WAAW,SAAS,KAAK,GAAG;AAAA,EAC7C;AACA,SAAO,KAAK,MAAM,GAAG,QAAQ;AAChC;;;ACRO,SAAS,oBACb,WACA,SACO;AACP,MAAI,YAAY,QAAQ;AACrB,WAAO,SAAS,WAAW,WAAW;AAAA,EACzC;AACA,SAAO,SAAS,WAAW,iBAAiB;AAC/C;;;ACVO,SAAS,eAAe,WAA2B;AACvD,SAAO,SAAS,WAAW,MAAM;AACpC;;;ACKA,eAAsB,cAAc,OAAgC;AACjE,QAAM,OAAO,IAAI,YAAY,EAAE,OAAO,KAAK;AAC3C,QAAM,OAAO,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI;AACvD,QAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,SAAO,MAAM,KAAK,KAAK,EACnB,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AACd;;;AChBA,SAAS,QAAAA,aAAY;;;ACArB,SAAS,cAAc;AAKhB,SAAS,YAAoB;AACjC,SAAO,OAAO;AACjB;;;ADMO,SAAS,WAAW,KAAqB;AAC7C,MAAI,QAAQ,aAAa,SAAS;AAC/B,WAAO,qBAAqB,GAAG;AAAA,EAClC;AACA,SAAOC,MAAK,UAAU,GAAG,QAAQ,GAAG,OAAO;AAC9C;",
6
+ "names": ["join", "join"]
7
+ }
package/dist/cli.cjs CHANGED
@@ -33,13 +33,25 @@ function resolveBaseDir(entryUrl, entryDirname) {
33
33
  return { scriptDir, cwd: process.cwd() };
34
34
  }
35
35
 
36
- // src/shared/dir-resolver/functions/resolve-worker-script.function.ts
36
+ // src/shared/dir-resolver/functions/join-path.function.ts
37
37
  var import_node_path2 = require("node:path");
38
+ function isRemoteUrl(path) {
39
+ return path.startsWith("http://") || path.startsWith("https://");
40
+ }
41
+ function joinPath(base, ...segments) {
42
+ if (isRemoteUrl(base)) {
43
+ const trailing = base.endsWith("/") ? "" : "/";
44
+ return base + trailing + segments.join("/");
45
+ }
46
+ return (0, import_node_path2.join)(base, ...segments);
47
+ }
48
+
49
+ // src/shared/dir-resolver/functions/resolve-worker-script.function.ts
38
50
  function resolveWorkerScript(scriptDir, runtime2) {
39
51
  if (runtime2 === "deno") {
40
- return (0, import_node_path2.join)(scriptDir, "worker.ts");
52
+ return joinPath(scriptDir, "worker.ts");
41
53
  }
42
- return (0, import_node_path2.join)(scriptDir, "kbdb-worker.cjs");
54
+ return joinPath(scriptDir, "kbdb-worker.cjs");
43
55
  }
44
56
 
45
57
  // src/shared/cli/constants/defaults.constant.ts