@incodetech/core 2.0.0-alpha.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.
Files changed (84) hide show
  1. package/package.json +51 -0
  2. package/src/camera/cameraActor.ts +21 -0
  3. package/src/camera/cameraService.test.ts +437 -0
  4. package/src/camera/cameraService.ts +165 -0
  5. package/src/camera/cameraServices.test.ts +66 -0
  6. package/src/camera/cameraServices.ts +26 -0
  7. package/src/camera/cameraStateMachine.test.ts +602 -0
  8. package/src/camera/cameraStateMachine.ts +264 -0
  9. package/src/camera/index.ts +5 -0
  10. package/src/camera/types.ts +17 -0
  11. package/src/device/getBrowser.ts +31 -0
  12. package/src/device/getDeviceClass.ts +29 -0
  13. package/src/device/index.ts +2 -0
  14. package/src/email/__mocks__/emailMocks.ts +59 -0
  15. package/src/email/emailActor.ts +15 -0
  16. package/src/email/emailManager.test.ts +573 -0
  17. package/src/email/emailManager.ts +427 -0
  18. package/src/email/emailServices.ts +66 -0
  19. package/src/email/emailStateMachine.test.ts +741 -0
  20. package/src/email/emailStateMachine.ts +367 -0
  21. package/src/email/index.ts +39 -0
  22. package/src/email/types.ts +60 -0
  23. package/src/events/addEvent.ts +20 -0
  24. package/src/events/types.ts +7 -0
  25. package/src/flow/__mocks__/flowMocks.ts +84 -0
  26. package/src/flow/flowActor.ts +13 -0
  27. package/src/flow/flowAnalyzer.test.ts +266 -0
  28. package/src/flow/flowAnalyzer.ts +37 -0
  29. package/src/flow/flowCompletionService.ts +21 -0
  30. package/src/flow/flowManager.test.ts +560 -0
  31. package/src/flow/flowManager.ts +235 -0
  32. package/src/flow/flowServices.test.ts +109 -0
  33. package/src/flow/flowServices.ts +13 -0
  34. package/src/flow/flowStateMachine.test.ts +334 -0
  35. package/src/flow/flowStateMachine.ts +182 -0
  36. package/src/flow/index.ts +21 -0
  37. package/src/flow/moduleLoader.test.ts +136 -0
  38. package/src/flow/moduleLoader.ts +73 -0
  39. package/src/flow/orchestratedFlowManager.test.ts +240 -0
  40. package/src/flow/orchestratedFlowManager.ts +231 -0
  41. package/src/flow/orchestratedFlowStateMachine.test.ts +199 -0
  42. package/src/flow/orchestratedFlowStateMachine.ts +325 -0
  43. package/src/flow/types.ts +434 -0
  44. package/src/http/__mocks__/api.ts +88 -0
  45. package/src/http/api.test.ts +231 -0
  46. package/src/http/api.ts +90 -0
  47. package/src/http/endpoints.ts +17 -0
  48. package/src/index.ts +33 -0
  49. package/src/permissions/index.ts +2 -0
  50. package/src/permissions/permissionServices.ts +31 -0
  51. package/src/permissions/types.ts +3 -0
  52. package/src/phone/__mocks__/phoneMocks.ts +71 -0
  53. package/src/phone/index.ts +39 -0
  54. package/src/phone/phoneActor.ts +15 -0
  55. package/src/phone/phoneManager.test.ts +393 -0
  56. package/src/phone/phoneManager.ts +458 -0
  57. package/src/phone/phoneServices.ts +98 -0
  58. package/src/phone/phoneStateMachine.test.ts +918 -0
  59. package/src/phone/phoneStateMachine.ts +422 -0
  60. package/src/phone/types.ts +83 -0
  61. package/src/recordings/recordingsRepository.test.ts +87 -0
  62. package/src/recordings/recordingsRepository.ts +48 -0
  63. package/src/recordings/streamingEvents.ts +10 -0
  64. package/src/selfie/__mocks__/selfieMocks.ts +26 -0
  65. package/src/selfie/index.ts +14 -0
  66. package/src/selfie/selfieActor.ts +17 -0
  67. package/src/selfie/selfieErrorUtils.test.ts +116 -0
  68. package/src/selfie/selfieErrorUtils.ts +66 -0
  69. package/src/selfie/selfieManager.test.ts +297 -0
  70. package/src/selfie/selfieManager.ts +301 -0
  71. package/src/selfie/selfieServices.ts +362 -0
  72. package/src/selfie/selfieStateMachine.test.ts +283 -0
  73. package/src/selfie/selfieStateMachine.ts +804 -0
  74. package/src/selfie/selfieUploadService.test.ts +90 -0
  75. package/src/selfie/selfieUploadService.ts +81 -0
  76. package/src/selfie/types.ts +103 -0
  77. package/src/session/index.ts +5 -0
  78. package/src/session/sessionService.ts +78 -0
  79. package/src/setup.test.ts +61 -0
  80. package/src/setup.ts +171 -0
  81. package/tsconfig.json +13 -0
  82. package/tsdown.config.ts +22 -0
  83. package/vitest.config.ts +37 -0
  84. package/vitest.setup.ts +135 -0
@@ -0,0 +1,135 @@
1
+ // Polyfill ImageData for Node.js test environment
2
+ export {};
3
+
4
+ if (typeof ImageData === 'undefined') {
5
+ globalThis.ImageData = class ImageData {
6
+ data: Uint8ClampedArray;
7
+ width: number;
8
+ height: number;
9
+
10
+ constructor(width: number, height: number);
11
+ constructor(data: Uint8ClampedArray, width: number, height?: number);
12
+ constructor(
13
+ widthOrData: number | Uint8ClampedArray,
14
+ heightOrWidth?: number,
15
+ height?: number,
16
+ ) {
17
+ if (typeof widthOrData === 'number') {
18
+ this.width = widthOrData;
19
+ this.height = heightOrWidth ?? widthOrData;
20
+ this.data = new Uint8ClampedArray(this.width * this.height * 4);
21
+ } else {
22
+ this.data = widthOrData;
23
+ this.width = heightOrWidth ?? 0;
24
+ this.height = height ?? 0;
25
+ }
26
+ }
27
+ } as typeof ImageData;
28
+ }
29
+
30
+ // Polyfill DOM APIs for Node.js test environment
31
+ if (typeof document === 'undefined') {
32
+ const { JSDOM } = await import('jsdom');
33
+
34
+ const dom = new JSDOM('<!DOCTYPE html><html><body></body></html>', {
35
+ url: 'http://localhost',
36
+ pretendToBeVisual: true,
37
+ resources: 'usable',
38
+ });
39
+
40
+ globalThis.document = dom.window.document;
41
+ globalThis.window = dom.window as unknown as Window & typeof globalThis;
42
+
43
+ // Mock navigator.permissions for testing
44
+ // Use a simple function that can be replaced in tests
45
+ let permissionState: 'granted' | 'denied' | 'prompt' = 'prompt';
46
+ const mockPermissions = {
47
+ query: async () => ({ state: permissionState }),
48
+ };
49
+
50
+ Object.defineProperty(globalThis, 'navigator', {
51
+ value: {
52
+ ...dom.window.navigator,
53
+ permissions: mockPermissions,
54
+ },
55
+ writable: true,
56
+ configurable: true,
57
+ });
58
+
59
+ // Export setter for test control
60
+ (
61
+ globalThis as {
62
+ __setPermissionState?: (state: 'granted' | 'denied' | 'prompt') => void;
63
+ }
64
+ ).__setPermissionState = (state) => {
65
+ permissionState = state;
66
+ };
67
+
68
+ globalThis.HTMLVideoElement = dom.window.HTMLVideoElement;
69
+ globalThis.HTMLCanvasElement = dom.window.HTMLCanvasElement;
70
+ Object.defineProperty(globalThis.HTMLCanvasElement.prototype, 'getContext', {
71
+ value: () =>
72
+ ({
73
+ drawImage: () => {},
74
+ getImageData: () => new ImageData(1, 1),
75
+ putImageData: () => {},
76
+ clearRect: () => {},
77
+ }) as unknown as CanvasRenderingContext2D,
78
+ configurable: true,
79
+ });
80
+
81
+ if (!('HTMLMediaElement' in globalThis)) {
82
+ (
83
+ globalThis as { HTMLMediaElement: typeof dom.window.HTMLMediaElement }
84
+ ).HTMLMediaElement = dom.window.HTMLMediaElement;
85
+ }
86
+
87
+ Object.defineProperty(globalThis.HTMLMediaElement.prototype, 'play', {
88
+ value: () => Promise.resolve(),
89
+ configurable: true,
90
+ });
91
+ }
92
+
93
+ // Polyfill window for Node.js test environment
94
+ if (typeof window === 'undefined') {
95
+ (globalThis as { window: typeof globalThis }).window =
96
+ globalThis as typeof window;
97
+ (
98
+ globalThis as unknown as { window: { wasmArrayBuffer: null } }
99
+ ).window.wasmArrayBuffer = null;
100
+ }
101
+
102
+ // Polyfill MediaStream for Node.js test environment
103
+ if (typeof MediaStream === 'undefined') {
104
+ class MockMediaStream {
105
+ id = 'mock-stream-id';
106
+ active = true;
107
+ getVideoTracks() {
108
+ return [];
109
+ }
110
+ getAudioTracks() {
111
+ return [];
112
+ }
113
+ getTracks() {
114
+ return [];
115
+ }
116
+ getTrackById() {
117
+ return null;
118
+ }
119
+ addTrack() {}
120
+ removeTrack() {}
121
+ clone() {
122
+ return new MockMediaStream();
123
+ }
124
+ addEventListener() {}
125
+ removeEventListener() {}
126
+ dispatchEvent() {
127
+ return true;
128
+ }
129
+ onaddtrack = null;
130
+ onremovetrack = null;
131
+ }
132
+
133
+ (globalThis as unknown as { MediaStream: typeof MediaStream }).MediaStream =
134
+ MockMediaStream as unknown as typeof MediaStream;
135
+ }