Skip to content
Open
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
132 changes: 0 additions & 132 deletions packages/isomorphic/platform.ts

This file was deleted.

30 changes: 30 additions & 0 deletions packages/isomorphic/stackTrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,33 @@ function fileURLToPath(fileUrl: string, pathSeparator: string): string {

return path.replace(/\//g, pathSeparator);
}

let _coreDir: string | undefined;
let _boxedStackPrefixes: string[] = [];
let _showInternalStackFrames = false;

export function setCoreDir(dir: string | undefined) {
_coreDir = dir;
}

export function coreDir(): string | undefined {
return _coreDir;
}

export function setBoxedStackPrefixes(prefixes: string[]) {
_boxedStackPrefixes = prefixes;
}

export function boxedStackPrefixes(): string[] {
if (_showInternalStackFrames)
return [];
return _coreDir ? [_coreDir, ..._boxedStackPrefixes] : _boxedStackPrefixes.slice();
}

export function setShowInternalStackFrames(value: boolean) {
_showInternalStackFrames = value;
}

export function showInternalStackFrames(): boolean {
return _showInternalStackFrames;
}
10 changes: 2 additions & 8 deletions packages/playwright-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"require": "./index.js",
"default": "./index.js"
"import": "./lib/index.mjs",
"default": "./lib/index.mjs"
},
"./package.json": "./package.json"
},
"scripts": {
"esbuild": "node build.js",
"build": "npm run esbuild",
"watch": "npm run esbuild -- --watch"
},
"dependencies": {
"playwright-core": "1.62.0-next"
}
Expand Down
3 changes: 1 addition & 2 deletions packages/playwright-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { Connection } from '../../playwright-core/src/client/connection';
import { webPlatform } from './webPlatform';

import type { Browser } from '../../playwright-core/src/client/browser';

Expand All @@ -30,7 +29,7 @@ export async function connect(wsEndpoint: string, browserName: string, options:
ws.addEventListener('error', r);
});

const connection = new Connection(webPlatform);
const connection = new Connection();
connection.onmessage = message => ws.send(JSON.stringify(message));
ws.addEventListener('message', message => connection.dispatch(JSON.parse(message.data)));
ws.addEventListener('close', () => connection.close());
Expand Down
27 changes: 27 additions & 0 deletions packages/playwright-client/src/nodeStubs/async_hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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 class AsyncLocalStorage<T> {
run<R>(_store: T, callback: () => R): R {
return callback();
}

getStore(): T | undefined {
return undefined;
}
}

export default { AsyncLocalStorage };
21 changes: 21 additions & 0 deletions packages/playwright-client/src/nodeStubs/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* 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.
*/

// Browser polyfill for `colors/safe`.

import { noColors } from '@isomorphic/colors';

export default noColors;
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
* limitations under the License.
*/

export { connect } from './index.js';
export class EventEmitter {
static defaultMaxListeners = 10;
}

export default { EventEmitter };
25 changes: 25 additions & 0 deletions packages/playwright-client/src/nodeStubs/fs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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 notAvailable(): never {
throw new Error('fs is not available in the browser');
}

export const promises: any = new Proxy({}, { get: () => notAvailable });
export const createReadStream: any = notAvailable;
export const createWriteStream: any = notAvailable;

export default { promises, createReadStream, createWriteStream };
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
* limitations under the License.
*/

module.exports = require('./lib/index');
export function url(): string | undefined {
return undefined;
}

export default { url };
29 changes: 29 additions & 0 deletions packages/playwright-client/src/nodeStubs/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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 notAvailable(): never {
throw new Error('path is not available in the browser');
}

export const sep = '/';
export const dirname: any = notAvailable;
export const basename: any = notAvailable;
export const resolve: any = notAvailable;
export const join: any = notAvailable;
export const relative: any = notAvailable;
export const isAbsolute: any = notAvailable;

export default { sep, dirname, basename, resolve, join, relative, isAbsolute };
22 changes: 22 additions & 0 deletions packages/playwright-client/src/nodeStubs/processShim.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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.
*/

// Injected (esbuild `inject`) as the `process` global in the browser build.
export const process = {
env: {} as Record<string, string | undefined>,
platform: 'browser',
argv: [] as string[],
};
24 changes: 24 additions & 0 deletions packages/playwright-client/src/nodeStubs/stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* 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 class Readable {}
export class Writable {}

export const promises = {
pipeline: (): Promise<void> => Promise.reject(new Error('stream is not available in the browser')),
};

export default { Readable, Writable, promises };
21 changes: 21 additions & 0 deletions packages/playwright-client/src/nodeStubs/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* 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 inspect: any = Object.assign((value: unknown) => String(value), {
custom: Symbol.for('nodejs.util.inspect.custom'),
});

export default { inspect };
Loading
Loading