@ai-matrx/print 0.12.39 → 0.12.40

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/dist/labels.cjs CHANGED
@@ -37233,8 +37233,27 @@ function withMathStyles(htmlDocument) {
37233
37233
  const head = htmlDocument.search(/<\/head>/i);
37234
37234
  return head >= 0 ? htmlDocument.slice(0, head) + style + htmlDocument.slice(head) : style + htmlDocument;
37235
37235
  }
37236
+ var PRINT_HOST = /* @__PURE__ */ Symbol.for("ai-matrx.print.host");
37237
+ function getPrintHost() {
37238
+ return globalThis[PRINT_HOST] ?? null;
37239
+ }
37240
+ function handToPrintHost(htmlDocument, title) {
37241
+ const host = getPrintHost();
37242
+ if (!host) return false;
37243
+ try {
37244
+ const done = host(htmlDocument, { title });
37245
+ if (done && typeof done.catch === "function") {
37246
+ done.catch((error) => console.error("[@ai-matrx/print] the host's print failed", error));
37247
+ }
37248
+ return true;
37249
+ } catch (error) {
37250
+ console.error("[@ai-matrx/print] the host's print threw; using the print window instead", error);
37251
+ return false;
37252
+ }
37253
+ }
37236
37254
  function openPrintWindow(rawDocument, filename = "print", windowFeatures = "width=920,height=720,scrollbars=yes") {
37237
37255
  const htmlDocument = withMathStyles(rawDocument);
37256
+ if (handToPrintHost(htmlDocument, filename)) return "opened";
37238
37257
  const win = (0, import_outbound.openOutbound)("", "_blank", windowFeatures);
37239
37258
  if (!win) return openPrintWindowFallback(htmlDocument, filename);
37240
37259
  win.document.open();