Skip to content

Commit

Permalink
updates to match JS changes in phoenix 1.7.14
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerbarker committed Jun 20, 2024
1 parent b86866d commit ac7a590
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# phoenix_ts

`phoenix_ts` is, first and foremost, an experiment and a learning exercise. It's an attempt to port the JS library bundled with the Phoenix web framework (as of v1.7.12) to TypeScript. Bundled and tested with [Bun](https://bun.sh).
`phoenix_ts` is, first and foremost, an experiment and a learning exercise. It's an attempt to port the JS library bundled with the Phoenix web framework (as of v1.7.14) to TypeScript. Bundled and tested with [Bun](https://bun.sh).

I'll be doing the same for `phoenix_live_view` in a separate repo at a later date. Great timing actually, as they just announced [a release candidate for v1.0](https://github.com/phoenixframework/phoenix_live_view/commit/d84b19c9761c8a665084a05178dfbd6de8acd6e8)!

Expand All @@ -17,8 +17,8 @@ This effort isn't officially endorsed by the Phoenix team, just a bit of fun. Th
- [x] Port serializer.js to TypeScript
- [x] Port push.js to TypeScript
- [x] Port longpoll.js to TypeScript
- [ ] Port channel.js to TypeScript
- [ ] Port presence.js to TypeScript
- [ ] Port channel.js to TypeScript
- [ ] Port socket.js to TypeScript
- [ ] Circle back to `any` types after everything is ported
- [ ] Circle back to `as` type assertions after everything is ported
Expand All @@ -28,6 +28,8 @@ This effort isn't officially endorsed by the Phoenix team, just a bit of fun. Th

## Staying Up to Date

Current Version: v1.7.14

I intend to release a corresponding version of this library for each Phoenix release from v1.7.12 onwards, even if the bundled JS does not change to assure compatibility.

I've written a script - to be run every day by a GH Action - which:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phoenix_ts",
"version": "1.7.12",
"version": "1.7.14",
"description": "The unofficial TypeScript client for the Phoenix web framework.",
"license": "MIT",
"main": "./dist/index.js",
Expand Down
15 changes: 8 additions & 7 deletions phoenix/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import Timer from "./timer";
* Defaults to WebSocket with automatic LongPoll fallback if WebSocket is not defined.
* To fallback to LongPoll when WebSocket attempts fail, use `longPollFallbackMs: 2500`.
*
* param {Function} [opts.longPollFallbackMs] - The millisecond time to attempt the primary transport
* param {number} [opts.longPollFallbackMs] - The millisecond time to attempt the primary transport
* before falling back to the LongPoll transport. Disabled by default.
*
* param {Function} [opts.debug] - When true, enables debug logging. Default false.
* param {boolean} [opts.debug] - When true, enables debug logging. Default false.
*
* param {Function} [opts.encode] - The function to encode outgoing messages.
*
Expand All @@ -51,8 +51,8 @@ import Timer from "./timer";
*
* Defaults `DEFAULT_TIMEOUT`
* param {number} [opts.heartbeatIntervalMs] - The millisec interval to send a heartbeat message
* param {number} [opts.reconnectAfterMs] - The optional function that returns the millisec
* socket reconnect interval.
* param {Function} [opts.reconnectAfterMs] - The optional function that returns the
* socket reconnect interval, in milliseconds.
*
* Defaults to stepped backoff of:
*
Expand All @@ -62,8 +62,8 @@ import Timer from "./timer";
* }
* ````
*
* param {number} [opts.rejoinAfterMs] - The optional function that returns the millisec
* rejoin interval for individual channels.
* param {Function} [opts.rejoinAfterMs] - The optional function that returns the millisec
* rejoin interval for individual channels
*
* ```javascript
* function(tries){
Expand Down Expand Up @@ -116,7 +116,8 @@ export default class Socket {
this.primaryPassedHealthCheck = false;
this.longPollFallbackMs = opts.longPollFallbackMs;
this.fallbackTimer = null;
this.sessionStore = opts.sessionStorage || global.sessionStorage;
this.sessionStore =
opts.sessionStorage || (global && global.sessionStorage);
this.establishedConnections = 0;
this.defaultEncoder = Serializer.encode.bind(Serializer);
this.defaultDecoder = Serializer.decode.bind(Serializer);
Expand Down
2 changes: 1 addition & 1 deletion phx-changes-check.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Octokit } from "@octokit/core";

const CURRENT_TAG = "v1.7.12";
const CURRENT_TAG = "v1.7.14";
const CHANGE_TRACKED_DIRECTORY = "assets/";
const TS_OWNER = "tylerbarker";
const TS_REPO = "phoenix_ts";
Expand Down

0 comments on commit ac7a590

Please sign in to comment.