testeranto 0.81.3 → 0.84.0

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.
Files changed (71) hide show
  1. package/dist/common/src/Node.js +4 -2
  2. package/dist/common/src/PM/main.js +188 -61
  3. package/dist/common/src/PM/node.js +32 -7
  4. package/dist/common/src/PM/web.js +28 -54
  5. package/dist/common/src/Project.js +0 -3
  6. package/dist/common/src/Puppeteer.js +9 -51
  7. package/dist/common/src/SubPackages/react-dom/jsx/web.js +11 -11
  8. package/dist/common/src/Web.js +7 -1
  9. package/dist/common/src/esbuildConfigs/featuresPlugin.js +39 -0
  10. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +62 -64
  11. package/dist/common/src/esbuildConfigs/node.js +10 -3
  12. package/dist/common/src/esbuildConfigs/web.js +6 -2
  13. package/dist/common/src/lib/abstractBase.js +348 -337
  14. package/dist/common/src/lib/basebuilder.js +9 -4
  15. package/dist/common/src/lib/core.js +1 -1
  16. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  17. package/dist/module/src/Node.js +3 -3
  18. package/dist/module/src/PM/main.js +188 -61
  19. package/dist/module/src/PM/node.js +32 -7
  20. package/dist/module/src/PM/web.js +28 -51
  21. package/dist/module/src/Project.js +0 -3
  22. package/dist/module/src/Puppeteer.js +9 -51
  23. package/dist/module/src/SubPackages/react-dom/jsx/web.js +10 -10
  24. package/dist/module/src/Web.js +6 -2
  25. package/dist/module/src/esbuildConfigs/featuresPlugin.js +34 -0
  26. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +62 -64
  27. package/dist/module/src/esbuildConfigs/node.js +10 -3
  28. package/dist/module/src/esbuildConfigs/web.js +6 -2
  29. package/dist/module/src/lib/abstractBase.js +348 -337
  30. package/dist/module/src/lib/basebuilder.js +9 -4
  31. package/dist/module/src/lib/core.js +1 -1
  32. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  33. package/dist/prebuild/Puppeteer.mjs +82033 -0
  34. package/dist/types/src/Node.d.ts +5 -1
  35. package/dist/types/src/PM/index.d.ts +10 -4
  36. package/dist/types/src/PM/main.d.ts +21 -9
  37. package/dist/types/src/PM/node.d.ts +11 -3
  38. package/dist/types/src/PM/web.d.ts +11 -2
  39. package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +1 -0
  40. package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +1 -0
  41. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -0
  42. package/dist/types/src/Types.d.ts +2 -2
  43. package/dist/types/src/Web.d.ts +5 -1
  44. package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +5 -0
  45. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +4 -2
  46. package/dist/types/src/lib/abstractBase.d.ts +5 -4
  47. package/dist/types/src/lib/core.d.ts +1 -1
  48. package/dist/types/src/lib/index.d.ts +1 -0
  49. package/dist/types/src/lib/types.d.ts +7 -5
  50. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  51. package/package.json +18 -45
  52. package/pupBuild.js +18 -0
  53. package/src/Node.ts +3 -5
  54. package/src/PM/index.ts +12 -3
  55. package/src/PM/main.ts +306 -140
  56. package/src/PM/node.ts +40 -7
  57. package/src/PM/web.ts +108 -58
  58. package/src/Project.ts +0 -8
  59. package/src/Puppeteer.ts +11 -57
  60. package/src/SubPackages/react-dom/jsx/web.ts +15 -10
  61. package/src/Types.ts +5 -2
  62. package/src/Web.ts +6 -2
  63. package/src/esbuildConfigs/featuresPlugin.ts +43 -0
  64. package/src/esbuildConfigs/inputFilesPlugin.ts +97 -90
  65. package/src/esbuildConfigs/node.ts +18 -3
  66. package/src/esbuildConfigs/web.ts +14 -2
  67. package/src/lib/abstractBase.ts +388 -366
  68. package/src/lib/basebuilder.ts +9 -9
  69. package/src/lib/core.ts +4 -2
  70. package/src/lib/index.ts +1 -0
  71. package/src/lib/types.ts +14 -6
@@ -1,16 +1,16 @@
1
1
  import Testeranto from "./lib/core.js";
2
2
  import { defaultTestResourceRequirement, } from "./lib/index.js";
3
3
  import { PM_Node } from "./PM/node.js";
4
- class NodeTesteranto extends Testeranto {
4
+ export class NodeTesteranto extends Testeranto {
5
5
  constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
6
6
  super(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
7
7
  }
8
8
  async receiveTestResourceConfig(partialTestResource) {
9
9
  const t = JSON.parse(partialTestResource);
10
- console.log("receiveTestResourceConfig", t);
11
10
  const pm = new PM_Node(t);
12
- const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
11
+ const { failed, artifacts, logPromise, features } = await this.testJobs[0].receiveTestResourceConfig(pm);
13
12
  pm.customclose();
13
+ return features;
14
14
  }
15
15
  }
16
16
  export default async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = defaultTestResourceRequirement) => {
@@ -1,11 +1,12 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import puppeteer from "puppeteer-core";
4
+ import crypto from "crypto";
4
5
  import { PM } from "./index.js";
5
6
  import { destinationOfRuntime } from "../utils.js";
6
7
  const fPaths = [];
7
8
  const fileStreams3 = [];
8
- const files = {}; // = new Set<string>();
9
+ const files = {};
9
10
  const screenshots = {};
10
11
  export class PM_Main extends PM {
11
12
  constructor(configs) {
@@ -23,11 +24,9 @@ export class PM_Main extends PM {
23
24
  }
24
25
  };
25
26
  this.register = (src) => {
26
- // console.log("register", src);
27
27
  this.registry[src] = false;
28
28
  };
29
29
  this.deregister = (src) => {
30
- // console.log("deregister", src, this.shutdownMode);
31
30
  this.registry[src] = true;
32
31
  if (this.shutdownMode) {
33
32
  this.checkForShutdown();
@@ -94,6 +93,9 @@ export class PM_Main extends PM {
94
93
  return module.default.then((defaultModule) => {
95
94
  defaultModule
96
95
  .receiveTestResourceConfig(argz)
96
+ .then(async (features) => {
97
+ this.receiveFeatures(features, destFolder);
98
+ })
97
99
  .catch((e) => {
98
100
  console.log("catch", e);
99
101
  })
@@ -119,22 +121,22 @@ export class PM_Main extends PM {
119
121
  fs: destFolder,
120
122
  browserWSEndpoint: this.browser.wsEndpoint(),
121
123
  });
122
- const evaluation = `
123
- console.log("importing ${dest}.mjs");
124
- import('${dest}.mjs').then(async (x) => {
125
- console.log("imported", x.default);
126
- })`;
124
+ // const evaluation = `
125
+ // console.log("importing ${dest}.mjs");
126
+ // import('${dest}.mjs').then(async (x) => {
127
+ // console.log("imported", x.default);
128
+ // })`;
127
129
  const fileStreams2 = [];
128
130
  const doneFileStream2 = [];
129
131
  return new Promise((res, rej) => {
130
132
  this.browser
131
133
  .newPage()
132
134
  .then((page) => {
133
- page.on("console", (msg) => {
134
- console.log("web > ", msg.args(), msg.text());
135
- // for (let i = 0; i < msg._args.length; ++i)
136
- // console.log(`${i}: ${msg._args[i]}`);
137
- });
135
+ // page.on("console", (msg) => {
136
+ // console.log("web > ", msg.args(), msg.text());
137
+ // // for (let i = 0; i < msg._args.length; ++i)
138
+ // // console.log(`${i}: ${msg._args[i]}`);
139
+ // });
138
140
  page.exposeFunction("custom-screenshot", async (ssOpts, testName) => {
139
141
  // console.log("main.ts browser custom-screenshot", testName);
140
142
  const p = ssOpts.path;
@@ -209,35 +211,12 @@ export class PM_Main extends PM {
209
211
  delete screenshots[testName];
210
212
  // page.close();
211
213
  });
212
- // globalThis["writeFileSync"](
213
- // p + "/manifest.json",
214
- // // files.entries()
215
- // JSON.stringify(Array.from(files[testName]))
216
- // );
217
- // console.log("closing doneFileStream2", doneFileStream2);
218
- // console.log("closing doneFileStream2", doneFileStream2);
219
- // Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
220
- // page.close();
221
- // });
222
- // Promise.all(screenshots).then(() => {
223
- // page.close();
224
- // });
225
- // setTimeout(() => {
226
- // console.log("Delayed for 1 second.");
227
- // page.close();
228
- // }, 5000);
229
- // return page.close();
230
214
  });
231
215
  return page;
232
216
  })
233
217
  .then(async (page) => {
234
- page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
235
218
  await page.goto(`file://${`${dest}.html`}`, {});
236
219
  res(page);
237
- // page.evaluate(evaluation).finally(() => {
238
- // console.log("evaluation failed.", dest);
239
- // });
240
- // return page;
241
220
  });
242
221
  });
243
222
  };
@@ -246,13 +225,6 @@ export class PM_Main extends PM {
246
225
  console.log("launchNodeSideCar", src, dest, d);
247
226
  const destFolder = dest.replace(".mjs", "");
248
227
  let argz = "";
249
- // const testConfig = this.configs.tests.find((t) => {
250
- // return t[0] === src;
251
- // });
252
- // if (!testConfig) {
253
- // console.error("missing test config");
254
- // process.exit(-1);
255
- // }
256
228
  const testConfigResource = testConfig[2];
257
229
  let portsToUse = [];
258
230
  if (testConfigResource.ports === 0) {
@@ -337,9 +309,9 @@ export class PM_Main extends PM {
337
309
  const evaluation = `
338
310
  console.log("importing ${dest}.mjs");
339
311
  import('${dest}.mjs').then(async (x) => {
340
- console.log("imported", x.default);
312
+ console.log("imported", (await x.default));
341
313
  try {
342
- await (await x.default).receiveTestResourceConfig(${webArgz})
314
+ return await (await x.default).receiveTestResourceConfig(${webArgz})
343
315
  } catch (e) {
344
316
  console.log("fail", e)
345
317
  }
@@ -349,13 +321,30 @@ export class PM_Main extends PM {
349
321
  this.browser
350
322
  .newPage()
351
323
  .then((page) => {
352
- page.on("console", (msg) => {
353
- console.log("web > ", msg.args(), msg.text());
354
- // for (let i = 0; i < msg._args.length; ++i)
355
- // console.log(`${i}: ${msg._args[i]}`);
324
+ // page.on("console", (msg) => {
325
+ // // console.log("web > ", msg.args(), msg.text());
326
+ // });
327
+ page.exposeFunction("screencast", async (ssOpts, testName) => {
328
+ const p = ssOpts.path;
329
+ const dir = path.dirname(p);
330
+ fs.mkdirSync(dir, {
331
+ recursive: true,
332
+ });
333
+ if (!files[testName]) {
334
+ files[testName] = new Set();
335
+ }
336
+ files[testName].add(ssOpts.path);
337
+ const sPromise = page.screenshot(Object.assign(Object.assign({}, ssOpts), { path: p }));
338
+ if (!screenshots[testName]) {
339
+ screenshots[testName] = [];
340
+ }
341
+ screenshots[testName].push(sPromise);
342
+ // sPromise.then(())
343
+ await sPromise;
344
+ return sPromise;
345
+ // page.evaluate(`window["screenshot done"]`);
356
346
  });
357
347
  page.exposeFunction("customScreenShot", async (ssOpts, testName) => {
358
- // console.log("main.ts browser custom-screenshot", testName);
359
348
  const p = ssOpts.path;
360
349
  const dir = path.dirname(p);
361
350
  fs.mkdirSync(dir, {
@@ -454,13 +443,46 @@ export class PM_Main extends PM {
454
443
  // }, 5000);
455
444
  // return page.close();
456
445
  });
446
+ page.exposeFunction("page", () => {
447
+ return page.mainFrame()._id;
448
+ });
449
+ page.exposeFunction("click", (sel) => {
450
+ return page.click(sel);
451
+ });
452
+ page.exposeFunction("focusOn", (sel) => {
453
+ return page.focus(sel);
454
+ });
455
+ page.exposeFunction("typeInto", async (value) => await page.keyboard.type(value));
456
+ page.exposeFunction("getValue", (selector) => page.$eval(selector, (input) => input.getAttribute("value")));
457
+ page.exposeFunction("getAttribute", async (selector, attribute) => {
458
+ const attributeValue = await page.$eval(selector, (input) => {
459
+ return input.getAttribute(attribute);
460
+ });
461
+ return attributeValue;
462
+ });
463
+ page.exposeFunction("isDisabled", async (selector) => {
464
+ const attributeValue = await page.$eval(selector, (input) => {
465
+ return input.disabled;
466
+ });
467
+ return attributeValue;
468
+ });
469
+ page.exposeFunction("$", async (selector) => {
470
+ const x = page.$(selector);
471
+ const y = await x;
472
+ return y;
473
+ });
457
474
  return page;
458
475
  })
459
476
  .then(async (page) => {
460
- page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
477
+ // page.on("console", (log) =>
478
+ // console.debug(`Log from client: [${log.text()}] `)
479
+ // );
461
480
  await page.goto(`file://${`${dest}.html`}`, {});
462
- page
481
+ await page
463
482
  .evaluate(evaluation)
483
+ .then(async (features) => {
484
+ this.receiveFeatures(features, destFolder);
485
+ })
464
486
  .catch((e) => {
465
487
  console.log("evaluation failed.", dest);
466
488
  console.log(e);
@@ -469,11 +491,62 @@ export class PM_Main extends PM {
469
491
  console.log("evaluation complete.", dest);
470
492
  // page.close();
471
493
  this.deregister(t);
472
- // whyIsNodeRunning();
473
494
  });
474
495
  return page;
475
496
  });
476
497
  };
498
+ this.receiveFeatures = (features, destFolder) => {
499
+ console.log("this.receiveFeatures", features);
500
+ features
501
+ .reduce(async (mm, featureStringKey) => {
502
+ const accum = await mm;
503
+ const isUrl = isValidUrl(featureStringKey);
504
+ if (isUrl) {
505
+ const u = new URL(featureStringKey);
506
+ if (u.protocol === "file:") {
507
+ const newPath = `${process.cwd()}/docs/features/internal/${path.relative(process.cwd(), u.pathname)}`;
508
+ await fs.promises.mkdir(path.dirname(newPath), { recursive: true });
509
+ try {
510
+ await fs.unlinkSync(newPath);
511
+ // console.log(`Removed existing link at ${newPath}`);
512
+ }
513
+ catch (error) {
514
+ if (error.code !== "ENOENT") {
515
+ // throw error;
516
+ }
517
+ }
518
+ fs.symlink(u.pathname, newPath, (err) => {
519
+ if (err) {
520
+ // console.error("Error creating symlink:", err);
521
+ }
522
+ else {
523
+ // console.log("Symlink created successfully");
524
+ }
525
+ });
526
+ accum.push(newPath);
527
+ }
528
+ else if (u.protocol === "http:" || u.protocol === "https:") {
529
+ const newPath = `${process.cwd()}/docs/features/external${u.hostname}${u.pathname}`;
530
+ const body = await this.configs.featureIngestor(featureStringKey);
531
+ writeFileAndCreateDir(newPath, body);
532
+ accum.push(newPath);
533
+ }
534
+ }
535
+ else {
536
+ const newPath = `${process.cwd()}/docs/features/plain/${await sha256(featureStringKey)}`;
537
+ writeFileAndCreateDir(newPath, featureStringKey);
538
+ accum.push(newPath);
539
+ }
540
+ return accum;
541
+ }, Promise.resolve([]))
542
+ .then((features) => {
543
+ fs.writeFileSync(`${destFolder}/featurePrompt.txt`, features
544
+ .map((f) => {
545
+ return `/read ${f}`;
546
+ })
547
+ .join("\n"));
548
+ });
549
+ };
477
550
  this.server = {};
478
551
  this.configs = configs;
479
552
  this.ports = {};
@@ -544,17 +617,14 @@ export class PM_Main extends PM {
544
617
  delete files[testName];
545
618
  };
546
619
  }
547
- shutDown() {
548
- console.log("shutting down...");
549
- this.shutdownMode = true;
550
- this.checkForShutdown();
620
+ $(selector) {
621
+ throw new Error("Method not implemented.");
551
622
  }
552
- customScreenShot(opts) {
623
+ screencast(opts) {
553
624
  throw new Error("Method not implemented.");
554
625
  }
555
- async startPuppeteer(options, destfolder) {
556
- this.browser = (await puppeteer.launch(options));
557
- return this.browser;
626
+ customScreenShot(opts) {
627
+ throw new Error("Method not implemented.");
558
628
  }
559
629
  end(accessObject) {
560
630
  throw new Error("Method not implemented.");
@@ -617,4 +687,61 @@ export class PM_Main extends PM {
617
687
  write(accessObject, contents) {
618
688
  throw new Error("Method not implemented.");
619
689
  }
690
+ page() {
691
+ throw new Error("Method not implemented.");
692
+ }
693
+ click(selector) {
694
+ throw new Error("Method not implemented.");
695
+ }
696
+ focusOn(selector) {
697
+ throw new Error("Method not implemented.");
698
+ }
699
+ typeInto(value) {
700
+ throw new Error("Method not implemented.");
701
+ }
702
+ getValue(value) {
703
+ throw new Error("Method not implemented.");
704
+ }
705
+ getAttribute(selector, attribute) {
706
+ throw new Error("Method not implemented.");
707
+ }
708
+ isDisabled(selector) {
709
+ throw new Error("Method not implemented.");
710
+ }
711
+ ////////////////////////////////////////////////////////////////////////////////
712
+ async startPuppeteer(options, destfolder) {
713
+ this.browser = (await puppeteer.launch(options));
714
+ }
715
+ ////////////////////////////////////////////////////////////////////////////////
716
+ shutDown() {
717
+ console.log("shutting down...");
718
+ this.shutdownMode = true;
719
+ this.checkForShutdown();
720
+ }
721
+ }
722
+ async function writeFileAndCreateDir(filePath, data) {
723
+ const dirPath = path.dirname(filePath);
724
+ try {
725
+ await fs.promises.mkdir(dirPath, { recursive: true });
726
+ await fs.promises.writeFile(filePath, data);
727
+ }
728
+ catch (error) {
729
+ console.error(`Error writing file: ${error}`);
730
+ }
731
+ }
732
+ async function sha256(rawData) {
733
+ const data = typeof rawData === "object" ? JSON.stringify(rawData) : String(rawData);
734
+ const msgBuffer = new TextEncoder().encode(data);
735
+ const hashBuffer = await crypto.subtle.digest("SHA-256", msgBuffer);
736
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
737
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
738
+ }
739
+ function isValidUrl(string) {
740
+ try {
741
+ new URL(string);
742
+ return true;
743
+ }
744
+ catch (err) {
745
+ return false;
746
+ }
620
747
  }
@@ -1,6 +1,5 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import puppeteer from "puppeteer-core";
4
3
  import { PM } from "./index.js";
5
4
  const fPaths = [];
6
5
  export class PM_Node extends PM {
@@ -9,8 +8,35 @@ export class PM_Node extends PM {
9
8
  this.server = {};
10
9
  this.testResourceConfiguration = t;
11
10
  }
12
- customScreenShot(opts, page) {
13
- return globalThis["customScreenShot"](opts, page);
11
+ $(selector) {
12
+ throw new Error("Method not implemented.");
13
+ }
14
+ screencast(opts) {
15
+ throw new Error("Method not implemented.");
16
+ }
17
+ isDisabled(selector) {
18
+ throw new Error("Method not implemented.");
19
+ }
20
+ getAttribute(selector, attribute) {
21
+ throw new Error("Method not implemented.");
22
+ }
23
+ getValue(selector) {
24
+ throw new Error("Method not implemented.");
25
+ }
26
+ focusOn(selector) {
27
+ throw new Error("Method not implemented.");
28
+ }
29
+ typeInto(value) {
30
+ throw new Error("Method not implemented.");
31
+ }
32
+ page() {
33
+ return globalThis["page"]();
34
+ }
35
+ click(selector) {
36
+ return globalThis["click"](selector);
37
+ }
38
+ customScreenShot(opts) {
39
+ return globalThis["customScreenShot"](opts);
14
40
  }
15
41
  existsSync(destFolder) {
16
42
  return globalThis["existsSync"](this.testResourceConfiguration.fs + "/" + destFolder);
@@ -22,7 +48,6 @@ export class PM_Node extends PM {
22
48
  return globalThis["write"](writeObject.uid, contents);
23
49
  }
24
50
  writeFileSync(filepath, contents) {
25
- // console.log("pm_node-writeFileSync", this.testResourceConfiguration);
26
51
  return globalThis["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents, this.testResourceConfiguration.name);
27
52
  }
28
53
  createWriteStream(filepath) {
@@ -74,8 +99,8 @@ export class PM_Node extends PM {
74
99
  }
75
100
  // launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
76
101
  startPuppeteer(options) {
77
- return puppeteer.connect(options).then((b) => {
78
- this.browser = b;
79
- });
102
+ // return puppeteer.connect(options).then((b) => {
103
+ // this.browser = b;
104
+ // });
80
105
  }
81
106
  }
@@ -1,4 +1,3 @@
1
- import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
2
1
  import { PM } from "./index.js";
3
2
  export class PM_Web extends PM {
4
3
  constructor(t) {
@@ -6,8 +5,35 @@ export class PM_Web extends PM {
6
5
  this.server = {};
7
6
  this.testResourceConfiguration = t;
8
7
  }
8
+ $(selector) {
9
+ return window["$"](selector);
10
+ }
11
+ screencast(opts) {
12
+ throw new Error("Method not implemented.");
13
+ }
14
+ isDisabled(selector) {
15
+ return window["isDisabled"](selector);
16
+ }
17
+ getAttribute(selector, attribute) {
18
+ return window["getValue"](selector, attribute);
19
+ }
20
+ getValue(selector) {
21
+ return window["getValue"](selector);
22
+ }
23
+ focusOn(selector) {
24
+ return window["focusOn"](selector);
25
+ }
26
+ typeInto(value) {
27
+ return window["typeInto"](value);
28
+ }
29
+ page() {
30
+ return window["page"]();
31
+ }
32
+ click(selector) {
33
+ return window["click"](selector);
34
+ }
9
35
  customScreenShot(opts) {
10
- window["customScreenShot"](opts);
36
+ return window["customScreenShot"](Object.assign(Object.assign({}, opts), { path: this.testResourceConfiguration.fs + "/" + opts.path }), this.testResourceConfiguration.name);
11
37
  }
12
38
  existsSync(destFolder) {
13
39
  return window["existsSync"](destFolder);
@@ -73,53 +99,4 @@ export class PM_Web extends PM {
73
99
  }));
74
100
  };
75
101
  }
76
- startPuppeteer(options, destFolder) {
77
- const name = this.testResourceConfiguration.name;
78
- return fetch(`http://localhost:3234/json/version`)
79
- .then((v) => {
80
- return v.json();
81
- })
82
- .then((json) => {
83
- return puppeteer
84
- .connect({
85
- browserWSEndpoint: json.webSocketDebuggerUrl,
86
- })
87
- .then((b) => {
88
- this.browser = b;
89
- const handler2 = {
90
- get(target, prop, receiver) {
91
- if (prop === "screenshot") {
92
- return async (x) => {
93
- return await window["custom-screenshot"](Object.assign(Object.assign({}, x), {
94
- // path: destFolder + "/" + x.path,
95
- path: x.path }), name);
96
- };
97
- }
98
- else if (prop === "mainFrame") {
99
- return () => target[prop](...arguments);
100
- }
101
- else {
102
- return Reflect.get(...arguments);
103
- }
104
- },
105
- };
106
- const handler1 = {
107
- get(target, prop, receiver) {
108
- if (prop === "pages") {
109
- return async () => {
110
- return target.pages().then((pages) => {
111
- return pages.map((p) => {
112
- return new Proxy(p, handler2);
113
- });
114
- });
115
- };
116
- }
117
- return Reflect.get(...arguments);
118
- },
119
- };
120
- const proxy3 = new Proxy(this.browser, handler1);
121
- this.browser = proxy3;
122
- });
123
- });
124
- }
125
102
  }
@@ -6,7 +6,6 @@ import { glob } from "glob";
6
6
  import esbuildNodeConfiger from "./esbuildConfigs/node.js";
7
7
  import esbuildWebConfiger from "./esbuildConfigs/web.js";
8
8
  import webHtmlFrame from "./web.html.js";
9
- // var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
10
9
  readline.emitKeypressEvents(process.stdin);
11
10
  if (process.stdin.isTTY)
12
11
  process.stdin.setRawMode(true);
@@ -68,7 +67,6 @@ export class ITProject {
68
67
  .then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
69
68
  })));
70
69
  const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
71
- console.log(`this.getSecondaryEndpointsPoints("web")`, this.getSecondaryEndpointsPoints("web"));
72
70
  glob(`./${this.config.outdir}/chunk-*.mjs`, {
73
71
  ignore: "node_modules/**",
74
72
  }).then((chunks) => {
@@ -112,7 +110,6 @@ export class ITProject {
112
110
  getSecondaryEndpointsPoints(runtime) {
113
111
  const meta = (ts, st) => {
114
112
  ts.forEach((t) => {
115
- console.log("getSecondaryEndpointsPoints", t);
116
113
  if (t[1] === runtime) {
117
114
  st.add(t[0]);
118
115
  }
@@ -3,14 +3,9 @@ import fs from "fs";
3
3
  import watch from "recursive-watch";
4
4
  import { PM_Main } from "./PM/main.js";
5
5
  import { destinationOfRuntime } from "./utils.js";
6
- // var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
7
- // const node2web: Record<string, string[]> = {};
8
- // const web2node: Record<string, string[]> = {};
9
- // const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
10
6
  readline.emitKeypressEvents(process.stdin);
11
7
  if (process.stdin.isTTY)
12
8
  process.stdin.setRawMode(true);
13
- // let shutDownMode = false;
14
9
  export default async (partialConfig) => {
15
10
  const config = Object.assign(Object.assign({}, partialConfig), { buildDir: process.cwd() + "/" + partialConfig.outdir });
16
11
  fs.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2));
@@ -24,9 +19,11 @@ export default async (partialConfig) => {
24
19
  headless: true,
25
20
  dumpio: true,
26
21
  // timeout: 0,
22
+ devtools: true,
27
23
  args: [
28
- // "--auto-open-devtools-for-tabs",
29
- "--disable-features=IsolateOrigins,site-per-process",
24
+ "--auto-open-devtools-for-tabs",
25
+ `--remote-debugging-port=3234`,
26
+ // "--disable-features=IsolateOrigins,site-per-process",
30
27
  "--disable-site-isolation-trials",
31
28
  "--allow-insecure-localhost",
32
29
  "--allow-file-access-from-files",
@@ -49,18 +46,21 @@ export default async (partialConfig) => {
49
46
  // "--single-process",
50
47
  // "--unsafely-treat-insecure-origin-as-secure",
51
48
  // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
52
- `--remote-debugging-port=3234`,
53
49
  // "--disk-cache-dir=/dev/null",
54
50
  // "--disk-cache-size=1",
55
51
  // "--start-maximized",
56
52
  ],
57
53
  }, ".");
58
- console.log("\n Puppeteer is running. Press 'q' to quit\n");
54
+ console.log("\n Puppeteer is running. Press 'q' to shutdown softly. Press 'x' to shutdown forcefully.\n");
59
55
  process.stdin.on("keypress", (str, key) => {
60
56
  if (key.name === "q") {
61
57
  pm.shutDown();
62
58
  // process.exit();
63
59
  }
60
+ if (key.name === "x") {
61
+ // pm.shutDown();
62
+ process.exit(-1);
63
+ }
64
64
  });
65
65
  config.tests.forEach(([test, runtime, tr, sidecars]) => {
66
66
  if (runtime === "node") {
@@ -105,46 +105,4 @@ export default async (partialConfig) => {
105
105
  else {
106
106
  pm.shutDown();
107
107
  }
108
- // pm.browser.close();
109
- // does not work on linux
110
- // fs.watch(
111
- // config.buildDir,
112
- // {
113
- // recursive: true,
114
- // },
115
- // (eventType, changedFile) => {
116
- // if (changedFile) {
117
- // config.tests.forEach(([test, runtime, tr, sidecars]) => {
118
- // if (eventType === "change" || eventType === "rename") {
119
- // if (
120
- // changedFile ===
121
- // test
122
- // .replace("./", "node/")
123
- // .split(".")
124
- // .slice(0, -1)
125
- // .concat("mjs")
126
- // .join(".")
127
- // ) {
128
- // pm.launchNode(test, destinationOfRuntime(test, "node", config));
129
- // }
130
- // if (
131
- // changedFile ===
132
- // test
133
- // .replace("./", "web/")
134
- // .split(".")
135
- // .slice(0, -1)
136
- // .concat("mjs")
137
- // .join(".")
138
- // ) {
139
- // pm.launchWeb(
140
- // test,
141
- // destinationOfRuntime(test, "web", config),
142
- // sidecars
143
- // );
144
- // }
145
- // }
146
- // });
147
- // }
148
- // }
149
- // );
150
108
  };