@area2-ai/a2-demo-cipher-react 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Area2 AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # TSDX React Component Library
2
+
3
+ Zero-config React component library development powered by modern tools.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Install dependencies
9
+ bun install
10
+
11
+ # Start development mode
12
+ bun run dev
13
+
14
+ # Build for production
15
+ bun run build
16
+
17
+ # Run tests
18
+ bun run test
19
+
20
+ # Lint code
21
+ bun run lint
22
+
23
+ # Format code
24
+ bun run format
25
+ ```
26
+
27
+ ## Project Structure
28
+
29
+ ```
30
+ /src
31
+ index.tsx # Your component entry point
32
+ /test
33
+ index.test.tsx # Tests using Vitest + Testing Library
34
+ /example
35
+ index.tsx # Demo app using Vite
36
+ .gitignore
37
+ package.json
38
+ README.md
39
+ tsconfig.json
40
+ vitest.config.ts
41
+ ```
42
+
43
+ ## Scripts
44
+
45
+ | Script | Description |
46
+ |--------|-------------|
47
+ | `bun run dev` | Start development mode with watch |
48
+ | `bun run build` | Build for production |
49
+ | `bun run test` | Run tests |
50
+ | `bun run test:watch` | Run tests in watch mode |
51
+ | `bun run lint` | Lint code |
52
+ | `bun run format` | Format code |
53
+ | `bun run format:check` | Check if code is formatted |
54
+ | `bun run typecheck` | Run TypeScript type checking |
55
+
56
+ ## Tools
57
+
58
+ TSDX wraps these modern, high-performance tools:
59
+
60
+ - **[Bunchee](https://github.com/huozhi/bunchee)** - Zero-config bundler for npm packages
61
+ - **[Vitest](https://vitest.dev/)** - Next-generation testing framework
62
+ - **[Testing Library](https://testing-library.com/)** - React testing utilities
63
+ - **[Oxlint](https://oxc.rs/docs/guide/usage/linter.html)** - Rust-powered linter (50-100x faster than ESLint)
64
+ - **[Oxfmt](https://oxc.rs/docs/guide/usage/formatter)** - Rust-powered formatter (35x faster than Prettier)
65
+ - **[TypeScript](https://www.typescriptlang.org/)** - Type safety
66
+
67
+ ## Development with Example
68
+
69
+ To test your component in a real React app:
70
+
71
+ ```bash
72
+ # In one terminal, start the library in watch mode
73
+ bun run dev
74
+
75
+ # In another terminal, run the example app
76
+ cd example
77
+ bun install
78
+ bun run dev
79
+ ```
80
+
81
+ ## Module Formats
82
+
83
+ This library exports both ESM and CommonJS formats, with full TypeScript support:
84
+
85
+ - `dist/index.js` - ESM
86
+ - `dist/index.cjs` - CommonJS
87
+ - `dist/index.d.ts` - TypeScript declarations
88
+
89
+ ## Publishing
90
+
91
+ ```bash
92
+ # Build the package
93
+ bun run build
94
+
95
+ # Publish to npm
96
+ npm publish
97
+ ```
98
+
99
+ We recommend using [np](https://github.com/sindresorhus/np) for publishing.
100
+
101
+ ## License
102
+
103
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,424 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var a2CipherCore = require('@area2-ai/a2-cipher-core');
6
+ var reactDeviceDetect = require('react-device-detect');
7
+
8
+ const Area2Context = /*#__PURE__*/ react.createContext({});
9
+
10
+ const AREA2_INITIAL_STATE = {};
11
+ const Area2Provider = ({ children })=>{
12
+ const [state] = react.useReducer(area2Reducer, AREA2_INITIAL_STATE); //[state, dispatch]
13
+ const keystrokeManagerRef = react.useRef();
14
+ const androidKeystrokeManagerRef = react.useRef();
15
+ const iosKeystrokeManagerRef = react.useRef();
16
+ const getKeystrokeManager = ()=>keystrokeManagerRef.current;
17
+ const getAndroidKeystrokeManager = ()=>androidKeystrokeManagerRef.current;
18
+ const getIosKeystrokeManager = ()=>iosKeystrokeManagerRef.current;
19
+ react.useEffect(()=>{
20
+ keystrokeManagerRef.current = new a2CipherCore.KeystrokeManager();
21
+ androidKeystrokeManagerRef.current = new a2CipherCore.AndroidKeystrokeManager();
22
+ iosKeystrokeManagerRef.current = new a2CipherCore.IosKeystrokeManager();
23
+ }, []);
24
+ return /*#__PURE__*/ jsxRuntime.jsx(Area2Context.Provider, {
25
+ value: {
26
+ ...state,
27
+ getKeystrokeManager,
28
+ getAndroidKeystrokeManager,
29
+ getIosKeystrokeManager
30
+ },
31
+ children: children
32
+ });
33
+ };
34
+
35
+ const area2Reducer = (state, action)=>{
36
+ switch(action.type){
37
+ case '[A2 Desktop] - Update text':
38
+ return {
39
+ ...state,
40
+ desktopTextValue: action.payload.newValue
41
+ };
42
+ default:
43
+ return state;
44
+ }
45
+ };
46
+
47
+ const getBrowserInfo = ()=>reactDeviceDetect.browserName;
48
+
49
+ const getOsInfo = ()=>reactDeviceDetect.osName;
50
+
51
+ const getPlatform = ()=>{
52
+ if (reactDeviceDetect.isAndroid) return 'android';
53
+ if (reactDeviceDetect.isDesktop) return 'desktop';
54
+ return 'ios';
55
+ };
56
+
57
+ const formatDemoKeystrokeData = (payload, isMobile)=>{
58
+ const base = {
59
+ session_id: payload.sessionID.substring(0, 5) + '-[* * *]',
60
+ temporal_kinematics: [
61
+ '* * *'
62
+ ],
63
+ spatial_kinematics: [
64
+ '* * *'
65
+ ],
66
+ type_kinematics: [
67
+ '* * *'
68
+ ]
69
+ };
70
+ if (isMobile) {
71
+ base.device_context = '[* * *]';
72
+ base.assist_signals = '[* * *]';
73
+ } else {
74
+ base.context = {
75
+ time: '[* * *]',
76
+ weekday: '[* * *]',
77
+ season: '[* * *]',
78
+ timezone: '[* * *]'
79
+ };
80
+ base.extra_metadata = {
81
+ OS: '[* * *]',
82
+ browser: '[* * *]'
83
+ };
84
+ }
85
+ return base;
86
+ };
87
+
88
+ /**
89
+ * Keystroke hook for android mobile browser
90
+ */ const useMobileKeystrokeAndroid = ()=>{
91
+ const { getAndroidKeystrokeManager } = react.useContext(Area2Context);
92
+ /**
93
+ * Handles the before input event.
94
+ * @param {string} newValue - The new value of the input before the input event.
95
+ * @param {string} inputValue - The current value of the input.
96
+ */ const handleProcessOnBeforeInput = react.useCallback((newValue, inputValue)=>{
97
+ getAndroidKeystrokeManager().processBeforeInput(newValue, inputValue);
98
+ }, []);
99
+ /**
100
+ * Handles the paste event.
101
+ * @param {ClipboardEvent<HTMLInputElement>} event - The paste event.
102
+ */ const handleProcessPaste = react.useCallback((event)=>{
103
+ const pastedText = event.clipboardData.getData("text");
104
+ getAndroidKeystrokeManager().processPaste(pastedText);
105
+ }, []);
106
+ /**
107
+ * Handles the key input event.
108
+ * @param {string} inputContent - The content of the key input.
109
+ */ const handleProcessKeyInput = react.useCallback((inputContent)=>{
110
+ getAndroidKeystrokeManager().processKeyInput(inputContent);
111
+ }, []);
112
+ /**
113
+ * Handles the keydown event.
114
+ * @param {HTMLInputElement} target - The target input element.
115
+ */ const handleProcessKeydown = react.useCallback((target)=>{
116
+ getAndroidKeystrokeManager().processKeydown(target);
117
+ }, []);
118
+ /**
119
+ * Handles the keyup event.
120
+ */ const handleProcessKeyup = react.useCallback(()=>{
121
+ getAndroidKeystrokeManager().processKeyup();
122
+ }, []);
123
+ /**
124
+ * Ends the typing session and returns the typing data.
125
+ * @returns {A2CapturePayload | undefined} - The typing data or undefined if no data.
126
+ */ // const handleEndTypingSession = useCallback((): A2CapturePayload | undefined => {
127
+ // const typingData = getAndroidKeystrokeManager().endTypingSession();
128
+ // getAndroidKeystrokeManager().resetTypingData();
129
+ // if (!typingData.startUnixTime) {
130
+ // console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
131
+ // return;
132
+ // }
133
+ // typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
134
+ // return typingData;
135
+ // }, []);
136
+ /**
137
+ * Ends the demo typing session and returns the typing data.
138
+ * @returns {A2DemoCapturePayload | undefined} - The typing data or undefined if no data.
139
+ */ const handleEndDemoTypingSession = react.useCallback(()=>{
140
+ const typingData = getAndroidKeystrokeManager().endTypingSession();
141
+ getAndroidKeystrokeManager().resetTypingData();
142
+ if (!typingData.startUnixTime) {
143
+ console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
144
+ return;
145
+ }
146
+ typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
147
+ return formatDemoKeystrokeData(typingData, true);
148
+ }, []);
149
+ return {
150
+ handleProcessOnBeforeInput,
151
+ handleProcessPaste,
152
+ handleProcessKeyInput,
153
+ handleProcessKeydown,
154
+ handleProcessKeyup,
155
+ handleEndTypingSession: handleEndDemoTypingSession
156
+ };
157
+ };
158
+
159
+ /**
160
+ * Keystroke hook for desktop platforms.
161
+ */ const useDesktopKeystroke = ()=>{
162
+ const { getKeystrokeManager } = react.useContext(Area2Context);
163
+ const getIsTypingSessionActive = ()=>getKeystrokeManager().getIsTypingSessionActive;
164
+ /**
165
+ * Handles the keydown event.
166
+ * @param {string} key - The key pressed.
167
+ */ const handleProcessKeydown = react.useCallback((key)=>{
168
+ getKeystrokeManager().processKeydown(key);
169
+ }, []);
170
+ /**
171
+ * Handles the keyup event.
172
+ * @param {string} key - The key released.
173
+ */ const handleProcessKeyup = react.useCallback((key)=>{
174
+ getKeystrokeManager().processKeyup(key);
175
+ }, []);
176
+ /**
177
+ * Ends the typing session and returns the typing data.
178
+ * @returns {A2CapturePayload | undefined} - The typing session data or undefined if no data.
179
+ */ // const handleEndTypingSession = useCallback((): A2CapturePayload | undefined => {
180
+ // const typingData = getKeystrokeManager().endTypingSession();
181
+ // getKeystrokeManager().resetTypingData();
182
+ // if (!typingData.startUnixTime) {
183
+ // console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
184
+ // return;
185
+ // }
186
+ // typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
187
+ // return typingData;
188
+ // }, []);
189
+ /**
190
+ * Ends the demo typing session and returns the typing data.
191
+ * @returns {A2DemoCapturePayload | undefined} - The typing session data or undefined if no data.
192
+ */ const handleEndDemoTypingSession = react.useCallback(()=>{
193
+ const typingData = getKeystrokeManager().endTypingSession();
194
+ getKeystrokeManager().resetTypingData();
195
+ if (!typingData.startUnixTime) {
196
+ console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
197
+ return;
198
+ }
199
+ typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
200
+ return formatDemoKeystrokeData(typingData, false);
201
+ }, []);
202
+ return {
203
+ handleProcessKeydown,
204
+ handleProcessKeyup,
205
+ getIsTypingSessionActive,
206
+ handleEndTypingSession: handleEndDemoTypingSession
207
+ };
208
+ };
209
+
210
+ /**
211
+ * Keystroke for ios mobile browser
212
+ * @param {string} inputValue - The current value of the text input - Needed to detect auto-correct changes.
213
+ */ const useMobileKeystrokeIOS = ()=>{
214
+ const { getIosKeystrokeManager } = react.useContext(Area2Context);
215
+ //! Undefined behavior - Try to load via context - provider
216
+ /**
217
+ * Processes auto-correction based on the current input value.
218
+ * @param {string} inputValue - The current value of the text input.
219
+ */ // const processAutoCorrection = getIosKeystrokeManager().processAutocorrection;
220
+ /**
221
+ * Handles the before input event.
222
+ * @param {number} value - The length of the content before the input event.
223
+ */ const handleProcessOnBeforeInput = react.useCallback((value)=>{
224
+ getIosKeystrokeManager().setPrevContentLength = value;
225
+ }, []);
226
+ /**
227
+ * Handles the paste event.
228
+ * @param {ClipboardEvent<HTMLInputElement>} event - The paste event.
229
+ */ const handleProcessPaste = react.useCallback((event)=>{
230
+ const pastedText = event.clipboardData.getData("text");
231
+ getIosKeystrokeManager().processPaste(pastedText);
232
+ }, []);
233
+ /**
234
+ * Checks for text prediction and processes it.
235
+ * @param {string} newValue - The new value of the text input.
236
+ * @param {string} inputValue - The current value of the text input.
237
+ */ const checkForPrediction = react.useCallback((newValue, inputValue)=>{
238
+ const textSnapshot = inputValue; // Before it changes
239
+ getIosKeystrokeManager().processPrediction(newValue, textSnapshot);
240
+ }, []);
241
+ /**
242
+ * Handles the input change event
243
+ * @param {ChangeEvent<HTMLInputElement>} event - The input change event
244
+ * @param {string} inputValue - The current value of the text input
245
+ */ const handleProcessInputChange = (event, inputValue)=>{
246
+ const newValue = event.target.value;
247
+ checkForPrediction(newValue, inputValue);
248
+ };
249
+ /**
250
+ * Handles the keydown event.
251
+ * @param {string} keyPressed - The key that was pressed.
252
+ * @param {HTMLInputElement} target - The target input element.
253
+ */ const handleProcessKeydown = react.useCallback((keyPressed, target)=>{
254
+ getIosKeystrokeManager().processKeydown(keyPressed, target);
255
+ }, []);
256
+ /**
257
+ * Handles the keyup event.
258
+ * @param {string} key - The key that was released.
259
+ */ const handleProcessKeyup = react.useCallback((keyPressed)=>{
260
+ getIosKeystrokeManager().processKeyup(keyPressed);
261
+ }, []);
262
+ /**
263
+ * Ends the typing session and returns the typing data.
264
+ * @returns {A2CapturePayload | undefined} - The typing data or undefined if no data.
265
+ */ // const handleEndTypingSession = useCallback((): A2CapturePayload | undefined => {
266
+ // const typingData = getIosKeystrokeManager().endTypingSession();
267
+ // getIosKeystrokeManager().resetTypingData();
268
+ // if (!typingData.startUnixTime) {
269
+ // console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
270
+ // return;
271
+ // }
272
+ // typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
273
+ // return typingData;
274
+ // }, []);
275
+ /**
276
+ * Ends the demo typing session and returns the typing data.
277
+ * @returns {A2DemoCapturePayload | undefined} - The typing data or undefined if no data.
278
+ */ const handleEndDemoTypingSession = react.useCallback(()=>{
279
+ const typingData = getIosKeystrokeManager().endTypingSession();
280
+ getIosKeystrokeManager().resetTypingData();
281
+ if (!typingData.startUnixTime) {
282
+ console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
283
+ return;
284
+ }
285
+ typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
286
+ return formatDemoKeystrokeData(typingData, true);
287
+ }, []);
288
+ return {
289
+ // processAutoCorrection,
290
+ handleProcessInputChange,
291
+ handleProcessKeydown,
292
+ handleProcessPaste,
293
+ handleProcessOnBeforeInput,
294
+ handleProcessKeyup,
295
+ handleEndTypingSession: handleEndDemoTypingSession
296
+ };
297
+ };
298
+
299
+ function useKeystrokeBuilder(target) {
300
+ const targetPlatform = target ?? getPlatform();
301
+ switch(targetPlatform){
302
+ case 'android':
303
+ return useMobileKeystrokeAndroid();
304
+ case 'ios':
305
+ return useMobileKeystrokeIOS();
306
+ case 'desktop':
307
+ default:
308
+ return useDesktopKeystroke();
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Component that renders a text input field and generates an A2CapturePayload data.
314
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
315
+ */ const A2AndroidTextInput = ({ ref, autoCapitalize, value, onChange, ...rest })=>{
316
+ const { handleProcessKeydown, handleProcessKeyup, handleProcessPaste, handleProcessKeyInput, handleProcessOnBeforeInput } = useMobileKeystrokeAndroid();
317
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
318
+ children: /*#__PURE__*/ jsxRuntime.jsx("input", {
319
+ ref: ref,
320
+ type: "text",
321
+ placeholder: "Using android implementation",
322
+ autoCapitalize: autoCapitalize || 'sentences',
323
+ value: value,
324
+ onChange: onChange,
325
+ onKeyDown: ({ currentTarget })=>handleProcessKeydown(currentTarget),
326
+ onKeyUp: handleProcessKeyup,
327
+ onPaste: handleProcessPaste,
328
+ onInput: ({ currentTarget })=>{
329
+ handleProcessKeyInput(currentTarget.value);
330
+ },
331
+ onBeforeInput: ({ currentTarget })=>handleProcessOnBeforeInput(currentTarget.value, value?.toString() || ''),
332
+ ...rest
333
+ })
334
+ });
335
+ };
336
+
337
+ /**
338
+ * Component that renders a text input field and generates an A2CapturePayload data.
339
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
340
+ */ const A2IosTextInput = ({ ref, value, onChange, ...rest })=>{
341
+ const { handleProcessInputChange, handleProcessKeydown, handleProcessKeyup, handleProcessPaste, handleProcessOnBeforeInput } = useMobileKeystrokeIOS();
342
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
343
+ children: /*#__PURE__*/ jsxRuntime.jsx("input", {
344
+ ref: ref,
345
+ type: "text",
346
+ placeholder: "Using iOS implementation",
347
+ onKeyDownCapture: ({ key, currentTarget })=>handleProcessKeydown(key, currentTarget),
348
+ onKeyUpCapture: ({ key })=>handleProcessKeyup(key),
349
+ value: value,
350
+ onChange: (event)=>{
351
+ handleProcessInputChange(event, value?.toString() || ''); //? Execute internal change handler
352
+ onChange?.(event); //? Execute parent's onChange if it exists
353
+ },
354
+ onPaste: handleProcessPaste,
355
+ onBeforeInput: ({ currentTarget })=>{
356
+ handleProcessOnBeforeInput(currentTarget.value.length);
357
+ },
358
+ ...rest
359
+ })
360
+ });
361
+ };
362
+
363
+ /**
364
+ * Component that renders a text input field and generates an A2CapturePayload data.
365
+ *
366
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
367
+ * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press.
368
+ */ const A2DesktopTextInput = ({ ref, onChange, handleEndSessionOnEnter, ...rest })=>{
369
+ const { handleProcessKeydown, handleProcessKeyup, getIsTypingSessionActive } = useDesktopKeystroke();
370
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
371
+ children: /*#__PURE__*/ jsxRuntime.jsx("input", {
372
+ ref: ref,
373
+ type: "text",
374
+ placeholder: "Using desktop implementation",
375
+ onKeyDownCapture: ({ key })=>handleProcessKeydown(key),
376
+ onKeyUpCapture: ({ key })=>{
377
+ handleProcessKeyup(key);
378
+ //? Handle ENTER key
379
+ if (key !== 'Enter') {
380
+ return;
381
+ }
382
+ if (!getIsTypingSessionActive()) {
383
+ return;
384
+ }
385
+ handleEndSessionOnEnter?.(); //? Call parent's function if it exists
386
+ },
387
+ onChange: (event)=>{
388
+ onChange?.(event); //? Execute parent's onChange if it exists
389
+ },
390
+ ...rest
391
+ })
392
+ });
393
+ };
394
+
395
+ /**
396
+ * Component that renders a text input field and generates an A2CapturePayload data.
397
+ *
398
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
399
+ * @param {TargetPlatform} [target] - Optional target platform ('ios', 'android', 'desktop'). If not provided, it will be auto-detected.
400
+ * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press (only for desktop).
401
+ */ const A2Textbox = ({ ref, target, handleEndSessionOnEnter, ...rest })=>{
402
+ const targetPlatform = target ?? getPlatform();
403
+ if (targetPlatform === 'android') {
404
+ return /*#__PURE__*/ jsxRuntime.jsx(A2AndroidTextInput, {
405
+ ...rest,
406
+ ref: ref
407
+ });
408
+ }
409
+ if (targetPlatform === 'ios') {
410
+ return /*#__PURE__*/ jsxRuntime.jsx(A2IosTextInput, {
411
+ ...rest,
412
+ ref: ref
413
+ });
414
+ }
415
+ return /*#__PURE__*/ jsxRuntime.jsx(A2DesktopTextInput, {
416
+ ...rest,
417
+ ref: ref,
418
+ handleEndSessionOnEnter: handleEndSessionOnEnter
419
+ });
420
+ };
421
+
422
+ exports.A2Textbox = A2Textbox;
423
+ exports.Area2Provider = Area2Provider;
424
+ exports.useCipherCapture = useKeystrokeBuilder;
@@ -0,0 +1,74 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React, { ClipboardEvent, ChangeEvent } from 'react';
3
+
4
+ type TargetPlatform = 'desktop' | 'ios' | 'android';
5
+ interface IKeystrokeHookTemplate<T> {
6
+ handleEndTypingSession: () => T | undefined;
7
+ }
8
+ interface IMobileKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {
9
+ handleProcessPaste: (event: ClipboardEvent<HTMLInputElement>) => void;
10
+ }
11
+ interface IDesktopKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {
12
+ getIsTypingSessionActive: () => boolean;
13
+ handleProcessKeydown: (key: string) => void;
14
+ handleProcessKeyup: (key: string) => void;
15
+ }
16
+ interface IAndroidKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {
17
+ handleProcessKeydown: (target: HTMLInputElement) => void;
18
+ handleProcessKeyInput: (inputContent: string) => void;
19
+ handleProcessKeyup: () => void;
20
+ handleProcessOnBeforeInput: (newValue: string, inputValue: string) => void;
21
+ }
22
+ interface IiOSKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {
23
+ handleProcessInputChange: (event: ChangeEvent<HTMLInputElement>, inputValue: string) => void;
24
+ handleProcessKeydown: (keyPressed: string, target: HTMLInputElement) => void;
25
+ handleProcessKeyup: (keyPressed: string) => void;
26
+ handleProcessOnBeforeInput: (value: number) => void;
27
+ }
28
+
29
+ interface A2DemoCapturePayload {
30
+ "session_id": string;
31
+ "temporal_kinematics": string[];
32
+ "spatial_kinematics": string[];
33
+ "type_kinematics": string[];
34
+ context?: {
35
+ "time": string;
36
+ "weekday": string;
37
+ "season": string;
38
+ "timezone": string;
39
+ };
40
+ extra_metadata?: {
41
+ "OS": string;
42
+ "browser": string;
43
+ };
44
+ device_context?: string;
45
+ assist_signals?: string;
46
+ }
47
+
48
+ interface Props$1 extends React.InputHTMLAttributes<HTMLInputElement> {
49
+ ref?: React.Ref<HTMLInputElement>;
50
+ target?: TargetPlatform;
51
+ handleEndSessionOnEnter?: Function;
52
+ }
53
+ /**
54
+ * Component that renders a text input field and generates an A2CapturePayload data.
55
+ *
56
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
57
+ * @param {TargetPlatform} [target] - Optional target platform ('ios', 'android', 'desktop'). If not provided, it will be auto-detected.
58
+ * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press (only for desktop).
59
+ */
60
+ declare const A2Textbox: ({ ref, target, handleEndSessionOnEnter, ...rest }: Props$1) => react_jsx_runtime.JSX.Element;
61
+
62
+ interface Props {
63
+ children: React.ReactNode;
64
+ }
65
+ declare const Area2Provider: ({ children }: Props) => react_jsx_runtime.JSX.Element;
66
+
67
+ declare function useKeystrokeBuilder(target: 'ios'): IiOSKeystrokeHookTemplate<A2DemoCapturePayload>;
68
+ declare function useKeystrokeBuilder(target: 'android'): IAndroidKeystrokeHookTemplate<A2DemoCapturePayload>;
69
+ declare function useKeystrokeBuilder(target: 'desktop'): IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;
70
+ declare function useKeystrokeBuilder(target?: TargetPlatform): IiOSKeystrokeHookTemplate<A2DemoCapturePayload> | IAndroidKeystrokeHookTemplate<A2DemoCapturePayload> | IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;
71
+
72
+ export { A2Textbox, Area2Provider, useKeystrokeBuilder as useCipherCapture };
73
+ export type { A2DemoCapturePayload, TargetPlatform };
74
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sources":["../src/interfaces/IKeystrokeHookTemplate.ts","../src/interfaces/IA2CapturePayload.ts","../src/components/A2Textbox.tsx","../src/context/area2/Area2Provider.tsx","../src/hooks/useKeystrokeBuilder.ts"],"sourcesContent":["import { ChangeEvent, ClipboardEvent } from \"react\";\n\nexport type TargetPlatform = 'desktop' | 'ios' | 'android';\n\n//* Common interface for keystroke hook templates\nexport interface IKeystrokeHookTemplate<T> {\n handleEndTypingSession: () => T | undefined;\n}\n\n//* Common interface for mobile keystroke hook template\nexport interface IMobileKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {\n handleProcessPaste: (event: ClipboardEvent<HTMLInputElement>) => void;\n}\n\n//? Interface for desktop keystroke hook\nexport interface IDesktopKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {\n getIsTypingSessionActive: () => boolean;\n handleProcessKeydown: (key: string) => void;\n handleProcessKeyup: (key: string) => void;\n}\n\n//? Interface for android keystroke hook\nexport interface IAndroidKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {\n handleProcessKeydown: (target: HTMLInputElement) => void;\n handleProcessKeyInput: (inputContent: string) => void;\n handleProcessKeyup: () => void;\n handleProcessOnBeforeInput: (newValue: string, inputValue: string) => void;\n}\n\n//? Interface for iOS keystroke hook\nexport interface IiOSKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {\n handleProcessInputChange: (event: ChangeEvent<HTMLInputElement>, inputValue: string) => void;\n handleProcessKeydown: (keyPressed: string, target: HTMLInputElement) => void;\n handleProcessKeyup: (keyPressed: string) => void;\n handleProcessOnBeforeInput: (value: number) => void;\n //! processAutoCorrection: (textInputValue: string) => void;\n}","import {\n IMobileKeystrokeCollection,\n IKeystrokeCollection,\n IBaseKeystrokeCollection\n} from \"@area2-ai/a2-cipher-core\";\n\nexport interface A2CapturePayload\n extends IBaseKeystrokeCollection,\n Partial<Omit<IKeystrokeCollection, keyof IBaseKeystrokeCollection>>,\n Partial<Omit<IMobileKeystrokeCollection, keyof IBaseKeystrokeCollection>> { }\n\nexport interface A2DemoCapturePayload {\n \"session_id\": string,\n \"temporal_kinematics\": string[],\n \"spatial_kinematics\": string[],\n \"type_kinematics\": string[],\n context?: {\n \"time\": string,\n \"weekday\": string,\n \"season\": string,\n \"timezone\": string\n },\n extra_metadata?: {\n \"OS\": string,\n \"browser\": string\n },\n device_context?: string,\n assist_signals?: string\n}","import React from 'react';\nimport { getPlatform } from '../utils';\n\nimport { A2AndroidTextInput } from './A2AndroidTextInput';\nimport { A2IosTextInput } from './A2IosTextInput';\nimport { A2DesktopTextInput } from './A2DesktopTextInput';\n\nimport type { TargetPlatform } from '../interfaces';\n\ninterface Props extends React.InputHTMLAttributes<HTMLInputElement> {\n ref?: React.Ref<HTMLInputElement>;\n target?: TargetPlatform;\n handleEndSessionOnEnter?: Function;\n}\n\n/**\n * Component that renders a text input field and generates an A2CapturePayload data.\n * \n * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.\n * @param {TargetPlatform} [target] - Optional target platform ('ios', 'android', 'desktop'). If not provided, it will be auto-detected.\n * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press (only for desktop).\n */\nexport const A2Textbox = ({ ref, target, handleEndSessionOnEnter, ...rest }: Props) => {\n const targetPlatform = target ?? getPlatform();\n\n if (targetPlatform === 'android') {\n return (\n <A2AndroidTextInput {...rest} ref={ref} />\n )\n }\n\n if (targetPlatform === 'ios') {\n return (\n <A2IosTextInput {...rest} ref={ref} />\n )\n }\n\n return (\n <A2DesktopTextInput {...rest} ref={ref} handleEndSessionOnEnter={handleEndSessionOnEnter} />\n )\n}\n","import React, { useEffect, useReducer, useRef } from 'react';\nimport {\n KeystrokeManager,\n AndroidKeystrokeManager,\n IosKeystrokeManager\n} from '@area2-ai/a2-cipher-core';\n\nimport { Area2Context, area2Reducer } from '.';\n\nexport interface Area2State { }\n\ninterface Props {\n children: React.ReactNode;\n}\n\nconst AREA2_INITIAL_STATE: Area2State = {}\n\nexport const Area2Provider = ({ children }: Props) => {\n\n const [state] = useReducer(area2Reducer, AREA2_INITIAL_STATE); //[state, dispatch]\n\n const keystrokeManagerRef = useRef<KeystrokeManager>();\n const androidKeystrokeManagerRef = useRef<AndroidKeystrokeManager>();\n const iosKeystrokeManagerRef = useRef<IosKeystrokeManager>();\n\n const getKeystrokeManager = () => keystrokeManagerRef.current!;\n const getAndroidKeystrokeManager = () => androidKeystrokeManagerRef.current!;\n const getIosKeystrokeManager = () => iosKeystrokeManagerRef.current!;\n\n useEffect(() => {\n keystrokeManagerRef.current = new KeystrokeManager();\n androidKeystrokeManagerRef.current = new AndroidKeystrokeManager();\n iosKeystrokeManagerRef.current = new IosKeystrokeManager();\n }, []);\n\n return (\n <Area2Context.Provider value={{\n ...state,\n getKeystrokeManager,\n getAndroidKeystrokeManager,\n getIosKeystrokeManager\n }}>\n {children}\n </Area2Context.Provider>\n )\n}","import { getPlatform } from \"../utils\";\nimport type {\n TargetPlatform,\n IiOSKeystrokeHookTemplate,\n IAndroidKeystrokeHookTemplate,\n IDesktopKeystrokeHookTemplate,\n A2DemoCapturePayload\n} from \"../interfaces\";\n\nimport { useMobileKeystrokeAndroid } from \"./useKeystroke.android\";\nimport { useDesktopKeystroke } from \"./useKeystroke.desktop\";\nimport { useMobileKeystrokeIOS } from \"./useKeystroke.ios\";\n\nexport function useKeystrokeBuilder(target: 'ios'): IiOSKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target: 'android'): IAndroidKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target: 'desktop'): IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target?: TargetPlatform): IiOSKeystrokeHookTemplate<A2DemoCapturePayload> | IAndroidKeystrokeHookTemplate<A2DemoCapturePayload> | IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target?: TargetPlatform) {\n\n const targetPlatform = target ?? getPlatform();\n\n switch (targetPlatform) {\n case 'android':\n return useMobileKeystrokeAndroid();\n case 'ios':\n return useMobileKeystrokeIOS();\n case 'desktop':\n default:\n return useDesktopKeystroke();\n }\n\n}"],"names":["Props"],"mappings":";;;AACO,KAAA,cAAA;AACA,UAAA,sBAAA;AACP;AACA;AACO,UAAA,4BAAA,YAAA,sBAAA;AACP,gCAAA,cAAA,CAAA,gBAAA;AACA;AACO,UAAA,6BAAA,YAAA,sBAAA;AACP;AACA;AACA;AACA;AACO,UAAA,6BAAA,YAAA,4BAAA;AACP,mCAAA,gBAAA;AACA;AACA;AACA;AACA;AACO,UAAA,yBAAA,YAAA,4BAAA;AACP,sCAAA,WAAA,CAAA,gBAAA;AACA,uDAAA,gBAAA;AACA;AACA;AACA;;ACrBO,UAAA,oBAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClBA,UAAAA,OAAA,SAAA,KAAA,CAAA,mBAAA,CAAA,gBAAA;AACA,UAAA,KAAA,CAAA,GAAA,CAAA,gBAAA;AACA,aAAA,cAAA;AACA,8BAAA,QAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,cAAA,SAAA,sDAAAA,OAAA,KAAuF,iBAA2B,CAAA,GAAA,CAAA,OAAA;;ACXzH,UAAA,KAAA;AACA,cAAA,KAAA,CAAA,SAAA;AACA;AACO,cAAA,aAAA,iBAAA,KAAA,KAAsD,iBAA2B,CAAA,GAAA,CAAA,OAAA;;ACLjF,iBAAA,mBAAA,iBAAA,yBAAA,CAAA,oBAAA;AACA,iBAAA,mBAAA,qBAAA,6BAAA,CAAA,oBAAA;AACA,iBAAA,mBAAA,qBAAA,6BAAA,CAAA,oBAAA;AACA,iBAAA,mBAAA,UAAA,cAAA,GAAA,yBAAA,CAAA,oBAAA,IAAA,6BAAA,CAAA,oBAAA,IAAA,6BAAA,CAAA,oBAAA;;;;"}
@@ -0,0 +1,74 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React, { ClipboardEvent, ChangeEvent } from 'react';
3
+
4
+ type TargetPlatform = 'desktop' | 'ios' | 'android';
5
+ interface IKeystrokeHookTemplate<T> {
6
+ handleEndTypingSession: () => T | undefined;
7
+ }
8
+ interface IMobileKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {
9
+ handleProcessPaste: (event: ClipboardEvent<HTMLInputElement>) => void;
10
+ }
11
+ interface IDesktopKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {
12
+ getIsTypingSessionActive: () => boolean;
13
+ handleProcessKeydown: (key: string) => void;
14
+ handleProcessKeyup: (key: string) => void;
15
+ }
16
+ interface IAndroidKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {
17
+ handleProcessKeydown: (target: HTMLInputElement) => void;
18
+ handleProcessKeyInput: (inputContent: string) => void;
19
+ handleProcessKeyup: () => void;
20
+ handleProcessOnBeforeInput: (newValue: string, inputValue: string) => void;
21
+ }
22
+ interface IiOSKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {
23
+ handleProcessInputChange: (event: ChangeEvent<HTMLInputElement>, inputValue: string) => void;
24
+ handleProcessKeydown: (keyPressed: string, target: HTMLInputElement) => void;
25
+ handleProcessKeyup: (keyPressed: string) => void;
26
+ handleProcessOnBeforeInput: (value: number) => void;
27
+ }
28
+
29
+ interface A2DemoCapturePayload {
30
+ "session_id": string;
31
+ "temporal_kinematics": string[];
32
+ "spatial_kinematics": string[];
33
+ "type_kinematics": string[];
34
+ context?: {
35
+ "time": string;
36
+ "weekday": string;
37
+ "season": string;
38
+ "timezone": string;
39
+ };
40
+ extra_metadata?: {
41
+ "OS": string;
42
+ "browser": string;
43
+ };
44
+ device_context?: string;
45
+ assist_signals?: string;
46
+ }
47
+
48
+ interface Props$1 extends React.InputHTMLAttributes<HTMLInputElement> {
49
+ ref?: React.Ref<HTMLInputElement>;
50
+ target?: TargetPlatform;
51
+ handleEndSessionOnEnter?: Function;
52
+ }
53
+ /**
54
+ * Component that renders a text input field and generates an A2CapturePayload data.
55
+ *
56
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
57
+ * @param {TargetPlatform} [target] - Optional target platform ('ios', 'android', 'desktop'). If not provided, it will be auto-detected.
58
+ * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press (only for desktop).
59
+ */
60
+ declare const A2Textbox: ({ ref, target, handleEndSessionOnEnter, ...rest }: Props$1) => react_jsx_runtime.JSX.Element;
61
+
62
+ interface Props {
63
+ children: React.ReactNode;
64
+ }
65
+ declare const Area2Provider: ({ children }: Props) => react_jsx_runtime.JSX.Element;
66
+
67
+ declare function useKeystrokeBuilder(target: 'ios'): IiOSKeystrokeHookTemplate<A2DemoCapturePayload>;
68
+ declare function useKeystrokeBuilder(target: 'android'): IAndroidKeystrokeHookTemplate<A2DemoCapturePayload>;
69
+ declare function useKeystrokeBuilder(target: 'desktop'): IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;
70
+ declare function useKeystrokeBuilder(target?: TargetPlatform): IiOSKeystrokeHookTemplate<A2DemoCapturePayload> | IAndroidKeystrokeHookTemplate<A2DemoCapturePayload> | IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;
71
+
72
+ export { A2Textbox, Area2Provider, useKeystrokeBuilder as useCipherCapture };
73
+ export type { A2DemoCapturePayload, TargetPlatform };
74
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/interfaces/IKeystrokeHookTemplate.ts","../src/interfaces/IA2CapturePayload.ts","../src/components/A2Textbox.tsx","../src/context/area2/Area2Provider.tsx","../src/hooks/useKeystrokeBuilder.ts"],"sourcesContent":["import { ChangeEvent, ClipboardEvent } from \"react\";\n\nexport type TargetPlatform = 'desktop' | 'ios' | 'android';\n\n//* Common interface for keystroke hook templates\nexport interface IKeystrokeHookTemplate<T> {\n handleEndTypingSession: () => T | undefined;\n}\n\n//* Common interface for mobile keystroke hook template\nexport interface IMobileKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {\n handleProcessPaste: (event: ClipboardEvent<HTMLInputElement>) => void;\n}\n\n//? Interface for desktop keystroke hook\nexport interface IDesktopKeystrokeHookTemplate<T> extends IKeystrokeHookTemplate<T> {\n getIsTypingSessionActive: () => boolean;\n handleProcessKeydown: (key: string) => void;\n handleProcessKeyup: (key: string) => void;\n}\n\n//? Interface for android keystroke hook\nexport interface IAndroidKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {\n handleProcessKeydown: (target: HTMLInputElement) => void;\n handleProcessKeyInput: (inputContent: string) => void;\n handleProcessKeyup: () => void;\n handleProcessOnBeforeInput: (newValue: string, inputValue: string) => void;\n}\n\n//? Interface for iOS keystroke hook\nexport interface IiOSKeystrokeHookTemplate<T> extends IMobileKeystrokeHookTemplate<T> {\n handleProcessInputChange: (event: ChangeEvent<HTMLInputElement>, inputValue: string) => void;\n handleProcessKeydown: (keyPressed: string, target: HTMLInputElement) => void;\n handleProcessKeyup: (keyPressed: string) => void;\n handleProcessOnBeforeInput: (value: number) => void;\n //! processAutoCorrection: (textInputValue: string) => void;\n}","import {\n IMobileKeystrokeCollection,\n IKeystrokeCollection,\n IBaseKeystrokeCollection\n} from \"@area2-ai/a2-cipher-core\";\n\nexport interface A2CapturePayload\n extends IBaseKeystrokeCollection,\n Partial<Omit<IKeystrokeCollection, keyof IBaseKeystrokeCollection>>,\n Partial<Omit<IMobileKeystrokeCollection, keyof IBaseKeystrokeCollection>> { }\n\nexport interface A2DemoCapturePayload {\n \"session_id\": string,\n \"temporal_kinematics\": string[],\n \"spatial_kinematics\": string[],\n \"type_kinematics\": string[],\n context?: {\n \"time\": string,\n \"weekday\": string,\n \"season\": string,\n \"timezone\": string\n },\n extra_metadata?: {\n \"OS\": string,\n \"browser\": string\n },\n device_context?: string,\n assist_signals?: string\n}","import React from 'react';\nimport { getPlatform } from '../utils';\n\nimport { A2AndroidTextInput } from './A2AndroidTextInput';\nimport { A2IosTextInput } from './A2IosTextInput';\nimport { A2DesktopTextInput } from './A2DesktopTextInput';\n\nimport type { TargetPlatform } from '../interfaces';\n\ninterface Props extends React.InputHTMLAttributes<HTMLInputElement> {\n ref?: React.Ref<HTMLInputElement>;\n target?: TargetPlatform;\n handleEndSessionOnEnter?: Function;\n}\n\n/**\n * Component that renders a text input field and generates an A2CapturePayload data.\n * \n * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.\n * @param {TargetPlatform} [target] - Optional target platform ('ios', 'android', 'desktop'). If not provided, it will be auto-detected.\n * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press (only for desktop).\n */\nexport const A2Textbox = ({ ref, target, handleEndSessionOnEnter, ...rest }: Props) => {\n const targetPlatform = target ?? getPlatform();\n\n if (targetPlatform === 'android') {\n return (\n <A2AndroidTextInput {...rest} ref={ref} />\n )\n }\n\n if (targetPlatform === 'ios') {\n return (\n <A2IosTextInput {...rest} ref={ref} />\n )\n }\n\n return (\n <A2DesktopTextInput {...rest} ref={ref} handleEndSessionOnEnter={handleEndSessionOnEnter} />\n )\n}\n","import React, { useEffect, useReducer, useRef } from 'react';\nimport {\n KeystrokeManager,\n AndroidKeystrokeManager,\n IosKeystrokeManager\n} from '@area2-ai/a2-cipher-core';\n\nimport { Area2Context, area2Reducer } from '.';\n\nexport interface Area2State { }\n\ninterface Props {\n children: React.ReactNode;\n}\n\nconst AREA2_INITIAL_STATE: Area2State = {}\n\nexport const Area2Provider = ({ children }: Props) => {\n\n const [state] = useReducer(area2Reducer, AREA2_INITIAL_STATE); //[state, dispatch]\n\n const keystrokeManagerRef = useRef<KeystrokeManager>();\n const androidKeystrokeManagerRef = useRef<AndroidKeystrokeManager>();\n const iosKeystrokeManagerRef = useRef<IosKeystrokeManager>();\n\n const getKeystrokeManager = () => keystrokeManagerRef.current!;\n const getAndroidKeystrokeManager = () => androidKeystrokeManagerRef.current!;\n const getIosKeystrokeManager = () => iosKeystrokeManagerRef.current!;\n\n useEffect(() => {\n keystrokeManagerRef.current = new KeystrokeManager();\n androidKeystrokeManagerRef.current = new AndroidKeystrokeManager();\n iosKeystrokeManagerRef.current = new IosKeystrokeManager();\n }, []);\n\n return (\n <Area2Context.Provider value={{\n ...state,\n getKeystrokeManager,\n getAndroidKeystrokeManager,\n getIosKeystrokeManager\n }}>\n {children}\n </Area2Context.Provider>\n )\n}","import { getPlatform } from \"../utils\";\nimport type {\n TargetPlatform,\n IiOSKeystrokeHookTemplate,\n IAndroidKeystrokeHookTemplate,\n IDesktopKeystrokeHookTemplate,\n A2DemoCapturePayload\n} from \"../interfaces\";\n\nimport { useMobileKeystrokeAndroid } from \"./useKeystroke.android\";\nimport { useDesktopKeystroke } from \"./useKeystroke.desktop\";\nimport { useMobileKeystrokeIOS } from \"./useKeystroke.ios\";\n\nexport function useKeystrokeBuilder(target: 'ios'): IiOSKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target: 'android'): IAndroidKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target: 'desktop'): IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target?: TargetPlatform): IiOSKeystrokeHookTemplate<A2DemoCapturePayload> | IAndroidKeystrokeHookTemplate<A2DemoCapturePayload> | IDesktopKeystrokeHookTemplate<A2DemoCapturePayload>;\nexport function useKeystrokeBuilder(target?: TargetPlatform) {\n\n const targetPlatform = target ?? getPlatform();\n\n switch (targetPlatform) {\n case 'android':\n return useMobileKeystrokeAndroid();\n case 'ios':\n return useMobileKeystrokeIOS();\n case 'desktop':\n default:\n return useDesktopKeystroke();\n }\n\n}"],"names":["Props"],"mappings":";;;AACO,KAAA,cAAA;AACA,UAAA,sBAAA;AACP;AACA;AACO,UAAA,4BAAA,YAAA,sBAAA;AACP,gCAAA,cAAA,CAAA,gBAAA;AACA;AACO,UAAA,6BAAA,YAAA,sBAAA;AACP;AACA;AACA;AACA;AACO,UAAA,6BAAA,YAAA,4BAAA;AACP,mCAAA,gBAAA;AACA;AACA;AACA;AACA;AACO,UAAA,yBAAA,YAAA,4BAAA;AACP,sCAAA,WAAA,CAAA,gBAAA;AACA,uDAAA,gBAAA;AACA;AACA;AACA;;ACrBO,UAAA,oBAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClBA,UAAAA,OAAA,SAAA,KAAA,CAAA,mBAAA,CAAA,gBAAA;AACA,UAAA,KAAA,CAAA,GAAA,CAAA,gBAAA;AACA,aAAA,cAAA;AACA,8BAAA,QAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,cAAA,SAAA,sDAAAA,OAAA,KAAuF,iBAA2B,CAAA,GAAA,CAAA,OAAA;;ACXzH,UAAA,KAAA;AACA,cAAA,KAAA,CAAA,SAAA;AACA;AACO,cAAA,aAAA,iBAAA,KAAA,KAAsD,iBAA2B,CAAA,GAAA,CAAA,OAAA;;ACLjF,iBAAA,mBAAA,iBAAA,yBAAA,CAAA,oBAAA;AACA,iBAAA,mBAAA,qBAAA,6BAAA,CAAA,oBAAA;AACA,iBAAA,mBAAA,qBAAA,6BAAA,CAAA,oBAAA;AACA,iBAAA,mBAAA,UAAA,cAAA,GAAA,yBAAA,CAAA,oBAAA,IAAA,6BAAA,CAAA,oBAAA,IAAA,6BAAA,CAAA,oBAAA;;;;"}
package/dist/index.js ADDED
@@ -0,0 +1,420 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+ import { createContext, useReducer, useRef, useEffect, useContext, useCallback } from 'react';
3
+ import { KeystrokeManager, AndroidKeystrokeManager, IosKeystrokeManager } from '@area2-ai/a2-cipher-core';
4
+ import { browserName, osName, isAndroid, isDesktop } from 'react-device-detect';
5
+
6
+ const Area2Context = /*#__PURE__*/ createContext({});
7
+
8
+ const AREA2_INITIAL_STATE = {};
9
+ const Area2Provider = ({ children })=>{
10
+ const [state] = useReducer(area2Reducer, AREA2_INITIAL_STATE); //[state, dispatch]
11
+ const keystrokeManagerRef = useRef();
12
+ const androidKeystrokeManagerRef = useRef();
13
+ const iosKeystrokeManagerRef = useRef();
14
+ const getKeystrokeManager = ()=>keystrokeManagerRef.current;
15
+ const getAndroidKeystrokeManager = ()=>androidKeystrokeManagerRef.current;
16
+ const getIosKeystrokeManager = ()=>iosKeystrokeManagerRef.current;
17
+ useEffect(()=>{
18
+ keystrokeManagerRef.current = new KeystrokeManager();
19
+ androidKeystrokeManagerRef.current = new AndroidKeystrokeManager();
20
+ iosKeystrokeManagerRef.current = new IosKeystrokeManager();
21
+ }, []);
22
+ return /*#__PURE__*/ jsx(Area2Context.Provider, {
23
+ value: {
24
+ ...state,
25
+ getKeystrokeManager,
26
+ getAndroidKeystrokeManager,
27
+ getIosKeystrokeManager
28
+ },
29
+ children: children
30
+ });
31
+ };
32
+
33
+ const area2Reducer = (state, action)=>{
34
+ switch(action.type){
35
+ case '[A2 Desktop] - Update text':
36
+ return {
37
+ ...state,
38
+ desktopTextValue: action.payload.newValue
39
+ };
40
+ default:
41
+ return state;
42
+ }
43
+ };
44
+
45
+ const getBrowserInfo = ()=>browserName;
46
+
47
+ const getOsInfo = ()=>osName;
48
+
49
+ const getPlatform = ()=>{
50
+ if (isAndroid) return 'android';
51
+ if (isDesktop) return 'desktop';
52
+ return 'ios';
53
+ };
54
+
55
+ const formatDemoKeystrokeData = (payload, isMobile)=>{
56
+ const base = {
57
+ session_id: payload.sessionID.substring(0, 5) + '-[* * *]',
58
+ temporal_kinematics: [
59
+ '* * *'
60
+ ],
61
+ spatial_kinematics: [
62
+ '* * *'
63
+ ],
64
+ type_kinematics: [
65
+ '* * *'
66
+ ]
67
+ };
68
+ if (isMobile) {
69
+ base.device_context = '[* * *]';
70
+ base.assist_signals = '[* * *]';
71
+ } else {
72
+ base.context = {
73
+ time: '[* * *]',
74
+ weekday: '[* * *]',
75
+ season: '[* * *]',
76
+ timezone: '[* * *]'
77
+ };
78
+ base.extra_metadata = {
79
+ OS: '[* * *]',
80
+ browser: '[* * *]'
81
+ };
82
+ }
83
+ return base;
84
+ };
85
+
86
+ /**
87
+ * Keystroke hook for android mobile browser
88
+ */ const useMobileKeystrokeAndroid = ()=>{
89
+ const { getAndroidKeystrokeManager } = useContext(Area2Context);
90
+ /**
91
+ * Handles the before input event.
92
+ * @param {string} newValue - The new value of the input before the input event.
93
+ * @param {string} inputValue - The current value of the input.
94
+ */ const handleProcessOnBeforeInput = useCallback((newValue, inputValue)=>{
95
+ getAndroidKeystrokeManager().processBeforeInput(newValue, inputValue);
96
+ }, []);
97
+ /**
98
+ * Handles the paste event.
99
+ * @param {ClipboardEvent<HTMLInputElement>} event - The paste event.
100
+ */ const handleProcessPaste = useCallback((event)=>{
101
+ const pastedText = event.clipboardData.getData("text");
102
+ getAndroidKeystrokeManager().processPaste(pastedText);
103
+ }, []);
104
+ /**
105
+ * Handles the key input event.
106
+ * @param {string} inputContent - The content of the key input.
107
+ */ const handleProcessKeyInput = useCallback((inputContent)=>{
108
+ getAndroidKeystrokeManager().processKeyInput(inputContent);
109
+ }, []);
110
+ /**
111
+ * Handles the keydown event.
112
+ * @param {HTMLInputElement} target - The target input element.
113
+ */ const handleProcessKeydown = useCallback((target)=>{
114
+ getAndroidKeystrokeManager().processKeydown(target);
115
+ }, []);
116
+ /**
117
+ * Handles the keyup event.
118
+ */ const handleProcessKeyup = useCallback(()=>{
119
+ getAndroidKeystrokeManager().processKeyup();
120
+ }, []);
121
+ /**
122
+ * Ends the typing session and returns the typing data.
123
+ * @returns {A2CapturePayload | undefined} - The typing data or undefined if no data.
124
+ */ // const handleEndTypingSession = useCallback((): A2CapturePayload | undefined => {
125
+ // const typingData = getAndroidKeystrokeManager().endTypingSession();
126
+ // getAndroidKeystrokeManager().resetTypingData();
127
+ // if (!typingData.startUnixTime) {
128
+ // console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
129
+ // return;
130
+ // }
131
+ // typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
132
+ // return typingData;
133
+ // }, []);
134
+ /**
135
+ * Ends the demo typing session and returns the typing data.
136
+ * @returns {A2DemoCapturePayload | undefined} - The typing data or undefined if no data.
137
+ */ const handleEndDemoTypingSession = useCallback(()=>{
138
+ const typingData = getAndroidKeystrokeManager().endTypingSession();
139
+ getAndroidKeystrokeManager().resetTypingData();
140
+ if (!typingData.startUnixTime) {
141
+ console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
142
+ return;
143
+ }
144
+ typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
145
+ return formatDemoKeystrokeData(typingData, true);
146
+ }, []);
147
+ return {
148
+ handleProcessOnBeforeInput,
149
+ handleProcessPaste,
150
+ handleProcessKeyInput,
151
+ handleProcessKeydown,
152
+ handleProcessKeyup,
153
+ handleEndTypingSession: handleEndDemoTypingSession
154
+ };
155
+ };
156
+
157
+ /**
158
+ * Keystroke hook for desktop platforms.
159
+ */ const useDesktopKeystroke = ()=>{
160
+ const { getKeystrokeManager } = useContext(Area2Context);
161
+ const getIsTypingSessionActive = ()=>getKeystrokeManager().getIsTypingSessionActive;
162
+ /**
163
+ * Handles the keydown event.
164
+ * @param {string} key - The key pressed.
165
+ */ const handleProcessKeydown = useCallback((key)=>{
166
+ getKeystrokeManager().processKeydown(key);
167
+ }, []);
168
+ /**
169
+ * Handles the keyup event.
170
+ * @param {string} key - The key released.
171
+ */ const handleProcessKeyup = useCallback((key)=>{
172
+ getKeystrokeManager().processKeyup(key);
173
+ }, []);
174
+ /**
175
+ * Ends the typing session and returns the typing data.
176
+ * @returns {A2CapturePayload | undefined} - The typing session data or undefined if no data.
177
+ */ // const handleEndTypingSession = useCallback((): A2CapturePayload | undefined => {
178
+ // const typingData = getKeystrokeManager().endTypingSession();
179
+ // getKeystrokeManager().resetTypingData();
180
+ // if (!typingData.startUnixTime) {
181
+ // console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
182
+ // return;
183
+ // }
184
+ // typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
185
+ // return typingData;
186
+ // }, []);
187
+ /**
188
+ * Ends the demo typing session and returns the typing data.
189
+ * @returns {A2DemoCapturePayload | undefined} - The typing session data or undefined if no data.
190
+ */ const handleEndDemoTypingSession = useCallback(()=>{
191
+ const typingData = getKeystrokeManager().endTypingSession();
192
+ getKeystrokeManager().resetTypingData();
193
+ if (!typingData.startUnixTime) {
194
+ console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
195
+ return;
196
+ }
197
+ typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
198
+ return formatDemoKeystrokeData(typingData, false);
199
+ }, []);
200
+ return {
201
+ handleProcessKeydown,
202
+ handleProcessKeyup,
203
+ getIsTypingSessionActive,
204
+ handleEndTypingSession: handleEndDemoTypingSession
205
+ };
206
+ };
207
+
208
+ /**
209
+ * Keystroke for ios mobile browser
210
+ * @param {string} inputValue - The current value of the text input - Needed to detect auto-correct changes.
211
+ */ const useMobileKeystrokeIOS = ()=>{
212
+ const { getIosKeystrokeManager } = useContext(Area2Context);
213
+ //! Undefined behavior - Try to load via context - provider
214
+ /**
215
+ * Processes auto-correction based on the current input value.
216
+ * @param {string} inputValue - The current value of the text input.
217
+ */ // const processAutoCorrection = getIosKeystrokeManager().processAutocorrection;
218
+ /**
219
+ * Handles the before input event.
220
+ * @param {number} value - The length of the content before the input event.
221
+ */ const handleProcessOnBeforeInput = useCallback((value)=>{
222
+ getIosKeystrokeManager().setPrevContentLength = value;
223
+ }, []);
224
+ /**
225
+ * Handles the paste event.
226
+ * @param {ClipboardEvent<HTMLInputElement>} event - The paste event.
227
+ */ const handleProcessPaste = useCallback((event)=>{
228
+ const pastedText = event.clipboardData.getData("text");
229
+ getIosKeystrokeManager().processPaste(pastedText);
230
+ }, []);
231
+ /**
232
+ * Checks for text prediction and processes it.
233
+ * @param {string} newValue - The new value of the text input.
234
+ * @param {string} inputValue - The current value of the text input.
235
+ */ const checkForPrediction = useCallback((newValue, inputValue)=>{
236
+ const textSnapshot = inputValue; // Before it changes
237
+ getIosKeystrokeManager().processPrediction(newValue, textSnapshot);
238
+ }, []);
239
+ /**
240
+ * Handles the input change event
241
+ * @param {ChangeEvent<HTMLInputElement>} event - The input change event
242
+ * @param {string} inputValue - The current value of the text input
243
+ */ const handleProcessInputChange = (event, inputValue)=>{
244
+ const newValue = event.target.value;
245
+ checkForPrediction(newValue, inputValue);
246
+ };
247
+ /**
248
+ * Handles the keydown event.
249
+ * @param {string} keyPressed - The key that was pressed.
250
+ * @param {HTMLInputElement} target - The target input element.
251
+ */ const handleProcessKeydown = useCallback((keyPressed, target)=>{
252
+ getIosKeystrokeManager().processKeydown(keyPressed, target);
253
+ }, []);
254
+ /**
255
+ * Handles the keyup event.
256
+ * @param {string} key - The key that was released.
257
+ */ const handleProcessKeyup = useCallback((keyPressed)=>{
258
+ getIosKeystrokeManager().processKeyup(keyPressed);
259
+ }, []);
260
+ /**
261
+ * Ends the typing session and returns the typing data.
262
+ * @returns {A2CapturePayload | undefined} - The typing data or undefined if no data.
263
+ */ // const handleEndTypingSession = useCallback((): A2CapturePayload | undefined => {
264
+ // const typingData = getIosKeystrokeManager().endTypingSession();
265
+ // getIosKeystrokeManager().resetTypingData();
266
+ // if (!typingData.startUnixTime) {
267
+ // console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
268
+ // return;
269
+ // }
270
+ // typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
271
+ // return typingData;
272
+ // }, []);
273
+ /**
274
+ * Ends the demo typing session and returns the typing data.
275
+ * @returns {A2DemoCapturePayload | undefined} - The typing data or undefined if no data.
276
+ */ const handleEndDemoTypingSession = useCallback(()=>{
277
+ const typingData = getIosKeystrokeManager().endTypingSession();
278
+ getIosKeystrokeManager().resetTypingData();
279
+ if (!typingData.startUnixTime) {
280
+ console.warn(`Empty typing data for session: ${typingData.sessionID}. Skipping...`);
281
+ return;
282
+ }
283
+ typingData.appContext = `${getOsInfo()} - ${getBrowserInfo()}`;
284
+ return formatDemoKeystrokeData(typingData, true);
285
+ }, []);
286
+ return {
287
+ // processAutoCorrection,
288
+ handleProcessInputChange,
289
+ handleProcessKeydown,
290
+ handleProcessPaste,
291
+ handleProcessOnBeforeInput,
292
+ handleProcessKeyup,
293
+ handleEndTypingSession: handleEndDemoTypingSession
294
+ };
295
+ };
296
+
297
+ function useKeystrokeBuilder(target) {
298
+ const targetPlatform = target ?? getPlatform();
299
+ switch(targetPlatform){
300
+ case 'android':
301
+ return useMobileKeystrokeAndroid();
302
+ case 'ios':
303
+ return useMobileKeystrokeIOS();
304
+ case 'desktop':
305
+ default:
306
+ return useDesktopKeystroke();
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Component that renders a text input field and generates an A2CapturePayload data.
312
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
313
+ */ const A2AndroidTextInput = ({ ref, autoCapitalize, value, onChange, ...rest })=>{
314
+ const { handleProcessKeydown, handleProcessKeyup, handleProcessPaste, handleProcessKeyInput, handleProcessOnBeforeInput } = useMobileKeystrokeAndroid();
315
+ return /*#__PURE__*/ jsx(Fragment, {
316
+ children: /*#__PURE__*/ jsx("input", {
317
+ ref: ref,
318
+ type: "text",
319
+ placeholder: "Using android implementation",
320
+ autoCapitalize: autoCapitalize || 'sentences',
321
+ value: value,
322
+ onChange: onChange,
323
+ onKeyDown: ({ currentTarget })=>handleProcessKeydown(currentTarget),
324
+ onKeyUp: handleProcessKeyup,
325
+ onPaste: handleProcessPaste,
326
+ onInput: ({ currentTarget })=>{
327
+ handleProcessKeyInput(currentTarget.value);
328
+ },
329
+ onBeforeInput: ({ currentTarget })=>handleProcessOnBeforeInput(currentTarget.value, value?.toString() || ''),
330
+ ...rest
331
+ })
332
+ });
333
+ };
334
+
335
+ /**
336
+ * Component that renders a text input field and generates an A2CapturePayload data.
337
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
338
+ */ const A2IosTextInput = ({ ref, value, onChange, ...rest })=>{
339
+ const { handleProcessInputChange, handleProcessKeydown, handleProcessKeyup, handleProcessPaste, handleProcessOnBeforeInput } = useMobileKeystrokeIOS();
340
+ return /*#__PURE__*/ jsx(Fragment, {
341
+ children: /*#__PURE__*/ jsx("input", {
342
+ ref: ref,
343
+ type: "text",
344
+ placeholder: "Using iOS implementation",
345
+ onKeyDownCapture: ({ key, currentTarget })=>handleProcessKeydown(key, currentTarget),
346
+ onKeyUpCapture: ({ key })=>handleProcessKeyup(key),
347
+ value: value,
348
+ onChange: (event)=>{
349
+ handleProcessInputChange(event, value?.toString() || ''); //? Execute internal change handler
350
+ onChange?.(event); //? Execute parent's onChange if it exists
351
+ },
352
+ onPaste: handleProcessPaste,
353
+ onBeforeInput: ({ currentTarget })=>{
354
+ handleProcessOnBeforeInput(currentTarget.value.length);
355
+ },
356
+ ...rest
357
+ })
358
+ });
359
+ };
360
+
361
+ /**
362
+ * Component that renders a text input field and generates an A2CapturePayload data.
363
+ *
364
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
365
+ * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press.
366
+ */ const A2DesktopTextInput = ({ ref, onChange, handleEndSessionOnEnter, ...rest })=>{
367
+ const { handleProcessKeydown, handleProcessKeyup, getIsTypingSessionActive } = useDesktopKeystroke();
368
+ return /*#__PURE__*/ jsx(Fragment, {
369
+ children: /*#__PURE__*/ jsx("input", {
370
+ ref: ref,
371
+ type: "text",
372
+ placeholder: "Using desktop implementation",
373
+ onKeyDownCapture: ({ key })=>handleProcessKeydown(key),
374
+ onKeyUpCapture: ({ key })=>{
375
+ handleProcessKeyup(key);
376
+ //? Handle ENTER key
377
+ if (key !== 'Enter') {
378
+ return;
379
+ }
380
+ if (!getIsTypingSessionActive()) {
381
+ return;
382
+ }
383
+ handleEndSessionOnEnter?.(); //? Call parent's function if it exists
384
+ },
385
+ onChange: (event)=>{
386
+ onChange?.(event); //? Execute parent's onChange if it exists
387
+ },
388
+ ...rest
389
+ })
390
+ });
391
+ };
392
+
393
+ /**
394
+ * Component that renders a text input field and generates an A2CapturePayload data.
395
+ *
396
+ * @param {React.Ref<HTMLInputElement>} [ref] - Optional ref for the input element.
397
+ * @param {TargetPlatform} [target] - Optional target platform ('ios', 'android', 'desktop'). If not provided, it will be auto-detected.
398
+ * @param {Function} [handleEndSessionOnEnter] - Optional function to handle ending the session on Enter key press (only for desktop).
399
+ */ const A2Textbox = ({ ref, target, handleEndSessionOnEnter, ...rest })=>{
400
+ const targetPlatform = target ?? getPlatform();
401
+ if (targetPlatform === 'android') {
402
+ return /*#__PURE__*/ jsx(A2AndroidTextInput, {
403
+ ...rest,
404
+ ref: ref
405
+ });
406
+ }
407
+ if (targetPlatform === 'ios') {
408
+ return /*#__PURE__*/ jsx(A2IosTextInput, {
409
+ ...rest,
410
+ ref: ref
411
+ });
412
+ }
413
+ return /*#__PURE__*/ jsx(A2DesktopTextInput, {
414
+ ...rest,
415
+ ref: ref,
416
+ handleEndSessionOnEnter: handleEndSessionOnEnter
417
+ });
418
+ };
419
+
420
+ export { A2Textbox, Area2Provider, useKeystrokeBuilder as useCipherCapture };
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@area2-ai/a2-demo-cipher-react",
3
+ "version": "0.1.1",
4
+ "license": "MIT",
5
+ "author": "Area2 AI",
6
+ "description": "# a2-demo-cipher-react for demo purposes",
7
+ "type": "module",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./dist/index.d.cts",
19
+ "default": "./dist/index.cjs"
20
+ }
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "release": {
28
+ "branches": [
29
+ "main"
30
+ ]
31
+ },
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "registry": "https://registry.npmjs.org"
35
+ },
36
+ "engines": {
37
+ "node": ">=20"
38
+ },
39
+ "scripts": {
40
+ "dev": "tsdx dev",
41
+ "build": "tsdx build",
42
+ "test": "tsdx test",
43
+ "test:watch": "tsdx test --watch",
44
+ "lint": "tsdx lint",
45
+ "format": "tsdx format",
46
+ "format:check": "tsdx format --check",
47
+ "typecheck": "tsdx typecheck",
48
+ "prepublishOnly": "bun run build",
49
+ "push:npm": "np",
50
+ "login:npm": "npm login",
51
+ "test-who": "npm whoami"
52
+ },
53
+ "peerDependencies": {
54
+ "react": ">=18",
55
+ "react-dom": ">=18"
56
+ },
57
+ "devDependencies": {
58
+ "@testing-library/react": "^16.1.0",
59
+ "@types/node": "^22.10.2",
60
+ "@types/react": "^18.3.17",
61
+ "@types/react-dom": "^18.3.5",
62
+ "bunchee": "^6.9.3",
63
+ "jsdom": "^25.0.1",
64
+ "np": "^10.2.0",
65
+ "react": "^18.3.1",
66
+ "react-dom": "^18.3.1",
67
+ "tsdx": "^2.0.0",
68
+ "typescript": "^5.7.2",
69
+ "vitest": "^4.0.17"
70
+ },
71
+ "dependencies": {
72
+ "@area2-ai/a2-cipher-core": "^2.1.0",
73
+ "react-device-detect": "^2.2.3"
74
+ }
75
+ }