Skip to content

fix: align iOS indices with JS + packaging hygiene; add release workflow#3

Merged
pablogdcr merged 3 commits into
mainfrom
fix/v0.2.1-ios-indices-packaging
Jun 2, 2026
Merged

fix: align iOS indices with JS + packaging hygiene; add release workflow#3
pablogdcr merged 3 commits into
mainfrom
fix/v0.2.1-ios-indices-packaging

Conversation

@pablogdcr

@pablogdcr pablogdcr commented Jun 2, 2026

Copy link
Copy Markdown
Owner

iOS start/end now match JavaScript string indices
The Swift module computed offsets with text.distance(...) over Swift's Character (grapheme) view. JavaScript strings, and Android's ML Kit annotation.start/end, use UTF-16 offsets. So for any text with emoji, accents, or non-BMP characters, iOS returned indices that disagreed with Android and broke text.slice(start, end) in JS. Now returns the raw UTF-16 NSRange offsets. (ASCII text hid this, which is why it passed manual testing.)

Android build.gradle version drift
Was hardcoded to 0.1.0 while the package was at 0.2.0. Now reads version from package.json (same as the podspec), so it can never drift again.

Explicit files allowlist in package.json
The tarball was shipping dev cruft (eslint.config.js, .editorconfig, .prettierrc, .prettierignore, CONTRIBUTING.md). Replaced the brittle, stale .npmignore with an allowlist. npm pack --dry-run now ships only src, build, android, ios, config, README, and LICENSE.

README hero image renders on npmjs.com
Switched the relative data-detector.png <img> to an absolute raw.githubusercontent.com URL. The PNG is excluded from the tarball, so the relative path was broken on the npm page.

pablogdcr added 2 commits June 2, 2026 14:12
- iOS: return UTF-16 offsets from NSDataDetector instead of grapheme
  distances so start/end align with JavaScript strings and Android's
  ML Kit char offsets (broke on emoji/accented/non-BMP text)
- android: read version from package.json instead of hardcoded 0.1.0
  so it never drifts from the published version again
- package.json: add explicit "files" allowlist; stop shipping dev
  cruft (eslint/prettier/editorconfig/CONTRIBUTING) in the tarball
- remove stale .npmignore (listed deleted files, missed new ones)
- README: use absolute raw GitHub URL for hero image so it renders
  on npmjs.com
Decouple releasing from merging: fixes land in main at 0.2.0 (the last
published version) and accumulate under CHANGELOG [Unreleased]. Publishing
is gated on pushing a v* tag, not on merge.

- add .github/workflows/release.yml: npm publish --provenance on v* tags,
  with a guard that the tag matches package.json version
- add CHANGELOG.md (Keep a Changelog format)
- revert version 0.2.1 -> 0.2.0; release happens later via npm version + tag
@pablogdcr pablogdcr changed the title fix: align iOS indices with JS + packaging hygiene (v0.2.1) fix: align iOS indices with JS + packaging hygiene; add release workflow Jun 2, 2026
- drop NODE_AUTH_TOKEN/NPM_TOKEN secret; auth now via id-token (OIDC)
  trusted publisher configured on npmjs.com
- upgrade npm to latest on the runner (OIDC needs >= 11.5.1)
- provenance is generated automatically under trusted publishing, so
  the explicit --provenance flag is no longer needed
@pablogdcr pablogdcr merged commit 8bc3144 into main Jun 2, 2026
3 checks passed
@pablogdcr pablogdcr deleted the fix/v0.2.1-ios-indices-packaging branch June 2, 2026 14:03
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.

1 participant