@ac-kit/browser 0.1.1 → 0.3.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 (79) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +325 -4
  3. package/dist/animation-frame/frame-scheduler.d.ts +91 -0
  4. package/dist/animation-frame/frame-scheduler.d.ts.map +1 -0
  5. package/dist/animation-frame/frame-scheduler.js +181 -0
  6. package/dist/animation-frame/frame-scheduler.js.map +1 -0
  7. package/dist/canvas/canvas-backing-size.d.ts +58 -0
  8. package/dist/canvas/canvas-backing-size.d.ts.map +1 -0
  9. package/dist/canvas/canvas-backing-size.js +141 -0
  10. package/dist/canvas/canvas-backing-size.js.map +1 -0
  11. package/dist/canvas/image-data-pixels.d.ts +61 -0
  12. package/dist/canvas/image-data-pixels.d.ts.map +1 -0
  13. package/dist/canvas/image-data-pixels.js +71 -0
  14. package/dist/canvas/image-data-pixels.js.map +1 -0
  15. package/dist/canvas/read-image-data.d.ts +120 -0
  16. package/dist/canvas/read-image-data.d.ts.map +1 -0
  17. package/dist/canvas/read-image-data.js +147 -0
  18. package/dist/canvas/read-image-data.js.map +1 -0
  19. package/dist/dom/index.d.ts +4 -0
  20. package/dist/dom/index.d.ts.map +1 -0
  21. package/dist/dom/index.js +4 -0
  22. package/dist/dom/index.js.map +1 -0
  23. package/dist/dom/media-query/watch-media-query.d.ts +26 -0
  24. package/dist/dom/media-query/watch-media-query.d.ts.map +1 -0
  25. package/dist/dom/media-query/watch-media-query.js +42 -0
  26. package/dist/dom/media-query/watch-media-query.js.map +1 -0
  27. package/dist/dom/resize-observer/observe-canvas-size.d.ts +54 -0
  28. package/dist/dom/resize-observer/observe-canvas-size.d.ts.map +1 -0
  29. package/dist/dom/resize-observer/observe-canvas-size.js +189 -0
  30. package/dist/dom/resize-observer/observe-canvas-size.js.map +1 -0
  31. package/dist/dom/web-animations/wait-for-transitions.d.ts +59 -0
  32. package/dist/dom/web-animations/wait-for-transitions.d.ts.map +1 -0
  33. package/dist/dom/web-animations/wait-for-transitions.js +40 -0
  34. package/dist/dom/web-animations/wait-for-transitions.js.map +1 -0
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +6 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/indexeddb/open-indexed-db.d.ts +1 -1
  40. package/dist/indexeddb/open-indexed-db.d.ts.map +1 -1
  41. package/dist/indexeddb/open-indexed-db.js +2 -1
  42. package/dist/indexeddb/open-indexed-db.js.map +1 -1
  43. package/dist/media-capture/microphone-access.d.ts +116 -0
  44. package/dist/media-capture/microphone-access.d.ts.map +1 -0
  45. package/dist/media-capture/microphone-access.js +222 -0
  46. package/dist/media-capture/microphone-access.js.map +1 -0
  47. package/dist/testing/fake-animation-frames.d.ts +31 -0
  48. package/dist/testing/fake-animation-frames.d.ts.map +1 -0
  49. package/dist/testing/fake-animation-frames.js +75 -0
  50. package/dist/testing/fake-animation-frames.js.map +1 -0
  51. package/dist/testing/fake-audio-context.d.ts +174 -0
  52. package/dist/testing/fake-audio-context.d.ts.map +1 -0
  53. package/dist/testing/fake-audio-context.js +314 -0
  54. package/dist/testing/fake-audio-context.js.map +1 -0
  55. package/dist/testing/fake-match-media.d.ts +19 -0
  56. package/dist/testing/fake-match-media.d.ts.map +1 -0
  57. package/dist/testing/fake-match-media.js +135 -0
  58. package/dist/testing/fake-match-media.js.map +1 -0
  59. package/dist/testing/fake-media-devices.d.ts +90 -0
  60. package/dist/testing/fake-media-devices.d.ts.map +1 -0
  61. package/dist/testing/fake-media-devices.js +147 -0
  62. package/dist/testing/fake-media-devices.js.map +1 -0
  63. package/dist/testing/fake-resize-observer.d.ts +58 -0
  64. package/dist/testing/fake-resize-observer.d.ts.map +1 -0
  65. package/dist/testing/fake-resize-observer.js +118 -0
  66. package/dist/testing/fake-resize-observer.js.map +1 -0
  67. package/dist/testing/fake-web-midi.d.ts +25 -0
  68. package/dist/testing/fake-web-midi.d.ts.map +1 -0
  69. package/dist/testing/fake-web-midi.js +52 -0
  70. package/dist/testing/fake-web-midi.js.map +1 -0
  71. package/dist/testing/index.d.ts +7 -0
  72. package/dist/testing/index.d.ts.map +1 -0
  73. package/dist/testing/index.js +7 -0
  74. package/dist/testing/index.js.map +1 -0
  75. package/dist/web-audio/audio-clock-mapping.d.ts +124 -0
  76. package/dist/web-audio/audio-clock-mapping.d.ts.map +1 -0
  77. package/dist/web-audio/audio-clock-mapping.js +245 -0
  78. package/dist/web-audio/audio-clock-mapping.js.map +1 -0
  79. package/package.json +23 -7
@@ -0,0 +1,124 @@
1
+ /** How an {@link AudioClockMapping} reads its ticks. */
2
+ export type AudioClockMappingOptions = {
3
+ /** How far back the offset is the minimum over, in milliseconds of page time. */
4
+ readonly windowMs: number;
5
+ /**
6
+ * The step, in milliseconds, that tells the audio clock was re-anchored: a
7
+ * tick that far below the offset, or `readyTicks` steady ticks in a row, all
8
+ * within the window, that far above it.
9
+ */
10
+ readonly jumpMs: number;
11
+ /**
12
+ * How much, in milliseconds, the offsets of `readyTicks` ticks may differ and
13
+ * still be one step in the audio clock, not jank or a backlog draining (whose
14
+ * offsets keep falling).
15
+ */
16
+ readonly steadyMs: number;
17
+ /** How many ticks since a reset make the mapping ready; a positive integer. */
18
+ readonly readyTicks: number;
19
+ /**
20
+ * How far the minimum lands above the true offset, taken off the offset, in
21
+ * milliseconds. Default 0.
22
+ */
23
+ readonly biasMs?: number;
24
+ };
25
+ /**
26
+ * The mapping between an audio clock (the time of the samples an `AudioContext`
27
+ * or an `AudioWorklet` has processed) and `performance.now()`, from ticks the
28
+ * audio thread posts: a tick carries the audio time it was posted at, and the
29
+ * page notes the time it received it.
30
+ *
31
+ * A tick can only arrive late, never early, so the offset is the minimum of
32
+ * `received − audio time` over a window: jank on the page's thread falls out,
33
+ * and what is left is the posting delay, within one render quantum of the true
34
+ * one (`biasMs` takes off a steady remainder). The mapping starts again when
35
+ * the clock is re-anchored: a context suspended and resumed, a worklet
36
+ * restarted ({@link AudioClockMapping.reset}), or a step the ticks show. A step
37
+ * up is taken from `readyTicks` ticks in a row within the window; when that
38
+ * many do not fit in it, the window adopts the new offset alone once the older
39
+ * ticks leave it.
40
+ *
41
+ * It reads no clock and no global: the caller passes both times, so it runs in
42
+ * a worker or under Node as well.
43
+ *
44
+ * Time complexity: O(n) per {@link AudioClockMapping.observe}, n the ticks in
45
+ * the window (a scan for their minimum, and O(readyTicks) more when a step up
46
+ * is checked); O(n) for {@link AudioClockMapping.offsetMs},
47
+ * {@link AudioClockMapping.toPageMs} and {@link AudioClockMapping.toAudioMs}.
48
+ * Memory: O(n), the most ticks the window has held, in a ring buffer that grows
49
+ * by doubling and never shrinks: a tick allocates nothing otherwise.
50
+ *
51
+ * @example
52
+ * const mapping = new AudioClockMapping({
53
+ * windowMs: 2000,
54
+ * jumpMs: 50,
55
+ * steadyMs: 5,
56
+ * readyTicks: 5,
57
+ * });
58
+ * port.onmessage = ({ data }) =>
59
+ * mapping.observe((data.frame / sampleRate) * 1000, performance.now());
60
+ * if (mapping.isReady) {
61
+ * const pageMs = mapping.toPageMs(dueAudioMs);
62
+ * }
63
+ */
64
+ export declare class AudioClockMapping {
65
+ private readonly windowMs_;
66
+ private readonly jumpMs_;
67
+ private readonly steadyMs_;
68
+ private readonly readyTicks_;
69
+ private readonly biasMs_;
70
+ private pages_;
71
+ private offsets_;
72
+ private head_;
73
+ private size_;
74
+ private runLength_;
75
+ private tickCount_;
76
+ private resetCount_;
77
+ private lastAudioMs_;
78
+ private lastPageMs_;
79
+ /** @throws {RangeError} On an option that is not valid. */
80
+ constructor(options: AudioClockMappingOptions);
81
+ /** Whether `readyTicks` ticks have come since the last reset. */
82
+ get isReady(): boolean;
83
+ /** How many times the mapping started again, by {@link reset} or by a step. */
84
+ get resetCount(): number;
85
+ /**
86
+ * Page time minus audio time, in milliseconds, or `undefined` until the
87
+ * mapping is ready.
88
+ */
89
+ get offsetMs(): number | undefined;
90
+ /**
91
+ * Notes a tick: the audio time it was posted at and the page time it arrived.
92
+ *
93
+ * @throws {RangeError} On a time that is not finite, or a page time earlier
94
+ * than the previous tick's.
95
+ */
96
+ observe(audioMs: number, pageMs: number): void;
97
+ /**
98
+ * Starts again: for the audio clock re-anchored, as when the context's
99
+ * `statechange` reports it suspended, or the worklet restarted.
100
+ */
101
+ reset(): void;
102
+ /**
103
+ * The page time of `audioMs`.
104
+ *
105
+ * @throws {Error} Before the mapping is ready.
106
+ */
107
+ toPageMs(audioMs: number): number;
108
+ /**
109
+ * The audio time of `pageMs`.
110
+ *
111
+ * @throws {Error} Before the mapping is ready.
112
+ */
113
+ toAudioMs(pageMs: number): number;
114
+ private restart_;
115
+ private readyOffset_;
116
+ private slot_;
117
+ private minimumOffset_;
118
+ private windowMinimum_;
119
+ private isStepDown_;
120
+ private add_;
121
+ private grow_;
122
+ private trackStepUp_;
123
+ }
124
+ //# sourceMappingURL=audio-clock-mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio-clock-mapping.d.ts","sourceRoot":"","sources":["../../src/web-audio/audio-clock-mapping.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,wBAAwB,GAAG;IACtC,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAA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Worklet` has processed) and `performance.now()`, from ticks the
5
+ * audio thread posts: a tick carries the audio time it was posted at, and the
6
+ * page notes the time it received it.
7
+ *
8
+ * A tick can only arrive late, never early, so the offset is the minimum of
9
+ * `received − audio time` over a window: jank on the page's thread falls out,
10
+ * and what is left is the posting delay, within one render quantum of the true
11
+ * one (`biasMs` takes off a steady remainder). The mapping starts again when
12
+ * the clock is re-anchored: a context suspended and resumed, a worklet
13
+ * restarted ({@link AudioClockMapping.reset}), or a step the ticks show. A step
14
+ * up is taken from `readyTicks` ticks in a row within the window; when that
15
+ * many do not fit in it, the window adopts the new offset alone once the older
16
+ * ticks leave it.
17
+ *
18
+ * It reads no clock and no global: the caller passes both times, so it runs in
19
+ * a worker or under Node as well.
20
+ *
21
+ * Time complexity: O(n) per {@link AudioClockMapping.observe}, n the ticks in
22
+ * the window (a scan for their minimum, and O(readyTicks) more when a step up
23
+ * is checked); O(n) for {@link AudioClockMapping.offsetMs},
24
+ * {@link AudioClockMapping.toPageMs} and {@link AudioClockMapping.toAudioMs}.
25
+ * Memory: O(n), the most ticks the window has held, in a ring buffer that grows
26
+ * by doubling and never shrinks: a tick allocates nothing otherwise.
27
+ *
28
+ * @example
29
+ * const mapping = new AudioClockMapping({
30
+ * windowMs: 2000,
31
+ * jumpMs: 50,
32
+ * steadyMs: 5,
33
+ * readyTicks: 5,
34
+ * });
35
+ * port.onmessage = ({ data }) =>
36
+ * mapping.observe((data.frame / sampleRate) * 1000, performance.now());
37
+ * if (mapping.isReady) {
38
+ * const pageMs = mapping.toPageMs(dueAudioMs);
39
+ * }
40
+ */
41
+ export class AudioClockMapping {
42
+ windowMs_;
43
+ jumpMs_;
44
+ steadyMs_;
45
+ readyTicks_;
46
+ biasMs_;
47
+ // The ticks of the window, oldest first, in a ring buffer: the page time each
48
+ // arrived at and its offset.
49
+ pages_ = new Float64Array(INITIAL_CAPACITY_);
50
+ offsets_ = new Float64Array(INITIAL_CAPACITY_);
51
+ head_ = 0;
52
+ size_ = 0;
53
+ // How many of the latest ticks of the window sit each more than `jumpMs`
54
+ // above the minimum of the ticks before it, up to `readyTicks`.
55
+ runLength_ = 0;
56
+ tickCount_ = 0;
57
+ resetCount_ = 0;
58
+ lastAudioMs_ = -Infinity;
59
+ lastPageMs_ = -Infinity;
60
+ /** @throws {RangeError} On an option that is not valid. */
61
+ constructor(options) {
62
+ const { windowMs, jumpMs, steadyMs, readyTicks, biasMs = 0 } = options;
63
+ if (!(Number.isFinite(windowMs) && windowMs > 0)) {
64
+ throw new RangeError("windowMs must be a positive number");
65
+ }
66
+ if (!(Number.isFinite(jumpMs) && jumpMs >= 0)) {
67
+ throw new RangeError("jumpMs must be a non-negative number");
68
+ }
69
+ if (!(Number.isFinite(steadyMs) && steadyMs >= 0)) {
70
+ throw new RangeError("steadyMs must be a non-negative number");
71
+ }
72
+ if (!Number.isInteger(readyTicks) || readyTicks < 1) {
73
+ throw new RangeError("readyTicks must be a positive integer");
74
+ }
75
+ if (!Number.isFinite(biasMs)) {
76
+ throw new RangeError("biasMs must be a finite number");
77
+ }
78
+ this.windowMs_ = windowMs;
79
+ this.jumpMs_ = jumpMs;
80
+ this.steadyMs_ = steadyMs;
81
+ this.readyTicks_ = readyTicks;
82
+ this.biasMs_ = biasMs;
83
+ }
84
+ /** Whether `readyTicks` ticks have come since the last reset. */
85
+ get isReady() {
86
+ return this.tickCount_ >= this.readyTicks_;
87
+ }
88
+ /** How many times the mapping started again, by {@link reset} or by a step. */
89
+ get resetCount() {
90
+ return this.resetCount_;
91
+ }
92
+ /**
93
+ * Page time minus audio time, in milliseconds, or `undefined` until the
94
+ * mapping is ready.
95
+ */
96
+ get offsetMs() {
97
+ if (!this.isReady) {
98
+ return undefined;
99
+ }
100
+ return this.windowMinimum_() - this.biasMs_;
101
+ }
102
+ /**
103
+ * Notes a tick: the audio time it was posted at and the page time it arrived.
104
+ *
105
+ * @throws {RangeError} On a time that is not finite, or a page time earlier
106
+ * than the previous tick's.
107
+ */
108
+ observe(audioMs, pageMs) {
109
+ if (!(Number.isFinite(audioMs) && Number.isFinite(pageMs))) {
110
+ throw new RangeError("a tick's times must be finite");
111
+ }
112
+ if (pageMs < this.lastPageMs_) {
113
+ throw new RangeError("a tick cannot arrive before the previous one");
114
+ }
115
+ const offsetMs = pageMs - audioMs;
116
+ if (audioMs < this.lastAudioMs_ || this.isStepDown_(offsetMs)) {
117
+ this.restart_();
118
+ }
119
+ this.lastAudioMs_ = audioMs;
120
+ this.lastPageMs_ = pageMs;
121
+ this.add_(pageMs, offsetMs);
122
+ this.trackStepUp_(offsetMs);
123
+ }
124
+ /**
125
+ * Starts again: for the audio clock re-anchored, as when the context's
126
+ * `statechange` reports it suspended, or the worklet restarted.
127
+ */
128
+ reset() {
129
+ this.restart_();
130
+ this.lastAudioMs_ = -Infinity;
131
+ }
132
+ /**
133
+ * The page time of `audioMs`.
134
+ *
135
+ * @throws {Error} Before the mapping is ready.
136
+ */
137
+ toPageMs(audioMs) {
138
+ return audioMs + this.readyOffset_();
139
+ }
140
+ /**
141
+ * The audio time of `pageMs`.
142
+ *
143
+ * @throws {Error} Before the mapping is ready.
144
+ */
145
+ toAudioMs(pageMs) {
146
+ return pageMs - this.readyOffset_();
147
+ }
148
+ restart_() {
149
+ this.head_ = 0;
150
+ this.size_ = 0;
151
+ this.runLength_ = 0;
152
+ this.tickCount_ = 0;
153
+ this.resetCount_ += 1;
154
+ }
155
+ readyOffset_() {
156
+ const offset = this.offsetMs;
157
+ if (offset === undefined) {
158
+ throw new Error("the audio clock mapping is not ready");
159
+ }
160
+ return offset;
161
+ }
162
+ slot_(position) {
163
+ return (this.head_ + position) % this.pages_.length;
164
+ }
165
+ // The least offset of the `count` oldest ticks of the window.
166
+ minimumOffset_(count) {
167
+ let minimum = Infinity;
168
+ for (let position = 0; position < count; position += 1) {
169
+ minimum = Math.min(minimum, this.offsets_[this.slot_(position)]);
170
+ }
171
+ return minimum;
172
+ }
173
+ windowMinimum_() {
174
+ return this.minimumOffset_(this.size_);
175
+ }
176
+ isStepDown_(offsetMs) {
177
+ return this.size_ > 0 && offsetMs < this.windowMinimum_() - this.jumpMs_;
178
+ }
179
+ add_(pageMs, offsetMs) {
180
+ if (this.size_ === this.pages_.length) {
181
+ this.grow_();
182
+ }
183
+ const slot = this.slot_(this.size_);
184
+ this.pages_[slot] = pageMs;
185
+ this.offsets_[slot] = offsetMs;
186
+ this.size_ += 1;
187
+ this.tickCount_ += 1;
188
+ const oldest = pageMs - this.windowMs_;
189
+ while (this.pages_[this.head_] < oldest) {
190
+ this.head_ = (this.head_ + 1) % this.pages_.length;
191
+ this.size_ -= 1;
192
+ }
193
+ }
194
+ grow_() {
195
+ const capacity = this.pages_.length * 2;
196
+ const pages = new Float64Array(capacity);
197
+ const offsets = new Float64Array(capacity);
198
+ for (let position = 0; position < this.size_; position += 1) {
199
+ const slot = this.slot_(position);
200
+ pages[position] = this.pages_[slot];
201
+ offsets[position] = this.offsets_[slot];
202
+ }
203
+ this.pages_ = pages;
204
+ this.offsets_ = offsets;
205
+ this.head_ = 0;
206
+ }
207
+ trackStepUp_(offsetMs) {
208
+ const earlierCount = this.size_ - 1;
209
+ if (earlierCount === 0 ||
210
+ offsetMs <= this.minimumOffset_(earlierCount) + this.jumpMs_) {
211
+ this.runLength_ = 0;
212
+ return;
213
+ }
214
+ // The run is the latest ticks of the window: those that left it are no
215
+ // longer part of it.
216
+ this.runLength_ =
217
+ Math.min(this.runLength_, earlierCount, this.readyTicks_ - 1) + 1;
218
+ if (this.runLength_ < this.readyTicks_) {
219
+ return;
220
+ }
221
+ // A step in the audio clock leaves the offset flat from then on, within
222
+ // jitter. Jank spreads the offsets, and a backlog draining after a freeze
223
+ // is ticks each handled in a task shorter than their interval, so their
224
+ // offsets keep falling: a fall of more than half the tolerance is no step.
225
+ const first = this.size_ - this.runLength_;
226
+ let highest = -Infinity;
227
+ let lowest = Infinity;
228
+ for (let position = first; position < this.size_; position += 1) {
229
+ const offset = this.offsets_[this.slot_(position)];
230
+ highest = Math.max(highest, offset);
231
+ lowest = Math.min(lowest, offset);
232
+ }
233
+ const fall = this.offsets_[this.slot_(first)] - offsetMs;
234
+ if (highest - lowest > this.steadyMs_ || fall > this.steadyMs_ / 2) {
235
+ return;
236
+ }
237
+ // Start again from the run alone.
238
+ this.head_ = this.slot_(first);
239
+ this.size_ = this.runLength_;
240
+ this.tickCount_ = this.runLength_;
241
+ this.runLength_ = 0;
242
+ this.resetCount_ += 1;
243
+ }
244
+ }
245
+ //# sourceMappingURL=audio-clock-mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio-clock-mapping.js","sourceRoot":"","sources":["../../src/web-audio/audio-clock-mapping.ts"],"names":[],"mappings":"AAyBA,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,OAAO,iBAAiB;IACZ,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,WAAW,CAAS;IACpB,OAAO,CAAS;IACjC,8EAA8E;IAC9E,6BAA6B;IACrB,MAAM,GAAG,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAC7C,QAAQ,GAAG,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAC/C,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAG,CAAC,CAAC;IAClB,yEAAyE;IACzE,gEAAgE;IACxD,UAAU,GAAG,CAAC,CAAC;IACf,UAAU,GAAG,CAAC,CAAC;IACf,WAAW,GAAG,CAAC,CAAC;IAChB,YAAY,GAAG,CAAC,QAAQ,CAAC;IACzB,WAAW,GAAG,CAAC,QAAQ,CAAC;IAEhC,2DAA2D;IAC3D,YAAY,OAAiC;QAC5C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC;QACvE,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC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E,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAE,GAAG,QAAQ,CAAC;QAC1D,IAAI,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;YACpE,OAAO;QACR,CAAC;QACD,kCAAkC;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC;IACvB,CAAC;CACD"}
package/package.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "name": "@ac-kit/browser",
3
- "version": "0.1.1",
4
- "description": "Browser extensions and zero-dependency wrappers over browser APIs: IndexedDB as promises with versioned upgrades, Web MIDI access with input ports followed by name across reloads and hot-plugs, and requests reporting their upload progress over XMLHttpRequest.",
3
+ "version": "0.3.0",
4
+ "description": "Browser extensions and zero-dependency wrappers over browser APIs: IndexedDB as promises with versioned upgrades, Web MIDI access with input ports followed by name across reloads and hot-plugs, the microphone opened for analysis with its permission and devices, an audio clock mapped onto the page's, requests reporting their upload progress over XMLHttpRequest, image pixels read through a canvas, scaled down, a canvas's backing store kept at its displayed size, frame scheduling, and the wait for an element's CSS transitions.",
5
5
  "keywords": [
6
+ "animation-frame",
7
+ "audio-clock",
8
+ "audio-worklet",
6
9
  "browser",
10
+ "canvas",
11
+ "css-transitions",
12
+ "getusermedia",
13
+ "image-data",
7
14
  "indexeddb",
15
+ "microphone",
8
16
  "midi",
9
17
  "storage",
10
18
  "upload-progress",
19
+ "web-animations",
20
+ "web-audio",
11
21
  "web-midi",
12
22
  "xmlhttprequest"
13
23
  ],
@@ -29,12 +39,16 @@
29
39
  "sideEffects": false,
30
40
  "main": "./dist/index.js",
31
41
  "exports": {
32
- ".": "./dist/index.js"
42
+ ".": "./dist/index.js",
43
+ "./dom": "./dist/dom/index.js",
44
+ "./testing": "./dist/testing/index.js"
33
45
  },
34
46
  "publishConfig": {
35
47
  "main": "./dist/index.js",
36
48
  "exports": {
37
- ".": "./dist/index.js"
49
+ ".": "./dist/index.js",
50
+ "./dom": "./dist/dom/index.js",
51
+ "./testing": "./dist/testing/index.js"
38
52
  },
39
53
  "access": "public"
40
54
  },
@@ -47,14 +61,16 @@
47
61
  "prepack": "yarn build"
48
62
  },
49
63
  "dependencies": {
50
- "@ac-kit/async": "^0.6.0",
51
- "@ac-kit/core": "^0.10.0",
64
+ "@ac-kit/async": "^0.8.0",
65
+ "@ac-kit/core": "^0.12.0",
52
66
  "@types/web": "^0.0.367"
53
67
  },
54
68
  "devDependencies": {
69
+ "@ac-kit/math-random": "0.4.0",
70
+ "@ac-kit/test-util": "0.4.0",
55
71
  "@ac-kit/tsconfig": "0.1.0",
56
72
  "@ac-kit/typedoc-config": "0.1.0",
57
- "@ac-kit/vitest-config": "0.1.1",
73
+ "@ac-kit/vitest-config": "0.2.0",
58
74
  "@typescript/native": "typescript@7.0.2",
59
75
  "fake-indexeddb": "6.2.8",
60
76
  "rimraf": "6.1.4",