@topconsultnpm/sdkui-react 6.21.0-dev2.47 โ†’ 6.21.0-dev2.48

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.
@@ -35,7 +35,7 @@ export declare class ZipManager {
35
35
  static configure(options: {
36
36
  useWebWorkers?: boolean;
37
37
  maxWorkers?: number;
38
- }): void;
38
+ }): Promise<void>;
39
39
  /** Crea ZIP da array di file */
40
40
  static createZip(files: ZipFileEntry[], options?: ZipCreateOptions): Promise<Blob>;
41
41
  /** Crea ZIP da singolo file */
@@ -1,4 +1,23 @@
1
- import { BlobReader, BlobWriter, TextReader, Uint8ArrayReader, ZipWriter, configure } from "@zip.js/zip.js";
1
+ // ============================================================================
2
+ // LAZY LOADING
3
+ // ============================================================================
4
+ /** Flag per tracciare se la libreria รจ stata caricata */
5
+ let zipJsLoaded = false;
6
+ /** Carica @zip.js/zip.js on-demand */
7
+ const loadZipJs = async () => {
8
+ // if (!zipJsLoaded) {
9
+ // console.log('[ZipManager] ๐Ÿ“ฆ Caricamento lazy di @zip.js/zip.js...');
10
+ // console.time('[ZipManager] Tempo caricamento');
11
+ // }
12
+ const module = await import("@zip.js/zip.js");
13
+ // if (!zipJsLoaded) {
14
+ // console.timeEnd('[ZipManager] Tempo caricamento');
15
+ // console.log('[ZipManager] โœ… Libreria caricata!');
16
+ // zipJsLoaded = true;
17
+ // }
18
+ zipJsLoaded = true;
19
+ return module;
20
+ };
2
21
  // ============================================================================
3
22
  // ZIP MANAGER CLASS
4
23
  // ============================================================================
@@ -8,7 +27,8 @@ import { BlobReader, BlobWriter, TextReader, Uint8ArrayReader, ZipWriter, config
8
27
  */
9
28
  export class ZipManager {
10
29
  /** Configura zip.js (useWebWorkers, maxWorkers) */
11
- static configure(options) {
30
+ static async configure(options) {
31
+ const { configure } = await loadZipJs();
12
32
  configure(options);
13
33
  }
14
34
  // ========================================================================
@@ -19,6 +39,8 @@ export class ZipManager {
19
39
  const { password, compressionLevel = 6, encryptionStrength = 3, comment, onProgress, onEntryProgress, signal } = options;
20
40
  // Validazione password: stringa vuota = nessuna cifratura
21
41
  const usePassword = typeof password === "string" && password.length > 0 ? password : undefined;
42
+ // Lazy load della libreria
43
+ const { BlobWriter, ZipWriter, BlobReader, TextReader, Uint8ArrayReader } = await loadZipJs();
22
44
  const blobWriter = new BlobWriter("application/zip");
23
45
  const zipWriter = new ZipWriter(blobWriter, { password: usePassword, zipCrypto: true });
24
46
  try {
@@ -29,7 +51,7 @@ export class ZipManager {
29
51
  }
30
52
  const file = files[i];
31
53
  onProgress?.(i + 1, total, file.filename);
32
- const reader = this.createReader(file.data);
54
+ const reader = this.createReader(file.data, { BlobReader, TextReader, Uint8ArrayReader });
33
55
  await zipWriter.add(file.filename, reader, {
34
56
  comment: file.comment,
35
57
  lastModDate: file.lastModDate,
@@ -91,7 +113,8 @@ export class ZipManager {
91
113
  // PRIVATE
92
114
  // ========================================================================
93
115
  /** Converte data nel reader appropriato per zip.js */
94
- static createReader(data) {
116
+ static createReader(data, readers) {
117
+ const { BlobReader, TextReader, Uint8ArrayReader } = readers;
95
118
  if (typeof data === "string")
96
119
  return new TextReader(data);
97
120
  if (data instanceof Uint8Array)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.21.0-dev2.47",
3
+ "version": "6.21.0-dev2.48",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",