@cotestdev/mcp_playwright 0.0.59 → 0.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -51,22 +51,24 @@ const kSupportedFormats = /* @__PURE__ */ new Map([
|
|
|
51
51
|
[null, null],
|
|
52
52
|
[void 0, void 0]
|
|
53
53
|
]);
|
|
54
|
-
async function load(
|
|
55
|
-
const moduleUrl = originalModuleUrl.replace(esmPreflightExtension, "");
|
|
54
|
+
async function load(moduleUrl, context, defaultLoad) {
|
|
56
55
|
if (!kSupportedFormats.has(context.format))
|
|
57
56
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
58
57
|
if (!moduleUrl.startsWith("file://"))
|
|
59
58
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
60
59
|
const filename = import_url.default.fileURLToPath(moduleUrl);
|
|
60
|
+
const isPreflight = moduleUrl.endsWith(esmPreflightExtension);
|
|
61
61
|
if (!(0, import_transform.shouldTransform)(filename))
|
|
62
62
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
63
|
-
const
|
|
64
|
-
const
|
|
63
|
+
const originalModuleUrl = isPreflight ? moduleUrl.slice(0, -esmPreflightExtension.length) : moduleUrl;
|
|
64
|
+
const originalFilename = isPreflight ? import_url.default.fileURLToPath(originalModuleUrl) : filename;
|
|
65
|
+
const code = import_fs.default.readFileSync(originalFilename, "utf-8");
|
|
66
|
+
const transformed = (0, import_transform.transformHook)(code, originalFilename, originalModuleUrl);
|
|
65
67
|
if (transformed.serializedCache)
|
|
66
68
|
transport?.post("pushToCompilationCache", { cache: transformed.serializedCache });
|
|
67
69
|
return {
|
|
68
|
-
format: kSupportedFormats.get(context.format) || ((0, import_util.fileIsModule)(
|
|
69
|
-
source:
|
|
70
|
+
format: kSupportedFormats.get(context.format) || ((0, import_util.fileIsModule)(originalFilename) ? "module" : "commonjs"),
|
|
71
|
+
source: isPreflight ? `void 0;` : transformed.code,
|
|
70
72
|
shortCircuit: true
|
|
71
73
|
};
|
|
72
74
|
}
|
|
@@ -219,7 +219,7 @@ async function requireOrImport(file) {
|
|
|
219
219
|
if (isModule) {
|
|
220
220
|
const fileName = import_url.default.pathToFileURL(file);
|
|
221
221
|
const esmImport = () => eval(`import(${JSON.stringify(fileName)})`);
|
|
222
|
-
await eval(`import(${JSON.stringify(fileName + ".esm.preflight")})`).finally(nextTask);
|
|
222
|
+
await eval(`import(${JSON.stringify(fileName + ".esm.preflight")})`).catch((error) => (0, import_util.debugTest)("Failed to load preflight for " + file + ", source maps may be missing for errors thrown during loading.", error)).finally(nextTask);
|
|
223
223
|
return await esmImport().finally(nextTask);
|
|
224
224
|
}
|
|
225
225
|
const result = require(file);
|