@simplysm/core-node 13.0.69 → 13.0.70

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.
@@ -2,196 +2,196 @@ import fs from "fs";
2
2
  import { type GlobOptions } from "glob";
3
3
  import "@simplysm/core-common";
4
4
  /**
5
- * 파일 또는 디렉토리 존재 확인 (동기).
6
- * @param targetPath - 확인할 경로
5
+ * Checks if a file or directory exists (synchronous).
6
+ * @param targetPath - Path to check
7
7
  */
8
8
  export declare function fsExistsSync(targetPath: string): boolean;
9
9
  /**
10
- * 파일 또는 디렉토리 존재 확인 (비동기).
11
- * @param targetPath - 확인할 경로
10
+ * Checks if a file or directory exists (asynchronous).
11
+ * @param targetPath - Path to check
12
12
  */
13
13
  export declare function fsExists(targetPath: string): Promise<boolean>;
14
14
  /**
15
- * 디렉토리 생성 (recursive).
16
- * @param targetPath - 생성할 디렉토리 경로
15
+ * Creates a directory (recursive).
16
+ * @param targetPath - Directory path to create
17
17
  */
18
18
  export declare function fsMkdirSync(targetPath: string): void;
19
19
  /**
20
- * 디렉토리 생성 (recursive, 비동기).
21
- * @param targetPath - 생성할 디렉토리 경로
20
+ * Creates a directory (recursive, asynchronous).
21
+ * @param targetPath - Directory path to create
22
22
  */
23
23
  export declare function fsMkdir(targetPath: string): Promise<void>;
24
24
  /**
25
- * 파일 또는 디렉토리 삭제.
26
- * @param targetPath - 삭제할 경로
27
- * @remarks 동기 버전은 재시도 없이 즉시 실패함. 파일 잠금 일시적 오류 가능성이 있는 경우 fsRm 사용을 권장함.
25
+ * Deletes a file or directory.
26
+ * @param targetPath - Path to delete
27
+ * @remarks The synchronous version fails immediately without retries. Use fsRm for cases with potential transient errors like file locks.
28
28
  */
29
29
  export declare function fsRmSync(targetPath: string): void;
30
30
  /**
31
- * 파일 또는 디렉토리 삭제 (비동기).
32
- * @param targetPath - 삭제할 경로
33
- * @remarks 비동기 버전은 파일 잠금 등의 일시적 오류에 대해 최대 6회(500ms 간격) 재시도함.
31
+ * Deletes a file or directory (asynchronous).
32
+ * @param targetPath - Path to delete
33
+ * @remarks The asynchronous version retries up to 6 times (500ms interval) for transient errors like file locks.
34
34
  */
35
35
  export declare function fsRm(targetPath: string): Promise<void>;
36
36
  /**
37
- * 파일 또는 디렉토리 복사.
37
+ * Copies a file or directory.
38
38
  *
39
- * sourcePath 존재하지 않으면 아무 작업도 수행하지 않고 반환한다.
39
+ * If sourcePath does not exist, no action is performed and the function returns.
40
40
  *
41
- * @param sourcePath 복사할 원본 경로
42
- * @param targetPath 복사 대상 경로
43
- * @param filter 복사 여부를 결정하는 필터 함수.
44
- * 파일/디렉토리의 **절대 경로**가 전달되며,
45
- * true 반환하면 복사, false 제외.
46
- * **주의**: 최상위 sourcePath 필터 대상이 아니며,
47
- * 모든 하위 항목(자식, 손자 등)에 재귀적으로 filter 함수가 적용된다.
48
- * 디렉토리에 false 반환하면 해당 디렉토리와 모든 하위 항목이 건너뛰어짐.
41
+ * @param sourcePath Path of the source to copy
42
+ * @param targetPath Destination path for the copy
43
+ * @param filter A filter function that determines whether to copy.
44
+ * The **absolute path** of each file/directory is passed.
45
+ * Returns true to copy, false to exclude.
46
+ * **Note**: The top-level sourcePath is not subject to filtering;
47
+ * the filter function is applied recursively to all children (direct and indirect).
48
+ * Returning false for a directory skips that directory and all its contents.
49
49
  */
50
50
  export declare function fsCopySync(sourcePath: string, targetPath: string, filter?: (absolutePath: string) => boolean): void;
51
51
  /**
52
- * 파일 또는 디렉토리 복사 (비동기).
52
+ * Copies a file or directory (asynchronous).
53
53
  *
54
- * sourcePath 존재하지 않으면 아무 작업도 수행하지 않고 반환한다.
54
+ * If sourcePath does not exist, no action is performed and the function returns.
55
55
  *
56
- * @param sourcePath 복사할 원본 경로
57
- * @param targetPath 복사 대상 경로
58
- * @param filter 복사 여부를 결정하는 필터 함수.
59
- * 파일/디렉토리의 **절대 경로**가 전달되며,
60
- * true 반환하면 복사, false 제외.
61
- * **주의**: 최상위 sourcePath 필터 대상이 아니며,
62
- * 모든 하위 항목(자식, 손자 등)에 재귀적으로 filter 함수가 적용된다.
63
- * 디렉토리에 false 반환하면 해당 디렉토리와 모든 하위 항목이 건너뛰어짐.
56
+ * @param sourcePath Path of the source to copy
57
+ * @param targetPath Destination path for the copy
58
+ * @param filter A filter function that determines whether to copy.
59
+ * The **absolute path** of each file/directory is passed.
60
+ * Returns true to copy, false to exclude.
61
+ * **Note**: The top-level sourcePath is not subject to filtering;
62
+ * the filter function is applied recursively to all children (direct and indirect).
63
+ * Returning false for a directory skips that directory and all its contents.
64
64
  */
65
65
  export declare function fsCopy(sourcePath: string, targetPath: string, filter?: (absolutePath: string) => boolean): Promise<void>;
66
66
  /**
67
- * 파일 읽기 (UTF-8 문자열).
68
- * @param targetPath - 읽을 파일 경로
67
+ * Reads a file as a UTF-8 string.
68
+ * @param targetPath - Path of the file to read
69
69
  */
70
70
  export declare function fsReadSync(targetPath: string): string;
71
71
  /**
72
- * 파일 읽기 (UTF-8 문자열, 비동기).
73
- * @param targetPath - 읽을 파일 경로
72
+ * Reads a file as a UTF-8 string (asynchronous).
73
+ * @param targetPath - Path of the file to read
74
74
  */
75
75
  export declare function fsRead(targetPath: string): Promise<string>;
76
76
  /**
77
- * 파일 읽기 (Buffer).
78
- * @param targetPath - 읽을 파일 경로
77
+ * Reads a file as a Buffer.
78
+ * @param targetPath - Path of the file to read
79
79
  */
80
80
  export declare function fsReadBufferSync(targetPath: string): Buffer;
81
81
  /**
82
- * 파일 읽기 (Buffer, 비동기).
83
- * @param targetPath - 읽을 파일 경로
82
+ * Reads a file as a Buffer (asynchronous).
83
+ * @param targetPath - Path of the file to read
84
84
  */
85
85
  export declare function fsReadBuffer(targetPath: string): Promise<Buffer>;
86
86
  /**
87
- * JSON 파일 읽기 (JsonConvert 사용).
88
- * @param targetPath - 읽을 JSON 파일 경로
87
+ * Reads a JSON file (using JsonConvert).
88
+ * @param targetPath - Path of the JSON file to read
89
89
  */
90
90
  export declare function fsReadJsonSync<TData = unknown>(targetPath: string): TData;
91
91
  /**
92
- * JSON 파일 읽기 (JsonConvert 사용, 비동기).
93
- * @param targetPath - 읽을 JSON 파일 경로
92
+ * Reads a JSON file (using JsonConvert, asynchronous).
93
+ * @param targetPath - Path of the JSON file to read
94
94
  */
95
95
  export declare function fsReadJson<TData = unknown>(targetPath: string): Promise<TData>;
96
96
  /**
97
- * 파일 쓰기 (부모 디렉토리 자동 생성).
98
- * @param targetPath - 파일 경로
99
- * @param data - 데이터 (문자열 또는 바이너리)
97
+ * Writes data to a file (auto-creates parent directories).
98
+ * @param targetPath - Path of the file to write
99
+ * @param data - Data to write (string or binary)
100
100
  */
101
101
  export declare function fsWriteSync(targetPath: string, data: string | Uint8Array): void;
102
102
  /**
103
- * 파일 쓰기 (부모 디렉토리 자동 생성, 비동기).
104
- * @param targetPath - 파일 경로
105
- * @param data - 데이터 (문자열 또는 바이너리)
103
+ * Writes data to a file (auto-creates parent directories, asynchronous).
104
+ * @param targetPath - Path of the file to write
105
+ * @param data - Data to write (string or binary)
106
106
  */
107
107
  export declare function fsWrite(targetPath: string, data: string | Uint8Array): Promise<void>;
108
108
  /**
109
- * JSON 파일 쓰기 (JsonConvert 사용).
110
- * @param targetPath - JSON 파일 경로
111
- * @param data - 데이터
112
- * @param options - JSON 직렬화 옵션
109
+ * Writes data to a JSON file (using JsonConvert).
110
+ * @param targetPath - Path of the JSON file to write
111
+ * @param data - Data to write
112
+ * @param options - JSON serialization options
113
113
  */
114
114
  export declare function fsWriteJsonSync(targetPath: string, data: unknown, options?: {
115
115
  replacer?: (this: unknown, key: string | undefined, value: unknown) => unknown;
116
116
  space?: string | number;
117
117
  }): void;
118
118
  /**
119
- * JSON 파일 쓰기 (JsonConvert 사용, 비동기).
120
- * @param targetPath - JSON 파일 경로
121
- * @param data - 데이터
122
- * @param options - JSON 직렬화 옵션
119
+ * Writes data to a JSON file (using JsonConvert, asynchronous).
120
+ * @param targetPath - Path of the JSON file to write
121
+ * @param data - Data to write
122
+ * @param options - JSON serialization options
123
123
  */
124
124
  export declare function fsWriteJson(targetPath: string, data: unknown, options?: {
125
125
  replacer?: (this: unknown, key: string | undefined, value: unknown) => unknown;
126
126
  space?: string | number;
127
127
  }): Promise<void>;
128
128
  /**
129
- * 디렉토리 내용 읽기.
130
- * @param targetPath - 읽을 디렉토리 경로
129
+ * Reads the contents of a directory.
130
+ * @param targetPath - Path of the directory to read
131
131
  */
132
132
  export declare function fsReaddirSync(targetPath: string): string[];
133
133
  /**
134
- * 디렉토리 내용 읽기 (비동기).
135
- * @param targetPath - 읽을 디렉토리 경로
134
+ * Reads the contents of a directory (asynchronous).
135
+ * @param targetPath - Path of the directory to read
136
136
  */
137
137
  export declare function fsReaddir(targetPath: string): Promise<string[]>;
138
138
  /**
139
- * 파일/디렉토리 정보 (심볼릭 링크 따라감).
140
- * @param targetPath - 정보를 조회할 경로
139
+ * Gets file/directory information (follows symbolic links).
140
+ * @param targetPath - Path to query information for
141
141
  */
142
142
  export declare function fsStatSync(targetPath: string): fs.Stats;
143
143
  /**
144
- * 파일/디렉토리 정보 (심볼릭 링크 따라감, 비동기).
145
- * @param targetPath - 정보를 조회할 경로
144
+ * Gets file/directory information (follows symbolic links, asynchronous).
145
+ * @param targetPath - Path to query information for
146
146
  */
147
147
  export declare function fsStat(targetPath: string): Promise<fs.Stats>;
148
148
  /**
149
- * 파일/디렉토리 정보 (심볼릭 링크 따라가지 않음).
150
- * @param targetPath - 정보를 조회할 경로
149
+ * Gets file/directory information (does not follow symbolic links).
150
+ * @param targetPath - Path to query information for
151
151
  */
152
152
  export declare function fsLstatSync(targetPath: string): fs.Stats;
153
153
  /**
154
- * 파일/디렉토리 정보 (심볼릭 링크 따라가지 않음, 비동기).
155
- * @param targetPath - 정보를 조회할 경로
154
+ * Gets file/directory information (does not follow symbolic links, asynchronous).
155
+ * @param targetPath - Path to query information for
156
156
  */
157
157
  export declare function fsLstat(targetPath: string): Promise<fs.Stats>;
158
158
  /**
159
- * 글로브 패턴으로 파일 검색.
160
- * @param pattern - 글로브 패턴 (예: "**\/*.ts")
161
- * @param options - glob 옵션
162
- * @returns 매칭된 파일들의 절대 경로 배열
159
+ * Searches for files using a glob pattern.
160
+ * @param pattern - Glob pattern (e.g., "**\/*.ts")
161
+ * @param options - glob options
162
+ * @returns Array of absolute paths for matched files
163
163
  */
164
164
  export declare function fsGlobSync(pattern: string, options?: GlobOptions): string[];
165
165
  /**
166
- * 글로브 패턴으로 파일 검색 (비동기).
167
- * @param pattern - 글로브 패턴 (예: "**\/*.ts")
168
- * @param options - glob 옵션
169
- * @returns 매칭된 파일들의 절대 경로 배열
166
+ * Searches for files using a glob pattern (asynchronous).
167
+ * @param pattern - Glob pattern (e.g., "**\/*.ts")
168
+ * @param options - glob options
169
+ * @returns Array of absolute paths for matched files
170
170
  */
171
171
  export declare function fsGlob(pattern: string, options?: GlobOptions): Promise<string[]>;
172
172
  /**
173
- * 지정 디렉토리 하위의 디렉토리를 재귀적으로 탐색하여 삭제.
174
- * 하위 디렉토리가 모두 삭제되어 디렉토리가 경우, 해당 디렉토리도 삭제 대상이 됨.
173
+ * Recursively searches and deletes empty directories under a specified directory.
174
+ * If all child directories are deleted and a parent becomes empty, it will also be deleted.
175
175
  */
176
176
  export declare function fsClearEmptyDirectory(dirPath: string): Promise<void>;
177
177
  /**
178
- * 시작 경로부터 루트 방향으로 상위 디렉토리를 순회하며 glob 패턴 검색.
179
- * 디렉토리에서 childGlob 패턴에 매칭되는 모든 파일 경로를 수집.
180
- * @param childGlob - 디렉토리에서 검색할 glob 패턴
181
- * @param fromPath - 검색 시작 경로
182
- * @param rootPath - 검색 종료 경로 (미지정 파일시스템 루트까지).
183
- * **주의**: fromPath rootPath의 자식 경로여야 함.
184
- * 그렇지 않으면 파일시스템 루트까지 검색함.
178
+ * Searches for files matching a glob pattern by traversing parent directories from a start path towards the root.
179
+ * Collects all file paths matching the childGlob pattern in each directory.
180
+ * @param childGlob - Glob pattern to search for in each directory
181
+ * @param fromPath - Path to start searching from
182
+ * @param rootPath - Path to stop searching at (if not specified, searches to filesystem root).
183
+ * **Note**: fromPath must be a child path of rootPath.
184
+ * Otherwise, searches to the filesystem root.
185
185
  */
186
186
  export declare function fsFindAllParentChildPathsSync(childGlob: string, fromPath: string, rootPath?: string): string[];
187
187
  /**
188
- * 시작 경로부터 루트 방향으로 상위 디렉토리를 순회하며 glob 패턴 검색 (비동기).
189
- * 디렉토리에서 childGlob 패턴에 매칭되는 모든 파일 경로를 수집.
190
- * @param childGlob - 디렉토리에서 검색할 glob 패턴
191
- * @param fromPath - 검색 시작 경로
192
- * @param rootPath - 검색 종료 경로 (미지정 파일시스템 루트까지).
193
- * **주의**: fromPath rootPath의 자식 경로여야 함.
194
- * 그렇지 않으면 파일시스템 루트까지 검색함.
188
+ * Searches for files matching a glob pattern by traversing parent directories from a start path towards the root (asynchronous).
189
+ * Collects all file paths matching the childGlob pattern in each directory.
190
+ * @param childGlob - Glob pattern to search for in each directory
191
+ * @param fromPath - Path to start searching from
192
+ * @param rootPath - Path to stop searching at (if not specified, searches to filesystem root).
193
+ * **Note**: fromPath must be a child path of rootPath.
194
+ * Otherwise, searches to the filesystem root.
195
195
  */
196
196
  export declare function fsFindAllParentChildPaths(childGlob: string, fromPath: string, rootPath?: string): Promise<string[]>;
197
197
  //# sourceMappingURL=fs.d.ts.map
@@ -1,13 +1,13 @@
1
1
  declare const NORM: unique symbol;
2
2
  /**
3
- * 정규화된 경로를 나타내는 브랜드 타입.
4
- * pathNorm()을 통해서만 생성 가능.
3
+ * Brand type representing a normalized path.
4
+ * Can only be created through pathNorm().
5
5
  */
6
6
  export type NormPath = string & {
7
7
  [NORM]: never;
8
8
  };
9
9
  /**
10
- * POSIX 스타일 경로로 변환 (백슬래시슬래시).
10
+ * Converts to POSIX-style path (backslashforward slash).
11
11
  *
12
12
  * @example
13
13
  * pathPosix("C:\\Users\\test"); // "C:/Users/test"
@@ -15,17 +15,17 @@ export type NormPath = string & {
15
15
  */
16
16
  export declare function pathPosix(...args: string[]): string;
17
17
  /**
18
- * 파일 경로의 디렉토리를 변경.
18
+ * Changes the directory of a file path.
19
19
  *
20
20
  * @example
21
21
  * pathChangeFileDirectory("/a/b/c.txt", "/a", "/x");
22
22
  * // → "/x/b/c.txt"
23
23
  *
24
- * @throws 파일이 fromDirectory 안에 없으면 에러
24
+ * @throws Error if the file is not inside fromDirectory
25
25
  */
26
26
  export declare function pathChangeFileDirectory(filePath: string, fromDirectory: string, toDirectory: string): string;
27
27
  /**
28
- * 확장자를 제거한 파일명(basename) 반환.
28
+ * Returns the filename (basename) without extension.
29
29
  *
30
30
  * @example
31
31
  * pathBasenameWithoutExt("file.txt"); // "file"
@@ -33,37 +33,37 @@ export declare function pathChangeFileDirectory(filePath: string, fromDirectory:
33
33
  */
34
34
  export declare function pathBasenameWithoutExt(filePath: string): string;
35
35
  /**
36
- * childPath parentPath의 자식 경로인지 확인.
37
- * 같은 경로는 false 반환.
36
+ * Checks if childPath is a child path of parentPath.
37
+ * Returns false if the paths are the same.
38
38
  *
39
- * 경로는 내부적으로 `pathNorm()`으로 정규화된 비교되며,
40
- * 플랫폼별 경로 구분자(Windows: `\`, Unix: `/`)를 사용한다.
39
+ * Paths are internally normalized using `pathNorm()` and compared using
40
+ * platform-specific path separators (Windows: `\`, Unix: `/`).
41
41
  *
42
42
  * @example
43
43
  * pathIsChildPath("/a/b/c", "/a/b"); // true
44
44
  * pathIsChildPath("/a/b", "/a/b/c"); // false
45
- * pathIsChildPath("/a/b", "/a/b"); // false (같은 경로)
45
+ * pathIsChildPath("/a/b", "/a/b"); // false (same path)
46
46
  */
47
47
  export declare function pathIsChildPath(childPath: string, parentPath: string): boolean;
48
48
  /**
49
- * 경로를 정규화하여 NormPath로 반환.
50
- * 절대 경로로 변환되며, 플랫폼별 구분자로 정규화됨.
49
+ * Normalizes the path and returns it as NormPath.
50
+ * Converts to absolute path and normalizes using platform-specific separators.
51
51
  *
52
52
  * @example
53
53
  * pathNorm("/some/path"); // NormPath
54
- * pathNorm("relative", "path"); // NormPath (절대 경로로 변환)
54
+ * pathNorm("relative", "path"); // NormPath (converted to absolute path)
55
55
  */
56
56
  export declare function pathNorm(...paths: string[]): NormPath;
57
57
  /**
58
- * 타겟 경로 목록을 기준으로 파일을 필터링.
59
- * 파일이 타겟 경로와 같거나 타겟의 자식 경로일 포함.
58
+ * Filters files based on a list of target paths.
59
+ * Includes files that match or are children of a target path.
60
60
  *
61
- * @param files - 필터링할 파일 경로 목록.
62
- * **주의**: cwd 하위의 절대 경로여야 함.
63
- * cwd 외부 경로는 상대 경로(../ 형태) 변환되어 처리됨.
64
- * @param targets - 타겟 경로 목록 (cwd 기준 상대 경로, POSIX 스타일 권장)
65
- * @param cwd - 현재 작업 디렉토리 (절대 경로)
66
- * @returns targets 배열이면 files 그대로, 아니면 타겟 경로 하위 파일만
61
+ * @param files - File paths to filter.
62
+ * **Note**: Must be absolute paths under cwd.
63
+ * Paths outside cwd are converted to relative paths (../) for processing.
64
+ * @param targets - Target paths (relative to cwd, POSIX style recommended)
65
+ * @param cwd - Current working directory (absolute path)
66
+ * @returns If targets is empty, returns files as-is; otherwise returns only files under target paths
67
67
  *
68
68
  * @example
69
69
  * const files = ["/proj/src/a.ts", "/proj/src/b.ts", "/proj/tests/c.ts"];
@@ -10,7 +10,7 @@ function pathChangeFileDirectory(filePath, fromDirectory, toDirectory) {
10
10
  return toDirectory;
11
11
  }
12
12
  if (!pathIsChildPath(filePath, fromDirectory)) {
13
- throw new ArgumentError(`'${filePath}'\uAC00 ${fromDirectory} \uC548\uC5D0 \uC5C6\uC2B5\uB2C8\uB2E4.`, {
13
+ throw new ArgumentError(`'${filePath}' is not inside ${fromDirectory}.`, {
14
14
  filePath,
15
15
  fromDirectory
16
16
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/path.ts"],
4
- "mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAI9B,MAAM,OAAO,uBAAO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C7E;AAAA,EACF,CAAC;AACH;",
5
5
  "names": []
6
6
  }
@@ -1,13 +1,13 @@
1
1
  /**
2
- * 워커 스레드에서 사용할 워커 팩토리.
2
+ * Worker factory for use in worker threads.
3
3
  *
4
4
  * @example
5
- * // 이벤트 없는 워커
5
+ * // Worker without events
6
6
  * export default createWorker({
7
7
  * add: (a: number, b: number) => a + b,
8
8
  * });
9
9
  *
10
- * // 이벤트 있는 워커
10
+ * // Worker with events
11
11
  * interface MyEvents { progress: number; }
12
12
  * const methods = {
13
13
  * calc: (x: number) => { sender.send("progress", 50); return x * 2; },
@@ -2,7 +2,7 @@ import { parentPort } from "worker_threads";
2
2
  import { SdError, transferableDecode, transferableEncode } from "@simplysm/core-common";
3
3
  function createWorker(methods) {
4
4
  if (parentPort === null) {
5
- throw new SdError("\uC774 \uC2A4\uD06C\uB9BD\uD2B8\uB294 \uC6CC\uCEE4 \uC2A4\uB808\uB4DC\uC5D0\uC11C \uC2E4\uD589\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4 (parentPort \uD544\uC694).");
5
+ throw new SdError("This script must be executed in a worker thread (parentPort required).");
6
6
  }
7
7
  const port = parentPort;
8
8
  process.stdout.write = (chunk, encodingOrCallback, callback) => {
@@ -28,7 +28,7 @@ function createWorker(methods) {
28
28
  const errorResponse = {
29
29
  type: "error",
30
30
  request: { id: "unknown", method: "unknown", params: [] },
31
- body: new SdError(`\uD615\uC2DD\uC774 \uC798\uBABB\uB41C \uC6CC\uCEE4 \uC694\uCCAD: ${decodedStr}`)
31
+ body: new SdError(`Invalid worker request format: ${decodedStr}`)
32
32
  };
33
33
  const serialized = transferableEncode(errorResponse);
34
34
  port.postMessage(serialized.result, serialized.transferList);
@@ -40,7 +40,7 @@ function createWorker(methods) {
40
40
  const response = {
41
41
  request,
42
42
  type: "error",
43
- body: new SdError(`\uC54C \uC218 \uC5C6\uB294 \uBA54\uC11C\uB4DC: ${request.method}`)
43
+ body: new SdError(`Unknown method: ${request.method}`)
44
44
  };
45
45
  const serialized = transferableEncode(response);
46
46
  port.postMessage(serialized.result, serialized.transferList);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/worker/create-worker.ts"],
4
- "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,oBAAoB,0BAA0B;AAsBzD,SAAS,aAId,SAKA;AACA,MAAI,eAAe,MAAM;AACvB,UAAM,IAAI,QAAQ,gKAA6C;AAAA,EACjE;AAEA,QAAM,OAAO;AAIb,UAAQ,OAAO,QAAQ,CACrB,OACA,oBACA,aACY;AACZ,UAAM,OAAO,OAAO,UAAU,WAAW,QAAQ,IAAI,YAAY,EAAE,OAAO,KAAK;AAC/E,UAAM,WAA2B,EAAE,MAAM,OAAO,KAAK;AACrD,UAAM,aAAa,mBAAmB,QAAQ;AAC9C,SAAK,YAAY,WAAW,QAAQ,WAAW,YAAY;AAE3D,UAAM,KAAK,OAAO,uBAAuB,aAAa,qBAAqB;AAC3E,QAAI,IAAI;AACN,qBAAe,MAAM,GAAG,CAAC;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT;AAEA,OAAK,GAAG,WAAW,OAAO,sBAA+B;AACvD,UAAM,UAAU,mBAAmB,iBAAiB;AAGpD,QACE,WAAW,QACX,OAAO,YAAY,YACnB,EAAE,QAAQ,YACV,EAAE,YAAY,YACd,EAAE,YAAY,UACd;AACA,UAAI;AACJ,UAAI;AACF,qBAAa,KAAK,UAAU,OAAO;AAAA,MACrC,QAAQ;AACN,qBAAa,OAAO,OAAO;AAAA,MAC7B;AACA,YAAM,gBAAgC;AAAA,QACpC,MAAM;AAAA,QACN,SAAS,EAAE,IAAI,WAAW,QAAQ,WAAW,QAAQ,CAAC,EAAE;AAAA,QACxD,MAAM,IAAI,QAAQ,oEAAkB,UAAU,EAAE;AAAA,MAClD;AACA,YAAM,aAAa,mBAAmB,aAAa;AACnD,WAAK,YAAY,WAAW,QAAQ,WAAW,YAAY;AAC3D;AAAA,IACF;AAC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AAM,SAAS,GAAG,QAAQ,MAAM;AAE/C,YAAM,WAA2B;AAAA,QAC/B;AAAA,QACA,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAEA,YAAM,aAAa,mBAAmB,QAAQ;AAC9C,WAAK,YAAY,WAAW,QAAQ,WAAW,YAAY;AAAA,IAC7D,SAAS,KAAK;AACZ,YAAM,WAA2B;AAAA,QAC/B;AAAA,QACA,MAAM;AAAA,QACN,MAAM,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAAA,MAC1D;AAEA,YAAM,aAAa,mBAAmB,QAAQ;AAC9C,WAAK,YAAY,WAAW,QAAQ,WAAW,YAAY;AAAA,IAC7D;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,WAAW;AAAA,IACX,UAAU,CAAC;AAAA,IACX,KAAuC,OAAU,MAAmB;AAClE,YAAM,WAA2B;AAAA,QAC/B,MAAM;AAAA,QACN;AAAA,QACA,MAAM;AAAA,MACR;AAEA,YAAM,aAAa,mBAAmB,QAAQ;AAC9C,WAAK,YAAY,WAAW,QAAQ,WAAW,YAAY;AAAA,IAC7D;AAAA,EACF;AACF;",
5
5
  "names": []
6
6
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
- * `createWorker()`가 반환하는 워커 모듈의 타입 구조.
3
- * `Worker.create<typeof import("./worker")>()`에서 타입 추론에 사용된다.
2
+ * Type structure of the worker module returned by `createWorker()`.
3
+ * Used for type inference in `Worker.create<typeof import("./worker")>()`.
4
4
  *
5
- * @see createWorker - 워커 모듈 생성
6
- * @see Worker.create - 워커 프록시 생성
5
+ * @see createWorker - Create worker module
6
+ * @see Worker.create - Create worker proxy
7
7
  */
8
8
  export interface WorkerModule {
9
9
  default: {
@@ -12,33 +12,33 @@ export interface WorkerModule {
12
12
  };
13
13
  }
14
14
  /**
15
- * 메서드 타입의 반환값을 Promise로 래핑하는 매핑 타입.
16
- * 워커 메서드는 postMessage 기반으로 동작하여 항상 비동기이므로,
17
- * 동기 메서드 타입도 `Promise<Awaited<R>>`로 변환한다.
15
+ * Mapping type that wraps method return values in Promise.
16
+ * Worker methods operate based on postMessage and are always asynchronous,
17
+ * so synchronous method types are also converted to `Promise<Awaited<R>>`.
18
18
  */
19
19
  export type PromisifyMethods<TMethods> = {
20
20
  [K in keyof TMethods]: TMethods[K] extends (...args: infer P) => infer R ? (...args: P) => Promise<Awaited<R>> : never;
21
21
  };
22
22
  /**
23
- * SdWorker.create()가 반환하는 Proxy 타입.
24
- * Promisified 메서드들 + on() + terminate() 제공.
23
+ * Proxy type returned by Worker.create().
24
+ * Provides promisified methods + on() + terminate().
25
25
  */
26
26
  export type WorkerProxy<TModule extends WorkerModule> = PromisifyMethods<TModule["default"]["__methods"]> & {
27
27
  /**
28
- * 워커 이벤트 리스너 등록.
28
+ * Registers a worker event listener.
29
29
  */
30
30
  on<K extends keyof TModule["default"]["__events"] & string>(event: K, listener: (data: TModule["default"]["__events"][K]) => void): void;
31
31
  /**
32
- * 워커 이벤트 리스너 제거.
32
+ * Unregisters a worker event listener.
33
33
  */
34
34
  off<K extends keyof TModule["default"]["__events"] & string>(event: K, listener: (data: TModule["default"]["__events"][K]) => void): void;
35
35
  /**
36
- * 워커 종료.
36
+ * Terminates the worker.
37
37
  */
38
38
  terminate(): Promise<void>;
39
39
  };
40
40
  /**
41
- * Worker 내부 요청 메시지.
41
+ * Internal worker request message.
42
42
  */
43
43
  export interface WorkerRequest {
44
44
  id: string;
@@ -46,7 +46,7 @@ export interface WorkerRequest {
46
46
  params: unknown[];
47
47
  }
48
48
  /**
49
- * Worker 내부 응답 메시지.
49
+ * Internal worker response message.
50
50
  */
51
51
  export type WorkerResponse = {
52
52
  request: WorkerRequest;
@@ -1,7 +1,7 @@
1
1
  import type { WorkerOptions as WorkerRawOptions } from "worker_threads";
2
2
  import type { WorkerModule, WorkerProxy } from "./types";
3
3
  /**
4
- * 타입 안전한 Worker 래퍼.
4
+ * Type-safe Worker wrapper.
5
5
  *
6
6
  * @example
7
7
  * // worker.ts
@@ -16,11 +16,11 @@ import type { WorkerModule, WorkerProxy } from "./types";
16
16
  */
17
17
  export declare const Worker: {
18
18
  /**
19
- * 타입 안전한 Worker Proxy 생성.
19
+ * Creates a type-safe Worker Proxy.
20
20
  *
21
- * @param filePath - 워커 파일 경로 (file:// URL 또는 절대 경로)
22
- * @param opt - Worker 옵션
23
- * @returns Proxy 객체 (메서드 직접 호출, on(), terminate() 지원)
21
+ * @param filePath - Worker file path (file:// URL or absolute path)
22
+ * @param opt - Worker options
23
+ * @returns Proxy object (supports direct method calls, on(), and terminate())
24
24
  */
25
25
  create<TModule extends WorkerModule>(filePath: string, opt?: Omit<WorkerRawOptions, "stdout" | "stderr">): WorkerProxy<TModule>;
26
26
  };