@simplysm/core-node 13.0.72 → 13.0.74

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.
Files changed (2) hide show
  1. package/README.md +79 -18
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,33 +2,94 @@
2
2
 
3
3
  Simplysm package - Core module (node)
4
4
 
5
+ Node.js utility library providing filesystem helpers, path utilities, a file-system watcher, and a type-safe worker thread abstraction.
6
+
5
7
  ## Installation
6
8
 
9
+ ```bash
7
10
  pnpm add @simplysm/core-node
11
+ ```
12
+
13
+ ---
14
+
15
+ ## Table of Contents
16
+
17
+ - [Filesystem Utilities](#filesystem-utilities)
18
+ - [Path Utilities](#path-utilities)
19
+ - [File System Watcher](#file-system-watcher)
20
+ - [Worker Thread Abstraction](#worker-thread-abstraction)
21
+
22
+ ---
23
+
24
+ ## Filesystem Utilities
25
+
26
+ [Full documentation: docs/fs.md](docs/fs.md)
27
+
28
+ Wraps the built-in `fs` module with recursive directory creation, retry logic, glob support, and consistent error wrapping via `SdError`. Both synchronous (`Sync` suffix) and asynchronous variants are provided for all operations.
29
+
30
+ | Function | Description |
31
+ |----------|-------------|
32
+ | `fsExistsSync` / `fsExists` | Check if a path exists |
33
+ | `fsMkdirSync` / `fsMkdir` | Create directory recursively |
34
+ | `fsRmSync` / `fsRm` | Delete file or directory recursively (async retries on lock) |
35
+ | `fsCopySync` / `fsCopy` | Copy file or directory with optional filter |
36
+ | `fsReadSync` / `fsRead` | Read file as UTF-8 string |
37
+ | `fsReadBufferSync` / `fsReadBuffer` | Read file as `Buffer` |
38
+ | `fsReadJsonSync` / `fsReadJson` | Read and parse a JSON file |
39
+ | `fsWriteSync` / `fsWrite` | Write string or `Uint8Array` to file (auto-creates parent dirs) |
40
+ | `fsWriteJsonSync` / `fsWriteJson` | Serialize and write JSON to file |
41
+ | `fsReaddirSync` / `fsReaddir` | List directory entries |
42
+ | `fsStatSync` / `fsStat` | Get `fs.Stats` following symlinks |
43
+ | `fsLstatSync` / `fsLstat` | Get `fs.Stats` without following symlinks |
44
+ | `fsGlobSync` / `fsGlob` | Find files by glob pattern (returns absolute paths) |
45
+ | `fsClearEmptyDirectory` | Recursively delete empty directories |
46
+ | `fsFindAllParentChildPathsSync` / `fsFindAllParentChildPaths` | Find matching paths by traversing parent directories |
47
+
48
+ ---
49
+
50
+ ## Path Utilities
51
+
52
+ [Full documentation: docs/path.md](docs/path.md)
53
+
54
+ Complements the built-in `path` module with normalization, POSIX conversion, and filtering helpers.
55
+
56
+ | Export | Description |
57
+ |--------|-------------|
58
+ | `NormPath` (type) | Branded string type for normalized absolute paths |
59
+ | `pathNorm` | Resolve segments to an absolute `NormPath` |
60
+ | `pathPosix` | Join and convert to forward-slash POSIX path |
61
+ | `pathChangeFileDirectory` | Re-root a file path to a different base directory |
62
+ | `pathBasenameWithoutExt` | Get filename without extension |
63
+ | `pathIsChildPath` | Check if one path is strictly inside another |
64
+ | `pathFilterByTargets` | Filter absolute paths by a list of relative targets |
65
+
66
+ ---
67
+
68
+ ## File System Watcher
69
+
70
+ [Full documentation: docs/watcher.md](docs/watcher.md)
8
71
 
9
- ## Source Index
72
+ A chokidar-based watcher that debounces rapid events and delivers them as a single batched array to a callback.
10
73
 
11
- ### Utils
74
+ | API | Description |
75
+ |-----|-------------|
76
+ | `FsWatcher.watch(paths, options?)` | Start watching; returns a ready `FsWatcher` instance |
77
+ | `watcher.onChange(opt, cb)` | Register a debounced batch-change handler |
78
+ | `watcher.close()` | Stop watching and dispose resources |
12
79
 
13
- | Source | Exports | Description | Test |
14
- |--------|---------|-------------|------|
15
- | `src/utils/fs.ts` | `fsExistsSync`, `fsExists`, `fsMkdirSync`, `fsMkdir`, `fsRmSync`, `fsRm`, `fsCopySync`, `fsCopy`, `fsReadSync`, `fsRead`, `fsReadBufferSync`, `fsReadBuffer`, `fsReadJsonSync`, `fsReadJson`, `fsWriteSync`, `fsWrite`, `fsWriteJsonSync`, `fsWriteJson`, `fsReaddirSync`, `fsReaddir`, `fsStatSync`, `fsStat`, `fsLstatSync`, `fsLstat`, `fsGlobSync`, `fsGlob`, `fsClearEmptyDirectory`, `fsFindAllParentChildPathsSync`, `fsFindAllParentChildPaths` | Comprehensive file system utilities (read, write, copy, delete, glob, stat) | `fs.spec.ts` |
16
- | `src/utils/path.ts` | `NormPath`, `pathPosix`, `pathChangeFileDirectory`, `pathBasenameWithoutExt`, `pathIsChildPath`, `pathNorm`, `pathFilterByTargets` | Path normalization and manipulation utilities for posix-style paths | `path.spec.ts` |
80
+ Related types: `FsWatcherEvent`, `FsWatcherChangeInfo`
17
81
 
18
- ### Features
82
+ ---
19
83
 
20
- | Source | Exports | Description | Test |
21
- |--------|---------|-------------|------|
22
- | `src/features/fs-watcher.ts` | `FsWatcherEvent`, `FsWatcherChangeInfo`, `FsWatcher` | File system watcher with debounced change detection and event filtering | `fs-watcher.spec.ts` |
84
+ ## Worker Thread Abstraction
23
85
 
24
- ### Worker
86
+ [Full documentation: docs/worker.md](docs/worker.md)
25
87
 
26
- | Source | Exports | Description | Test |
27
- |--------|---------|-------------|------|
28
- | `src/worker/types.ts` | `WorkerModule`, `PromisifyMethods`, `WorkerProxy`, `WorkerRequest`, `WorkerResponse` | Type definitions for worker thread message passing and proxy pattern | - |
29
- | `src/worker/worker.ts` | `Worker` | Worker thread wrapper with method-based RPC and error forwarding | `sd-worker.spec.ts` |
30
- | `src/worker/create-worker.ts` | `createWorker` | Factory to create a type-safe worker proxy from a module path | `sd-worker.spec.ts` |
88
+ Type-safe RPC bridge over Node.js `worker_threads`. Define methods in a worker file and call them from the main thread with full TypeScript inference.
31
89
 
32
- ## License
90
+ | API | Description |
91
+ |-----|-------------|
92
+ | `createWorker(methods)` | Register RPC methods inside a worker file |
93
+ | `Worker.create(filePath, opt?)` | Create a typed proxy to the worker from the main thread |
33
94
 
34
- Apache-2.0
95
+ Related types: `WorkerModule`, `WorkerProxy`, `PromisifyMethods`, `WorkerRequest`, `WorkerResponse`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/core-node",
3
- "version": "13.0.72",
3
+ "version": "13.0.74",
4
4
  "description": "Simplysm package - Core module (node)",
5
5
  "author": "simplysm",
6
6
  "license": "Apache-2.0",
@@ -24,6 +24,6 @@
24
24
  "glob": "^13.0.6",
25
25
  "minimatch": "^10.2.4",
26
26
  "tsx": "^4.21.0",
27
- "@simplysm/core-common": "13.0.72"
27
+ "@simplysm/core-common": "13.0.74"
28
28
  }
29
29
  }