mcard-js 1.0.0

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.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/__mocks__/better-sqlite3.js +20 -0
  4. package/dist/__mocks__/better-sqlite3.js.map +1 -0
  5. package/dist/config/config_constants.js +188 -0
  6. package/dist/config/config_constants.js.map +1 -0
  7. package/dist/config/env_parameters.js +62 -0
  8. package/dist/config/env_parameters.js.map +1 -0
  9. package/dist/content/model/content_type_detector.js +89 -0
  10. package/dist/content/model/content_type_detector.js.map +1 -0
  11. package/dist/core/card-collection.js +279 -0
  12. package/dist/core/card-collection.js.map +1 -0
  13. package/dist/core/event-producer.js +132 -0
  14. package/dist/core/event-producer.js.map +1 -0
  15. package/dist/core/g_time.js +201 -0
  16. package/dist/core/g_time.js.map +1 -0
  17. package/dist/core/hash/enums.js +19 -0
  18. package/dist/core/hash/enums.js.map +1 -0
  19. package/dist/core/hash/validator.js +260 -0
  20. package/dist/core/hash/validator.js.map +1 -0
  21. package/dist/core/mcard.js +205 -0
  22. package/dist/core/mcard.js.map +1 -0
  23. package/dist/engine/sqlite_engine.js +723 -0
  24. package/dist/engine/sqlite_engine.js.map +1 -0
  25. package/dist/index.js +10 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/middleware/mcardPersistenceMiddleware.js +45 -0
  28. package/dist/middleware/mcardPersistenceMiddleware.js.map +1 -0
  29. package/dist/models/database_schemas.js +31 -0
  30. package/dist/models/database_schemas.js.map +1 -0
  31. package/dist/services/logger.js +80 -0
  32. package/dist/services/logger.js.map +1 -0
  33. package/dist/services/mcardStorageService.js +36 -0
  34. package/dist/services/mcardStorageService.js.map +1 -0
  35. package/dist/utils/actionHelpers.js +25 -0
  36. package/dist/utils/actionHelpers.js.map +1 -0
  37. package/dist/utils/bufferContentHelper.js +393 -0
  38. package/dist/utils/bufferContentHelper.js.map +1 -0
  39. package/dist/utils/bufferPolyfill.js +198 -0
  40. package/dist/utils/bufferPolyfill.js.map +1 -0
  41. package/dist/utils/content-detection.js +74 -0
  42. package/dist/utils/content-detection.js.map +1 -0
  43. package/dist/utils/content-utils.js +269 -0
  44. package/dist/utils/content-utils.js.map +1 -0
  45. package/dist/utils/content_type_detector copy.js +480 -0
  46. package/dist/utils/content_type_detector copy.js.map +1 -0
  47. package/dist/utils/content_type_detector.js +480 -0
  48. package/dist/utils/content_type_detector.js.map +1 -0
  49. package/dist/utils/cryptoPolyfill.js +166 -0
  50. package/dist/utils/cryptoPolyfill.js.map +1 -0
  51. package/dist/utils/dotenv-browser.js +35 -0
  52. package/dist/utils/dotenv-browser.js.map +1 -0
  53. package/dist/utils/environmentDetector.js +93 -0
  54. package/dist/utils/environmentDetector.js.map +1 -0
  55. package/dist/utils/logWriter.js +27 -0
  56. package/dist/utils/logWriter.js.map +1 -0
  57. package/dist/utils/serviceWorkerManager.js +118 -0
  58. package/dist/utils/serviceWorkerManager.js.map +1 -0
  59. package/dist/utils/test-content-detection.js +79 -0
  60. package/dist/utils/test-content-detection.js.map +1 -0
  61. package/dist/utils/test-detection-fix.js +121 -0
  62. package/dist/utils/test-detection-fix.js.map +1 -0
  63. package/dist/utils/test-format-conversion.js +170 -0
  64. package/dist/utils/test-format-conversion.js.map +1 -0
  65. package/dist/utils/test-mov-viewer.js +57 -0
  66. package/dist/utils/test-mov-viewer.js.map +1 -0
  67. package/dist/utils/testDetection.js +21 -0
  68. package/dist/utils/testDetection.js.map +1 -0
  69. package/dist/utils/textEncoderPolyfill.js +87 -0
  70. package/dist/utils/textEncoderPolyfill.js.map +1 -0
  71. package/package.json +74 -0
  72. package/src/__mocks__/better-sqlite3.js +14 -0
  73. package/src/config/config_constants.js +227 -0
  74. package/src/config/env_parameters.js +69 -0
  75. package/src/content/model/content_type_detector.js +87 -0
  76. package/src/core/card-collection.js +300 -0
  77. package/src/core/event-producer.js +160 -0
  78. package/src/core/g_time.js +215 -0
  79. package/src/core/hash/enums.js +13 -0
  80. package/src/core/hash/validator.js +271 -0
  81. package/src/core/mcard.js +203 -0
  82. package/src/engine/sqlite_engine.js +755 -0
  83. package/src/index.js +10 -0
  84. package/src/middleware/mcardPersistenceMiddleware.js +45 -0
  85. package/src/models/database_schemas.js +26 -0
  86. package/src/services/logger.js +74 -0
  87. package/src/services/mcardStorageService.js +34 -0
  88. package/src/utils/actionHelpers.js +13 -0
  89. package/src/utils/bufferContentHelper.js +436 -0
  90. package/src/utils/bufferPolyfill.js +202 -0
  91. package/src/utils/cn.ts +6 -0
  92. package/src/utils/content-detection.js +66 -0
  93. package/src/utils/content-utils.js +250 -0
  94. package/src/utils/content_type_detector copy.js +501 -0
  95. package/src/utils/content_type_detector.js +501 -0
  96. package/src/utils/cryptoPolyfill.js +180 -0
  97. package/src/utils/dateUtils.ts +18 -0
  98. package/src/utils/dbInitializer.ts +27 -0
  99. package/src/utils/dotenv-browser.js +29 -0
  100. package/src/utils/environmentDetector.js +92 -0
  101. package/src/utils/logWriter.js +20 -0
  102. package/src/utils/serviceWorkerManager.js +122 -0
  103. package/src/utils/stateWatcher.ts +78 -0
  104. package/src/utils/storeAdapter copy.ts +157 -0
  105. package/src/utils/storeAdapter.ts +157 -0
  106. package/src/utils/test-content-detection.js +71 -0
  107. package/src/utils/test-detection-fix.js +136 -0
  108. package/src/utils/test-format-conversion.js +165 -0
  109. package/src/utils/test-mov-viewer.js +59 -0
  110. package/src/utils/testDetection.js +16 -0
  111. package/src/utils/textEncoderPolyfill.js +88 -0
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createHash = createHash;
7
+ exports.default = void 0;
8
+ var _textEncoderPolyfill = require("./textEncoderPolyfill.js");
9
+ /**
10
+ * Cross-environment crypto polyfill
11
+ *
12
+ * This module provides a unified interface for cryptographic operations
13
+ * that works in both browser and Node.js/SSR environments.
14
+ */
15
+
16
+ // Since Astro SSR environment is complex and sometimes behaves like browser,
17
+ // sometimes like Node.js, we need to carefully detect capabilities
18
+ const hasWebCrypto = typeof window !== 'undefined' && window.crypto && window.crypto.subtle;
19
+ const hasNodeCrypto = typeof process !== 'undefined' && process.versions && process.versions.node;
20
+
21
+ /**
22
+ * Create a hash object that works in any environment
23
+ * @param {string} algorithm - Hash algorithm to use
24
+ * @returns {Object} Hash object with update and digest methods
25
+ */
26
+ function createHash(algorithm) {
27
+ // Normalize algorithm name for consistency
28
+ const normalizedAlg = String(algorithm).toLowerCase().replace(/-/g, '');
29
+ if (hasNodeCrypto) {
30
+ const nodeCrypto = require('crypto');
31
+ const hash = nodeCrypto.createHash(normalizedAlg);
32
+ return {
33
+ update: function (data) {
34
+ const bufferData = typeof data === 'string' ? (0, _textEncoderPolyfill.encodeText)(data) : data;
35
+ hash.update(bufferData);
36
+ return this;
37
+ },
38
+ digest: function (encoding = 'hex') {
39
+ return hash.digest(encoding);
40
+ }
41
+ };
42
+ }
43
+
44
+ // Map to standardized algorithm names
45
+ const webCryptoAlg = normalizedAlg === 'md5' ? 'SHA-1' :
46
+ // Web Crypto doesn't support MD5, fallback to SHA-1
47
+ normalizedAlg === 'sha1' ? 'SHA-1' : normalizedAlg === 'sha224' ? 'SHA-256' :
48
+ // Web Crypto doesn't support SHA-224
49
+ normalizedAlg === 'sha256' ? 'SHA-256' : normalizedAlg === 'sha384' ? 'SHA-384' : normalizedAlg === 'sha512' ? 'SHA-512' : 'SHA-256';
50
+
51
+ // Implement a unified hash interface
52
+ return {
53
+ data: null,
54
+ /**
55
+ * Update hash with data
56
+ * @param {string|Uint8Array} data - Data to hash
57
+ * @returns {Object} This hash object for chaining
58
+ */
59
+ update: function (data) {
60
+ this.data = data;
61
+ return this;
62
+ },
63
+ /**
64
+ * Complete hash computation and return result
65
+ * @param {string} [encoding='hex'] - Encoding for output ('hex' or undefined for buffer)
66
+ * @returns {string|Uint8Array|Promise<string|Uint8Array>} Hash result
67
+ */
68
+ digest: function (encoding = 'hex') {
69
+ // Handle empty data case
70
+ if (!this.data) {
71
+ return encoding === 'hex' ? '' : new Uint8Array();
72
+ }
73
+
74
+ // Use Web Crypto API if available
75
+ if (hasWebCrypto) {
76
+ // Ensure data is properly encoded
77
+ const dataBuffer = this.data instanceof Uint8Array ? this.data.buffer : (0, _textEncoderPolyfill.encodeText)(String(this.data)).buffer;
78
+
79
+ // Return a promise that resolves to the hash
80
+ return window.crypto.subtle.digest(webCryptoAlg, dataBuffer).then(hashBuffer => {
81
+ if (encoding === 'hex') {
82
+ return Array.from(new Uint8Array(hashBuffer)).map(b => b.toString(16).padStart(2, '0')).join('');
83
+ }
84
+ return new Uint8Array(hashBuffer);
85
+ }).catch(err => {
86
+ console.error('Web Crypto error:', err);
87
+ // Return empty result on error
88
+ return encoding === 'hex' ? '' : new Uint8Array();
89
+ });
90
+ }
91
+ try {
92
+ // Try to use Node.js crypto if available, without direct require
93
+ if (typeof global !== 'undefined' && global.process && global.process.versions && global.process.versions.node) {
94
+ // In Node.js environment, we can safely try to require crypto
95
+ const crypto = require('crypto');
96
+ const nodeHash = crypto.createHash(normalizedAlg);
97
+ if (this.data instanceof Uint8Array) {
98
+ nodeHash.update(Buffer.from(this.data));
99
+ } else {
100
+ nodeHash.update(String(this.data));
101
+ }
102
+ return nodeHash.digest(encoding);
103
+ }
104
+ } catch (e) {
105
+ console.warn('Node.js crypto module not available:', e.message);
106
+ // Fall through to fallback implementation
107
+ }
108
+
109
+ // If we're in neither environment or if detection fails, use a better fallback
110
+ // that doesn't require 'require()' calls but produces reasonable output
111
+ const fallbackHash = enhancedFallbackHash(normalizedAlg, this.data);
112
+ return encoding === 'hex' ? fallbackHash : (0, _textEncoderPolyfill.encodeText)(fallbackHash);
113
+ }
114
+ };
115
+ }
116
+
117
+ /**
118
+ * Enhanced fallback hash implementation that produces output
119
+ * with the correct length for the requested algorithm
120
+ *
121
+ * @param {string} algorithm - Hash algorithm name
122
+ * @param {string|Uint8Array} data - Data to hash
123
+ * @returns {string} Hash string with appropriate length
124
+ */
125
+ function enhancedFallbackHash(algorithm, data) {
126
+ // Convert data to string if it's a Uint8Array
127
+ const inputStr = data instanceof Uint8Array ? Array.from(data).map(b => String.fromCharCode(b)).join('') : String(data);
128
+
129
+ // Determine output length based on algorithm
130
+ const hashLength = algorithm === 'md5' ? 32 : algorithm === 'sha1' ? 40 : algorithm === 'sha224' ? 56 : algorithm === 'sha256' ? 64 : algorithm === 'sha384' ? 96 : algorithm === 'sha512' ? 128 : 64; // Default to SHA-256 length
131
+
132
+ // More sophisticated hash function
133
+ // This still isn't cryptographically secure, but it's better than the simple one
134
+ // and will produce the right length output
135
+
136
+ // Start with a seed based on algorithm
137
+ const seed = algorithm.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
138
+
139
+ // Generate initial hash chunks
140
+ const chunks = [];
141
+ let lastVal = seed;
142
+
143
+ // Generate enough raw material for our hash length
144
+ for (let i = 0; i < hashLength / 8 + 1; i++) {
145
+ let chunk = 0;
146
+ for (let j = 0; j < inputStr.length; j++) {
147
+ const char = inputStr.charCodeAt(j);
148
+ chunk = (chunk << 5) - chunk + char + j + i + lastVal & 0xFFFFFFFF;
149
+ }
150
+ lastVal = chunk;
151
+ chunks.push(chunk);
152
+ }
153
+
154
+ // Convert chunks to hex and combine into final hash
155
+ let hexHash = '';
156
+ for (let i = 0; i < chunks.length && hexHash.length < hashLength; i++) {
157
+ hexHash += Math.abs(chunks[i]).toString(16).padStart(8, '0');
158
+ }
159
+
160
+ // Ensure exact length
161
+ return hexHash.substring(0, hashLength);
162
+ }
163
+ var _default = exports.default = {
164
+ createHash
165
+ };
166
+ //# sourceMappingURL=cryptoPolyfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cryptoPolyfill.js","names":["_textEncoderPolyfill","require","hasWebCrypto","window","crypto","subtle","hasNodeCrypto","process","versions","node","createHash","algorithm","normalizedAlg","String","toLowerCase","replace","nodeCrypto","hash","update","data","bufferData","encodeText","digest","encoding","webCryptoAlg","Uint8Array","dataBuffer","buffer","then","hashBuffer","Array","from","map","b","toString","padStart","join","catch","err","console","error","global","nodeHash","Buffer","e","warn","message","fallbackHash","enhancedFallbackHash","inputStr","fromCharCode","hashLength","seed","split","reduce","acc","char","charCodeAt","chunks","lastVal","i","chunk","j","length","push","hexHash","Math","abs","substring","_default","exports","default"],"sources":["../../src/utils/cryptoPolyfill.js"],"sourcesContent":["/**\n * Cross-environment crypto polyfill\n * \n * This module provides a unified interface for cryptographic operations\n * that works in both browser and Node.js/SSR environments.\n */\n\nimport { encodeText } from './textEncoderPolyfill.js';\n\n// Since Astro SSR environment is complex and sometimes behaves like browser, \n// sometimes like Node.js, we need to carefully detect capabilities\nconst hasWebCrypto = typeof window !== 'undefined' && window.crypto && window.crypto.subtle;\nconst hasNodeCrypto = typeof process !== 'undefined' && process.versions && process.versions.node;\n\n/**\n * Create a hash object that works in any environment\n * @param {string} algorithm - Hash algorithm to use\n * @returns {Object} Hash object with update and digest methods\n */\nexport function createHash(algorithm) {\n // Normalize algorithm name for consistency\n const normalizedAlg = String(algorithm).toLowerCase().replace(/-/g, '');\n \n if (hasNodeCrypto) {\n const nodeCrypto = require('crypto');\n const hash = nodeCrypto.createHash(normalizedAlg);\n return {\n update: function(data) {\n const bufferData = typeof data === 'string' ? encodeText(data) : data;\n hash.update(bufferData);\n return this;\n },\n digest: function(encoding = 'hex') {\n return hash.digest(encoding);\n }\n };\n }\n\n // Map to standardized algorithm names\n const webCryptoAlg = \n normalizedAlg === 'md5' ? 'SHA-1' : // Web Crypto doesn't support MD5, fallback to SHA-1\n normalizedAlg === 'sha1' ? 'SHA-1' :\n normalizedAlg === 'sha224' ? 'SHA-256' : // Web Crypto doesn't support SHA-224\n normalizedAlg === 'sha256' ? 'SHA-256' :\n normalizedAlg === 'sha384' ? 'SHA-384' :\n normalizedAlg === 'sha512' ? 'SHA-512' : 'SHA-256';\n \n // Implement a unified hash interface\n return {\n data: null,\n \n /**\n * Update hash with data\n * @param {string|Uint8Array} data - Data to hash\n * @returns {Object} This hash object for chaining\n */\n update: function(data) {\n this.data = data;\n return this;\n },\n \n /**\n * Complete hash computation and return result\n * @param {string} [encoding='hex'] - Encoding for output ('hex' or undefined for buffer)\n * @returns {string|Uint8Array|Promise<string|Uint8Array>} Hash result\n */\n digest: function(encoding = 'hex') {\n // Handle empty data case\n if (!this.data) {\n return encoding === 'hex' ? '' : new Uint8Array();\n }\n \n // Use Web Crypto API if available\n if (hasWebCrypto) {\n // Ensure data is properly encoded\n const dataBuffer = this.data instanceof Uint8Array \n ? this.data.buffer\n : encodeText(String(this.data)).buffer;\n \n // Return a promise that resolves to the hash\n return window.crypto.subtle.digest(webCryptoAlg, dataBuffer)\n .then(hashBuffer => {\n if (encoding === 'hex') {\n return Array.from(new Uint8Array(hashBuffer))\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n }\n return new Uint8Array(hashBuffer);\n })\n .catch(err => {\n console.error('Web Crypto error:', err);\n // Return empty result on error\n return encoding === 'hex' ? '' : new Uint8Array();\n });\n }\n \n try {\n // Try to use Node.js crypto if available, without direct require\n if (typeof global !== 'undefined' && global.process && global.process.versions && global.process.versions.node) {\n // In Node.js environment, we can safely try to require crypto\n const crypto = require('crypto');\n const nodeHash = crypto.createHash(normalizedAlg);\n \n if (this.data instanceof Uint8Array) {\n nodeHash.update(Buffer.from(this.data));\n } else {\n nodeHash.update(String(this.data));\n }\n \n return nodeHash.digest(encoding);\n }\n } catch (e) {\n console.warn('Node.js crypto module not available:', e.message);\n // Fall through to fallback implementation\n }\n \n // If we're in neither environment or if detection fails, use a better fallback\n // that doesn't require 'require()' calls but produces reasonable output\n const fallbackHash = enhancedFallbackHash(normalizedAlg, this.data);\n return encoding === 'hex' ? fallbackHash : encodeText(fallbackHash);\n }\n };\n}\n\n/**\n * Enhanced fallback hash implementation that produces output\n * with the correct length for the requested algorithm\n * \n * @param {string} algorithm - Hash algorithm name\n * @param {string|Uint8Array} data - Data to hash\n * @returns {string} Hash string with appropriate length\n */\nfunction enhancedFallbackHash(algorithm, data) {\n // Convert data to string if it's a Uint8Array\n const inputStr = data instanceof Uint8Array \n ? Array.from(data).map(b => String.fromCharCode(b)).join('')\n : String(data);\n \n // Determine output length based on algorithm\n const hashLength = \n algorithm === 'md5' ? 32 :\n algorithm === 'sha1' ? 40 :\n algorithm === 'sha224' ? 56 :\n algorithm === 'sha256' ? 64 :\n algorithm === 'sha384' ? 96 :\n algorithm === 'sha512' ? 128 : 64; // Default to SHA-256 length\n \n // More sophisticated hash function\n // This still isn't cryptographically secure, but it's better than the simple one\n // and will produce the right length output\n \n // Start with a seed based on algorithm\n const seed = algorithm.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);\n \n // Generate initial hash chunks\n const chunks = [];\n let lastVal = seed;\n \n // Generate enough raw material for our hash length\n for (let i = 0; i < hashLength / 8 + 1; i++) {\n let chunk = 0;\n for (let j = 0; j < inputStr.length; j++) {\n const char = inputStr.charCodeAt(j);\n chunk = ((chunk << 5) - chunk + char + j + i + lastVal) & 0xFFFFFFFF;\n }\n lastVal = chunk;\n chunks.push(chunk);\n }\n \n // Convert chunks to hex and combine into final hash\n let hexHash = '';\n for (let i = 0; i < chunks.length && hexHash.length < hashLength; i++) {\n hexHash += Math.abs(chunks[i]).toString(16).padStart(8, '0');\n }\n \n // Ensure exact length\n return hexHash.substring(0, hashLength);\n}\n\nexport default { createHash };\n"],"mappings":";;;;;;;AAOA,IAAAA,oBAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA,MAAMC,YAAY,GAAG,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,MAAM,IAAID,MAAM,CAACC,MAAM,CAACC,MAAM;AAC3F,MAAMC,aAAa,GAAG,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,QAAQ,IAAID,OAAO,CAACC,QAAQ,CAACC,IAAI;;AAEjG;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAACC,SAA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,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EAAE7D;AAAW,CAAC","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * Browser-compatible dotenv replacement
9
+ * Provides a no-op implementation of dotenv for browser environments
10
+ */
11
+
12
+ // Create browser-safe "process.env" equivalent
13
+ const browserEnv = {};
14
+
15
+ // Create a browser-safe version of the dotenv module
16
+ const dotenvBrowser = {
17
+ // No-op config function that returns an empty object in browser context
18
+ config: () => ({
19
+ parsed: {}
20
+ }),
21
+ // Provide access to our browser environment variables
22
+ env: browserEnv,
23
+ // Add any variables from window.__ENV__ if it exists (useful for SSR)
24
+ init: () => {
25
+ if (typeof window !== 'undefined' && window.__ENV__) {
26
+ Object.assign(browserEnv, window.__ENV__);
27
+ }
28
+ return browserEnv;
29
+ }
30
+ };
31
+
32
+ // Initialize immediately
33
+ dotenvBrowser.init();
34
+ var _default = exports.default = dotenvBrowser;
35
+ //# sourceMappingURL=dotenv-browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotenv-browser.js","names":["browserEnv","dotenvBrowser","config","parsed","env","init","window","__ENV__","Object","assign","_default","exports","default"],"sources":["../../src/utils/dotenv-browser.js"],"sourcesContent":["/**\n * Browser-compatible dotenv replacement\n * Provides a no-op implementation of dotenv for browser environments\n */\n\n// Create browser-safe \"process.env\" equivalent\nconst browserEnv = {};\n\n// Create a browser-safe version of the dotenv module\nconst dotenvBrowser = {\n // No-op config function that returns an empty object in browser context\n config: () => ({ parsed: {} }),\n \n // Provide access to our browser environment variables\n env: browserEnv,\n \n // Add any variables from window.__ENV__ if it exists (useful for SSR)\n init: () => {\n if (typeof window !== 'undefined' && window.__ENV__) {\n Object.assign(browserEnv, window.__ENV__);\n }\n return browserEnv;\n }\n};\n\n// Initialize immediately\ndotenvBrowser.init();\n\nexport default dotenvBrowser;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAEA;AACA,MAAMA,UAAU,GAAG,CAAC,CAAC;;AAErB;AACA,MAAMC,aAAa,GAAG;EACpB;EACAC,MAAM,EAAEA,CAAA,MAAO;IAAEC,MAAM,EAAE,CAAC;EAAE,CAAC,CAAC;EAE9B;EACAC,GAAG,EAAEJ,UAAU;EAEf;EACAK,IAAI,EAAEA,CAAA,KAAM;IACV,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,OAAO,EAAE;MACnDC,MAAM,CAACC,MAAM,CAACT,UAAU,EAAEM,MAAM,CAACC,OAAO,CAAC;IAC3C;IACA,OAAOP,UAAU;EACnB;AACF,CAAC;;AAED;AACAC,aAAa,CAACI,IAAI,CAAC,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAENX,aAAa","ignoreList":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setGlobalProperty = exports.isServiceWorker = exports.isNode = exports.isBrowser = exports.getTextEncoder = exports.getGlobalScope = exports.getGlobalProperty = void 0;
7
+ /**
8
+ * Environment detection utility for cross-environment compatibility
9
+ */
10
+
11
+ // Check if running in a browser environment
12
+ const isBrowser = exports.isBrowser = typeof window !== 'undefined';
13
+
14
+ // Check if running in a Node.js environment
15
+ const isNode = exports.isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
16
+
17
+ // Check for service worker environment
18
+ const isServiceWorker = exports.isServiceWorker = typeof self === 'object' && self.constructor && self.constructor.name === 'ServiceWorkerGlobalScope';
19
+
20
+ /**
21
+ * Get a safe reference to global scope that works across environments
22
+ * @returns The global scope object (window, global, self)
23
+ */
24
+ const getGlobalScope = () => {
25
+ if (typeof window !== 'undefined') return window;
26
+ if (typeof global !== 'undefined') return global;
27
+ if (typeof self !== 'undefined') return self;
28
+ return {};
29
+ };
30
+
31
+ /**
32
+ * Safely access a property on the global scope
33
+ * @param {string} propertyName - The name of the property to access
34
+ * @returns The property value or undefined if not available
35
+ */
36
+ exports.getGlobalScope = getGlobalScope;
37
+ const getGlobalProperty = propertyName => {
38
+ const globalScope = getGlobalScope();
39
+ return globalScope[propertyName];
40
+ };
41
+
42
+ /**
43
+ * Safely set a property on the global scope
44
+ * @param {string} propertyName - The name of the property to set
45
+ * @param {any} value - The value to set
46
+ */
47
+ exports.getGlobalProperty = getGlobalProperty;
48
+ const setGlobalProperty = (propertyName, value) => {
49
+ const globalScope = getGlobalScope();
50
+ globalScope[propertyName] = value;
51
+ };
52
+
53
+ /**
54
+ * Get an environment-appropriate text encoder
55
+ * @returns A TextEncoder instance or polyfill
56
+ */
57
+ exports.setGlobalProperty = setGlobalProperty;
58
+ const getTextEncoder = () => {
59
+ // Browser environment
60
+ if (typeof window !== 'undefined' && window.TextEncoder) {
61
+ return new window.TextEncoder();
62
+ }
63
+
64
+ // Node.js environment
65
+ if (typeof TextEncoder !== 'undefined') {
66
+ return new TextEncoder();
67
+ }
68
+
69
+ // Fallback implementation
70
+ return {
71
+ encode: str => {
72
+ const utf8 = [];
73
+ for (let i = 0; i < str.length; i++) {
74
+ let charCode = str.charCodeAt(i);
75
+ if (charCode < 0x80) {
76
+ utf8.push(charCode);
77
+ } else if (charCode < 0x800) {
78
+ utf8.push(0xc0 | charCode >> 6, 0x80 | charCode & 0x3f);
79
+ } else if (charCode < 0xd800 || charCode >= 0xe000) {
80
+ utf8.push(0xe0 | charCode >> 12, 0x80 | charCode >> 6 & 0x3f, 0x80 | charCode & 0x3f);
81
+ } else {
82
+ // Handle surrogate pairs
83
+ i++;
84
+ charCode = 0x10000 + ((charCode & 0x3ff) << 10 | str.charCodeAt(i) & 0x3ff);
85
+ utf8.push(0xf0 | charCode >> 18, 0x80 | charCode >> 12 & 0x3f, 0x80 | charCode >> 6 & 0x3f, 0x80 | charCode & 0x3f);
86
+ }
87
+ }
88
+ return new Uint8Array(utf8);
89
+ }
90
+ };
91
+ };
92
+ exports.getTextEncoder = getTextEncoder;
93
+ //# sourceMappingURL=environmentDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environmentDetector.js","names":["isBrowser","exports","window","isNode","process","versions","node","isServiceWorker","self","constructor","name","getGlobalScope","global","getGlobalProperty","propertyName","globalScope","setGlobalProperty","value","getTextEncoder","TextEncoder","encode","str","utf8","i","length","charCode","charCodeAt","push","Uint8Array"],"sources":["../../src/utils/environmentDetector.js"],"sourcesContent":["/**\n * Environment detection utility for cross-environment compatibility\n */\n\n// Check if running in a browser environment\nexport const isBrowser = typeof window !== 'undefined';\n\n// Check if running in a Node.js environment\nexport const isNode = typeof process !== 'undefined' && \n process.versions != null && \n process.versions.node != null;\n\n// Check for service worker environment\nexport const isServiceWorker = typeof self === 'object' && \n self.constructor && \n self.constructor.name === 'ServiceWorkerGlobalScope';\n\n/**\n * Get a safe reference to global scope that works across environments\n * @returns The global scope object (window, global, self)\n */\nexport const getGlobalScope = () => {\n if (typeof window !== 'undefined') return window;\n if (typeof global !== 'undefined') return global;\n if (typeof self !== 'undefined') return self;\n return {};\n};\n\n/**\n * Safely access a property on the global scope\n * @param {string} propertyName - The name of the property to access\n * @returns The property value or undefined if not available\n */\nexport const getGlobalProperty = (propertyName) => {\n const globalScope = getGlobalScope();\n return globalScope[propertyName];\n};\n\n/**\n * Safely set a property on the global scope\n * @param {string} propertyName - The name of the property to set\n * @param {any} value - The value to set\n */\nexport const setGlobalProperty = (propertyName, value) => {\n const globalScope = getGlobalScope();\n globalScope[propertyName] = value;\n};\n\n/**\n * Get an environment-appropriate text encoder\n * @returns A TextEncoder instance or polyfill\n */\nexport const getTextEncoder = () => {\n // Browser environment\n if (typeof window !== 'undefined' && window.TextEncoder) {\n return new window.TextEncoder();\n }\n \n // Node.js environment\n if (typeof TextEncoder !== 'undefined') {\n return new TextEncoder();\n }\n \n // Fallback implementation\n return {\n encode: (str) => {\n const utf8 = [];\n for (let i = 0; i < str.length; i++) {\n let charCode = str.charCodeAt(i);\n if (charCode < 0x80) {\n utf8.push(charCode);\n } else if (charCode < 0x800) {\n utf8.push(0xc0 | (charCode >> 6), \n 0x80 | (charCode & 0x3f));\n } else if (charCode < 0xd800 || charCode >= 0xe000) {\n utf8.push(0xe0 | (charCode >> 12), \n 0x80 | ((charCode >> 6) & 0x3f), \n 0x80 | (charCode & 0x3f));\n } else {\n // Handle surrogate pairs\n i++;\n charCode = 0x10000 + (((charCode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));\n utf8.push(0xf0 | (charCode >> 18), \n 0x80 | ((charCode >> 12) & 0x3f), \n 0x80 | ((charCode >> 6) & 0x3f), \n 0x80 | (charCode & 0x3f));\n }\n }\n return new Uint8Array(utf8);\n }\n };\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAEA;AACO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,OAAOE,MAAM,KAAK,WAAW;;AAEtD;AACO,MAAMC,MAAM,GAAAF,OAAA,CAAAE,MAAA,GAAG,OAAOC,OAAO,KAAK,WAAW,IAC/BA,OAAO,CAACC,QAAQ,IAAI,IAAI,IACxBD,OAAO,CAACC,QAAQ,CAACC,IAAI,IAAI,IAAI;;AAElD;AACO,MAAMC,eAAe,GAAAN,OAAA,CAAAM,eAAA,GAAG,OAAOC,IAAI,KAAK,QAAQ,IACzBA,IAAI,CAACC,WAAW,IAChBD,IAAI,CAACC,WAAW,CAACC,IAAI,KAAK,0BAA0B;;AAElF;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,IAAI,OAAOT,MAAM,KAAK,WAAW,EAAE,OAAOA,MAAM;EAChD,IAAI,OAAOU,MAAM,KAAK,WAAW,EAAE,OAAOA,MAAM;EAChD,IAAI,OAAOJ,IAAI,KAAK,WAAW,EAAE,OAAOA,IAAI;EAC5C,OAAO,CAAC,CAAC;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAP,OAAA,CAAAU,c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AG,MAAM,IAAIA,QAAQ,IAAI,MAAM,EAAE;UAClDH,IAAI,CAACK,IAAI,CAAC,IAAI,GAAIF,QAAQ,IAAI,EAAG,EACxB,IAAI,GAAKA,QAAQ,IAAI,CAAC,GAAI,IAAK,EAC/B,IAAI,GAAIA,QAAQ,GAAG,IAAK,CAAC;QACpC,CAAC,MAAM;UACL;UACAF,CAAC,EAAE;UACHE,QAAQ,GAAG,OAAO,IAAK,CAACA,QAAQ,GAAG,KAAK,KAAK,EAAE,GAAKJ,GAAG,CAACK,UAAU,CAACH,CAAC,CAAC,GAAG,KAAM,CAAC;UAC/ED,IAAI,CAACK,IAAI,CAAC,IAAI,GAAIF,QAAQ,IAAI,EAAG,EACxB,IAAI,GAAKA,QAAQ,IAAI,EAAE,GAAI,IAAK,EAChC,IAAI,GAAKA,QAAQ,IAAI,CAAC,GAAI,IAAK,EAC/B,IAAI,GAAIA,QAAQ,GAAG,IAAK,CAAC;QACpC;MACF;MACA,OAAO,IAAIG,UAAU,CAACN,IAAI,CAAC;IAC7B;EACF,CAAC;AACH,CAAC;AAACrB,OAAA,CAAAiB,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.writeToJsonl = void 0;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _path = _interopRequireDefault(require("path"));
10
+ const writeToJsonl = async logEntry => {
11
+ try {
12
+ const response = await fetch('/api/write-log', {
13
+ method: 'POST',
14
+ headers: {
15
+ 'Content-Type': 'application/json'
16
+ },
17
+ body: JSON.stringify(logEntry)
18
+ });
19
+ if (!response.ok) {
20
+ console.error('Failed to write log');
21
+ }
22
+ } catch (error) {
23
+ console.error('Error writing log:', error);
24
+ }
25
+ };
26
+ exports.writeToJsonl = writeToJsonl;
27
+ //# sourceMappingURL=logWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logWriter.js","names":["_fs","_interopRequireDefault","require","_path","writeToJsonl","logEntry","response","fetch","method","headers","body","JSON","stringify","ok","console","error","exports"],"sources":["../../src/utils/logWriter.js"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nexport const writeToJsonl = async (logEntry) => {\n try {\n const response = await fetch('/api/write-log', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(logEntry)\n });\n \n if (!response.ok) {\n console.error('Failed to write log');\n }\n } catch (error) {\n console.error('Error writing log:', error);\n }\n};"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEO,MAAME,YAAY,GAAG,MAAOC,QAAQ,IAAK;EAC5C,IAAI;IACA,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAAC,gBAAgB,EAAE;MAC3CC,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACL,cAAc,EAAE;MACpB,CAAC;MACDC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACP,QAAQ;IACjC,CAAC,CAAC;IAEF,IAAI,CAACC,QAAQ,CAACO,EAAE,EAAE;MACdC,OAAO,CAACC,KAAK,CAAC,qBAAqB,CAAC;IACxC;EACJ,CAAC,CAAC,OAAOA,KAAK,EAAE;IACZD,OAAO,CAACC,KAAK,CAAC,oBAAoB,EAAEA,KAAK,CAAC;EAC9C;AACJ,CAAC;AAACC,OAAA,CAAAZ,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.checkApiEndpoints = checkApiEndpoints;
7
+ exports.checkServiceWorkerVersion = checkServiceWorkerVersion;
8
+ exports.initServiceWorkerManager = initServiceWorkerManager;
9
+ exports.updateServiceWorker = updateServiceWorker;
10
+ /**
11
+ * Service Worker Manager
12
+ *
13
+ * Utility functions to manage service worker registration and updates
14
+ * Helps ensure the service worker is up-to-date with the latest API endpoints
15
+ */
16
+
17
+ // Force update any existing service worker
18
+ async function updateServiceWorker() {
19
+ if ('serviceWorker' in navigator) {
20
+ try {
21
+ // Get all service worker registrations
22
+ const registrations = await navigator.serviceWorker.getRegistrations();
23
+
24
+ // Unregister all existing service workers
25
+ for (const registration of registrations) {
26
+ console.log('[ServiceWorkerManager] Unregistering service worker:', registration.scope);
27
+ await registration.unregister();
28
+ }
29
+
30
+ // Register the new service worker
31
+ const newRegistration = await navigator.serviceWorker.register('/custom-sw.js');
32
+ console.log('[ServiceWorkerManager] New service worker registered:', newRegistration);
33
+ return true;
34
+ } catch (error) {
35
+ console.error('[ServiceWorkerManager] Error updating service worker:', error);
36
+ return false;
37
+ }
38
+ }
39
+ return false;
40
+ }
41
+
42
+ // Check if the service worker needs to be updated by comparing version
43
+ async function checkServiceWorkerVersion() {
44
+ if ('serviceWorker' in navigator) {
45
+ try {
46
+ // Try to communicate with the service worker to get its version
47
+ const registration = await navigator.serviceWorker.ready;
48
+
49
+ // If there's no controller, we need to wait for the service worker to activate
50
+ if (!navigator.serviceWorker.controller) {
51
+ console.log('[ServiceWorkerManager] No active service worker controller yet');
52
+ return false;
53
+ }
54
+
55
+ // Create a promise that will resolve when the service worker responds
56
+ const versionPromise = new Promise(resolve => {
57
+ const messageChannel = new MessageChannel();
58
+
59
+ // Set up the response handler
60
+ messageChannel.port1.onmessage = event => {
61
+ if (event.data && event.data.type === 'VERSION') {
62
+ resolve(event.data.version);
63
+ } else {
64
+ resolve(null);
65
+ }
66
+ };
67
+
68
+ // Send the message
69
+ navigator.serviceWorker.controller.postMessage({
70
+ type: 'GET_VERSION'
71
+ }, [messageChannel.port2]);
72
+
73
+ // Set a timeout in case the service worker doesn't respond
74
+ setTimeout(() => resolve(null), 1000);
75
+ });
76
+ const swVersion = await versionPromise;
77
+ const currentVersion = '2'; // Update this when changing the service worker
78
+
79
+ console.log('[ServiceWorkerManager] Service Worker Version:', swVersion, 'Current Version:', currentVersion);
80
+ if (swVersion !== currentVersion) {
81
+ console.log('[ServiceWorkerManager] Service worker needs update');
82
+ return true;
83
+ }
84
+ return false;
85
+ } catch (error) {
86
+ console.error('[ServiceWorkerManager] Error checking service worker version:', error);
87
+ return true; // If we can't check, assume we need to update
88
+ }
89
+ }
90
+ return false;
91
+ }
92
+
93
+ // Initialize the service worker manager
94
+ async function initServiceWorkerManager() {
95
+ const needsUpdate = await checkServiceWorkerVersion();
96
+ if (needsUpdate) {
97
+ console.log('[ServiceWorkerManager] Updating service worker...');
98
+ return updateServiceWorker();
99
+ }
100
+ console.log('[ServiceWorkerManager] Service worker is up-to-date');
101
+ return false;
102
+ }
103
+
104
+ // Make sure all API requests are using the unified endpoints
105
+ function checkApiEndpoints() {
106
+ const deprecatedEndpoints = ['/api/store-card', '/api/update-card', '/api/get-card', '/api/store-clm', '/api/update-clm', '/api/submit'];
107
+
108
+ // Check for any code still using deprecated endpoints
109
+ window.addEventListener('fetch', event => {
110
+ const url = new URL(event.request.url);
111
+ if (deprecatedEndpoints.includes(url.pathname)) {
112
+ console.warn(`[API Deprecation Warning] Detected use of deprecated API endpoint: ${url.pathname}\n` + `Please update to use the unified Card Collection API: /api/card-collection`);
113
+ }
114
+ }, {
115
+ passive: true
116
+ });
117
+ }
118
+ //# sourceMappingURL=serviceWorkerManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceWorkerManager.js","names":["updateServiceWorker","navigator","registrations","serviceWorker","getRegistrations","registration","console","log","scope","unregister","newRegistration","register","error","checkServiceWorkerVersion","ready","controller","versionPromise","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","data","type","version","postMessage","port2","setTimeout","swVersion","currentVersion","initServiceWorkerManager","needsUpdate","checkApiEndpoints","deprecatedEndpoints","window","addEventListener","url","URL","request","includes","pathname","warn","passive"],"sources":["../../src/utils/serviceWorkerManager.js"],"sourcesContent":["/**\n * Service Worker Manager\n * \n * Utility functions to manage service worker registration and updates\n * Helps ensure the service worker is up-to-date with the latest API endpoints\n */\n\n// Force update any existing service worker\nexport async function updateServiceWorker() {\n if ('serviceWorker' in navigator) {\n try {\n // Get all service worker registrations\n const registrations = await navigator.serviceWorker.getRegistrations();\n \n // Unregister all existing service workers\n for (const registration of registrations) {\n console.log('[ServiceWorkerManager] Unregistering service worker:', registration.scope);\n await registration.unregister();\n }\n \n // Register the new service worker\n const newRegistration = await navigator.serviceWorker.register('/custom-sw.js');\n console.log('[ServiceWorkerManager] New service worker registered:', newRegistration);\n \n return true;\n } catch (error) {\n console.error('[ServiceWorkerManager] Error updating service worker:', error);\n return false;\n }\n }\n return false;\n}\n\n// Check if the service worker needs to be updated by comparing version\nexport async function checkServiceWorkerVersion() {\n if ('serviceWorker' in navigator) {\n try {\n // Try to communicate with the service worker to get its version\n const registration = await navigator.serviceWorker.ready;\n \n // If there's no controller, we need to wait for the service worker to activate\n if (!navigator.serviceWorker.controller) {\n console.log('[ServiceWorkerManager] No active service worker controller yet');\n return false;\n }\n \n // Create a promise that will resolve when the service worker responds\n const versionPromise = new Promise((resolve) => {\n const messageChannel = new MessageChannel();\n \n // Set up the response handler\n messageChannel.port1.onmessage = (event) => {\n if (event.data && event.data.type === 'VERSION') {\n resolve(event.data.version);\n } else {\n resolve(null);\n }\n };\n \n // Send the message\n navigator.serviceWorker.controller.postMessage({\n type: 'GET_VERSION'\n }, [messageChannel.port2]);\n \n // Set a timeout in case the service worker doesn't respond\n setTimeout(() => resolve(null), 1000);\n });\n \n const swVersion = await versionPromise;\n const currentVersion = '2'; // Update this when changing the service worker\n\n console.log('[ServiceWorkerManager] Service Worker Version:', swVersion, 'Current Version:', currentVersion);\n \n if (swVersion !== currentVersion) {\n console.log('[ServiceWorkerManager] Service worker needs update');\n return true;\n }\n \n return false;\n } catch (error) {\n console.error('[ServiceWorkerManager] Error checking service worker version:', error);\n return true; // If we can't check, assume we need to update\n }\n }\n return false;\n}\n\n// Initialize the service worker manager\nexport async function initServiceWorkerManager() {\n const needsUpdate = await checkServiceWorkerVersion();\n \n if (needsUpdate) {\n console.log('[ServiceWorkerManager] Updating service worker...');\n return updateServiceWorker();\n }\n \n console.log('[ServiceWorkerManager] Service worker is up-to-date');\n return false;\n}\n\n// Make sure all API requests are using the unified endpoints\nexport function checkApiEndpoints() {\n const deprecatedEndpoints = [\n '/api/store-card',\n '/api/update-card',\n '/api/get-card',\n '/api/store-clm',\n '/api/update-clm',\n '/api/submit'\n ];\n \n // Check for any code still using deprecated endpoints\n window.addEventListener('fetch', (event) => {\n const url = new URL(event.request.url);\n if (deprecatedEndpoints.includes(url.pathname)) {\n console.warn(\n `[API Deprecation Warning] Detected use of deprecated API endpoint: ${url.pathname}\\n` +\n `Please update to use the unified Card Collection API: /api/card-collection`\n );\n }\n }, { passive: true });\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACO,eAAeA,mBAAmBA,CAAA,EAAG;EAC1C,IAAI,eAAe,IAAIC,SAAS,EAAE;IAChC,IAAI;MACF;MACA,MAAMC,aAAa,GAAG,MAAMD,SAAS,CAACE,aAAa,CAACC,gBAAgB,CAAC,CAAC;;MAEtE;MACA,KAAK,MAAMC,YAAY,IAAIH,aAAa,EAAE;QACxCI,OAAO,CAACC,GAAG,CAAC,sDAAsD,EAAEF,YAAY,CAACG,KAAK,CAAC;QACvF,MAAMH,YAAY,CAACI,UAAU,CAAC,CAAC;MACjC;;MAEA;MACA,MAAMC,eAAe,GAAG,MAAMT,SAAS,CAACE,aAAa,CAACQ,QAAQ,CAAC,eAAe,CAAC;MAC/EL,OAAO,CAACC,GAAG,CAAC,uDAAuD,EAAEG,eAAe,CAAC;MAErF,OAAO,IAAI;IACb,CAAC,CAAC,OAAOE,KAAK,EAAE;MACdN,OAAO,CAACM,KAAK,CAAC,uDAAuD,EAAEA,KAAK,CAAC;MAC7E,OAAO,KAAK;IACd;EACF;EACA,OAAO,K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AAOK,KAAK,EAAE;MACdN,OAAO,CAACM,KAAK,CAAC,+DAA+D,EAAEA,KAAK,CAAC;MACrF,OAAO,IAAI,CAAC,CAAC;IACf;EACF;EACA,OAAO,KAAK;AACd;;AAEA;AACO,eAAeoB,wBAAwBA,CAAA,EAAG;EAC/C,MAAMC,WAAW,GAAG,MAAMpB,yBAAyB,CAAC,CAAC;EAErD,IAAIoB,WAAW,EAAE;IACf3B,OAAO,CAACC,GAAG,CAAC,mDAAmD,CAAC;IAChE,OAAOP,mBAAmB,CAAC,CAAC;EAC9B;EAEAM,OAAO,CAACC,GAAG,CAAC,qDAAqD,CAAC;EAClE,OAAO,KAAK;AACd;;AAEA;AACO,SAAS2B,iBAAiBA,CAAA,EAAG;EAClC,MAAMC,mBAAmB,GAAG,CAC1B,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,CACd;;EAED;EACAC,MAAM,CAACC,gBAAgB,CAAC,OAAO,EAAGd,KAAK,IAAK;IAC1C,MAAMe,GAAG,GAAG,IAAIC,GAAG,CAAChB,KAAK,CAACiB,OAAO,CAACF,GAAG,CAAC;IACtC,IAAIH,mBAAmB,CAACM,QAAQ,CAACH,GAAG,CAACI,QAAQ,CAAC,EAAE;MAC9CpC,OAAO,CAACqC,IAAI,CACV,sEAAsEL,GAAG,CAACI,QAAQ,IAAI,GACtF,4EACF,CAAC;IACH;EACF,CAAC,EAAE;IAAEE,OAAO,EAAE;EAAK,CAAC,CAAC;AACvB","ignoreList":[]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _content_type_detector = _interopRequireDefault(require("../content/model/content_type_detector.js"));
5
+ // Test script for content type detection
6
+
7
+ // Create test examples
8
+ const jsonBufferExample = {
9
+ "type": "Buffer",
10
+ "data": [123, 10, 32, 32, 34, 110, 97, 109, 101, 34, 58, 32, 34, 84, 101, 115, 116, 32, 79, 98, 106, 101, 99, 116, 34, 44, 10, 32, 32, 34, 112, 114, 111, 112, 101, 114, 116, 105, 101, 115, 34, 58, 32, 123, 10, 32, 32, 32, 32, 34, 99, 111, 108, 111, 114, 34, 58, 32, 34, 98, 108, 117, 101, 34, 44, 10, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 58, 32, 49, 48, 48, 44, 10, 32, 32, 32, 32, 34, 110, 101, 115, 116, 101, 100, 34, 58, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 97, 114, 114, 97, 121, 34, 58, 32, 91, 10, 32, 32, 32, 32, 32, 32, 32, 32, 49, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 50, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 51, 10, 32, 32, 32, 32, 32, 32, 93, 44, 10, 32, 32, 32, 32, 32, 32, 34, 98, 111, 111, 108, 101, 97, 110, 34, 58, 32, 116, 114, 117, 101, 10, 32, 32, 32, 32, 125, 10, 32, 32, 125, 10, 125]
11
+ };
12
+ const csvBufferExample = {
13
+ "type": "Buffer",
14
+ "data": [105, 100, 44, 110, 97, 109, 101, 44, 118, 97, 108, 117, 101, 10, 49, 44, 73, 116, 101, 109, 32, 49, 44, 49, 48, 48, 10, 50, 44, 73, 116, 101, 109, 32, 50, 44, 50, 48, 48, 10, 51, 44, 73, 116, 101, 109, 32, 51, 44, 51, 48, 48, 10]
15
+ };
16
+
17
+ // Plain text example
18
+ const txtBufferExample = {
19
+ "type": "Buffer",
20
+ "data": [84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 115, 105, 109, 112, 108, 101, 32, 112, 108, 97, 105, 110, 32, 116, 101, 120, 116, 32, 102, 105, 108, 101, 46, 10, 10, 73, 116, 32, 100, 111, 101, 115, 110, 39, 116, 32, 104, 97, 118, 101, 32, 97, 110, 121, 32, 115, 112, 101, 99, 105, 97, 108, 32, 102, 111, 114, 109, 97, 116, 116, 105, 110, 103, 32, 111, 114, 32, 115, 116, 114, 117, 99, 116, 117, 114, 101, 46, 10, 10, 74, 117, 115, 116, 32, 112, 108, 97, 105, 110, 32, 116, 101, 120, 116, 46]
21
+ };
22
+
23
+ // Example MOV file header bytes
24
+ const movFileHeader = new Uint8Array([0x00, 0x00, 0x00, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
25
+
26
+ // Mock MOV file buffer
27
+ const movBufferExample = {
28
+ type: "Buffer",
29
+ data: Array.from(movFileHeader)
30
+ };
31
+
32
+ // Function to decode buffer content to readable format
33
+ function decodeBuffer(bufferJson) {
34
+ if (typeof bufferJson === 'object' && bufferJson.type === 'Buffer' && Array.isArray(bufferJson.data)) {
35
+ const array = new Uint8Array(bufferJson.data);
36
+ return new TextDecoder().decode(array);
37
+ }
38
+ return "Not a buffer format";
39
+ }
40
+
41
+ // Test detection without our enhancement
42
+ function runTests() {
43
+ console.log("====== TEST RESULTS ======");
44
+
45
+ // 1. Test JSON Buffer content
46
+ console.log("\n1. Testing JSON Buffer Example:");
47
+ console.log("Decoded content:", decodeBuffer(jsonBufferExample));
48
+ const jsonResult = _content_type_detector.default.detectContentType(jsonBufferExample);
49
+ console.log("Detection result:", jsonResult);
50
+
51
+ // 2. Test CSV Buffer content
52
+ console.log("\n2. Testing CSV Buffer Example:");
53
+ console.log("Decoded content:", decodeBuffer(csvBufferExample));
54
+ const csvResult = _content_type_detector.default.detectContentType(csvBufferExample);
55
+ console.log("Detection result:", csvResult);
56
+
57
+ // 3. Test TXT Buffer content
58
+ console.log("\n3. Testing TXT Buffer Example:");
59
+ console.log("Decoded content:", decodeBuffer(txtBufferExample));
60
+ const txtResult = _content_type_detector.default.detectContentType(txtBufferExample);
61
+ console.log("Detection result:", txtResult);
62
+
63
+ // 4. Test MOV file detection
64
+ console.log("\n4. Testing MOV Buffer Example:");
65
+ console.log("Cannot show decoded binary content");
66
+ const movResult = _content_type_detector.default.detectContentType(movBufferExample);
67
+ console.log("Detection result:", movResult);
68
+
69
+ // Summary
70
+ console.log("\n====== SUMMARY ======");
71
+ console.log("JSON detected as:", jsonResult.mimeType, "(" + jsonResult.extension + ")");
72
+ console.log("CSV detected as:", csvResult.mimeType, "(" + csvResult.extension + ")");
73
+ console.log("TXT detected as:", txtResult.mimeType, "(" + txtResult.extension + ")");
74
+ console.log("MOV detected as:", movResult.mimeType, "(" + movResult.extension + ")");
75
+ }
76
+ runTests();
77
+
78
+ // Run this with Node.js: node src/utils/test-content-detection.js
79
+ //# sourceMappingURL=test-content-detection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-content-detection.js","names":["_content_type_detector","_interopRequireDefault","require","jsonBufferExample","csvBufferExample","txtBufferExample","movFileHeader","Uint8Array","movBufferExample","type","data","Array","from","decodeBuffer","bufferJson","isArray","array","TextDecoder","decode","runTests","console","log","jsonResult","ContentTypeInterpreter","detectContentType","csvResult","txtResult","movResult","mimeType","extension"],"sources":["../../src/utils/test-content-detection.js"],"sourcesContent":["// Test script for content type detection\nimport ContentTypeInterpreter from '../content/model/content_type_detector.js';\n\n// Create test examples\nconst jsonBufferExample = {\"type\":\"Buffer\",\"data\":[123,10,32,32,34,110,97,109,101,34,58,32,34,84,101,115,116,32,79,98,106,101,99,116,34,44,10,32,32,34,112,114,111,112,101,114,116,105,101,115,34,58,32,123,10,32,32,32,32,34,99,111,108,111,114,34,58,32,34,98,108,117,101,34,44,10,32,32,32,32,34,115,105,122,101,34,58,32,49,48,48,44,10,32,32,32,32,34,110,101,115,116,101,100,34,58,32,123,10,32,32,32,32,32,32,34,97,114,114,97,121,34,58,32,91,10,32,32,32,32,32,32,32,32,49,44,10,32,32,32,32,32,32,32,32,50,44,10,32,32,32,32,32,32,32,32,51,10,32,32,32,32,32,32,93,44,10,32,32,32,32,32,32,34,98,111,111,108,101,97,110,34,58,32,116,114,117,101,10,32,32,32,32,125,10,32,32,125,10,125]}; \n\nconst csvBufferExample = {\"type\":\"Buffer\",\"data\":[105,100,44,110,97,109,101,44,118,97,108,117,101,10,49,44,73,116,101,109,32,49,44,49,48,48,10,50,44,73,116,101,109,32,50,44,50,48,48,10,51,44,73,116,101,109,32,51,44,51,48,48,10]};\n\n// Plain text example\nconst txtBufferExample = {\"type\":\"Buffer\",\"data\":[84,104,105,115,32,105,115,32,97,32,115,105,109,112,108,101,32,112,108,97,105,110,32,116,101,120,116,32,102,105,108,101,46,10,10,73,116,32,100,111,101,115,110,39,116,32,104,97,118,101,32,97,110,121,32,115,112,101,99,105,97,108,32,102,111,114,109,97,116,116,105,110,103,32,111,114,32,115,116,114,117,99,116,117,114,101,46,10,10,74,117,115,116,32,112,108,97,105,110,32,116,101,120,116,46]};\n\n// Example MOV file header bytes\nconst movFileHeader = new Uint8Array([\n 0x00, 0x00, 0x00, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20, \n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n]);\n\n// Mock MOV file buffer\nconst movBufferExample = {\n type: \"Buffer\",\n data: Array.from(movFileHeader)\n};\n\n// Function to decode buffer content to readable format\nfunction decodeBuffer(bufferJson) {\n if (typeof bufferJson === 'object' && bufferJson.type === 'Buffer' && Array.isArray(bufferJson.data)) {\n const array = new Uint8Array(bufferJson.data);\n return new TextDecoder().decode(array);\n }\n return \"Not a buffer format\";\n}\n\n// Test detection without our enhancement\nfunction runTests() {\n console.log(\"====== TEST RESULTS ======\");\n \n // 1. Test JSON Buffer content\n console.log(\"\\n1. Testing JSON Buffer Example:\");\n console.log(\"Decoded content:\", decodeBuffer(jsonBufferExample));\n const jsonResult = ContentTypeInterpreter.detectContentType(jsonBufferExample);\n console.log(\"Detection result:\", jsonResult);\n \n // 2. Test CSV Buffer content\n console.log(\"\\n2. Testing CSV Buffer Example:\");\n console.log(\"Decoded content:\", decodeBuffer(csvBufferExample));\n const csvResult = ContentTypeInterpreter.detectContentType(csvBufferExample);\n console.log(\"Detection result:\", csvResult);\n \n // 3. Test TXT Buffer content\n console.log(\"\\n3. Testing TXT Buffer Example:\");\n console.log(\"Decoded content:\", decodeBuffer(txtBufferExample));\n const txtResult = ContentTypeInterpreter.detectContentType(txtBufferExample);\n console.log(\"Detection result:\", txtResult);\n \n // 4. Test MOV file detection\n console.log(\"\\n4. Testing MOV Buffer Example:\");\n console.log(\"Cannot show decoded binary content\");\n const movResult = ContentTypeInterpreter.detectContentType(movBufferExample);\n console.log(\"Detection result:\", movResult);\n \n // Summary\n console.log(\"\\n====== SUMMARY ======\");\n console.log(\"JSON detected as:\", jsonResult.mimeType, \"(\"+jsonResult.extension+\")\");\n console.log(\"CSV detected as:\", csvResult.mimeType, \"(\"+csvResult.extension+\")\");\n console.log(\"TXT detected as:\", txtResult.mimeType, \"(\"+txtResult.extension+\")\");\n console.log(\"MOV detected as:\", movResult.mimeType, \"(\"+movResult.extension+\")\");\n}\n\nrunTests();\n\n// Run this with Node.js: node src/utils/test-content-detection.js\n"],"mappings":";;;AACA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AADA;;AAGA;AACA,MAAMC,iBAAiB,GAAG;EAAC,MAAM,EAAC,QAAQ;EAAC,MAAM,EAAC,CAAC,GAAG,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,GAAG,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,GAAG,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,EAAE,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,G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