testeranto 0.62.0 → 0.73.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.
- package/README.md +38 -26
- package/dist/cjs-shim.js +2 -2
- package/dist/common/Node.js +14 -51
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +361 -0
- package/dist/common/PM/node.js +176 -0
- package/dist/common/PM/web.js +174 -0
- package/dist/common/Project.js +121 -266
- package/dist/common/Puppeteer.js +109 -0
- package/dist/common/Reporter.js +119 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +3 -1
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/common/Types.js +2 -32
- package/dist/common/Web.js +25 -37
- package/dist/common/esbuildConfigs/index.js +5 -5
- package/dist/common/esbuildConfigs/node.js +17 -15
- package/dist/common/esbuildConfigs/report.js +12 -47
- package/dist/common/esbuildConfigs/tests.js +0 -1
- package/dist/common/esbuildConfigs/web.js +17 -12
- package/dist/common/lib/abstractBase.js +190 -35
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +8 -5
- package/dist/common/lib/core.js +42 -17
- package/dist/common/lib/index.js +11 -8
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +14 -28
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +14 -51
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +331 -0
- package/dist/module/PM/node.js +168 -0
- package/dist/module/PM/web.js +167 -0
- package/dist/module/Project.js +122 -267
- package/dist/module/Puppeteer.js +104 -0
- package/dist/module/Reporter.js +114 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +3 -1
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-dom/component/node.js +2 -2
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/module/Types.js +3 -30
- package/dist/module/Web.js +26 -38
- package/dist/module/esbuildConfigs/index.js +5 -5
- package/dist/module/esbuildConfigs/node.js +17 -15
- package/dist/module/esbuildConfigs/report.js +11 -48
- package/dist/module/esbuildConfigs/tests.js +0 -1
- package/dist/module/esbuildConfigs/web.js +17 -12
- package/dist/module/lib/abstractBase.js +190 -35
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +8 -5
- package/dist/module/lib/core.js +44 -19
- package/dist/module/lib/index.js +11 -8
- package/dist/module/preload.js +15 -27
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.css +1616 -584
- package/dist/prebuild/Report.js +2635 -2506
- package/dist/types/Node.d.ts +3 -2
- package/dist/types/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +28 -0
- package/dist/types/PM/node.d.ts +26 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Project.d.ts +1 -2
- package/dist/types/Puppeteer.d.ts +1 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/puppeteer.d.ts +3 -3
- package/dist/types/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
- package/dist/types/Types.d.ts +19 -100
- package/dist/types/Web.d.ts +3 -2
- package/dist/types/esbuildConfigs/features.d.ts +1 -1
- package/dist/types/esbuildConfigs/index.d.ts +1 -1
- package/dist/types/esbuildConfigs/node.d.ts +1 -1
- package/dist/types/esbuildConfigs/report.d.ts +4 -0
- package/dist/types/esbuildConfigs/tests.d.ts +1 -1
- package/dist/types/esbuildConfigs/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +26 -24
- package/dist/types/lib/basebuilder.d.ts +10 -7
- package/dist/types/lib/classBuilder.d.ts +4 -3
- package/dist/types/lib/core.d.ts +5 -4
- package/dist/types/lib/index.d.ts +7 -5
- package/dist/types/lib/types.d.ts +62 -0
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -7
- package/src/Node.ts +30 -85
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +420 -0
- package/src/PM/node.ts +515 -0
- package/src/PM/web.ts +497 -0
- package/src/Project.ts +183 -619
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +158 -44
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +19 -14
- package/src/SubPackages/react/component/node.ts +20 -32
- package/src/SubPackages/react/component/web.ts +20 -30
- package/src/SubPackages/react/jsx/index.ts +13 -24
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react/jsx/web.ts +10 -8
- package/src/SubPackages/react-dom/component/node.ts +17 -23
- package/src/SubPackages/react-dom/component/web.ts +134 -95
- package/src/SubPackages/react-dom/jsx/web.ts +41 -48
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
- package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
- package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
- package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
- package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
- package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
- package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
- package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
- package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
- package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
- package/src/Types.ts +73 -307
- package/src/Web.ts +40 -81
- package/src/cjs-shim.js +2 -2
- package/src/esbuildConfigs/features.ts +3 -4
- package/src/esbuildConfigs/index.ts +8 -8
- package/src/esbuildConfigs/node.ts +21 -20
- package/src/esbuildConfigs/report.ts +15 -51
- package/src/esbuildConfigs/tests.ts +3 -9
- package/src/esbuildConfigs/web.ts +22 -20
- package/src/lib/abstractBase.ts +312 -164
- package/src/lib/basebuilder.ts +123 -127
- package/src/lib/classBuilder.ts +30 -48
- package/src/lib/core.ts +115 -84
- package/src/lib/index.ts +58 -56
- package/src/lib/types.ts +197 -0
- package/src/preload.ts +14 -30
- package/src/puppeteerConfiger.ts +26 -0
- package/src/web.html.ts +1 -1
- package/dist/common/NodeWriter.js +0 -56
- package/dist/common/electron.js +0 -196
- package/dist/common/lib/browser.js +0 -26
- package/dist/common/nodeWriterElectron.js +0 -55
- package/dist/module/NodeWriter.js +0 -50
- package/dist/module/electron.js +0 -191
- package/dist/module/lib/browser.js +0 -22
- package/dist/module/nodeWriterElectron.js +0 -52
- package/dist/types/NodeWriter.d.ts +0 -2
- package/dist/types/lib/browser.d.ts +0 -6
- package/dist/types/nodeWriterElectron.d.ts +0 -2
- package/src/NodeWriter.ts +0 -69
- package/src/electron.ts +0 -250
- package/src/lib/browser.ts +0 -34
- package/src/nodeWriterElectron.ts +0 -71
- package/yarn-error.log +0 -3144
- /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PM_Node = exports.addPageBinding = void 0;
|
|
7
|
+
// import puppeteer from "puppeteer";
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
// import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core";
|
|
11
|
+
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
12
|
+
const index_js_1 = require("./index.js");
|
|
13
|
+
const fPaths = [];
|
|
14
|
+
function addPageBinding(type, name, prefix) {
|
|
15
|
+
// Depending on the frame loading state either Runtime.evaluate or
|
|
16
|
+
// Page.addScriptToEvaluateOnNewDocument might succeed. Let's check that we
|
|
17
|
+
// don't re-wrap Puppeteer's binding.
|
|
18
|
+
if (globalThis[name]) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// We replace the CDP binding with a Puppeteer binding.
|
|
22
|
+
Object.assign(globalThis, {
|
|
23
|
+
[name](...args) {
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
// This is the Puppeteer binding.
|
|
26
|
+
const callPuppeteer = globalThis[name];
|
|
27
|
+
(_a = callPuppeteer.args) !== null && _a !== void 0 ? _a : (callPuppeteer.args = new Map());
|
|
28
|
+
(_b = callPuppeteer.callbacks) !== null && _b !== void 0 ? _b : (callPuppeteer.callbacks = new Map());
|
|
29
|
+
const seq = ((_c = callPuppeteer.lastSeq) !== null && _c !== void 0 ? _c : 0) + 1;
|
|
30
|
+
callPuppeteer.lastSeq = seq;
|
|
31
|
+
callPuppeteer.args.set(seq, args);
|
|
32
|
+
// Needs to be the same as CDP_BINDING_PREFIX.
|
|
33
|
+
globalThis[prefix + name](JSON.stringify({
|
|
34
|
+
type,
|
|
35
|
+
name,
|
|
36
|
+
seq,
|
|
37
|
+
args,
|
|
38
|
+
isTrivial: !args.some((value) => {
|
|
39
|
+
return value instanceof Node;
|
|
40
|
+
}),
|
|
41
|
+
}));
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
callPuppeteer.callbacks.set(seq, {
|
|
44
|
+
resolve(value) {
|
|
45
|
+
callPuppeteer.args.delete(seq);
|
|
46
|
+
resolve(value);
|
|
47
|
+
},
|
|
48
|
+
reject(value) {
|
|
49
|
+
callPuppeteer.args.delete(seq);
|
|
50
|
+
reject(value);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.addPageBinding = addPageBinding;
|
|
58
|
+
const files = new Set();
|
|
59
|
+
class PM_Node extends index_js_1.PM {
|
|
60
|
+
constructor(t) {
|
|
61
|
+
super();
|
|
62
|
+
this.server = {};
|
|
63
|
+
this.testResourceConfiguration = t;
|
|
64
|
+
}
|
|
65
|
+
existsSync(destFolder) {
|
|
66
|
+
return globalThis["existsSync"](this.testResourceConfiguration.fs + "/" + destFolder);
|
|
67
|
+
}
|
|
68
|
+
mkdirSync() {
|
|
69
|
+
return globalThis["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
70
|
+
}
|
|
71
|
+
write(writeObject, contents) {
|
|
72
|
+
return globalThis["write"](writeObject.uid, contents);
|
|
73
|
+
}
|
|
74
|
+
writeFileSync(filepath, contents) {
|
|
75
|
+
files.add(filepath);
|
|
76
|
+
return globalThis["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents);
|
|
77
|
+
}
|
|
78
|
+
createWriteStream(filepath) {
|
|
79
|
+
files.add(filepath);
|
|
80
|
+
return globalThis["createWriteStream"](this.testResourceConfiguration.fs + "/" + filepath);
|
|
81
|
+
}
|
|
82
|
+
end(writeObject) {
|
|
83
|
+
return globalThis["end"](writeObject.uid);
|
|
84
|
+
}
|
|
85
|
+
customclose() {
|
|
86
|
+
console.log("node-customclose");
|
|
87
|
+
// globalThis["writeFileSync"](
|
|
88
|
+
// this.testResourceConfiguration.fs + "/manifest.json",
|
|
89
|
+
// // files.entries()
|
|
90
|
+
// JSON.stringify(Array.from(files))
|
|
91
|
+
// ).then(() => {
|
|
92
|
+
// globalThis["customclose"]();
|
|
93
|
+
// });
|
|
94
|
+
}
|
|
95
|
+
// write(accessObject: { uid: number; }, contents: string): boolean {
|
|
96
|
+
// throw new Error("Method not implemented.");
|
|
97
|
+
// }
|
|
98
|
+
// existsSync(destFolder: string): boolean {
|
|
99
|
+
// return fs.existsSync(destFolder);
|
|
100
|
+
// }
|
|
101
|
+
// async mkdirSync(destFolder: string) {
|
|
102
|
+
// if (!fs.existsSync(destFolder)) {
|
|
103
|
+
// return fs.mkdirSync(destFolder, { recursive: true });
|
|
104
|
+
// }
|
|
105
|
+
// return false;
|
|
106
|
+
// }
|
|
107
|
+
// writeFileSync(fp: string, contents: string) {
|
|
108
|
+
// fs.writeFileSync(fp, contents);
|
|
109
|
+
// }
|
|
110
|
+
// createWriteStream(filepath: string): fs.WriteStream {
|
|
111
|
+
// return fs.createWriteStream(filepath);
|
|
112
|
+
// }
|
|
113
|
+
testArtiFactoryfileWriter(tLog, callback) {
|
|
114
|
+
return (fPath, value) => {
|
|
115
|
+
callback(new Promise((res, rej) => {
|
|
116
|
+
tLog("testArtiFactory =>", fPath);
|
|
117
|
+
const cleanPath = path_1.default.resolve(fPath);
|
|
118
|
+
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
119
|
+
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
120
|
+
fs_1.default.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
121
|
+
if (error) {
|
|
122
|
+
console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
123
|
+
}
|
|
124
|
+
fs_1.default.writeFileSync(path_1.default.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
|
|
125
|
+
encoding: "utf-8",
|
|
126
|
+
});
|
|
127
|
+
if (Buffer.isBuffer(value)) {
|
|
128
|
+
fs_1.default.writeFileSync(fPath, value, "binary");
|
|
129
|
+
res();
|
|
130
|
+
}
|
|
131
|
+
else if (`string` === typeof value) {
|
|
132
|
+
fs_1.default.writeFileSync(fPath, value.toString(), {
|
|
133
|
+
encoding: "utf-8",
|
|
134
|
+
});
|
|
135
|
+
res();
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
/* @ts-ignore:next-line */
|
|
139
|
+
const pipeStream = value;
|
|
140
|
+
const myFile = fs_1.default.createWriteStream(fPath);
|
|
141
|
+
pipeStream.pipe(myFile);
|
|
142
|
+
pipeStream.on("close", () => {
|
|
143
|
+
myFile.close();
|
|
144
|
+
res();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
|
|
152
|
+
startPuppeteer(options) {
|
|
153
|
+
console.log("start1");
|
|
154
|
+
return puppeteer_core_1.default.connect(options).then((b) => {
|
|
155
|
+
this.browser = b;
|
|
156
|
+
});
|
|
157
|
+
// return new Promise<Browser>((res, rej) => {
|
|
158
|
+
// // this.browser = await puppeteer.connect(options);
|
|
159
|
+
// // console.log("start2", this.browser);
|
|
160
|
+
// // console.log("mark5", this.browser);
|
|
161
|
+
// // res(this.browser);
|
|
162
|
+
// });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.PM_Node = PM_Node;
|
|
166
|
+
// class PuppetMasterServer extends AbstractPuppetMaster {
|
|
167
|
+
// // constructor(...z: []) {
|
|
168
|
+
// // super(...z);
|
|
169
|
+
// // }
|
|
170
|
+
// // // pages(): Promise<Page[]>;
|
|
171
|
+
// // pages(): Promise<Page[]> {
|
|
172
|
+
// // return new Promise<Page[]>((res, rej) => {
|
|
173
|
+
// // res(super.pages());
|
|
174
|
+
// // });
|
|
175
|
+
// // }
|
|
176
|
+
// }
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PM_Web = void 0;
|
|
7
|
+
const index_js_1 = require("./index.js");
|
|
8
|
+
const puppeteer_core_browser_js_1 = __importDefault(require("puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js"));
|
|
9
|
+
function waitForFunctionCall() {
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
window["myFunction"] = () => {
|
|
12
|
+
// Do something when myFunction is called
|
|
13
|
+
console.log("myFunction was called!");
|
|
14
|
+
resolve(); // Resolve the promise
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const files = new Set();
|
|
19
|
+
class PM_Web extends index_js_1.PM {
|
|
20
|
+
// testResourceConfiguration: ITTestResourceConfiguration;
|
|
21
|
+
constructor(t) {
|
|
22
|
+
super();
|
|
23
|
+
this.server = {};
|
|
24
|
+
this.testResourceConfiguration = t;
|
|
25
|
+
}
|
|
26
|
+
existsSync(destFolder) {
|
|
27
|
+
return window["existsSync"](destFolder);
|
|
28
|
+
}
|
|
29
|
+
mkdirSync() {
|
|
30
|
+
return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
31
|
+
}
|
|
32
|
+
write(writeObject, contents) {
|
|
33
|
+
return window["write"](writeObject.uid, contents);
|
|
34
|
+
}
|
|
35
|
+
writeFileSync(filepath, contents) {
|
|
36
|
+
console.log("WEB writeFileSync", filepath);
|
|
37
|
+
files.add(filepath);
|
|
38
|
+
return window["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents);
|
|
39
|
+
}
|
|
40
|
+
createWriteStream(filepath) {
|
|
41
|
+
files.add(filepath);
|
|
42
|
+
return window["createWriteStream"](this.testResourceConfiguration.fs + "/" + filepath);
|
|
43
|
+
}
|
|
44
|
+
end(writeObject) {
|
|
45
|
+
return window["end"](writeObject.uid);
|
|
46
|
+
}
|
|
47
|
+
customclose() {
|
|
48
|
+
window["writeFileSync"](this.testResourceConfiguration.fs + "/manifest.json",
|
|
49
|
+
// files.entries()
|
|
50
|
+
JSON.stringify(Array.from(files))).then(() => {
|
|
51
|
+
window["customclose"]();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
testArtiFactoryfileWriter(tLog, callback) {
|
|
55
|
+
return (fPath, value) => {
|
|
56
|
+
callback(new Promise((res, rej) => {
|
|
57
|
+
tLog("testArtiFactory =>", fPath);
|
|
58
|
+
// const cleanPath = path.resolve(fPath);
|
|
59
|
+
// fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
60
|
+
// const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
61
|
+
// fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
62
|
+
// if (error) {
|
|
63
|
+
// console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
64
|
+
// }
|
|
65
|
+
// fs.writeFileSync(
|
|
66
|
+
// path.resolve(
|
|
67
|
+
// targetDir.split("/").slice(0, -1).join("/"),
|
|
68
|
+
// "manifest"
|
|
69
|
+
// ),
|
|
70
|
+
// fPaths.join(`\n`),
|
|
71
|
+
// {
|
|
72
|
+
// encoding: "utf-8",
|
|
73
|
+
// }
|
|
74
|
+
// );
|
|
75
|
+
// if (Buffer.isBuffer(value)) {
|
|
76
|
+
// fs.writeFileSync(fPath, value, "binary");
|
|
77
|
+
// res();
|
|
78
|
+
// } else if (`string` === typeof value) {
|
|
79
|
+
// fs.writeFileSync(fPath, value.toString(), {
|
|
80
|
+
// encoding: "utf-8",
|
|
81
|
+
// });
|
|
82
|
+
// res();
|
|
83
|
+
// } else {
|
|
84
|
+
// /* @ts-ignore:next-line */
|
|
85
|
+
// const pipeStream: PassThrough = value;
|
|
86
|
+
// const myFile = fs.createWriteStream(fPath);
|
|
87
|
+
// pipeStream.pipe(myFile);
|
|
88
|
+
// pipeStream.on("close", () => {
|
|
89
|
+
// myFile.close();
|
|
90
|
+
// res();
|
|
91
|
+
// });
|
|
92
|
+
// }
|
|
93
|
+
// });
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
startPuppeteer(options, destFolder) {
|
|
98
|
+
return fetch(`http://localhost:3234/json/version`)
|
|
99
|
+
.then((v) => {
|
|
100
|
+
return v.json();
|
|
101
|
+
})
|
|
102
|
+
.then((json) => {
|
|
103
|
+
console.log("found endpoint", json.webSocketDebuggerUrl);
|
|
104
|
+
return puppeteer_core_browser_js_1.default
|
|
105
|
+
.connect({
|
|
106
|
+
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
107
|
+
})
|
|
108
|
+
.then((b) => {
|
|
109
|
+
this.browser = b;
|
|
110
|
+
const handler2 = {
|
|
111
|
+
get(target, prop, receiver) {
|
|
112
|
+
if (prop === "screenshot") {
|
|
113
|
+
return async (x) => {
|
|
114
|
+
// debugger;
|
|
115
|
+
files.add(x.path);
|
|
116
|
+
console.log("aloha", files);
|
|
117
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: destFolder + "/" + x.path }));
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
else if (prop === "mainFrame") {
|
|
121
|
+
return () => target[prop](...arguments);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return Reflect.get(...arguments);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
const handler1 = {
|
|
129
|
+
get(target, prop, receiver) {
|
|
130
|
+
if (prop === "pages") {
|
|
131
|
+
return async () => {
|
|
132
|
+
return target.pages().then((pages) => {
|
|
133
|
+
return pages.map((p) => {
|
|
134
|
+
return new Proxy(p, handler2);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return Reflect.get(...arguments);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
const proxy3 = new Proxy(this.browser, handler1);
|
|
143
|
+
this.browser = proxy3;
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
// console.log("connecting to ws://localhost:3234/devtools/browser/RANDOM");
|
|
147
|
+
// return puppeteer
|
|
148
|
+
// .connect({
|
|
149
|
+
// ...options,
|
|
150
|
+
// })
|
|
151
|
+
// .finally(() => {
|
|
152
|
+
// console.log("idk");
|
|
153
|
+
// });
|
|
154
|
+
// return new Promise<Browser>(async (res, rej) => {
|
|
155
|
+
// console.log("connecting with options", options);
|
|
156
|
+
// this.browser = await puppeteer.connect({
|
|
157
|
+
// ...options,
|
|
158
|
+
// });
|
|
159
|
+
// res(this.browser);
|
|
160
|
+
// });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.PM_Web = PM_Web;
|
|
164
|
+
// class PuppetMasterServer extends AbstractPuppetMaster {
|
|
165
|
+
// // constructor(...z: []) {
|
|
166
|
+
// // super(...z);
|
|
167
|
+
// // }
|
|
168
|
+
// // // pages(): Promise<Page[]>;
|
|
169
|
+
// // pages(): Promise<Page[]> {
|
|
170
|
+
// // return new Promise<Page[]>((res, rej) => {
|
|
171
|
+
// // res(super.pages());
|
|
172
|
+
// // });
|
|
173
|
+
// // }
|
|
174
|
+
// }
|