@vaclav-synacek/pi-coding-agent-termux 0.45.7-1 → 0.46.0-1

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 (106) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +1 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +2 -0
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +2 -0
  8. package/dist/config.js.map +1 -1
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +2 -2
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/compaction/compaction.d.ts.map +1 -1
  13. package/dist/core/compaction/compaction.js +6 -5
  14. package/dist/core/compaction/compaction.js.map +1 -1
  15. package/dist/core/keybindings.d.ts +1 -5
  16. package/dist/core/keybindings.d.ts.map +1 -1
  17. package/dist/core/keybindings.js +4 -12
  18. package/dist/core/keybindings.js.map +1 -1
  19. package/dist/core/model-resolver.d.ts.map +1 -1
  20. package/dist/core/model-resolver.js +1 -0
  21. package/dist/core/model-resolver.js.map +1 -1
  22. package/dist/core/tools/edit-diff.d.ts +30 -0
  23. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  24. package/dist/core/tools/edit-diff.js +82 -10
  25. package/dist/core/tools/edit-diff.js.map +1 -1
  26. package/dist/core/tools/edit.d.ts.map +1 -1
  27. package/dist/core/tools/edit.js +16 -13
  28. package/dist/core/tools/edit.js.map +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/main.d.ts.map +1 -1
  34. package/dist/main.js +38 -9
  35. package/dist/main.js.map +1 -1
  36. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  37. package/dist/modes/interactive/components/bash-execution.js +4 -3
  38. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  39. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  40. package/dist/modes/interactive/components/bordered-loader.js +2 -1
  41. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  42. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  43. package/dist/modes/interactive/components/branch-summary-message.js +4 -1
  44. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  45. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  46. package/dist/modes/interactive/components/compaction-summary-message.js +4 -1
  47. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  48. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  49. package/dist/modes/interactive/components/custom-editor.js +3 -3
  50. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  51. package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
  52. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  53. package/dist/modes/interactive/components/extension-editor.js +14 -8
  54. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  55. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  56. package/dist/modes/interactive/components/extension-input.js +2 -1
  57. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  58. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  59. package/dist/modes/interactive/components/extension-selector.js +6 -1
  60. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  61. package/dist/modes/interactive/components/index.d.ts +1 -0
  62. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  63. package/dist/modes/interactive/components/index.js +1 -0
  64. package/dist/modes/interactive/components/index.js.map +1 -1
  65. package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
  66. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  67. package/dist/modes/interactive/components/keybinding-hints.js +61 -0
  68. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  69. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  70. package/dist/modes/interactive/components/login-dialog.js +4 -3
  71. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  72. package/dist/modes/interactive/components/session-selector-search.d.ts +21 -0
  73. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  74. package/dist/modes/interactive/components/session-selector-search.js +146 -0
  75. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  76. package/dist/modes/interactive/components/session-selector.d.ts +7 -1
  77. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  78. package/dist/modes/interactive/components/session-selector.js +35 -8
  79. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  80. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  81. package/dist/modes/interactive/components/tool-execution.js +14 -8
  82. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  83. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  84. package/dist/modes/interactive/components/tree-selector.js +5 -2
  85. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  86. package/dist/modes/interactive/interactive-mode.d.ts +4 -4
  87. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  88. package/dist/modes/interactive/interactive-mode.js +58 -95
  89. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  90. package/dist/utils/image-convert.d.ts.map +1 -1
  91. package/dist/utils/image-convert.js +12 -14
  92. package/dist/utils/image-convert.js.map +1 -1
  93. package/dist/utils/image-resize.d.ts +2 -2
  94. package/dist/utils/image-resize.d.ts.map +1 -1
  95. package/dist/utils/image-resize.js +102 -122
  96. package/dist/utils/image-resize.js.map +1 -1
  97. package/examples/extensions/plan-mode/README.md +1 -1
  98. package/examples/extensions/plan-mode/index.ts +2 -2
  99. package/examples/extensions/with-deps/package-lock.json +2 -2
  100. package/examples/extensions/with-deps/package.json +1 -1
  101. package/package.json +5 -5
  102. package/README.md +0 -341
  103. package/dist/utils/vips.d.ts +0 -11
  104. package/dist/utils/vips.d.ts.map +0 -1
  105. package/dist/utils/vips.js +0 -35
  106. package/dist/utils/vips.js.map +0 -1
package/README.md DELETED
@@ -1,341 +0,0 @@
1
- # pi-coding-agent-termux
2
-
3
- Termux port of [pi-coding-agent](https://github.com/badlogic/pi-mono) - a terminal-based coding agent with multi-model support.
4
-
5
- **For user documentation, features, and usage instructions, please see the [upstream repository](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent).**
6
-
7
- This repository maintains a Termux-compatible fork of pi-coding-agent. The port removes problematic dependencies and provides minimal Termux-specific replacements to enable running pi on Android devices via Termux.
8
-
9
- ## Installation on Termux
10
-
11
- ```bash
12
- npm install -g @vaclav-synacek/pi-coding-agent-termux
13
- ```
14
-
15
- Or build from source (on a development machine):
16
-
17
- ```bash
18
- git clone https://github.com/VaclavSynacek/pi-coding-agent-termux.git
19
- cd pi-coding-agent-termux
20
- npm install
21
- npm run build
22
- cd packages/coding-agent
23
- npm pack
24
- # Transfer the .tgz file to Termux and install it
25
- ```
26
-
27
- On Termux:
28
- ```bash
29
- npm install -g /path/to/vaclav-synacek-pi-coding-agent-termux-0.45.7.tgz
30
- ```
31
-
32
- **Note**: Building on Termux is not supported because the build tool (`tsgo`) doesn't have ARM64 binaries. Build on a regular machine and transfer the package, or install directly from npm.
33
-
34
- For clipboard support, install Termux:API:
35
-
36
- ```bash
37
- pkg install termux-api
38
- ```
39
-
40
- ## Functional Changes in this Port
41
-
42
- This port modifies the upstream pi-coding-agent to work on Termux by:
43
-
44
- ### 1. Clipboard Integration
45
- - **Changed**: `@mariozechner/clipboard` made optional (native bindings incompatible with Termux)
46
- - **Added**: Termux clipboard support via `termux-clipboard-set` and `termux-clipboard-get` commands
47
- - **Behavior**: Text clipboard works via Termux:API; image clipboard operations are disabled on Termux
48
- - **Files modified**:
49
- - `packages/coding-agent/src/utils/clipboard.ts`
50
- - `packages/coding-agent/src/utils/clipboard-image.ts`
51
- - `packages/coding-agent/package.json` (clipboard moved to optionalDependencies)
52
-
53
- ### 2. Image Processing
54
- - **Changed**: Uses `wasm-vips` for image processing
55
- - **Note**: Upstream v0.45.7+ migrated from `photon-node` to `wasm-vips` which is WebAssembly-based
56
- - **Behavior**: Image resizing and conversion work correctly (wasm-vips is platform-independent)
57
- - **Files modified**: None required - wasm-vips works on all platforms including Termux
58
-
59
- ### 3. Update Notification
60
- - **Changed**: Version check and update notification system
61
- - **Behavior**: Checks for updates against `@vaclav-synacek/pi-coding-agent-termux` on npm (instead of upstream package)
62
- - **Display**: Shows correct command: `npm install -g @vaclav-synacek/pi-coding-agent-termux`
63
- - **Files modified**:
64
- - `packages/coding-agent/src/modes/interactive/interactive-mode.ts` (npm registry URL and install command)
65
-
66
- ### 4. Optional Dependencies
67
- - **Changed**: `canvas` moved to optionalDependencies in `packages/ai/package.json`
68
- - **Reason**: Canvas cannot build on Termux (requires pixman-1), but is only used for ai tests
69
- - **Behavior**: npm install succeeds on Termux even if canvas build fails
70
- - **Files modified**: `packages/ai/package.json`
71
-
72
- ### 5. TypeScript Target
73
- - **Changed**: `tsconfig.base.json` target set to ES2024
74
- - **Reason**: Support for regex `v` flag (required by some dependencies)
75
- - **Files modified**: `tsconfig.base.json`
76
-
77
- ## Repository Structure & Maintenance
78
-
79
- This repository follows a structured branching strategy to track upstream releases while maintaining Termux-specific patches:
80
-
81
- ### Branches
82
-
83
- - **`master`** - The main Termux port branch
84
- - Contains Termux-specific modifications applied on top of upstream
85
- - Rebased onto new upstream versions when they are released
86
- - Force-pushed after each rebase (history is rewritten)
87
-
88
- - **`upstream`** - Clean upstream tracking branch
89
- - Mirrors `https://github.com/badlogic/pi-mono.git` main branch
90
- - Used as the base for rebasing master
91
- - Never contains Termux-specific changes
92
- - Helps maintain transparency about what's changed in the port
93
-
94
- ### Tags
95
-
96
- Tags follow the naming convention: `v{UPSTREAM_VERSION}-{PORT_REVISION}`
97
-
98
- Examples:
99
- - `v0.45.7-0` - First Termux port of upstream v0.45.7
100
- - `v0.45.7-1` - Second Termux port of upstream v0.45.7 (port bugfix)
101
- - `v0.46.0-0` - First Termux port of upstream v0.46.0
102
-
103
- **Tags are immutable** - once published to npm, a tag is never changed or deleted. This preserves the complete version history.
104
-
105
- ### Remotes
106
-
107
- - `origin` - This repository (`VaclavSynacek/pi-coding-agent-termux`)
108
- - `upstream` - Upstream repository (`badlogic/pi-mono`)
109
-
110
- ## Maintenance Workflow
111
-
112
- ### When a New Upstream Version is Released
113
-
114
- Example: Upstream releases `v0.46.0`
115
-
116
- 1. **Update upstream branch**
117
- ```bash
118
- git checkout upstream
119
- git fetch upstream
120
- git merge upstream/main # or git reset --hard upstream/main
121
- git push origin upstream
122
- ```
123
-
124
- 2. **Rebase master onto new upstream version**
125
- ```bash
126
- git checkout master
127
- git rebase v0.46.0 # rebase onto the upstream tag
128
- ```
129
-
130
- 3. **Resolve conflicts**
131
- - Fix any rebase conflicts in Termux-specific patches
132
- - Pay special attention to files listed in "Functional Changes" section above
133
- - Ensure patches still apply cleanly and make sense
134
-
135
- 4. **Test thoroughly**
136
- - Build the project: `npm install && npm run build`
137
- - Test on actual Termux device
138
- - Verify clipboard operations (with Termux:API installed)
139
- - Test that image operations degrade gracefully
140
- - Check that all core features work
141
-
142
- 5. **Update package.json version**
143
- ```bash
144
- cd packages/coding-agent
145
- # Update version to match upstream (e.g., "0.46.0")
146
- ```
147
-
148
- 6. **Create immutable release tag**
149
- ```bash
150
- git tag -a v0.46.0-0 -m "Termux port of upstream v0.46.0"
151
- git push origin v0.46.0-0
152
- ```
153
-
154
- 7. **Publish to npm**
155
- ```bash
156
- cd packages/coding-agent
157
- npm publish
158
- ```
159
-
160
- 8. **Push rebased master**
161
- ```bash
162
- git push origin master --force-with-lease
163
- ```
164
-
165
- ### When Port Needs a Bugfix (Without Upstream Change)
166
-
167
- Example: Fix a bug in the Termux port of v0.46.0
168
-
169
- 1. **Make fixes on master branch**
170
- ```bash
171
- git checkout master
172
- # Make your fixes
173
- git commit -m "fix: describe the port-specific fix"
174
- ```
175
-
176
- 2. **Update package.json version** (increment port revision)
177
- ```bash
178
- cd packages/coding-agent
179
- # Version stays "0.46.0" (or use "0.46.0-termux.1" if needed)
180
- ```
181
-
182
- 3. **Create new port revision tag**
183
- ```bash
184
- git tag -a v0.46.0-1 -m "Termux port of upstream v0.46.0 (bugfix)"
185
- git push origin v0.46.0-1
186
- ```
187
-
188
- 4. **Publish to npm**
189
- ```bash
190
- cd packages/coding-agent
191
- npm publish
192
- ```
193
-
194
- 5. **Push master**
195
- ```bash
196
- git push origin master
197
- ```
198
-
199
- ### Initial Setup (Already Done)
200
-
201
- This was the initial setup of this repository:
202
-
203
- 1. Created new repository
204
- 2. Added upstream remote: `git remote add upstream https://github.com/badlogic/pi-mono.git`
205
- 3. Fetched upstream: `git fetch upstream --tags`
206
- 4. Created `upstream` branch: `git checkout -b upstream upstream/main`
207
- 5. Created `master` branch from upstream v0.45.7: `git checkout -b master v0.45.7`
208
- 6. Applied Termux patches as focused commits
209
- 7. Tagged first release: `v0.45.7-0`
210
-
211
- ## Termux Port Commits
212
-
213
- The Termux port consists of these focused commits (applied on top of upstream):
214
-
215
- 1. **docs: Add comprehensive Termux port README** - Complete documentation and maintenance instructions
216
- 2. **feat: Update TypeScript target to ES2024** - Enable modern JavaScript features
217
- 3. **feat: Make @mariozechner/clipboard optional for Termux compatibility** - Optional require() for clipboard
218
- 4. **feat: Add Termux clipboard support** - Integration with termux-clipboard-set/get
219
- 5. **feat: Make @mariozechner/clipboard optional dependency** - Move to optionalDependencies in package.json
220
- 6. **feat: Update version check to use Termux port package** - Point to @vaclav-synacek/pi-coding-agent-termux
221
- 7. **feat: Update package.json for Termux port** - Package name and metadata
222
- 8. **feat: Make canvas optional dependency in ai package** - Allow clean build on Termux
223
- 9. **chore: Remove package-lock.json** - Platform-independent dependency resolution
224
-
225
- ## Commit Strategy for Rebasing
226
-
227
- To make rebasing easier, Termux-specific changes are organized as **minimal, focused commits**:
228
-
229
- - One commit per logical change
230
- - Clear commit messages explaining why the change is needed for Termux
231
- - Avoid mixing unrelated changes
232
- - Keep patches as small as possible while maintaining functionality
233
-
234
- This approach ensures that when rebasing onto new upstream versions, conflicts are:
235
- - Easier to understand and resolve
236
- - Less likely to occur
237
- - Clearly attributable to specific Termux requirements
238
-
239
- ## Development Notes
240
-
241
- ### Building (Development Machine Required)
242
-
243
- **Important**: Building requires `tsgo` which doesn't have Android ARM64 binaries. Build on a regular development machine (Linux/macOS/Windows).
244
-
245
- This is a monorepo. To build all packages:
246
-
247
- ```bash
248
- # From repository root (on development machine)
249
- npm install
250
- npm run build
251
- ```
252
-
253
- To build only the coding-agent package:
254
-
255
- ```bash
256
- cd packages/coding-agent
257
- npm run build
258
- ```
259
-
260
- **For Termux deployment**: Build on a development machine, then either:
261
- 1. Publish to npm and install from there
262
- 2. Use `npm pack` to create a .tgz file and transfer it to Termux
263
-
264
- **Note**: The optional dependency `canvas` (in packages/ai) may fail to build due to missing native libraries (pixman-1). This is expected and harmless - npm will skip it and continue. Canvas is only used for ai package tests.
265
-
266
- ### Testing on Termux
267
-
268
- 1. Install Termux from F-Droid
269
- 2. Install dependencies:
270
- ```bash
271
- pkg update && pkg install git nodejs-lts
272
- pkg install termux-api # For clipboard support
273
- ```
274
- 3. Install the package:
275
- ```bash
276
- npm install -g @vaclav-synacek/pi-coding-agent-termux
277
- ```
278
- 4. Run: `pi`
279
-
280
- **For development/testing unreleased changes**: Build on a development machine, create a tarball with `npm pack`, transfer to Termux, and install with `npm install -g /path/to/package.tgz`.
281
-
282
- ### Comparison with Upstream
283
-
284
- To see all Termux-specific changes:
285
-
286
- ```bash
287
- git diff upstream master
288
- ```
289
-
290
- To see changes in a specific file:
291
-
292
- ```bash
293
- git diff upstream master packages/coding-agent/src/utils/clipboard.ts
294
- ```
295
-
296
- ## Publishing to npm
297
-
298
- The package is published as `@vaclav-synacek/pi-coding-agent-termux` on npm.
299
-
300
- **Publishing steps:**
301
-
302
- ```bash
303
- cd packages/coding-agent
304
- npm publish
305
- ```
306
-
307
- **Key package.json fields:**
308
- - `name`: `@vaclav-synacek/pi-coding-agent-termux` (different from upstream to avoid conflicts)
309
- - `version`: Matches upstream version (e.g., `0.46.0`)
310
- - `description`: "Termux port of pi-coding-agent - Coding agent CLI with read, bash, edit, write tools and session management"
311
- - `repository`: Points to this repository (`VaclavSynacek/pi-coding-agent-termux`)
312
- - `homepage`: https://github.com/VaclavSynacek/pi-coding-agent-termux#readme
313
-
314
- ## Why This Approach?
315
-
316
- This maintenance strategy provides:
317
-
318
- 1. **Clean separation** - Clear distinction between upstream code and Termux patches
319
- 2. **Easy updates** - Rebasing makes it straightforward to adopt new upstream features
320
- 3. **Version history** - Immutable tags preserve every published version
321
- 4. **Transparency** - Easy to see exactly what's different from upstream
322
- 5. **Maintainability** - Future maintainers can understand the port structure
323
- 6. **No upstream dependency** - Port can continue indefinitely without upstream acceptance
324
-
325
- ## Contributing
326
-
327
- When contributing Termux-specific changes:
328
-
329
- 1. Fork this repository
330
- 2. Create a feature branch from `master`
331
- 3. Make focused commits with clear messages
332
- 4. Test on actual Termux device
333
- 5. Submit pull request
334
-
335
- For general pi-coding-agent features/bugs, contribute to the [upstream repository](https://github.com/badlogic/pi-mono) instead.
336
-
337
- ## License
338
-
339
- Same as upstream: MIT License
340
-
341
- See [LICENSE](LICENSE) file for details.
@@ -1,11 +0,0 @@
1
- /**
2
- * Singleton wrapper for wasm-vips initialization.
3
- * wasm-vips requires async initialization, so we cache the instance.
4
- */
5
- import type Vips from "wasm-vips";
6
- /**
7
- * Get the initialized wasm-vips instance.
8
- * Returns null if wasm-vips is not available or fails to initialize.
9
- */
10
- export declare function getVips(): Promise<Awaited<ReturnType<typeof Vips>> | null>;
11
- //# sourceMappingURL=vips.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vips.d.ts","sourceRoot":"","sources":["../../src/utils/vips.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAKlC;;;GAGG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAyBhF","sourcesContent":["/**\n * Singleton wrapper for wasm-vips initialization.\n * wasm-vips requires async initialization, so we cache the instance.\n */\n\nimport type Vips from \"wasm-vips\";\n\nlet vipsInstance: Awaited<ReturnType<typeof Vips>> | null = null;\nlet vipsInitPromise: Promise<Awaited<ReturnType<typeof Vips>> | null> | null = null;\n\n/**\n * Get the initialized wasm-vips instance.\n * Returns null if wasm-vips is not available or fails to initialize.\n */\nexport async function getVips(): Promise<Awaited<ReturnType<typeof Vips>> | null> {\n\tif (vipsInstance) {\n\t\treturn vipsInstance;\n\t}\n\n\tif (vipsInitPromise) {\n\t\treturn vipsInitPromise;\n\t}\n\n\tvipsInitPromise = (async () => {\n\t\ttry {\n\t\t\tconst VipsInit = (await import(\"wasm-vips\")).default;\n\t\t\tvipsInstance = await VipsInit();\n\t\t\treturn vipsInstance;\n\t\t} catch {\n\t\t\t// wasm-vips not available\n\t\t\treturn null;\n\t\t}\n\t})();\n\n\tconst result = await vipsInitPromise;\n\tif (!result) {\n\t\tvipsInitPromise = null; // Allow retry on failure\n\t}\n\treturn result;\n}\n"]}
@@ -1,35 +0,0 @@
1
- /**
2
- * Singleton wrapper for wasm-vips initialization.
3
- * wasm-vips requires async initialization, so we cache the instance.
4
- */
5
- let vipsInstance = null;
6
- let vipsInitPromise = null;
7
- /**
8
- * Get the initialized wasm-vips instance.
9
- * Returns null if wasm-vips is not available or fails to initialize.
10
- */
11
- export async function getVips() {
12
- if (vipsInstance) {
13
- return vipsInstance;
14
- }
15
- if (vipsInitPromise) {
16
- return vipsInitPromise;
17
- }
18
- vipsInitPromise = (async () => {
19
- try {
20
- const VipsInit = (await import("wasm-vips")).default;
21
- vipsInstance = await VipsInit();
22
- return vipsInstance;
23
- }
24
- catch {
25
- // wasm-vips not available
26
- return null;
27
- }
28
- })();
29
- const result = await vipsInitPromise;
30
- if (!result) {
31
- vipsInitPromise = null; // Allow retry on failure
32
- }
33
- return result;
34
- }
35
- //# sourceMappingURL=vips.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vips.js","sourceRoot":"","sources":["../../src/utils/vips.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,IAAI,YAAY,GAA4C,IAAI,CAAC;AACjE,IAAI,eAAe,GAA4D,IAAI,CAAC;AAEpF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,GAAqD;IACjF,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACrB,OAAO,eAAe,CAAC;IACxB,CAAC;IAED,eAAe,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC;YACrD,YAAY,GAAG,MAAM,QAAQ,EAAE,CAAC;YAChC,OAAO,YAAY,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACR,0BAA0B;YAC1B,OAAO,IAAI,CAAC;QACb,CAAC;IAAA,CACD,CAAC,EAAE,CAAC;IAEL,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;IACrC,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,eAAe,GAAG,IAAI,CAAC,CAAC,yBAAyB;IAClD,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * Singleton wrapper for wasm-vips initialization.\n * wasm-vips requires async initialization, so we cache the instance.\n */\n\nimport type Vips from \"wasm-vips\";\n\nlet vipsInstance: Awaited<ReturnType<typeof Vips>> | null = null;\nlet vipsInitPromise: Promise<Awaited<ReturnType<typeof Vips>> | null> | null = null;\n\n/**\n * Get the initialized wasm-vips instance.\n * Returns null if wasm-vips is not available or fails to initialize.\n */\nexport async function getVips(): Promise<Awaited<ReturnType<typeof Vips>> | null> {\n\tif (vipsInstance) {\n\t\treturn vipsInstance;\n\t}\n\n\tif (vipsInitPromise) {\n\t\treturn vipsInitPromise;\n\t}\n\n\tvipsInitPromise = (async () => {\n\t\ttry {\n\t\t\tconst VipsInit = (await import(\"wasm-vips\")).default;\n\t\t\tvipsInstance = await VipsInit();\n\t\t\treturn vipsInstance;\n\t\t} catch {\n\t\t\t// wasm-vips not available\n\t\t\treturn null;\n\t\t}\n\t})();\n\n\tconst result = await vipsInitPromise;\n\tif (!result) {\n\t\tvipsInitPromise = null; // Allow retry on failure\n\t}\n\treturn result;\n}\n"]}