@arcanejs/react-toolkit 0.4.0 → 0.5.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/README.md +7 -1
- package/dist/index.d.mts +86 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +250 -0
- package/dist/index.mjs +250 -0
- package/dist/logging.d.mts +2 -2
- package/dist/logging.d.ts +2 -2
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ const ControlPanel = () => {
|
|
|
90
90
|
<Group>
|
|
91
91
|
{`Switch State: ${switchState}`}
|
|
92
92
|
<Switch
|
|
93
|
-
|
|
93
|
+
value={switchState}
|
|
94
94
|
onChange={setSwitchState}
|
|
95
95
|
/>
|
|
96
96
|
</Group>
|
|
@@ -289,6 +289,12 @@ For a comprehensive list of examples,
|
|
|
289
289
|
please see the example directory in the arcane monorepo:
|
|
290
290
|
<https://github.com/arcanejs/arcanejs/tree/main/examples/react>
|
|
291
291
|
|
|
292
|
+
### [Example Philips Hue App](https://github.com/arcanejs/hue-example)
|
|
293
|
+
|
|
294
|
+
Check out this example repository that uses `@arcanejs/react-toolkit`
|
|
295
|
+
to create an app that can be used to control a Philips Hue Bridge
|
|
296
|
+
on your local network.
|
|
297
|
+
|
|
292
298
|
## Status / Suitability / Security Disclaimer
|
|
293
299
|
|
|
294
300
|
This project is **experimental**,
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as ld from '@arcanejs/toolkit';
|
|
2
|
+
import { Props as Props$1, Events as Events$1, Group as Group$1, GroupHeader as GroupHeader$1 } from '@arcanejs/toolkit/components/group';
|
|
3
|
+
import { Props, Events, Button as Button$1 } from '@arcanejs/toolkit/components/button';
|
|
4
|
+
import { Props as Props$2, Label as Label$1 } from '@arcanejs/toolkit/components/label';
|
|
5
|
+
import { Props as Props$3, Rect as Rect$1 } from '@arcanejs/toolkit/components/rect';
|
|
6
|
+
import { Props as Props$4, Events as Events$2, SliderButton as SliderButton$1 } from '@arcanejs/toolkit/components/slider-button';
|
|
7
|
+
import { Props as Props$5, Events as Events$3, Switch as Switch$1 } from '@arcanejs/toolkit/components/switch';
|
|
8
|
+
import { TabProps, Tab as Tab$1, TabsProps, Tabs as Tabs$1 } from '@arcanejs/toolkit/components/tabs';
|
|
9
|
+
import { Props as Props$6, Events as Events$4, TextInput as TextInput$1 } from '@arcanejs/toolkit/components/text-input';
|
|
10
|
+
import { Props as Props$7, Timeline as Timeline$1 } from '@arcanejs/toolkit/components/timeline';
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { Ref } from 'react';
|
|
13
|
+
|
|
14
|
+
type Child = JSX.Element | string | null | undefined | boolean;
|
|
15
|
+
type Children = Child | Child[];
|
|
16
|
+
interface LightDeskIntrinsicElements {
|
|
17
|
+
button: Props & {
|
|
18
|
+
children?: never;
|
|
19
|
+
onClick?: Events['click'];
|
|
20
|
+
ref?: Ref<Button$1>;
|
|
21
|
+
};
|
|
22
|
+
group: Props$1 & {
|
|
23
|
+
children?: Children;
|
|
24
|
+
onTitleChanged?: Events$1['title-changed'];
|
|
25
|
+
ref?: Ref<Group$1>;
|
|
26
|
+
};
|
|
27
|
+
'group-header': {
|
|
28
|
+
children?: Children;
|
|
29
|
+
ref?: Ref<GroupHeader$1>;
|
|
30
|
+
};
|
|
31
|
+
label: Props$2 & {
|
|
32
|
+
children?: never;
|
|
33
|
+
ref?: Ref<Label$1>;
|
|
34
|
+
};
|
|
35
|
+
rect: Props$3 & {
|
|
36
|
+
children?: never;
|
|
37
|
+
ref?: Ref<Rect$1>;
|
|
38
|
+
};
|
|
39
|
+
'slider-button': Props$4 & {
|
|
40
|
+
children?: never;
|
|
41
|
+
onChange?: Events$2['change'];
|
|
42
|
+
ref?: Ref<SliderButton$1>;
|
|
43
|
+
};
|
|
44
|
+
switch: Props$5 & {
|
|
45
|
+
children?: never;
|
|
46
|
+
onChange?: Events$3['change'];
|
|
47
|
+
ref?: Ref<Switch$1>;
|
|
48
|
+
};
|
|
49
|
+
tab: TabProps & {
|
|
50
|
+
children?: JSX.Element | string;
|
|
51
|
+
ref?: Ref<Tab$1>;
|
|
52
|
+
};
|
|
53
|
+
tabs: TabsProps & {
|
|
54
|
+
children?: JSX.Element | JSX.Element[];
|
|
55
|
+
ref?: Ref<Tabs$1>;
|
|
56
|
+
};
|
|
57
|
+
'text-input': Props$6 & {
|
|
58
|
+
children?: JSX.Element | JSX.Element[];
|
|
59
|
+
onChange?: Events$4['change'];
|
|
60
|
+
ref?: Ref<TextInput$1>;
|
|
61
|
+
};
|
|
62
|
+
timeline: Props$7 & {
|
|
63
|
+
children?: never;
|
|
64
|
+
ref?: Ref<Timeline$1>;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type ComponentWithRef<T, P> = React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
|
|
69
|
+
declare const Button: ComponentWithRef<Button$1, LightDeskIntrinsicElements['button']>;
|
|
70
|
+
declare const Group: ComponentWithRef<Group$1, LightDeskIntrinsicElements['group']>;
|
|
71
|
+
declare const GroupHeader: ComponentWithRef<GroupHeader$1, LightDeskIntrinsicElements['group-header']>;
|
|
72
|
+
declare const Label: ComponentWithRef<Label$1, LightDeskIntrinsicElements['label']>;
|
|
73
|
+
declare const Rect: ComponentWithRef<Rect$1, LightDeskIntrinsicElements['rect']>;
|
|
74
|
+
declare const SliderButton: ComponentWithRef<SliderButton$1, LightDeskIntrinsicElements['slider-button']>;
|
|
75
|
+
declare const Switch: ComponentWithRef<Switch$1, LightDeskIntrinsicElements['switch']>;
|
|
76
|
+
declare const Tab: ComponentWithRef<Tab$1, LightDeskIntrinsicElements['tab']>;
|
|
77
|
+
declare const Tabs: ComponentWithRef<Tabs$1, LightDeskIntrinsicElements['tabs']>;
|
|
78
|
+
declare const TextInput: ComponentWithRef<TextInput$1, LightDeskIntrinsicElements['text-input']>;
|
|
79
|
+
declare const Timeline: ComponentWithRef<Timeline$1, LightDeskIntrinsicElements['timeline']>;
|
|
80
|
+
|
|
81
|
+
declare const ToolkitRenderer: {
|
|
82
|
+
renderGroup: (component: JSX.Element, container: ld.Group) => void;
|
|
83
|
+
render: (component: JSX.Element, container: ld.Toolkit, rootGroupProps?: Props$1) => void;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { Button, Group, GroupHeader, Label, type LightDeskIntrinsicElements, Rect, SliderButton, Switch, Tab, Tabs, TextInput, Timeline, ToolkitRenderer };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as ld from '@arcanejs/toolkit';
|
|
2
|
+
import { Props as Props$1, Events as Events$1, Group as Group$1, GroupHeader as GroupHeader$1 } from '@arcanejs/toolkit/components/group';
|
|
3
|
+
import { Props, Events, Button as Button$1 } from '@arcanejs/toolkit/components/button';
|
|
4
|
+
import { Props as Props$2, Label as Label$1 } from '@arcanejs/toolkit/components/label';
|
|
5
|
+
import { Props as Props$3, Rect as Rect$1 } from '@arcanejs/toolkit/components/rect';
|
|
6
|
+
import { Props as Props$4, Events as Events$2, SliderButton as SliderButton$1 } from '@arcanejs/toolkit/components/slider-button';
|
|
7
|
+
import { Props as Props$5, Events as Events$3, Switch as Switch$1 } from '@arcanejs/toolkit/components/switch';
|
|
8
|
+
import { TabProps, Tab as Tab$1, TabsProps, Tabs as Tabs$1 } from '@arcanejs/toolkit/components/tabs';
|
|
9
|
+
import { Props as Props$6, Events as Events$4, TextInput as TextInput$1 } from '@arcanejs/toolkit/components/text-input';
|
|
10
|
+
import { Props as Props$7, Timeline as Timeline$1 } from '@arcanejs/toolkit/components/timeline';
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { Ref } from 'react';
|
|
13
|
+
|
|
14
|
+
type Child = JSX.Element | string | null | undefined | boolean;
|
|
15
|
+
type Children = Child | Child[];
|
|
16
|
+
interface LightDeskIntrinsicElements {
|
|
17
|
+
button: Props & {
|
|
18
|
+
children?: never;
|
|
19
|
+
onClick?: Events['click'];
|
|
20
|
+
ref?: Ref<Button$1>;
|
|
21
|
+
};
|
|
22
|
+
group: Props$1 & {
|
|
23
|
+
children?: Children;
|
|
24
|
+
onTitleChanged?: Events$1['title-changed'];
|
|
25
|
+
ref?: Ref<Group$1>;
|
|
26
|
+
};
|
|
27
|
+
'group-header': {
|
|
28
|
+
children?: Children;
|
|
29
|
+
ref?: Ref<GroupHeader$1>;
|
|
30
|
+
};
|
|
31
|
+
label: Props$2 & {
|
|
32
|
+
children?: never;
|
|
33
|
+
ref?: Ref<Label$1>;
|
|
34
|
+
};
|
|
35
|
+
rect: Props$3 & {
|
|
36
|
+
children?: never;
|
|
37
|
+
ref?: Ref<Rect$1>;
|
|
38
|
+
};
|
|
39
|
+
'slider-button': Props$4 & {
|
|
40
|
+
children?: never;
|
|
41
|
+
onChange?: Events$2['change'];
|
|
42
|
+
ref?: Ref<SliderButton$1>;
|
|
43
|
+
};
|
|
44
|
+
switch: Props$5 & {
|
|
45
|
+
children?: never;
|
|
46
|
+
onChange?: Events$3['change'];
|
|
47
|
+
ref?: Ref<Switch$1>;
|
|
48
|
+
};
|
|
49
|
+
tab: TabProps & {
|
|
50
|
+
children?: JSX.Element | string;
|
|
51
|
+
ref?: Ref<Tab$1>;
|
|
52
|
+
};
|
|
53
|
+
tabs: TabsProps & {
|
|
54
|
+
children?: JSX.Element | JSX.Element[];
|
|
55
|
+
ref?: Ref<Tabs$1>;
|
|
56
|
+
};
|
|
57
|
+
'text-input': Props$6 & {
|
|
58
|
+
children?: JSX.Element | JSX.Element[];
|
|
59
|
+
onChange?: Events$4['change'];
|
|
60
|
+
ref?: Ref<TextInput$1>;
|
|
61
|
+
};
|
|
62
|
+
timeline: Props$7 & {
|
|
63
|
+
children?: never;
|
|
64
|
+
ref?: Ref<Timeline$1>;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type ComponentWithRef<T, P> = React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
|
|
69
|
+
declare const Button: ComponentWithRef<Button$1, LightDeskIntrinsicElements['button']>;
|
|
70
|
+
declare const Group: ComponentWithRef<Group$1, LightDeskIntrinsicElements['group']>;
|
|
71
|
+
declare const GroupHeader: ComponentWithRef<GroupHeader$1, LightDeskIntrinsicElements['group-header']>;
|
|
72
|
+
declare const Label: ComponentWithRef<Label$1, LightDeskIntrinsicElements['label']>;
|
|
73
|
+
declare const Rect: ComponentWithRef<Rect$1, LightDeskIntrinsicElements['rect']>;
|
|
74
|
+
declare const SliderButton: ComponentWithRef<SliderButton$1, LightDeskIntrinsicElements['slider-button']>;
|
|
75
|
+
declare const Switch: ComponentWithRef<Switch$1, LightDeskIntrinsicElements['switch']>;
|
|
76
|
+
declare const Tab: ComponentWithRef<Tab$1, LightDeskIntrinsicElements['tab']>;
|
|
77
|
+
declare const Tabs: ComponentWithRef<Tabs$1, LightDeskIntrinsicElements['tabs']>;
|
|
78
|
+
declare const TextInput: ComponentWithRef<TextInput$1, LightDeskIntrinsicElements['text-input']>;
|
|
79
|
+
declare const Timeline: ComponentWithRef<Timeline$1, LightDeskIntrinsicElements['timeline']>;
|
|
80
|
+
|
|
81
|
+
declare const ToolkitRenderer: {
|
|
82
|
+
renderGroup: (component: JSX.Element, container: ld.Group) => void;
|
|
83
|
+
render: (component: JSX.Element, container: ld.Toolkit, rootGroupProps?: Props$1) => void;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { Button, Group, GroupHeader, Label, type LightDeskIntrinsicElements, Rect, SliderButton, Switch, Tab, Tabs, TextInput, Timeline, ToolkitRenderer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkRT2VSMJLjs = require('./chunk-RT2VSMJL.js');
|
|
4
|
+
|
|
5
|
+
// src/index.tsx
|
|
6
|
+
var _reactreconciler = require('react-reconciler'); var _reactreconciler2 = _interopRequireDefault(_reactreconciler);
|
|
7
|
+
var _constants = require('react-reconciler/constants');
|
|
8
|
+
var _toolkit = require('@arcanejs/toolkit'); var ld = _interopRequireWildcard(_toolkit);
|
|
9
|
+
var _base = require('@arcanejs/toolkit/components/base');
|
|
10
|
+
|
|
11
|
+
// src/components.ts
|
|
12
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react);
|
|
13
|
+
var Button = React.forwardRef(
|
|
14
|
+
(props, ref) => React.createElement("button", { ...props, ref }, props.children)
|
|
15
|
+
);
|
|
16
|
+
var Group = React.forwardRef(
|
|
17
|
+
(props, ref) => React.createElement("group", { ...props, ref }, props.children)
|
|
18
|
+
);
|
|
19
|
+
var GroupHeader = React.forwardRef(
|
|
20
|
+
(props, ref) => React.createElement("group-header", { ...props, ref }, props.children)
|
|
21
|
+
);
|
|
22
|
+
var Label = React.forwardRef(
|
|
23
|
+
(props, ref) => React.createElement("label", { ...props, ref }, props.children)
|
|
24
|
+
);
|
|
25
|
+
var Rect = React.forwardRef(
|
|
26
|
+
(props, ref) => React.createElement("rect", { ...props, ref }, props.children)
|
|
27
|
+
);
|
|
28
|
+
var SliderButton = React.forwardRef(
|
|
29
|
+
(props, ref) => React.createElement("slider-button", { ...props, ref }, props.children)
|
|
30
|
+
);
|
|
31
|
+
var Switch = React.forwardRef(
|
|
32
|
+
(props, ref) => React.createElement("switch", { ...props, ref }, props.children)
|
|
33
|
+
);
|
|
34
|
+
var Tab = React.forwardRef(
|
|
35
|
+
(props, ref) => React.createElement("tab", { ...props, ref }, props.children)
|
|
36
|
+
);
|
|
37
|
+
var Tabs = React.forwardRef(
|
|
38
|
+
(props, ref) => React.createElement("tabs", { ...props, ref }, props.children)
|
|
39
|
+
);
|
|
40
|
+
var TextInput = React.forwardRef(
|
|
41
|
+
(props, ref) => React.createElement("text-input", { ...props, ref }, props.children)
|
|
42
|
+
);
|
|
43
|
+
var Timeline = React.forwardRef(
|
|
44
|
+
(props, ref) => React.createElement("timeline", { ...props, ref }, props.children)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// src/index.tsx
|
|
48
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
49
|
+
var isType = (targetType, type, _props) => targetType === type;
|
|
50
|
+
var canSetProps = (instance) => instance instanceof _base.Base;
|
|
51
|
+
var updateListener = (eventName, property, instance, prevProps, nextProps) => {
|
|
52
|
+
const prev = prevProps[property];
|
|
53
|
+
const next = nextProps[property];
|
|
54
|
+
if (prev !== next) {
|
|
55
|
+
prev && instance.removeListener(eventName, prev);
|
|
56
|
+
next && instance.addListener(eventName, next);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var updateListeners = (type, instance, prevProps, nextProps) => {
|
|
60
|
+
if (isType("button", type, prevProps) && isType("button", type, nextProps)) {
|
|
61
|
+
if (instance instanceof ld.Button) {
|
|
62
|
+
updateListener("click", "onClick", instance, prevProps, nextProps);
|
|
63
|
+
}
|
|
64
|
+
} else if (isType("group", type, prevProps) && isType("group", type, nextProps)) {
|
|
65
|
+
if (instance instanceof ld.Group) {
|
|
66
|
+
updateListener(
|
|
67
|
+
"title-changed",
|
|
68
|
+
"onTitleChanged",
|
|
69
|
+
instance,
|
|
70
|
+
prevProps,
|
|
71
|
+
nextProps
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} else if (isType("slider-button", type, prevProps) && isType("slider-button", type, nextProps)) {
|
|
75
|
+
if (instance instanceof ld.SliderButton) {
|
|
76
|
+
updateListener("change", "onChange", instance, prevProps, nextProps);
|
|
77
|
+
}
|
|
78
|
+
} else if (isType("switch", type, prevProps) && isType("switch", type, nextProps)) {
|
|
79
|
+
if (instance instanceof ld.Switch) {
|
|
80
|
+
updateListener("change", "onChange", instance, prevProps, nextProps);
|
|
81
|
+
}
|
|
82
|
+
} else if (isType("text-input", type, prevProps) && isType("text-input", type, nextProps)) {
|
|
83
|
+
if (instance instanceof ld.TextInput) {
|
|
84
|
+
updateListener("change", "onChange", instance, prevProps, nextProps);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var hostConfig = {
|
|
89
|
+
supportsMutation: true,
|
|
90
|
+
supportsPersistence: false,
|
|
91
|
+
noTimeout: -1,
|
|
92
|
+
isPrimaryRenderer: true,
|
|
93
|
+
supportsHydration: false,
|
|
94
|
+
afterActiveInstanceBlur: () => null,
|
|
95
|
+
appendChild: (parentInstance, child) => {
|
|
96
|
+
if (parentInstance instanceof _base.BaseParent) {
|
|
97
|
+
parentInstance.appendChild(child);
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
appendInitialChild: (parentInstance, child) => {
|
|
103
|
+
if (parentInstance instanceof _base.BaseParent) {
|
|
104
|
+
parentInstance.appendChild(child);
|
|
105
|
+
} else {
|
|
106
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
appendChildToContainer(container, child) {
|
|
110
|
+
container.appendChild(child);
|
|
111
|
+
},
|
|
112
|
+
beforeActiveInstanceBlur: () => null,
|
|
113
|
+
cancelTimeout: (id) => clearTimeout(id),
|
|
114
|
+
clearContainer: (container) => container.removeAllChildren(),
|
|
115
|
+
commitMount: () => {
|
|
116
|
+
throw new Error(`Unexpected call to commitMount()`);
|
|
117
|
+
},
|
|
118
|
+
commitUpdate(instance, updatePayload, type, prevProps, nextProps, _internalHandle) {
|
|
119
|
+
if (canSetProps(instance)) {
|
|
120
|
+
instance.setProps(updatePayload);
|
|
121
|
+
updateListeners(type, instance, prevProps, nextProps);
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error(`Unexpected Instance: ${instance}`);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
commitTextUpdate: (textInstance, _oldText, newText) => textInstance.setText(newText),
|
|
127
|
+
createInstance: (type, props) => {
|
|
128
|
+
let instance = null;
|
|
129
|
+
if (isType("button", type, props)) {
|
|
130
|
+
instance = new ld.Button(props);
|
|
131
|
+
} else if (isType("group", type, props)) {
|
|
132
|
+
instance = new ld.Group(props);
|
|
133
|
+
} else if (isType("group-header", type, props)) {
|
|
134
|
+
instance = new ld.GroupHeader(props);
|
|
135
|
+
} else if (isType("label", type, props)) {
|
|
136
|
+
instance = new ld.Label(props);
|
|
137
|
+
} else if (isType("rect", type, props)) {
|
|
138
|
+
instance = new ld.Rect(props);
|
|
139
|
+
} else if (isType("slider-button", type, props)) {
|
|
140
|
+
instance = new ld.SliderButton(props);
|
|
141
|
+
} else if (isType("switch", type, props)) {
|
|
142
|
+
instance = new ld.Switch(props);
|
|
143
|
+
} else if (isType("tab", type, props)) {
|
|
144
|
+
instance = new ld.Tab(props);
|
|
145
|
+
} else if (isType("tabs", type, props)) {
|
|
146
|
+
instance = new ld.Tabs(props);
|
|
147
|
+
} else if (isType("text-input", type, props)) {
|
|
148
|
+
instance = new ld.TextInput(props);
|
|
149
|
+
} else if (isType("timeline", type, props)) {
|
|
150
|
+
instance = new ld.Timeline(props);
|
|
151
|
+
}
|
|
152
|
+
if (instance) {
|
|
153
|
+
updateListeners(type, instance, {}, props);
|
|
154
|
+
return instance;
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error(`Not implemented type: ${type}`);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
createTextInstance: (text) => new ld.Label({ text }),
|
|
160
|
+
detachDeletedInstance: () => null,
|
|
161
|
+
getChildHostContext: (parentHostContext) => parentHostContext,
|
|
162
|
+
getCurrentEventPriority: () => _constants.DefaultEventPriority,
|
|
163
|
+
getInstanceFromNode: () => {
|
|
164
|
+
throw new Error("Not yet implemented.");
|
|
165
|
+
},
|
|
166
|
+
getInstanceFromScope: () => {
|
|
167
|
+
throw new Error("Not yet implemented.");
|
|
168
|
+
},
|
|
169
|
+
getPublicInstance: (instance) => instance,
|
|
170
|
+
getRootHostContext: () => null,
|
|
171
|
+
insertBefore: (parentInstance, child, beforeChild) => {
|
|
172
|
+
if (parentInstance instanceof _base.BaseParent) {
|
|
173
|
+
parentInstance.insertBefore(child, beforeChild);
|
|
174
|
+
} else {
|
|
175
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
insertInContainerBefore: (container, child, beforeChild) => container.insertBefore(child, beforeChild),
|
|
179
|
+
finalizeInitialChildren: () => false,
|
|
180
|
+
prepareForCommit: () => null,
|
|
181
|
+
preparePortalMount: () => null,
|
|
182
|
+
prepareScopeUpdate: () => null,
|
|
183
|
+
prepareUpdate: (_instance, _type, _oldProps, newProps, _rootContainer, _hostContext) => {
|
|
184
|
+
const updates = {};
|
|
185
|
+
for (const [key, val] of Object.entries(newProps)) {
|
|
186
|
+
if (key !== "children") {
|
|
187
|
+
updates[key] = val;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (Object.keys(updates).length) {
|
|
191
|
+
return updates;
|
|
192
|
+
} else {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
removeChild(parentInstance, child) {
|
|
197
|
+
if (parentInstance instanceof _base.BaseParent) {
|
|
198
|
+
parentInstance.removeChild(child);
|
|
199
|
+
} else {
|
|
200
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
removeChildFromContainer: (container, child) => container.removeChild(child),
|
|
204
|
+
resetAfterCommit: () => null,
|
|
205
|
+
resetTextContent: () => {
|
|
206
|
+
throw new Error(`Unexpected call to resetTextContent()`);
|
|
207
|
+
},
|
|
208
|
+
scheduleTimeout: (fn, delay) => setTimeout(fn, delay),
|
|
209
|
+
shouldSetTextContent: () => false,
|
|
210
|
+
// Not-implemented
|
|
211
|
+
hideInstance: () => {
|
|
212
|
+
console.log("Not-implemented: hideInstance");
|
|
213
|
+
},
|
|
214
|
+
hideTextInstance: () => {
|
|
215
|
+
console.log("Not-implemented: hideTextInstance");
|
|
216
|
+
},
|
|
217
|
+
unhideInstance: () => {
|
|
218
|
+
console.log("Not-implemented: unhideInstance");
|
|
219
|
+
},
|
|
220
|
+
unhideTextInstance: () => {
|
|
221
|
+
console.log("Not-implemented: unhideTextInstance");
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var reconciler = _reactreconciler2.default.call(void 0, hostConfig);
|
|
225
|
+
var ToolkitRenderer = {
|
|
226
|
+
renderGroup: (component, container) => {
|
|
227
|
+
const root = reconciler.createContainer(container, 0, false, null);
|
|
228
|
+
const componentWithContexts = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRT2VSMJLjs.LoggerContext.Provider, { value: container.log, children: component });
|
|
229
|
+
reconciler.updateContainer(componentWithContexts, root, null);
|
|
230
|
+
},
|
|
231
|
+
render: (component, container, rootGroupProps) => {
|
|
232
|
+
const group = new ld.Group({ direction: "vertical", ...rootGroupProps });
|
|
233
|
+
container.setRoot(group);
|
|
234
|
+
ToolkitRenderer.renderGroup(component, group);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
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; exports.ToolkitRenderer = ToolkitRenderer;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LoggerContext
|
|
3
|
+
} from "./chunk-TOGR56FN.mjs";
|
|
4
|
+
|
|
5
|
+
// src/index.tsx
|
|
6
|
+
import Reconciler from "react-reconciler";
|
|
7
|
+
import { DefaultEventPriority } from "react-reconciler/constants";
|
|
8
|
+
import * as ld from "@arcanejs/toolkit";
|
|
9
|
+
import { Base, BaseParent } from "@arcanejs/toolkit/components/base";
|
|
10
|
+
|
|
11
|
+
// src/components.ts
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
var Button = React.forwardRef(
|
|
14
|
+
(props, ref) => React.createElement("button", { ...props, ref }, props.children)
|
|
15
|
+
);
|
|
16
|
+
var Group = React.forwardRef(
|
|
17
|
+
(props, ref) => React.createElement("group", { ...props, ref }, props.children)
|
|
18
|
+
);
|
|
19
|
+
var GroupHeader = React.forwardRef(
|
|
20
|
+
(props, ref) => React.createElement("group-header", { ...props, ref }, props.children)
|
|
21
|
+
);
|
|
22
|
+
var Label = React.forwardRef(
|
|
23
|
+
(props, ref) => React.createElement("label", { ...props, ref }, props.children)
|
|
24
|
+
);
|
|
25
|
+
var Rect = React.forwardRef(
|
|
26
|
+
(props, ref) => React.createElement("rect", { ...props, ref }, props.children)
|
|
27
|
+
);
|
|
28
|
+
var SliderButton = React.forwardRef(
|
|
29
|
+
(props, ref) => React.createElement("slider-button", { ...props, ref }, props.children)
|
|
30
|
+
);
|
|
31
|
+
var Switch = React.forwardRef(
|
|
32
|
+
(props, ref) => React.createElement("switch", { ...props, ref }, props.children)
|
|
33
|
+
);
|
|
34
|
+
var Tab = React.forwardRef(
|
|
35
|
+
(props, ref) => React.createElement("tab", { ...props, ref }, props.children)
|
|
36
|
+
);
|
|
37
|
+
var Tabs = React.forwardRef(
|
|
38
|
+
(props, ref) => React.createElement("tabs", { ...props, ref }, props.children)
|
|
39
|
+
);
|
|
40
|
+
var TextInput = React.forwardRef(
|
|
41
|
+
(props, ref) => React.createElement("text-input", { ...props, ref }, props.children)
|
|
42
|
+
);
|
|
43
|
+
var Timeline = React.forwardRef(
|
|
44
|
+
(props, ref) => React.createElement("timeline", { ...props, ref }, props.children)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// src/index.tsx
|
|
48
|
+
import { jsx } from "react/jsx-runtime";
|
|
49
|
+
var isType = (targetType, type, _props) => targetType === type;
|
|
50
|
+
var canSetProps = (instance) => instance instanceof Base;
|
|
51
|
+
var updateListener = (eventName, property, instance, prevProps, nextProps) => {
|
|
52
|
+
const prev = prevProps[property];
|
|
53
|
+
const next = nextProps[property];
|
|
54
|
+
if (prev !== next) {
|
|
55
|
+
prev && instance.removeListener(eventName, prev);
|
|
56
|
+
next && instance.addListener(eventName, next);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var updateListeners = (type, instance, prevProps, nextProps) => {
|
|
60
|
+
if (isType("button", type, prevProps) && isType("button", type, nextProps)) {
|
|
61
|
+
if (instance instanceof ld.Button) {
|
|
62
|
+
updateListener("click", "onClick", instance, prevProps, nextProps);
|
|
63
|
+
}
|
|
64
|
+
} else if (isType("group", type, prevProps) && isType("group", type, nextProps)) {
|
|
65
|
+
if (instance instanceof ld.Group) {
|
|
66
|
+
updateListener(
|
|
67
|
+
"title-changed",
|
|
68
|
+
"onTitleChanged",
|
|
69
|
+
instance,
|
|
70
|
+
prevProps,
|
|
71
|
+
nextProps
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} else if (isType("slider-button", type, prevProps) && isType("slider-button", type, nextProps)) {
|
|
75
|
+
if (instance instanceof ld.SliderButton) {
|
|
76
|
+
updateListener("change", "onChange", instance, prevProps, nextProps);
|
|
77
|
+
}
|
|
78
|
+
} else if (isType("switch", type, prevProps) && isType("switch", type, nextProps)) {
|
|
79
|
+
if (instance instanceof ld.Switch) {
|
|
80
|
+
updateListener("change", "onChange", instance, prevProps, nextProps);
|
|
81
|
+
}
|
|
82
|
+
} else if (isType("text-input", type, prevProps) && isType("text-input", type, nextProps)) {
|
|
83
|
+
if (instance instanceof ld.TextInput) {
|
|
84
|
+
updateListener("change", "onChange", instance, prevProps, nextProps);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var hostConfig = {
|
|
89
|
+
supportsMutation: true,
|
|
90
|
+
supportsPersistence: false,
|
|
91
|
+
noTimeout: -1,
|
|
92
|
+
isPrimaryRenderer: true,
|
|
93
|
+
supportsHydration: false,
|
|
94
|
+
afterActiveInstanceBlur: () => null,
|
|
95
|
+
appendChild: (parentInstance, child) => {
|
|
96
|
+
if (parentInstance instanceof BaseParent) {
|
|
97
|
+
parentInstance.appendChild(child);
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
appendInitialChild: (parentInstance, child) => {
|
|
103
|
+
if (parentInstance instanceof BaseParent) {
|
|
104
|
+
parentInstance.appendChild(child);
|
|
105
|
+
} else {
|
|
106
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
appendChildToContainer(container, child) {
|
|
110
|
+
container.appendChild(child);
|
|
111
|
+
},
|
|
112
|
+
beforeActiveInstanceBlur: () => null,
|
|
113
|
+
cancelTimeout: (id) => clearTimeout(id),
|
|
114
|
+
clearContainer: (container) => container.removeAllChildren(),
|
|
115
|
+
commitMount: () => {
|
|
116
|
+
throw new Error(`Unexpected call to commitMount()`);
|
|
117
|
+
},
|
|
118
|
+
commitUpdate(instance, updatePayload, type, prevProps, nextProps, _internalHandle) {
|
|
119
|
+
if (canSetProps(instance)) {
|
|
120
|
+
instance.setProps(updatePayload);
|
|
121
|
+
updateListeners(type, instance, prevProps, nextProps);
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error(`Unexpected Instance: ${instance}`);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
commitTextUpdate: (textInstance, _oldText, newText) => textInstance.setText(newText),
|
|
127
|
+
createInstance: (type, props) => {
|
|
128
|
+
let instance = null;
|
|
129
|
+
if (isType("button", type, props)) {
|
|
130
|
+
instance = new ld.Button(props);
|
|
131
|
+
} else if (isType("group", type, props)) {
|
|
132
|
+
instance = new ld.Group(props);
|
|
133
|
+
} else if (isType("group-header", type, props)) {
|
|
134
|
+
instance = new ld.GroupHeader(props);
|
|
135
|
+
} else if (isType("label", type, props)) {
|
|
136
|
+
instance = new ld.Label(props);
|
|
137
|
+
} else if (isType("rect", type, props)) {
|
|
138
|
+
instance = new ld.Rect(props);
|
|
139
|
+
} else if (isType("slider-button", type, props)) {
|
|
140
|
+
instance = new ld.SliderButton(props);
|
|
141
|
+
} else if (isType("switch", type, props)) {
|
|
142
|
+
instance = new ld.Switch(props);
|
|
143
|
+
} else if (isType("tab", type, props)) {
|
|
144
|
+
instance = new ld.Tab(props);
|
|
145
|
+
} else if (isType("tabs", type, props)) {
|
|
146
|
+
instance = new ld.Tabs(props);
|
|
147
|
+
} else if (isType("text-input", type, props)) {
|
|
148
|
+
instance = new ld.TextInput(props);
|
|
149
|
+
} else if (isType("timeline", type, props)) {
|
|
150
|
+
instance = new ld.Timeline(props);
|
|
151
|
+
}
|
|
152
|
+
if (instance) {
|
|
153
|
+
updateListeners(type, instance, {}, props);
|
|
154
|
+
return instance;
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error(`Not implemented type: ${type}`);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
createTextInstance: (text) => new ld.Label({ text }),
|
|
160
|
+
detachDeletedInstance: () => null,
|
|
161
|
+
getChildHostContext: (parentHostContext) => parentHostContext,
|
|
162
|
+
getCurrentEventPriority: () => DefaultEventPriority,
|
|
163
|
+
getInstanceFromNode: () => {
|
|
164
|
+
throw new Error("Not yet implemented.");
|
|
165
|
+
},
|
|
166
|
+
getInstanceFromScope: () => {
|
|
167
|
+
throw new Error("Not yet implemented.");
|
|
168
|
+
},
|
|
169
|
+
getPublicInstance: (instance) => instance,
|
|
170
|
+
getRootHostContext: () => null,
|
|
171
|
+
insertBefore: (parentInstance, child, beforeChild) => {
|
|
172
|
+
if (parentInstance instanceof BaseParent) {
|
|
173
|
+
parentInstance.insertBefore(child, beforeChild);
|
|
174
|
+
} else {
|
|
175
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
insertInContainerBefore: (container, child, beforeChild) => container.insertBefore(child, beforeChild),
|
|
179
|
+
finalizeInitialChildren: () => false,
|
|
180
|
+
prepareForCommit: () => null,
|
|
181
|
+
preparePortalMount: () => null,
|
|
182
|
+
prepareScopeUpdate: () => null,
|
|
183
|
+
prepareUpdate: (_instance, _type, _oldProps, newProps, _rootContainer, _hostContext) => {
|
|
184
|
+
const updates = {};
|
|
185
|
+
for (const [key, val] of Object.entries(newProps)) {
|
|
186
|
+
if (key !== "children") {
|
|
187
|
+
updates[key] = val;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (Object.keys(updates).length) {
|
|
191
|
+
return updates;
|
|
192
|
+
} else {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
removeChild(parentInstance, child) {
|
|
197
|
+
if (parentInstance instanceof BaseParent) {
|
|
198
|
+
parentInstance.removeChild(child);
|
|
199
|
+
} else {
|
|
200
|
+
throw new Error(`Unexpected Parent: ${parentInstance}`);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
removeChildFromContainer: (container, child) => container.removeChild(child),
|
|
204
|
+
resetAfterCommit: () => null,
|
|
205
|
+
resetTextContent: () => {
|
|
206
|
+
throw new Error(`Unexpected call to resetTextContent()`);
|
|
207
|
+
},
|
|
208
|
+
scheduleTimeout: (fn, delay) => setTimeout(fn, delay),
|
|
209
|
+
shouldSetTextContent: () => false,
|
|
210
|
+
// Not-implemented
|
|
211
|
+
hideInstance: () => {
|
|
212
|
+
console.log("Not-implemented: hideInstance");
|
|
213
|
+
},
|
|
214
|
+
hideTextInstance: () => {
|
|
215
|
+
console.log("Not-implemented: hideTextInstance");
|
|
216
|
+
},
|
|
217
|
+
unhideInstance: () => {
|
|
218
|
+
console.log("Not-implemented: unhideInstance");
|
|
219
|
+
},
|
|
220
|
+
unhideTextInstance: () => {
|
|
221
|
+
console.log("Not-implemented: unhideTextInstance");
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var reconciler = Reconciler(hostConfig);
|
|
225
|
+
var ToolkitRenderer = {
|
|
226
|
+
renderGroup: (component, container) => {
|
|
227
|
+
const root = reconciler.createContainer(container, 0, false, null);
|
|
228
|
+
const componentWithContexts = /* @__PURE__ */ jsx(LoggerContext.Provider, { value: container.log, children: component });
|
|
229
|
+
reconciler.updateContainer(componentWithContexts, root, null);
|
|
230
|
+
},
|
|
231
|
+
render: (component, container, rootGroupProps) => {
|
|
232
|
+
const group = new ld.Group({ direction: "vertical", ...rootGroupProps });
|
|
233
|
+
container.setRoot(group);
|
|
234
|
+
ToolkitRenderer.renderGroup(component, group);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
export {
|
|
238
|
+
Button,
|
|
239
|
+
Group,
|
|
240
|
+
GroupHeader,
|
|
241
|
+
Label,
|
|
242
|
+
Rect,
|
|
243
|
+
SliderButton,
|
|
244
|
+
Switch,
|
|
245
|
+
Tab,
|
|
246
|
+
Tabs,
|
|
247
|
+
TextInput,
|
|
248
|
+
Timeline,
|
|
249
|
+
ToolkitRenderer
|
|
250
|
+
};
|
package/dist/logging.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { Logger } from '@arcanejs/protocol/logging';
|
|
3
3
|
|
|
4
|
-
declare const LoggerContext:
|
|
4
|
+
declare const LoggerContext: React.Context<() => Logger | null>;
|
|
5
5
|
declare const useLogger: () => Logger | null;
|
|
6
6
|
|
|
7
7
|
export { LoggerContext, useLogger };
|
package/dist/logging.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { Logger } from '@arcanejs/protocol/logging';
|
|
3
3
|
|
|
4
|
-
declare const LoggerContext:
|
|
4
|
+
declare const LoggerContext: React.Context<() => Logger | null>;
|
|
5
5
|
declare const useLogger: () => Logger | null;
|
|
6
6
|
|
|
7
7
|
export { LoggerContext, useLogger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcanejs/react-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"import": "./dist/logging.mjs",
|
|
37
37
|
"require": "./dist/logging.js",
|
|
38
38
|
"types": "./dist/logging.d.ts"
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@types/eslint": "^8.56.5",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"@types/node": "^20.11.24",
|
|
45
46
|
"@types/react": "^18",
|
|
46
47
|
"@types/react-reconciler": "^0.28.8",
|
|
48
|
+
"check-export-map": "^1.3.1",
|
|
47
49
|
"eslint": "^8.57.0",
|
|
48
50
|
"tsup": "^8.1.0",
|
|
49
51
|
"typescript": "^5.3.3",
|
|
@@ -56,7 +58,7 @@
|
|
|
56
58
|
"react": "^18",
|
|
57
59
|
"react-reconciler": "0.28.0",
|
|
58
60
|
"@arcanejs/protocol": "^0.2.0",
|
|
59
|
-
"@arcanejs/toolkit": "^0.
|
|
61
|
+
"@arcanejs/toolkit": "^0.4.0"
|
|
60
62
|
},
|
|
61
63
|
"peerDependencies": {
|
|
62
64
|
"zod": "^3.23.8"
|
|
@@ -74,7 +76,7 @@
|
|
|
74
76
|
},
|
|
75
77
|
"scripts": {
|
|
76
78
|
"lint": "eslint . --max-warnings 0",
|
|
77
|
-
"build": "tsup",
|
|
79
|
+
"build": "rm -rf dist && tsup && check-export-map",
|
|
78
80
|
"dev": "tsup --watch"
|
|
79
81
|
}
|
|
80
82
|
}
|