@arcanewizards/timecode-toolbox 0.1.0 → 0.1.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/LICENSE +21 -0
- package/dist/components/frontend/index.js +865 -272
- package/dist/components/frontend/index.mjs +855 -262
- package/dist/entrypoint.css +163 -53
- package/dist/entrypoint.js +1474 -493
- package/dist/entrypoint.js.map +4 -4
- package/dist/frontend.js +1474 -493
- package/dist/frontend.js.map +4 -4
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +308 -37
- package/dist/index.mjs +329 -49
- package/dist/start.d.mts +1 -2
- package/dist/start.d.ts +1 -2
- package/dist/start.js +311 -38
- package/dist/start.mjs +332 -50
- package/package.json +12 -6
- package/.turbo/turbo-build.log +0 -58
- package/.turbo/turbo-lint.log +0 -4
- package/CHANGELOG.md +0 -40
- package/eslint.config.mjs +0 -49
- package/src/app.tsx +0 -147
- package/src/components/backend/index.ts +0 -6
- package/src/components/backend/toolbox-root.ts +0 -119
- package/src/components/frontend/constants.ts +0 -81
- package/src/components/frontend/entrypoint.ts +0 -12
- package/src/components/frontend/frontend.css +0 -108
- package/src/components/frontend/index.tsx +0 -46
- package/src/components/frontend/toolbox/content.tsx +0 -45
- package/src/components/frontend/toolbox/context.tsx +0 -63
- package/src/components/frontend/toolbox/core/size-aware-div.tsx +0 -51
- package/src/components/frontend/toolbox/core/timecode-display.tsx +0 -592
- package/src/components/frontend/toolbox/generators.tsx +0 -318
- package/src/components/frontend/toolbox/inputs.tsx +0 -484
- package/src/components/frontend/toolbox/outputs.tsx +0 -581
- package/src/components/frontend/toolbox/preferences.ts +0 -25
- package/src/components/frontend/toolbox/root.tsx +0 -335
- package/src/components/frontend/toolbox/settings.tsx +0 -54
- package/src/components/frontend/toolbox/types.ts +0 -28
- package/src/components/frontend/toolbox/util.tsx +0 -61
- package/src/components/proto.ts +0 -420
- package/src/config.ts +0 -7
- package/src/generators/clock.tsx +0 -206
- package/src/generators/index.tsx +0 -15
- package/src/index.ts +0 -38
- package/src/inputs/artnet.tsx +0 -305
- package/src/inputs/index.tsx +0 -13
- package/src/inputs/tcnet.tsx +0 -272
- package/src/outputs/artnet.tsx +0 -170
- package/src/outputs/index.tsx +0 -11
- package/src/start.ts +0 -47
- package/src/tree.ts +0 -133
- package/src/types.ts +0 -12
- package/src/urls.ts +0 -49
- package/src/util.ts +0 -82
- package/tailwind.config.cjs +0 -7
- package/tsconfig.json +0 -10
- package/tsup.config.ts +0 -10
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { FC, useCallback, useContext, useState } from 'react';
|
|
2
|
-
import { STRINGS } from '../constants';
|
|
3
|
-
import { PrimaryToolboxSection } from './util';
|
|
4
|
-
import { NoToolboxChildren } from './content';
|
|
5
|
-
import { ConfigContext, useApplicationState } from './context';
|
|
6
|
-
import { AssignToOutputCallback, DialogMode, SettingsProps } from './types';
|
|
7
|
-
import {
|
|
8
|
-
ControlButton,
|
|
9
|
-
ControlColorSelect,
|
|
10
|
-
ControlDialog,
|
|
11
|
-
ControlDialogButtons,
|
|
12
|
-
ControlInput,
|
|
13
|
-
ControlLabel,
|
|
14
|
-
} from '@arcanewizards/sigil/frontend/controls';
|
|
15
|
-
import { GeneratorConfig, GeneratorDefinition } from '../../proto';
|
|
16
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
17
|
-
import {
|
|
18
|
-
ChangeCommitContext,
|
|
19
|
-
useChangeCommitBoundary,
|
|
20
|
-
} from '@arcanewizards/sigil/frontend/context';
|
|
21
|
-
import { TimecodeTreeDisplay } from './core/timecode-display';
|
|
22
|
-
|
|
23
|
-
const ClockSpecificSettings: FC<SettingsProps<GeneratorDefinition>> = ({
|
|
24
|
-
data,
|
|
25
|
-
updateSettings,
|
|
26
|
-
}) => {
|
|
27
|
-
const { commitChanges } = useContext(ChangeCommitContext);
|
|
28
|
-
|
|
29
|
-
if (data.type !== 'clock') {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<>
|
|
35
|
-
<ControlLabel>Speed</ControlLabel>
|
|
36
|
-
<ControlInput
|
|
37
|
-
position="both"
|
|
38
|
-
type="string"
|
|
39
|
-
value={data.speed?.toString() ?? ''}
|
|
40
|
-
placeholder={`Default (1)`}
|
|
41
|
-
onChange={(value, enterPressed) => {
|
|
42
|
-
const speed = value ? parseFloat(value) : 1;
|
|
43
|
-
if (speed !== undefined && isNaN(speed)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
updateSettings((current) => ({
|
|
47
|
-
...current,
|
|
48
|
-
speed,
|
|
49
|
-
}));
|
|
50
|
-
if (enterPressed) {
|
|
51
|
-
commitChanges();
|
|
52
|
-
}
|
|
53
|
-
}}
|
|
54
|
-
/>
|
|
55
|
-
</>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
type GeneratorSettingsDialogProps = {
|
|
60
|
-
target: DialogMode['target'];
|
|
61
|
-
generator: GeneratorDefinition['type'];
|
|
62
|
-
close: () => void;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const GeneratorSettingsDialog: FC<GeneratorSettingsDialogProps> = ({
|
|
66
|
-
target,
|
|
67
|
-
generator,
|
|
68
|
-
close,
|
|
69
|
-
}) => {
|
|
70
|
-
const { config, updateConfig } = useContext(ConfigContext);
|
|
71
|
-
const [newData, setNewData] = useState<GeneratorConfig>({
|
|
72
|
-
name: '',
|
|
73
|
-
definition: {
|
|
74
|
-
type: generator,
|
|
75
|
-
speed: 1,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const updateSettings: SettingsProps<GeneratorConfig>['updateSettings'] =
|
|
80
|
-
useCallback(
|
|
81
|
-
(change) => {
|
|
82
|
-
if (target.type === 'add') {
|
|
83
|
-
setNewData(change);
|
|
84
|
-
} else {
|
|
85
|
-
updateConfig((current) => {
|
|
86
|
-
const existing = current.generators?.[target.uuid];
|
|
87
|
-
if (!existing) {
|
|
88
|
-
return current;
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
...current,
|
|
92
|
-
generators: {
|
|
93
|
-
...current.generators,
|
|
94
|
-
[target.uuid]: change(existing),
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
[target, updateConfig],
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
const updateDefinition = useCallback(
|
|
104
|
-
(change: (current: GeneratorDefinition) => GeneratorDefinition) => {
|
|
105
|
-
updateSettings((current) => ({
|
|
106
|
-
...current,
|
|
107
|
-
definition: change(current.definition),
|
|
108
|
-
}));
|
|
109
|
-
},
|
|
110
|
-
[updateSettings],
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const addGenerator = useCallback(() => {
|
|
114
|
-
updateConfig((current) => {
|
|
115
|
-
return {
|
|
116
|
-
...current,
|
|
117
|
-
generators: {
|
|
118
|
-
...current.generators,
|
|
119
|
-
[uuidv4()]: newData,
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
close();
|
|
124
|
-
}, [newData, close, updateConfig]);
|
|
125
|
-
|
|
126
|
-
const resolvedTarget =
|
|
127
|
-
target.type === 'add' ? 'add' : config.generators?.[target.uuid];
|
|
128
|
-
|
|
129
|
-
const data = resolvedTarget === 'add' ? newData : resolvedTarget;
|
|
130
|
-
|
|
131
|
-
const commitChanges = useCallback(() => {
|
|
132
|
-
if (target.type === 'add') {
|
|
133
|
-
addGenerator();
|
|
134
|
-
} else {
|
|
135
|
-
close();
|
|
136
|
-
}
|
|
137
|
-
}, [target, addGenerator, close]);
|
|
138
|
-
|
|
139
|
-
const commitBoundary = useChangeCommitBoundary(data, commitChanges);
|
|
140
|
-
|
|
141
|
-
if (!data) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<ChangeCommitContext.Provider value={commitBoundary}>
|
|
147
|
-
<ControlDialog
|
|
148
|
-
dialogClosed={close}
|
|
149
|
-
title={
|
|
150
|
-
target.type === 'add'
|
|
151
|
-
? STRINGS.generators.addDialog(STRINGS.generators.type[generator])
|
|
152
|
-
: STRINGS.generators.editDialog(
|
|
153
|
-
STRINGS.generators.type[generator],
|
|
154
|
-
data.name || '',
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
>
|
|
158
|
-
<ControlLabel>Name</ControlLabel>
|
|
159
|
-
<ControlInput
|
|
160
|
-
position="both"
|
|
161
|
-
type="string"
|
|
162
|
-
value={data.name ?? ''}
|
|
163
|
-
placeholder={`No name specified`}
|
|
164
|
-
onChange={(name, enterPressed) => {
|
|
165
|
-
if (enterPressed) {
|
|
166
|
-
commitBoundary.commitChanges();
|
|
167
|
-
}
|
|
168
|
-
updateSettings((current) => ({
|
|
169
|
-
...current,
|
|
170
|
-
name,
|
|
171
|
-
}));
|
|
172
|
-
}}
|
|
173
|
-
/>
|
|
174
|
-
<ControlLabel>Color</ControlLabel>
|
|
175
|
-
<ControlColorSelect
|
|
176
|
-
position="both"
|
|
177
|
-
color={data.color ?? ''}
|
|
178
|
-
variant="standard"
|
|
179
|
-
placeholder="Default"
|
|
180
|
-
onChange={(color) => {
|
|
181
|
-
updateSettings((current) => ({
|
|
182
|
-
...current,
|
|
183
|
-
color,
|
|
184
|
-
}));
|
|
185
|
-
}}
|
|
186
|
-
/>
|
|
187
|
-
{data.definition.type === 'clock' ? (
|
|
188
|
-
<ClockSpecificSettings
|
|
189
|
-
data={data.definition}
|
|
190
|
-
updateSettings={updateDefinition}
|
|
191
|
-
/>
|
|
192
|
-
) : null}
|
|
193
|
-
{resolvedTarget === 'add' ? (
|
|
194
|
-
<ControlDialogButtons>
|
|
195
|
-
<ControlButton onClick={close} variant="large">
|
|
196
|
-
Cancel
|
|
197
|
-
</ControlButton>
|
|
198
|
-
<ControlButton onClick={addGenerator} variant="large">
|
|
199
|
-
Add Generator
|
|
200
|
-
</ControlButton>
|
|
201
|
-
</ControlDialogButtons>
|
|
202
|
-
) : (
|
|
203
|
-
<ControlDialogButtons>
|
|
204
|
-
<ControlButton onClick={close} variant="large">
|
|
205
|
-
Close
|
|
206
|
-
</ControlButton>
|
|
207
|
-
</ControlDialogButtons>
|
|
208
|
-
)}
|
|
209
|
-
</ControlDialog>
|
|
210
|
-
</ChangeCommitContext.Provider>
|
|
211
|
-
);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
type GeneratorDisplayProps = {
|
|
215
|
-
uuid: string;
|
|
216
|
-
config: GeneratorConfig;
|
|
217
|
-
setDialogMode: (mode: DialogMode | null) => void;
|
|
218
|
-
assignToOutput: AssignToOutputCallback;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const GeneratorDisplay: FC<GeneratorDisplayProps> = ({
|
|
222
|
-
uuid,
|
|
223
|
-
config,
|
|
224
|
-
setDialogMode,
|
|
225
|
-
assignToOutput,
|
|
226
|
-
}) => {
|
|
227
|
-
const { generators } = useApplicationState();
|
|
228
|
-
const state = generators[uuid];
|
|
229
|
-
|
|
230
|
-
return (
|
|
231
|
-
<TimecodeTreeDisplay
|
|
232
|
-
id={['generator', uuid]}
|
|
233
|
-
config={{ delayMs: config.delayMs ?? null }}
|
|
234
|
-
type={STRINGS.generators.type[config.definition.type]}
|
|
235
|
-
name={config.name ? [config.name] : []}
|
|
236
|
-
color={config.color}
|
|
237
|
-
timecode={state?.timecode ?? null}
|
|
238
|
-
namePlaceholder={`Unnamed Generator`}
|
|
239
|
-
buttons={
|
|
240
|
-
<>
|
|
241
|
-
<ControlButton
|
|
242
|
-
variant="large"
|
|
243
|
-
title="Edit Generator"
|
|
244
|
-
onClick={() =>
|
|
245
|
-
setDialogMode({
|
|
246
|
-
section: {
|
|
247
|
-
type: 'generators',
|
|
248
|
-
generator: config.definition.type,
|
|
249
|
-
},
|
|
250
|
-
target: { type: 'edit', uuid },
|
|
251
|
-
})
|
|
252
|
-
}
|
|
253
|
-
icon="edit"
|
|
254
|
-
/>
|
|
255
|
-
</>
|
|
256
|
-
}
|
|
257
|
-
assignToOutput={assignToOutput}
|
|
258
|
-
/>
|
|
259
|
-
);
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
export type GeneratorsSectionProps = {
|
|
263
|
-
setDialogMode: (mode: DialogMode | null) => void;
|
|
264
|
-
assignToOutput: AssignToOutputCallback;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
export const GeneratorsSection: FC<GeneratorsSectionProps> = ({
|
|
268
|
-
setDialogMode,
|
|
269
|
-
assignToOutput,
|
|
270
|
-
}) => {
|
|
271
|
-
const { config } = useContext(ConfigContext);
|
|
272
|
-
return (
|
|
273
|
-
<PrimaryToolboxSection
|
|
274
|
-
title={STRINGS.generators.title}
|
|
275
|
-
buttons={
|
|
276
|
-
<>
|
|
277
|
-
{(['clock'] as const).map((generator) => (
|
|
278
|
-
<ControlButton
|
|
279
|
-
key={generator}
|
|
280
|
-
onClick={() =>
|
|
281
|
-
setDialogMode({
|
|
282
|
-
section: { type: 'generators', generator },
|
|
283
|
-
target: { type: 'add' },
|
|
284
|
-
})
|
|
285
|
-
}
|
|
286
|
-
variant="toolbar"
|
|
287
|
-
icon="add"
|
|
288
|
-
>
|
|
289
|
-
{STRINGS.outputs.addButton(STRINGS.generators.type[generator])}
|
|
290
|
-
</ControlButton>
|
|
291
|
-
))}
|
|
292
|
-
</>
|
|
293
|
-
}
|
|
294
|
-
>
|
|
295
|
-
{Object.entries(config.generators ?? {}).length === 0 ? (
|
|
296
|
-
<NoToolboxChildren text={STRINGS.generators.noChildren} />
|
|
297
|
-
) : (
|
|
298
|
-
<div
|
|
299
|
-
className="
|
|
300
|
-
grid grow grid-cols-1 gap-px
|
|
301
|
-
min-[600px]:grid-cols-2
|
|
302
|
-
min-[900px]:grid-cols-3
|
|
303
|
-
"
|
|
304
|
-
>
|
|
305
|
-
{Object.entries(config.generators).map(([uuid, generator]) => (
|
|
306
|
-
<GeneratorDisplay
|
|
307
|
-
key={uuid}
|
|
308
|
-
uuid={uuid}
|
|
309
|
-
config={generator}
|
|
310
|
-
setDialogMode={setDialogMode}
|
|
311
|
-
assignToOutput={assignToOutput}
|
|
312
|
-
/>
|
|
313
|
-
))}
|
|
314
|
-
</div>
|
|
315
|
-
)}
|
|
316
|
-
</PrimaryToolboxSection>
|
|
317
|
-
);
|
|
318
|
-
};
|