@5minds/node-red-contrib-processcube 1.15.0 → 1.15.1-develop-d4d471-mapda5nn

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.15.0",
3
+ "version": "1.15.1-develop-d4d471-mapda5nn",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -2,10 +2,10 @@ module.exports = function (RED) {
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const os = require('os');
6
5
  const { pipeline } = require('stream');
7
6
  const { promisify } = require('util');
8
7
  const AdmZip = require('adm-zip');
8
+ const fetch = require('node-fetch');
9
9
 
10
10
  const streamPipeline = promisify(pipeline);
11
11
 
@@ -19,6 +19,30 @@ module.exports = function (RED) {
19
19
 
20
20
  try {
21
21
 
22
+ async function inlineCssImport(html) {
23
+ // 1. Finde @import-Zeile
24
+ const importRegex = /@import\s+url\(([^)]+)\);?/;
25
+ const match = html.match(importRegex);
26
+ if (!match) return html; // keine @import-Zeile gefunden
27
+
28
+ const url = match[1].replace(/['"]/g, ''); // evtl. Anführungszeichen entfernen
29
+
30
+ try {
31
+ const response = await fetch(url);
32
+ if (!response.ok) throw new Error(`Fehler beim Laden von ${url}`);
33
+
34
+ const cssContent = await response.text();
35
+
36
+ // 2. Ersetze @import-Zeile durch eingebettetes CSS
37
+ const embeddedStyle = `\n/* inlined from ${url} */\n${cssContent}`;
38
+ return html.replace(importRegex, embeddedStyle);
39
+ } catch (error) {
40
+ console.error('Fehler beim Inlining der CSS-Datei:', error);
41
+ return html; // Fallback: Original belassen
42
+ }
43
+ }
44
+
45
+
22
46
  function convertGoogleDriveLink(link) {
23
47
  // Format 0: https://docs.google.com/document/d/FILE_ID/edit
24
48
  const editMatch = link.match(/https:\/\/docs\.google\.com\/document\/d\/([^/]+)/);
@@ -112,6 +136,8 @@ module.exports = function (RED) {
112
136
  }
113
137
  }
114
138
 
139
+ html = await inlineCssImport(html);
140
+
115
141
  let new_payload = renderTemplate(html, msg.payload);
116
142
 
117
143
  // ggf. mit schalter