-
Notifications
You must be signed in to change notification settings - Fork 0
initial files #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 11 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
028a201
initial files
corrideat 5102db0
Add pubsub
corrideat 8a35c42
Add local selectors, events, Secret, functions, constants
corrideat 4c96a70
Add errors
corrideat 59d77ef
Updated types
corrideat 7e769d8
Types for all files except chelonia.ts, functions.ts, internals.ts, S…
corrideat 2ed9398
Fix types
corrideat 12d6aca
Types
corrideat 8d29ece
Fix types in chelonia.js
corrideat 96302cb
Internals types
corrideat df33723
Fix all types
corrideat da3b249
GI changes
corrideat b990fd6
Tests & exports
corrideat e6b5e14
Port changes
corrideat 2fa83af
Port KV change
corrideat df0c33d
Empty
corrideat d5491d7
Almost final changes
corrideat 7a5f9ed
Add build helper
corrideat 28409f0
Stdio
corrideat 430465f
Port GI PR 2833
corrideat 8ebb3ae
Add missing skipDecryptionAttempts
corrideat 636a934
Add missing deserialize param
corrideat e048d3e
GI consistency
corrideat 6cdda9b
Consisency feedback
corrideat 82cc8b5
Add dist files
corrideat 634a91a
Remove uses of global Buffer
corrideat 6c91bb6
Port eventsBetween changes
corrideat 39d8b86
Fix CI file
corrideat 33f7cb1
events API consistency
corrideat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: Node.js Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "master" ] | ||
| pull_request: | ||
| branches: [ "master" ] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| environment: CI | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org/ | ||
| - run: npm ci | ||
| - run: npm install | ||
| - run: npm test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /node_modules/ | ||
| /.parcel-cache/ | ||
| *.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
| import '@sbp/okturtles.events'; | ||
| export declare const NOTIFICATION_TYPE: Readonly<{ | ||
| ENTRY: "entry"; | ||
| DELETION: "deletion"; | ||
| KV: "kv"; | ||
| PING: "ping"; | ||
| PONG: "pong"; | ||
| PUB: "pub"; | ||
| SUB: "sub"; | ||
| UNSUB: "unsub"; | ||
| VERSION_INFO: "version_info"; | ||
| }>; | ||
| export declare const REQUEST_TYPE: Readonly<{ | ||
| PUB: "pub"; | ||
| SUB: "sub"; | ||
| UNSUB: "unsub"; | ||
| PUSH_ACTION: "push_action"; | ||
| }>; | ||
| export declare const RESPONSE_TYPE: Readonly<{ | ||
| ERROR: "error"; | ||
| OK: "ok"; | ||
| }>; | ||
| export declare const PUSH_SERVER_ACTION_TYPE: Readonly<{ | ||
| SEND_PUBLIC_KEY: "send-public-key"; | ||
| STORE_SUBSCRIPTION: "store-subscription"; | ||
| DELETE_SUBSCRIPTION: "delete-subscription"; | ||
| SEND_PUSH_NOTIFICATION: "send-push-notification"; | ||
| }>; | ||
| export type NotificationTypeEnum = typeof NOTIFICATION_TYPE[keyof typeof NOTIFICATION_TYPE]; | ||
| export type RequestTypeEnum = typeof REQUEST_TYPE[keyof typeof REQUEST_TYPE]; | ||
| export type ResponseTypeEnum = typeof RESPONSE_TYPE[keyof typeof RESPONSE_TYPE]; | ||
| export type JSONType = string | number | boolean | null | JSONObject | JSONArray; | ||
| export type JSONObject = { | ||
| [key: string]: JSONType; | ||
| }; | ||
| export type JSONArray = Array<JSONType>; | ||
| type Options = { | ||
| logPingMessages: boolean; | ||
| pingTimeout: number; | ||
| maxReconnectionDelay: number; | ||
| maxRetries: number; | ||
| minReconnectionDelay: number; | ||
| reconnectOnDisconnection: boolean; | ||
| reconnectOnOnline: boolean; | ||
| reconnectOnTimeout: boolean; | ||
| reconnectionDelayGrowFactor: number; | ||
| timeout: number; | ||
| manual?: boolean; | ||
| handlers?: Partial<ClientEventHandlers>; | ||
| messageHandlers?: Partial<MessageHandlers>; | ||
| }; | ||
| export declare const PUBSUB_ERROR = "pubsub-error"; | ||
| export declare const PUBSUB_RECONNECTION_ATTEMPT = "pubsub-reconnection-attempt"; | ||
| export declare const PUBSUB_RECONNECTION_FAILED = "pubsub-reconnection-failed"; | ||
| export declare const PUBSUB_RECONNECTION_SCHEDULED = "pubsub-reconnection-scheduled"; | ||
| export declare const PUBSUB_RECONNECTION_SUCCEEDED = "pubsub-reconnection-succeeded"; | ||
| export declare const PUBSUB_SUBSCRIPTION_SUCCEEDED = "pubsub-subscription-succeeded"; | ||
| type TimeoutID = ReturnType<typeof setTimeout>; | ||
| export type Message = { | ||
| [key: string]: JSONType; | ||
| type: string; | ||
| }; | ||
| export type PubSubClient = { | ||
| connectionTimeoutID: TimeoutID | undefined; | ||
| connectionTimeUsed?: number; | ||
| customEventHandlers: Partial<ClientEventHandlers>; | ||
| failedConnectionAttempts: number; | ||
| isLocal: boolean; | ||
| isNew: boolean; | ||
| listeners: ClientEventHandlers; | ||
| messageHandlers: MessageHandlers; | ||
| nextConnectionAttemptDelayID: TimeoutID | undefined; | ||
| options: Options; | ||
| pendingSubscriptionSet: Set<string>; | ||
| pendingUnsubscriptionSet: Set<string>; | ||
| pingTimeoutID: TimeoutID | undefined; | ||
| shouldReconnect: boolean; | ||
| socket: WebSocket | null; | ||
| subscriptionSet: Set<string>; | ||
| url: string; | ||
| clearAllTimers(this: PubSubClient): void; | ||
| connect(this: PubSubClient): void; | ||
| destroy(this: PubSubClient): void; | ||
| pub(this: PubSubClient, channelID: string, data: JSONType): void; | ||
| scheduleConnectionAttempt(this: PubSubClient): void; | ||
| sub(this: PubSubClient, channelID: string): void; | ||
| unsub(this: PubSubClient, channelID: string): void; | ||
| getNextRandomDelay(this: PubSubClient): number; | ||
| }; | ||
| type ClientEventHandlers = { | ||
| close(this: PubSubClient, event: CloseEvent): void; | ||
| error(this: PubSubClient, event: Event): void; | ||
| message(this: PubSubClient, event: MessageEvent): void; | ||
| offline(this: PubSubClient, event: Event): void; | ||
| online(this: PubSubClient, event: Event): void; | ||
| open(this: PubSubClient, event: Event): void; | ||
| 'reconnection-attempt'(this: PubSubClient, event: CustomEvent): void; | ||
| 'reconnection-succeeded'(this: PubSubClient, event: CustomEvent): void; | ||
| 'reconnection-failed'(this: PubSubClient, event: CustomEvent): void; | ||
| 'reconnection-scheduled'(this: PubSubClient, event: CustomEvent): void; | ||
| 'subscription-succeeded'(this: PubSubClient, event: CustomEvent): void; | ||
| }; | ||
| type MessageHandlers = { | ||
| [NOTIFICATION_TYPE.ENTRY](this: PubSubClient, msg: { | ||
| data: JSONType; | ||
| type: string; | ||
| [x: string]: unknown; | ||
| }): void; | ||
| [NOTIFICATION_TYPE.PING](this: PubSubClient, msg: { | ||
| data: JSONType; | ||
| }): void; | ||
| [NOTIFICATION_TYPE.PUB](this: PubSubClient, msg: { | ||
| channelID: string; | ||
| data: JSONType; | ||
| }): void; | ||
| [NOTIFICATION_TYPE.KV](this: PubSubClient, msg: { | ||
| channelID: string; | ||
| key: string; | ||
| data: JSONType; | ||
| }): void; | ||
| [NOTIFICATION_TYPE.SUB](this: PubSubClient, msg: { | ||
| channelID: string; | ||
| type: string; | ||
| data: JSONType; | ||
| }): void; | ||
| [NOTIFICATION_TYPE.UNSUB](this: PubSubClient, msg: { | ||
| channelID: string; | ||
| type: string; | ||
| data: JSONType; | ||
| }): void; | ||
| [RESPONSE_TYPE.ERROR](this: PubSubClient, msg: { | ||
| data: { | ||
| type: string; | ||
| channelID: string; | ||
| data: JSONType; | ||
| reason: string; | ||
| actionType?: string; | ||
| message?: string; | ||
| }; | ||
| }): void; | ||
| [RESPONSE_TYPE.OK](this: PubSubClient, msg: { | ||
| data: { | ||
| type: string; | ||
| channelID: string; | ||
| }; | ||
| }): void; | ||
| }; | ||
| export type PubMessage = { | ||
| type: 'pub'; | ||
| channelID: string; | ||
| data: JSONType; | ||
| }; | ||
| export type SubMessage = { | ||
| [key: string]: JSONType; | ||
| type: 'sub'; | ||
| channelID: string; | ||
| }; | ||
| export type UnsubMessage = { | ||
| [key: string]: JSONType; | ||
| type: 'unsub'; | ||
| channelID: string; | ||
| }; | ||
| /** | ||
| * Creates a pubsub client instance. | ||
| * | ||
| * @param {string} url - A WebSocket URL to connect to. | ||
| * @param {Object?} options | ||
| * {object?} handlers - Custom handlers for WebSocket events. | ||
| * {boolean?} logPingMessages - Whether to log received pings. | ||
| * {boolean?} manual - Whether the factory should call 'connect()' automatically. | ||
| * Also named 'autoConnect' or 'startClosed' in other libraries. | ||
| * {object?} messageHandlers - Custom handlers for different message types. | ||
| * {number?} pingTimeout=45_000 - How long to wait for the server to send a ping, in milliseconds. | ||
| * {boolean?} reconnectOnDisconnection=true - Whether to reconnect after a server-side disconnection. | ||
| * {boolean?} reconnectOnOnline=true - Whether to reconnect after coming back online. | ||
| * {boolean?} reconnectOnTimeout=false - Whether to reconnect after a connection timeout. | ||
| * {number?} timeout=5_000 - Connection timeout duration in milliseconds. | ||
| * @returns {PubSubClient} | ||
| */ | ||
| export declare function createClient(url: string, options?: Partial<Options>): PubSubClient; | ||
| export declare function createMessage(type: string, data: JSONType, meta?: object | null | undefined): { | ||
| type: string; | ||
| data: JSONType; | ||
| [x: string]: unknown; | ||
| }; | ||
| export declare function createKvMessage(channelID: string, key: string, data: JSONType): string; | ||
| export declare function createPubMessage(channelID: string, data: JSONType): string; | ||
| export declare function createRequest(type: RequestTypeEnum, data: JSONObject): string; | ||
| export declare const messageParser: (data: string) => Message; | ||
| declare const _default: { | ||
| NOTIFICATION_TYPE: Readonly<{ | ||
| ENTRY: "entry"; | ||
| DELETION: "deletion"; | ||
| KV: "kv"; | ||
| PING: "ping"; | ||
| PONG: "pong"; | ||
| PUB: "pub"; | ||
| SUB: "sub"; | ||
| UNSUB: "unsub"; | ||
| VERSION_INFO: "version_info"; | ||
| }>; | ||
| REQUEST_TYPE: Readonly<{ | ||
| PUB: "pub"; | ||
| SUB: "sub"; | ||
| UNSUB: "unsub"; | ||
| PUSH_ACTION: "push_action"; | ||
| }>; | ||
| RESPONSE_TYPE: Readonly<{ | ||
| ERROR: "error"; | ||
| OK: "ok"; | ||
| }>; | ||
| createClient: typeof createClient; | ||
| createMessage: typeof createMessage; | ||
| createRequest: typeof createRequest; | ||
| }; | ||
| export default _default; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.