feat: native replacement for JSZip#2376
Conversation
Greptile SummaryThis PR replaces the pure-JS
Confidence Score: 5/5Safe to merge; the core JS-to-Java bridge wiring is correct and the previously reported blocking bugs are fixed. The three previously flagged blocking issues (this-context loss in remove/folder, result.data undefined in generateAsync, and uncommented debug logging) are all resolved. The two remaining findings are minor defensive hardening: a missing setTime on an effectively unreachable code path in generateZip, and a theoretical thread-pool race between the fire-and-forget create call and subsequent native operations. Neither causes observable failures under normal usage. The JSZip constructor in src/plugins/jszip-java/www/JsZip.js and the directory-entry branch of generateZip in src/plugins/jszip-java/src/android/JsZip.java are worth a second look. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant JS as JS (JsZip.js)
participant CB as Cordova Bridge
participant TP as Thread Pool
participant JV as JsZip.java
Note over JS,JV: new JSZip() — fire-and-forget create
JS->>CB: exec(null, null, JsZip, create, [id])
CB->>TP: submit create task
Note over JS,JV: loadAsync(data) — at least 2 microtask ticks later
JS->>CB: exec(resolve, reject, JsZip, load, [id, payload, opts])
CB->>TP: submit load task
TP->>JV: createInstance(id) → instances.put(id, ...)
TP->>JV: loadZip(id, ...) → instances.get(id) → OK
Note over JS,JV: generateAsync — waits for all pending, then streams zip
JS->>CB: exec(onResult, reject, JsZip, generate, [id, prefix, opts])
CB->>TP: submit generateZip task
TP->>JV: generateZip → streamFile 256 KB chunks with keepCallback
JV-->>CB: PluginResult OK chunk x N keepCallback true
CB-->>JS: result instanceof ArrayBuffer → chunks.push(result)
JV-->>CB: PluginResult OK done true keepCallback false
CB-->>JS: result.done → merge chunks → _convertOutput → resolve
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant JS as JS (JsZip.js)
participant CB as Cordova Bridge
participant TP as Thread Pool
participant JV as JsZip.java
Note over JS,JV: new JSZip() — fire-and-forget create
JS->>CB: exec(null, null, JsZip, create, [id])
CB->>TP: submit create task
Note over JS,JV: loadAsync(data) — at least 2 microtask ticks later
JS->>CB: exec(resolve, reject, JsZip, load, [id, payload, opts])
CB->>TP: submit load task
TP->>JV: createInstance(id) → instances.put(id, ...)
TP->>JV: loadZip(id, ...) → instances.get(id) → OK
Note over JS,JV: generateAsync — waits for all pending, then streams zip
JS->>CB: exec(onResult, reject, JsZip, generate, [id, prefix, opts])
CB->>TP: submit generateZip task
TP->>JV: generateZip → streamFile 256 KB chunks with keepCallback
JV-->>CB: PluginResult OK chunk x N keepCallback true
CB-->>JS: result instanceof ArrayBuffer → chunks.push(result)
JV-->>CB: PluginResult OK done true keepCallback false
CB-->>JS: result.done → merge chunks → _convertOutput → resolve
Reviews (4): Last reviewed commit: "fix: issues" | Re-trigger Greptile |
No description provided.