@ccheever/exact-ibex-runtime 0.1.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 (161) hide show
  1. package/package.json +63 -0
  2. package/src/abort/AbortController.ts +23 -0
  3. package/src/abort/AbortSignal.ts +152 -0
  4. package/src/abort/index.ts +2 -0
  5. package/src/accessibility.ts +12 -0
  6. package/src/arraybuffer-detach.ts +109 -0
  7. package/src/base64/base64.ts +168 -0
  8. package/src/base64/index.ts +1 -0
  9. package/src/blob/Blob.ts +259 -0
  10. package/src/blob/File.ts +59 -0
  11. package/src/blob/FormData.ts +323 -0
  12. package/src/blob/index.ts +3 -0
  13. package/src/bootstrap.ts +1946 -0
  14. package/src/broadcast/BroadcastChannel.ts +280 -0
  15. package/src/broadcast/index.ts +5 -0
  16. package/src/cache/Cache.ts +349 -0
  17. package/src/cache/CacheStorage.ts +89 -0
  18. package/src/cache/index.ts +27 -0
  19. package/src/camera/index.ts +6202 -0
  20. package/src/camera/processor.worker.ts +194 -0
  21. package/src/camera/scene.ts +195 -0
  22. package/src/clipboard/Clipboard.ts +129 -0
  23. package/src/clipboard/ClipboardItem.ts +97 -0
  24. package/src/clipboard/index.ts +6 -0
  25. package/src/clone/index.ts +1 -0
  26. package/src/clone/structuredClone.ts +389 -0
  27. package/src/clone/transferableSymbols.ts +2 -0
  28. package/src/compression/CompressionStream.ts +146 -0
  29. package/src/compression/DecompressionStream.ts +342 -0
  30. package/src/compression/index.ts +4 -0
  31. package/src/console/Console.ts +341 -0
  32. package/src/console/index.ts +2 -0
  33. package/src/core/accessibility-state.ts +263 -0
  34. package/src/core/accessibility.ts +184 -0
  35. package/src/core/agent-state.ts +37 -0
  36. package/src/core/diagnostics-logs.ts +144 -0
  37. package/src/core/host-call-bridge.ts +16 -0
  38. package/src/core/i18n-helpers.ts +189 -0
  39. package/src/core/locale-state.ts +253 -0
  40. package/src/core/locale.ts +95 -0
  41. package/src/crypto/Crypto.ts +2743 -0
  42. package/src/crypto/index.ts +1 -0
  43. package/src/diagnostics/logs.ts +7 -0
  44. package/src/encoding/TextDecoder.ts +1181 -0
  45. package/src/encoding/TextDecoderStream.ts +58 -0
  46. package/src/encoding/TextEncoder.ts +180 -0
  47. package/src/encoding/TextEncoderStream.ts +39 -0
  48. package/src/encoding/index.ts +8 -0
  49. package/src/events/CloseEvent.ts +91 -0
  50. package/src/events/DOMException.ts +409 -0
  51. package/src/events/ErrorEvent.ts +39 -0
  52. package/src/events/Event.ts +151 -0
  53. package/src/events/EventTarget.ts +280 -0
  54. package/src/events/FocusEvent.ts +27 -0
  55. package/src/events/KeyboardEvent.ts +46 -0
  56. package/src/events/MessageEvent.ts +61 -0
  57. package/src/events/ProgressEvent.ts +33 -0
  58. package/src/events/PromiseRejectionEvent.ts +31 -0
  59. package/src/events/index.ts +52 -0
  60. package/src/eventsource/EventSource.ts +371 -0
  61. package/src/eventsource/index.ts +2 -0
  62. package/src/fetch/Headers.ts +642 -0
  63. package/src/fetch/Request.ts +760 -0
  64. package/src/fetch/Response.ts +543 -0
  65. package/src/fetch/body.ts +1256 -0
  66. package/src/fetch/cookie-jar.ts +566 -0
  67. package/src/fetch/demo.ts +207 -0
  68. package/src/fetch/errors.ts +101 -0
  69. package/src/fetch/fetch.ts +2610 -0
  70. package/src/fetch/index.ts +101 -0
  71. package/src/fetch/native-bridge.ts +65 -0
  72. package/src/fetch/types.ts +258 -0
  73. package/src/filereader/FileReader.ts +236 -0
  74. package/src/filereader/index.ts +1 -0
  75. package/src/fs/Dirent.ts +39 -0
  76. package/src/fs/ExactFile.ts +450 -0
  77. package/src/fs/Stats.ts +80 -0
  78. package/src/fs/index.ts +944 -0
  79. package/src/fs/promises.ts +386 -0
  80. package/src/fs/shared.ts +328 -0
  81. package/src/http-server/index.js +697 -0
  82. package/src/http-server/index.ts +27 -0
  83. package/src/identity.generated.ts +14 -0
  84. package/src/index.ts +283 -0
  85. package/src/indexeddb/IDBCursor.ts +188 -0
  86. package/src/indexeddb/IDBDatabase.ts +343 -0
  87. package/src/indexeddb/IDBFactory.ts +269 -0
  88. package/src/indexeddb/IDBIndex.ts +194 -0
  89. package/src/indexeddb/IDBKeyRange.ts +109 -0
  90. package/src/indexeddb/IDBObjectStore.ts +468 -0
  91. package/src/indexeddb/IDBRequest.ts +163 -0
  92. package/src/indexeddb/IDBTransaction.ts +207 -0
  93. package/src/indexeddb/index.ts +34 -0
  94. package/src/indexeddb/utils.ts +52 -0
  95. package/src/inspect/index.ts +1 -0
  96. package/src/inspect/inspect.ts +465 -0
  97. package/src/internal/detect.ts +104 -0
  98. package/src/locale.ts +10 -0
  99. package/src/location/index.ts +1059 -0
  100. package/src/locks/LockManager.ts +460 -0
  101. package/src/locks/index.ts +12 -0
  102. package/src/media/VideoFrame.ts +58 -0
  103. package/src/messaging/MessageChannel.ts +31 -0
  104. package/src/messaging/MessagePort.ts +180 -0
  105. package/src/messaging/index.ts +2 -0
  106. package/src/messaging.ts +247 -0
  107. package/src/native/NativeModules.ts +354 -0
  108. package/src/native/index.ts +1 -0
  109. package/src/navigator/Navigator.ts +351 -0
  110. package/src/navigator/index.ts +1 -0
  111. package/src/node/Buffer.ts +1786 -0
  112. package/src/node/index.ts +4 -0
  113. package/src/node/path.ts +495 -0
  114. package/src/node/process.ts +2528 -0
  115. package/src/performance/Performance.ts +532 -0
  116. package/src/performance/index.ts +21 -0
  117. package/src/polyfills/array.ts +236 -0
  118. package/src/polyfills/arraybuffer.ts +172 -0
  119. package/src/polyfills/groupby.ts +85 -0
  120. package/src/polyfills/index.ts +85 -0
  121. package/src/polyfills/intl.ts +1956 -0
  122. package/src/polyfills/iterator.ts +479 -0
  123. package/src/polyfills/promise.ts +37 -0
  124. package/src/polyfills/set.ts +245 -0
  125. package/src/polyfills/string.ts +85 -0
  126. package/src/polyfills/typedarray.ts +110 -0
  127. package/src/promise-rejection-tracking.ts +464 -0
  128. package/src/react-native/index.ts +388 -0
  129. package/src/runtime-entry.ts +55 -0
  130. package/src/scheduling/AnimationFrame.ts +105 -0
  131. package/src/scheduling/IdleCallback.ts +167 -0
  132. package/src/scheduling/index.ts +13 -0
  133. package/src/security/Capabilities.ts +1146 -0
  134. package/src/security/Permissions.ts +392 -0
  135. package/src/security/capability-bits.generated.ts +63 -0
  136. package/src/security/index.ts +16 -0
  137. package/src/sqlite/Database.ts +456 -0
  138. package/src/sqlite/Statement.ts +206 -0
  139. package/src/sqlite/constants.ts +79 -0
  140. package/src/sqlite/errors.ts +25 -0
  141. package/src/sqlite/index.ts +34 -0
  142. package/src/sqlite/module.js +438 -0
  143. package/src/storage/Storage.ts +291 -0
  144. package/src/storage/StorageManager.ts +91 -0
  145. package/src/storage/index.ts +3 -0
  146. package/src/stream-compat.ts +47 -0
  147. package/src/streams/ReadableStream.ts +4131 -0
  148. package/src/streams/TransformStream.ts +375 -0
  149. package/src/streams/WritableStream.ts +866 -0
  150. package/src/streams/index.ts +41 -0
  151. package/src/timers/Timers.ts +296 -0
  152. package/src/timers/index.ts +11 -0
  153. package/src/url/URL.ts +656 -0
  154. package/src/url/URLPattern.ts +850 -0
  155. package/src/url/URLSearchParams.ts +244 -0
  156. package/src/url/index.ts +9 -0
  157. package/src/websocket/WebSocket.ts +770 -0
  158. package/src/websocket/WebSocketError.ts +52 -0
  159. package/src/websocket/WebSocketStream.ts +628 -0
  160. package/src/websocket/index.ts +7 -0
  161. package/src/window/index.ts +872 -0
@@ -0,0 +1,194 @@
1
+ /**
2
+ * IDBIndex - IndexedDB Index
3
+ *
4
+ * Provides access to a subset of data in an object store,
5
+ * with records sorted by the index key rather than the primary key.
6
+ *
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/IDBIndex
8
+ */
9
+
10
+ import { IDBRequest } from './IDBRequest';
11
+ import { IDBKeyRange } from './IDBKeyRange';
12
+ import { IDBCursorWithValue, type IDBCursorDirection } from './IDBCursor';
13
+
14
+ export interface IDBIndexParameters {
15
+ unique?: boolean;
16
+ multiEntry?: boolean;
17
+ }
18
+
19
+ export class IDBIndex {
20
+ readonly name: string;
21
+ readonly keyPath: string | string[];
22
+ readonly unique: boolean;
23
+ readonly multiEntry: boolean;
24
+ /** @internal */
25
+ _objectStore: any;
26
+
27
+ constructor(
28
+ name: string,
29
+ keyPath: string | string[],
30
+ options: IDBIndexParameters,
31
+ objectStore: any,
32
+ ) {
33
+ this.name = name;
34
+ this.keyPath = keyPath;
35
+ this.unique = options.unique ?? false;
36
+ this.multiEntry = options.multiEntry ?? false;
37
+ this._objectStore = objectStore;
38
+ }
39
+
40
+ get objectStore(): any {
41
+ return this._objectStore;
42
+ }
43
+
44
+ /**
45
+ * Retrieve the first record matching a key or key range from this index.
46
+ */
47
+ get(query: any): IDBRequest {
48
+ const request = new IDBRequest();
49
+ request.source = this;
50
+ try {
51
+ const records = this._getMatchingRecords(query);
52
+ request._resolve(records.length > 0 ? records[0].value : undefined);
53
+ } catch (e: any) {
54
+ request._reject(e);
55
+ }
56
+ return request;
57
+ }
58
+
59
+ /**
60
+ * Retrieve the key of the first record matching from this index.
61
+ */
62
+ getKey(query: any): IDBRequest {
63
+ const request = new IDBRequest();
64
+ request.source = this;
65
+ try {
66
+ const records = this._getMatchingRecords(query);
67
+ request._resolve(records.length > 0 ? records[0].primaryKey : undefined);
68
+ } catch (e: any) {
69
+ request._reject(e);
70
+ }
71
+ return request;
72
+ }
73
+
74
+ /**
75
+ * Retrieve all records matching from this index.
76
+ */
77
+ getAll(query?: any, count?: number): IDBRequest {
78
+ const request = new IDBRequest();
79
+ request.source = this;
80
+ try {
81
+ let records = this._getMatchingRecords(query);
82
+ if (count !== undefined && count >= 0) {
83
+ records = records.slice(0, count);
84
+ }
85
+ request._resolve(records.map(r => r.value));
86
+ } catch (e: any) {
87
+ request._reject(e);
88
+ }
89
+ return request;
90
+ }
91
+
92
+ /**
93
+ * Retrieve all keys matching from this index.
94
+ */
95
+ getAllKeys(query?: any, count?: number): IDBRequest {
96
+ const request = new IDBRequest();
97
+ request.source = this;
98
+ try {
99
+ let records = this._getMatchingRecords(query);
100
+ if (count !== undefined && count >= 0) {
101
+ records = records.slice(0, count);
102
+ }
103
+ request._resolve(records.map(r => r.primaryKey));
104
+ } catch (e: any) {
105
+ request._reject(e);
106
+ }
107
+ return request;
108
+ }
109
+
110
+ /**
111
+ * Count records matching a key or range in this index.
112
+ */
113
+ count(query?: any): IDBRequest {
114
+ const request = new IDBRequest();
115
+ request.source = this;
116
+ try {
117
+ const records = this._getMatchingRecords(query);
118
+ request._resolve(records.length);
119
+ } catch (e: any) {
120
+ request._reject(e);
121
+ }
122
+ return request;
123
+ }
124
+
125
+ /**
126
+ * Open a cursor over the index's records.
127
+ */
128
+ openCursor(query?: any, direction?: IDBCursorDirection): IDBRequest {
129
+ const request = new IDBRequest();
130
+ request.source = this;
131
+ try {
132
+ const records = this._getMatchingRecords(query);
133
+ if (records.length === 0) {
134
+ request._resolve(null);
135
+ } else {
136
+ const cursor = new IDBCursorWithValue(this, direction ?? 'next', records, request);
137
+ request._resolve(cursor);
138
+ }
139
+ } catch (e: any) {
140
+ request._reject(e);
141
+ }
142
+ return request;
143
+ }
144
+
145
+ /**
146
+ * Open a key cursor over the index.
147
+ */
148
+ openKeyCursor(query?: any, direction?: IDBCursorDirection): IDBRequest {
149
+ // Same as openCursor but without values - for simplicity we include values
150
+ return this.openCursor(query, direction);
151
+ }
152
+
153
+ /** @internal - Get records that match a query via this index */
154
+ _getMatchingRecords(query?: any): Array<{ key: any; primaryKey: any; value: any }> {
155
+ const keyPath = this.keyPath;
156
+ const allRecords = this._objectStore._getAllRecords();
157
+
158
+ // Extract index key from each record
159
+ const indexedRecords = allRecords.map((r: any) => ({
160
+ key: extractKeyPath(r.value, keyPath),
161
+ primaryKey: r.key,
162
+ value: r.value,
163
+ }));
164
+
165
+ if (query === undefined || query === null) {
166
+ return indexedRecords;
167
+ }
168
+
169
+ const range = query instanceof IDBKeyRange ? query : IDBKeyRange.only(query);
170
+ return indexedRecords.filter((r: any) => r.key !== undefined && range.includes(r.key));
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Extract a value from an object using a key path.
176
+ */
177
+ export function extractKeyPath(obj: any, keyPath: string | string[]): any {
178
+ if (obj === null || obj === undefined) return undefined;
179
+
180
+ if (Array.isArray(keyPath)) {
181
+ return keyPath.map(kp => extractSingleKeyPath(obj, kp));
182
+ }
183
+ return extractSingleKeyPath(obj, keyPath);
184
+ }
185
+
186
+ function extractSingleKeyPath(obj: any, keyPath: string): any {
187
+ const parts = keyPath.split('.');
188
+ let current = obj;
189
+ for (const part of parts) {
190
+ if (current === null || current === undefined) return undefined;
191
+ current = current[part];
192
+ }
193
+ return current;
194
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * IDBKeyRange - IndexedDB Key Range
3
+ *
4
+ * Represents a continuous interval over keys used for selecting records.
5
+ *
6
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/IDBKeyRange
7
+ */
8
+
9
+ import { DOMException } from './utils';
10
+
11
+ export class IDBKeyRange {
12
+ readonly lower: any;
13
+ readonly upper: any;
14
+ readonly lowerOpen: boolean;
15
+ readonly upperOpen: boolean;
16
+
17
+ constructor(lower: any, upper: any, lowerOpen: boolean, upperOpen: boolean) {
18
+ this.lower = lower;
19
+ this.upper = upper;
20
+ this.lowerOpen = lowerOpen;
21
+ this.upperOpen = upperOpen;
22
+ }
23
+
24
+ /**
25
+ * Check whether a key is within this range.
26
+ */
27
+ includes(key: any): boolean {
28
+ const cmp = compareKeys;
29
+ if (this.lower !== undefined) {
30
+ const lowerCmp = cmp(key, this.lower);
31
+ if (this.lowerOpen ? lowerCmp <= 0 : lowerCmp < 0) return false;
32
+ }
33
+ if (this.upper !== undefined) {
34
+ const upperCmp = cmp(key, this.upper);
35
+ if (this.upperOpen ? upperCmp >= 0 : upperCmp > 0) return false;
36
+ }
37
+ return true;
38
+ }
39
+
40
+ /**
41
+ * Creates a key range with only a lower bound.
42
+ */
43
+ static lowerBound(lower: any, open = false): IDBKeyRange {
44
+ return new IDBKeyRange(lower, undefined, open, true);
45
+ }
46
+
47
+ /**
48
+ * Creates a key range with only an upper bound.
49
+ */
50
+ static upperBound(upper: any, open = false): IDBKeyRange {
51
+ return new IDBKeyRange(undefined, upper, true, open);
52
+ }
53
+
54
+ /**
55
+ * Creates a key range with both lower and upper bounds.
56
+ */
57
+ static bound(lower: any, upper: any, lowerOpen = false, upperOpen = false): IDBKeyRange {
58
+ if (compareKeys(lower, upper) > 0) {
59
+ throw new DOMException('lower is greater than upper', 'DataError');
60
+ }
61
+ return new IDBKeyRange(lower, upper, lowerOpen, upperOpen);
62
+ }
63
+
64
+ /**
65
+ * Creates a key range containing a single key value.
66
+ */
67
+ static only(value: any): IDBKeyRange {
68
+ return new IDBKeyRange(value, value, false, false);
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Compare two IndexedDB keys per the spec ordering.
74
+ * Returns negative if a < b, positive if a > b, 0 if equal.
75
+ */
76
+ export function compareKeys(a: any, b: any): number {
77
+ // Type order: Array > String > Date > Number
78
+ const typeOrder = (v: any): number => {
79
+ if (Array.isArray(v)) return 4;
80
+ if (typeof v === 'string') return 3;
81
+ if (v instanceof Date) return 2;
82
+ if (typeof v === 'number') return 1;
83
+ return 0;
84
+ };
85
+
86
+ const ta = typeOrder(a);
87
+ const tb = typeOrder(b);
88
+ if (ta !== tb) return ta - tb;
89
+
90
+ if (typeof a === 'number' && typeof b === 'number') {
91
+ return a - b;
92
+ }
93
+ if (typeof a === 'string' && typeof b === 'string') {
94
+ return a < b ? -1 : a > b ? 1 : 0;
95
+ }
96
+ if (a instanceof Date && b instanceof Date) {
97
+ return a.getTime() - b.getTime();
98
+ }
99
+ if (Array.isArray(a) && Array.isArray(b)) {
100
+ const len = Math.min(a.length, b.length);
101
+ for (let i = 0; i < len; i++) {
102
+ const c = compareKeys(a[i], b[i]);
103
+ if (c !== 0) return c;
104
+ }
105
+ return a.length - b.length;
106
+ }
107
+ return 0;
108
+ }
109
+