Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

playwright-core

Package Overview
Dependencies
0
Maintainers
4
Versions
4380
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.45.0-alpha-2024-06-09 to 1.45.0-alpha-2024-06-10

lib/vite/recorder/assets/codeMirrorModule-Bzggq412.js

2

lib/generated/clockSource.js

@@ -7,2 +7,2 @@ "use strict";

exports.source = void 0;
const source = exports.source = "\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/playwright-core/src/server/injected/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar TimerType = /* @__PURE__ */ ((TimerType2) => {\n TimerType2[\"Timeout\"] = \"Timeout\";\n TimerType2[\"Interval\"] = \"Interval\";\n TimerType2[\"Immediate\"] = \"Immediate\";\n TimerType2[\"AnimationFrame\"] = \"AnimationFrame\";\n TimerType2[\"IdleCallback\"] = \"IdleCallback\";\n return TimerType2;\n})(TimerType || {});\nvar ClockController = class {\n constructor(embedder, startDate, loopLimit = 1e3) {\n this._adjustedSystemTime = 0;\n this._duringTick = false;\n this._timers = /* @__PURE__ */ new Map();\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n const start = Math.floor(getEpoch(startDate));\n this.start = start;\n this._now = start;\n this._embedder = embedder;\n this._loopLimit = loopLimit;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n return this._now;\n }\n performanceNow() {\n return this._now - this._adjustedSystemTime - this.start;\n }\n async _doTick(msFloat) {\n if (msFloat < 0)\n throw new TypeError(\"Negative ticks are not supported\");\n const ms = Math.floor(msFloat);\n let tickTo = this._now + ms;\n let tickFrom = this._now;\n let previous = this._now;\n let firstException;\n this._duringTick = true;\n let timer = this._firstTimerInRange(tickFrom, tickTo);\n while (timer && tickFrom <= tickTo) {\n tickFrom = timer.callAt;\n this._now = timer.callAt;\n const oldNow = this._now;\n try {\n this._callTimer(timer);\n await new Promise((f) => this._embedder.postTask(f));\n } catch (e) {\n firstException = firstException || e;\n }\n if (oldNow !== this._now) {\n tickFrom += this._now - oldNow;\n tickTo += this._now - oldNow;\n previous += this._now - oldNow;\n }\n timer = this._firstTimerInRange(previous, tickTo);\n previous = tickFrom;\n }\n this._duringTick = false;\n this._now = tickTo;\n if (firstException)\n throw firstException;\n return this._now;\n }\n async recordTick(tickValue) {\n const msFloat = parseTime(tickValue);\n this._now += msFloat;\n }\n async tick(tickValue) {\n return await this._doTick(parseTime(tickValue));\n }\n async next() {\n const timer = this._firstTimer();\n if (!timer)\n return this._now;\n let err;\n this._duringTick = true;\n this._now = timer.callAt;\n try {\n this._callTimer(timer);\n await new Promise((f) => this._embedder.postTask(f));\n } catch (e) {\n err = e;\n }\n this._duringTick = false;\n if (err)\n throw err;\n return this._now;\n }\n async runToFrame() {\n return this.tick(this.getTimeToNextFrame());\n }\n async runAll() {\n for (let i = 0; i < this._loopLimit; i++) {\n const numTimers = this._timers.size;\n if (numTimers === 0)\n return this._now;\n await this.next();\n }\n const excessJob = this._firstTimer();\n if (!excessJob)\n return;\n throw this._getInfiniteLoopError(excessJob);\n }\n async runToLast() {\n const timer = this._lastTimer();\n if (!timer)\n return this._now;\n return await this.tick(timer.callAt - this._now);\n }\n reset() {\n this._timers.clear();\n this._now = this.start;\n }\n setSystemTime(systemTime) {\n const newNow = getEpoch(systemTime);\n const difference = newNow - this._now;\n this._adjustedSystemTime = this._adjustedSystemTime + difference;\n this._now = newNow;\n for (const timer of this._timers.values()) {\n timer.createdAt += difference;\n timer.callAt += difference;\n }\n }\n async jump(tickValue) {\n const msFloat = parseTime(tickValue);\n const ms = Math.floor(msFloat);\n for (const timer of this._timers.values()) {\n if (this._now + ms > timer.callAt)\n timer.callAt = this._now + ms;\n }\n return await this.tick(ms);\n }\n addTimer(options) {\n if (options.func === void 0)\n throw new Error(\"Callback must be provided to timer calls\");\n let delay = options.delay ? +options.delay : 0;\n if (!Number.isFinite(delay))\n delay = 0;\n delay = delay > maxTimeout ? 1 : delay;\n delay = Math.max(0, delay);\n const timer = {\n type: options.type,\n func: options.func,\n args: options.args || (() => []),\n delay,\n callAt: this._now + (delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n return timer.id;\n }\n _firstTimerInRange(from, to) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = inRange(from, to, timer);\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer() {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n if (!firstTimer || compareTimers(firstTimer, timer) === 1)\n firstTimer = timer;\n }\n return firstTimer;\n }\n _lastTimer() {\n let lastTimer = null;\n for (const timer of this._timers.values()) {\n if (!lastTimer || compareTimers(lastTimer, timer) === -1)\n lastTimer = timer;\n }\n return lastTimer;\n }\n _callTimer(timer) {\n if (timer.type === \"Interval\" /* Interval */)\n this._timers.get(timer.id).callAt += timer.delay;\n else\n this._timers.delete(timer.id);\n callFunction(timer.func, timer.args());\n }\n _getInfiniteLoopError(job) {\n const infiniteLoopError = new Error(\n `Aborting after running ${this._loopLimit} timers, assuming an infinite loop!`\n );\n if (!job.error)\n return infiniteLoopError;\n const computedTargetPattern = /target\\.*[<|(|[].*?[>|\\]|)]\\s*/;\n const clockMethodPattern = new RegExp(\n String(Object.keys(this).join(\"|\"))\n );\n let matchedLineIndex = -1;\n job.error.stack.split(\"\\n\").some((line, i) => {\n const matchedComputedTarget = line.match(computedTargetPattern);\n if (matchedComputedTarget) {\n matchedLineIndex = i;\n return true;\n }\n const matchedClockMethod = line.match(clockMethodPattern);\n if (matchedClockMethod) {\n matchedLineIndex = i;\n return false;\n }\n return matchedLineIndex >= 0;\n });\n const funcName = typeof job.func === \"function\" ? job.func.name : \"anonymous\";\n const stack = `${infiniteLoopError}\n${job.type || \"Microtask\"} - ${funcName}\n${job.error.stack.split(\"\\n\").slice(matchedLineIndex + 1).join(\"\\n\")}`;\n infiniteLoopError.stack = stack;\n return infiniteLoopError;\n }\n getTimeToNextFrame() {\n return 16 - (this._now - this.start) % 16;\n }\n clearTimer(timerId, type) {\n if (!timerId) {\n return;\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(type);\n new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);\n }\n const timer = this._timers.get(id);\n if (timer) {\n if (timer.type === type || timer.type === \"Timeout\" && type === \"Interval\" || timer.type === \"Interval\" && type === \"Timeout\") {\n this._timers.delete(id);\n } else {\n const clear = getClearHandler(type);\n const schedule = getScheduleHandler(timer.type);\n throw new Error(\n `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`\n );\n }\n }\n }\n advanceAutomatically(advanceTimeDelta = 20) {\n return this._embedder.postTaskPeriodically(\n () => this.tick(advanceTimeDelta),\n advanceTimeDelta\n );\n }\n};\nfunction getEpoch(epoch) {\n if (!epoch)\n return 0;\n if (typeof epoch !== \"number\")\n return epoch.getTime();\n return epoch;\n}\nfunction inRange(from, to, timer) {\n return timer && timer.callAt >= from && timer.callAt <= to;\n}\nfunction parseTime(value) {\n if (typeof value === \"number\")\n return value;\n if (!value)\n return 0;\n const str = value;\n const strings = str.split(\":\");\n const l = strings.length;\n let i = l;\n let ms = 0;\n let parsed;\n if (l > 3 || !/^(\\d\\d:){0,2}\\d\\d?$/.test(str)) {\n throw new Error(\n `Clock only understands numbers, 'mm:ss' and 'hh:mm:ss'`\n );\n }\n while (i--) {\n parsed = parseInt(strings[i], 10);\n if (parsed >= 60)\n throw new Error(`Invalid time ${str}`);\n ms += parsed * Math.pow(60, l - i - 1);\n }\n return ms * 1e3;\n}\nfunction mirrorDateProperties(target, source) {\n let prop;\n for (prop of Object.keys(source))\n target[prop] = source[prop];\n target.toString = () => source.toString();\n target.prototype = source.prototype;\n target.parse = source.parse;\n target.UTC = source.UTC;\n target.prototype.toUTCString = source.prototype.toUTCString;\n target.isFake = true;\n return target;\n}\nfunction createDate(clock, NativeDate) {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate))\n return new NativeDate(clock.now()).toString();\n switch (arguments.length) {\n case 0:\n return new NativeDate(clock.now());\n case 1:\n return new NativeDate(year);\n case 2:\n return new NativeDate(year, month);\n case 3:\n return new NativeDate(year, month, date);\n case 4:\n return new NativeDate(year, month, date, hour);\n case 5:\n return new NativeDate(year, month, date, hour, minute);\n case 6:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second\n );\n default:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second,\n ms\n );\n }\n }\n ClockDate.now = () => clock.now();\n return mirrorDateProperties(ClockDate, NativeDate);\n}\nfunction createIntl(clock, NativeIntl) {\n const ClockIntl = {};\n for (const key of Object.keys(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args2) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args2);\n const formatter = {\n formatRange: realFormatter.formatRange.bind(realFormatter),\n formatRangeToParts: realFormatter.formatRangeToParts.bind(realFormatter),\n resolvedOptions: realFormatter.resolvedOptions.bind(realFormatter),\n format: (date) => realFormatter.format(date || clock.now()),\n formatToParts: (date) => realFormatter.formatToParts(date || clock.now())\n };\n return formatter;\n };\n ClockIntl.DateTimeFormat.prototype = Object.create(\n NativeIntl.DateTimeFormat.prototype\n );\n ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;\n return ClockIntl;\n}\nfunction compareTimers(a, b) {\n if (a.callAt < b.callAt)\n return -1;\n if (a.callAt > b.callAt)\n return 1;\n if (a.type === \"Immediate\" /* Immediate */ && b.type !== \"Immediate\" /* Immediate */)\n return -1;\n if (a.type !== \"Immediate\" /* Immediate */ && b.type === \"Immediate\" /* Immediate */)\n return 1;\n if (a.createdAt < b.createdAt)\n return -1;\n if (a.createdAt > b.createdAt)\n return 1;\n if (a.id < b.id)\n return -1;\n if (a.id > b.id)\n return 1;\n}\nfunction callFunction(func, args) {\n if (typeof func === \"function\")\n func.apply(null, args);\n else\n (() => {\n eval(func);\n })();\n}\nvar maxTimeout = Math.pow(2, 31) - 1;\nvar idCounterStart = 1e12;\nfunction platformOriginals(globalObject) {\n const raw = {\n setTimeout: globalObject.setTimeout,\n clearTimeout: globalObject.clearTimeout,\n setInterval: globalObject.setInterval,\n clearInterval: globalObject.clearInterval,\n requestAnimationFrame: globalObject.requestAnimationFrame ? globalObject.requestAnimationFrame : void 0,\n cancelAnimationFrame: globalObject.cancelAnimationFrame ? globalObject.cancelAnimationFrame : void 0,\n requestIdleCallback: globalObject.requestIdleCallback ? globalObject.requestIdleCallback : void 0,\n cancelIdleCallback: globalObject.cancelIdleCallback ? globalObject.cancelIdleCallback : void 0,\n Date: globalObject.Date,\n performance: globalObject.performance,\n Intl: globalObject.Intl\n };\n const bound = { ...raw };\n for (const key of Object.keys(bound)) {\n if (key !== \"Date\" && typeof bound[key] === \"function\")\n bound[key] = bound[key].bind(globalObject);\n }\n return { raw, bound };\n}\nfunction getScheduleHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `request${type}`;\n return `set${type}`;\n}\nfunction createApi(clock, originals) {\n return {\n setTimeout: (func2, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Timeout\" /* Timeout */,\n func: func2,\n args: () => args2,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, \"Timeout\" /* Timeout */);\n },\n setInterval: (func2, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Interval\" /* Interval */,\n func: func2,\n args: () => args2,\n delay\n });\n },\n clearInterval: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"Interval\" /* Interval */);\n },\n requestAnimationFrame: (callback) => {\n return clock.addTimer({\n type: \"AnimationFrame\" /* AnimationFrame */,\n func: callback,\n delay: clock.getTimeToNextFrame(),\n args: () => [clock.performanceNow()]\n });\n },\n cancelAnimationFrame: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"AnimationFrame\" /* AnimationFrame */);\n },\n requestIdleCallback: (callback, options) => {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0)\n timeToNextIdlePeriod = 50;\n return clock.addTimer({\n type: \"IdleCallback\" /* IdleCallback */,\n func: callback,\n args: () => [],\n delay: (options == null ? void 0 : options.timeout) ? Math.min(options == null ? void 0 : options.timeout, timeToNextIdlePeriod) : timeToNextIdlePeriod\n });\n },\n cancelIdleCallback: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"IdleCallback\" /* IdleCallback */);\n },\n Intl: originals.Intl ? createIntl(clock, originals.Intl) : void 0,\n Date: createDate(clock, originals.Date),\n performance: originals.performance ? fakePerformance(clock, originals.performance) : void 0\n };\n}\nfunction getClearHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `cancel${type}`;\n return `clear${type}`;\n}\nfunction fakePerformance(clock, performance) {\n const result = {\n now: () => clock.performanceNow(),\n timeOrigin: clock.start\n };\n for (const key of Object.keys(performance.__proto__)) {\n if (key === \"now\" || key === \"timeOrigin\")\n continue;\n if (key === \"getEntries\" || key === \"getEntriesByName\" || key === \"getEntriesByType\")\n result[key] = () => [];\n else\n result[key] = () => {\n };\n }\n return result;\n}\nfunction createClock(globalObject, config = {}) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n postTask: (task) => {\n originals.bound.setTimeout(task, 0);\n },\n postTaskPeriodically: (task, delay) => {\n const intervalId = globalObject.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder, config.now, config.loopLimit);\n const api = createApi(clock, originals.bound);\n return { clock, api, originals: originals.raw };\n}\nfunction install(globalObject, config = {}) {\n var _a, _b;\n if ((_a = globalObject.Date) == null ? void 0 : _a.isFake) {\n throw new TypeError(`Can't install fake timers twice on the same global object.`);\n }\n const { clock, api, originals } = createClock(globalObject, config);\n const toFake = ((_b = config.toFake) == null ? void 0 : _b.length) ? config.toFake : Object.keys(originals);\n for (const method of toFake) {\n if (method === \"Date\") {\n globalObject.Date = mirrorDateProperties(api.Date, globalObject.Date);\n } else if (method === \"Intl\") {\n globalObject.Intl = api[method];\n } else if (method === \"performance\") {\n globalObject.performance = api[method];\n } else {\n globalObject[method] = (...args2) => {\n return api[method].apply(api, args2);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n return {\n install: (config) => {\n const { clock } = install(globalObject, config);\n return clock;\n },\n builtin: platformOriginals(globalObject).bound\n };\n}\n";
const source = exports.source = "\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/playwright-core/src/server/injected/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar TimerType = /* @__PURE__ */ ((TimerType2) => {\n TimerType2[\"Timeout\"] = \"Timeout\";\n TimerType2[\"Interval\"] = \"Interval\";\n TimerType2[\"Immediate\"] = \"Immediate\";\n TimerType2[\"AnimationFrame\"] = \"AnimationFrame\";\n TimerType2[\"IdleCallback\"] = \"IdleCallback\";\n return TimerType2;\n})(TimerType || {});\nvar ClockController = class {\n constructor(embedder, startDate, loopLimit = 1e3) {\n this._duringTick = false;\n this._timers = /* @__PURE__ */ new Map();\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n const start = Math.floor(getEpoch(startDate));\n this.timeOrigin = start;\n this._now = { time: start, ticks: 0, timeFrozen: false };\n this._embedder = embedder;\n this._loopLimit = loopLimit;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n return this._now.time;\n }\n setTime(now, options = {}) {\n this._now.time = getEpoch(now);\n this._now.timeFrozen = !!options.freeze;\n }\n performanceNow() {\n return this._now.ticks;\n }\n _advanceNow(toTicks) {\n if (!this._now.timeFrozen)\n this._now.time += toTicks - this._now.ticks;\n this._now.ticks = toTicks;\n }\n async _doTick(msFloat) {\n if (msFloat < 0)\n throw new TypeError(\"Negative ticks are not supported\");\n const ms = Math.floor(msFloat);\n const tickTo = this._now.ticks + ms;\n let tickFrom = this._now.ticks;\n let previous = this._now.ticks;\n let firstException;\n let timer2 = this._firstTimerInRange(tickFrom, tickTo);\n while (timer2 && tickFrom <= tickTo) {\n tickFrom = timer2.callAt;\n const error = await this._callTimer(timer2).catch((e) => e);\n firstException = firstException || error;\n timer2 = this._firstTimerInRange(previous, tickTo);\n previous = tickFrom;\n }\n this._advanceNow(tickTo);\n if (firstException)\n throw firstException;\n return this._now.ticks;\n }\n async recordTick(tickValue) {\n const msFloat = parseTime(tickValue);\n this._advanceNow(this._now.ticks + msFloat);\n }\n async tick(tickValue) {\n return await this._doTick(parseTime(tickValue));\n }\n async next() {\n const timer2 = this._firstTimer();\n if (!timer2)\n return this._now.ticks;\n await this._callTimer(timer2);\n return this._now.ticks;\n }\n async runToFrame() {\n return this.tick(this.getTimeToNextFrame());\n }\n async runAll() {\n for (let i = 0; i < this._loopLimit; i++) {\n const numTimers = this._timers.size;\n if (numTimers === 0)\n return this._now.ticks;\n await this.next();\n }\n const excessJob = this._firstTimer();\n if (!excessJob)\n return this._now.ticks;\n throw this._getInfiniteLoopError(excessJob);\n }\n async runToLast() {\n const timer2 = this._lastTimer();\n if (!timer2)\n return this._now.ticks;\n return await this.tick(timer2.callAt - this._now.ticks);\n }\n reset() {\n this._timers.clear();\n this._now = { time: this.timeOrigin, ticks: 0, timeFrozen: false };\n }\n async jump(tickValue) {\n const msFloat = parseTime(tickValue);\n const ms = Math.floor(msFloat);\n for (const timer2 of this._timers.values()) {\n if (this._now.ticks + ms > timer2.callAt)\n timer2.callAt = this._now.ticks + ms;\n }\n return await this.tick(ms);\n }\n addTimer(options) {\n if (options.func === void 0)\n throw new Error(\"Callback must be provided to timer calls\");\n let delay = options.delay ? +options.delay : 0;\n if (!Number.isFinite(delay))\n delay = 0;\n delay = delay > maxTimeout ? 1 : delay;\n delay = Math.max(0, delay);\n const timer2 = {\n type: options.type,\n func: options.func,\n args: options.args || [],\n delay,\n callAt: this._now.ticks + (delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now.ticks,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer2.id, timer2);\n return timer2.id;\n }\n _firstTimerInRange(from, to) {\n let firstTimer = null;\n for (const timer2 of this._timers.values()) {\n const isInRange = inRange(from, to, timer2);\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer2) === 1))\n firstTimer = timer2;\n }\n return firstTimer;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer() {\n let firstTimer = null;\n for (const timer2 of this._timers.values()) {\n if (!firstTimer || compareTimers(firstTimer, timer2) === 1)\n firstTimer = timer2;\n }\n return firstTimer;\n }\n _lastTimer() {\n let lastTimer = null;\n for (const timer2 of this._timers.values()) {\n if (!lastTimer || compareTimers(lastTimer, timer2) === -1)\n lastTimer = timer2;\n }\n return lastTimer;\n }\n async _callTimer(timer) {\n this._advanceNow(timer.callAt);\n if (timer.type === \"Interval\" /* Interval */)\n this._timers.get(timer.id).callAt += timer.delay;\n else\n this._timers.delete(timer.id);\n this._duringTick = true;\n try {\n if (typeof timer.func !== \"function\") {\n (() => {\n eval(timer.func);\n })();\n return;\n }\n let args = timer.args;\n if (timer.type === \"AnimationFrame\" /* AnimationFrame */)\n args = [this._now.ticks];\n else if (timer.type === \"IdleCallback\" /* IdleCallback */)\n args = [{ didTimeout: false, timeRemaining: () => 0 }];\n timer.func.apply(null, args);\n await new Promise((f) => this._embedder.postTask(f));\n } finally {\n this._duringTick = false;\n }\n }\n _getInfiniteLoopError(job) {\n const infiniteLoopError = new Error(\n `Aborting after running ${this._loopLimit} timers, assuming an infinite loop!`\n );\n if (!job.error)\n return infiniteLoopError;\n const computedTargetPattern = /target\\.*[<|(|[].*?[>|\\]|)]\\s*/;\n const clockMethodPattern = new RegExp(\n String(Object.keys(this).join(\"|\"))\n );\n let matchedLineIndex = -1;\n job.error.stack.split(\"\\n\").some((line, i) => {\n const matchedComputedTarget = line.match(computedTargetPattern);\n if (matchedComputedTarget) {\n matchedLineIndex = i;\n return true;\n }\n const matchedClockMethod = line.match(clockMethodPattern);\n if (matchedClockMethod) {\n matchedLineIndex = i;\n return false;\n }\n return matchedLineIndex >= 0;\n });\n const funcName = typeof job.func === \"function\" ? job.func.name : \"anonymous\";\n const stack = `${infiniteLoopError}\n${job.type || \"Microtask\"} - ${funcName}\n${job.error.stack.split(\"\\n\").slice(matchedLineIndex + 1).join(\"\\n\")}`;\n infiniteLoopError.stack = stack;\n return infiniteLoopError;\n }\n getTimeToNextFrame() {\n return 16 - this._now.ticks % 16;\n }\n clearTimer(timerId, type) {\n if (!timerId) {\n return;\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(type);\n new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);\n }\n const timer2 = this._timers.get(id);\n if (timer2) {\n if (timer2.type === type || timer2.type === \"Timeout\" && type === \"Interval\" || timer2.type === \"Interval\" && type === \"Timeout\") {\n this._timers.delete(id);\n } else {\n const clear = getClearHandler(type);\n const schedule = getScheduleHandler(timer2.type);\n throw new Error(\n `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`\n );\n }\n }\n }\n advanceAutomatically(advanceTimeDelta = 20) {\n return this._embedder.postTaskPeriodically(\n () => this._doTick(advanceTimeDelta),\n advanceTimeDelta\n );\n }\n};\nfunction getEpoch(epoch) {\n if (!epoch)\n return 0;\n if (typeof epoch !== \"number\")\n return epoch.getTime();\n return epoch;\n}\nfunction inRange(from, to, timer2) {\n return timer2 && timer2.callAt >= from && timer2.callAt <= to;\n}\nfunction parseTime(value) {\n if (typeof value === \"number\")\n return value;\n if (!value)\n return 0;\n const str = value;\n const strings = str.split(\":\");\n const l = strings.length;\n let i = l;\n let ms = 0;\n let parsed;\n if (l > 3 || !/^(\\d\\d:){0,2}\\d\\d?$/.test(str)) {\n throw new Error(\n `Clock only understands numbers, 'mm:ss' and 'hh:mm:ss'`\n );\n }\n while (i--) {\n parsed = parseInt(strings[i], 10);\n if (parsed >= 60)\n throw new Error(`Invalid time ${str}`);\n ms += parsed * Math.pow(60, l - i - 1);\n }\n return ms * 1e3;\n}\nfunction mirrorDateProperties(target, source) {\n let prop;\n for (prop of Object.keys(source))\n target[prop] = source[prop];\n target.toString = () => source.toString();\n target.prototype = source.prototype;\n target.parse = source.parse;\n target.UTC = source.UTC;\n target.prototype.toUTCString = source.prototype.toUTCString;\n target.isFake = true;\n return target;\n}\nfunction createDate(clock, NativeDate) {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate))\n return new NativeDate(clock.now()).toString();\n switch (arguments.length) {\n case 0:\n return new NativeDate(clock.now());\n case 1:\n return new NativeDate(year);\n case 2:\n return new NativeDate(year, month);\n case 3:\n return new NativeDate(year, month, date);\n case 4:\n return new NativeDate(year, month, date, hour);\n case 5:\n return new NativeDate(year, month, date, hour, minute);\n case 6:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second\n );\n default:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second,\n ms\n );\n }\n }\n ClockDate.now = () => clock.now();\n return mirrorDateProperties(ClockDate, NativeDate);\n}\nfunction createIntl(clock, NativeIntl) {\n const ClockIntl = {};\n for (const key of Object.keys(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args2) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args2);\n const formatter = {\n formatRange: realFormatter.formatRange.bind(realFormatter),\n formatRangeToParts: realFormatter.formatRangeToParts.bind(realFormatter),\n resolvedOptions: realFormatter.resolvedOptions.bind(realFormatter),\n format: (date) => realFormatter.format(date || clock.now()),\n formatToParts: (date) => realFormatter.formatToParts(date || clock.now())\n };\n return formatter;\n };\n ClockIntl.DateTimeFormat.prototype = Object.create(\n NativeIntl.DateTimeFormat.prototype\n );\n ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;\n return ClockIntl;\n}\nfunction compareTimers(a, b) {\n if (a.callAt < b.callAt)\n return -1;\n if (a.callAt > b.callAt)\n return 1;\n if (a.type === \"Immediate\" /* Immediate */ && b.type !== \"Immediate\" /* Immediate */)\n return -1;\n if (a.type !== \"Immediate\" /* Immediate */ && b.type === \"Immediate\" /* Immediate */)\n return 1;\n if (a.createdAt < b.createdAt)\n return -1;\n if (a.createdAt > b.createdAt)\n return 1;\n if (a.id < b.id)\n return -1;\n if (a.id > b.id)\n return 1;\n}\nvar maxTimeout = Math.pow(2, 31) - 1;\nvar idCounterStart = 1e12;\nfunction platformOriginals(globalObject) {\n const raw = {\n setTimeout: globalObject.setTimeout,\n clearTimeout: globalObject.clearTimeout,\n setInterval: globalObject.setInterval,\n clearInterval: globalObject.clearInterval,\n requestAnimationFrame: globalObject.requestAnimationFrame ? globalObject.requestAnimationFrame : void 0,\n cancelAnimationFrame: globalObject.cancelAnimationFrame ? globalObject.cancelAnimationFrame : void 0,\n requestIdleCallback: globalObject.requestIdleCallback ? globalObject.requestIdleCallback : void 0,\n cancelIdleCallback: globalObject.cancelIdleCallback ? globalObject.cancelIdleCallback : void 0,\n Date: globalObject.Date,\n performance: globalObject.performance,\n Intl: globalObject.Intl\n };\n const bound = { ...raw };\n for (const key of Object.keys(bound)) {\n if (key !== \"Date\" && typeof bound[key] === \"function\")\n bound[key] = bound[key].bind(globalObject);\n }\n return { raw, bound };\n}\nfunction getScheduleHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `request${type}`;\n return `set${type}`;\n}\nfunction createApi(clock, originals) {\n return {\n setTimeout: (func, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Timeout\" /* Timeout */,\n func,\n args: args2,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, \"Timeout\" /* Timeout */);\n },\n setInterval: (func, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Interval\" /* Interval */,\n func,\n args: args2,\n delay\n });\n },\n clearInterval: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"Interval\" /* Interval */);\n },\n requestAnimationFrame: (callback) => {\n return clock.addTimer({\n type: \"AnimationFrame\" /* AnimationFrame */,\n func: callback,\n delay: clock.getTimeToNextFrame()\n });\n },\n cancelAnimationFrame: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"AnimationFrame\" /* AnimationFrame */);\n },\n requestIdleCallback: (callback, options) => {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0)\n timeToNextIdlePeriod = 50;\n return clock.addTimer({\n type: \"IdleCallback\" /* IdleCallback */,\n func: callback,\n delay: (options == null ? void 0 : options.timeout) ? Math.min(options == null ? void 0 : options.timeout, timeToNextIdlePeriod) : timeToNextIdlePeriod\n });\n },\n cancelIdleCallback: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"IdleCallback\" /* IdleCallback */);\n },\n Intl: originals.Intl ? createIntl(clock, originals.Intl) : void 0,\n Date: createDate(clock, originals.Date),\n performance: originals.performance ? fakePerformance(clock, originals.performance) : void 0\n };\n}\nfunction getClearHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `cancel${type}`;\n return `clear${type}`;\n}\nfunction fakePerformance(clock, performance) {\n const result = {\n now: () => clock.performanceNow(),\n timeOrigin: clock.timeOrigin\n };\n for (const key of Object.keys(performance.__proto__)) {\n if (key === \"now\" || key === \"timeOrigin\")\n continue;\n if (key === \"getEntries\" || key === \"getEntriesByName\" || key === \"getEntriesByType\")\n result[key] = () => [];\n else\n result[key] = () => {\n };\n }\n return result;\n}\nfunction createClock(globalObject, config = {}) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n postTask: (task) => {\n originals.bound.setTimeout(task, 0);\n },\n postTaskPeriodically: (task, delay) => {\n const intervalId = globalObject.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder, config.now, config.loopLimit);\n const api = createApi(clock, originals.bound);\n return { clock, api, originals: originals.raw };\n}\nfunction install(globalObject, config = {}) {\n var _a, _b;\n if ((_a = globalObject.Date) == null ? void 0 : _a.isFake) {\n throw new TypeError(`Can't install fake timers twice on the same global object.`);\n }\n const { clock, api, originals } = createClock(globalObject, config);\n const toFake = ((_b = config.toFake) == null ? void 0 : _b.length) ? config.toFake : Object.keys(originals);\n for (const method of toFake) {\n if (method === \"Date\") {\n globalObject.Date = mirrorDateProperties(api.Date, globalObject.Date);\n } else if (method === \"Intl\") {\n globalObject.Intl = api[method];\n } else if (method === \"performance\") {\n globalObject.performance = api[method];\n } else {\n globalObject[method] = (...args2) => {\n return api[method].apply(api, args2);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n return {\n install: (config) => {\n const { clock } = install(globalObject, config);\n return clock;\n },\n builtin: platformOriginals(globalObject).bound\n };\n}\n";
{
"name": "playwright-core",
"version": "1.45.0-alpha-2024-06-09",
"version": "1.45.0-alpha-2024-06-10",
"description": "A high-level API to automate web browsers",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc