@mablhq/mabl-cli 1.16.11 → 1.16.32

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.
@@ -14,6 +14,18 @@ mablEmbeddedPdfDetector = () => {
14
14
  document.doctype.name &&
15
15
  document.doctype.name.indexOf('html') !== -1
16
16
  ) {
17
+ window.addEventListener(PDFEventType, handle, true);
18
+
19
+ // Don't wait for animation to load existing embedded elements
20
+ Array.from(document.querySelectorAll('object, embed')).forEach(
21
+ (element) => {
22
+ handle({
23
+ target: element,
24
+ animationName: MABL_PDF_DETECTOR_ANIMATION_NAME,
25
+ });
26
+ },
27
+ );
28
+
17
29
  if (!document.getElementById(MABL_PDF_DETECTOR_STYLE_ID)) {
18
30
  const pdfDetectorStyleElem = document.createElement.call(
19
31
  document,
@@ -34,7 +46,6 @@ mablEmbeddedPdfDetector = () => {
34
46
  document.body.appendChild(pdfDetectorStyleElem);
35
47
  }
36
48
  }
37
- window.addEventListener(PDFEventType, handle, true);
38
49
  }
39
50
 
40
51
  async function handle(event) {
@@ -50,6 +61,13 @@ mablEmbeddedPdfDetector = () => {
50
61
  const pdfUrl = pdfElement.src || pdfElement.data;
51
62
  const pdfFileName = mablGetPdfFilenameFromUrl(pdfUrl);
52
63
 
64
+ const embeddedPdfMablId = '__mabl_pdf_viewer_' + idSanitize(pdfFileName);
65
+ // Mark the embedded PDF element so that we can find it to replace it later
66
+ pdfElement.setAttribute(
67
+ MABL_EMBEDDED_PDF_DETECTED_FLAG,
68
+ embeddedPdfMablId,
69
+ );
70
+
53
71
  // Signal embedded PDF detection and pending download
54
72
  // Wait for the event to be acknowledged before starting the download
55
73
  await window.dispatchMablEvent({
@@ -62,13 +80,6 @@ mablEmbeddedPdfDetector = () => {
62
80
  // Trigger a download for the PDF
63
81
  mablDownloadEmbeddedPdf(pdfFileName, pdfUrl);
64
82
 
65
- const embeddedPdfMablId = '__mabl_pdf_viewer_' + idSanitize(pdfFileName);
66
- // Mark the embedded PDF element so that we can find it to replace it later
67
- pdfElement.setAttribute(
68
- MABL_EMBEDDED_PDF_DETECTED_FLAG,
69
- embeddedPdfMablId,
70
- );
71
-
72
83
  // Trigger replacement of the embedded PDF with an interactable version served by PDF server
73
84
  window.dispatchMablEvent({
74
85
  type: MESSAGE_TYPE_EMBEDDED_PDF_MARKED,
package/util/logUtils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.formatTimestamp = exports.valueToString = exports.logWebUIAndCliOutput = exports.findResultSeverityToLogLevel = exports.logCliOutput = exports.logInternal = void 0;
6
+ exports.formatTimestamp = exports.valueToString = exports.logWebUIAndCliOutput = exports.logWebUI = exports.findResultSeverityToLogLevel = exports.logCliOutput = exports.logInternal = void 0;
7
7
  const mablscriptFind_1 = require("../mablscriptFind");
8
8
  const loggingProvider_1 = require("../providers/logging/loggingProvider");
9
9
  const moment_1 = __importDefault(require("moment"));
@@ -43,6 +43,12 @@ function findResultSeverityToLogLevel(severity) {
43
43
  }
44
44
  }
45
45
  exports.findResultSeverityToLogLevel = findResultSeverityToLogLevel;
46
+ function logWebUI(logLine, logLevel, executionContext, metadata) {
47
+ metadata = metadata ? JSON.parse(JSON.stringify(metadata)) : {};
48
+ metadata.shouldOutputInConsole = false;
49
+ logWebUIAndCliOutput(logLine, logLevel, executionContext, metadata);
50
+ }
51
+ exports.logWebUI = logWebUI;
46
52
  function logWebUIAndCliOutput(logLine, logLevel, executionContext, metadata) {
47
53
  switch (logLevel) {
48
54
  case loggingProvider_1.LogLevel.Error:
@@ -22,15 +22,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.findNodeModulesDirectory = exports.findDirectory = exports.findResource = void 0;
23
23
  const path = __importStar(require("path"));
24
24
  const fs = __importStar(require("fs"));
25
- function findResource(pathInResource) {
26
- const unpackedPath = path.normalize(path.resolve(`${__dirname}/../../resources/${pathInResource}`));
27
- const packedPath = path.normalize(path.resolve(`${__dirname}/../resources/${pathInResource}`));
28
- if (fs.existsSync(unpackedPath)) {
29
- return unpackedPath;
25
+ function findResource(pathInResource, resourcesPathOverride) {
26
+ const pathsToCheck = [];
27
+ if (resourcesPathOverride) {
28
+ pathsToCheck.push(`${resourcesPathOverride}/${pathInResource}`);
30
29
  }
31
- return packedPath;
30
+ pathsToCheck.push(`${__dirname}/../../resources/${pathInResource}`);
31
+ pathsToCheck.push(`${__dirname}/../resources/${pathInResource}`);
32
+ const foundPath = pathsToCheck
33
+ .map((p) => path.normalize(path.resolve(p)))
34
+ .find(safeExistSync);
35
+ if (foundPath) {
36
+ return foundPath;
37
+ }
38
+ return path.normalize(pathsToCheck[0]);
32
39
  }
33
40
  exports.findResource = findResource;
41
+ function safeExistSync(path) {
42
+ try {
43
+ return fs.existsSync(path);
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ }
34
49
  function findDirectory(pathFromBase) {
35
50
  const unpackedPath = path.normalize(path.resolve(`${__dirname}/../../${pathFromBase}`));
36
51
  const packedPath = path.normalize(path.resolve(`${__dirname}/../${pathFromBase}`));