@simplysm/sd-claude 14.0.91 → 14.0.93
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/claude/references/sd-simplysm14/README.md +7 -6
- package/claude/references/sd-simplysm14/apis/angular/README.md +59 -39
- package/claude/references/sd-simplysm14/apis/angular/controls.md +119 -186
- package/claude/references/sd-simplysm14/apis/angular/crud.md +70 -31
- package/claude/references/sd-simplysm14/apis/angular/directives.md +55 -57
- package/claude/references/sd-simplysm14/apis/angular/features.md +86 -105
- package/claude/references/sd-simplysm14/apis/angular/infra.md +48 -57
- package/claude/references/sd-simplysm14/apis/angular/layout.md +37 -47
- package/claude/references/sd-simplysm14/apis/angular/overlay.md +82 -74
- package/claude/references/sd-simplysm14/apis/angular/routing-appstructure.md +61 -50
- package/claude/references/sd-simplysm14/apis/angular/shared-data.md +74 -57
- package/claude/references/sd-simplysm14/apis/angular/sheet.md +63 -72
- package/claude/references/sd-simplysm14/apis/capacitor-plugin-auto-update/README.md +23 -18
- package/claude/references/sd-simplysm14/apis/capacitor-plugin-file-system/README.md +21 -19
- package/claude/references/sd-simplysm14/apis/capacitor-plugin-intent/README.md +23 -18
- package/claude/references/sd-simplysm14/apis/capacitor-plugin-usb-storage/README.md +72 -32
- package/claude/references/sd-simplysm14/apis/core-browser/README.md +18 -18
- package/claude/references/sd-simplysm14/apis/core-browser/dom-element.md +29 -29
- package/claude/references/sd-simplysm14/apis/core-browser/indexed-db.md +41 -41
- package/claude/references/sd-simplysm14/apis/core-common/README.md +97 -90
- package/claude/references/sd-simplysm14/apis/core-common/async-runtime.md +75 -51
- package/claude/references/sd-simplysm14/apis/core-common/collection-ext.md +81 -0
- package/claude/references/sd-simplysm14/apis/core-common/errors.md +27 -29
- package/claude/references/sd-simplysm14/apis/core-common/obj.md +44 -45
- package/claude/references/sd-simplysm14/apis/core-common/serialization.md +34 -33
- package/claude/references/sd-simplysm14/apis/core-common/value-types.md +86 -0
- package/claude/references/sd-simplysm14/apis/core-node/README.md +6 -6
- package/claude/references/sd-simplysm14/apis/core-node/consola.md +3 -0
- package/claude/references/sd-simplysm14/apis/core-node/cpx.md +2 -2
- package/claude/references/sd-simplysm14/apis/core-node/fs-watcher.md +1 -1
- package/claude/references/sd-simplysm14/apis/core-node/fsx.md +2 -2
- package/claude/references/sd-simplysm14/apis/core-node/worker.md +6 -3
- package/claude/references/sd-simplysm14/apis/excel/README.md +10 -10
- package/claude/references/sd-simplysm14/apis/excel/conditional-format.md +4 -2
- package/claude/references/sd-simplysm14/apis/excel/utils.md +1 -1
- package/claude/references/sd-simplysm14/apis/excel/workbook-worksheet.md +6 -6
- package/claude/references/sd-simplysm14/apis/lint/README.md +6 -32
- package/claude/references/sd-simplysm14/apis/lint/recommended.md +60 -0
- package/claude/references/sd-simplysm14/apis/lint/rules.md +17 -17
- package/claude/references/sd-simplysm14/apis/orm-common/README.md +15 -6
- package/claude/references/sd-simplysm14/apis/orm-common/db-context.md +68 -102
- package/claude/references/sd-simplysm14/apis/orm-common/expr.md +75 -89
- package/claude/references/sd-simplysm14/apis/orm-common/queryable.md +87 -99
- package/claude/references/sd-simplysm14/apis/orm-common/schema.md +110 -147
- package/claude/references/sd-simplysm14/apis/orm-common/types.md +48 -51
- package/claude/references/sd-simplysm14/apis/orm-node/README.md +8 -13
- package/claude/references/sd-simplysm14/apis/orm-node/db-conn.md +5 -5
- package/claude/references/sd-simplysm14/apis/sd-cli/README.md +9 -6
- package/claude/references/sd-simplysm14/apis/sd-cli/SdTsCompiler.md +9 -8
- package/claude/references/sd-simplysm14/apis/sd-cli/sd-config-types.md +23 -19
- package/claude/references/sd-simplysm14/apis/service-client/README.md +20 -12
- package/claude/references/sd-simplysm14/apis/service-client/orm.md +6 -6
- package/claude/references/sd-simplysm14/apis/service-client/transport.md +1 -1
- package/claude/references/sd-simplysm14/apis/service-common/README.md +35 -32
- package/claude/references/sd-simplysm14/apis/service-common/app-structure.md +23 -22
- package/claude/references/sd-simplysm14/apis/service-common/protocol.md +23 -23
- package/claude/references/sd-simplysm14/apis/service-server/README.md +51 -43
- package/claude/references/sd-simplysm14/apis/service-server/service-authoring.md +6 -6
- package/claude/references/sd-simplysm14/apis/service-server/transport-internals.md +31 -21
- package/claude/references/sd-simplysm14/apis/service-server/v1-legacy.md +8 -8
- package/claude/references/sd-simplysm14/apis/storage/README.md +55 -49
- package/claude/references/sd-simplysm14/manuals/client-component.md +843 -740
- package/claude/references/sd-simplysm14/manuals/client-crud.md +8 -0
- package/claude/references/sd-simplysm14/manuals/client-demo.md +6 -16
- package/claude/references/sd-simplysm14/manuals/client-shared-data.md +26 -0
- package/claude/references/sd-simplysm14/manuals/logging.md +1 -1
- package/claude/references/sd-simplysm14/manuals/orm.md +15 -1
- package/claude/rules/sd-design-rules.md +7 -0
- package/claude/sd-system-prompt.md +5 -8
- package/claude/skills/sd-debug/SKILL.md +43 -0
- package/claude/skills/sd-debug/workflow.js +390 -0
- package/claude/skills/sd-demo/SKILL.md +18 -20
- package/claude/skills/sd-dev/SKILL.md +127 -24
- package/claude/skills/sd-docs/SKILL.md +5 -3
- package/claude/skills/sd-docs/references/subagent-prompt.md +2 -3
- package/claude/skills/sd-impl/SKILL.md +18 -18
- package/claude/skills/sd-manual/SKILL.md +1 -0
- package/claude/skills/sd-review/SKILL.md +24 -18
- package/claude/skills/sd-review/workflow.js +324 -0
- package/claude/skills/sd-spec/SKILL.md +96 -679
- package/claude/skills/sd-spec/references/example-spec.md +28 -50
- package/claude/skills/sd-spec/references/format-analyze.md +232 -0
- package/claude/skills/sd-spec/references/format-design.md +248 -0
- package/claude/skills/sd-spec/workflow-analyze.js +615 -0
- package/claude/skills/sd-spec/workflow-design.js +667 -0
- package/claude/skills/sd-unpack/scripts/handlers/office_com.py +5 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +157 -18
- package/claude/references/sd-simplysm14/apis/angular/selection-managers.md +0 -68
- package/claude/references/sd-simplysm14/apis/core-common/array-ext.md +0 -77
- package/claude/references/sd-simplysm14/apis/core-common/datetime.md +0 -86
- package/claude/skills/sd-skill/SKILL.md +0 -245
- package/claude/skills/sd-skill/scripts/run_eval.py +0 -380
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
# @simplysm/capacitor-plugin-file-system
|
|
2
2
|
|
|
3
|
-
Capacitor 네이티브 파일 시스템 접근 플러그인. Android
|
|
3
|
+
Capacitor 네이티브 파일 시스템 접근 플러그인. Android 에서는 OS 파일 시스템(11+ `MANAGE_EXTERNAL_STORAGE`, 10- `READ/WRITE_EXTERNAL_STORAGE` 권한)에, 웹에서는 IndexedDB 기반 가상 파일 시스템 에뮬레이션에 동일 API 로 접근한다. 진입점은 `FileSystem` 정적 클래스이며, 입출력 형태는 `StorageType`·`FileInfo`·`FileSystemPlugin` 타입으로 기술된다.
|
|
4
4
|
|
|
5
5
|
## 사용 트리거 인덱스
|
|
6
6
|
|
|
7
|
-
- **FileSystem** — 앱에서 단말 파일을 읽고 쓰거나
|
|
8
|
-
- **StorageType** — `getStoragePath` 인자.
|
|
9
|
-
- **FileInfo** — `readdir` 결과 항목
|
|
10
|
-
- **FileSystemPlugin** — 저수준 Capacitor 플러그인 인터페이스(옵션 객체 기반 원형). 보통 직접 쓰지 않고 `FileSystem` 래퍼를 쓰며, 커스텀
|
|
7
|
+
- **FileSystem** — 앱에서 단말 파일을 읽고 쓰거나 디렉토리·권한·저장소 경로·파일 URI 를 다룰 때의 진입점. 모든 메서드가 `static async` 이며 `new` 없이 `FileSystem.메서드()` 로 호출(abstract class).
|
|
8
|
+
- **StorageType** — `getStoragePath` 인자. 외부/앱 전용/캐시 등 어느 표준 저장소의 기준 경로를 얻을지 고를 때.
|
|
9
|
+
- **FileInfo** — `readdir` 결과 항목 1건의 타입(이름 + 디렉토리 여부). 디렉토리 나열 결과를 순회·분기할 때.
|
|
10
|
+
- **FileSystemPlugin** — 저수준 Capacitor 플러그인 계약 인터페이스(옵션 객체 기반 원형). 보통 직접 쓰지 않고 `FileSystem` 래퍼를 쓰며, 커스텀 web 구현이나 옵션·반환 타입 참조가 필요할 때만 사용.
|
|
11
11
|
|
|
12
12
|
## FileSystem
|
|
13
13
|
|
|
14
|
-
모든 파일 작업의 진입점. 추상 클래스의 정적 메서드 모음이라
|
|
14
|
+
모든 파일 작업의 진입점. 추상 클래스의 정적 메서드 모음이라 인스턴스화 없이 호출한다. 내부적으로 `registerPlugin<FileSystemPlugin>("FileSystem")` 로 얻은 네이티브 구현(웹은 `FileSystemWeb`)에 위임하고, 플러그인의 `{ ... }` 래퍼 결과를 평탄화해 반환한다. 모든 메서드는 Promise 반환.
|
|
15
15
|
|
|
16
|
-
- `static checkPermissions(): Promise<boolean>` — 파일 접근 권한 보유
|
|
17
|
-
- `static requestPermissions(): Promise<void>` — 권한 요청. Android 11+ 는
|
|
18
|
-
- `static readdir(dirPath: string): Promise<FileInfo[]>` —
|
|
19
|
-
- `static getStoragePath(type: StorageType): Promise<string>` — 표준 저장소 위치의 기준 경로
|
|
20
|
-
- `static getUri(filePath: string): Promise<string>` — 파일을 외부에 넘길 수 있는 URI
|
|
21
|
-
- `static writeFile(filePath: string, data: string | Bytes): Promise<void>` — 파일 쓰기(
|
|
22
|
-
- `static readFile(filePath: string): Promise<Bytes>` / `static readFile(filePath: string, encoding: "utf8"): Promise<string>` — 파일 읽기
|
|
23
|
-
- `
|
|
24
|
-
- `
|
|
25
|
-
- `static
|
|
16
|
+
- `static checkPermissions(): Promise<boolean>` — 파일 접근 권한 보유 여부. `true` = 권한 있음, `false` = 없음. 웹은 항상 `true`. 읽기/쓰기 전 게이트로 호출. 플러그인의 `{ granted }` 를 boolean 으로 풀어 반환.
|
|
17
|
+
- `static requestPermissions(): Promise<void>` — 권한 요청. Android 11+ 는 설정 화면으로 이동, Android 10- 는 권한 대화상자 표시. 웹은 무동작. `checkPermissions()` 가 `false` 일 때 호출.
|
|
18
|
+
- `static readdir(dirPath: string): Promise<FileInfo[]>` — `dirPath` 디렉토리의 직접 하위 항목을 나열. 디렉토리가 없으면 throw. 각 항목은 `FileInfo`(이름·디렉토리 여부). 폴더 내용을 훑을 때.
|
|
19
|
+
- `static getStoragePath(type: StorageType): Promise<string>` — `type` 에 해당하는 표준 저장소 위치의 기준 경로 문자열. 경로를 하드코딩하지 말고 이 값으로 베이스를 얻어 join. 웹은 `/webfs/<type>` 가상 경로를 자동 생성 후 반환.
|
|
20
|
+
- `static getUri(filePath: string): Promise<string>` — 파일을 외부에 넘길 수 있는 URI. Android 는 FileProvider content:// URI(타 앱 공유·뷰어 인텐트용), 웹은 `URL.createObjectURL` Blob URL. 웹의 Blob URL 은 사용 후 반드시 `URL.revokeObjectURL(uri)` 로 해제(미해제 시 메모리 누수). 파일이 없으면 throw.
|
|
21
|
+
- `static writeFile(filePath: string, data: string | Bytes): Promise<void>` — 파일 쓰기(상위 디렉토리 자동 생성). `data` 가 `string` 이면 utf8 로, `Bytes`(Uint8Array)이면 base64 로 변환해 바이너리 저장(`bytes.toBase64`, cross-realm 안전). 텍스트면 문자열, 바이너리면 `Bytes` 를 넘김.
|
|
22
|
+
- `static readFile(filePath: string): Promise<Bytes>` / `static readFile(filePath: string, encoding: "utf8"): Promise<string>` — 파일 읽기(오버로드). 반환 타입이 인자로 갈리므로 바이너리는 인자 없이, 텍스트는 `"utf8"` 명시. 파일이 없으면 throw.
|
|
23
|
+
- `encoding` 생략 — base64 로 읽어 `Bytes`(`bytes.fromBase64`) 반환. 이미지·바이너리 파일용.
|
|
24
|
+
- `encoding: "utf8"` — utf8 텍스트 `string` 반환. 텍스트 파일을 문자열로 바로 다룰 때.
|
|
25
|
+
- `static remove(targetPath: string): Promise<void>` — 파일/디렉토리 재귀 삭제(디렉토리면 하위 전체). 실패 시 throw. 정리·덮어쓰기 전 제거 시.
|
|
26
|
+
- `static mkdir(targetPath: string): Promise<void>` — 디렉토리 재귀 생성(중간 상위 경로까지, 이미 있으면 무동작). `writeFile` 은 부모를 자동 생성하므로 빈 디렉토리만 보장하면 될 때 사용.
|
|
27
|
+
- `static exists(targetPath: string): Promise<boolean>` — 경로 존재 여부. `true` = 파일·디렉토리 존재, `false` = 없음. 읽기/삭제 전 분기 조건.
|
|
26
28
|
|
|
27
|
-
`data` 의 `Bytes` 는 `@simplysm/core-common` 의 바이트 배열 타입(Uint8Array 계열).
|
|
29
|
+
`data` 의 `Bytes` 와 `readFile` 반환 `Bytes` 는 `@simplysm/core-common` 의 바이트 배열 타입(Uint8Array 계열). 바이너리는 내부에서 base64 왕복 처리한다.
|
|
28
30
|
|
|
29
31
|
사용 예:
|
|
30
32
|
|
|
@@ -76,11 +78,11 @@ interface FileInfo {
|
|
|
76
78
|
```
|
|
77
79
|
|
|
78
80
|
- `name: string` — 항목 이름(경로가 아닌 파일/디렉토리명). 표시·필터·경로 결합 시.
|
|
79
|
-
- `isDirectory: boolean` — 디렉토리 여부. true = 하위 디렉토리(재귀 탐색 대상), false = 파일. 파일만 처리할지 폴더로 내려갈지 분기할 때.
|
|
81
|
+
- `isDirectory: boolean` — 디렉토리 여부. `true` = 하위 디렉토리(재귀 탐색 대상), `false` = 파일. 파일만 처리할지 폴더로 내려갈지 분기할 때.
|
|
80
82
|
|
|
81
83
|
## FileSystemPlugin
|
|
82
84
|
|
|
83
|
-
저수준 Capacitor 플러그인 인터페이스. `FileSystem` 정적 메서드가 내부에서 위임하는 원형으로, 메서드가 옵션 객체(`{ path }`, `{ type }`, `{ path, data, encoding }`)를 받고 결과도 래핑 객체(`{ granted }`, `{ files }`, `{ path }`, `{ uri }`, `{ data }`, `{ exists }`)로 반환한다. 보통 직접 호출하지 않으며, 커스텀 web 구현(`FileSystemPlugin` 구현)을 작성하거나
|
|
85
|
+
저수준 Capacitor 플러그인 계약 인터페이스. `FileSystem` 정적 메서드가 내부에서 위임하는 원형으로, 메서드가 옵션 객체(`{ path }`, `{ type }`, `{ path, data, encoding }`)를 받고 결과도 래핑 객체(`{ granted }`, `{ files }`, `{ path }`, `{ uri }`, `{ data }`, `{ exists }`)로 반환한다. 보통 직접 호출하지 않으며, 커스텀 web 구현(`FileSystemPlugin` 구현)을 작성하거나 옵션·반환 타입을 참조해야 할 때만 사용한다.
|
|
84
86
|
|
|
85
87
|
- `checkPermissions(): Promise<{ granted: boolean }>` — 권한 보유 여부를 `granted` 로 반환.
|
|
86
88
|
- `requestPermissions(): Promise<void>` — 권한 요청.
|
|
@@ -1,44 +1,49 @@
|
|
|
1
1
|
# @simplysm/capacitor-plugin-intent
|
|
2
2
|
|
|
3
|
-
Android 인텐트
|
|
3
|
+
Android 인텐트 송수신 Capacitor 플러그인. 정적 클래스 `Intent` 로 브로드캐스트 구독/전송·실행 인텐트 조회·newIntent 리스닝·startActivityForResult 외부 Activity 실행을 수행한다. 바코드 스캐너·PDA(예: Zebra DataWedge) 등 산업용 디바이스 연동 시 사용. 웹 환경(`IntentWeb` 스텁)에서는 실제 동작 없이 경고 로그만 남기고 무해한 기본값을 반환하므로 실제 인텐트 처리는 Android 네이티브에서만 일어난다.
|
|
4
4
|
|
|
5
5
|
## 사용 트리거 인덱스
|
|
6
6
|
|
|
7
|
-
- **Intent** — 인텐트 작업의 정적 진입점(추상 클래스). 브로드캐스트
|
|
8
|
-
-
|
|
9
|
-
- **IntentPlugin** — `registerPlugin` 에 쓰이는 Capacitor 네이티브 플러그인 계약. 보통 직접 호출하지 않고 `Intent` 정적 메서드를 거치며,
|
|
7
|
+
- **Intent** — 인텐트 작업의 정적 진입점(추상 클래스). 브로드캐스트 수신기 등록/해제(`subscribe`/`unsubscribeAll`), 브로드캐스트 전송(`send`), 앱 실행 인텐트 조회(`getLaunchIntent`), 실행 중 새 인텐트 리스닝(`addListener`/`removeAllListeners`), 외부 Activity 실행 후 결과 수신(`startActivityForResult`) 이 필요할 때. 아래 인라인 섹션 참조.
|
|
8
|
+
- **결과·옵션 타입** (`IntentResult`, `StartActivityForResultOptions`, `StartActivityForResultResult`) — `Intent` 메서드의 콜백 인자·반환·실행 옵션을 타입으로 다룰 때. 아래 인라인 섹션 참조.
|
|
9
|
+
- **IntentPlugin** — `registerPlugin` 에 쓰이는 Capacitor 네이티브 플러그인 저수준 계약. 보통 직접 호출하지 않고 `Intent` 정적 메서드를 거치며, 네이티브 구현·웹 스텁의 계약 확인용. 아래 인라인 섹션 참조.
|
|
10
10
|
|
|
11
11
|
## Intent (정적 클래스)
|
|
12
12
|
|
|
13
|
-
`abstract class Intent` — 정적 메서드만 가진 진입점. 인스턴스화하지 않고 `Intent.xxx()` 형태로 호출하며 모든 메서드는 비동기(`Promise`). 내부적으로 `registerPlugin<IntentPlugin>("Intent")` 로 얻은 플러그인(웹은 `IntentWeb`)을
|
|
13
|
+
`abstract class Intent` — 정적 메서드만 가진 진입점. 인스턴스화하지 않고 `Intent.xxx()` 형태로 호출하며 모든 메서드는 비동기(`Promise`). 내부적으로 `registerPlugin<IntentPlugin>("Intent")` 로 얻은 플러그인(웹은 `IntentWeb`)을 래핑한다.
|
|
14
14
|
|
|
15
|
-
- `Intent.subscribe(filters: string[], callback: (result: IntentResult) => void): Promise<() => Promise<void>>` — 브로드캐스트
|
|
15
|
+
- `Intent.subscribe(filters: string[], callback: (result: IntentResult) => void): Promise<() => Promise<void>>` — 브로드캐스트 수신기를 등록하고, 호출하면 해당 구독만 해제하는 함수를 resolve.
|
|
16
16
|
- `filters: string[]` — 수신할 인텐트 액션 문자열 배열(예: `"com.symbol.datawedge.api.RESULT_ACTION"`). 이 액션들로 들어오는 브로드캐스트만 콜백으로 전달. 스캐너 결과 액션 등 수신 대상 액션을 등록할 때 지정.
|
|
17
|
-
- `callback: (result: IntentResult) => void` — 매칭 브로드캐스트 도착 시마다 호출. 등록 직후 플러그인이 보내는 `{ id }` 만 담긴 초기 resolve(`result.action == null`)는 내부에서 걸러져 호출되지
|
|
18
|
-
- 반환: 구독 해제 함수 `() => Promise<void>`. 호출 시 내부 `id` 로 해당 수신기만 해제. 화면 진입 시 등록하고 이탈 시 반환 함수로
|
|
19
|
-
- `Intent.unsubscribeAll(): Promise<void>` — 등록된 모든 브로드캐스트 수신기를 한 번에 해제. 개별 해제 함수를 보관하지 않았거나 화면 정리 시 전체를
|
|
20
|
-
- `Intent.send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>` — 브로드캐스트 전송.
|
|
17
|
+
- `callback: (result: IntentResult) => void` — 매칭 브로드캐스트 도착 시마다 호출. 등록 직후 플러그인이 보내는 `{ id }` 만 담긴 초기 resolve(`result.action == null`)는 내부에서 걸러져 호출되지 않으며, `action` 이 채워진 실제 수신 시점에만 호출.
|
|
18
|
+
- 반환: 구독 해제 함수 `() => Promise<void>`. `await` 한 결과가 이 함수이며 호출(다시 `await`) 시 내부 `id` 로 해당 수신기만 해제. 화면 진입 시 등록하고 이탈 시 반환 함수로 해제하는 용도.
|
|
19
|
+
- `Intent.unsubscribeAll(): Promise<void>` — 등록된 모든 브로드캐스트 수신기를 한 번에 해제. 개별 해제 함수를 보관하지 않았거나 화면 정리 시 전체를 일괄로 끊을 때.
|
|
20
|
+
- `Intent.send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>` — 브로드캐스트 전송. 스캐너 트리거 토글 등 디바이스 제어 명령 송신에 사용.
|
|
21
21
|
- `action: string` — 전송할 인텐트 액션 문자열(필수). 디바이스 API 가 정의한 명령 액션을 지정.
|
|
22
22
|
- `extras?: Record<string, unknown>` — 함께 보낼 추가 키-값 데이터(선택). 명령 파라미터(예: 스캐너 트리거 토글 값)를 담을 때.
|
|
23
|
-
- `Intent.getLaunchIntent(): Promise<IntentResult>` — 앱을 실행시킨 인텐트 조회. 외부 인텐트로 앱이 기동됐는지·그 `extras` 를 앱 시작 시점에 읽을 때. 웹 스텁은 항상 빈 객체 `{}` 반환.
|
|
24
|
-
- `Intent.addListener(eventName: "newIntent", callback: (result: IntentResult) => void): Promise<PluginListenerHandle>` —
|
|
23
|
+
- `Intent.getLaunchIntent(): Promise<IntentResult>` — 앱을 실행시킨 인텐트(action·extras)를 조회. 외부 인텐트로 앱이 기동됐는지·그 `extras` 를 앱 시작 시점에 읽을 때. 웹 스텁은 항상 빈 객체 `{}` 반환.
|
|
24
|
+
- `Intent.addListener(eventName: "newIntent", callback: (result: IntentResult) => void): Promise<PluginListenerHandle>` — 앱이 이미 실행 중인 상태에서 새로 도착하는 인텐트(`onNewIntent`)를 리스닝.
|
|
25
25
|
- `eventName: "newIntent"` — 리스닝 대상 이벤트(현재 이 리터럴 하나만 지원). 이미 떠 있는 앱에 인텐트가 재전달되는 singleTop 등 상황에서 발생.
|
|
26
|
-
- `callback: (result: IntentResult) => void` — 새 인텐트 수신 시 호출.
|
|
26
|
+
- `callback: (result: IntentResult) => void` — 새 인텐트 수신 시 호출. `subscribe` 와 달리 액션 필터 없이 들어오는 새 인텐트의 `action`·`extras` 를 받음.
|
|
27
27
|
- 반환: `PluginListenerHandle`(@capacitor/core). `handle.remove()` 로 이 리스너만 개별 해제.
|
|
28
|
-
- `Intent.removeAllListeners(): Promise<void>` — `addListener` 로 등록한 모든 이벤트 리스너를 일괄 제거. subscribe(브로드캐스트 수신기)와는 별개 채널이므로 둘 다 쓰면 각각 정리해야 함.
|
|
29
|
-
- `Intent.startActivityForResult(options: StartActivityForResultOptions): Promise<StartActivityForResultResult>` — 외부 Activity 를 실행하고
|
|
28
|
+
- `Intent.removeAllListeners(): Promise<void>` — `addListener` 로 등록한 모든 이벤트 리스너를 일괄 제거. `subscribe`(브로드캐스트 수신기)와는 별개 채널이므로 둘 다 쓰면 각각 정리해야 함.
|
|
29
|
+
- `Intent.startActivityForResult(options: StartActivityForResultOptions): Promise<StartActivityForResultResult>` — 외부 Activity 를 실행하고 그 결과 코드·데이터를 `await` 로 직접 수신. 결제·서명 등 외부 앱에 1회성 작업을 위임하고 응답을 되받아야 할 때. 반환 `resultCode` 로 성공 판정(Android 규약상 `-1` = RESULT_OK, `0` = RESULT_CANCELED). 옵션·결과 필드는 아래 "결과·옵션 타입" 참조.
|
|
30
|
+
|
|
31
|
+
`subscribe`/`unsubscribeAll` 은 구독 핸들로 끊거나 일괄로 끊는 두 경로를 제공하므로, 화면별로는 `subscribe` 의 반환 함수를, 전역 정리에는 `unsubscribeAll` 을 쓴다. `addListener`/`removeAllListeners` 는 newIntent 이벤트용 동일 패턴이며 브로드캐스트 수신기와 별개 채널이다.
|
|
30
32
|
|
|
31
33
|
사용 예:
|
|
32
34
|
|
|
33
35
|
```ts
|
|
36
|
+
// 바코드 스캐너 결과 브로드캐스트 구독
|
|
34
37
|
const unsub = await Intent.subscribe(
|
|
35
38
|
["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
36
39
|
(result) => console.log(result.action, result.extras),
|
|
37
40
|
);
|
|
41
|
+
// 스캐너 트리거 토글 전송
|
|
38
42
|
await Intent.send({
|
|
39
43
|
action: "com.symbol.datawedge.api.ACTION",
|
|
40
44
|
extras: { "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING" },
|
|
41
45
|
});
|
|
46
|
+
// 외부 Activity 실행 후 결과 수신
|
|
42
47
|
const res = await Intent.startActivityForResult({ action: "com.example.PAY", extras: { amount: 1000 } });
|
|
43
48
|
if (res.resultCode === -1) { /* RESULT_OK */ }
|
|
44
49
|
await unsub(); // 개별 해제
|
|
@@ -46,7 +51,7 @@ await unsub(); // 개별 해제
|
|
|
46
51
|
|
|
47
52
|
주의: 웹 플랫폼(`IntentWeb`)에서는 `subscribe`·`send`·`startActivityForResult` 가 실제 동작 없이 경고 로그(`createLogger("capacitor:intent")` → `"웹 환경에서는 지원하지 않습니다."`)만 남긴다. 이때 `subscribe` 는 `{ id: "web-stub" }`(콜백 미호출), `getLaunchIntent` 는 `{}`(경고 없음), `startActivityForResult` 는 `{ resultCode: 0 }`(항상 CANCELED 로 보임)을 반환하고, `unsubscribe`·`unsubscribeAll` 은 무동작. 웹·하이브리드 공용 코드에서 호출해도 예외는 나지 않으나 인텐트 동작은 Android 에서만 발생함을 전제로 작성할 것.
|
|
48
53
|
|
|
49
|
-
##
|
|
54
|
+
## 결과·옵션 타입
|
|
50
55
|
|
|
51
56
|
`Intent` 메서드의 결과·옵션을 타입으로 다룰 때 참조하는 인터페이스. "값 없음"은 그대로 `undefined` 로 전달되므로 호출부에서 optional 로 다룰 것.
|
|
52
57
|
|
|
@@ -60,7 +65,7 @@ await unsub(); // 개별 해제
|
|
|
60
65
|
- `type?: string` — MIME 타입. 데이터 형식으로 처리 대상 앱을 좁힐 때.
|
|
61
66
|
- `packageName?: string` — 실행할 특정 앱 패키지명. 명시적 인텐트화(특정 앱으로만 실행)할 때.
|
|
62
67
|
- `className?: string` — 실행할 특정 Activity 클래스명. `packageName` 과 함께 컴포넌트를 직접 지정할 때.
|
|
63
|
-
- `flags?: number` — Android Intent flags
|
|
68
|
+
- `flags?: number` — Android Intent flags 비트값(`Intent.FLAG_*`). 실행 모드(새 태스크 시작 등) 제어가 필요할 때.
|
|
64
69
|
- `StartActivityForResultResult` — `startActivityForResult` 반환.
|
|
65
70
|
- `resultCode: number` — Activity 결과 코드(필수). Android 규약상 `-1` = RESULT_OK, `0` = RESULT_CANCELED. 성공/취소 분기 판단에 사용(웹 스텁은 항상 `0`).
|
|
66
71
|
- `data?: { action?: string; uri?: string; extras?: Record<string, unknown> }` — 결과 인텐트 데이터(선택, 결과 없으면 부재). `action` = 결과 인텐트 액션, `uri` = 결과 data URI, `extras` = 결과 추가 데이터. 결과 본문은 `data?.extras` 형태로 접근.
|
|
@@ -70,7 +75,7 @@ await unsub(); // 개별 해제
|
|
|
70
75
|
`interface IntentPlugin` — `registerPlugin<IntentPlugin>("Intent")` 에 쓰이는 Capacitor 네이티브 플러그인 계약. 웹 구현(`IntentWeb`)과 Android 네이티브가 이를 구현. 일반 사용 코드는 `Intent` 정적 메서드를 쓰고 이 인터페이스를 직접 호출하지 않으며, 네이티브 구현·웹 스텁이 충족해야 할 저수준 계약을 확인할 때만 참조.
|
|
71
76
|
|
|
72
77
|
- `subscribe(options: { filters: string[] }, callback: (result: IntentResult) => void): Promise<{ id: string }>` — 수신기 등록 후 해제용 `id` 반환. `Intent.subscribe` 가 이 `id` 를 클로저로 보관해 반환 함수에서 `unsubscribe` 에 넘김.
|
|
73
|
-
- `unsubscribe(options: { id: string }): Promise<void>` — 주어진 `id` 의 수신기만 해제.
|
|
78
|
+
- `unsubscribe(options: { id: string }): Promise<void>` — 주어진 `id` 의 수신기만 해제. 단일 구독 해제는 `IntentPlugin` 에만 있고 `Intent` 클래스에서는 `subscribe` 가 돌려주는 해제 함수로 대체됨.
|
|
74
79
|
- `unsubscribeAll(): Promise<void>` — 모든 수신기 해제.
|
|
75
80
|
- `send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>` — 브로드캐스트 전송.
|
|
76
81
|
- `getLaunchIntent(): Promise<IntentResult>` — 실행 인텐트 조회.
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
# @simplysm/capacitor-plugin-usb-storage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
연결된 USB Mass Storage 장치를 열거하고, 장치별 접근 권한을 확인·요청한 뒤 디렉토리·파일을 읽는 Capacitor 플러그인. Android 는 libaums 라이브러리로 USB Mass Storage 에 접근하고, 웹은 IndexedDB 기반 가상 USB 저장소(`capacitor_usb_virtual_storage` DB)로 동일 API 를 에뮬레이션한다. 모든 호출은 `vendorId`/`productId` 조합(`UsbDeviceFilter`)으로 대상 장치를 지정하며, `UsbStorage` 정적 메서드가 진입점이다.
|
|
4
4
|
|
|
5
5
|
## 사용 트리거 인덱스
|
|
6
6
|
|
|
7
|
-
- **UsbStorage** — USB 저장
|
|
8
|
-
- **
|
|
7
|
+
- **UsbStorage** — 앱에서 USB 저장 장치를 다룰 때의 진입점. 장치 목록 조회·권한 확인/요청·디렉토리 나열·파일 읽기 전반. 모든 메서드가 `static async` 이며 인스턴스화 불필요(abstract class).
|
|
8
|
+
- **UsbDeviceFilter** — `requestPermissions`/`checkPermissions`/`readdir`/`readFile` 의 대상 장치 지정 인자. `getDevices` 로 얻은 장치 중 하나를 vendorId/productId 로 가리킬 때.
|
|
9
|
+
- **UsbDeviceInfo** — `getDevices` 결과 항목 타입. 연결된 장치를 표시·선택하거나 거기서 filter 를 만들 때.
|
|
10
|
+
- **UsbFileInfo** — `readdir` 결과 항목 타입. 디렉토리 나열 결과를 순회·필터할 때.
|
|
11
|
+
- **UsbStoragePlugin** — 저수준 Capacitor 플러그인 인터페이스(옵션 객체 기반 원형). 보통 직접 쓰지 않고 `UsbStorage` 래퍼를 쓰며, 커스텀 네이티브/web 구현이나 옵션·반환 타입 참조가 필요할 때만 사용.
|
|
9
12
|
|
|
10
13
|
## UsbStorage
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
모든 USB 저장 작업의 진입점. 추상 클래스의 정적 메서드 모음이라 `new` 없이 `UsbStorage.메서드()` 로 호출한다. 내부적으로 `registerPlugin<UsbStoragePlugin>("UsbStorage")` 로 얻은 네이티브 구현(웹은 `UsbStorageWeb`)에 위임하고, 플러그인의 `{ ... }` 래퍼 결과를 평탄화해 반환한다. 대상 장치는 항상 `UsbDeviceFilter`(`{ vendorId, productId }`) 로 지정하며 readdir/readFile 도 매 호출마다 filter 를 받는다(상태 없음).
|
|
13
16
|
|
|
14
|
-
- `static getDevices(): Promise<UsbDeviceInfo[]>` — 현재 연결된 USB 장치 목록 조회. 권한과 무관하게 열거되며, 반환 항목의 `vendorId`/`productId` 를 추려 이후 호출의 filter 로 사용. 흐름의 첫
|
|
15
|
-
- `static
|
|
16
|
-
- `static
|
|
17
|
-
- `static readdir(filter: UsbDeviceFilter, dirPath: string): Promise<UsbFileInfo[]>` — 지정 장치의 `dirPath`
|
|
18
|
-
- `static readFile(filter: UsbDeviceFilter, filePath: string): Promise<Bytes | undefined>` — 지정 장치의 `
|
|
17
|
+
- `static getDevices(): Promise<UsbDeviceInfo[]>` — 현재 연결된 USB 장치 목록 조회. 빈 배열이면 연결된 장치 없음. 권한과 무관하게 열거되며, 반환 항목의 `vendorId`/`productId` 를 추려 이후 호출의 filter 로 사용. 목록 UI 를 채우거나 흐름의 첫 단계에서 호출. 플러그인의 `{ devices }` 를 배열로 풀어 반환.
|
|
18
|
+
- `static checkPermissions(filter: UsbDeviceFilter): Promise<boolean>` — 다이얼로그 없이 지정 장치 접근 권한 보유 여부만 확인. true = 이미 보유(requestPermissions 생략 가능), false = 미보유(요청 필요). 웹은 항상 true. `readdir`/`readFile` 전 게이트로 호출. 플러그인의 `{ granted }` 를 boolean 으로 풀어 반환.
|
|
19
|
+
- `static requestPermissions(filter: UsbDeviceFilter): Promise<boolean>` — 지정 장치 접근 권한을 사용자에게 요청(다이얼로그). true = 승인, false = 거부(이때 읽기 중단). 웹은 항상 true. `checkPermissions` 가 false 일 때 호출. 플러그인의 `{ granted }` 를 boolean 으로 풀어 반환.
|
|
20
|
+
- `static readdir(filter: UsbDeviceFilter, dirPath: string): Promise<UsbFileInfo[]>` — 지정 장치의 디렉토리 항목 나열. `filter` = 대상 장치, `dirPath` = 나열할 디렉토리 경로(루트는 `"/"`). 각 항목은 `UsbFileInfo`(이름·디렉토리 여부)로, 트리를 순회하려면 `isDirectory === true` 인 항목을 다시 readdir. 폴더 내용을 훑을 때. 플러그인의 `{ files }` 를 배열로 풀어 반환.
|
|
21
|
+
- `static readFile(filter: UsbDeviceFilter, filePath: string): Promise<Bytes | undefined>` — 지정 장치의 파일 읽기. `filter` = 대상 장치, `filePath` = 읽을 파일 경로. 플러그인이 base64 문자열로 준 데이터를 `bytes.fromBase64` 로 `Bytes`(Uint8Array 계열)로 디코드해 반환. 파일이 없거나 데이터가 `null` 이면 `undefined`(결측 그대로 전파 — `""`·기본값 치환 금지). 읽은 바이너리를 가공·저장할 때.
|
|
22
|
+
|
|
23
|
+
반환 `Bytes` 는 `@simplysm/core-common` 의 바이트 배열 타입. 플러그인 레벨에서는 base64 문자열로 주고받고, `UsbStorage.readFile` 가 base64 ↔ `Bytes` 변환을 담당한다.
|
|
19
24
|
|
|
20
25
|
사용 예:
|
|
21
26
|
|
|
@@ -32,31 +37,66 @@ if (!(await UsbStorage.checkPermissions(filter))) {
|
|
|
32
37
|
|
|
33
38
|
for (const entry of await UsbStorage.readdir(filter, "/")) {
|
|
34
39
|
if (entry.isDirectory) continue; // 폴더면 하위 readdir 로 순회
|
|
35
|
-
const data = await UsbStorage.readFile(filter, `/${entry.name}`);
|
|
40
|
+
const data = await UsbStorage.readFile(filter, `/${entry.name}`); // Bytes | undefined
|
|
36
41
|
if (data === undefined) continue; // 파일 없음/데이터 없음
|
|
37
42
|
// data: Bytes 사용
|
|
38
43
|
}
|
|
39
44
|
```
|
|
40
45
|
|
|
41
|
-
##
|
|
42
|
-
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
## UsbDeviceFilter
|
|
47
|
+
|
|
48
|
+
권한 메서드와 `readdir`/`readFile` 가 대상 장치를 가리키는 데 쓰는 식별 인자. 보통 `getDevices` 결과 항목의 `vendorId`/`productId` 를 그대로 옮겨 만든다.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
interface UsbDeviceFilter {
|
|
52
|
+
vendorId: number;
|
|
53
|
+
productId: number;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `vendorId: number` — 대상 USB 장치 벤더 ID(제조사 식별 코드). `UsbDeviceInfo.vendorId` 를 그대로 넘김. 같은 제조사여도 모델 구분은 `productId` 로.
|
|
58
|
+
- `productId: number` — 대상 USB 장치 제품 ID(모델 식별 코드). `UsbDeviceInfo.productId` 를 그대로 넘김. `vendorId` 와 조합해 하나의 장치를 특정(웹 구현은 `${vendorId}:${productId}` 를 장치 키로 사용).
|
|
59
|
+
|
|
60
|
+
## UsbDeviceInfo
|
|
61
|
+
|
|
62
|
+
`getDevices` 가 반환하는 연결 장치 1건. 표시·선택용 메타데이터에 더해 `UsbDeviceFilter` 를 만들 두 ID 를 포함한다.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
interface UsbDeviceInfo {
|
|
66
|
+
deviceName: string;
|
|
67
|
+
manufacturerName: string;
|
|
68
|
+
productName: string;
|
|
69
|
+
vendorId: number;
|
|
70
|
+
productId: number;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- `deviceName: string` — OS 가 부여한 장치 시스템 이름(식별 문자열). 디버깅·로그·표시용.
|
|
75
|
+
- `manufacturerName: string` — 제조사 표시명. 사람이 읽는 장치 라벨을 만들거나 동일 제품명을 구분할 때.
|
|
76
|
+
- `productName: string` — 제품 표시명. 목록 UI 의 장치 항목 라벨에 사용.
|
|
77
|
+
- `vendorId: number` — 벤더 ID. 이 값을 `UsbDeviceFilter.vendorId` 로 옮겨 권한·읽기 호출에 사용.
|
|
78
|
+
- `productId: number` — 제품 ID. 이 값을 `UsbDeviceFilter.productId` 로 옮겨 권한·읽기 호출에 사용.
|
|
79
|
+
|
|
80
|
+
## UsbFileInfo
|
|
81
|
+
|
|
82
|
+
`readdir` 가 반환하는 디렉토리 항목 1건.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
interface UsbFileInfo {
|
|
86
|
+
name: string;
|
|
87
|
+
isDirectory: boolean;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- `name: string` — 항목 이름(경로가 아닌 단일 세그먼트의 파일/디렉토리명). readFile·하위 readdir 경로를 만들 때 부모 경로에 이어붙임.
|
|
92
|
+
- `isDirectory: boolean` — 디렉토리 여부. true = 하위 디렉토리(다시 readdir 대상), false = 파일(readFile 대상). 트리 순회·파일 필터링의 분기 기준.
|
|
93
|
+
|
|
94
|
+
## UsbStoragePlugin
|
|
95
|
+
|
|
96
|
+
저수준 Capacitor 플러그인 인터페이스. `UsbStorage` 정적 메서드가 내부에서 위임하는 원형으로, 메서드가 옵션 객체(`UsbDeviceFilter`, 또는 거기에 `path` 를 더한 형태)를 받고 결과도 래핑 객체(`{ devices }`·`{ granted }`·`{ files }`·`{ data }`)로 반환한다. 보통 직접 호출하지 않으며, 커스텀 web 구현(`UsbStoragePlugin` 구현)을 작성하거나 옵션/반환 타입을 참조해야 할 때만 사용한다.
|
|
97
|
+
|
|
98
|
+
- `getDevices(): Promise<{ devices: UsbDeviceInfo[] }>` — 연결 장치 목록을 `devices` 로 반환.
|
|
99
|
+
- `requestPermissions(options: UsbDeviceFilter): Promise<{ granted: boolean }>` — `options` 장치의 권한 요청 결과를 `granted` 로 반환(true=승인).
|
|
100
|
+
- `checkPermissions(options: UsbDeviceFilter): Promise<{ granted: boolean }>` — `options` 장치의 권한 보유 여부를 `granted` 로 반환(true=보유).
|
|
101
|
+
- `readdir(options: UsbDeviceFilter & { path: string }): Promise<{ files: UsbFileInfo[] }>` — filter 에 `path`(나열할 디렉토리 경로)를 합친 입력으로 항목 목록을 `files` 로 반환.
|
|
102
|
+
- `readFile(options: UsbDeviceFilter & { path: string }): Promise<{ data: string | null }>` — filter 에 `path`(읽을 파일 경로)를 합친 입력으로 파일을 base64 문자열 `data` 로 반환. 파일이 없거나 데이터 없음이면 `data` 가 `null`(래퍼 `UsbStorage.readFile` 이 이를 `undefined` 로 변환).
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# @simplysm/core-browser
|
|
2
2
|
|
|
3
|
-
브라우저 전용 유틸리티
|
|
3
|
+
브라우저 전용 유틸리티 — DOM 요소 탐색·위치 계산·가시성 확장, IndexedDB 영속화 및 가상 파일시스템, Blob 다운로드·URL 바이너리 수신·파일 선택 대화상자.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
이 패키지의 심볼을 하나라도 import 하면 `index.ts` 가 `element-ext`/`html-element-ext` 를 사이드 이펙트로 실행해 `Element`/`HTMLElement` 프로토타입 확장 메서드가 전역에서 자동 활성화된다(별도 초기화 불필요).
|
|
6
6
|
|
|
7
7
|
## 사용 트리거 인덱스
|
|
8
8
|
|
|
9
|
-
- **DOM 요소
|
|
10
|
-
- **IndexedDB 영속화**
|
|
11
|
-
-
|
|
9
|
+
- **DOM 요소 확장** — DOM 조회(findAll/findFirst)·조상/자식 순회·탭 이동 대상 탐색·offset/가시성 판정·부모 기준 상대 좌표 계산·가림 보정 스크롤·강제 리페인트·클립보드 복사/붙여넣기 핸들러·다중 요소 경계 측정이 필요할 때. 자세히: [dom-element.md](./dom-element.md)
|
|
10
|
+
- **IndexedDB 영속화** — 브라우저 IndexedDB 에 키-값을 영구 저장(IndexedDbStore)하거나, 그 위에 경로 키 기반 가상 파일트리(IndexedDbVirtualFs)를 올릴 때. 자세히: [indexed-db.md](./indexed-db.md)
|
|
11
|
+
- **파일 입출력** — 메모리 Blob 을 파일로 내려받거나(downloadBlob), URL 에서 진행률과 함께 바이너리를 받거나(fetchUrlBytes), 파일 선택 대화상자를 코드로 열 때(openFileDialog). 아래 인라인 섹션 참조.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 파일 입출력
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
데이터를 파일로 내보내거나, 외부 바이너리를 받거나, 사용자에게 파일을 고르게 하는 단발성 함수 묶음.
|
|
16
16
|
|
|
17
17
|
### downloadBlob
|
|
18
18
|
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
function downloadBlob(blob: Blob, fileName: string): void;
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Blob 을 object URL 로 만들어 동적 `a[download]` 클릭으로 저장하고, object URL 은 1초 뒤 revoke
|
|
23
|
+
Blob 을 object URL 로 만들어 동적 `a[download]` 클릭으로 저장하고, object URL 은 1초 뒤 revoke 한다. 클릭 직후 반환되며 다운로드 완료를 기다리지 않는다. 다운로드 버튼 핸들러에서 즉시 저장할 때.
|
|
24
24
|
|
|
25
|
-
- blob: Blob — 저장할 데이터. 엑셀·이미지·텍스트 등 메모리에서 만든 Blob 을 그대로 전달.
|
|
26
|
-
- fileName: string — 저장 파일명. `sanitize-filename` 으로 OS 금지 문자·예약어를 제거한 뒤 추가로 `[`·`]` 도 제거하며, 결과가 빈 문자열이면 `"download"` 로 대체. 확장자 포함, 사용자 입력 파일명을 그대로 넣어도 안전.
|
|
25
|
+
- `blob: Blob` — 저장할 데이터. 엑셀·이미지·텍스트 등 메모리에서 만든 Blob 을 그대로 전달.
|
|
26
|
+
- `fileName: string` — 저장 파일명. `sanitize-filename` 으로 OS 금지 문자·예약어를 제거한 뒤 추가로 `[`·`]` 도 제거하며, 결과가 빈 문자열이면 `"download"` 로 대체. 확장자 포함, 사용자 입력 파일명을 그대로 넣어도 안전.
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
downloadBlob(new Blob([buf], { type: "application/pdf" }), "보고서[2026].pdf");
|
|
@@ -39,12 +39,12 @@ function fetchUrlBytes(
|
|
|
39
39
|
): Promise<Uint8Array>;
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
URL 바이너리를 스트림 reader 로 다운로드하며 진행률을
|
|
42
|
+
URL 바이너리를 스트림 reader 로 다운로드하며 진행률을 보고한다. 큰 파일을 진행 바와 함께 받을 때.
|
|
43
43
|
|
|
44
|
-
- url: string — 다운로드 대상 URL. `response.ok` 가 아니면 `Error("다운로드 실패: <status> <statusText>")`, 본문 reader 가 없으면 `Error("응답 본문을 읽을 수 없습니다")` throw.
|
|
45
|
-
- options.onProgress
|
|
46
|
-
- DownloadProgress.receivedLength: number — 지금까지 받은 누적 바이트 수.
|
|
47
|
-
- DownloadProgress.contentLength: number — 전체 바이트 수(`Content-Length` 헤더 값, 없으면 0). 헤더가 있으면 그 크기로 버퍼를 사전 할당하고, 수신량이 헤더 값을 초과·미달하면 무결성 위반으로 Error throw.
|
|
44
|
+
- `url: string` — 다운로드 대상 URL. `response.ok` 가 아니면 `Error("다운로드 실패: <status> <statusText>")`, 본문 reader 가 없으면 `Error("응답 본문을 읽을 수 없습니다")` throw.
|
|
45
|
+
- `options.onProgress?: (progress: DownloadProgress) => void` — 청크 수신마다 호출되는 진행 콜백. `Content-Length` 헤더가 있는 경로에서만 호출됨(헤더가 없으면 청크를 모아 `bytes.concat` 으로 마지막에 한 번 병합 — chunked encoding 이라 중간 보고 없음). 진행 바 갱신이 필요할 때만 전달.
|
|
46
|
+
- `DownloadProgress.receivedLength: number` — 지금까지 받은 누적 바이트 수.
|
|
47
|
+
- `DownloadProgress.contentLength: number` — 전체 바이트 수(`Content-Length` 헤더 값, 없으면 0). 헤더가 있으면 그 크기로 버퍼를 사전 할당하고, 수신량이 헤더 값을 초과·미달하면 무결성 위반으로 Error throw.
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
50
|
const data = await fetchUrlBytes("/api/file", {
|
|
@@ -58,10 +58,10 @@ const data = await fetchUrlBytes("/api/file", {
|
|
|
58
58
|
function openFileDialog(options?: { accept?: string; multiple?: boolean }): Promise<File[] | undefined>;
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
동적 `input[type=file]` 을 만들어
|
|
61
|
+
동적 `input[type=file]` 을 만들어 클릭해 파일 선택 대화상자를 표시한다. 업로드 버튼 핸들러에서 호출.
|
|
62
62
|
|
|
63
|
-
- options.accept
|
|
64
|
-
- options.multiple
|
|
63
|
+
- `options.accept?: string` — 허용 MIME/확장자 필터(input `accept` 에 그대로 전달, 예: `".png,.jpg"`, `"image/*"`). 미지정 시 제한 없음.
|
|
64
|
+
- `options.multiple?: boolean` — 다중 선택 허용. true 면 여러 파일 선택 가능, 기본 `false`(단일). 여러 파일을 한 번에 받을 화면이면 true.
|
|
65
65
|
- 반환: 선택 파일이 있으면 `File[]`, 사용자가 취소하거나(`cancel` 이벤트) 0개 선택이면 `undefined`. 결측을 빈 배열로 뭉개지 않으므로 `== null` 로 취소를 구분.
|
|
66
66
|
|
|
67
67
|
```ts
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# @simplysm/core-browser — DOM 요소
|
|
1
|
+
# @simplysm/core-browser — DOM 요소 확장
|
|
2
2
|
|
|
3
|
-
DOM 요소를 다룰 때 함께 읽히는 묶음. `Element.prototype`/`HTMLElement.prototype` 에 등록되는 확장 메서드와, 이벤트 핸들러·다중 요소용 정적 함수(`copyElement`/`pasteToElement`/`getBounds`)로 구성. 패키지를 import 하면 프로토타입 메서드가 자동 등록되므로 별도
|
|
3
|
+
DOM 요소를 다룰 때 함께 읽히는 묶음. `Element.prototype`/`HTMLElement.prototype` 에 등록되는 확장 메서드와, 이벤트 핸들러·다중 요소용 정적 함수(`copyElement`/`pasteToElement`/`getBounds`)로 구성. 패키지를 import 하면 프로토타입 메서드가 자동 등록되므로 별도 초기화는 필요 없다.
|
|
4
4
|
|
|
5
5
|
## Element 확장 메서드
|
|
6
6
|
|
|
7
7
|
`Element.prototype` 에 등록. import 만으로 활성화.
|
|
8
8
|
|
|
9
|
-
- findAll<TEl>(selector: string): TEl[] — 선택자 일치 하위 요소를 배열로 반환. 선택자를 trim 한 결과가 빈 문자열이면 `[]`. `querySelectorAll` 결과를 NodeList 대신 배열로 받고 빈 선택자 예외를 회피할 때.
|
|
10
|
-
- findFirst<TEl>(selector: string): TEl | undefined — 첫 일치 하위 요소 또는 `undefined`. 빈 선택자도 `undefined`, 미일치도 `undefined`. `querySelector` 의 `null` 을 `undefined` 로 정규화한 형태.
|
|
11
|
-
- prependChild<TEl>(child: TEl): TEl — 자식을 첫 번째 위치(`insertBefore(child, firstElementChild)`)에 삽입하고 그 요소 반환. 맨 앞에
|
|
12
|
-
- getParents(): Element[] — 모든 조상 요소를 가까운 것부터 먼 순서로 배열 반환. 조상 체인 순회·특정 조상 포함 판정에.
|
|
13
|
-
- findTabbableParent(): HTMLElement | undefined — `tabbable` 라이브러리 기준 첫 탭 이동 가능 조상. 없으면 `undefined`. 포커스 위임 대상을 위로 탐색할 때.
|
|
14
|
-
- findFirstTabbableChild(): HTMLElement | undefined — TreeWalker 로 순회한 첫 탭 이동 가능 하위 요소. 없으면 `undefined`. 컨테이너 진입 시 자동 포커스 대상을 찾을 때.
|
|
15
|
-
- isOffsetElement(): boolean — `getComputedStyle().position` 이 relative/absolute/fixed/sticky 중 하나면 true, 아니면 false. offset parent
|
|
16
|
-
- isVisible(): boolean — `getClientRects().length > 0` 이고 `visibility !== "hidden"` 이고 `opacity !== "0"` 를 모두 만족하면 true. 화면 표시 여부 판정에(display:none 은 clientRects 가 비어 false).
|
|
9
|
+
- `findAll<TEl>(selector: string): TEl[]` — 선택자 일치 하위 요소를 배열로 반환. 선택자를 trim 한 결과가 빈 문자열이면 `[]`. `querySelectorAll` 결과를 NodeList 대신 배열로 받고 빈 선택자 예외를 회피할 때.
|
|
10
|
+
- `findFirst<TEl>(selector: string): TEl | undefined` — 첫 일치 하위 요소 또는 `undefined`. 빈 선택자도 `undefined`, 미일치도 `undefined`. `querySelector` 의 `null` 을 `undefined` 로 정규화한 형태.
|
|
11
|
+
- `prependChild<TEl>(child: TEl): TEl` — 자식을 첫 번째 위치(`insertBefore(child, firstElementChild)`)에 삽입하고 그 요소 반환. 맨 앞에 끼워 넣을 때.
|
|
12
|
+
- `getParents(): Element[]` — 모든 조상 요소를 가까운 것부터 먼 순서로 배열 반환. 조상 체인 순회·특정 조상 포함 판정에.
|
|
13
|
+
- `findTabbableParent(): HTMLElement | undefined` — `tabbable` 라이브러리 기준 첫 탭 이동 가능 조상. 없으면 `undefined`. 포커스 위임 대상을 위로 탐색할 때.
|
|
14
|
+
- `findFirstTabbableChild(): HTMLElement | undefined` — TreeWalker 로 순회한 첫 탭 이동 가능 하위 요소. 없으면 `undefined`. 컨테이너 진입 시 자동 포커스 대상을 찾을 때.
|
|
15
|
+
- `isOffsetElement(): boolean` — `getComputedStyle().position` 이 relative/absolute/fixed/sticky 중 하나면 true, 아니면 false. 절대배치 기준(offset parent) 역할 여부 판정에.
|
|
16
|
+
- `isVisible(): boolean` — `getClientRects().length > 0` 이고 `visibility !== "hidden"` 이고 `opacity !== "0"` 를 모두 만족하면 true. 화면 표시 여부 판정에(display:none 은 clientRects 가 비어 false).
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
import "@simplysm/core-browser";
|
|
@@ -25,12 +25,12 @@ const first = containerEl.findFirstTabbableChild();
|
|
|
25
25
|
|
|
26
26
|
`HTMLElement.prototype` 에 등록. 위와 동일하게 import 만으로 활성화.
|
|
27
27
|
|
|
28
|
-
- repaint(): void — `offsetHeight` 접근으로 강제 동기 레이아웃(reflow)을 유발해 즉시 리페인트. 스타일 변경 직후 즉각 반영을 강제할 때.
|
|
29
|
-
- getRelativeOffset(parent: HTMLElement | string): { top: number; left: number } — 부모 기준 CSS `top`/`left` 좌표 계산. 뷰포트 위치(getBoundingClientRect)·부모 내부 스크롤(scrollTop/Left)·중간 요소 border 두께·CSS transform 까지 반영해, 드롭다운/팝업 위치 지정에 바로 쓸 수 있는
|
|
30
|
-
- parent: HTMLElement | string — 기준 부모. 문자열이면 `this.closest(parent)` 로 조상 탐색, 요소면 직접 사용(예: `document.body`, `".container"`).
|
|
31
|
-
- scrollIntoViewIfNeeded(target, offset?): void — 대상이 스크롤 영역의 상단/좌측 경계를 벗어났을 때만 그쪽으로 스크롤해 보이게 함. 하단/우측 방향은 처리하지 않고 브라우저 기본 포커스 스크롤에 위임. 고정 헤더/컬럼이 있는 테이블의 포커스 처리에.
|
|
32
|
-
- target: { top: number; left: number } — 컨테이너 내 대상 위치(offsetTop/offsetLeft 기준).
|
|
33
|
-
- offset
|
|
28
|
+
- `repaint(): void` — `offsetHeight` 접근으로 강제 동기 레이아웃(reflow)을 유발해 즉시 리페인트. 스타일 변경 직후 즉각 반영을 강제할 때.
|
|
29
|
+
- `getRelativeOffset(parent: HTMLElement | string): { top: number; left: number }` — 부모 기준 CSS `top`/`left` 좌표 계산. 뷰포트 위치(getBoundingClientRect)·부모 내부 스크롤(scrollTop/Left)·중간 요소 border 두께·CSS transform 까지 반영해, 드롭다운/팝업 위치 지정에 바로 쓸 수 있는 좌표를 반환. 부모를 못 찾으면(`HTMLElement` 아님) `ArgumentError` throw.
|
|
30
|
+
- `parent: HTMLElement | string` — 기준 부모. 문자열이면 `this.closest(parent)` 로 조상 탐색, 요소면 직접 사용(예: `document.body`, `".container"`).
|
|
31
|
+
- `scrollIntoViewIfNeeded(target, offset?): void` — 대상이 스크롤 영역의 상단/좌측 경계를 벗어났을 때만 그쪽으로 스크롤해 보이게 함. 하단/우측 방향은 처리하지 않고 브라우저 기본 포커스 스크롤에 위임. 고정 헤더/컬럼이 있는 테이블의 포커스 처리에.
|
|
32
|
+
- `target: { top: number; left: number }` — 컨테이너 내 대상 위치(offsetTop/offsetLeft 기준).
|
|
33
|
+
- `offset?: { top: number; left: number }` — 가려지면 안 되는 영역 크기(고정 헤더 높이·고정 컬럼 너비). 기본 `{ top: 0, left: 0 }`.
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
const { top, left } = popupEl.getRelativeOffset(".container");
|
|
@@ -41,19 +41,19 @@ scrollEl.scrollIntoViewIfNeeded({ top: cellTop, left: cellLeft }, { top: headerH
|
|
|
41
41
|
|
|
42
42
|
이벤트 핸들러로 붙이거나 다중 요소를 한 번에 처리하는 함수. 프로토타입 확장이 아니라 named export 이므로 직접 import.
|
|
43
43
|
|
|
44
|
-
- copyElement(event: ClipboardEvent): void — copy 이벤트 핸들러용. 이벤트 타겟 내 첫 `input/textarea` 의 `value` 를 클립보드 `text/plain` 으로 기록하고 `preventDefault`. clipboardData 가 없거나 타겟이 Element 가 아니거나 input 이 없으면 무동작.
|
|
45
|
-
- event: ClipboardEvent — copy 이벤트 객체. `el.addEventListener("copy", copyElement)` 로 등록.
|
|
46
|
-
- pasteToElement(event: ClipboardEvent): void — paste 이벤트 핸들러용. 타겟 내 첫 `input/textarea` 의 전체 `value` 를 클립보드 텍스트로 교체하고 `input` 이벤트 dispatch(`bubbles: true`) 후 `preventDefault`. 커서 위치·선택 영역은 무시하고 전체를 치환.
|
|
47
|
-
- event: ClipboardEvent — paste 이벤트 객체. `el.addEventListener("paste", pasteToElement)` 로 등록.
|
|
48
|
-
- getBounds(els: Element[], timeout?: number): Promise<ElementBounds[]
|
|
49
|
-
- els: Element[] — 측정 대상. 중복은 제거되고 결과는 입력 순서로 정렬됨.
|
|
50
|
-
- timeout
|
|
51
|
-
- ElementBounds (반환 항목 타입):
|
|
52
|
-
- target: Element — 측정된 요소.
|
|
53
|
-
- top: number — 뷰포트 기준 상단 위치(boundingClientRect.top).
|
|
54
|
-
- left: number — 뷰포트 기준 좌측 위치(boundingClientRect.left).
|
|
55
|
-
- width: number — 요소 너비(boundingClientRect.width).
|
|
56
|
-
- height: number — 요소 높이(boundingClientRect.height).
|
|
44
|
+
- `copyElement(event: ClipboardEvent): void` — copy 이벤트 핸들러용. 이벤트 타겟 내 첫 `input/textarea` 의 `value` 를 클립보드 `text/plain` 으로 기록하고 `preventDefault`. clipboardData 가 없거나 타겟이 Element 가 아니거나 input 이 없으면 무동작.
|
|
45
|
+
- `event: ClipboardEvent` — copy 이벤트 객체. `el.addEventListener("copy", copyElement)` 로 등록.
|
|
46
|
+
- `pasteToElement(event: ClipboardEvent): void` — paste 이벤트 핸들러용. 타겟 내 첫 `input/textarea` 의 전체 `value` 를 클립보드 텍스트로 교체하고 `input` 이벤트 dispatch(`bubbles: true`) 후 `preventDefault`. 커서 위치·선택 영역은 무시하고 전체를 치환.
|
|
47
|
+
- `event: ClipboardEvent` — paste 이벤트 객체. `el.addEventListener("paste", pasteToElement)` 로 등록.
|
|
48
|
+
- `getBounds(els: Element[], timeout?: number): Promise<ElementBounds[]>` — `IntersectionObserver` 로 여러 요소의 뷰포트 기준 경계를 한 번에 측정. 중복은 제거하고 입력 순서대로 정렬해 반환. 빈 배열이면 즉시 `[]`. 모든 요소 관측 완료 시 resolve, 제한시간 초과 시 `TimeoutError` throw(어느 경우든 finally 에서 observer disconnect).
|
|
49
|
+
- `els: Element[]` — 측정 대상. 중복은 제거되고 결과는 입력 순서로 정렬됨.
|
|
50
|
+
- `timeout?: number` — 제한시간(ms). 기본 `5000`. 초과 시 `TimeoutError`.
|
|
51
|
+
- `ElementBounds` (반환 항목 타입):
|
|
52
|
+
- `target: Element` — 측정된 요소.
|
|
53
|
+
- `top: number` — 뷰포트 기준 상단 위치(boundingClientRect.top).
|
|
54
|
+
- `left: number` — 뷰포트 기준 좌측 위치(boundingClientRect.left).
|
|
55
|
+
- `width: number` — 요소 너비(boundingClientRect.width).
|
|
56
|
+
- `height: number` — 요소 높이(boundingClientRect.height).
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
59
|
inputEl.addEventListener("copy", copyElement);
|