@adcops/autocore-react 3.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 (136) hide show
  1. package/LICENSE +59 -0
  2. package/additional-docs/ButtonApiSpecs.md +48 -0
  3. package/additional-docs/GlobalEventEmitter.md +244 -0
  4. package/additional-docs/general_recommendations.md +22 -0
  5. package/dist/components/DPad.css +522 -0
  6. package/dist/components/DPad.d.ts +34 -0
  7. package/dist/components/DPad.js +1 -0
  8. package/dist/components/Indicator.d.ts +81 -0
  9. package/dist/components/Indicator.js +1 -0
  10. package/dist/components/IndicatorButton.d.ts +137 -0
  11. package/dist/components/IndicatorButton.js +1 -0
  12. package/dist/components/IndicatorColor.d.ts +26 -0
  13. package/dist/components/IndicatorColor.js +1 -0
  14. package/dist/components/Osk.d.ts +14 -0
  15. package/dist/components/Osk.js +1 -0
  16. package/dist/components/OskDialog.d.ts +33 -0
  17. package/dist/components/OskDialog.js +1 -0
  18. package/dist/components/ValueDisplay.d.ts +99 -0
  19. package/dist/components/ValueDisplay.js +1 -0
  20. package/dist/components/osk.css +123 -0
  21. package/dist/core/EventEmitterContext.d.ts +223 -0
  22. package/dist/core/EventEmitterContext.js +1 -0
  23. package/dist/core/MaskPatterns.d.ts +71 -0
  24. package/dist/core/MaskPatterns.js +1 -0
  25. package/dist/core/NumerableTypes.d.ts +58 -0
  26. package/dist/core/NumerableTypes.js +1 -0
  27. package/dist/core/PositionContext.d.ts +38 -0
  28. package/dist/core/PositionContext.js +1 -0
  29. package/dist/core/UniqueId.d.ts +16 -0
  30. package/dist/core/UniqueId.js +1 -0
  31. package/dist/core/ValueSimulator.d.ts +71 -0
  32. package/dist/core/ValueSimulator.js +1 -0
  33. package/dist/core/hoc.d.ts +31 -0
  34. package/dist/core/hoc.js +1 -0
  35. package/dist/hub/HubBase.d.ts +169 -0
  36. package/dist/hub/HubBase.js +1 -0
  37. package/dist/hub/HubSimulate.d.ts +20 -0
  38. package/dist/hub/HubSimulate.js +1 -0
  39. package/dist/hub/HubSocketIo.d.ts +101 -0
  40. package/dist/hub/HubSocketIo.js +1 -0
  41. package/dist/hub/HubTauri.d.ts +86 -0
  42. package/dist/hub/HubTauri.js +1 -0
  43. package/dist/hub/index.d.ts +13 -0
  44. package/dist/hub/index.js +1 -0
  45. package/docs/.nojekyll +1 -0
  46. package/docs/assets/highlight.css +106 -0
  47. package/docs/assets/icons.js +15 -0
  48. package/docs/assets/icons.svg +1 -0
  49. package/docs/assets/main.js +59 -0
  50. package/docs/assets/navigation.js +1 -0
  51. package/docs/assets/search.js +1 -0
  52. package/docs/assets/style.css +1414 -0
  53. package/docs/classes/components_Indicator.Indicator.html +105 -0
  54. package/docs/classes/components_IndicatorButton.IndicatorButton.html +119 -0
  55. package/docs/classes/components_OskDialog.OskDialog.html +117 -0
  56. package/docs/classes/components_ValueDisplay.ValueDisplay.html +104 -0
  57. package/docs/classes/core_ValueSimulator.ValueSimulator.html +41 -0
  58. package/docs/classes/hub_HubBase.HubBase.html +67 -0
  59. package/docs/classes/hub_HubSimulate.HubSimulate.html +72 -0
  60. package/docs/classes/hub_HubSocketIo.HubSocketIo.html +80 -0
  61. package/docs/classes/hub_HubTauri.HubTauri.html +80 -0
  62. package/docs/enums/components_DPad.VcJoyPadAction.html +10 -0
  63. package/docs/enums/components_DPad.VcJoyPadButtonId.html +7 -0
  64. package/docs/enums/components_IndicatorButton.ActionMode.html +6 -0
  65. package/docs/enums/components_IndicatorColor.IndicatorColor.html +13 -0
  66. package/docs/functions/components_DPad.VcDPad.html +5 -0
  67. package/docs/functions/components_Osk.Osk.html +5 -0
  68. package/docs/functions/core_EventEmitterContext.EventEmitterProvider.html +8 -0
  69. package/docs/functions/core_UniqueId.UniqueId.html +4 -0
  70. package/docs/functions/core_hoc.hocAddSubscription.html +6 -0
  71. package/docs/functions/hub.createHub.html +3 -0
  72. package/docs/hierarchy.html +1 -0
  73. package/docs/index.html +69 -0
  74. package/docs/interfaces/components_IndicatorButton.IndicatorButtonProps.html +635 -0
  75. package/docs/interfaces/components_IndicatorButton.IndicatorButtonState.html +10 -0
  76. package/docs/interfaces/core_DimensionsContext.IDimensionsContext.html +4 -0
  77. package/docs/interfaces/core_EventEmitterContext.Action.html +5 -0
  78. package/docs/interfaces/core_EventEmitterContext.EventEmitterContextType.html +18 -0
  79. package/docs/interfaces/core_EventEmitterContext.State.html +8 -0
  80. package/docs/interfaces/core_EventEmitterContext.Subscription.html +6 -0
  81. package/docs/modules/components_DPad.html +5 -0
  82. package/docs/modules/components_Indicator.html +4 -0
  83. package/docs/modules/components_IndicatorButton.html +7 -0
  84. package/docs/modules/components_IndicatorColor.html +2 -0
  85. package/docs/modules/components_Osk.html +3 -0
  86. package/docs/modules/components_OskDialog.html +3 -0
  87. package/docs/modules/components_ValueDisplay.html +3 -0
  88. package/docs/modules/core_DimensionsContext.html +4 -0
  89. package/docs/modules/core_EventEmitterContext.html +11 -0
  90. package/docs/modules/core_InputPatterns.html +2 -0
  91. package/docs/modules/core_NumerableTypes.html +2 -0
  92. package/docs/modules/core_UniqueId.html +2 -0
  93. package/docs/modules/core_ValueSimulator.html +3 -0
  94. package/docs/modules/core_hoc.html +3 -0
  95. package/docs/modules/hub.html +6 -0
  96. package/docs/modules/hub_HubBase.html +3 -0
  97. package/docs/modules/hub_HubSimulate.html +3 -0
  98. package/docs/modules/hub_HubSocketIo.html +3 -0
  99. package/docs/modules/hub_HubTauri.html +2 -0
  100. package/docs/types/core_EventEmitterContext.EmitterDispatchFunction.html +1 -0
  101. package/docs/types/core_EventEmitterContext.EmitterSubscribeFunction.html +1 -0
  102. package/docs/types/core_EventEmitterContext.EmitterUnsubscribeFunction.html +1 -0
  103. package/docs/types/core_NumerableTypes.NumerableFormatOptions.html +1 -0
  104. package/docs/types/core_hoc.HocAddSubscriptionProps.html +4 -0
  105. package/docs/variables/core_DimensionsContext.DimensionsContext.html +1 -0
  106. package/docs/variables/core_EventEmitterContext.EventEmitterContext.html +5 -0
  107. package/docs/variables/core_InputPatterns.InputPatterns.html +2 -0
  108. package/package.json +79 -0
  109. package/readme.md +140 -0
  110. package/src/components/DPad.css +522 -0
  111. package/src/components/DPad.tsx +94 -0
  112. package/src/components/Indicator.tsx +243 -0
  113. package/src/components/IndicatorButton.tsx +306 -0
  114. package/src/components/IndicatorColor.ts +36 -0
  115. package/src/components/Osk.tsx +193 -0
  116. package/src/components/OskDialog.tsx +165 -0
  117. package/src/components/ValueDisplay.tsx +181 -0
  118. package/src/components/osk.css +123 -0
  119. package/src/core/EventEmitterContext.tsx +394 -0
  120. package/src/core/MaskPatterns.ts +82 -0
  121. package/src/core/NumerableTypes.ts +81 -0
  122. package/src/core/PositionContext.ts +60 -0
  123. package/src/core/UniqueId.ts +41 -0
  124. package/src/core/ValueSimulator.ts +167 -0
  125. package/src/core/hoc.tsx +65 -0
  126. package/src/hub/HubBase.ts +293 -0
  127. package/src/hub/HubSimulate.ts +47 -0
  128. package/src/hub/HubSocketIo.ts +166 -0
  129. package/src/hub/HubTauri.ts +145 -0
  130. package/src/hub/index.ts +41 -0
  131. package/terser.config.cjs +25 -0
  132. package/todo.md +18 -0
  133. package/tools/copy-distribution-files.cjs +73 -0
  134. package/tools/minify.cjs +56 -0
  135. package/tsconfig.json +34 -0
  136. package/typedoc.json +13 -0
@@ -0,0 +1,166 @@
1
+ /*
2
+ * Copyright (C) 2023 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2023-12-17 10:38:21
4
+ * Author: Thomas C. Bitsky Jr.
5
+ * -----
6
+ * Last Modified: 2024-03-08 09:46:20
7
+ * Modified By: ADC
8
+ * -----
9
+ *
10
+ */
11
+
12
+ import { HubBase } from './HubBase';
13
+ import io, { Socket } from 'socket.io-client';
14
+
15
+ /**
16
+ * Hub for integrating with a webserver/backend using Socket.IO as the pipeline.
17
+ *
18
+ * The socket-io connection is expected to broadcast messages on the event
19
+ * name: 'autocore://broadcast_event'
20
+ *
21
+ * This hub will capture those messages and dispatch them globally to any
22
+ * listeners in the web app.
23
+ *
24
+ *
25
+ * Example: Listen to an event 'xarm-position':
26
+ * ```
27
+ * const {subscribe, unsubscribe} = useContext(EventEmitterContext);
28
+ * useEffect(() => {
29
+ * const unsubscripeMp = subscribe('xarm-position', (value) => {
30
+ * // The rust backend sent a JSON object of 3D position values.
31
+ * setX(value.x);
32
+ * setY(value.y);
33
+ * setZ(value.z);
34
+ * setA(value.roll);
35
+ * setB(value.yaw);
36
+ * setC(value.pitch);
37
+ * });
38
+ *
39
+ * return () => {
40
+ * unsubscribe(unsubscripeMp);
41
+ * }
42
+ *
43
+ * }, [] );
44
+ *
45
+ * ```
46
+ *
47
+ * The hub should also be used for invoking events in the Tauri backend.
48
+ * This example will call the function "update_count" in the rust backend, passing
49
+ * the expected argument "count".
50
+ * ```
51
+ * const {invoke} = useContext(EventEmitterContext);
52
+ * const incrementCount = () => {
53
+ * count += 1;
54
+ * invoke('update_count', {"count": count});
55
+ * };
56
+ * ```
57
+ *
58
+ * Of course, like any class derived from HubBase, the hub can be used to publish and subscribe to
59
+ * topics in the front-end, without need of interacting with the Tauri backed.
60
+ *
61
+ * ```
62
+ * const {dispatch, subscribe, unsubscribe} = useContext(EventEmitterContext);
63
+ * const [controlPower, setControlPower] = useState(false);
64
+ * useEffect(() => {
65
+ * const unsubscribeControlPower = subscribe('value-simulator-bBit1', (value) => {
66
+ * setControlPower(value);
67
+ * });
68
+ *
69
+ *
70
+ * return () => {
71
+ * unsubscribe(unsubscribeControlPower);
72
+ * }
73
+ * }, [] );
74
+ *
75
+ * const onPbPressed = () => {
76
+ * let count = 1;
77
+ * dispatch({
78
+ * topic: "my-awesome-topic",
79
+ * payload: count
80
+ * });
81
+ * }
82
+ *
83
+ * ```
84
+ *
85
+ */
86
+ export class HubSocketIo extends HubBase {
87
+ private socket: Socket;
88
+
89
+ /**
90
+ * Constructor
91
+ */
92
+ constructor() {
93
+ super();
94
+
95
+ // Initialize the Socket.IO client to connect to the same domain and protocol
96
+ const socketUrl = window.location.origin;
97
+
98
+ this.socket = io(socketUrl);
99
+
100
+ // Listen for a custom event from the backend
101
+ this.socket.on('autocore://broadcast_event', (ev: any) => {
102
+ let objPayload = JSON.parse(ev.payload);
103
+
104
+ if (objPayload.topic !== undefined && objPayload.topic !== null ) {
105
+
106
+ if ( objPayload.payload !== undefined && objPayload.payload !== null ) {
107
+ this.publish(objPayload.topic, objPayload.payload);
108
+ }
109
+ else {
110
+ this.publish(objPayload.topic, undefined);
111
+ }
112
+
113
+ }
114
+ });
115
+
116
+ }
117
+
118
+ /**
119
+ * Invoke a method in the Socket.IO backend and wait for acknowledgment.
120
+ *
121
+ * @param fname method name
122
+ * @param payload Optional data payload
123
+ * @param timeout Timeout in milliseconds after which the promise is rejected if no response is received.
124
+ * @returns A Promise that resolves to the response from the backend or rejects if a timeout occurs.
125
+ */
126
+ invoke(fname: string, payload?: object, timeout: number = 5000): Promise<object> {
127
+ return new Promise((resolve, reject) => {
128
+ // Flag to track if the response was received
129
+ let responseReceived = false;
130
+
131
+ this.socket.emit(fname, payload, (response: object) => {
132
+ responseReceived = true;
133
+ resolve(response);
134
+ });
135
+
136
+ // Set a timeout to reject the promise if no response is received
137
+ setTimeout(() => {
138
+ if (!responseReceived) {
139
+ reject(new Error(`Timeout: No response received within ${timeout} ms`));
140
+ }
141
+ }, timeout);
142
+ });
143
+ }
144
+
145
+ /**
146
+ * Disconnects the Socket.IO client.
147
+ */
148
+ disconnect(): void {
149
+ this.socket.disconnect();
150
+ }
151
+
152
+
153
+ /**
154
+ * Emit an event to the Socket.IO server.
155
+ * The intention is that the invoke method is used instead.
156
+ *
157
+ * @param eventName Name of the event to emit
158
+ * @param payload Optional data payload
159
+ */
160
+ protected emit(eventName: string, payload?: object): void {
161
+ this.socket.emit(eventName, payload);
162
+ }
163
+
164
+ }
165
+
166
+ export default HubSocketIo;
@@ -0,0 +1,145 @@
1
+ /*
2
+ * Copyright (C) 2023 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2023-12-17 09:50:23
4
+ * Author: Thomas C. Bitsky Jr.
5
+ * -----
6
+ * Last Modified: 2024-03-07 13:20:46
7
+ * Modified By: ADC
8
+ * -----
9
+ *
10
+ */
11
+
12
+ import { InvokeArgs } from '@tauri-apps/api/tauri';
13
+ import { HubBase } from './HubBase';
14
+ import {event, invoke} from '@tauri-apps/api';
15
+
16
+
17
+ /**
18
+ * Hub for integrating with the Tauri backend.
19
+ *
20
+ * The tauri backend is expected to broadcast messages on the event
21
+ * name: 'autocore://broadcast_event'
22
+ *
23
+ * This hub will capture those messages and dispatch them globally to any
24
+ * listeners in the web app.
25
+ *
26
+ *
27
+ * Example: Listen to an event 'xarm-position':
28
+ * ```
29
+ * const {subscribe, unsubscribe} = useContext(EventEmitterContext);
30
+ * useEffect(() => {
31
+ * const unsubscripeMp = subscribe('xarm-position', (value) => {
32
+ * // The rust backend sent a JSON object of 3D position values.
33
+ * setX(value.x);
34
+ * setY(value.y);
35
+ * setZ(value.z);
36
+ * setA(value.roll);
37
+ * setB(value.yaw);
38
+ * setC(value.pitch);
39
+ * });
40
+ *
41
+ * return () => {
42
+ * unsubscribe(unsubscripeMp);
43
+ * }
44
+ *
45
+ * }, [] );
46
+ *
47
+ * ```
48
+ *
49
+ * The hub should also be used for invoking events in the Tauri backend.
50
+ * This example will call the function "update_count" in the rust backend, passing
51
+ * the expected argument "count".
52
+ * ```
53
+ * const {invoke} = useContext(EventEmitterContext);
54
+ * const incrementCount = () => {
55
+ * count += 1;
56
+ * invoke('update_count', {"count": count});
57
+ * };
58
+ * ```
59
+ *
60
+ * Of course, like any class derived from HubBase, the hub can be used to publish and subscribe to
61
+ * topics in the front-end, without need of interacting with the Tauri backed.
62
+ *
63
+ * ```
64
+ * const {dispatch, subscribe, unsubscribe} = useContext(EventEmitterContext);
65
+ * const [controlPower, setControlPower] = useState(false);
66
+ * useEffect(() => {
67
+ * const unsubscribeControlPower = subscribe('value-simulator-bBit1', (value) => {
68
+ * setControlPower(value);
69
+ * });
70
+ *
71
+ *
72
+ * return () => {
73
+ * unsubscribe(unsubscribeControlPower);
74
+ * }
75
+ * }, [] );
76
+ *
77
+ * const onPbPressed = () => {
78
+ * let count = 1;
79
+ * dispatch({
80
+ * topic: "my-awesome-topic",
81
+ * payload: count
82
+ * });
83
+ * }
84
+ *
85
+ * ```
86
+ *
87
+ */
88
+ export class HubTauri extends HubBase {
89
+
90
+ /**
91
+ * Constructor
92
+ */
93
+ constructor() {
94
+ super();
95
+
96
+
97
+ /**
98
+ * Receive broadcasts from the Tauri backend. Data is received as a payload object,
99
+ * {topic: string, payload: any | null}
100
+ * From here, we extract into a form HubBase can use, then pass on to the
101
+ * dispatcher.
102
+ *
103
+ * Events without a topic are ignored.
104
+ */
105
+ event.listen('autocore://broadcast_event', (ev: any) => {
106
+
107
+ let objPayload = JSON.parse(ev.payload);
108
+
109
+ if (objPayload.topic !== undefined && objPayload.topic !== null ) {
110
+
111
+ if ( objPayload.payload !== undefined && objPayload.payload !== null ) {
112
+ this.publish(objPayload.topic, objPayload.payload);
113
+ }
114
+ else {
115
+ this.publish(objPayload.topic, undefined);
116
+ }
117
+
118
+ }
119
+
120
+ });
121
+
122
+ }
123
+
124
+ /**
125
+ * Invoke a method in the rust backend.
126
+ *
127
+ * @param fname method name
128
+ * @param payload Optional data payload
129
+ * @returns The return value of the backend method.
130
+ */
131
+ invoke(fname: string, payload?: object | undefined): Promise<object> {
132
+
133
+ console.log(JSON.stringify(event));
134
+
135
+ if (payload !== undefined && payload !== null) {
136
+ console.log(`Payload: ${JSON.stringify(payload)}`);
137
+ return invoke(fname, payload as InvokeArgs);
138
+ }
139
+ else {
140
+ return invoke(fname);
141
+ }
142
+
143
+ }
144
+
145
+ }
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2024-01-16 21:07:29
4
+ * -----
5
+ * Last Modified: 2024-03-08 10:20:06
6
+ * Modified By: ADC
7
+ * -----
8
+ *
9
+ */
10
+
11
+ import { HubBase as Hub } from './HubBase';
12
+ import { HubTauri } from './HubTauri';
13
+ import { HubSocketIo } from "./HubSocketIo";
14
+ import {HubSimulate} from "./HubSimulate"
15
+
16
+ /**
17
+ * Creates a connection to the backend.
18
+ * @returns Hub
19
+ */
20
+ export function createHub(): Hub {
21
+ if (window.__TAURI__) {
22
+ return new HubTauri();
23
+ }
24
+ else if (window.location.port !== '80' && window.location.port !== '443' ) {
25
+
26
+ // We're loaded in some development environment
27
+ return new HubSimulate();
28
+
29
+ }
30
+ else {
31
+ return new HubSocketIo();
32
+ }
33
+ }
34
+
35
+
36
+ // Export HubBase for convenience to save importing throughout the
37
+ // application.
38
+ export {HubBase as Hub} from './HubBase';
39
+ export {HubTauri}
40
+ export {HubSocketIo}
41
+ export {HubSimulate}
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2024-01-15 09:43:10
4
+ * Author: Thomas C. Bitsky Jr.
5
+ * -----
6
+ * Last Modified: 2024-01-15 10:11:50
7
+ * Modified By: Thomas C. Bitsky Jr.
8
+ * -----
9
+ *
10
+ */
11
+
12
+
13
+
14
+ module.exports = {
15
+ compress: {
16
+ drop_console: true, // Remove console statements (optional)
17
+ warnings: false, // Suppress warnings (optional)
18
+ keep_fnames: true, // Preserve function names for better debugging
19
+ keep_fargs: true, // Preserve function arguments for better hinting
20
+ },
21
+ mangle: true,
22
+ format: {
23
+ comments: /@preserve|@license|@cc_on|^!|^\*!|^\*\*!/,
24
+ },
25
+ };
package/todo.md ADDED
@@ -0,0 +1,18 @@
1
+ # TODO
2
+
3
+ ## Integration
4
+ - [x] Hub class to route to and from the back end
5
+ - -[x] The Hub should also be the dispatcher. I can't think of a reason they should be separate.
6
+ - [x] Wrapper to link any control and one of its properties or methods to a signal from the backend
7
+ - - [x] update value from a topic
8
+ - - [ ] write topic and callback for accepted value
9
+
10
+ ## Controls
11
+ - [ ] Alarm List Dialog
12
+ - [ ] Alarm List Widget
13
+ - [ ] Settings view
14
+ - [-] JoyPad widget
15
+ - [-] On-screen keyboard (based on https://github.com/hodgef/simple-keyboard)
16
+ - - [-] Num pad
17
+ - - [-] Text input
18
+
@@ -0,0 +1,73 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2024-01-08 13:01:16
4
+ * Author: Thomas C. Bitsky Jr.
5
+ * -----
6
+ * Last Modified: 2024-01-15 07:32:57
7
+ * Modified By: Thomas C. Bitsky Jr.
8
+ * -----
9
+ *
10
+ */
11
+
12
+
13
+ //
14
+ // Copy items into dist needed for publication of the package.
15
+ // Typescript files will be created autmatically, but other
16
+ // resources need to be specified.
17
+ //
18
+
19
+
20
+ const fs = require('fs');
21
+ const path = require('path');
22
+
23
+ /**
24
+ * Copy css files recursively.
25
+ * @param {*} srcDir
26
+ * @param {*} destDir
27
+ */
28
+ function copyFilesByType(srcDir, destDir, extension) {
29
+ // Create the destination directory if it doesn't exist
30
+ if (!fs.existsSync(destDir)) {
31
+ fs.mkdirSync(destDir, { recursive: true });
32
+ }
33
+
34
+ // Read the contents of the source directory
35
+ fs.readdir(srcDir, { withFileTypes: true }, (err, files) => {
36
+ if (err) {
37
+ console.error('Error reading directory:', err);
38
+ return;
39
+ }
40
+
41
+ files.forEach(file => {
42
+ const srcPath = path.join(srcDir, file.name);
43
+ const destPath = path.join(destDir, file.name);
44
+
45
+ if (file.isDirectory()) {
46
+ // If it's a directory, recurse into it
47
+ copyFilesByType(srcPath, destPath, extension);
48
+ } else if (path.extname(file.name) === `.${extension}`) {
49
+ // If it's a CSS file, copy it
50
+ fs.copyFile(srcPath, destPath, err => {
51
+ if (err) {
52
+ console.error('Error copying file:', err);
53
+ }
54
+ });
55
+ }
56
+ });
57
+ });
58
+ }
59
+
60
+
61
+ // // destination.txt will be created or overwritten by default.
62
+ // fs.copyFile("./package.json", './dist/package.json', (err) =>
63
+ // {
64
+ // if (err) throw err;
65
+ // });
66
+
67
+ // copy in the files that won't be included by tsc
68
+
69
+ copyFilesByType("./src", "./dist", "css");
70
+ copyFilesByType("./src", "./dist", "ttf");
71
+ copyFilesByType("./src", "./dist", "woff2");
72
+ // JavaScript files won't be processed by tsc
73
+ //copyFilesByType("./src", "./dist", "js");
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2024-01-15 09:48:58
4
+ * Author: Thomas C. Bitsky Jr.
5
+ * -----
6
+ * Last Modified: 2024-01-16 16:30:39
7
+ * Modified By: Thomas C. Bitsky Jr.
8
+ * -----
9
+ *
10
+ * These scripts recursively minify a directory in-place based on the settings in
11
+ * ./terser.config.cjs
12
+ *
13
+ */
14
+
15
+
16
+
17
+ const terser = require("terser");
18
+ const fs = require("fs");
19
+ const path = require("path");
20
+ const terserConfig = require("../terser.config.cjs");
21
+
22
+ const distFolder = './dist'; // Path to your dist folder
23
+
24
+
25
+
26
+
27
+ /**
28
+ * Recursively minify the JS files in a folder.
29
+ * @param {string} s Target folder
30
+ */
31
+ function minifyFolder(s) {
32
+
33
+ fs.readdirSync(s).forEach(file => {
34
+ const filePath = path.join(s, file);
35
+
36
+ console.log(`Minifying path ${filePath}`);
37
+
38
+ if (fs.lstatSync(filePath).isFile() && filePath.endsWith('.js')) {
39
+ console.log(`Minifying ${file}...`);
40
+ const fileContents = fs.readFileSync(filePath, 'utf8');
41
+ terser.minify(fileContents, terserConfig).then(minified => {
42
+ fs.writeFileSync(filePath, minified.code);
43
+ }).catch(error => {
44
+ console.error(`Error minifying ${file}:`, error);
45
+ });
46
+ }
47
+ else if (fs.lstatSync(filePath).isDirectory()) {
48
+ minifyFolder(filePath)
49
+ }
50
+ });
51
+ }
52
+
53
+ //
54
+ // Start the process by scanning the top-level distribution folder.
55
+ //
56
+ minifyFolder(distFolder);
package/tsconfig.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020", // Set the JavaScript language version for emitted JavaScript and include compatible library declarations
4
+ "outDir": "./dist", // Specify an output folder for all emitted files
5
+ "useDefineForClassFields": true, // Use 'define' semantics for class fields (as opposed to 'set')
6
+
7
+ // Specify a set of compiled-in library files to be included in the compilation context
8
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
9
+
10
+ "module": "ESNext", // Specify what module code is generated (here, it's the latest module standard)
11
+ "declaration": true, // Generate the types files (*.d.ts)
12
+ "skipLibCheck": true, // Skip type checking of declaration files (*.d.ts)
13
+
14
+ /* Bundler mode */
15
+ "moduleResolution": "node", // Choose the module resolution strategy: 'node' for Node.js
16
+ "allowSyntheticDefaultImports": true, // Allow default imports from modules with no default export
17
+ "resolveJsonModule": true, // Include modules imported with '.json' extension
18
+ "isolatedModules": true, // Ensure each file can be safely transpiled without relying on other imports
19
+ "noEmit": false, // Do not emit outputs (if set to true, no files are emitted)
20
+ "jsx": "react-jsx", // Specify JSX code generation: 'preserve', 'react', or 'react-jsx' (new transform)
21
+
22
+ /* Linting */
23
+ "strict": true, // Enable all strict type checking options
24
+ "noUnusedLocals": true, // Report errors on unused locals
25
+ "noUnusedParameters": true, // Report errors on unused parameters
26
+ "noFallthroughCasesInSwitch": true // Report errors for fallthrough cases in switch statement
27
+ },
28
+ "include": ["src"], // Specify file glob patterns to include in the program
29
+ "exclude": [ // Specify file globa patterns to exclude from compilation
30
+ "node_modules",
31
+ "dist"
32
+ ]
33
+ }
34
+
package/typedoc.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "out": "docs",
3
+ "entryPoints": ["src"],
4
+ "entryPointStrategy": "expand",
5
+ "tsconfig": "tsconfig.json",
6
+ "exclude": [
7
+ "**/*.test.ts", "**/node_modules"
8
+ ],
9
+ "name": "autocore-react",
10
+ "includeVersion": true,
11
+ "readme": "readme.md",
12
+ "theme": "default"
13
+ }