@arcanejs/toolkit 4.0.0 → 5.0.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.
Files changed (71) hide show
  1. package/dist/backend/components/base.d.mts +1 -1
  2. package/dist/backend/components/base.d.ts +1 -1
  3. package/dist/backend/components/base.js +2 -2
  4. package/dist/backend/components/base.mjs +1 -1
  5. package/dist/backend/components/button.d.mts +1 -1
  6. package/dist/backend/components/button.d.ts +1 -1
  7. package/dist/backend/components/button.js +3 -3
  8. package/dist/backend/components/button.mjs +2 -2
  9. package/dist/backend/components/group.d.mts +1 -1
  10. package/dist/backend/components/group.d.ts +1 -1
  11. package/dist/backend/components/group.js +3 -3
  12. package/dist/backend/components/group.mjs +2 -2
  13. package/dist/backend/components/label.d.mts +1 -1
  14. package/dist/backend/components/label.d.ts +1 -1
  15. package/dist/backend/components/label.js +3 -3
  16. package/dist/backend/components/label.mjs +2 -2
  17. package/dist/backend/components/rect.d.mts +1 -1
  18. package/dist/backend/components/rect.d.ts +1 -1
  19. package/dist/backend/components/rect.js +3 -3
  20. package/dist/backend/components/rect.mjs +2 -2
  21. package/dist/backend/components/slider-button.d.mts +1 -1
  22. package/dist/backend/components/slider-button.d.ts +1 -1
  23. package/dist/backend/components/slider-button.js +3 -3
  24. package/dist/backend/components/slider-button.mjs +2 -2
  25. package/dist/backend/components/switch.d.mts +1 -1
  26. package/dist/backend/components/switch.d.ts +1 -1
  27. package/dist/backend/components/switch.js +3 -3
  28. package/dist/backend/components/switch.mjs +2 -2
  29. package/dist/backend/components/tabs.d.mts +1 -1
  30. package/dist/backend/components/tabs.d.ts +1 -1
  31. package/dist/backend/components/tabs.js +3 -3
  32. package/dist/backend/components/tabs.mjs +2 -2
  33. package/dist/backend/components/text-input.d.mts +1 -1
  34. package/dist/backend/components/text-input.d.ts +1 -1
  35. package/dist/backend/components/text-input.js +3 -3
  36. package/dist/backend/components/text-input.mjs +2 -2
  37. package/dist/backend/components/timeline.d.mts +1 -1
  38. package/dist/backend/components/timeline.d.ts +1 -1
  39. package/dist/backend/components/timeline.js +3 -3
  40. package/dist/backend/components/timeline.mjs +2 -2
  41. package/dist/{chunk-Z3HEU534.js → chunk-3GTEUTFT.js} +2 -2
  42. package/dist/{chunk-YN7LHBRI.mjs → chunk-3TXBS2UN.mjs} +1 -1
  43. package/dist/{chunk-ZWYJEKZP.js → chunk-4OCRZD4F.js} +3 -3
  44. package/dist/{chunk-3VAHVFJ3.js → chunk-53EOA4UE.js} +3 -3
  45. package/dist/{chunk-XMP5XJWR.mjs → chunk-6ELB27LK.mjs} +1 -1
  46. package/dist/{chunk-VXNNW2KH.js → chunk-6QWYIJLM.js} +2 -2
  47. package/dist/{chunk-QT43ONN5.js → chunk-7JIC2XBC.js} +4 -4
  48. package/dist/{chunk-PIVARHCZ.mjs → chunk-E6FGU7DA.mjs} +1 -1
  49. package/dist/{chunk-JKTEVA75.mjs → chunk-GONHNB6V.mjs} +14 -0
  50. package/dist/{chunk-4EOCJT6W.js → chunk-HTCWMJUA.js} +3 -3
  51. package/dist/{chunk-MMK3PCSS.mjs → chunk-KMEDXCBI.mjs} +1 -1
  52. package/dist/{chunk-6BVEU2NV.mjs → chunk-LK6MGXYC.mjs} +1 -1
  53. package/dist/{chunk-6KPK5YOL.js → chunk-NL3W4M7J.js} +3 -3
  54. package/dist/{chunk-GIXAFIEY.mjs → chunk-PG5EAV5X.mjs} +1 -1
  55. package/dist/{chunk-JSZMJCCH.js → chunk-QAH2OSHR.js} +2 -2
  56. package/dist/{chunk-PYJC5BFZ.mjs → chunk-QB2WPBWV.mjs} +1 -1
  57. package/dist/{chunk-LGIWNJQA.js → chunk-U6FSQBQ3.js} +3 -3
  58. package/dist/{chunk-XYFDH3E7.mjs → chunk-UQWCTVMC.mjs} +1 -1
  59. package/dist/{chunk-VJ3Q2HZJ.mjs → chunk-WDB3IMOP.mjs} +1 -1
  60. package/dist/{chunk-HTM2L3DT.js → chunk-WN3GXVUE.js} +16 -2
  61. package/dist/frontend/entrypoint.js +54 -4
  62. package/dist/frontend/entrypoint.js.map +4 -4
  63. package/dist/frontend/index.js +51 -1
  64. package/dist/frontend/index.mjs +51 -1
  65. package/dist/index.d.mts +1 -1
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.js +12 -12
  68. package/dist/index.mjs +10 -10
  69. package/dist/{toolkit-BjYBFkG8.d.ts → toolkit-C37sQAkD.d.ts} +6 -1
  70. package/dist/{toolkit-k-CCIw3V.d.mts → toolkit-CQMnQMOF.d.mts} +6 -1
  71. package/package.json +3 -3
@@ -34,7 +34,57 @@ var _toolkitfrontend = require('@arcanejs/toolkit-frontend');
34
34
 
35
35
 
36
36
  // ../toolkit-frontend/src/util/index.ts
37
+ var COLOR_SCHEME_SETTINGS = "arcane-color-scheme-preference";
38
+ var VALID_COLOR_SCHEME_PREFS = ["auto", "dark", "light"];
39
+ var isValidColorSchemePreference = (value) => {
40
+ return VALID_COLOR_SCHEME_PREFS.includes(value);
41
+ };
42
+ var useColorSchemePreferences = () => {
43
+ if (typeof window === "undefined") {
44
+ return {
45
+ colorSchemePreference: "auto",
46
+ setColorSchemePreference: () => {
47
+ }
48
+ };
49
+ }
50
+ const [preference, setPreference] = _react.useState.call(void 0,
51
+ window.localStorage.getItem(
52
+ COLOR_SCHEME_SETTINGS
53
+ ) || "auto"
54
+ );
55
+ const setColorSchemePreference = (newPreference) => {
56
+ if (!isValidColorSchemePreference(newPreference)) {
57
+ throw new Error(`Invalid color scheme preference: ${newPreference}`);
58
+ }
59
+ window.localStorage.setItem(COLOR_SCHEME_SETTINGS, newPreference);
60
+ window.dispatchEvent(
61
+ new StorageEvent("storage", {
62
+ key: COLOR_SCHEME_SETTINGS,
63
+ newValue: newPreference
64
+ })
65
+ );
66
+ };
67
+ _react.useEffect.call(void 0, () => {
68
+ const onStorageChange = (event) => {
69
+ if (event.key === COLOR_SCHEME_SETTINGS) {
70
+ const newValue = event.newValue;
71
+ if (isValidColorSchemePreference(newValue)) {
72
+ setPreference(newValue);
73
+ }
74
+ }
75
+ };
76
+ window.addEventListener("storage", onStorageChange);
77
+ return () => {
78
+ window.removeEventListener("storage", onStorageChange);
79
+ };
80
+ }, []);
81
+ return {
82
+ colorSchemePreference: isValidColorSchemePreference(preference) ? preference : "auto",
83
+ setColorSchemePreference
84
+ };
85
+ };
37
86
  var usePreferredColorScheme = () => {
87
+ const { colorSchemePreference } = useColorSchemePreferences();
38
88
  const [theme, setTheme] = _react.useState.call(void 0, "light");
39
89
  _react.useEffect.call(void 0, () => {
40
90
  if (typeof window !== "undefined") {
@@ -49,7 +99,7 @@ var usePreferredColorScheme = () => {
49
99
  };
50
100
  }
51
101
  }, []);
52
- return theme;
102
+ return colorSchemePreference === "auto" ? theme : colorSchemePreference;
53
103
  };
54
104
 
55
105
  // ../toolkit-frontend/src/styling.tsx
@@ -34,7 +34,57 @@ import { useEffect, useState as useState2 } from "react";
34
34
  import { useState } from "react";
35
35
 
36
36
  // ../toolkit-frontend/src/util/index.ts
37
+ var COLOR_SCHEME_SETTINGS = "arcane-color-scheme-preference";
38
+ var VALID_COLOR_SCHEME_PREFS = ["auto", "dark", "light"];
39
+ var isValidColorSchemePreference = (value) => {
40
+ return VALID_COLOR_SCHEME_PREFS.includes(value);
41
+ };
42
+ var useColorSchemePreferences = () => {
43
+ if (typeof window === "undefined") {
44
+ return {
45
+ colorSchemePreference: "auto",
46
+ setColorSchemePreference: () => {
47
+ }
48
+ };
49
+ }
50
+ const [preference, setPreference] = useState2(
51
+ window.localStorage.getItem(
52
+ COLOR_SCHEME_SETTINGS
53
+ ) || "auto"
54
+ );
55
+ const setColorSchemePreference = (newPreference) => {
56
+ if (!isValidColorSchemePreference(newPreference)) {
57
+ throw new Error(`Invalid color scheme preference: ${newPreference}`);
58
+ }
59
+ window.localStorage.setItem(COLOR_SCHEME_SETTINGS, newPreference);
60
+ window.dispatchEvent(
61
+ new StorageEvent("storage", {
62
+ key: COLOR_SCHEME_SETTINGS,
63
+ newValue: newPreference
64
+ })
65
+ );
66
+ };
67
+ useEffect(() => {
68
+ const onStorageChange = (event) => {
69
+ if (event.key === COLOR_SCHEME_SETTINGS) {
70
+ const newValue = event.newValue;
71
+ if (isValidColorSchemePreference(newValue)) {
72
+ setPreference(newValue);
73
+ }
74
+ }
75
+ };
76
+ window.addEventListener("storage", onStorageChange);
77
+ return () => {
78
+ window.removeEventListener("storage", onStorageChange);
79
+ };
80
+ }, []);
81
+ return {
82
+ colorSchemePreference: isValidColorSchemePreference(preference) ? preference : "auto",
83
+ setColorSchemePreference
84
+ };
85
+ };
37
86
  var usePreferredColorScheme = () => {
87
+ const { colorSchemePreference } = useColorSchemePreferences();
38
88
  const [theme, setTheme] = useState2("light");
39
89
  useEffect(() => {
40
90
  if (typeof window !== "undefined") {
@@ -49,7 +99,7 @@ var usePreferredColorScheme = () => {
49
99
  };
50
100
  }
51
101
  }, []);
52
- return theme;
102
+ return colorSchemePreference === "auto" ? theme : colorSchemePreference;
53
103
  };
54
104
 
55
105
  // ../toolkit-frontend/src/styling.tsx
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-k-CCIw3V.mjs';
1
+ export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-CQMnQMOF.mjs';
2
2
  export { Label } from './backend/components/label.mjs';
3
3
  export { Rect } from './backend/components/rect.mjs';
4
4
  export { SliderButton } from './backend/components/slider-button.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-BjYBFkG8.js';
1
+ export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-C37sQAkD.js';
2
2
  export { Label } from './backend/components/label.js';
3
3
  export { Rect } from './backend/components/rect.js';
4
4
  export { SliderButton } from './backend/components/slider-button.js';
package/dist/index.js CHANGED
@@ -1,38 +1,38 @@
1
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 }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
2
2
 
3
3
 
4
- var _chunkLGIWNJQAjs = require('./chunk-LGIWNJQA.js');
4
+ var _chunkU6FSQBQ3js = require('./chunk-U6FSQBQ3.js');
5
5
 
6
6
 
7
- var _chunk4EOCJT6Wjs = require('./chunk-4EOCJT6W.js');
7
+ var _chunkHTCWMJUAjs = require('./chunk-HTCWMJUA.js');
8
8
 
9
9
 
10
- var _chunkVXNNW2KHjs = require('./chunk-VXNNW2KH.js');
10
+ var _chunk6QWYIJLMjs = require('./chunk-6QWYIJLM.js');
11
11
 
12
12
 
13
13
  var _chunkEABM5X65js = require('./chunk-EABM5X65.js');
14
14
 
15
15
 
16
- var _chunkZWYJEKZPjs = require('./chunk-ZWYJEKZP.js');
16
+ var _chunk4OCRZD4Fjs = require('./chunk-4OCRZD4F.js');
17
17
 
18
18
 
19
19
 
20
- var _chunkQT43ONN5js = require('./chunk-QT43ONN5.js');
20
+ var _chunk7JIC2XBCjs = require('./chunk-7JIC2XBC.js');
21
21
 
22
22
 
23
- var _chunkZ3HEU534js = require('./chunk-Z3HEU534.js');
23
+ var _chunk3GTEUTFTjs = require('./chunk-3GTEUTFT.js');
24
24
 
25
25
 
26
- var _chunkJSZMJCCHjs = require('./chunk-JSZMJCCH.js');
26
+ var _chunkQAH2OSHRjs = require('./chunk-QAH2OSHR.js');
27
27
 
28
28
 
29
- var _chunk6KPK5YOLjs = require('./chunk-6KPK5YOL.js');
29
+ var _chunkNL3W4M7Jjs = require('./chunk-NL3W4M7J.js');
30
30
 
31
31
 
32
- var _chunk3VAHVFJ3js = require('./chunk-3VAHVFJ3.js');
32
+ var _chunk53EOA4UEjs = require('./chunk-53EOA4UE.js');
33
33
 
34
34
 
35
- var _chunkHTM2L3DTjs = require('./chunk-HTM2L3DT.js');
35
+ var _chunkWN3GXVUEjs = require('./chunk-WN3GXVUE.js');
36
36
 
37
37
 
38
38
  var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
@@ -189,7 +189,7 @@ var Toolkit = (_class2 = class {
189
189
  __init5() {this.connections = /* @__PURE__ */ new Map()}
190
190
  __init6() {this.rootGroup = null}
191
191
  /** @hidden */
192
- __init7() {this.events = new (0, _chunkHTM2L3DTjs.EventEmitter)()}
192
+ __init7() {this.events = new (0, _chunkWN3GXVUEjs.EventEmitter)()}
193
193
  constructor(options = {}) {;_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);_class2.prototype.__init17.call(this);_class2.prototype.__init18.call(this);
194
194
  this.options = {
195
195
  ...DEFAULT_LIGHT_DESK_OPTIONS,
@@ -369,4 +369,4 @@ var Toolkit = (_class2 = class {
369
369
 
370
370
 
371
371
 
372
- exports.Button = _chunkZWYJEKZPjs.Button; exports.Group = _chunkQT43ONN5js.Group; exports.GroupHeader = _chunkQT43ONN5js.GroupHeader; exports.Label = _chunkZ3HEU534js.Label; exports.Rect = _chunkJSZMJCCHjs.Rect; exports.SliderButton = _chunk6KPK5YOLjs.SliderButton; exports.Switch = _chunk3VAHVFJ3js.Switch; exports.Tab = _chunkLGIWNJQAjs.Tab; exports.Tabs = _chunkLGIWNJQAjs.Tabs; exports.TextInput = _chunk4EOCJT6Wjs.TextInput; exports.Timeline = _chunkVXNNW2KHjs.Timeline; exports.Toolkit = Toolkit;
372
+ exports.Button = _chunk4OCRZD4Fjs.Button; exports.Group = _chunk7JIC2XBCjs.Group; exports.GroupHeader = _chunk7JIC2XBCjs.GroupHeader; exports.Label = _chunk3GTEUTFTjs.Label; exports.Rect = _chunkQAH2OSHRjs.Rect; exports.SliderButton = _chunkNL3W4M7Jjs.SliderButton; exports.Switch = _chunk53EOA4UEjs.Switch; exports.Tab = _chunkU6FSQBQ3js.Tab; exports.Tabs = _chunkU6FSQBQ3js.Tabs; exports.TextInput = _chunkHTCWMJUAjs.TextInput; exports.Timeline = _chunk6QWYIJLMjs.Timeline; exports.Toolkit = Toolkit;
package/dist/index.mjs CHANGED
@@ -1,38 +1,38 @@
1
1
  import {
2
2
  Tab,
3
3
  Tabs
4
- } from "./chunk-MMK3PCSS.mjs";
4
+ } from "./chunk-KMEDXCBI.mjs";
5
5
  import {
6
6
  TextInput
7
- } from "./chunk-VJ3Q2HZJ.mjs";
7
+ } from "./chunk-WDB3IMOP.mjs";
8
8
  import {
9
9
  Timeline
10
- } from "./chunk-YN7LHBRI.mjs";
10
+ } from "./chunk-3TXBS2UN.mjs";
11
11
  import {
12
12
  IDMap
13
13
  } from "./chunk-RGHJEMWG.mjs";
14
14
  import {
15
15
  Button
16
- } from "./chunk-6BVEU2NV.mjs";
16
+ } from "./chunk-LK6MGXYC.mjs";
17
17
  import {
18
18
  Group,
19
19
  GroupHeader
20
- } from "./chunk-PIVARHCZ.mjs";
20
+ } from "./chunk-E6FGU7DA.mjs";
21
21
  import {
22
22
  Label
23
- } from "./chunk-XYFDH3E7.mjs";
23
+ } from "./chunk-UQWCTVMC.mjs";
24
24
  import {
25
25
  Rect
26
- } from "./chunk-XMP5XJWR.mjs";
26
+ } from "./chunk-6ELB27LK.mjs";
27
27
  import {
28
28
  SliderButton
29
- } from "./chunk-PYJC5BFZ.mjs";
29
+ } from "./chunk-QB2WPBWV.mjs";
30
30
  import {
31
31
  Switch
32
- } from "./chunk-GIXAFIEY.mjs";
32
+ } from "./chunk-PG5EAV5X.mjs";
33
33
  import {
34
34
  EventEmitter
35
- } from "./chunk-JKTEVA75.mjs";
35
+ } from "./chunk-GONHNB6V.mjs";
36
36
  import {
37
37
  __require
38
38
  } from "./chunk-Y6FXYEAI.mjs";
@@ -165,7 +165,12 @@ declare class EventEmitter<Map extends Record<string, (...args: any[]) => void>>
165
165
  private readonly listeners;
166
166
  addListener: <T extends keyof Map>(type: T, listener: Map[T]) => void;
167
167
  removeListener: <T extends keyof Map>(type: T, listener: Map[T]) => void;
168
- emit: <T extends keyof Map>(type: T, ...args: Parameters<Map[T]>) => Promise<unknown>;
168
+ emit: <T extends keyof Map>(type: T, ...args: Parameters<Map[T]>) => Promise<ReturnType<Map[T]>[]>;
169
+ /**
170
+ * Like {@link emit},
171
+ * but ensures only a single listener exists and returns its result.
172
+ */
173
+ call: <T extends keyof Map>(type: T, ...args: Parameters<Map[T]>) => Promise<ReturnType<Map[T]>>;
169
174
  /**
170
175
  * Process prop changes to update listeners
171
176
  */
@@ -165,7 +165,12 @@ declare class EventEmitter<Map extends Record<string, (...args: any[]) => void>>
165
165
  private readonly listeners;
166
166
  addListener: <T extends keyof Map>(type: T, listener: Map[T]) => void;
167
167
  removeListener: <T extends keyof Map>(type: T, listener: Map[T]) => void;
168
- emit: <T extends keyof Map>(type: T, ...args: Parameters<Map[T]>) => Promise<unknown>;
168
+ emit: <T extends keyof Map>(type: T, ...args: Parameters<Map[T]>) => Promise<ReturnType<Map[T]>[]>;
169
+ /**
170
+ * Like {@link emit},
171
+ * but ensures only a single listener exists and returns its result.
172
+ */
173
+ call: <T extends keyof Map>(type: T, ...args: Parameters<Map[T]>) => Promise<ReturnType<Map[T]>>;
169
174
  /**
170
175
  * Process prop changes to update listeners
171
176
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcanejs/toolkit",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "private": false,
5
5
  "description": "Build web-accessible control interfaces for your long-running Node.js processes",
6
6
  "keywords": [
@@ -114,8 +114,8 @@
114
114
  "styled-components": "^6.1.13",
115
115
  "tsup": "^8.1.0",
116
116
  "typescript": "^5.3.3",
117
+ "@arcanejs/toolkit-frontend": "^0.8.0",
117
118
  "@arcanejs/eslint-config": "^0.0.0",
118
- "@arcanejs/toolkit-frontend": "^0.7.0",
119
119
  "@arcanejs/typescript-config": "^0.0.0"
120
120
  },
121
121
  "dependencies": {
@@ -132,7 +132,7 @@
132
132
  "react": "^18",
133
133
  "react-dom": "18.3.1",
134
134
  "styled-components": "^6.1.13",
135
- "@arcanejs/toolkit-frontend": "^0.7.0"
135
+ "@arcanejs/toolkit-frontend": "^0.8.0"
136
136
  },
137
137
  "peerDependenciesMeta": {
138
138
  "@arcanejs/toolkit-frontend": {