Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove stackTrace => path dependency #34763

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions packages/playwright-core/ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This project incorporates components from the projects listed below. The origina
- brace-expansion@1.1.11 (https://github.com/juliangruber/brace-expansion)
- buffer-crc32@0.2.13 (https://github.com/brianloveswords/buffer-crc32)
- codemirror@5.65.18 (https://github.com/codemirror/CodeMirror)
- colors@1.4.0 (https://github.com/Marak/colors.js)
- commander@8.3.0 (https://github.com/tj/commander.js)
- concat-map@0.0.1 (https://github.com/substack/node-concat-map)
- debug@4.3.4 (https://github.com/debug-js/debug)
Expand Down Expand Up @@ -355,36 +354,6 @@ THE SOFTWARE.
=========================================
END OF codemirror@5.65.18 AND INFORMATION

%% colors@1.4.0 NOTICES AND INFORMATION BEGIN HERE
=========================================
MIT License

Original Library
- Copyright (c) Marak Squires

Additional Functionality
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
=========================================
END OF colors@1.4.0 AND INFORMATION

%% commander@8.3.0 NOTICES AND INFORMATION BEGIN HERE
=========================================
(The MIT License)
Expand Down Expand Up @@ -1555,6 +1524,6 @@ END OF yazl@2.5.1 AND INFORMATION

SUMMARY BEGIN HERE
=========================================
Total Packages: 46
Total Packages: 45
=========================================
END OF SUMMARY
9 changes: 0 additions & 9 deletions packages/playwright-core/bundles/utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/playwright-core/bundles/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
},
"dependencies": {
"colors": "1.4.0",
"commander": "8.3.0",
"debug": "^4.3.4",
"diff": "^7.0.0",
Expand Down
3 changes: 0 additions & 3 deletions packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

/* eslint-disable import/order */

import colorsLibrary from 'colors/safe';
export const colors = colorsLibrary;

import debugLibrary from 'debug';
export const debug = debugLibrary;

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/browserServerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { helper } from './server/helper';
import { serverSideCallMetadata } from './server/instrumentation';
import { createPlaywright } from './server/playwright';
import { createGuid } from './server/utils/crypto';
import { rewriteErrorMessage } from './utils/stackTrace';
import { rewriteErrorMessage } from './utils/isomorphic/stackTrace';
import { ws } from './utilsBundle';

import type { BrowserServer, BrowserServerLauncher } from './client/browserType';
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/client/browserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { mkdirIfNeeded } from '../utils/fileUtils';
import { headersObjectToArray } from '../utils/isomorphic/headers';
import { urlMatchesEqual } from '../utils/isomorphic/urlMatch';
import { isRegExp, isString } from '../utils/isomorphic/rtti';
import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';

import type { BrowserType } from './browserType';
import type { BrowserContextOptions, Headers, LaunchOptions, StorageState, WaitForEventOptions } from './types';
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/client/channelOwner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { EventEmitter } from './eventEmitter';
import { ValidationError, maybeFindValidator } from '../protocol/validator';
import { isUnderTest } from '../utils/debug';
import { debugLogger } from '../utils/debugLogger';
import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/stackTrace';
import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';

import type { ClientInstrumentation } from './clientInstrumentation';
Expand Down Expand Up @@ -183,7 +183,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel

if (isInternal === undefined)
isInternal = this._isInternalType;
const stackTrace = captureLibraryStackTrace();
const stackTrace = captureLibraryStackTrace(this._platform.pathSeparator);
const apiZone: ApiZone = { apiName: stackTrace.apiName, frames: stackTrace.frames, isInternal, reported: false, userData: undefined, stepId: undefined };

try {
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/client/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { Worker } from './worker';
import { WritableStream } from './writableStream';
import { ValidationError, findValidator } from '../protocol/validator';
import { debugLogger } from '../utils/debugLogger';
import { formatCallLog, rewriteErrorMessage } from '../utils/stackTrace';
import { formatCallLog, rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';

import type { ClientInstrumentation } from './clientInstrumentation';
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/client/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { urlMatches } from '../utils/isomorphic/urlMatch';
import { LongStandingScope, ManualPromise } from '../utils/isomorphic/manualPromise';
import { MultiMap } from '../utils/isomorphic/multimap';
import { isRegExp, isString } from '../utils/isomorphic/rtti';
import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';
import { mime } from '../utilsBundle';

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/client/waiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { TimeoutError } from './errors';
import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';

import type { ChannelOwner } from './channelOwner';
Expand Down
4 changes: 4 additions & 0 deletions packages/playwright-core/src/inProcessFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@
* limitations under the License.
*/

import path from 'path';

import { AndroidServerLauncherImpl } from './androidServerImpl';
import { BrowserServerLauncherImpl } from './browserServerImpl';
import { Connection } from './client/connection';
import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from './server';
import { setLibraryStackPrefix } from './utils/isomorphic/stackTrace';

import type { Playwright as PlaywrightAPI } from './client/playwright';
import type { Language } from './utils';
import type { Platform } from './utils/platform';

export function createInProcessPlaywright(platform: Platform): PlaywrightAPI {
const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });
setLibraryStackPrefix(path.join(__dirname, '..'));

const clientConnection = new Connection(undefined, platform, undefined, []);
clientConnection.useRawBuffers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { getExceptionMessage, releaseObject } from './crProtocolHelper';
import { rewriteErrorMessage } from '../../utils/stackTrace';
import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';
import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers';
import * as js from '../javascript';
import { isSessionClosedError } from '../protocolError';
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/chromium/crPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as path from 'path';
import { assert } from '../../utils/debug';
import { createGuid } from '../utils/crypto';
import { eventsHelper } from '../utils/eventsHelper';
import { rewriteErrorMessage } from '../../utils/stackTrace';
import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';
import * as dialog from '../dialog';
import * as dom from '../dom';
import * as frames from '../frames';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import * as fs from 'fs';

import { splitErrorMessage } from '../../utils/stackTrace';
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
import { mkdirIfNeeded } from '../utils/fileUtils';

import type { CRSession } from './crConnection';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { rewriteErrorMessage } from '../../utils/stackTrace';
import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';
import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers';
import * as js from '../javascript';
import { isSessionClosedError } from '../protocolError';
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/firefox/ffPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { FFExecutionContext } from './ffExecutionContext';
import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './ffInput';
import { FFNetworkManager } from './ffNetworkManager';
import { debugLogger } from '../../utils/debugLogger';
import { splitErrorMessage } from '../../utils/stackTrace';
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
import { BrowserContext } from '../browserContext';
import { TargetClosedError } from '../errors';

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/protocolError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';

export class ProtocolError extends Error {
type: 'error' | 'closed' | 'crashed';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import * as path from 'path';
import { debugLogger } from '../../utils/debugLogger';
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
import { getUserAgent } from '../../utils/userAgent';
import { colors, progress as ProgressBar } from '../../utilsBundle';
import { progress as ProgressBar } from '../../utilsBundle';
import { colors } from '../../utils/isomorphic/colors';
import { existsAsync } from '../utils/fileUtils';

import { browserDirectoryToMarkerFilePath } from '.';
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright-core/src/server/utils/comparators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import { compare } from './image_tools/compare';
// @ts-ignore
import pixelmatch from '../../third_party/pixelmatch';
import { colors, jpegjs } from '../../utilsBundle';
import { jpegjs } from '../../utilsBundle';
import { colors } from '../../utils/isomorphic/colors';
import { diff } from '../../utilsBundle';
import { PNG } from '../../utilsBundle';

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/webkit/wkPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { headersArrayToObject } from '../../utils/isomorphic/headers';
import { createGuid } from '../utils/crypto';
import { eventsHelper } from '../utils/eventsHelper';
import { hostPlatform } from '../../utils/hostPlatform';
import { splitErrorMessage } from '../../utils/stackTrace';
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
import { PNG, jpegjs } from '../../utilsBundle';
import { BrowserContext } from '../browserContext';
import * as dialog from '../dialog';
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

export * from './utils/isomorphic/colors';
export * from './utils/isomorphic/locatorGenerators';
export * from './utils/isomorphic/manualPromise';
export * from './utils/isomorphic/mimeType';
Expand All @@ -31,7 +32,7 @@ export * from './utils/hostPlatform';
export * from './utils/isomorphic/headers';
export * from './utils/isomorphic/semaphore';
export * from './utils/platform';
export * from './utils/stackTrace';
export * from './utils/isomorphic/stackTrace';
export * from './utils/task';
export * from './utils/userAgent';
export * from './utils/zipFile';
Expand Down
117 changes: 117 additions & 0 deletions packages/playwright-core/src/utils/isomorphic/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* 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 const colors = {
enabled: true,
reset: (text: string) => applyStyle(0, 0, text),

bold: (text: string) => applyStyle(1, 22, text),
dim: (text: string) => applyStyle(2, 22, text),
italic: (text: string) => applyStyle(3, 23, text),
underline: (text: string) => applyStyle(4, 24, text),
inverse: (text: string) => applyStyle(7, 27, text),
hidden: (text: string) => applyStyle(8, 28, text),
strikethrough: (text: string) => applyStyle(9, 29, text),

black: (text: string) => applyStyle(30, 39, text),
red: (text: string) => applyStyle(31, 39, text),
green: (text: string) => applyStyle(32, 39, text),
yellow: (text: string) => applyStyle(33, 39, text),
blue: (text: string) => applyStyle(34, 39, text),
magenta: (text: string) => applyStyle(35, 39, text),
cyan: (text: string) => applyStyle(36, 39, text),
white: (text: string) => applyStyle(37, 39, text),
gray: (text: string) => applyStyle(90, 39, text),
grey: (text: string) => applyStyle(90, 39, text),

brightRed: (text: string) => applyStyle(91, 39, text),
brightGreen: (text: string) => applyStyle(92, 39, text),
brightYellow: (text: string) => applyStyle(93, 39, text),
brightBlue: (text: string) => applyStyle(94, 39, text),
brightMagenta: (text: string) => applyStyle(95, 39, text),
brightCyan: (text: string) => applyStyle(96, 39, text),
brightWhite: (text: string) => applyStyle(97, 39, text),

bgBlack: (text: string) => applyStyle(40, 49, text),
bgRed: (text: string) => applyStyle(41, 49, text),
bgGreen: (text: string) => applyStyle(42, 49, text),
bgYellow: (text: string) => applyStyle(43, 49, text),
bgBlue: (text: string) => applyStyle(44, 49, text),
bgMagenta: (text: string) => applyStyle(45, 49, text),
bgCyan: (text: string) => applyStyle(46, 49, text),
bgWhite: (text: string) => applyStyle(47, 49, text),
bgGray: (text: string) => applyStyle(100, 49, text),
bgGrey: (text: string) => applyStyle(100, 49, text),

bgBrightRed: (text: string) => applyStyle(101, 49, text),
bgBrightGreen: (text: string) => applyStyle(102, 49, text),
bgBrightYellow: (text: string) => applyStyle(103, 49, text),
bgBrightBlue: (text: string) => applyStyle(104, 49, text),
bgBrightMagenta: (text: string) => applyStyle(105, 49, text),
bgBrightCyan: (text: string) => applyStyle(106, 49, text),
bgBrightWhite: (text: string) => applyStyle(107, 49, text),
};

type Colors = typeof colors;

export const noColors: Colors = {
enabled: false,
reset: t => t,
bold: t => t,
dim: t => t,
italic: t => t,
underline: t => t,
inverse: t => t,
hidden: t => t,
strikethrough: t => t,
black: t => t,
red: t => t,
green: t => t,
yellow: t => t,
blue: t => t,
magenta: t => t,
cyan: t => t,
white: t => t,
gray: t => t,
grey: t => t,
brightRed: t => t,
brightGreen: t => t,
brightYellow: t => t,
brightBlue: t => t,
brightMagenta: t => t,
brightCyan: t => t,
brightWhite: t => t,
bgBlack: t => t,
bgRed: t => t,
bgGreen: t => t,
bgYellow: t => t,
bgBlue: t => t,
bgMagenta: t => t,
bgCyan: t => t,
bgWhite: t => t,
bgGray: t => t,
bgGrey: t => t,
bgBrightRed: t => t,
bgBrightGreen: t => t,
bgBrightYellow: t => t,
bgBrightBlue: t => t,
bgBrightMagenta: t => t,
bgBrightCyan: t => t,
bgBrightWhite: t => t
};


const applyStyle = (open: number, close: number, text: string) => `\u001b[${open}m${text}\u001b[${close}m`;
Loading
Loading