Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 0.6.1 (2026-06-11)

**Fixed:**

- Example: `Response.json()` was invoked without its `this` binding, failing every fetch
tick in a real browser with "Illegal invocation"; it is now called bound via
`jsonFn(this:)` ([#24](https://github.com/IGRSoft/OpenCombineJS/issues/24))

**Documentation:**

- README gains a "Running the example" guide: PackageToJS `--use-cdn` bundling, the
`index.html` loader, static serving, and opening the example in a host browser or the
iOS Simulator's Safari ([#24](https://github.com/IGRSoft/OpenCombineJS/issues/24))

# 0.6.0 (2026-06-11)

**Build/packaging change — no public API is removed or deprecated:**
Expand Down
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ let timer = JSTimer(millisecondsDelay: 1000, isRepeating: true) {
guard
let obj = responseValue.object,
let jsonFn = obj.json.function,
let jsonObj = jsonFn().object,
// `Response.json` must be called with the response as `this`.
let jsonObj = jsonFn(this: obj).object,
let jsonPromise = JSPromise(jsonObj)
else {
return JSPromise(resolver: { resolve in
Expand Down Expand Up @@ -95,6 +96,44 @@ let timer = JSTimer(millisecondsDelay: 1000, isRepeating: true) {
}
```

## Running the example

The example is a WebAssembly program: it needs a browser. It cannot run as a native
process on macOS or an iOS simulator — JavaScriptKit's native builds exist only for
editor/type-checking support (the JS bridge is compiled `#if __wasm32__`), so a native
launch aborts immediately.

1. Bundle for the browser (requires the official wasm Swift SDK matching your toolchain,
e.g. `swift-6.3.2-RELEASE_wasm`):

```console
swift package --disable-sandbox --swift-sdk swift-6.3.2-RELEASE_wasm \
js --use-cdn --product OpenCombineJSExample
```

2. Put an `index.html` next to the produced bundle
(`.build/plugins/PackageToJS/outputs/Package/`):

```html
<script type="module">
import { init } from "./index.js";
await init();
</script>
```

3. Serve the bundle directory and open it — any browser works, including Safari inside
a booted iOS simulator:

```console
python3 -m http.server 8741 --directory .build/plugins/PackageToJS/outputs/Package
open http://127.0.0.1:8741/index.html # host browser
xcrun simctl openurl booted http://127.0.0.1:8741/index.html # iOS Simulator Safari
```

`--use-cdn` resolves the WASI shim dependency from a CDN; without it, browsers cannot
resolve the bundle's bare `@bjorn3/browser_wasi_shim` import unless you `npm install`
in the output directory and serve through a bundler.

### Code of Conduct

This project adheres to the [Contributor Covenant Code of
Expand Down
4 changes: 3 additions & 1 deletion Sources/OpenCombineJSExample/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ let timer = JSTimer(millisecondsDelay: 1000, isRepeating: true) {
guard
let responseObject = responseValue.object,
let jsonFn = responseObject.json.function,
let jsonPromiseObject = jsonFn().object,
// `Response.json` must be called WITH the response as `this` — an unbound
// call throws "Illegal invocation" in browsers (#24).
let jsonPromiseObject = jsonFn(this: responseObject).object,
let jsonPromise = JSPromise(jsonPromiseObject)
else {
// Return a publisher that immediately fails if the response is malformed.
Expand Down
Loading