@ac-kit/browser 0.2.0 → 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.
- package/CHANGELOG.md +60 -0
- package/README.md +69 -2
- package/dist/animation-frame/frame-scheduler.d.ts +91 -0
- package/dist/animation-frame/frame-scheduler.d.ts.map +1 -0
- package/dist/animation-frame/frame-scheduler.js +181 -0
- package/dist/animation-frame/frame-scheduler.js.map +1 -0
- package/dist/canvas/canvas-backing-size.d.ts +58 -0
- package/dist/canvas/canvas-backing-size.d.ts.map +1 -0
- package/dist/canvas/canvas-backing-size.js +141 -0
- package/dist/canvas/canvas-backing-size.js.map +1 -0
- package/dist/canvas/image-data-pixels.d.ts +1 -1
- package/dist/canvas/image-data-pixels.d.ts.map +1 -1
- package/dist/canvas/image-data-pixels.js +2 -5
- package/dist/canvas/image-data-pixels.js.map +1 -1
- package/dist/canvas/read-image-data.d.ts.map +1 -1
- package/dist/canvas/read-image-data.js +2 -2
- package/dist/canvas/read-image-data.js.map +1 -1
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/index.d.ts.map +1 -1
- package/dist/dom/index.js +2 -0
- package/dist/dom/index.js.map +1 -1
- package/dist/dom/media-query/watch-media-query.d.ts +26 -0
- package/dist/dom/media-query/watch-media-query.d.ts.map +1 -0
- package/dist/dom/media-query/watch-media-query.js +42 -0
- package/dist/dom/media-query/watch-media-query.js.map +1 -0
- package/dist/dom/resize-observer/observe-canvas-size.d.ts +54 -0
- package/dist/dom/resize-observer/observe-canvas-size.d.ts.map +1 -0
- package/dist/dom/resize-observer/observe-canvas-size.js +189 -0
- package/dist/dom/resize-observer/observe-canvas-size.js.map +1 -0
- package/dist/dom/web-animations/wait-for-transitions.d.ts.map +1 -1
- package/dist/dom/web-animations/wait-for-transitions.js +2 -6
- package/dist/dom/web-animations/wait-for-transitions.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/indexeddb/open-indexed-db.d.ts +1 -1
- package/dist/indexeddb/open-indexed-db.d.ts.map +1 -1
- package/dist/indexeddb/open-indexed-db.js +2 -1
- package/dist/indexeddb/open-indexed-db.js.map +1 -1
- package/dist/media-capture/microphone-access.d.ts.map +1 -1
- package/dist/media-capture/microphone-access.js +4 -6
- package/dist/media-capture/microphone-access.js.map +1 -1
- package/dist/testing/fake-animation-frames.d.ts +31 -0
- package/dist/testing/fake-animation-frames.d.ts.map +1 -0
- package/dist/testing/fake-animation-frames.js +75 -0
- package/dist/testing/fake-animation-frames.js.map +1 -0
- package/dist/testing/fake-match-media.d.ts +19 -0
- package/dist/testing/fake-match-media.d.ts.map +1 -0
- package/dist/testing/fake-match-media.js +135 -0
- package/dist/testing/fake-match-media.js.map +1 -0
- package/dist/testing/fake-resize-observer.d.ts +58 -0
- package/dist/testing/fake-resize-observer.d.ts.map +1 -0
- package/dist/testing/fake-resize-observer.js +118 -0
- package/dist/testing/fake-resize-observer.js.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -1
- package/package.json +8 -6
- package/dist/_race-abort.d.ts +0 -2
- package/dist/_race-abort.d.ts.map +0 -1
- package/dist/_race-abort.js +0 -20
- package/dist/_race-abort.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `requestAnimationFrame` and `cancelAnimationFrame` stand-ins for tests under
|
|
3
|
+
* Node: callbacks queue until the test runs a frame.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const frames = new FakeAnimationFrames();
|
|
7
|
+
* const scheduler = new FrameScheduler(frames, render);
|
|
8
|
+
* scheduler.invalidate();
|
|
9
|
+
* frames.runFrame(16);
|
|
10
|
+
*/
|
|
11
|
+
export declare class FakeAnimationFrames {
|
|
12
|
+
private nextHandle_;
|
|
13
|
+
private queue_;
|
|
14
|
+
private running_;
|
|
15
|
+
private isRunning_;
|
|
16
|
+
/** How many callbacks wait for the next frame. */
|
|
17
|
+
get pendingCount(): number;
|
|
18
|
+
requestAnimationFrame(callback: FrameRequestCallback): number;
|
|
19
|
+
cancelAnimationFrame(handle: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Runs, in request order, the callbacks queued before the call, each given
|
|
22
|
+
* `time`, except those an earlier one cancelled; those requested meanwhile
|
|
23
|
+
* wait for the next frame. As a host does, it runs them all when one throws,
|
|
24
|
+
* then rethrows the first error.
|
|
25
|
+
*
|
|
26
|
+
* @returns How many ran.
|
|
27
|
+
*/
|
|
28
|
+
runFrame(time: number): number;
|
|
29
|
+
private run_;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=fake-animation-frames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-animation-frames.d.ts","sourceRoot":"","sources":["../../src/testing/fake-animation-frames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,QAAQ,CAA2C;IAC3D,OAAO,CAAC,UAAU,CAAS;IAE3B,kDAAkD;IAClD,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,qBAAqB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAK5D;IAED,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAGzC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY7B;IAED,OAAO,CAAC,IAAI;CAyBZ"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `requestAnimationFrame` and `cancelAnimationFrame` stand-ins for tests under
|
|
3
|
+
* Node: callbacks queue until the test runs a frame.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const frames = new FakeAnimationFrames();
|
|
7
|
+
* const scheduler = new FrameScheduler(frames, render);
|
|
8
|
+
* scheduler.invalidate();
|
|
9
|
+
* frames.runFrame(16);
|
|
10
|
+
*/
|
|
11
|
+
export class FakeAnimationFrames {
|
|
12
|
+
nextHandle_ = 1;
|
|
13
|
+
queue_ = new Map();
|
|
14
|
+
running_ = new Map();
|
|
15
|
+
isRunning_ = false;
|
|
16
|
+
/** How many callbacks wait for the next frame. */
|
|
17
|
+
get pendingCount() {
|
|
18
|
+
return this.queue_.size;
|
|
19
|
+
}
|
|
20
|
+
requestAnimationFrame(callback) {
|
|
21
|
+
const handle = this.nextHandle_++;
|
|
22
|
+
this.queue_.set(handle, callback);
|
|
23
|
+
return handle;
|
|
24
|
+
}
|
|
25
|
+
cancelAnimationFrame(handle) {
|
|
26
|
+
this.queue_.delete(handle);
|
|
27
|
+
this.running_.delete(handle);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Runs, in request order, the callbacks queued before the call, each given
|
|
31
|
+
* `time`, except those an earlier one cancelled; those requested meanwhile
|
|
32
|
+
* wait for the next frame. As a host does, it runs them all when one throws,
|
|
33
|
+
* then rethrows the first error.
|
|
34
|
+
*
|
|
35
|
+
* @returns How many ran.
|
|
36
|
+
*/
|
|
37
|
+
runFrame(time) {
|
|
38
|
+
if (this.isRunning_) {
|
|
39
|
+
throw new Error("FakeAnimationFrames: runFrame called from within a frame");
|
|
40
|
+
}
|
|
41
|
+
this.isRunning_ = true;
|
|
42
|
+
try {
|
|
43
|
+
return this.run_(time);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
this.isRunning_ = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
run_(time) {
|
|
50
|
+
this.running_ = this.queue_;
|
|
51
|
+
this.queue_ = new Map();
|
|
52
|
+
let ran = 0;
|
|
53
|
+
let failed = false;
|
|
54
|
+
let firstError;
|
|
55
|
+
for (const [handle, callback] of this.running_) {
|
|
56
|
+
// Deleting the current entry while iterating a Map is safe.
|
|
57
|
+
this.running_.delete(handle);
|
|
58
|
+
ran += 1;
|
|
59
|
+
try {
|
|
60
|
+
callback(time);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (!failed) {
|
|
64
|
+
failed = true;
|
|
65
|
+
firstError = error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (failed) {
|
|
70
|
+
throw firstError;
|
|
71
|
+
}
|
|
72
|
+
return ran;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=fake-animation-frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-animation-frames.js","sourceRoot":"","sources":["../../src/testing/fake-animation-frames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAmB;IACvB,WAAW,GAAG,CAAC,CAAC;IAChB,MAAM,GAAG,IAAI,GAAG,EAAgC,CAAC;IACjD,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IACnD,UAAU,GAAG,KAAK,CAAC;IAE3B,kDAAkD;IAClD,IAAI,YAAY;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,qBAAqB,CAAC,QAA8B;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAElC,OAAO,MAAM,CAAC;IACf,CAAC;IAED,oBAAoB,CAAC,MAAc;QAClC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAY;QACpB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACd,0DAA0D,CAC1D,CAAC;QACH,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACzB,CAAC;IACF,CAAC;IAEO,IAAI,CAAC,IAAY;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACxB,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,UAAmB,CAAC;QACxB,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChD,4DAA4D;YAC5D,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC7B,GAAG,IAAI,CAAC,CAAC;YACT,IAAI,CAAC;gBACJ,QAAQ,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,EAAE,CAAC;oBACb,MAAM,GAAG,IAAI,CAAC;oBACd,UAAU,GAAG,KAAK,CAAC;gBACpB,CAAC;YACF,CAAC;QACF,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,UAAU,CAAC;QAClB,CAAC;QAED,OAAO,GAAG,CAAC;IACZ,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A window's `matchMedia` for tests under Node: every query starts as not
|
|
3
|
+
* matching, and the test flips it, which fires `change` on the lists given.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const media = new FakeMatchMedia();
|
|
7
|
+
* const watch = watchMediaQuery(media, "(prefers-reduced-motion: reduce)");
|
|
8
|
+
* media.set("(prefers-reduced-motion: reduce)", true);
|
|
9
|
+
*/
|
|
10
|
+
export declare class FakeMatchMedia implements Pick<Window, "matchMedia"> {
|
|
11
|
+
private readonly matches_;
|
|
12
|
+
private readonly lists_;
|
|
13
|
+
/** Sets whether `query` matches and tells the lists made for it. */
|
|
14
|
+
set(query: string, matches: boolean): void;
|
|
15
|
+
/** How many `change` listeners are attached, across every query. */
|
|
16
|
+
get listenerCount(): number;
|
|
17
|
+
matchMedia: (query: string) => MediaQueryList;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=fake-match-media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-match-media.d.ts","sourceRoot":"","sources":["../../src/testing/fake-match-media.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,cAAe,YAAW,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;IAChE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;IAEtE,oEAAoE;IACpE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CASzC;IAED,oEAAoE;IACpE,IAAI,aAAa,IAAI,MAAM,CAS1B;IAED,UAAU,UAAW,MAAM,KAAG,cAAc,CAa1C;CACF"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A window's `matchMedia` for tests under Node: every query starts as not
|
|
3
|
+
* matching, and the test flips it, which fires `change` on the lists given.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const media = new FakeMatchMedia();
|
|
7
|
+
* const watch = watchMediaQuery(media, "(prefers-reduced-motion: reduce)");
|
|
8
|
+
* media.set("(prefers-reduced-motion: reduce)", true);
|
|
9
|
+
*/
|
|
10
|
+
export class FakeMatchMedia {
|
|
11
|
+
matches_ = new Map();
|
|
12
|
+
lists_ = new Map();
|
|
13
|
+
/** Sets whether `query` matches and tells the lists made for it. */
|
|
14
|
+
set(query, matches) {
|
|
15
|
+
const wasMatching = this.matches_.get(query) ?? false;
|
|
16
|
+
this.matches_.set(query, matches);
|
|
17
|
+
if (wasMatching === matches) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
for (const list of this.lists_.get(query) ?? []) {
|
|
21
|
+
list.fire(matches);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** How many `change` listeners are attached, across every query. */
|
|
25
|
+
get listenerCount() {
|
|
26
|
+
let count = 0;
|
|
27
|
+
for (const lists of this.lists_.values()) {
|
|
28
|
+
for (const list of lists) {
|
|
29
|
+
count += list.listenerCount;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return count;
|
|
33
|
+
}
|
|
34
|
+
matchMedia = (query) => {
|
|
35
|
+
const list = new FakeMediaQueryList_(query, () => this.matches_.get(query) ?? false);
|
|
36
|
+
let lists = this.lists_.get(query);
|
|
37
|
+
if (lists === undefined) {
|
|
38
|
+
lists = new Set();
|
|
39
|
+
this.lists_.set(query, lists);
|
|
40
|
+
}
|
|
41
|
+
lists.add(list);
|
|
42
|
+
return list;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
class FakeMediaQueryList_ extends EventTarget {
|
|
46
|
+
media;
|
|
47
|
+
read_;
|
|
48
|
+
registrations_ = [];
|
|
49
|
+
constructor(media, read_) {
|
|
50
|
+
super();
|
|
51
|
+
this.media = media;
|
|
52
|
+
this.read_ = read_;
|
|
53
|
+
}
|
|
54
|
+
get matches() {
|
|
55
|
+
return this.read_();
|
|
56
|
+
}
|
|
57
|
+
get listenerCount() {
|
|
58
|
+
return this.registrations_.length;
|
|
59
|
+
}
|
|
60
|
+
addEventListener(type, callback, options) {
|
|
61
|
+
if (callback === null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const capture = typeof options === "boolean" ? options : (options?.capture ?? false);
|
|
65
|
+
// As `EventTarget` does: the same type, callback and capture flag once.
|
|
66
|
+
if (this.indexOf_(type, callback, capture) >= 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const signal = typeof options === "object" ? options.signal : undefined;
|
|
70
|
+
if (signal?.aborted) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const once = typeof options === "object" && options.once === true;
|
|
74
|
+
const registration = {
|
|
75
|
+
type,
|
|
76
|
+
callback,
|
|
77
|
+
capture,
|
|
78
|
+
listener: (event) => {
|
|
79
|
+
// `EventTarget` forgets a `once` listener before invoking it, so one
|
|
80
|
+
// that registers again from its callback is counted again.
|
|
81
|
+
if (once) {
|
|
82
|
+
this.forget_(registration);
|
|
83
|
+
}
|
|
84
|
+
if (typeof callback === "function") {
|
|
85
|
+
callback.call(this, event);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
callback.handleEvent(event);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
this.registrations_.push(registration);
|
|
93
|
+
super.addEventListener(type, registration.listener, {
|
|
94
|
+
capture,
|
|
95
|
+
once,
|
|
96
|
+
passive: typeof options === "object" ? options.passive : undefined,
|
|
97
|
+
signal,
|
|
98
|
+
});
|
|
99
|
+
signal?.addEventListener("abort", () => this.forget_(registration), {
|
|
100
|
+
once: true,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
removeEventListener(type, callback, options) {
|
|
104
|
+
if (callback === null) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const capture = typeof options === "boolean" ? options : (options?.capture ?? false);
|
|
108
|
+
const index = this.indexOf_(type, callback, capture);
|
|
109
|
+
if (index < 0) {
|
|
110
|
+
// `EventTarget` itself removes the listener it holds when a signal aborts.
|
|
111
|
+
super.removeEventListener(type, callback, options);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const [registration] = this.registrations_.splice(index, 1);
|
|
115
|
+
super.removeEventListener(type, registration.listener, capture);
|
|
116
|
+
}
|
|
117
|
+
fire(matches) {
|
|
118
|
+
const event = new Event("change");
|
|
119
|
+
event.matches = matches;
|
|
120
|
+
event.media = this.media;
|
|
121
|
+
this.dispatchEvent(event);
|
|
122
|
+
}
|
|
123
|
+
indexOf_(type, callback, capture) {
|
|
124
|
+
return this.registrations_.findIndex((registration) => registration.type === type &&
|
|
125
|
+
registration.callback === callback &&
|
|
126
|
+
registration.capture === capture);
|
|
127
|
+
}
|
|
128
|
+
forget_(registration) {
|
|
129
|
+
const index = this.registrations_.indexOf(registration);
|
|
130
|
+
if (index >= 0) {
|
|
131
|
+
this.registrations_.splice(index, 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=fake-match-media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-match-media.js","sourceRoot":"","sources":["../../src/testing/fake-match-media.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAc;IACT,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IACtC,MAAM,GAAG,IAAI,GAAG,EAAoC,CAAC;IAEtE,oEAAoE;IACpE,GAAG,CAAC,KAAa,EAAE,OAAgB;QAClC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;QACtD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,WAAW,KAAK,OAAO,EAAE,CAAC;YAC7B,OAAO;QACR,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;IAED,oE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A4C,EAC5C,OAAgB;QAEhB,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CACnC,CAAC,YAAY,EAAE,EAAE,CAChB,YAAY,CAAC,IAAI,KAAK,IAAI;YAC1B,YAAY,CAAC,QAAQ,KAAK,QAAQ;YAClC,YAAY,CAAC,OAAO,KAAK,OAAO,CACjC,CAAC;IACH,CAAC;IAEO,OAAO,CAAC,YAA2B;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CanvasBoxSize } from "../canvas/canvas-backing-size.js";
|
|
2
|
+
export type FakeResizeObserverOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* `observe` throws a `TypeError` for `device-pixel-content-box`, as Safari
|
|
5
|
+
* does. Default false.
|
|
6
|
+
*/
|
|
7
|
+
readonly refuseDevicePixelBox?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* How a stand-in entry lays its box out, a vertical writing mode swapping the
|
|
11
|
+
* axes.
|
|
12
|
+
*/
|
|
13
|
+
export type FakeResizeEntryOptions = {
|
|
14
|
+
readonly vertical?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** A `ResizeObserver` constructor made by {@link FakeResizeObserver.create}. */
|
|
17
|
+
export type FakeResizeObserverConstructor = {
|
|
18
|
+
new (callback: ResizeObserverCallback): FakeResizeObserver;
|
|
19
|
+
/** The observers made, in order. */
|
|
20
|
+
readonly instances: readonly FakeResizeObserver[];
|
|
21
|
+
/** `resize` on every observer made. */
|
|
22
|
+
resize(size: CanvasBoxSize, options?: FakeResizeEntryOptions): void;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A `ResizeObserver` stand-in for tests under Node: it records what is observed
|
|
26
|
+
* and delivers the entries the test gives it, as a browser does: an entry for a
|
|
27
|
+
* target only when the box it observes changed since the last one (the first
|
|
28
|
+
* always), carrying every box the size gives; observing a target again replaces
|
|
29
|
+
* the earlier observation and reports it afresh.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const ResizeObserver = FakeResizeObserver.create();
|
|
33
|
+
* const window = { ResizeObserver, devicePixelRatio: 2, … };
|
|
34
|
+
* ResizeObserver.resize({ cssWidth: 300, cssHeight: 150, devicePixelRatio: 2, devicePixelWidth: 600, devicePixelHeight: 300 });
|
|
35
|
+
*/
|
|
36
|
+
export declare class FakeResizeObserver implements ResizeObserver {
|
|
37
|
+
private readonly callback_;
|
|
38
|
+
/** The targets observed, with the options each was given. */
|
|
39
|
+
readonly observed: {
|
|
40
|
+
target: Element;
|
|
41
|
+
options?: ResizeObserverOptions;
|
|
42
|
+
}[];
|
|
43
|
+
isConnected: boolean;
|
|
44
|
+
private readonly refuseDevicePixelBox_;
|
|
45
|
+
private readonly reported_;
|
|
46
|
+
protected constructor(callback_: ResizeObserverCallback, options: FakeResizeObserverOptions);
|
|
47
|
+
/** A constructor to hand to code that makes its own `ResizeObserver`. */
|
|
48
|
+
static create(options?: FakeResizeObserverOptions): FakeResizeObserverConstructor;
|
|
49
|
+
observe(target: Element, options?: ResizeObserverOptions): void;
|
|
50
|
+
unobserve(target: Element): void;
|
|
51
|
+
disconnect(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Delivers, after layout, an entry for each observed target whose observed
|
|
54
|
+
* box changed. Nothing happens once disconnected.
|
|
55
|
+
*/
|
|
56
|
+
resize(size: CanvasBoxSize, options?: FakeResizeEntryOptions): void;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=fake-resize-observer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-resize-observer.d.ts","sourceRoot":"","sources":["../../src/testing/fake-res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UAAU,IAAI,IAAI,CAIjB;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,GAAE,sBAA2B,GAAG,IAAI,CAuBtE;CACD"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `ResizeObserver` stand-in for tests under Node: it records what is observed
|
|
3
|
+
* and delivers the entries the test gives it, as a browser does: an entry for a
|
|
4
|
+
* target only when the box it observes changed since the last one (the first
|
|
5
|
+
* always), carrying every box the size gives; observing a target again replaces
|
|
6
|
+
* the earlier observation and reports it afresh.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const ResizeObserver = FakeResizeObserver.create();
|
|
10
|
+
* const window = { ResizeObserver, devicePixelRatio: 2, … };
|
|
11
|
+
* ResizeObserver.resize({ cssWidth: 300, cssHeight: 150, devicePixelRatio: 2, devicePixelWidth: 600, devicePixelHeight: 300 });
|
|
12
|
+
*/
|
|
13
|
+
export class FakeResizeObserver {
|
|
14
|
+
callback_;
|
|
15
|
+
/** The targets observed, with the options each was given. */
|
|
16
|
+
observed = [];
|
|
17
|
+
isConnected = true;
|
|
18
|
+
refuseDevicePixelBox_;
|
|
19
|
+
reported_ = new Map();
|
|
20
|
+
constructor(callback_, options) {
|
|
21
|
+
this.callback_ = callback_;
|
|
22
|
+
this.refuseDevicePixelBox_ = options.refuseDevicePixelBox ?? false;
|
|
23
|
+
}
|
|
24
|
+
/** A constructor to hand to code that makes its own `ResizeObserver`. */
|
|
25
|
+
static create(options = {}) {
|
|
26
|
+
const instances = [];
|
|
27
|
+
return class extends FakeResizeObserver {
|
|
28
|
+
static instances = instances;
|
|
29
|
+
static resize(size, resizeOptions) {
|
|
30
|
+
for (const instance of instances) {
|
|
31
|
+
instance.resize(size, resizeOptions);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
constructor(callback) {
|
|
35
|
+
super(callback, options);
|
|
36
|
+
instances.push(this);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
observe(target, options) {
|
|
41
|
+
if (this.refuseDevicePixelBox_ &&
|
|
42
|
+
options?.box === "device-pixel-content-box") {
|
|
43
|
+
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': The provided value 'device-pixel-content-box' is not a valid enum value.");
|
|
44
|
+
}
|
|
45
|
+
this.unobserve(target);
|
|
46
|
+
this.observed.push(options === undefined ? { target } : { target, options });
|
|
47
|
+
this.isConnected = true;
|
|
48
|
+
}
|
|
49
|
+
unobserve(target) {
|
|
50
|
+
const index = this.observed.findIndex((item) => item.target === target);
|
|
51
|
+
if (index !== -1) {
|
|
52
|
+
this.observed.splice(index, 1);
|
|
53
|
+
}
|
|
54
|
+
this.reported_.delete(target);
|
|
55
|
+
}
|
|
56
|
+
disconnect() {
|
|
57
|
+
this.observed.length = 0;
|
|
58
|
+
this.reported_.clear();
|
|
59
|
+
this.isConnected = false;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Delivers, after layout, an entry for each observed target whose observed
|
|
63
|
+
* box changed. Nothing happens once disconnected.
|
|
64
|
+
*/
|
|
65
|
+
resize(size, options = {}) {
|
|
66
|
+
const entries = [];
|
|
67
|
+
for (const { target, options: observed } of this.observed) {
|
|
68
|
+
const isDeviceBox = observed?.box === "device-pixel-content-box";
|
|
69
|
+
const key = isDeviceBox
|
|
70
|
+
? `device ${size.devicePixelWidth} ${size.devicePixelHeight}`
|
|
71
|
+
: `content ${size.cssWidth} ${size.cssHeight}`;
|
|
72
|
+
if (this.reported_.get(target) === key) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
this.reported_.set(target, key);
|
|
76
|
+
entries.push(entryOf_(target, size, !this.refuseDevicePixelBox_, options.vertical === true));
|
|
77
|
+
}
|
|
78
|
+
if (entries.length > 0) {
|
|
79
|
+
this.callback_(entries, this);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function sizeOf_(inlineSize, blockSize) {
|
|
84
|
+
return { inlineSize, blockSize };
|
|
85
|
+
}
|
|
86
|
+
function entryOf_(target, size, hasDevicePixelBox, vertical) {
|
|
87
|
+
const { cssWidth, cssHeight, devicePixelWidth, devicePixelHeight } = size;
|
|
88
|
+
const contentBox = vertical
|
|
89
|
+
? sizeOf_(cssHeight, cssWidth)
|
|
90
|
+
: sizeOf_(cssWidth, cssHeight);
|
|
91
|
+
const devicePixelBox = hasDevicePixelBox &&
|
|
92
|
+
devicePixelWidth !== undefined &&
|
|
93
|
+
devicePixelHeight !== undefined
|
|
94
|
+
? [
|
|
95
|
+
vertical
|
|
96
|
+
? sizeOf_(devicePixelHeight, devicePixelWidth)
|
|
97
|
+
: sizeOf_(devicePixelWidth, devicePixelHeight),
|
|
98
|
+
]
|
|
99
|
+
: [];
|
|
100
|
+
return {
|
|
101
|
+
target,
|
|
102
|
+
contentRect: {
|
|
103
|
+
x: 0,
|
|
104
|
+
y: 0,
|
|
105
|
+
width: cssWidth,
|
|
106
|
+
height: cssHeight,
|
|
107
|
+
top: 0,
|
|
108
|
+
left: 0,
|
|
109
|
+
right: cssWidth,
|
|
110
|
+
bottom: cssHeight,
|
|
111
|
+
toJSON: () => ({}),
|
|
112
|
+
},
|
|
113
|
+
contentBoxSize: [contentBox],
|
|
114
|
+
borderBoxSize: [contentBox],
|
|
115
|
+
devicePixelContentBoxSize: devicePixelBox,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=fake-resize-observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-resize-observer.js","sourceRoot":"","sources":["../../src/testing/fake-resize-observer.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,kBAAkB;IASZ,SAAS;IAR3B,6DAA6D;IACpD,QAAQ,GAChB,EAAE,CAAC;IACJ,WAAW,GAAG,IAAI,CAAC;IACF,qBAAqB,CAAU;IAC/B,SAAS,GAAG,IAAI,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.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from "./fake-animation-frames.js";
|
|
1
2
|
export * from "./fake-audio-context.js";
|
|
3
|
+
export * from "./fake-match-media.js";
|
|
2
4
|
export * from "./fake-media-devices.js";
|
|
5
|
+
export * from "./fake-resize-observer.js";
|
|
3
6
|
export * from "./fake-web-midi.js";
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC"}
|
package/dist/testing/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from "./fake-animation-frames.js";
|
|
1
2
|
export * from "./fake-audio-context.js";
|
|
3
|
+
export * from "./fake-match-media.js";
|
|
2
4
|
export * from "./fake-media-devices.js";
|
|
5
|
+
export * from "./fake-resize-observer.js";
|
|
3
6
|
export * from "./fake-web-midi.js";
|
|
4
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/browser",
|
|
3
|
-
"version": "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, and the wait for an element's CSS transitions.",
|
|
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",
|
|
6
7
|
"audio-clock",
|
|
7
8
|
"audio-worklet",
|
|
8
9
|
"browser",
|
|
@@ -60,15 +61,16 @@
|
|
|
60
61
|
"prepack": "yarn build"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
|
-
"@ac-kit/async": "^0.
|
|
64
|
-
"@ac-kit/core": "^0.
|
|
64
|
+
"@ac-kit/async": "^0.8.0",
|
|
65
|
+
"@ac-kit/core": "^0.12.0",
|
|
65
66
|
"@types/web": "^0.0.367"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@ac-kit/math-random": "0.
|
|
69
|
+
"@ac-kit/math-random": "0.4.0",
|
|
70
|
+
"@ac-kit/test-util": "0.4.0",
|
|
69
71
|
"@ac-kit/tsconfig": "0.1.0",
|
|
70
72
|
"@ac-kit/typedoc-config": "0.1.0",
|
|
71
|
-
"@ac-kit/vitest-config": "0.
|
|
73
|
+
"@ac-kit/vitest-config": "0.2.0",
|
|
72
74
|
"@typescript/native": "typescript@7.0.2",
|
|
73
75
|
"fake-indexeddb": "6.2.8",
|
|
74
76
|
"rimraf": "6.1.4",
|
package/dist/_race-abort.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_race-abort.d.ts","sourceRoot":"","sources":["../src/_race-abort.ts"],"names":[],"mappings":"AAIA,wBAAsB,UAAU,CAAC,CAAC,EACjC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,MAAM,EAAE,WAAW,GACjB,OAAO,CAAC,CAAC,CAAC,CAaZ"}
|
package/dist/_race-abort.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Settles as `work`, or rejects with `signal`'s reason once it aborts. It
|
|
2
|
-
// listens on a signal of its own following `signal`, which the browser aborts
|
|
3
|
-
// with it: a listener on `signal` calling `stopImmediatePropagation`, or an
|
|
4
|
-
// `abort` event dispatched by hand, cannot reach it.
|
|
5
|
-
export async function raceAbort_(work, signal) {
|
|
6
|
-
const following = AbortSignal.any([signal]);
|
|
7
|
-
following.throwIfAborted();
|
|
8
|
-
const aborted = Promise.withResolvers();
|
|
9
|
-
const onAbort = () => {
|
|
10
|
-
aborted.reject(following.reason);
|
|
11
|
-
};
|
|
12
|
-
following.addEventListener("abort", onAbort, { once: true });
|
|
13
|
-
try {
|
|
14
|
-
return await Promise.race([work, aborted.promise]);
|
|
15
|
-
}
|
|
16
|
-
finally {
|
|
17
|
-
following.removeEventListener("abort", onAbort);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=_race-abort.js.map
|
package/dist/_race-abort.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_race-abort.js","sourceRoot":"","sources":["../src/_race-abort.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8EAA8E;AAC9E,4EAA4E;AAC5E,qDAAqD;AACrD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC/B,IAAgB,EAChB,MAAmB;IAEnB,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,SAAS,CAAC,cAAc,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IAC/C,MAAM,OAAO,GAAG,GAAS,EAAE;QAC1B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC;IACF,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC;QACJ,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACpD,CAAC;YAAS,CAAC;QACV,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;AACF,CAAC"}
|