@esposter/shared-node 4.11.0 → 4.13.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/dist/cache.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { CACHE_ROOT, CONTENT_CACHE_DIRECTORY } from "./services/cache/constants.js";
1
+ import { CONTENT_CACHE_DIRECTORY } from "./services/cache/constants.js";
2
2
  import { readContentAddressedObject } from "./services/cache/readContentAddressedObject.js";
3
3
  import { writePartialThenMove } from "./services/cache/writePartialThenMove.js";
4
- export { CACHE_ROOT, CONTENT_CACHE_DIRECTORY, readContentAddressedObject, writePartialThenMove };
4
+ import { CACHE_ROOT, DATA_ROOT, STATE_ROOT, WINDOWS_ANIMESTUDIO_DIRECTORY } from "./services/dataRoot/constants.js";
5
+ export { CACHE_ROOT, CONTENT_CACHE_DIRECTORY, DATA_ROOT, STATE_ROOT, WINDOWS_ANIMESTUDIO_DIRECTORY, readContentAddressedObject, writePartialThenMove };
package/dist/cache.js CHANGED
@@ -1,4 +1,5 @@
1
- import { CACHE_ROOT, CONTENT_CACHE_DIRECTORY } from "./services/cache/constants.js";
1
+ import { CONTENT_CACHE_DIRECTORY } from "./services/cache/constants.js";
2
2
  import { readContentAddressedObject } from "./services/cache/readContentAddressedObject.js";
3
3
  import { writePartialThenMove } from "./services/cache/writePartialThenMove.js";
4
- export { CACHE_ROOT, CONTENT_CACHE_DIRECTORY, readContentAddressedObject, writePartialThenMove };
4
+ import { CACHE_ROOT, DATA_ROOT, STATE_ROOT, WINDOWS_ANIMESTUDIO_DIRECTORY } from "./services/dataRoot/constants.js";
5
+ export { CACHE_ROOT, CONTENT_CACHE_DIRECTORY, DATA_ROOT, STATE_ROOT, WINDOWS_ANIMESTUDIO_DIRECTORY, readContentAddressedObject, writePartialThenMove };
@@ -1,2 +1 @@
1
- export declare const CACHE_ROOT: string;
2
1
  export declare const CONTENT_CACHE_DIRECTORY: string;
@@ -1,7 +1,5 @@
1
- import { SITE_NAME } from "@esposter/shared";
2
- import { homedir } from "node:os";
1
+ import { CACHE_ROOT } from "../dataRoot/constants.js";
3
2
  import { join } from "node:path";
4
3
  // src/services/cache/constants.ts
5
- const CACHE_ROOT = join(homedir(), SITE_NAME, "cache");
6
4
  const CONTENT_CACHE_DIRECTORY = join(CACHE_ROOT, "content");
7
- export { CACHE_ROOT, CONTENT_CACHE_DIRECTORY };
5
+ export { CONTENT_CACHE_DIRECTORY };
@@ -1,10 +1,10 @@
1
1
  import { CONTENT_CACHE_DIRECTORY } from "./constants.js";
2
2
  import { writePartialThenMove } from "./writePartialThenMove.js";
3
3
  import { InvalidOperationError, Operation, getResultAsync, noop } from "@esposter/shared";
4
- import { join } from "node:path";
4
+ import { createHash } from "node:crypto";
5
5
  import { existsSync } from "node:fs";
6
6
  import { readFile, writeFile } from "node:fs/promises";
7
- import { createHash } from "node:crypto";
7
+ import { join } from "node:path";
8
8
  // src/services/cache/readContentAddressedObject.ts
9
9
  const SHA_256_HEX_REGEX = /^[0-9a-f]{64}$/u;
10
10
  const readContentAddressedObject = async (hash, download, directory = CONTENT_CACHE_DIRECTORY) => {
@@ -1,11 +1,12 @@
1
1
  import { getResultAsync, noop } from "@esposter/shared";
2
- import { dirname } from "node:path";
3
2
  import { rmSync } from "node:fs";
4
3
  import { mkdir, rename } from "node:fs/promises";
4
+ import { dirname } from "node:path";
5
+ import { v7 } from "uuid";
5
6
  // src/services/cache/writePartialThenMove.ts
6
7
  const writePartialThenMove = async (path, write) => {
7
8
  await mkdir(dirname(path), { recursive: true });
8
- const partialPath = `${path}.${crypto.randomUUID()}.part`;
9
+ const partialPath = `${path}.${v7()}.part`;
9
10
  (await getResultAsync(async () => {
10
11
  await write(partialPath);
11
12
  await rename(partialPath, path);
@@ -0,0 +1,4 @@
1
+ export declare const DATA_ROOT: string;
2
+ export declare const CACHE_ROOT: string;
3
+ export declare const STATE_ROOT: string;
4
+ export declare const WINDOWS_ANIMESTUDIO_DIRECTORY: string;
@@ -0,0 +1,13 @@
1
+ import { homedir } from "node:os";
2
+ import { isAbsolute, join } from "node:path";
3
+ // src/services/dataRoot/constants.ts
4
+ const NAMESPACE = "workspace-data";
5
+ const getBaseDirectory = (variableName, ...defaultSegments) => {
6
+ const baseDirectory = process.env[variableName] ?? "";
7
+ return isAbsolute(baseDirectory) ? baseDirectory : join(homedir(), ...defaultSegments);
8
+ };
9
+ const DATA_ROOT = join(getBaseDirectory("XDG_DATA_HOME", ".local", "share"), NAMESPACE);
10
+ const CACHE_ROOT = join(getBaseDirectory("XDG_CACHE_HOME", ".cache"), NAMESPACE);
11
+ const STATE_ROOT = join(getBaseDirectory("XDG_STATE_HOME", ".local", "state"), NAMESPACE);
12
+ const WINDOWS_ANIMESTUDIO_DIRECTORY = join(homedir(), "Downloads", "AnimeStudio");
13
+ export { CACHE_ROOT, DATA_ROOT, STATE_ROOT, WINDOWS_ANIMESTUDIO_DIRECTORY };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esposter/shared-node",
3
- "version": "4.11.0",
3
+ "version": "4.13.0",
4
4
  "description": "Node-only shared tooling: the machine-wide download cache, hidden-window child processes, and benchmark reporting reused across packages.",
5
5
  "keywords": [
6
6
  "benchmark",
@@ -47,20 +47,21 @@
47
47
  "typecheck": "tsrs --fast"
48
48
  },
49
49
  "dependencies": {
50
- "@esposter/shared": "4.11.0"
50
+ "@esposter/shared": "4.13.0",
51
+ "uuid": "^14.0.3"
51
52
  },
52
53
  "devDependencies": {
53
- "@esposter/configuration": "4.11.0",
54
+ "@esposter/configuration": "4.13.0",
54
55
  "@types/node": "^26.6.6",
55
56
  "tsdown": "^0.23.7"
56
57
  },
57
58
  "peerDependencies": {
58
- "vitest": "^5.1.0"
59
+ "vitest": "^5.1.1"
59
60
  },
60
61
  "peerDependenciesMeta": {
61
62
  "vitest": {
62
63
  "optional": true
63
64
  }
64
65
  },
65
- "gitHead": "30487eb6b35629858a53abd3adbaf324b161f185"
66
+ "gitHead": "d60ae90f266ad504f7c584ccf1103a8a8cbd1f04"
66
67
  }