@uuv/assistant 1.4.3 → 1.5.1

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.
@@ -1,4 +1,6 @@
1
1
  {
2
- "reactScript": "/../../build/static/js/main.cb348734.js",
3
- "cssFile": "/../../build/static/css/main.8c76db0a.css"
2
+ "packageJson": "/../../package.json",
3
+ "reactScript": "/build/static/js/main.d482abe3.js",
4
+ "cssFile": "/build/static/css/main.8c76db0a.css",
5
+ "unifiedFile": "/../uuv-assistant-resources.bundle.js"
4
6
  }
@@ -1 +1 @@
1
- export * from './uuv-assistant';
1
+ export * from "./uuv-assistant";
@@ -1,2 +1,17 @@
1
1
  #!/usr/bin/env node
2
+ /**
3
+ * Copyright UUV.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
2
17
  export {};
@@ -1,5 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ /**
4
+ * Copyright UUV.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
3
18
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
20
  };
@@ -8,6 +23,7 @@ const index_1 = require("./index");
8
23
  const chalk_1 = __importDefault(require("chalk"));
9
24
  const figlet_1 = __importDefault(require("figlet"));
10
25
  const fs_1 = __importDefault(require("fs"));
26
+ const conf_json_1 = __importDefault(require("./conf.json"));
11
27
  function printBanner(getCurrentVersion) {
12
28
  console.log(chalk_1.default.blueBright(figlet_1.default.textSync("UUV - Assistant", {
13
29
  font: "Big",
@@ -19,7 +35,7 @@ function printBanner(getCurrentVersion) {
19
35
  console.info(chalk_1.default.blueBright(`Version: ${getCurrentVersion()}\n\n`));
20
36
  }
21
37
  function getCurrentVersion() {
22
- const pJsonStr = fs_1.default.readFileSync(`${__dirname}/../package.json`, {
38
+ const pJsonStr = fs_1.default.readFileSync(`${__dirname}${conf_json_1.default.packageJson}`, {
23
39
  encoding: "utf8", flag: "r"
24
40
  });
25
41
  return JSON.parse(pJsonStr).version;
@@ -1,4 +1,18 @@
1
+ /**
2
+ * Copyright UUV.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  export declare class UuvAssistant {
2
- private initReactDomRootElementFn;
3
17
  start(translatorFn?: (el: HTMLElement) => string): Promise<void>;
4
18
  }
@@ -1,54 +1,48 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright UUV.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
2
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
19
  };
5
20
  Object.defineProperty(exports, "__esModule", { value: true });
6
21
  exports.UuvAssistant = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- let translator;
9
- let uuvCssContent;
22
+ const playwright_chromium_1 = require("playwright-chromium");
23
+ const conf_json_1 = __importDefault(require("./conf.json"));
24
+ const chalk_1 = __importDefault(require("chalk"));
25
+ const minimist_1 = __importDefault(require("minimist"));
10
26
  class UuvAssistant {
11
- initReactDomRootElementFn() {
12
- return () => {
13
- window.onload = function () {
14
- if (window.location === window.parent.location) {
15
- console.log("DOMContentLoaded");
16
- const rootElement = document.createElement("div");
17
- const event = translator !== undefined ? new CustomEvent("UUVAssistantReadyToLoad", {
18
- detail: {
19
- translator: translator
20
- }
21
- }) : new Event("UUVAssistantReadyToLoad");
22
- rootElement.id = "uvv-assistant-root";
23
- document.body.appendChild(rootElement);
24
- document.dispatchEvent(event);
25
- const style = document.createElement("style");
26
- style.type = "text/css";
27
- style.innerHTML = uuvCssContent;
28
- document.getElementsByTagName("head")[0].appendChild(style);
29
- }
30
- };
31
- };
32
- }
33
27
  async start(translatorFn) {
34
- const { chromium } = require("playwright-chromium");
35
- const argv = require("minimist")(process.argv.slice(2));
36
- const conf = require("./conf.json");
37
- const browser = await chromium.launch({ headless: false });
28
+ const argv = (0, minimist_1.default)(process.argv.slice(2));
29
+ const browser = await playwright_chromium_1.chromium.launch({ headless: false });
38
30
  const browserContext = await browser.newContext({ viewport: null });
39
31
  const page = await browserContext.newPage();
32
+ if (!argv["targetUrl"]) {
33
+ console.error(chalk_1.default.redBright("Parameter --targetUrl is required"));
34
+ process.exit(-1);
35
+ }
40
36
  const translatorDeclaration = translatorFn ?
41
37
  `var translator = ${translatorFn.toString()}; console.log('translator'); console.log(translator);` :
42
38
  "var translator = null;";
43
- const cssContentDeclaration = `\n var uuvCssContent = "${fs_1.default.readFileSync(__dirname + conf.cssFile).toString()}"`;
44
39
  await browserContext.addInitScript({
45
- content: `${translatorDeclaration}${cssContentDeclaration}`
40
+ content: `${translatorDeclaration}`
46
41
  });
47
- await browserContext.addInitScript(this.initReactDomRootElementFn());
48
42
  await browserContext.addInitScript({
49
- path: `${__dirname}${conf.reactScript}`
43
+ path: `${__dirname}${conf_json_1.default.unifiedFile}`
50
44
  });
51
- await page.goto(argv.targetUrl);
45
+ await page.goto(argv["targetUrl"]);
52
46
  }
53
47
  }
54
48
  exports.UuvAssistant = UuvAssistant;