pulse-ui-client 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ import type { ServerChannelMessage } from "./messages";
2
+ import type { PulseSocketIOClient } from "./client";
3
+ export declare class PulseChannelResetError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ export type ChannelEventHandler = (payload: any) => any | Promise<any>;
7
+ export declare class ChannelBridge {
8
+ private client;
9
+ readonly id: string;
10
+ private handlers;
11
+ private pending;
12
+ private backlog;
13
+ private closed;
14
+ constructor(client: PulseSocketIOClient, id: string);
15
+ emit(event: string, payload?: any): void;
16
+ request(event: string, payload?: any): Promise<any>;
17
+ on(event: string, handler: ChannelEventHandler): () => void;
18
+ handleServerMessage(message: ServerChannelMessage): boolean;
19
+ handleDisconnect(reason: PulseChannelResetError): void;
20
+ dispose(reason: PulseChannelResetError): void;
21
+ private ensureOpen;
22
+ private flushBacklog;
23
+ private dispatchEvent;
24
+ private dispatchRequest;
25
+ private resolvePending;
26
+ private close;
27
+ }
28
+ export declare function createChannelBridge(client: PulseSocketIOClient, id: string): ChannelBridge;
@@ -0,0 +1 @@
1
+ export {};
package/dist/client.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { RouteInfo } from "./helpers";
2
2
  import type { VDOM, VDOMUpdate } from "./vdom";
3
- import type { ServerErrorInfo } from "./messages";
3
+ import type { ClientChannelMessage, ServerErrorInfo } from "./messages";
4
4
  import type { NavigateFunction } from "react-router";
5
+ import type { ChannelBridge } from "./channel";
5
6
  export interface MountedView {
6
7
  routeInfo: RouteInfo;
7
8
  onInit: (vdom: VDOM) => void;
@@ -29,6 +30,7 @@ export declare class PulseSocketIOClient {
29
30
  private connectionListeners;
30
31
  private serverErrors;
31
32
  private serverErrorListeners;
33
+ private channels;
32
34
  constructor(url: string, renderId: string, frameworkNavigate: NavigateFunction);
33
35
  isConnected(): boolean;
34
36
  connect(): Promise<void>;
@@ -37,6 +39,7 @@ export declare class PulseSocketIOClient {
37
39
  onServerError(listener: ServerErrorListener): () => void;
38
40
  private notifyServerError;
39
41
  private sendMessage;
42
+ sendChannelMessage(message: ClientChannelMessage): Promise<void>;
40
43
  mountView(path: string, view: MountedView): void;
41
44
  navigate(path: string, routeInfo: RouteInfo): Promise<void>;
42
45
  unmount(path: string): void;
@@ -44,4 +47,9 @@ export declare class PulseSocketIOClient {
44
47
  private handleServerMessage;
45
48
  private performApiCall;
46
49
  invokeCallback(path: string, callback: string, args: any[]): Promise<void>;
50
+ acquireChannel(id: string): ChannelBridge;
51
+ releaseChannel(id: string): void;
52
+ private ensureChannelEntry;
53
+ private routeChannelMessage;
54
+ private handleTransportDisconnect;
47
55
  }
package/dist/form.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ export type PulseFormProps = React.ComponentPropsWithoutRef<"form"> & {
3
+ action: string;
4
+ };
5
+ /**
6
+ * PulseForm intercepts native form submissions and sends them through fetch so the
7
+ * surrounding Pulse view stays mounted. Server-side handlers are still invoked via
8
+ * the form action endpoint and reactive updates propagate over the socket.
9
+ */
10
+ export declare const PulseForm: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
11
+ action: string;
12
+ } & React.RefAttributes<HTMLFormElement>>;
13
+ interface SubmitForm {
14
+ event: React.FormEvent<HTMLFormElement>;
15
+ action: string;
16
+ onSubmit?: PulseFormProps["onSubmit"];
17
+ formData?: FormData;
18
+ force?: boolean;
19
+ }
20
+ export declare function submitForm({ event, action, onSubmit, formData, force }: SubmitForm): Promise<void>;
21
+ export {};