@arcanejs/react-toolkit 0.7.0 → 0.8.1

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/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Button,
3
+ CoreComponents,
3
4
  Group,
4
5
  GroupHeader,
5
6
  Label,
@@ -9,208 +10,14 @@ import {
9
10
  Tab,
10
11
  Tabs,
11
12
  TextInput,
12
- Timeline
13
- } from "./chunk-HVMRFXJ2.mjs";
14
- import {
15
- LoggerContext
16
- } from "./chunk-TOGR56FN.mjs";
17
-
18
- // src/index.tsx
19
- import Reconciler from "react-reconciler";
20
- import { DefaultEventPriority } from "react-reconciler/constants";
21
- import * as ld from "@arcanejs/toolkit";
22
- import { Base, BaseParent } from "@arcanejs/toolkit/components/base";
23
- import { jsx } from "react/jsx-runtime";
24
- var isType = (targetType, type, _props) => targetType === type;
25
- var canSetProps = (instance) => instance instanceof Base;
26
- var updateListener = (eventName, property, instance, prevProps, nextProps) => {
27
- const prev = prevProps[property];
28
- const next = nextProps[property];
29
- if (prev !== next) {
30
- prev && instance.removeListener(eventName, prev);
31
- next && instance.addListener(eventName, next);
32
- }
33
- };
34
- var updateListeners = (type, instance, prevProps, nextProps) => {
35
- if (isType("button", type, prevProps) && isType("button", type, nextProps)) {
36
- if (instance instanceof ld.Button) {
37
- updateListener("click", "onClick", instance, prevProps, nextProps);
38
- }
39
- } else if (isType("group", type, prevProps) && isType("group", type, nextProps)) {
40
- if (instance instanceof ld.Group) {
41
- updateListener(
42
- "title-changed",
43
- "onTitleChanged",
44
- instance,
45
- prevProps,
46
- nextProps
47
- );
48
- }
49
- } else if (isType("slider-button", type, prevProps) && isType("slider-button", type, nextProps)) {
50
- if (instance instanceof ld.SliderButton) {
51
- updateListener("change", "onChange", instance, prevProps, nextProps);
52
- }
53
- } else if (isType("switch", type, prevProps) && isType("switch", type, nextProps)) {
54
- if (instance instanceof ld.Switch) {
55
- updateListener("change", "onChange", instance, prevProps, nextProps);
56
- }
57
- } else if (isType("text-input", type, prevProps) && isType("text-input", type, nextProps)) {
58
- if (instance instanceof ld.TextInput) {
59
- updateListener("change", "onChange", instance, prevProps, nextProps);
60
- }
61
- }
62
- };
63
- var hostConfig = {
64
- supportsMutation: true,
65
- supportsPersistence: false,
66
- noTimeout: -1,
67
- isPrimaryRenderer: true,
68
- supportsHydration: false,
69
- afterActiveInstanceBlur: () => null,
70
- appendChild: (parentInstance, child) => {
71
- if (parentInstance instanceof BaseParent) {
72
- parentInstance.appendChild(child);
73
- } else {
74
- throw new Error(`Unexpected Parent: ${parentInstance}`);
75
- }
76
- },
77
- appendInitialChild: (parentInstance, child) => {
78
- if (parentInstance instanceof BaseParent) {
79
- parentInstance.appendChild(child);
80
- } else {
81
- throw new Error(`Unexpected Parent: ${parentInstance}`);
82
- }
83
- },
84
- appendChildToContainer(container, child) {
85
- container.appendChild(child);
86
- },
87
- beforeActiveInstanceBlur: () => null,
88
- cancelTimeout: (id) => clearTimeout(id),
89
- clearContainer: (container) => container.removeAllChildren(),
90
- commitMount: () => {
91
- throw new Error(`Unexpected call to commitMount()`);
92
- },
93
- commitUpdate(instance, updatePayload, type, prevProps, nextProps, _internalHandle) {
94
- if (canSetProps(instance)) {
95
- instance.setProps(updatePayload);
96
- updateListeners(type, instance, prevProps, nextProps);
97
- } else {
98
- throw new Error(`Unexpected Instance: ${instance}`);
99
- }
100
- },
101
- commitTextUpdate: (textInstance, _oldText, newText) => textInstance.setText(newText),
102
- createInstance: (type, props) => {
103
- let instance = null;
104
- if (isType("button", type, props)) {
105
- instance = new ld.Button(props);
106
- } else if (isType("group", type, props)) {
107
- instance = new ld.Group(props);
108
- } else if (isType("group-header", type, props)) {
109
- instance = new ld.GroupHeader(props);
110
- } else if (isType("label", type, props)) {
111
- instance = new ld.Label(props);
112
- } else if (isType("rect", type, props)) {
113
- instance = new ld.Rect(props);
114
- } else if (isType("slider-button", type, props)) {
115
- instance = new ld.SliderButton(props);
116
- } else if (isType("switch", type, props)) {
117
- instance = new ld.Switch(props);
118
- } else if (isType("tab", type, props)) {
119
- instance = new ld.Tab(props);
120
- } else if (isType("tabs", type, props)) {
121
- instance = new ld.Tabs(props);
122
- } else if (isType("text-input", type, props)) {
123
- instance = new ld.TextInput(props);
124
- } else if (isType("timeline", type, props)) {
125
- instance = new ld.Timeline(props);
126
- }
127
- if (instance) {
128
- updateListeners(type, instance, {}, props);
129
- return instance;
130
- } else {
131
- throw new Error(`Not implemented type: ${type}`);
132
- }
133
- },
134
- createTextInstance: (text) => new ld.Label({ text }),
135
- detachDeletedInstance: () => null,
136
- getChildHostContext: (parentHostContext) => parentHostContext,
137
- getCurrentEventPriority: () => DefaultEventPriority,
138
- getInstanceFromNode: () => {
139
- throw new Error("Not yet implemented.");
140
- },
141
- getInstanceFromScope: () => {
142
- throw new Error("Not yet implemented.");
143
- },
144
- getPublicInstance: (instance) => instance,
145
- getRootHostContext: () => null,
146
- insertBefore: (parentInstance, child, beforeChild) => {
147
- if (parentInstance instanceof BaseParent) {
148
- parentInstance.insertBefore(child, beforeChild);
149
- } else {
150
- throw new Error(`Unexpected Parent: ${parentInstance}`);
151
- }
152
- },
153
- insertInContainerBefore: (container, child, beforeChild) => container.insertBefore(child, beforeChild),
154
- finalizeInitialChildren: () => false,
155
- prepareForCommit: () => null,
156
- preparePortalMount: () => null,
157
- prepareScopeUpdate: () => null,
158
- prepareUpdate: (_instance, _type, _oldProps, newProps, _rootContainer, _hostContext) => {
159
- const updates = {};
160
- for (const [key, val] of Object.entries(newProps)) {
161
- if (key !== "children") {
162
- updates[key] = val;
163
- }
164
- }
165
- if (Object.keys(updates).length) {
166
- return updates;
167
- } else {
168
- return null;
169
- }
170
- },
171
- removeChild(parentInstance, child) {
172
- if (parentInstance instanceof BaseParent) {
173
- parentInstance.removeChild(child);
174
- } else {
175
- throw new Error(`Unexpected Parent: ${parentInstance}`);
176
- }
177
- },
178
- removeChildFromContainer: (container, child) => container.removeChild(child),
179
- resetAfterCommit: () => null,
180
- resetTextContent: () => {
181
- throw new Error(`Unexpected call to resetTextContent()`);
182
- },
183
- scheduleTimeout: (fn, delay) => setTimeout(fn, delay),
184
- shouldSetTextContent: () => false,
185
- // Not-implemented
186
- hideInstance: () => {
187
- console.log("Not-implemented: hideInstance");
188
- },
189
- hideTextInstance: () => {
190
- console.log("Not-implemented: hideTextInstance");
191
- },
192
- unhideInstance: () => {
193
- console.log("Not-implemented: unhideInstance");
194
- },
195
- unhideTextInstance: () => {
196
- console.log("Not-implemented: unhideTextInstance");
197
- }
198
- };
199
- var reconciler = Reconciler(hostConfig);
200
- var ToolkitRenderer = {
201
- renderGroup: (component, container) => {
202
- const root = reconciler.createContainer(container, 0, false, null);
203
- const componentWithContexts = /* @__PURE__ */ jsx(LoggerContext.Provider, { value: container.log, children: component });
204
- reconciler.updateContainer(componentWithContexts, root, null);
205
- },
206
- render: (component, container, rootGroupProps) => {
207
- const group = new ld.Group({ direction: "vertical", ...rootGroupProps });
208
- container.setRoot(group);
209
- ToolkitRenderer.renderGroup(component, group);
210
- }
211
- };
13
+ Timeline,
14
+ ToolkitRenderer,
15
+ prepareComponents
16
+ } from "./chunk-CAHNLXTY.mjs";
17
+ import "./chunk-TOGR56FN.mjs";
212
18
  export {
213
19
  Button,
20
+ CoreComponents,
214
21
  Group,
215
22
  GroupHeader,
216
23
  Label,
@@ -221,5 +28,6 @@ export {
221
28
  Tabs,
222
29
  TextInput,
223
30
  Timeline,
224
- ToolkitRenderer
31
+ ToolkitRenderer,
32
+ prepareComponents
225
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcanejs/react-toolkit",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "private": false,
5
5
  "description": "Build web-accessible control interfaces for your long-running Node.js processes",
6
6
  "keywords": [
@@ -21,27 +21,27 @@
21
21
  "exports": {
22
22
  ".": {
23
23
  "@arcanejs/source": "./src/index.tsx",
24
+ "types": "./dist/index.d.ts",
24
25
  "import": "./dist/index.mjs",
25
- "require": "./dist/index.js",
26
- "types": "./dist/index.d.ts"
26
+ "require": "./dist/index.js"
27
27
  },
28
28
  "./colors": {
29
29
  "@arcanejs/source": "./src/colors.tsx",
30
+ "types": "./dist/colors.d.ts",
30
31
  "import": "./dist/colors.mjs",
31
- "require": "./dist/colors.js",
32
- "types": "./dist/colors.d.ts"
32
+ "require": "./dist/colors.js"
33
33
  },
34
34
  "./data": {
35
35
  "@arcanejs/source": "./src/data.tsx",
36
+ "types": "./dist/data.d.ts",
36
37
  "import": "./dist/data.mjs",
37
- "require": "./dist/data.js",
38
- "types": "./dist/data.d.ts"
38
+ "require": "./dist/data.js"
39
39
  },
40
40
  "./logging": {
41
41
  "@arcanejs/source": "./src/logging.ts",
42
+ "types": "./dist/logging.d.ts",
42
43
  "import": "./dist/logging.mjs",
43
- "require": "./dist/logging.js",
44
- "types": "./dist/logging.d.ts"
44
+ "require": "./dist/logging.js"
45
45
  },
46
46
  "./package.json": "./package.json"
47
47
  },
@@ -56,15 +56,15 @@
56
56
  "tsup": "^8.1.0",
57
57
  "typescript": "^5.3.3",
58
58
  "zod": "^3.23.8",
59
- "@arcanejs/typescript-config": "^0.0.0",
60
- "@arcanejs/eslint-config": "^0.0.0"
59
+ "@arcanejs/eslint-config": "^0.0.0",
60
+ "@arcanejs/typescript-config": "^0.0.0"
61
61
  },
62
62
  "dependencies": {
63
63
  "lodash": "^4.17.21",
64
64
  "react": "^18",
65
65
  "react-reconciler": "0.28.0",
66
- "@arcanejs/protocol": "^0.3.0",
67
- "@arcanejs/toolkit": "^0.5.1"
66
+ "@arcanejs/protocol": "^0.4.0",
67
+ "@arcanejs/toolkit": "^1.0.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "zod": "^3.23.8"
@@ -1,49 +0,0 @@
1
- // src/components.ts
2
- import * as React from "react";
3
- var Button = React.forwardRef(
4
- (props, ref) => React.createElement("button", { ...props, ref }, props.children)
5
- );
6
- var Group = React.forwardRef(
7
- (props, ref) => React.createElement("group", { ...props, ref }, props.children)
8
- );
9
- var GroupHeader = React.forwardRef(
10
- (props, ref) => React.createElement("group-header", { ...props, ref }, props.children)
11
- );
12
- var Label = React.forwardRef(
13
- (props, ref) => React.createElement("label", { ...props, ref }, props.children)
14
- );
15
- var Rect = React.forwardRef(
16
- (props, ref) => React.createElement("rect", { ...props, ref }, props.children)
17
- );
18
- var SliderButton = React.forwardRef(
19
- (props, ref) => React.createElement("slider-button", { ...props, ref }, props.children)
20
- );
21
- var Switch = React.forwardRef(
22
- (props, ref) => React.createElement("switch", { ...props, ref }, props.children)
23
- );
24
- var Tab = React.forwardRef(
25
- (props, ref) => React.createElement("tab", { ...props, ref }, props.children)
26
- );
27
- var Tabs = React.forwardRef(
28
- (props, ref) => React.createElement("tabs", { ...props, ref }, props.children)
29
- );
30
- var TextInput = React.forwardRef(
31
- (props, ref) => React.createElement("text-input", { ...props, ref }, props.children)
32
- );
33
- var Timeline = React.forwardRef(
34
- (props, ref) => React.createElement("timeline", { ...props, ref }, props.children)
35
- );
36
-
37
- export {
38
- Button,
39
- Group,
40
- GroupHeader,
41
- Label,
42
- Rect,
43
- SliderButton,
44
- Switch,
45
- Tab,
46
- Tabs,
47
- TextInput,
48
- Timeline
49
- };
@@ -1,49 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// src/components.ts
2
- var _react = require('react'); var React = _interopRequireWildcard(_react);
3
- var Button = React.forwardRef(
4
- (props, ref) => React.createElement("button", { ...props, ref }, props.children)
5
- );
6
- var Group = React.forwardRef(
7
- (props, ref) => React.createElement("group", { ...props, ref }, props.children)
8
- );
9
- var GroupHeader = React.forwardRef(
10
- (props, ref) => React.createElement("group-header", { ...props, ref }, props.children)
11
- );
12
- var Label = React.forwardRef(
13
- (props, ref) => React.createElement("label", { ...props, ref }, props.children)
14
- );
15
- var Rect = React.forwardRef(
16
- (props, ref) => React.createElement("rect", { ...props, ref }, props.children)
17
- );
18
- var SliderButton = React.forwardRef(
19
- (props, ref) => React.createElement("slider-button", { ...props, ref }, props.children)
20
- );
21
- var Switch = React.forwardRef(
22
- (props, ref) => React.createElement("switch", { ...props, ref }, props.children)
23
- );
24
- var Tab = React.forwardRef(
25
- (props, ref) => React.createElement("tab", { ...props, ref }, props.children)
26
- );
27
- var Tabs = React.forwardRef(
28
- (props, ref) => React.createElement("tabs", { ...props, ref }, props.children)
29
- );
30
- var TextInput = React.forwardRef(
31
- (props, ref) => React.createElement("text-input", { ...props, ref }, props.children)
32
- );
33
- var Timeline = React.forwardRef(
34
- (props, ref) => React.createElement("timeline", { ...props, ref }, props.children)
35
- );
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
- exports.Button = Button; exports.Group = Group; exports.GroupHeader = GroupHeader; exports.Label = Label; exports.Rect = Rect; exports.SliderButton = SliderButton; exports.Switch = Switch; exports.Tab = Tab; exports.Tabs = Tabs; exports.TextInput = TextInput; exports.Timeline = Timeline;
@@ -1,66 +0,0 @@
1
- import { Props as Props$1, Events as Events$1, Group, GroupHeader } from '@arcanejs/toolkit/components/group';
2
- import { Props, Events, Button } from '@arcanejs/toolkit/components/button';
3
- import { Props as Props$2, Label } from '@arcanejs/toolkit/components/label';
4
- import { Props as Props$3, Rect } from '@arcanejs/toolkit/components/rect';
5
- import { Props as Props$4, Events as Events$2, SliderButton } from '@arcanejs/toolkit/components/slider-button';
6
- import { Props as Props$5, Events as Events$3, Switch } from '@arcanejs/toolkit/components/switch';
7
- import { TabProps, Tab, TabsProps, Tabs } from '@arcanejs/toolkit/components/tabs';
8
- import { Props as Props$6, Events as Events$4, TextInput } from '@arcanejs/toolkit/components/text-input';
9
- import { Props as Props$7, Timeline } from '@arcanejs/toolkit/components/timeline';
10
- import { Ref } from 'react';
11
-
12
- type Child = JSX.Element | string | null | undefined | boolean;
13
- type Children = Child | Child[];
14
- interface LightDeskIntrinsicElements {
15
- button: Props & {
16
- children?: never;
17
- onClick?: Events['click'];
18
- ref?: Ref<Button>;
19
- };
20
- group: Props$1 & {
21
- children?: Children;
22
- onTitleChanged?: Events$1['title-changed'];
23
- ref?: Ref<Group>;
24
- };
25
- 'group-header': {
26
- children?: Children;
27
- ref?: Ref<GroupHeader>;
28
- };
29
- label: Props$2 & {
30
- children?: never;
31
- ref?: Ref<Label>;
32
- };
33
- rect: Props$3 & {
34
- children?: never;
35
- ref?: Ref<Rect>;
36
- };
37
- 'slider-button': Props$4 & {
38
- children?: never;
39
- onChange?: Events$2['change'];
40
- ref?: Ref<SliderButton>;
41
- };
42
- switch: Props$5 & {
43
- children?: never;
44
- onChange?: Events$3['change'];
45
- ref?: Ref<Switch>;
46
- };
47
- tab: TabProps & {
48
- children?: JSX.Element | string;
49
- ref?: Ref<Tab>;
50
- };
51
- tabs: TabsProps & {
52
- children?: JSX.Element | JSX.Element[];
53
- ref?: Ref<Tabs>;
54
- };
55
- 'text-input': Props$6 & {
56
- children?: JSX.Element | JSX.Element[];
57
- onChange?: Events$4['change'];
58
- ref?: Ref<TextInput>;
59
- };
60
- timeline: Props$7 & {
61
- children?: never;
62
- ref?: Ref<Timeline>;
63
- };
64
- }
65
-
66
- export type { LightDeskIntrinsicElements as L };
@@ -1,66 +0,0 @@
1
- import { Props as Props$1, Events as Events$1, Group, GroupHeader } from '@arcanejs/toolkit/components/group';
2
- import { Props, Events, Button } from '@arcanejs/toolkit/components/button';
3
- import { Props as Props$2, Label } from '@arcanejs/toolkit/components/label';
4
- import { Props as Props$3, Rect } from '@arcanejs/toolkit/components/rect';
5
- import { Props as Props$4, Events as Events$2, SliderButton } from '@arcanejs/toolkit/components/slider-button';
6
- import { Props as Props$5, Events as Events$3, Switch } from '@arcanejs/toolkit/components/switch';
7
- import { TabProps, Tab, TabsProps, Tabs } from '@arcanejs/toolkit/components/tabs';
8
- import { Props as Props$6, Events as Events$4, TextInput } from '@arcanejs/toolkit/components/text-input';
9
- import { Props as Props$7, Timeline } from '@arcanejs/toolkit/components/timeline';
10
- import { Ref } from 'react';
11
-
12
- type Child = JSX.Element | string | null | undefined | boolean;
13
- type Children = Child | Child[];
14
- interface LightDeskIntrinsicElements {
15
- button: Props & {
16
- children?: never;
17
- onClick?: Events['click'];
18
- ref?: Ref<Button>;
19
- };
20
- group: Props$1 & {
21
- children?: Children;
22
- onTitleChanged?: Events$1['title-changed'];
23
- ref?: Ref<Group>;
24
- };
25
- 'group-header': {
26
- children?: Children;
27
- ref?: Ref<GroupHeader>;
28
- };
29
- label: Props$2 & {
30
- children?: never;
31
- ref?: Ref<Label>;
32
- };
33
- rect: Props$3 & {
34
- children?: never;
35
- ref?: Ref<Rect>;
36
- };
37
- 'slider-button': Props$4 & {
38
- children?: never;
39
- onChange?: Events$2['change'];
40
- ref?: Ref<SliderButton>;
41
- };
42
- switch: Props$5 & {
43
- children?: never;
44
- onChange?: Events$3['change'];
45
- ref?: Ref<Switch>;
46
- };
47
- tab: TabProps & {
48
- children?: JSX.Element | string;
49
- ref?: Ref<Tab>;
50
- };
51
- tabs: TabsProps & {
52
- children?: JSX.Element | JSX.Element[];
53
- ref?: Ref<Tabs>;
54
- };
55
- 'text-input': Props$6 & {
56
- children?: JSX.Element | JSX.Element[];
57
- onChange?: Events$4['change'];
58
- ref?: Ref<TextInput>;
59
- };
60
- timeline: Props$7 & {
61
- children?: never;
62
- ref?: Ref<Timeline>;
63
- };
64
- }
65
-
66
- export type { LightDeskIntrinsicElements as L };