testeranto 0.82.0 → 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 (70) hide show
  1. package/dist/common/package.json +3 -0
  2. package/dist/common/src/Node.js +2 -0
  3. package/dist/common/src/PM/main.js +182 -79
  4. package/dist/common/src/PM/node.js +32 -6
  5. package/dist/common/src/PM/web.js +28 -54
  6. package/dist/common/src/Project.js +0 -3
  7. package/dist/common/src/Puppeteer.js +9 -51
  8. package/dist/common/src/SubPackages/react-dom/jsx/web.js +11 -11
  9. package/dist/common/src/Web.js +2 -0
  10. package/dist/common/src/esbuildConfigs/featuresPlugin.js +39 -0
  11. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +62 -41
  12. package/dist/common/src/esbuildConfigs/node.js +10 -3
  13. package/dist/common/src/esbuildConfigs/web.js +6 -2
  14. package/dist/common/src/lib/abstractBase.js +343 -335
  15. package/dist/common/src/lib/basebuilder.js +7 -3
  16. package/dist/common/src/lib/core.js +1 -1
  17. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  18. package/dist/module/package.json +3 -0
  19. package/dist/module/src/Node.js +1 -1
  20. package/dist/module/src/PM/main.js +182 -79
  21. package/dist/module/src/PM/node.js +32 -6
  22. package/dist/module/src/PM/web.js +28 -51
  23. package/dist/module/src/Project.js +0 -3
  24. package/dist/module/src/Puppeteer.js +9 -51
  25. package/dist/module/src/SubPackages/react-dom/jsx/web.js +10 -10
  26. package/dist/module/src/Web.js +1 -1
  27. package/dist/module/src/esbuildConfigs/featuresPlugin.js +34 -0
  28. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +62 -41
  29. package/dist/module/src/esbuildConfigs/node.js +10 -3
  30. package/dist/module/src/esbuildConfigs/web.js +6 -2
  31. package/dist/module/src/lib/abstractBase.js +343 -335
  32. package/dist/module/src/lib/basebuilder.js +7 -3
  33. package/dist/module/src/lib/core.js +1 -1
  34. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  35. package/dist/prebuild/Puppeteer.mjs +82033 -0
  36. package/dist/types/src/Node.d.ts +5 -1
  37. package/dist/types/src/PM/index.d.ts +10 -4
  38. package/dist/types/src/PM/main.d.ts +21 -9
  39. package/dist/types/src/PM/node.d.ts +11 -3
  40. package/dist/types/src/PM/web.d.ts +11 -2
  41. package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +1 -0
  42. package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +1 -0
  43. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -0
  44. package/dist/types/src/Types.d.ts +2 -2
  45. package/dist/types/src/Web.d.ts +5 -1
  46. package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +5 -0
  47. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +4 -2
  48. package/dist/types/src/lib/abstractBase.d.ts +5 -5
  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 -41
  52. package/pupBuild.js +18 -0
  53. package/src/Node.ts +1 -3
  54. package/src/PM/index.ts +12 -3
  55. package/src/PM/main.ts +300 -164
  56. package/src/PM/node.ts +40 -6
  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 +1 -1
  63. package/src/esbuildConfigs/featuresPlugin.ts +43 -0
  64. package/src/esbuildConfigs/inputFilesPlugin.ts +98 -66
  65. package/src/esbuildConfigs/node.ts +18 -3
  66. package/src/esbuildConfigs/web.ts +14 -2
  67. package/src/lib/abstractBase.ts +381 -364
  68. package/src/lib/basebuilder.ts +7 -7
  69. package/src/lib/core.ts +1 -1
  70. package/src/lib/types.ts +13 -5
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -1,7 +1,7 @@
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
  }
@@ -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();
@@ -95,16 +94,7 @@ export class PM_Main extends PM {
95
94
  defaultModule
96
95
  .receiveTestResourceConfig(argz)
97
96
  .then(async (features) => {
98
- Object.keys(features)
99
- .reduce(async (mm, lm) => {
100
- const accum = await mm;
101
- const x = await this.configs.featureIngestor(features[lm]);
102
- accum[lm] = x;
103
- return accum;
104
- }, Promise.resolve({}))
105
- .then((x) => {
106
- fs.writeFileSync(`${destFolder}/features.json`, JSON.stringify(x, null, 2));
107
- });
97
+ this.receiveFeatures(features, destFolder);
108
98
  })
109
99
  .catch((e) => {
110
100
  console.log("catch", e);
@@ -131,22 +121,22 @@ export class PM_Main extends PM {
131
121
  fs: destFolder,
132
122
  browserWSEndpoint: this.browser.wsEndpoint(),
133
123
  });
134
- const evaluation = `
135
- console.log("importing ${dest}.mjs");
136
- import('${dest}.mjs').then(async (x) => {
137
- console.log("imported", x.default);
138
- })`;
124
+ // const evaluation = `
125
+ // console.log("importing ${dest}.mjs");
126
+ // import('${dest}.mjs').then(async (x) => {
127
+ // console.log("imported", x.default);
128
+ // })`;
139
129
  const fileStreams2 = [];
140
130
  const doneFileStream2 = [];
141
131
  return new Promise((res, rej) => {
142
132
  this.browser
143
133
  .newPage()
144
134
  .then((page) => {
145
- page.on("console", (msg) => {
146
- console.log("web > ", msg.args(), msg.text());
147
- // for (let i = 0; i < msg._args.length; ++i)
148
- // console.log(`${i}: ${msg._args[i]}`);
149
- });
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
+ // });
150
140
  page.exposeFunction("custom-screenshot", async (ssOpts, testName) => {
151
141
  // console.log("main.ts browser custom-screenshot", testName);
152
142
  const p = ssOpts.path;
@@ -221,35 +211,12 @@ export class PM_Main extends PM {
221
211
  delete screenshots[testName];
222
212
  // page.close();
223
213
  });
224
- // globalThis["writeFileSync"](
225
- // p + "/manifest.json",
226
- // // files.entries()
227
- // JSON.stringify(Array.from(files[testName]))
228
- // );
229
- // console.log("closing doneFileStream2", doneFileStream2);
230
- // console.log("closing doneFileStream2", doneFileStream2);
231
- // Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
232
- // page.close();
233
- // });
234
- // Promise.all(screenshots).then(() => {
235
- // page.close();
236
- // });
237
- // setTimeout(() => {
238
- // console.log("Delayed for 1 second.");
239
- // page.close();
240
- // }, 5000);
241
- // return page.close();
242
214
  });
243
215
  return page;
244
216
  })
245
217
  .then(async (page) => {
246
- page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
247
218
  await page.goto(`file://${`${dest}.html`}`, {});
248
219
  res(page);
249
- // page.evaluate(evaluation).finally(() => {
250
- // console.log("evaluation failed.", dest);
251
- // });
252
- // return page;
253
220
  });
254
221
  });
255
222
  };
@@ -258,13 +225,6 @@ export class PM_Main extends PM {
258
225
  console.log("launchNodeSideCar", src, dest, d);
259
226
  const destFolder = dest.replace(".mjs", "");
260
227
  let argz = "";
261
- // const testConfig = this.configs.tests.find((t) => {
262
- // return t[0] === src;
263
- // });
264
- // if (!testConfig) {
265
- // console.error("missing test config");
266
- // process.exit(-1);
267
- // }
268
228
  const testConfigResource = testConfig[2];
269
229
  let portsToUse = [];
270
230
  if (testConfigResource.ports === 0) {
@@ -349,7 +309,7 @@ export class PM_Main extends PM {
349
309
  const evaluation = `
350
310
  console.log("importing ${dest}.mjs");
351
311
  import('${dest}.mjs').then(async (x) => {
352
- console.log("imported", x.default);
312
+ console.log("imported", (await x.default));
353
313
  try {
354
314
  return await (await x.default).receiveTestResourceConfig(${webArgz})
355
315
  } catch (e) {
@@ -361,13 +321,30 @@ export class PM_Main extends PM {
361
321
  this.browser
362
322
  .newPage()
363
323
  .then((page) => {
364
- page.on("console", (msg) => {
365
- console.log("web > ", msg.args(), msg.text());
366
- // for (let i = 0; i < msg._args.length; ++i)
367
- // 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"]`);
368
346
  });
369
347
  page.exposeFunction("customScreenShot", async (ssOpts, testName) => {
370
- // console.log("main.ts browser custom-screenshot", testName);
371
348
  const p = ssOpts.path;
372
349
  const dir = path.dirname(p);
373
350
  fs.mkdirSync(dir, {
@@ -466,24 +443,45 @@ export class PM_Main extends PM {
466
443
  // }, 5000);
467
444
  // return page.close();
468
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
+ });
469
474
  return page;
470
475
  })
471
476
  .then(async (page) => {
472
- 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
+ // );
473
480
  await page.goto(`file://${`${dest}.html`}`, {});
474
481
  await page
475
482
  .evaluate(evaluation)
476
483
  .then(async (features) => {
477
- Object.keys(features)
478
- .reduce(async (mm, lm) => {
479
- const accum = await mm;
480
- const x = await this.configs.featureIngestor(features[lm]);
481
- accum[lm] = x;
482
- return accum;
483
- }, Promise.resolve({}))
484
- .then((x) => {
485
- fs.writeFileSync(`${destFolder}/features.json`, JSON.stringify(x, null, 2));
486
- });
484
+ this.receiveFeatures(features, destFolder);
487
485
  })
488
486
  .catch((e) => {
489
487
  console.log("evaluation failed.", dest);
@@ -493,11 +491,62 @@ export class PM_Main extends PM {
493
491
  console.log("evaluation complete.", dest);
494
492
  // page.close();
495
493
  this.deregister(t);
496
- // whyIsNodeRunning();
497
494
  });
498
495
  return page;
499
496
  });
500
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
+ };
501
550
  this.server = {};
502
551
  this.configs = configs;
503
552
  this.ports = {};
@@ -568,17 +617,14 @@ export class PM_Main extends PM {
568
617
  delete files[testName];
569
618
  };
570
619
  }
571
- shutDown() {
572
- console.log("shutting down...");
573
- this.shutdownMode = true;
574
- this.checkForShutdown();
620
+ $(selector) {
621
+ throw new Error("Method not implemented.");
575
622
  }
576
- customScreenShot(opts) {
623
+ screencast(opts) {
577
624
  throw new Error("Method not implemented.");
578
625
  }
579
- async startPuppeteer(options, destfolder) {
580
- this.browser = (await puppeteer.launch(options));
581
- return this.browser;
626
+ customScreenShot(opts) {
627
+ throw new Error("Method not implemented.");
582
628
  }
583
629
  end(accessObject) {
584
630
  throw new Error("Method not implemented.");
@@ -641,4 +687,61 @@ export class PM_Main extends PM {
641
687
  write(accessObject, contents) {
642
688
  throw new Error("Method not implemented.");
643
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
+ }
644
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);
@@ -73,8 +99,8 @@ export class PM_Node extends PM {
73
99
  }
74
100
  // launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
75
101
  startPuppeteer(options) {
76
- return puppeteer.connect(options).then((b) => {
77
- this.browser = b;
78
- });
102
+ // return puppeteer.connect(options).then((b) => {
103
+ // this.browser = b;
104
+ // });
79
105
  }
80
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
  };