Tons of Solutions Engineering work done today for the rest of the CS team! Headway, Howard Hanna, Engels, Brighton, etc. Also completed Datasnippers auth flow and worked on Anthology's script. Cloned Anthology's courses (900..) and will clone Full Story on Monday.

This commit is contained in:
Norm Rasmussen
2024-01-05 17:07:59 -05:00
parent ce261975ca
commit a5fe4bd2c8
3157 changed files with 554269 additions and 16 deletions

View File

@ -0,0 +1,27 @@
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Implements a FIFO buffer with a fixed size. */
export declare class Buffer<T> {
#private;
/**
* @param capacity The buffer capacity.
* @param onItemRemoved Delegate called for each removed element.
*/
constructor(capacity: number, onItemRemoved?: (value: T) => void);
get(): T[];
add(value: T): void;
}

View File

@ -0,0 +1,47 @@
"use strict";
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Buffer = void 0;
/** Implements a FIFO buffer with a fixed size. */
class Buffer {
#capacity;
#entries = [];
#onItemRemoved;
/**
* @param capacity The buffer capacity.
* @param onItemRemoved Delegate called for each removed element.
*/
constructor(capacity, onItemRemoved) {
this.#capacity = capacity;
this.#onItemRemoved = onItemRemoved;
}
get() {
return this.#entries;
}
add(value) {
this.#entries.push(value);
while (this.#entries.length > this.#capacity) {
const item = this.#entries.shift();
if (item !== undefined) {
this.#onItemRemoved?.(item);
}
}
}
}
exports.Buffer = Buffer;
//# sourceMappingURL=Buffer.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Buffer.js","sourceRoot":"","sources":["../../../src/utils/Buffer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,kDAAkD;AAClD,MAAa,MAAM;IACR,SAAS,CAAS;IAClB,QAAQ,GAAQ,EAAE,CAAC;IACnB,cAAc,CAAsB;IAE7C;;;OAGG;IACH,YAAY,QAAgB,EAAE,aAAkC;QAC9D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,GAAG,CAAC,KAAQ;QACV,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACnC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3BD,wBA2BC"}

View File

@ -0,0 +1,22 @@
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @see https://crsrc.org/c/third_party/devtools-frontend/src/front_end/core/protocol_client/InspectorBackend.ts */
export declare const enum CdpErrorConstants {
CONNECTION_CLOSED = -32001,
DEVTOOLS_STUB = -32015,
GENERIC_ERROR = -32000
}

View File

@ -0,0 +1,19 @@
"use strict";
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=CdpErrorConstants.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"CdpErrorConstants.js","sourceRoot":"","sources":["../../../src/utils/CdpErrorConstants.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}

View File

@ -0,0 +1,26 @@
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A subclass of Map whose functionality is almost the same as its parent
* except for the fact that DefaultMap never returns undefined. It provides a
* default value for keys that do not exist.
*/
export declare class DefaultMap<K, V> extends Map<K, V> {
#private;
constructor(getDefaultValue: (key: K) => V, entries?: readonly (readonly [K, V])[] | null);
get(key: K): V;
}

View File

@ -0,0 +1,40 @@
"use strict";
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultMap = void 0;
/**
* A subclass of Map whose functionality is almost the same as its parent
* except for the fact that DefaultMap never returns undefined. It provides a
* default value for keys that do not exist.
*/
class DefaultMap extends Map {
/** The default value to return whenever a key is not present in the map. */
#getDefaultValue;
constructor(getDefaultValue, entries) {
super(entries);
this.#getDefaultValue = getDefaultValue;
}
get(key) {
if (!this.has(key)) {
this.set(key, this.#getDefaultValue(key));
}
return super.get(key);
}
}
exports.DefaultMap = DefaultMap;
//# sourceMappingURL=DefaultMap.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"DefaultMap.js","sourceRoot":"","sources":["../../../src/utils/DefaultMap.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;;;GAIG;AACH,MAAa,UAAiB,SAAQ,GAAS;IAC7C,4EAA4E;IAC5E,gBAAgB,CAAgB;IAEhC,YACE,eAA8B,EAC9B,OAA6C;QAE7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IAEQ,GAAG,CAAC,GAAM;QACjB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IACzB,CAAC;CACF;AAlBD,gCAkBC"}

View File

@ -0,0 +1,27 @@
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare class Deferred<T> implements Promise<T> {
#private;
get isFinished(): boolean;
constructor();
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
catch<TResult = never>(onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
resolve(value: T): void;
reject(reason: unknown): void;
finally(onFinally?: (() => void) | null): Promise<T>;
[Symbol.toStringTag]: string;
}

View File

@ -0,0 +1,63 @@
"use strict";
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Deferred = void 0;
class Deferred {
#isFinished = false;
#promise;
#resolve;
#reject;
get isFinished() {
return this.#isFinished;
}
constructor() {
this.#promise = new Promise((resolve, reject) => {
this.#resolve = resolve;
this.#reject = reject;
});
// Needed to avoid `Uncaught (in promise)`. The promises returned by `then`
// and `catch` will be rejected anyway.
this.#promise.catch((_error) => {
// Intentionally empty.
});
}
then(onFulfilled, onRejected) {
return this.#promise.then(onFulfilled, onRejected);
}
catch(onRejected) {
return this.#promise.catch(onRejected);
}
resolve(value) {
if (!this.#isFinished) {
this.#isFinished = true;
this.#resolve(value);
}
}
reject(reason) {
if (!this.#isFinished) {
this.#isFinished = true;
this.#reject(reason);
}
}
finally(onFinally) {
return this.#promise.finally(onFinally);
}
[Symbol.toStringTag] = 'Promise';
}
exports.Deferred = Deferred;
//# sourceMappingURL=Deferred.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Deferred.js","sourceRoot":"","sources":["../../../src/utils/Deferred.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,MAAa,QAAQ;IACnB,WAAW,GAAG,KAAK,CAAC;IACpB,QAAQ,CAAa;IACrB,QAAQ,CAAsB;IAC9B,OAAO,CAA6B;IAEpC,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,2EAA2E;QAC3E,uCAAuC;QACvC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;YAC7B,uBAAuB;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CACF,WAAqE,EACrE,UAA2E;QAE3E,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CACH,UAAyE;QAEzE,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,KAAQ;QACd,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,MAAe;QACpB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,SAA+B;QACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;CAClC;AAtDD,4BAsDC"}

View File

@ -0,0 +1,58 @@
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type EventType, type Handler, type WildcardHandler } from 'mitt';
export declare class EventEmitter<Events extends Record<EventType, unknown>> {
#private;
/**
* Binds an event listener to fire when an event occurs.
* @param event The event type you'd like to listen to. Can be a string or symbol.
* @param handler The function to be called when the event occurs.
* @return `this` to enable chaining method calls.
*/
on(type: '*', handler: WildcardHandler<Events>): this;
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): this;
/**
* Like `on` but the listener will only be fired once and then it will be removed.
* @param event The event you'd like to listen to
* @param handler The handler function to run when the event occurs
* @return `this` to enable chaining method calls.
*/
once(event: EventType, handler: Handler): this;
/**
* Removes an event listener from firing.
* @param event The event type you'd like to stop listening to.
* @param handler The function that should be removed.
* @return `this` to enable chaining method calls.
*/
off(type: '*', handler: WildcardHandler<Events>): this;
off<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): EventEmitter<Events>;
/**
* Emits an event and call any associated listeners.
*
* @param event The event to emit.
* @param eventData Any data to emit with the event.
* @return `true` if there are any listeners, `false` otherwise.
*/
emit<Key extends keyof Events>(event: Key, eventData: Events[Key]): void;
/**
* Removes all listeners. If given an event argument, it will remove only
* listeners for that event.
* @param event - the event to remove listeners for.
* @returns `this` to enable you to chain method calls.
*/
removeAllListeners(event?: EventType): this;
}

View File

@ -0,0 +1,74 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventEmitter = void 0;
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const mitt_1 = __importDefault(require("mitt"));
class EventEmitter {
#emitter = (0, mitt_1.default)();
on(type, handler) {
this.#emitter.on(type, handler);
return this;
}
/**
* Like `on` but the listener will only be fired once and then it will be removed.
* @param event The event you'd like to listen to
* @param handler The handler function to run when the event occurs
* @return `this` to enable chaining method calls.
*/
once(event, handler) {
const onceHandler = (eventData) => {
handler(eventData);
this.off(event, onceHandler);
};
return this.on(event, onceHandler);
}
off(type, handler) {
this.#emitter.off(type, handler);
return this;
}
/**
* Emits an event and call any associated listeners.
*
* @param event The event to emit.
* @param eventData Any data to emit with the event.
* @return `true` if there are any listeners, `false` otherwise.
*/
emit(event, eventData) {
this.#emitter.emit(event, eventData);
}
/**
* Removes all listeners. If given an event argument, it will remove only
* listeners for that event.
* @param event - the event to remove listeners for.
* @returns `this` to enable you to chain method calls.
*/
removeAllListeners(event) {
if (event) {
this.#emitter.all.delete(event);
}
else {
this.#emitter.all.clear();
}
return this;
}
}
exports.EventEmitter = EventEmitter;
//# sourceMappingURL=EventEmitter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"EventEmitter.js","sourceRoot":"","sources":["../../../src/utils/EventEmitter.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,gDAKc;AAEd,MAAa,YAAY;IACvB,QAAQ,GAAoB,IAAA,cAAI,GAAE,CAAC;IAUnC,EAAE,CAAC,IAAS,EAAE,OAAY;QACxB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,KAAgB,EAAE,OAAgB;QACrC,MAAM,WAAW,GAAY,CAAC,SAAS,EAAE,EAAE;YACzC,OAAO,CAAC,SAAS,CAAC,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC/B,CAAC,CAAC;QACF,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACrC,CAAC;IAaD,GAAG,CAAC,IAAS,EAAE,OAAY;QACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAA2B,KAAU,EAAE,SAAsB;QAC/D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,KAAiB;QAClC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAvED,oCAuEC"}

View File

@ -0,0 +1,24 @@
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Creates an object with a positive unique incrementing id.
*/
export declare class IdWrapper {
#private;
constructor();
get id(): number;
}

View File

@ -0,0 +1,34 @@
"use strict";
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.IdWrapper = void 0;
/**
* Creates an object with a positive unique incrementing id.
*/
class IdWrapper {
static #counter = 0;
#id;
constructor() {
this.#id = ++IdWrapper.#counter;
}
get id() {
return this.#id;
}
}
exports.IdWrapper = IdWrapper;
//# sourceMappingURL=IdWrapper.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"IdWrapper.js","sourceRoot":"","sources":["../../../src/utils/IdWrapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;GAEG;AACH,MAAa,SAAS;IACpB,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;IACX,GAAG,CAAS;IAErB;QACE,IAAI,CAAC,GAAG,GAAG,EAAE,SAAS,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;;AAVH,8BAWC"}

View File

@ -0,0 +1,29 @@
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
* Copyright 2022 The Chromium Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type ReleaseFunction = () => void;
/**
* Use Mutex class to coordinate local concurrent operations.
* Once `acquire` promise resolves, you hold the lock and must
* call `release` function returned by `acquire` to release the
* lock. Failing to `release` the lock may lead to deadlocks.
*/
export declare class Mutex {
#private;
acquire(): Promise<ReleaseFunction>;
run<T>(action: () => Promise<T>): Promise<T>;
}

View File

@ -0,0 +1,68 @@
"use strict";
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
* Copyright 2022 The Chromium Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mutex = void 0;
/**
* Use Mutex class to coordinate local concurrent operations.
* Once `acquire` promise resolves, you hold the lock and must
* call `release` function returned by `acquire` to release the
* lock. Failing to `release` the lock may lead to deadlocks.
*/
class Mutex {
#locked = false;
#acquirers = [];
// This is FIFO.
acquire() {
const state = { resolved: false };
if (this.#locked) {
return new Promise((resolve) => {
this.#acquirers.push(() => resolve(this.#release.bind(this, state)));
});
}
this.#locked = true;
return Promise.resolve(this.#release.bind(this, state));
}
#release(state) {
if (state.resolved) {
throw new Error('Cannot release more than once.');
}
state.resolved = true;
const resolve = this.#acquirers.shift();
if (!resolve) {
this.#locked = false;
return;
}
resolve();
}
async run(action) {
const release = await this.acquire();
try {
// Note we need to await here because we want the await to release AFTER
// that await happens. Returning action() will trigger the release
// immediately which is counter to what we want.
const result = await action();
return result;
}
finally {
release();
}
}
}
exports.Mutex = Mutex;
//# sourceMappingURL=Mutex.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Mutex.js","sourceRoot":"","sources":["../../../src/utils/Mutex.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAIH;;;;;GAKG;AACH,MAAa,KAAK;IAChB,OAAO,GAAG,KAAK,CAAC;IAChB,UAAU,GAAmB,EAAE,CAAC;IAEhC,gBAAgB;IAChB,OAAO;QACL,MAAM,KAAK,GAAG,EAAC,QAAQ,EAAE,KAAK,EAAC,CAAC;QAChC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,QAAQ,CAAC,KAA0B;QACjC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QACD,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QAEtB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,OAAO;QACT,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,MAAwB;QACnC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,wEAAwE;YACxE,kEAAkE;YAClE,gDAAgD;YAChD,MAAM,MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AA1CD,sBA0CC"}

View File

@ -0,0 +1,24 @@
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type LoggerFn } from './log.js';
import type { Result } from './result.js';
export declare class ProcessingQueue<T> {
#private;
static readonly LOGGER_PREFIX: "debug:queue";
constructor(processor: (arg: T) => Promise<void>, logger?: LoggerFn);
add(entry: Promise<Result<T>>, name: string): void;
}

View File

@ -0,0 +1,65 @@
"use strict";
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProcessingQueue = void 0;
const log_js_1 = require("./log.js");
class ProcessingQueue {
static LOGGER_PREFIX = `${log_js_1.LogType.debug}:queue`;
#logger;
#processor;
#queue = [];
// Flag to keep only 1 active processor.
#isProcessing = false;
constructor(processor, logger) {
this.#processor = processor;
this.#logger = logger;
}
add(entry, name) {
this.#queue.push([entry, name]);
// No need in waiting. Just initialize processor if needed.
void this.#processIfNeeded();
}
async #processIfNeeded() {
if (this.#isProcessing) {
return;
}
this.#isProcessing = true;
while (this.#queue.length > 0) {
const arrayEntry = this.#queue.shift();
if (!arrayEntry) {
continue;
}
const [entryPromise, name] = arrayEntry;
this.#logger?.(ProcessingQueue.LOGGER_PREFIX, 'Processing event:', name);
await entryPromise
.then((entry) => {
if (entry.kind === 'error') {
this.#logger?.(log_js_1.LogType.debugError, 'Event threw before sending:', entry.error.message, entry.error.stack);
return;
}
return this.#processor(entry.value);
})
.catch((error) => {
this.#logger?.(log_js_1.LogType.debugError, 'Event was not processed:', error?.message);
});
}
this.#isProcessing = false;
}
}
exports.ProcessingQueue = ProcessingQueue;
//# sourceMappingURL=ProcessingQueue.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ProcessingQueue.js","sourceRoot":"","sources":["../../../src/utils/ProcessingQueue.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,qCAAgD;AAGhD,MAAa,eAAe;IAC1B,MAAM,CAAU,aAAa,GAAG,GAAG,gBAAO,CAAC,KAAK,QAAiB,CAAC;IAEzD,OAAO,CAAY;IACnB,UAAU,CAA4B;IACtC,MAAM,GAAmC,EAAE,CAAC;IAErD,wCAAwC;IACxC,aAAa,GAAG,KAAK,CAAC;IAEtB,YAAY,SAAoC,EAAE,MAAiB;QACjE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,GAAG,CAAC,KAAyB,EAAE,IAAY;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAChC,2DAA2D;QAC3D,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,SAAS;YACX,CAAC;YACD,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC;YACxC,IAAI,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,mBAAmB,EAAE,IAAI,CAAC,CAAC;YAEzE,MAAM,YAAY;iBACf,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACd,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3B,IAAI,CAAC,OAAO,EAAE,CACZ,gBAAO,CAAC,UAAU,EAClB,6BAA6B,EAC7B,KAAK,CAAC,KAAK,CAAC,OAAO,EACnB,KAAK,CAAC,KAAK,CAAC,KAAK,CAClB,CAAC;oBACF,OAAO;gBACT,CAAC;gBACD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtC,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,OAAO,EAAE,CACZ,gBAAO,CAAC,UAAU,EAClB,0BAA0B,EAC1B,KAAK,EAAE,OAAO,CACf,CAAC;YACJ,CAAC,CAAC,CAAC;QACP,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;;AAzDH,0CA0DC"}

View File

@ -0,0 +1,18 @@
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { URLPattern } from 'urlpattern-polyfill';
export { URLPattern };

View File

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.URLPattern = void 0;
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const urlpattern_polyfill_1 = require("urlpattern-polyfill");
Object.defineProperty(exports, "URLPattern", { enumerable: true, get: function () { return urlpattern_polyfill_1.URLPattern; } });
// XXX: Switch to native URLPattern when available.
// https://github.com/nodejs/node/issues/40844
if ('URLPattern' in globalThis) {
urlpattern_polyfill_1.URLPattern = globalThis.URLPattern;
}
//# sourceMappingURL=UrlPattern.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"UrlPattern.js","sourceRoot":"","sources":["../../../src/utils/UrlPattern.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,6DAA+C;AAQvC,2FARA,gCAAU,OAQA;AANlB,mDAAmD;AACnD,8CAA8C;AAC9C,IAAI,YAAY,IAAI,UAAU,EAAE,CAAC;IAC9B,gCAAkB,GAAI,UAAkB,CAAC,UAAU,CAAC;AACvD,CAAC"}

View File

@ -0,0 +1,25 @@
/**
* Copyright 2021 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type WebSocket from 'ws';
import type { ITransport } from './transport.js';
export declare class WebSocketTransport implements ITransport {
#private;
constructor(websocket: WebSocket);
setOnMessage(onMessage: (message: string) => void): void;
sendMessage(message: string): void;
close(): void;
}

View File

@ -0,0 +1,41 @@
"use strict";
/**
* Copyright 2021 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebSocketTransport = void 0;
class WebSocketTransport {
#onMessage = null;
#websocket;
constructor(websocket) {
this.#websocket = websocket;
this.#websocket.on('message', (message) => {
this.#onMessage?.(message);
});
}
setOnMessage(onMessage) {
this.#onMessage = onMessage;
}
sendMessage(message) {
this.#websocket.send(message);
}
close() {
this.#onMessage = null;
this.#websocket.close();
}
}
exports.WebSocketTransport = WebSocketTransport;
//# sourceMappingURL=WebsocketTransport.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"WebsocketTransport.js","sourceRoot":"","sources":["../../../src/utils/WebsocketTransport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAMH,MAAa,kBAAkB;IAC7B,UAAU,GAAuC,IAAI,CAAC;IAEtD,UAAU,CAAY;IAEtB,YAAY,SAAoB;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAe,EAAE,EAAE;YAChD,IAAI,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY,CAAC,SAAoC;QAC/C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,OAAe;QACzB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF;AAzBD,gDAyBC"}

View File

@ -0,0 +1,17 @@
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare function assert<T>(predicate: T, message?: string): asserts predicate;

View File

@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assert = void 0;
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function assert(predicate, message) {
if (!predicate) {
throw new Error(message ?? 'Internal assertion failed.');
}
}
exports.assert = assert;
//# sourceMappingURL=assert.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/utils/assert.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,MAAM,CAAI,SAAY,EAAE,OAAgB;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAJD,wBAIC"}

View File

@ -0,0 +1,25 @@
/**
* Copyright 2021 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare enum LogType {
bidi = "bidi",
cdp = "cdp",
debug = "debug",
debugError = "debug:error",
debugInfo = "debug:info"
}
export type LogPrefix = LogType | `${LogType}:${string}`;
export type LoggerFn = (type: LogPrefix, ...messages: unknown[]) => void;

View File

@ -0,0 +1,30 @@
"use strict";
/**
* Copyright 2021 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogType = void 0;
var LogType;
(function (LogType) {
// keep-sorted start
LogType["bidi"] = "bidi";
LogType["cdp"] = "cdp";
LogType["debug"] = "debug";
LogType["debugError"] = "debug:error";
LogType["debugInfo"] = "debug:info";
// keep-sorted end
})(LogType || (exports.LogType = LogType = {}));
//# sourceMappingURL=log.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/utils/log.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,IAAY,OAQX;AARD,WAAY,OAAO;IACjB,oBAAoB;IACpB,wBAAa,CAAA;IACb,sBAAW,CAAA;IACX,0BAAe,CAAA;IACf,qCAA0B,CAAA;IAC1B,mCAAwB,CAAA;IACxB,kBAAkB;AACpB,CAAC,EARW,OAAO,uBAAP,OAAO,QAQlB"}

View File

@ -0,0 +1,23 @@
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type Result<T, E = Error> = {
kind: 'success';
value: T;
} | {
kind: 'error';
error: E;
};

View File

@ -0,0 +1,19 @@
"use strict";
/**
* Copyright 2022 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=result.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/utils/result.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}

View File

@ -0,0 +1,25 @@
/**
* Copyright 2021 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Represents a low-level transport mechanism for raw text messages like
* a WebSocket, pipe, or Window binding.
*/
export interface ITransport {
setOnMessage: (handler: (message: string) => Promise<void> | void) => void;
sendMessage: (message: string) => Promise<void> | void;
close(): void;
}

View File

@ -0,0 +1,19 @@
"use strict";
/**
* Copyright 2021 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=transport.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/utils/transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}

View File

@ -0,0 +1,18 @@
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @return Given an input in cm, convert it to inches. */
export declare function inchesFromCm(cm: number): number;

View File

@ -0,0 +1,25 @@
"use strict";
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.inchesFromCm = void 0;
/** @return Given an input in cm, convert it to inches. */
function inchesFromCm(cm) {
return cm / 2.54;
}
exports.inchesFromCm = inchesFromCm;
//# sourceMappingURL=unitConversions.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"unitConversions.js","sourceRoot":"","sources":["../../../src/utils/unitConversions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,0DAA0D;AAC1D,SAAgB,YAAY,CAAC,EAAU;IACrC,OAAO,EAAE,GAAG,IAAI,CAAC;AACnB,CAAC;AAFD,oCAEC"}

View File

@ -0,0 +1,25 @@
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Generates a random v4 UUID, as specified in RFC4122.
*
* Uses the native Web Crypto API if available, otherwise falls back to a
* polyfill.
*
* Example: '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
*/
export declare function uuidv4(): `${string}-${string}-${string}-${string}-${string}`;

View File

@ -0,0 +1,63 @@
"use strict";
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuidv4 = void 0;
/**
* Generates a random v4 UUID, as specified in RFC4122.
*
* Uses the native Web Crypto API if available, otherwise falls back to a
* polyfill.
*
* Example: '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
*/
function uuidv4() {
// Available only in secure contexts
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API
if ('crypto' in globalThis && 'randomUUID' in globalThis.crypto) {
// Node with
// https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#crypto_1 or
// secure browser context.
return globalThis.crypto.randomUUID();
}
const randomValues = new Uint8Array(16);
if ('crypto' in globalThis && 'getRandomValues' in globalThis.crypto) {
// Node with
// https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#crypto_1 or
// browser.
globalThis.crypto.getRandomValues(randomValues);
}
else {
// Node without
// https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#crypto_1.
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('crypto').webcrypto.getRandomValues(randomValues);
}
// Set version (4) and variant (RFC4122) bits.
randomValues[6] = (randomValues[6] & 0x0f) | 0x40;
randomValues[8] = (randomValues[8] & 0x3f) | 0x80;
const bytesToHex = (bytes) => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
return [
bytesToHex(randomValues.subarray(0, 4)),
bytesToHex(randomValues.subarray(4, 6)),
bytesToHex(randomValues.subarray(6, 8)),
bytesToHex(randomValues.subarray(8, 10)),
bytesToHex(randomValues.subarray(10, 16)),
].join('-');
}
exports.uuidv4 = uuidv4;
//# sourceMappingURL=uuid.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;;;;;;GAOG;AACH,SAAgB,MAAM;IACpB,oCAAoC;IACpC,kEAAkE;IAClE,IAAI,QAAQ,IAAI,UAAU,IAAI,YAAY,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QAChE,YAAY;QACZ,yEAAyE;QACzE,0BAA0B;QAC1B,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAExC,IAAI,QAAQ,IAAI,UAAU,IAAI,iBAAiB,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QACrE,YAAY;QACZ,yEAAyE;QACzE,WAAW;QACX,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,eAAe;QACf,uEAAuE;QACvE,8DAA8D;QAC9D,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAC5D,CAAC;IAED,8CAA8C;IAC9C,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACnD,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAEnD,MAAM,UAAU,GAAG,CAAC,KAAiB,EAAE,EAAE,CACvC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAE5E,OAAO;QACL,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;KAC1C,CAAC,IAAI,CAAC,GAAG,CAAwD,CAAC;AACrE,CAAC;AAtCD,wBAsCC"}