@simple-reporting/base 1.0.19 → 1.0.20
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/dev/package.json +1 -1
- package/package.json +1 -1
- package/scripts/build.js +33 -10
- package/srl/.srl/utils/html.ts +1 -104
package/dev/package.json
CHANGED
package/package.json
CHANGED
package/scripts/build.js
CHANGED
|
@@ -448,10 +448,10 @@ async function buildLdd(version) {
|
|
|
448
448
|
input: importFile,
|
|
449
449
|
output: {
|
|
450
450
|
assetFileNames: (assetInfo) => {
|
|
451
|
-
if (/
|
|
452
|
-
return '[name]
|
|
451
|
+
if (/css/.test(assetInfo.name)) {
|
|
452
|
+
return '[name][extname]';
|
|
453
453
|
}
|
|
454
|
-
return '[name][extname]';
|
|
454
|
+
return '[name]-[hash][extname]';
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
}
|
|
@@ -478,7 +478,19 @@ async function buildLdd(version) {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
async function buildPdfCustomer(customer) {
|
|
481
|
-
|
|
481
|
+
|
|
482
|
+
const customersDir = join(folders.root, 'pdf', 'customers');
|
|
483
|
+
|
|
484
|
+
if (customer === 'all') {
|
|
485
|
+
const customers = readdirSync(customersDir);
|
|
486
|
+
for (let i = 0; i < customers.length; i++) {
|
|
487
|
+
await buildPdfCustomer(customers[i]);
|
|
488
|
+
}
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const customerDir = join(customersDir, customer);
|
|
493
|
+
const customerName = customer.split('-')[0];
|
|
482
494
|
|
|
483
495
|
try {
|
|
484
496
|
statSync(customerDir);
|
|
@@ -502,7 +514,7 @@ async function buildPdfCustomer(customer) {
|
|
|
502
514
|
|
|
503
515
|
try {
|
|
504
516
|
statSync(customerDir);
|
|
505
|
-
const customerTarget = join(lddPdfDir,
|
|
517
|
+
const customerTarget = join(lddPdfDir, customerName);
|
|
506
518
|
mkdirSync(customerTarget, { recursive: true });
|
|
507
519
|
const jsReferences = [
|
|
508
520
|
'pdf.js'
|
|
@@ -514,6 +526,7 @@ async function buildPdfCustomer(customer) {
|
|
|
514
526
|
try {
|
|
515
527
|
const tsPath = join(customerDir, 'custom.ts');
|
|
516
528
|
statSync(tsPath);
|
|
529
|
+
|
|
517
530
|
const config = {
|
|
518
531
|
css: {
|
|
519
532
|
preprocessorOptions: {
|
|
@@ -524,12 +537,22 @@ async function buildPdfCustomer(customer) {
|
|
|
524
537
|
},
|
|
525
538
|
base: './',
|
|
526
539
|
build: {
|
|
540
|
+
assetsInlineLimit: 0,
|
|
527
541
|
outDir: customerTarget,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
542
|
+
assetsDir: '',
|
|
543
|
+
rollupOptions: {
|
|
544
|
+
input: tsPath,
|
|
545
|
+
output: {
|
|
546
|
+
entryFileNames: '[name].js',
|
|
547
|
+
chunkFileNames: '[name].js',
|
|
548
|
+
assetFileNames: (assetInfo) => {
|
|
549
|
+
if (/css/.test(assetInfo.name)) {
|
|
550
|
+
return '[name][extname]';
|
|
551
|
+
}
|
|
552
|
+
return 'assets/[name]-[hash][extname]';
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
533
556
|
},
|
|
534
557
|
publicDir: false,
|
|
535
558
|
};
|
package/srl/.srl/utils/html.ts
CHANGED
|
@@ -8,110 +8,13 @@ function attributesToString(attributes: Record<string, string | null>): string {
|
|
|
8
8
|
.join(' ');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function replaceAccordionContainer(text: string): string {
|
|
12
|
-
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion\s[^"']*["'][^>]*)>/gi;
|
|
13
|
-
let result = '';
|
|
14
|
-
let lastIndex = 0;
|
|
15
|
-
let match;
|
|
16
|
-
|
|
17
|
-
while ((match = openTagRegex.exec(text)) !== null) {
|
|
18
|
-
const start = match.index;
|
|
19
|
-
const attrs = match[1];
|
|
20
|
-
let depth = 1;
|
|
21
|
-
let end = openTagRegex.lastIndex;
|
|
22
|
-
|
|
23
|
-
while (depth > 0) {
|
|
24
|
-
const nextOpen = text.indexOf('<div', end);
|
|
25
|
-
const nextClose = text.indexOf('</div>', end);
|
|
26
|
-
if (nextClose === -1) break;
|
|
27
|
-
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
28
|
-
depth++;
|
|
29
|
-
end = nextOpen + 4;
|
|
30
|
-
} else {
|
|
31
|
-
depth--;
|
|
32
|
-
end = nextClose + 6;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const innerContent = replaceAccordionContainer(text.slice(openTagRegex.lastIndex, end - 6));
|
|
37
|
-
|
|
38
|
-
result += text.slice(lastIndex, start);
|
|
39
|
-
result += `<srl-category-accordion v-slot="{ accordion }"${attrs}>${innerContent}</srl-category-accordion>`;
|
|
40
|
-
lastIndex = end;
|
|
41
|
-
openTagRegex.lastIndex = end;
|
|
42
|
-
}
|
|
43
|
-
result += text.slice(lastIndex);
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function replaceAccordionToggle(text: string): string {
|
|
48
|
-
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion__head\s[^"']*["'][^>]*)>/gi;
|
|
49
|
-
let result = '';
|
|
50
|
-
let lastIndex = 0;
|
|
51
|
-
let match;
|
|
52
|
-
|
|
53
|
-
while ((match = openTagRegex.exec(text)) !== null) {
|
|
54
|
-
const start = match.index;
|
|
55
|
-
const attrs = match[1];
|
|
56
|
-
const contentStart = openTagRegex.lastIndex;
|
|
57
|
-
const closeTag = '</div>';
|
|
58
|
-
const end = text.indexOf(closeTag, contentStart);
|
|
59
|
-
if (end === -1) break;
|
|
60
|
-
|
|
61
|
-
const innerContent = text.slice(contentStart, end);
|
|
62
|
-
|
|
63
|
-
result += text.slice(lastIndex, start);
|
|
64
|
-
result += `<srl-category-accordion-toggle :accordion="accordion"${attrs}>${innerContent}</srl-category-accordion-toggle>`;
|
|
65
|
-
lastIndex = end + closeTag.length;
|
|
66
|
-
openTagRegex.lastIndex = lastIndex;
|
|
67
|
-
}
|
|
68
|
-
result += text.slice(lastIndex);
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function replaceAccordionContent(text: string): string {
|
|
73
|
-
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion__content(?:\s[^"']*)?["'][^>]*)>/gi;
|
|
74
|
-
let result = '';
|
|
75
|
-
let lastIndex = 0;
|
|
76
|
-
let match;
|
|
77
|
-
|
|
78
|
-
while ((match = openTagRegex.exec(text)) !== null) {
|
|
79
|
-
const start = match.index;
|
|
80
|
-
const attrs = match[1];
|
|
81
|
-
let depth = 1;
|
|
82
|
-
let end = openTagRegex.lastIndex;
|
|
83
|
-
|
|
84
|
-
while (depth > 0) {
|
|
85
|
-
const nextOpen = text.indexOf('<div', end);
|
|
86
|
-
const nextClose = text.indexOf('</div>', end);
|
|
87
|
-
if (nextClose === -1) break;
|
|
88
|
-
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
89
|
-
depth++;
|
|
90
|
-
end = nextOpen + 4;
|
|
91
|
-
} else {
|
|
92
|
-
depth--;
|
|
93
|
-
end = nextClose + 6;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const innerContent = replaceAccordionContent(text.slice(openTagRegex.lastIndex, end - 6));
|
|
98
|
-
|
|
99
|
-
result += text.slice(lastIndex, start);
|
|
100
|
-
result += `<srl-category-accordion-content :accordion="accordion"${attrs}>${innerContent}</srl-category-accordion-content>`;
|
|
101
|
-
lastIndex = end;
|
|
102
|
-
openTagRegex.lastIndex = end;
|
|
103
|
-
}
|
|
104
|
-
result += text.slice(lastIndex);
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
11
|
export function prepareHtmlContent(text: string): string {
|
|
109
12
|
const articles = useArticles();
|
|
110
13
|
const locale = useLocale();
|
|
111
14
|
|
|
112
15
|
const regex = /<a\s+([^>]+)>(.*?)<\/a>/gis;
|
|
113
16
|
text = text.replace(regex, (match, attrString, innerText) => {
|
|
114
|
-
|
|
17
|
+
|
|
115
18
|
const attrObj: AttrObj = {};
|
|
116
19
|
attrString.replace(/([a-zA-Z0-9\-_]+)(?:="([^"]*)")?/g, (m, key: string, value: string | null) => {
|
|
117
20
|
attrObj[key] = value || null;
|
|
@@ -169,12 +72,6 @@ export function prepareHtmlContent(text: string): string {
|
|
|
169
72
|
(_match, name, content) => `<template #${name}>${content}</template>`
|
|
170
73
|
);
|
|
171
74
|
|
|
172
|
-
text = replaceAccordionContainer(text);
|
|
173
|
-
text = replaceAccordionToggle(text);
|
|
174
|
-
text = replaceAccordionContent(text);
|
|
175
|
-
|
|
176
|
-
text = text.replaceAll('../', `./`);
|
|
177
|
-
|
|
178
75
|
text = text.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi, (match, p1) => {
|
|
179
76
|
addCssStyles(p1);
|
|
180
77
|
return '';
|