@arcanejs/react-toolkit 0.15.0 → 0.16.0
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.
- package/dist/connections.d.mts +7 -3
- package/dist/connections.d.ts +7 -3
- package/dist/connections.js +23 -2
- package/dist/connections.mjs +23 -2
- package/dist/index.d.mts +14 -13
- package/dist/index.d.ts +14 -13
- package/package.json +4 -4
package/dist/connections.d.mts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
3
|
+
import { BaseNotificationMessage } from '@arcanejs/protocol';
|
|
1
4
|
import { ToolkitConnection, Toolkit } from '@arcanejs/toolkit';
|
|
2
|
-
import React__default, { FC, ReactNode } from 'react';
|
|
3
5
|
|
|
4
6
|
type ConnectionsContextData = {
|
|
5
7
|
connections: ToolkitConnection[];
|
|
8
|
+
sendNotification: <T extends BaseNotificationMessage<string, string>>(notification: T, filter?: (connection: ToolkitConnection) => boolean) => void;
|
|
6
9
|
};
|
|
7
|
-
declare const ConnectionsContext:
|
|
10
|
+
declare const ConnectionsContext: React.Context<ConnectionsContextData>;
|
|
8
11
|
type ConnectionsContextProviderProps = {
|
|
9
12
|
toolkit: Toolkit;
|
|
10
13
|
children: ReactNode;
|
|
11
14
|
};
|
|
12
15
|
declare const ConnectionsContextProvider: FC<ConnectionsContextProviderProps>;
|
|
16
|
+
declare const useNotificationSender: <T extends BaseNotificationMessage<string, string>>(namespace: T["namespace"], notification: T["notification"]) => ((notification: Omit<T, "type" | "namespace" | "notification">, filter?: (connection: ToolkitConnection) => boolean) => void);
|
|
13
17
|
|
|
14
|
-
export { ConnectionsContext, ConnectionsContextProvider };
|
|
18
|
+
export { ConnectionsContext, ConnectionsContextProvider, useNotificationSender };
|
package/dist/connections.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
3
|
+
import { BaseNotificationMessage } from '@arcanejs/protocol';
|
|
1
4
|
import { ToolkitConnection, Toolkit } from '@arcanejs/toolkit';
|
|
2
|
-
import React__default, { FC, ReactNode } from 'react';
|
|
3
5
|
|
|
4
6
|
type ConnectionsContextData = {
|
|
5
7
|
connections: ToolkitConnection[];
|
|
8
|
+
sendNotification: <T extends BaseNotificationMessage<string, string>>(notification: T, filter?: (connection: ToolkitConnection) => boolean) => void;
|
|
6
9
|
};
|
|
7
|
-
declare const ConnectionsContext:
|
|
10
|
+
declare const ConnectionsContext: React.Context<ConnectionsContextData>;
|
|
8
11
|
type ConnectionsContextProviderProps = {
|
|
9
12
|
toolkit: Toolkit;
|
|
10
13
|
children: ReactNode;
|
|
11
14
|
};
|
|
12
15
|
declare const ConnectionsContextProvider: FC<ConnectionsContextProviderProps>;
|
|
16
|
+
declare const useNotificationSender: <T extends BaseNotificationMessage<string, string>>(namespace: T["namespace"], notification: T["notification"]) => ((notification: Omit<T, "type" | "namespace" | "notification">, filter?: (connection: ToolkitConnection) => boolean) => void);
|
|
13
17
|
|
|
14
|
-
export { ConnectionsContext, ConnectionsContextProvider };
|
|
18
|
+
export { ConnectionsContext, ConnectionsContextProvider, useNotificationSender };
|
package/dist/connections.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
|
|
6
8
|
var _react = require('react');
|
|
7
9
|
var _jsxruntime = require('react/jsx-runtime');
|
|
8
10
|
var ConnectionsContext = _react.createContext.call(void 0,
|
|
@@ -31,9 +33,28 @@ var ConnectionsContextProvider = ({ toolkit, children }) => {
|
|
|
31
33
|
toolkit.removeListener("closed-connection", onClosedConnection);
|
|
32
34
|
};
|
|
33
35
|
}, [toolkit]);
|
|
34
|
-
|
|
36
|
+
const sendNotification = toolkit.sendNotification.bind(toolkit);
|
|
37
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ConnectionsContext.Provider, { value: { connections, sendNotification }, children });
|
|
35
38
|
};
|
|
39
|
+
var useNotificationSender = (namespace, notification) => {
|
|
40
|
+
const { sendNotification } = _react.useContext.call(void 0, ConnectionsContext);
|
|
41
|
+
return _react.useCallback.call(void 0,
|
|
42
|
+
(notificationData, filter) => {
|
|
43
|
+
sendNotification(
|
|
44
|
+
{
|
|
45
|
+
type: "notification",
|
|
46
|
+
namespace,
|
|
47
|
+
notification,
|
|
48
|
+
...notificationData
|
|
49
|
+
},
|
|
50
|
+
filter
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
[namespace, notification, sendNotification]
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
36
57
|
|
|
37
58
|
|
|
38
59
|
|
|
39
|
-
exports.ConnectionsContext = ConnectionsContext; exports.ConnectionsContextProvider = ConnectionsContextProvider;
|
|
60
|
+
exports.ConnectionsContext = ConnectionsContext; exports.ConnectionsContextProvider = ConnectionsContextProvider; exports.useNotificationSender = useNotificationSender;
|
package/dist/connections.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// src/connections.tsx
|
|
2
2
|
import {
|
|
3
3
|
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
4
6
|
useEffect,
|
|
5
7
|
useState
|
|
6
8
|
} from "react";
|
|
@@ -31,9 +33,28 @@ var ConnectionsContextProvider = ({ toolkit, children }) => {
|
|
|
31
33
|
toolkit.removeListener("closed-connection", onClosedConnection);
|
|
32
34
|
};
|
|
33
35
|
}, [toolkit]);
|
|
34
|
-
|
|
36
|
+
const sendNotification = toolkit.sendNotification.bind(toolkit);
|
|
37
|
+
return /* @__PURE__ */ jsx(ConnectionsContext.Provider, { value: { connections, sendNotification }, children });
|
|
38
|
+
};
|
|
39
|
+
var useNotificationSender = (namespace, notification) => {
|
|
40
|
+
const { sendNotification } = useContext(ConnectionsContext);
|
|
41
|
+
return useCallback(
|
|
42
|
+
(notificationData, filter) => {
|
|
43
|
+
sendNotification(
|
|
44
|
+
{
|
|
45
|
+
type: "notification",
|
|
46
|
+
namespace,
|
|
47
|
+
notification,
|
|
48
|
+
...notificationData
|
|
49
|
+
},
|
|
50
|
+
filter
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
[namespace, notification, sendNotification]
|
|
54
|
+
);
|
|
35
55
|
};
|
|
36
56
|
export {
|
|
37
57
|
ConnectionsContext,
|
|
38
|
-
ConnectionsContextProvider
|
|
58
|
+
ConnectionsContextProvider,
|
|
59
|
+
useNotificationSender
|
|
39
60
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as _arcanejs_toolkit_components_text_input from '@arcanejs/toolkit/components/text-input';
|
|
2
|
+
import * as _arcanejs_toolkit_components_switch from '@arcanejs/toolkit/components/switch';
|
|
3
|
+
import * as _arcanejs_toolkit_components_slider_button from '@arcanejs/toolkit/components/slider-button';
|
|
1
4
|
import * as _arcanejs_protocol_core from '@arcanejs/protocol/core';
|
|
2
5
|
import * as _arcanejs_protocol_styles from '@arcanejs/protocol/styles';
|
|
3
6
|
import * as _arcanejs_toolkit_components_group from '@arcanejs/toolkit/components/group';
|
|
@@ -70,18 +73,18 @@ declare const Rect: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
|
70
73
|
grow?: boolean | undefined;
|
|
71
74
|
}>> & React__default.RefAttributes<ld.Rect>>;
|
|
72
75
|
declare const SliderButton: React__default.ForwardRefExoticComponent<Partial<Pick<Pick<_arcanejs_protocol_core.SliderButtonComponent, "grow" | "min" | "max" | "step" | "gradient"> & {
|
|
73
|
-
value?: number
|
|
74
|
-
defaultValue?: number
|
|
75
|
-
onChange?:
|
|
76
|
+
value?: number;
|
|
77
|
+
defaultValue?: number;
|
|
78
|
+
onChange?: _arcanejs_toolkit_components_slider_button.Events["change"];
|
|
76
79
|
}, "value"> & Partial<Omit<Pick<_arcanejs_protocol_core.SliderButtonComponent, "grow" | "min" | "max" | "step" | "gradient"> & {
|
|
77
|
-
value?: number
|
|
78
|
-
defaultValue?: number
|
|
79
|
-
onChange?:
|
|
80
|
+
value?: number;
|
|
81
|
+
defaultValue?: number;
|
|
82
|
+
onChange?: _arcanejs_toolkit_components_slider_button.Events["change"];
|
|
80
83
|
}, "value">>> & React__default.RefAttributes<ld.SliderButton>>;
|
|
81
84
|
declare const Switch: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
82
|
-
value?: "on" | "off"
|
|
83
|
-
defaultValue?: "on" | "off"
|
|
84
|
-
onChange?:
|
|
85
|
+
value?: "on" | "off";
|
|
86
|
+
defaultValue?: "on" | "off";
|
|
87
|
+
onChange?: _arcanejs_toolkit_components_switch.Events["change"];
|
|
85
88
|
}>> & React__default.RefAttributes<ld.Switch>>;
|
|
86
89
|
declare const Tab: React__default.ForwardRefExoticComponent<{
|
|
87
90
|
name: string;
|
|
@@ -93,15 +96,13 @@ declare const Tabs: React__default.ForwardRefExoticComponent<Partial<{} & {
|
|
|
93
96
|
}> & React__default.RefAttributes<ld.Tabs>>;
|
|
94
97
|
declare const TextInput: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
95
98
|
value: string | null;
|
|
96
|
-
onChange?:
|
|
99
|
+
onChange?: _arcanejs_toolkit_components_text_input.Events["change"];
|
|
97
100
|
}>> & React__default.RefAttributes<ld.TextInput>>;
|
|
98
101
|
declare const Timeline: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
99
102
|
state: _arcanejs_protocol_core.TimelineState;
|
|
100
103
|
title: string | null;
|
|
101
104
|
subtitles: string[] | null;
|
|
102
|
-
source:
|
|
103
|
-
name: string;
|
|
104
|
-
} | null | undefined;
|
|
105
|
+
source: _arcanejs_protocol_core.TimelineComponent["source"] | null;
|
|
105
106
|
}>> & React__default.RefAttributes<ld.Timeline>>;
|
|
106
107
|
|
|
107
108
|
export { Button, CoreComponents, Group, GroupHeader, Label, Rect, SliderButton, Switch, Tab, Tabs, TextInput, Timeline, ToolkitRenderer, prepareComponents };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as _arcanejs_toolkit_components_text_input from '@arcanejs/toolkit/components/text-input';
|
|
2
|
+
import * as _arcanejs_toolkit_components_switch from '@arcanejs/toolkit/components/switch';
|
|
3
|
+
import * as _arcanejs_toolkit_components_slider_button from '@arcanejs/toolkit/components/slider-button';
|
|
1
4
|
import * as _arcanejs_protocol_core from '@arcanejs/protocol/core';
|
|
2
5
|
import * as _arcanejs_protocol_styles from '@arcanejs/protocol/styles';
|
|
3
6
|
import * as _arcanejs_toolkit_components_group from '@arcanejs/toolkit/components/group';
|
|
@@ -70,18 +73,18 @@ declare const Rect: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
|
70
73
|
grow?: boolean | undefined;
|
|
71
74
|
}>> & React__default.RefAttributes<ld.Rect>>;
|
|
72
75
|
declare const SliderButton: React__default.ForwardRefExoticComponent<Partial<Pick<Pick<_arcanejs_protocol_core.SliderButtonComponent, "grow" | "min" | "max" | "step" | "gradient"> & {
|
|
73
|
-
value?: number
|
|
74
|
-
defaultValue?: number
|
|
75
|
-
onChange?:
|
|
76
|
+
value?: number;
|
|
77
|
+
defaultValue?: number;
|
|
78
|
+
onChange?: _arcanejs_toolkit_components_slider_button.Events["change"];
|
|
76
79
|
}, "value"> & Partial<Omit<Pick<_arcanejs_protocol_core.SliderButtonComponent, "grow" | "min" | "max" | "step" | "gradient"> & {
|
|
77
|
-
value?: number
|
|
78
|
-
defaultValue?: number
|
|
79
|
-
onChange?:
|
|
80
|
+
value?: number;
|
|
81
|
+
defaultValue?: number;
|
|
82
|
+
onChange?: _arcanejs_toolkit_components_slider_button.Events["change"];
|
|
80
83
|
}, "value">>> & React__default.RefAttributes<ld.SliderButton>>;
|
|
81
84
|
declare const Switch: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
82
|
-
value?: "on" | "off"
|
|
83
|
-
defaultValue?: "on" | "off"
|
|
84
|
-
onChange?:
|
|
85
|
+
value?: "on" | "off";
|
|
86
|
+
defaultValue?: "on" | "off";
|
|
87
|
+
onChange?: _arcanejs_toolkit_components_switch.Events["change"];
|
|
85
88
|
}>> & React__default.RefAttributes<ld.Switch>>;
|
|
86
89
|
declare const Tab: React__default.ForwardRefExoticComponent<{
|
|
87
90
|
name: string;
|
|
@@ -93,15 +96,13 @@ declare const Tabs: React__default.ForwardRefExoticComponent<Partial<{} & {
|
|
|
93
96
|
}> & React__default.RefAttributes<ld.Tabs>>;
|
|
94
97
|
declare const TextInput: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
95
98
|
value: string | null;
|
|
96
|
-
onChange?:
|
|
99
|
+
onChange?: _arcanejs_toolkit_components_text_input.Events["change"];
|
|
97
100
|
}>> & React__default.RefAttributes<ld.TextInput>>;
|
|
98
101
|
declare const Timeline: React__default.ForwardRefExoticComponent<Partial<Partial<{
|
|
99
102
|
state: _arcanejs_protocol_core.TimelineState;
|
|
100
103
|
title: string | null;
|
|
101
104
|
subtitles: string[] | null;
|
|
102
|
-
source:
|
|
103
|
-
name: string;
|
|
104
|
-
} | null | undefined;
|
|
105
|
+
source: _arcanejs_protocol_core.TimelineComponent["source"] | null;
|
|
105
106
|
}>> & React__default.RefAttributes<ld.Timeline>>;
|
|
106
107
|
|
|
107
108
|
export { Button, CoreComponents, Group, GroupHeader, Label, Rect, SliderButton, Switch, Tab, Tabs, TextInput, Timeline, ToolkitRenderer, prepareComponents };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcanejs/react-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"check-export-map": "^1.3.1",
|
|
61
61
|
"eslint": "^8.57.0",
|
|
62
62
|
"tsup": "^8.1.0",
|
|
63
|
-
"typescript": "^5.
|
|
63
|
+
"typescript": "^5.7",
|
|
64
64
|
"zod": "^3.23.8",
|
|
65
65
|
"@arcanejs/eslint-config": "^0.0.0",
|
|
66
66
|
"@arcanejs/typescript-config": "^0.0.0"
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"lodash": "^4.17.23",
|
|
70
70
|
"react": "^19.2.0",
|
|
71
71
|
"react-reconciler": "0.33.0",
|
|
72
|
-
"@arcanejs/protocol": "^0.
|
|
73
|
-
"@arcanejs/toolkit": "^
|
|
72
|
+
"@arcanejs/protocol": "^0.9.0",
|
|
73
|
+
"@arcanejs/toolkit": "^9.0.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"zod": "^3.23.8"
|