Skip to content

fix: harden editor and tree-sitter parser for iOS Cordova (WKWebView/JSC) - #110

Open
rajkumargaramie wants to merge 3 commits into
mainfrom
fix/ios-setupextensions-not-iterable
Open

fix: harden editor and tree-sitter parser for iOS Cordova (WKWebView/JSC)#110
rajkumargaramie wants to merge 3 commits into
mainfrom
fix/ios-setupextensions-not-iterable

Conversation

@rajkumargaramie

@rajkumargaramie rajkumargaramie commented Jul 21, 2026

Copy link
Copy Markdown

Closes #101

Summary

Fixes three iOS-only failures that prevented the Kerebron editor from loading in an iOS Cordova / WKWebView (JavaScriptCore) environment. All three reproduce deterministically on iOS while desktop V8/Chromium happens to avoid them, so they were only surfaced by on-device testing.

Changes

1. ExtensionManager — non-iterable extensions ({} is not iterable)

iOS JSC threw TypeError: {} is not iterable from setupExtensions/ExtensionManager. Added a toArraySafe() helper (prefers .forEach for Set/Map, falls back to Array.from, otherwise warns and returns []) and applied it at every iteration site, and replaced Map/Set for...of loops with .forEach.

2. createParsercannot construct a Parser before calling init()

A boolean hasBeenLoaded flag was flipped to true before Parser.init() resolved, so a concurrent createParser call skipped initialization and reached new Parser() before the runtime was ready. Replaced the flag with a shared initPromise that every caller awaits (reset on failure to allow retry).

3. createParserInvalid scheme

web-tree-sitter's findWasmBinary() still runs even when wasmBinary is supplied; without a locateFile it falls back to new URL('web-tree-sitter.wasm', import.meta.url), which throws Invalid scheme inside an iOS Cordova WKWebView. We now pass a locateFile that returns the asset name. Because wasmBinary is already provided, the returned path is never fetched.

CI

The pull_request commit-message lint and the pre-push hook iterated $(git log ...) unquoted, so each word of a subject was validated separately and no conventional-commit subject with spaces could pass; the pre-push hook additionally used origin/$BRANCH, which resolves to the ambiguous origin/HEAD under a detached-HEAD CI checkout. Both now iterate messages line by line, and the hook skips the range check when the upstream branch is unavailable.

Testing

  • Verified on an iOS simulator build: the editor now opens, typing/saving work, and existing markdown content loads into the rich editor (previously it silently fell back to plain text).
  • No behavior change on desktop.

Two iOS Cordova/WKWebView failures in createParser:

1. A boolean 'hasBeenLoaded' flag was flipped to true before Parser.init()
   resolved, so a concurrent createParser call skipped init and reached
   'new Parser()' before the runtime was ready, throwing 'cannot construct a
   Parser before calling init()'. Replaced with a shared initPromise that every
   caller awaits (reset on failure to allow retry).

2. web-tree-sitter's findWasmBinary() still runs even when wasmBinary is
   supplied; without locateFile it falls back to
   new URL('web-tree-sitter.wasm', import.meta.url), which throws 'Invalid
   scheme' inside an iOS Cordova WKWebView. Pass a locateFile that returns the
   asset name (never fetched, since wasmBinary is present).
The commit-message lint iterated $(git log ...) unquoted, so each word of a
subject was validated separately and no conventional-commit subject with
spaces could ever pass. The pre-push hook had the same word-splitting bug and
also used origin/$BRANCH, which resolves to the ambiguous origin/HEAD under a
detached-HEAD CI checkout. Iterate messages line by line and skip the range
check when the upstream branch is not available.
@rajkumargaramie
rajkumargaramie force-pushed the fix/ios-setupextensions-not-iterable branch from eb96f95 to b9aeeb9 Compare July 22, 2026 00:00
@rajkumargaramie

Copy link
Copy Markdown
Author
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kerebron editor fails to load on iOS Cordova / WKWebView (JSC): non-iterable extensions, Parser.init race, and "Invalid scheme"

1 participant