mcard-js 2.1.39 → 2.1.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.
Files changed (40) hide show
  1. package/dist/AbstractSqlEngine-BSfp8S_Y.d.cts +451 -0
  2. package/dist/AbstractSqlEngine-BSfp8S_Y.d.ts +451 -0
  3. package/dist/CardCollection-MXTUJV4J.js +9 -0
  4. package/dist/EventProducer-AWD6YMZR.js +47 -0
  5. package/dist/Handle-3N4QOA3U.js +13 -0
  6. package/dist/IndexedDBEngine-2G5KCISA.js +11 -0
  7. package/dist/LLMRuntime-LBWUJ7ON.js +16 -0
  8. package/dist/LambdaRuntime-B6D6IQKZ.js +18 -0
  9. package/dist/Loader-3LSJXJQG.js +11 -0
  10. package/dist/MCard-H56VOJLR.js +8 -0
  11. package/dist/NetworkRuntime-IAFHPQSX.js +1570 -0
  12. package/dist/OllamaProvider-QPX2JXL2.js +8 -0
  13. package/dist/chunk-2R4ESMZB.js +110 -0
  14. package/dist/chunk-3EIBJPNF.js +17 -0
  15. package/dist/chunk-3LPY36OG.js +355 -0
  16. package/dist/chunk-3MMMJ7NH.js +1068 -0
  17. package/dist/chunk-42VF42KH.js +273 -0
  18. package/dist/chunk-4PDYHPR6.js +297 -0
  19. package/dist/chunk-ADV52544.js +95 -0
  20. package/dist/chunk-FIE4LAJG.js +215 -0
  21. package/dist/chunk-PNKVD2UK.js +26 -0
  22. package/dist/chunk-RSTKX7WM.js +907 -0
  23. package/dist/chunk-VXV35I5J.js +2315 -0
  24. package/dist/index.browser.cjs +375 -276
  25. package/dist/index.browser.d.cts +4 -4
  26. package/dist/index.browser.d.ts +4 -4
  27. package/dist/index.browser.js +18 -13
  28. package/dist/index.cjs +382 -453
  29. package/dist/index.d.cts +2 -2
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +26 -21
  32. package/dist/storage/SqliteNodeEngine.cjs +395 -270
  33. package/dist/storage/SqliteNodeEngine.d.cts +9 -94
  34. package/dist/storage/SqliteNodeEngine.d.ts +9 -94
  35. package/dist/storage/SqliteNodeEngine.js +6 -5
  36. package/dist/storage/SqliteWasmEngine.cjs +382 -252
  37. package/dist/storage/SqliteWasmEngine.d.cts +8 -29
  38. package/dist/storage/SqliteWasmEngine.d.ts +8 -29
  39. package/dist/storage/SqliteWasmEngine.js +6 -5
  40. package/package.json +1 -1
@@ -0,0 +1,1068 @@
1
+ import {
2
+ GTime,
3
+ HashValidator
4
+ } from "./chunk-7NKII2JA.js";
5
+
6
+ // src/model/detectors/BinaryDetector.ts
7
+ var BinarySignatureDetector = class _BinarySignatureDetector {
8
+ contentTypeName = "binary";
9
+ // Signatures map: [Signature Bytes, Mime Type]
10
+ static SIGNATURES = [
11
+ [new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), "image/png"],
12
+ [new Uint8Array([255, 216, 255]), "image/jpeg"],
13
+ [new Uint8Array([71, 73, 70, 56, 55, 97]), "image/gif"],
14
+ // GIF87a
15
+ [new Uint8Array([71, 73, 70, 56, 57, 97]), "image/gif"],
16
+ // GIF89a
17
+ [new Uint8Array([66, 77]), "image/bmp"],
18
+ // BM
19
+ [new Uint8Array([0, 0, 1, 0]), "image/x-icon"],
20
+ [new Uint8Array([0, 0, 2, 0]), "image/x-icon"],
21
+ [new Uint8Array([37, 80, 68, 70]), "application/pdf"],
22
+ // %PDF
23
+ [new Uint8Array([80, 75, 3, 4]), "application/zip"],
24
+ // PK..
25
+ [new Uint8Array([31, 139, 8]), "application/gzip"],
26
+ [new Uint8Array([82, 97, 114, 33, 26, 7, 0]), "application/x-rar-compressed"],
27
+ [new Uint8Array([55, 122, 188, 175, 39, 28]), "application/x-7z-compressed"],
28
+ [new Uint8Array([83, 81, 76, 105, 116, 101, 32, 102, 111, 114, 109, 97, 116, 32, 51, 0]), "application/x-sqlite3"]
29
+ ];
30
+ // Extension-to-MIME mapping for binary types (used when byte detection fails)
31
+ static EXT_TO_MIME = {
32
+ // Video
33
+ ".mp4": "video/mp4",
34
+ ".webm": "video/webm",
35
+ ".avi": "video/x-msvideo",
36
+ ".mov": "video/quicktime",
37
+ ".mkv": "video/x-matroska",
38
+ ".wmv": "video/x-ms-wmv",
39
+ ".flv": "video/x-flv",
40
+ ".m4v": "video/x-m4v",
41
+ // Audio
42
+ ".mp3": "audio/mpeg",
43
+ ".ogg": "audio/ogg",
44
+ ".flac": "audio/flac",
45
+ ".aac": "audio/aac",
46
+ ".m4a": "audio/mp4",
47
+ ".wma": "audio/x-ms-wma",
48
+ // Images (backup for when signature detection fails)
49
+ ".png": "image/png",
50
+ ".jpg": "image/jpeg",
51
+ ".jpeg": "image/jpeg",
52
+ ".gif": "image/gif",
53
+ ".bmp": "image/bmp",
54
+ ".ico": "image/x-icon",
55
+ ".webp": "image/webp",
56
+ ".svg": "image/svg+xml",
57
+ // Documents
58
+ ".pdf": "application/pdf",
59
+ // Archives
60
+ ".zip": "application/zip",
61
+ ".gz": "application/gzip",
62
+ ".rar": "application/x-rar-compressed",
63
+ ".7z": "application/x-7z-compressed",
64
+ ".tar": "application/x-tar",
65
+ // Database
66
+ ".db": "application/x-sqlite3",
67
+ ".sqlite": "application/x-sqlite3",
68
+ ".sqlite3": "application/x-sqlite3",
69
+ // Fonts
70
+ ".woff": "font/woff",
71
+ ".woff2": "font/woff2",
72
+ ".ttf": "font/ttf",
73
+ ".otf": "font/otf",
74
+ ".eot": "application/vnd.ms-fontobject"
75
+ };
76
+ detect(contentSample, lines, firstLine, fileExtension) {
77
+ const mime = this.getMimeType(contentSample, lines, firstLine, fileExtension);
78
+ return mime && mime !== "application/octet-stream" ? 0.95 : 0;
79
+ }
80
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
81
+ const bytes = this.toBytes(contentSample);
82
+ const detected = this.detectFromBytes(bytes);
83
+ if (detected !== "application/octet-stream") {
84
+ return detected;
85
+ }
86
+ if (fileExtension) {
87
+ let ext = fileExtension.toLowerCase();
88
+ const lastDotIndex = ext.lastIndexOf(".");
89
+ if (lastDotIndex > -1) {
90
+ ext = ext.substring(lastDotIndex);
91
+ } else if (!ext.startsWith(".")) {
92
+ if (ext.includes("/") || ext.includes("\\")) {
93
+ return "application/octet-stream";
94
+ }
95
+ ext = "." + ext;
96
+ }
97
+ const extMime = _BinarySignatureDetector.EXT_TO_MIME[ext];
98
+ if (extMime) {
99
+ return extMime;
100
+ }
101
+ }
102
+ return "application/octet-stream";
103
+ }
104
+ /**
105
+ * Detect MIME type directly from bytes.
106
+ */
107
+ detectFromBytes(bytes) {
108
+ if (this.startsWith(bytes, new Uint8Array([82, 73, 70, 70]))) {
109
+ return this.detectRiffFormat(bytes);
110
+ }
111
+ for (const [sig, mime] of _BinarySignatureDetector.SIGNATURES) {
112
+ if (this.startsWith(bytes, sig)) {
113
+ if (mime === "application/zip") {
114
+ return this.detectZipType(bytes);
115
+ }
116
+ return mime;
117
+ }
118
+ }
119
+ return "application/octet-stream";
120
+ }
121
+ toBytes(content) {
122
+ if (content instanceof Uint8Array) return content;
123
+ return new TextEncoder().encode(content);
124
+ }
125
+ startsWith(data, prefix) {
126
+ if (data.length < prefix.length) return false;
127
+ for (let i = 0; i < prefix.length; i++) {
128
+ if (data[i] !== prefix[i]) return false;
129
+ }
130
+ return true;
131
+ }
132
+ detectRiffFormat(bytes) {
133
+ if (bytes.length < 12) return "application/octet-stream";
134
+ const format = new TextDecoder().decode(bytes.slice(8, 12));
135
+ if (format === "WAVE") return "audio/wav";
136
+ if (format === "WEBP") return "image/webp";
137
+ return "application/octet-stream";
138
+ }
139
+ detectZipType(bytes) {
140
+ const header = new TextDecoder().decode(bytes.slice(0, 2048));
141
+ if (header.includes("[Content_Types].xml") && header.includes("_rels/.rels")) {
142
+ if (header.includes("word/")) return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
143
+ if (header.includes("xl/")) return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
144
+ if (header.includes("ppt/")) return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
145
+ }
146
+ return "application/zip";
147
+ }
148
+ };
149
+
150
+ // src/model/detectors/LanguageDetector.ts
151
+ var ProgrammingLanguageDetector = class {
152
+ contentTypeName = "code";
153
+ detect(contentSample, lines, firstLine, fileExtension) {
154
+ const mime = this.getMimeType(contentSample, lines, firstLine, fileExtension);
155
+ return mime && mime !== "text/plain" ? 0.95 : 0;
156
+ }
157
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
158
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
159
+ if (this.isPython(firstLine, text, lines)) {
160
+ return "text/x-python";
161
+ }
162
+ const cType = this.detectCFamily(text);
163
+ if (cType) return cType;
164
+ const jsType = this.detectJsType(text);
165
+ if (jsType) return jsType;
166
+ if (this.isTypescript(text)) {
167
+ return "text/typescript";
168
+ }
169
+ return "text/plain";
170
+ }
171
+ isPython(firstLine, text, lines) {
172
+ if (/^\s*import\s+(\w+|\w+\.\w+)/m.test(text) || /^\s*from\s+(\w+|\w+\.\w+)\s+import\s+/m.test(text)) {
173
+ const stdLibs = ["os", "sys", "re", "json", "math", "random", "datetime"];
174
+ if (stdLibs.some((lib) => text.includes(`import ${lib}`) || text.includes(`from ${lib}`))) {
175
+ return true;
176
+ }
177
+ }
178
+ if (firstLine.startsWith("#!") && firstLine.toLowerCase().includes("python")) return true;
179
+ if (text.includes("if __name__ ==") && text.includes("__main__")) return true;
180
+ if (/^\s*def\s+\w+\s*\(/.test(text) && !text.includes("function")) return true;
181
+ if (/^\s*class\s+\w+\s*[\(:]/m.test(text)) return true;
182
+ if (/^\s*@\w+/m.test(text)) return true;
183
+ let count = 0;
184
+ const patterns = [
185
+ /\bif\b.*?:/,
186
+ /\belif\b.*?:/,
187
+ /\belse\s*:/,
188
+ /\bfor\b.*?\bin\b.*?:/,
189
+ /\bwhile\b.*?:/,
190
+ /\btry\s*:/,
191
+ /\bexcept\b.*?:/,
192
+ /\bfinally\s*:/,
193
+ /\bNone\b/,
194
+ /\bTrue\b/,
195
+ /\bFalse\b/,
196
+ /f["'].*?\{.*?\}["']/,
197
+ // f-string
198
+ /\bdef\b/,
199
+ /\bclass\b/,
200
+ /\bimport\b/,
201
+ /\bfrom\b/,
202
+ /\blambda\b.*?:/
203
+ ];
204
+ for (const p of patterns) {
205
+ if (p.test(text)) count++;
206
+ }
207
+ const nonEmptyLines = lines.filter((l) => l.trim().length > 0).length;
208
+ if (nonEmptyLines <= 5 && count >= 1) {
209
+ return true;
210
+ }
211
+ return count >= 3;
212
+ }
213
+ detectCFamily(text) {
214
+ const cPatterns = [
215
+ /#include\s*<.*?>/,
216
+ /#include\s*".*?"/,
217
+ /\b(int|void|char|float|double)\s+main\s*\(.*\)\s*\{/,
218
+ /\bstruct\s+\w+\s*\{/,
219
+ /#define\s+\w+/,
220
+ /printf\(.*?\);/,
221
+ /scanf\(.*?\);/
222
+ ];
223
+ const cppPatterns = [
224
+ /\bclass\s+\w+\s*\{/,
225
+ /\bnamespace\s+\w+\s*\{/,
226
+ /\btemplate\s*<.*?>/,
227
+ /::/,
228
+ /\bstd::/,
229
+ /\bcout\s*<</,
230
+ /\bcin\s*>>/,
231
+ /\bnew\s+\w+/,
232
+ /\bdelete\s+\w+/,
233
+ /#include\s*<iostream>/
234
+ ];
235
+ let cCount = 0;
236
+ let cppCount = 0;
237
+ cPatterns.forEach((p) => {
238
+ if (p.test(text)) cCount++;
239
+ });
240
+ cppPatterns.forEach((p) => {
241
+ if (p.test(text)) cppCount++;
242
+ });
243
+ if (cppCount >= 2 || cppCount >= 1 && text.includes("std::")) return "text/x-c++";
244
+ if (cCount >= 2) return "text/x-c";
245
+ return null;
246
+ }
247
+ detectJsType(text) {
248
+ const jsPatterns = [
249
+ /function\s+\w+\s*\(/.test(text),
250
+ // function foo(
251
+ /\bconst\s+\w+\s*=/.test(text),
252
+ /\blet\s+\w+\s*=/.test(text),
253
+ /\bvar\s+\w+\s*=/.test(text),
254
+ /\bimport\s+.*\s+from/.test(text),
255
+ /\bexport\s+/.test(text),
256
+ /\=\>\s*\{/.test(text),
257
+ // Arrow func
258
+ /console\.log\(/.test(text)
259
+ ];
260
+ const jsxPatterns = [
261
+ /<\w+(>|\s+.*?>)[\s\S]*?<\/\w+>/m.test(text),
262
+ /<\w+\s+\/>/m.test(text),
263
+ /className=/.test(text),
264
+ /React\.createElement/.test(text)
265
+ ];
266
+ const jsCount = jsPatterns.filter(Boolean).length;
267
+ const jsxCount = jsxPatterns.filter(Boolean).length;
268
+ if (jsxCount > 0 && (text.includes("import React") || text.includes('from "react"'))) return "text/jsx";
269
+ if (jsxCount >= 2) return "text/jsx";
270
+ if (jsCount >= 2) {
271
+ const stripped = text.trim();
272
+ if (stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]")) {
273
+ try {
274
+ JSON.parse(text);
275
+ if (jsCount < 2) return null;
276
+ } catch {
277
+ }
278
+ }
279
+ return "text/javascript";
280
+ }
281
+ return null;
282
+ }
283
+ isTypescript(text) {
284
+ const tsPatterns = [
285
+ /:\s*(string|number|boolean|any|void|null|undefined)\b/,
286
+ /\binterface\s+\w+\s*\{/,
287
+ /\bclass\s+\w+\s+implements\s+\w+/,
288
+ /\btype\s+\w+\s*=/,
289
+ /\b(public|private|protected)\s+/,
290
+ /\bnamespace\s+\w+\s*\{/,
291
+ /<\w+>/
292
+ // Generics (simple check)
293
+ ];
294
+ let count = 0;
295
+ tsPatterns.forEach((p) => {
296
+ if (p.test(text)) count++;
297
+ });
298
+ return count >= 2;
299
+ }
300
+ };
301
+
302
+ // src/model/detectors/MarkupDetectors.ts
303
+ var XMLDetector = class _XMLDetector {
304
+ contentTypeName = "xml";
305
+ static XML_DECLARATION = /^\s*<\?xml/i;
306
+ static BASIC_TAG_PAIR = /<(\w+)[^>]*>.*?<\/\1>/s;
307
+ detect(contentSample, lines, firstLine, fileExtension) {
308
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
309
+ let confidence = 0;
310
+ if (fileExtension && fileExtension.toLowerCase() === ".xml") {
311
+ confidence = Math.max(confidence, 0.95);
312
+ }
313
+ if (_XMLDetector.XML_DECLARATION.test(firstLine) || text.trim().startsWith("<?xml")) {
314
+ confidence = Math.max(confidence, 0.95);
315
+ }
316
+ if (text.includes("<") && text.includes(">") && text.includes("</")) {
317
+ confidence = Math.max(confidence, 0.5);
318
+ if (_XMLDetector.BASIC_TAG_PAIR.test(text)) {
319
+ confidence = Math.max(confidence, 0.7);
320
+ }
321
+ }
322
+ if (text.toLowerCase().includes("<!doctype html")) {
323
+ if (confidence > 0.3) confidence -= 0.4;
324
+ }
325
+ return Math.min(Math.max(confidence, 0), 1);
326
+ }
327
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
328
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
329
+ if (fileExtension === ".xml") return "application/xml";
330
+ if (text.toLowerCase().includes("<svg")) return "image/svg+xml";
331
+ if (text.toLowerCase().includes("<html") || text.toLowerCase().includes("<!doctype html")) return "text/html";
332
+ if (this.detect(contentSample, lines, firstLine, fileExtension) > 0.5) return "application/xml";
333
+ return "text/plain";
334
+ }
335
+ };
336
+ var MarkdownDetector = class _MarkdownDetector {
337
+ contentTypeName = "markdown";
338
+ static MD_PATTERNS = [
339
+ /^#{1,6}\s+\S+/,
340
+ // ATX Headers
341
+ /^\s*[\*\+\-]\s+\S+/,
342
+ // List items
343
+ /^\s*\d+\.\s+\S+/,
344
+ // Ordered list items
345
+ /`{1,3}[^`]+`{1,3}/,
346
+ // Inline code
347
+ /\[[^\]]+\]\([^\)]+\)/,
348
+ // Links
349
+ /!\[[^\]]+\]\([^\)]+\)/,
350
+ // Images
351
+ /^\s*>.*/
352
+ // Blockquotes
353
+ ];
354
+ static SETEXT_HEADER = /^.*\n(?:={3,}|-{3,})\s*$/m;
355
+ detect(contentSample, lines, firstLine, fileExtension) {
356
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
357
+ let confidence = 0;
358
+ if (fileExtension && [".md", ".markdown"].includes(fileExtension.toLowerCase())) {
359
+ confidence = Math.max(confidence, 0.95);
360
+ }
361
+ let mdFeatures = 0;
362
+ if (_MarkdownDetector.SETEXT_HEADER.test(text)) mdFeatures += 2;
363
+ for (const line of lines.slice(0, 20)) {
364
+ if (_MarkdownDetector.MD_PATTERNS.some((p) => p.test(line))) {
365
+ mdFeatures++;
366
+ }
367
+ }
368
+ const hasCodeFence = text.includes("```");
369
+ if (hasCodeFence) mdFeatures++;
370
+ if (mdFeatures > 1 && hasCodeFence) confidence = Math.max(confidence, 0.85);
371
+ if (mdFeatures > 3 && hasCodeFence) confidence = Math.max(confidence, 0.95);
372
+ else if (mdFeatures > 1) confidence = Math.max(confidence, 0.6);
373
+ else if (mdFeatures > 3) confidence = Math.max(confidence, 0.8);
374
+ else if (mdFeatures > 5) confidence = Math.max(confidence, 0.9);
375
+ const stripped = text.trim();
376
+ if (stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]")) {
377
+ try {
378
+ JSON.parse(text);
379
+ if (confidence > 0.3) confidence -= 0.4;
380
+ } catch {
381
+ }
382
+ }
383
+ if (stripped.startsWith("<") && text.includes("<?xml")) {
384
+ if (confidence > 0.3) confidence -= 0.4;
385
+ }
386
+ return Math.min(Math.max(confidence, 0), 1);
387
+ }
388
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
389
+ return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/markdown" : "text/plain";
390
+ }
391
+ };
392
+ var PlainTextDetector = class _PlainTextDetector {
393
+ contentTypeName = "text";
394
+ static IMAGE_EXTS = [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg", ".webp"];
395
+ detect(contentSample, lines, firstLine, fileExtension) {
396
+ if (!contentSample && lines.length === 0) return 0.1;
397
+ if (fileExtension) {
398
+ const ext = fileExtension.toLowerCase();
399
+ if (_PlainTextDetector.IMAGE_EXTS.includes(ext) || ext === ".pdf") return 0;
400
+ }
401
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
402
+ if (text.includes(",") && lines.length < 5) {
403
+ const commaLines = lines.filter((l) => l.includes(",")).length;
404
+ if (commaLines > 0 && commaLines === lines.length) {
405
+ return 0.8;
406
+ }
407
+ }
408
+ return 0.15;
409
+ }
410
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
411
+ return "text/plain";
412
+ }
413
+ };
414
+
415
+ // src/model/detectors/DataFormatDetectors.ts
416
+ var SQLDetector = class _SQLDetector {
417
+ contentTypeName = "sql";
418
+ // Keywords (case insensitive checking handled in method)
419
+ static KEYWORDS = [
420
+ "SELECT ",
421
+ "INSERT ",
422
+ "UPDATE ",
423
+ "DELETE ",
424
+ "CREATE ",
425
+ "DROP ",
426
+ "ALTER ",
427
+ "FROM ",
428
+ "WHERE ",
429
+ "JOIN ",
430
+ "TABLE ",
431
+ "INTO ",
432
+ "VALUES ",
433
+ "SET ",
434
+ "PRIMARY KEY"
435
+ ];
436
+ detect(contentSample, lines, firstLine, fileExtension) {
437
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
438
+ let confidence = 0;
439
+ if (fileExtension && fileExtension.toLowerCase() === ".sql") {
440
+ confidence = Math.max(confidence, 0.95);
441
+ }
442
+ let hits = 0;
443
+ const upperText = text.toUpperCase();
444
+ for (const line of lines.slice(0, 10)) {
445
+ const upperLine = line.toUpperCase();
446
+ for (const kw of _SQLDetector.KEYWORDS) {
447
+ if (upperLine.includes(kw)) {
448
+ hits++;
449
+ }
450
+ }
451
+ }
452
+ if (hits >= 2) confidence = Math.max(confidence, 0.85);
453
+ else if (hits === 1) confidence = Math.max(confidence, 0.6);
454
+ return Math.min(confidence, 1);
455
+ }
456
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
457
+ return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/x-sql" : "text/plain";
458
+ }
459
+ };
460
+ var JSONDetector = class {
461
+ contentTypeName = "json";
462
+ detect(contentSample, lines, firstLine, fileExtension) {
463
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
464
+ if (fileExtension && fileExtension.toLowerCase() === ".json") {
465
+ return this.verifyJsonStructure(text) ? 0.95 : 0.6;
466
+ }
467
+ const stripped = text.trim();
468
+ if (!(stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]"))) {
469
+ return 0;
470
+ }
471
+ for (const line of lines.slice(0, 5)) {
472
+ const l = line.trim();
473
+ if (l.startsWith("//") || l.startsWith("/*")) return 0;
474
+ }
475
+ try {
476
+ JSON.parse(text);
477
+ return 0.9;
478
+ } catch (e) {
479
+ return 0;
480
+ }
481
+ }
482
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
483
+ return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "application/json" : "text/plain";
484
+ }
485
+ verifyJsonStructure(text) {
486
+ try {
487
+ JSON.parse(text);
488
+ return true;
489
+ } catch {
490
+ return false;
491
+ }
492
+ }
493
+ };
494
+ var YAMLDetector = class _YAMLDetector {
495
+ contentTypeName = "yaml";
496
+ static YAML_START_PATTERNS = [/^---\s*$/, /^%YAML/];
497
+ static KEY_VALUE_PATTERN = /^\s*[\w.-]+:\s+(?![=\{\[])/;
498
+ static LIST_ITEM_PATTERN = /^\s*-\s+[\w\'\"]/;
499
+ detect(contentSample, lines, firstLine, fileExtension) {
500
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
501
+ let confidence = 0;
502
+ if (fileExtension && [".yaml", ".yml"].includes(fileExtension.toLowerCase())) {
503
+ confidence = Math.max(confidence, 0.95);
504
+ }
505
+ if (_YAMLDetector.YAML_START_PATTERNS.some((p) => p.test(firstLine))) {
506
+ confidence = Math.max(confidence, 0.9);
507
+ }
508
+ let yamlFeatures = 0;
509
+ if (_YAMLDetector.YAML_START_PATTERNS.some((p) => new RegExp(p.source, "m").test(text))) {
510
+ yamlFeatures += 2;
511
+ }
512
+ for (const line of lines.slice(0, 20)) {
513
+ const stripped = line.trim();
514
+ if (_YAMLDetector.KEY_VALUE_PATTERN.test(stripped)) yamlFeatures++;
515
+ else if (_YAMLDetector.LIST_ITEM_PATTERN.test(stripped)) yamlFeatures++;
516
+ }
517
+ const firstNonEmpty = lines.find((l) => l.trim().length > 0) || "";
518
+ if (firstNonEmpty.trim() === "---") {
519
+ if (yamlFeatures > 1) confidence = Math.max(confidence, 0.5);
520
+ if (yamlFeatures > 3) confidence = Math.max(confidence, 0.75);
521
+ if (yamlFeatures > 5) confidence = Math.max(confidence, 0.9);
522
+ } else {
523
+ if (fileExtension && [".yaml", ".yml"].includes(fileExtension.toLowerCase())) {
524
+ }
525
+ }
526
+ return Math.min(Math.max(confidence, 0), 1);
527
+ }
528
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
529
+ const conf = this.detect(contentSample, lines, firstLine, fileExtension);
530
+ return conf > 0.5 ? "application/x-yaml" : "text/plain";
531
+ }
532
+ };
533
+ var CSVDetector = class {
534
+ contentTypeName = "csv";
535
+ detect(contentSample, lines, firstLine, fileExtension) {
536
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
537
+ if (fileExtension && fileExtension.toLowerCase() === ".csv") {
538
+ return this.verifyCsvStructure(lines) ? 0.95 : 0.6;
539
+ }
540
+ const hasComma = lines.some((l) => l.includes(","));
541
+ if (hasComma) {
542
+ if (lines.length < 3) {
543
+ const commaLines = lines.filter((l) => l.includes(",")).length;
544
+ if (commaLines > 0 && commaLines === lines.length) {
545
+ const delimCounts = lines.filter((l) => l.trim()).map((l) => (l.match(/,/g) || []).length);
546
+ if (delimCounts.length > 0 && delimCounts.every((c) => c <= 2)) {
547
+ return 0;
548
+ }
549
+ }
550
+ }
551
+ }
552
+ return this.analyzeCsvContent(lines);
553
+ }
554
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
555
+ return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/csv" : "text/plain";
556
+ }
557
+ verifyCsvStructure(lines) {
558
+ const sampleLines = lines.slice(0, 10).filter((l) => l.trim().length > 0);
559
+ if (sampleLines.length === 0) return false;
560
+ if (!sampleLines.every((l) => l.includes(","))) return false;
561
+ const counts = sampleLines.map((l) => (l.match(/,/g) || []).length);
562
+ const uniqueCounts = [...new Set(counts)];
563
+ if (uniqueCounts.length === 1 && uniqueCounts[0] > 0) return true;
564
+ if (sampleLines.length > 1) {
565
+ const dataCounts = counts.slice(1);
566
+ const uniqueData = [...new Set(dataCounts)];
567
+ if (uniqueData.length === 1 && uniqueData[0] > 0) return true;
568
+ }
569
+ return false;
570
+ }
571
+ analyzeCsvContent(lines) {
572
+ if (!lines || lines.length === 0) return 0;
573
+ const sampleLines = lines.slice(0, 10).filter((l) => l.trim().length > 0);
574
+ if (sampleLines.length === 0 || !sampleLines.every((l) => l.includes(","))) return 0;
575
+ const counts = sampleLines.map((l) => (l.match(/,/g) || []).length);
576
+ const uniqueCounts = [...new Set(counts)];
577
+ if (uniqueCounts.length === 1 && uniqueCounts[0] > 0) return 0.9;
578
+ if (sampleLines.length > 1) {
579
+ const dataCounts = counts.slice(1);
580
+ const uniqueData = [...new Set(dataCounts)];
581
+ if (uniqueData.length === 1 && uniqueData[0] > 0) return 0.8;
582
+ }
583
+ if (counts.every((c) => c > 0)) return 0.5;
584
+ return 0;
585
+ }
586
+ };
587
+
588
+ // src/model/detectors/OBJDetector.ts
589
+ var OBJDetector = class _OBJDetector {
590
+ contentTypeName = "obj";
591
+ // Check for 'v ' (vertex), 'f ' (face), 'vn ', 'vt '
592
+ static COMMANDS = ["v ", "vt ", "vn ", "f ", "g ", "o ", "s ", "mtllib ", "usemtl "];
593
+ detect(contentSample, lines, firstLine, fileExtension) {
594
+ const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
595
+ let confidence = 0;
596
+ if (fileExtension && fileExtension.toLowerCase() === ".obj") {
597
+ confidence = Math.max(confidence, 0.95);
598
+ }
599
+ const validLines = lines.filter((l) => l.trim().length > 0 && !l.trim().startsWith("#"));
600
+ let commandCount = 0;
601
+ for (const line of validLines.slice(0, 20)) {
602
+ const trimmed = line.trim();
603
+ for (const cmd of _OBJDetector.COMMANDS) {
604
+ if (trimmed.startsWith(cmd)) {
605
+ commandCount++;
606
+ break;
607
+ }
608
+ }
609
+ }
610
+ if (commandCount >= 2) {
611
+ if (commandCount > 10) confidence = Math.max(confidence, 0.9);
612
+ else if (commandCount > 5) confidence = Math.max(confidence, 0.8);
613
+ else confidence = Math.max(confidence, 0.7);
614
+ }
615
+ const codeKeywords = ["def ", "class ", "import ", "function ", "var ", "let ", "const "];
616
+ if (codeKeywords.some((k) => text.includes(k))) {
617
+ return 0;
618
+ }
619
+ return Math.min(confidence, 1);
620
+ }
621
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
622
+ return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "application/3d-obj" : "text/plain";
623
+ }
624
+ };
625
+
626
+ // src/model/detectors/registry.ts
627
+ var DetectorRegistry = class {
628
+ detectors;
629
+ constructor() {
630
+ this.detectors = [
631
+ new BinarySignatureDetector(),
632
+ // Programming languages
633
+ new ProgrammingLanguageDetector(),
634
+ // Structured data
635
+ new XMLDetector(),
636
+ new JSONDetector(),
637
+ new OBJDetector(),
638
+ // Markup
639
+ new MarkdownDetector(),
640
+ // Data formats (lower priority)
641
+ new SQLDetector(),
642
+ new CSVDetector(),
643
+ new YAMLDetector(),
644
+ // Fallback
645
+ new PlainTextDetector()
646
+ ];
647
+ }
648
+ /**
649
+ * Get the active detectors.
650
+ */
651
+ getDetectors() {
652
+ return this.detectors;
653
+ }
654
+ };
655
+ var registry = new DetectorRegistry();
656
+
657
+ // ../mime_extensions.json
658
+ var mime_extensions_default = {
659
+ textMimeTypes: [
660
+ "text/plain",
661
+ "text/html",
662
+ "text/xml",
663
+ "text/csv",
664
+ "text/css",
665
+ "text/javascript",
666
+ "text/markdown",
667
+ "text/x-python",
668
+ "text/x-java",
669
+ "text/x-c",
670
+ "text/x-c++",
671
+ "text/x-sql",
672
+ "text/jsx",
673
+ "text/typescript",
674
+ "application/json",
675
+ "application/xml",
676
+ "application/x-yaml",
677
+ "application/javascript",
678
+ "application/x-httpd-php",
679
+ "application/x-sh",
680
+ "application/x-tex",
681
+ "application/3d-obj",
682
+ "text/vnd.graphviz",
683
+ "text/x-mermaid",
684
+ "text/x-plantuml",
685
+ "application/x-properties",
686
+ "application/toml"
687
+ ],
688
+ mimeToExtension: {
689
+ "image/png": "png",
690
+ "image/jpeg": "jpg",
691
+ "image/gif": "gif",
692
+ "image/bmp": "bmp",
693
+ "image/x-icon": "ico",
694
+ "image/svg+xml": "svg",
695
+ "image/djvu": "djvu",
696
+ "image/vnd.djvu": "djv",
697
+ "image/webp": "webp",
698
+ "audio/wav": "wav",
699
+ "audio/x-wav": "wav",
700
+ "video/mp4": "mp4",
701
+ "video/quicktime": "mov",
702
+ "application/pdf": "pdf",
703
+ "application/msword": "doc",
704
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
705
+ "application/vnd.ms-excel": "xls",
706
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
707
+ "application/vnd.ms-powerpoint": "ppt",
708
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
709
+ "application/zip": "zip",
710
+ "application/gzip": "gz",
711
+ "application/x-rar-compressed": "rar",
712
+ "application/x-7z-compressed": "7z",
713
+ "application/x-sqlite3": "db",
714
+ "application/x-parquet": "parquet",
715
+ "text/plain": "txt",
716
+ "text/html": "html",
717
+ "text/xml": "xml",
718
+ "text/csv": "csv",
719
+ "text/css": "css",
720
+ "text/javascript": "js",
721
+ "text/markdown": "md",
722
+ "text/x-python": "py",
723
+ "text/x-java": "java",
724
+ "text/x-c": "c",
725
+ "text/x-sql": "sql",
726
+ "text/jsx": "js",
727
+ "application/json": "json",
728
+ "application/xml": "xml",
729
+ "application/x-yaml": "yaml",
730
+ "application/javascript": "js",
731
+ "application/x-httpd-php": "php",
732
+ "application/x-sh": "sh",
733
+ "application/x-tex": "tex",
734
+ "text/vnd.graphviz": "dot",
735
+ "text/x-mermaid": "mmd",
736
+ "text/x-plantuml": "puml",
737
+ "application/3d-obj": "obj",
738
+ "application/x-properties": "properties",
739
+ "application/toml": "toml"
740
+ }
741
+ };
742
+
743
+ // src/config/constants.ts
744
+ var DEFAULT_PAGE_SIZE = 10;
745
+ var DETECTION_SAMPLE_CAP = 8192;
746
+ var MAX_FILE_SIZE = 50 * 1024 * 1024;
747
+ var KNOWN_TYPE_SIZE_LIMIT = 1024 * 1024;
748
+ var BINARY_CHECK_SAMPLE_SIZE = 32 * 1024;
749
+ var CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
750
+ var DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
751
+ var INDEXEDDB_DEFAULT_DB_NAME = "mcard-db";
752
+ var INDEXEDDB_DEFAULT_DB_VERSION = 1;
753
+ var SQLITE_BUSY_TIMEOUT_MS = 5e3;
754
+ var DEFAULT_SQLJS_WASM_URL = "https://sql.js.org/dist/";
755
+
756
+ // src/model/strategies/DetectionStrategy.ts
757
+ function loadSharedMimeData() {
758
+ return {
759
+ textMimeTypes: new Set(mime_extensions_default.textMimeTypes || []),
760
+ mimeToExtension: mime_extensions_default.mimeToExtension || {}
761
+ };
762
+ }
763
+ var _sharedData = loadSharedMimeData();
764
+ function withDot(ext) {
765
+ return ext.startsWith(".") ? ext : `.${ext}`;
766
+ }
767
+ var DefaultDetectionStrategy = class _DefaultDetectionStrategy {
768
+ constructor(customRegistry) {
769
+ this.customRegistry = customRegistry;
770
+ }
771
+ // Loaded from the shared JSON
772
+ static extensionsRegistry = Object.fromEntries(
773
+ Object.entries(_sharedData.mimeToExtension).map(([k, v]) => [k, withDot(v)])
774
+ );
775
+ static textMimeTypes = _sharedData.textMimeTypes;
776
+ static registerExtension(mimeType, extension) {
777
+ this.extensionsRegistry[mimeType] = extension;
778
+ }
779
+ static loadExtensions(mapping) {
780
+ for (const [mime, ext] of Object.entries(mapping)) {
781
+ this.extensionsRegistry[mime] = ext;
782
+ }
783
+ }
784
+ static getExtension(mimeType) {
785
+ return this.extensionsRegistry[mimeType] || "";
786
+ }
787
+ detect(content, fileExtension) {
788
+ const contentSample = typeof content === "string" ? content.slice(0, DETECTION_SAMPLE_CAP) : content.slice(0, DETECTION_SAMPLE_CAP);
789
+ const textSample = this.getTextSample(contentSample);
790
+ const lines = textSample.split("\n").slice(0, 20);
791
+ const firstLine = lines[0] || "";
792
+ const detectors = this.customRegistry ? this.customRegistry.getDetectors() : registry.getDetectors();
793
+ let bestConfidence = 0;
794
+ let mimeType = "text/plain";
795
+ for (const detector of detectors) {
796
+ const confidence = detector.detect(contentSample, lines, firstLine, fileExtension);
797
+ if (confidence > bestConfidence) {
798
+ const detectedMime = detector.getMimeType(contentSample, lines, firstLine, fileExtension);
799
+ if (detectedMime) {
800
+ bestConfidence = confidence;
801
+ mimeType = detectedMime;
802
+ if (confidence >= 0.99) break;
803
+ }
804
+ }
805
+ }
806
+ let extension = this.getExtension(mimeType);
807
+ if (fileExtension && extension) {
808
+ if (fileExtension.toLowerCase() === extension || fileExtension.toLowerCase() === `.${extension}`) {
809
+ extension = fileExtension;
810
+ }
811
+ }
812
+ if (!extension && fileExtension) {
813
+ extension = fileExtension;
814
+ }
815
+ if (!extension) {
816
+ extension = ".txt";
817
+ }
818
+ return { mimeType, extension };
819
+ }
820
+ getTextSample(content) {
821
+ if (typeof content === "string") {
822
+ return content.slice(0, DETECTION_SAMPLE_CAP);
823
+ }
824
+ return new TextDecoder("utf-8", { fatal: false }).decode(content.slice(0, DETECTION_SAMPLE_CAP));
825
+ }
826
+ getExtension(mimeType) {
827
+ return _DefaultDetectionStrategy.getExtension(mimeType);
828
+ }
829
+ };
830
+
831
+ // src/model/utils/ContentAnalyzer.ts
832
+ var ContentAnalyzer = class {
833
+ /**
834
+ * Check if content should be treated as binary.
835
+ */
836
+ static isBinaryContent(content, mimeType) {
837
+ if (mimeType) {
838
+ if (mimeType.startsWith("text/") || mimeType.includes("json") || mimeType.includes("xml") || mimeType.includes("javascript") || mimeType.includes("ecmascript")) {
839
+ return false;
840
+ }
841
+ return true;
842
+ }
843
+ if (typeof content === "string") return false;
844
+ if (content.indexOf(0) !== -1) {
845
+ return true;
846
+ }
847
+ try {
848
+ const decoder = new TextDecoder("utf-8", { fatal: true });
849
+ const decoded = decoder.decode(content);
850
+ const sample = content.slice(0, 4096);
851
+ if (sample.length === 0) return false;
852
+ let nonTextChars = 0;
853
+ for (let i = 0; i < sample.length; i++) {
854
+ const b = sample[i];
855
+ if (b < 9 || b > 13 && b < 32 || b > 126) {
856
+ nonTextChars++;
857
+ }
858
+ }
859
+ const textRatio = 1 - nonTextChars / sample.length;
860
+ return textRatio < 0.7;
861
+ } catch (e) {
862
+ return true;
863
+ }
864
+ }
865
+ static isKnownLongLineExtension(extension) {
866
+ if (!extension) return false;
867
+ const ext = extension.toLowerCase();
868
+ return [".min.js", ".min.css", ".map", ".svg", ".json", ".geojson"].some((e) => ext.endsWith(e));
869
+ }
870
+ static isUnstructuredBinary(sample) {
871
+ if (sample.length < 512) return false;
872
+ let nullCount = 0;
873
+ let controlCount = 0;
874
+ const len = Math.min(sample.length, 32 * 1024);
875
+ for (let i = 0; i < len; i++) {
876
+ const byte = sample[i];
877
+ if (byte === 0) {
878
+ nullCount++;
879
+ }
880
+ if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
881
+ controlCount++;
882
+ }
883
+ }
884
+ const nullRatio = nullCount / len;
885
+ const controlRatio = controlCount / len;
886
+ return nullRatio > 0.1 || controlRatio > 0.2;
887
+ }
888
+ static hasPathologicalLines(sample, isKnownType) {
889
+ if (isKnownType || sample.length < 32768) return false;
890
+ for (let i = 0; i < sample.length; i++) {
891
+ if (sample[i] === 10 || sample[i] === 13) return false;
892
+ }
893
+ return true;
894
+ }
895
+ };
896
+
897
+ // src/model/ContentTypeInterpreter.ts
898
+ var ContentTypeInterpreter = class {
899
+ static strategy = new DefaultDetectionStrategy();
900
+ /**
901
+ * Convenience method to detect MIME type only.
902
+ * Matches the API expected by MCard/PCard/VCard.
903
+ */
904
+ static detect(content) {
905
+ return this.detectContentType(content).mimeType;
906
+ }
907
+ /**
908
+ * Detect content type and suggest extension.
909
+ *
910
+ * @param content Content string or binary buffer
911
+ * @param fileExtension Optional file extension hint
912
+ * @returns Object containing detected mimeType and suggested extension
913
+ */
914
+ static detectContentType(content, fileExtension) {
915
+ return this.strategy.detect(content, fileExtension);
916
+ }
917
+ static registerExtension(mimeType, extension) {
918
+ DefaultDetectionStrategy.registerExtension(mimeType, extension);
919
+ }
920
+ static registerExtensions(mapping) {
921
+ DefaultDetectionStrategy.loadExtensions(mapping);
922
+ }
923
+ static getExtension(mimeType) {
924
+ return DefaultDetectionStrategy.getExtension(mimeType);
925
+ }
926
+ /**
927
+ * Check if content should be treated as binary.
928
+ */
929
+ static isBinaryContent(content, mimeType) {
930
+ return ContentAnalyzer.isBinaryContent(content, mimeType);
931
+ }
932
+ static isKnownLongLineExtension(extension) {
933
+ return ContentAnalyzer.isKnownLongLineExtension(extension);
934
+ }
935
+ static isUnstructuredBinary(sample) {
936
+ return ContentAnalyzer.isUnstructuredBinary(sample);
937
+ }
938
+ static hasPathologicalLines(sample, isKnownType) {
939
+ return ContentAnalyzer.hasPathologicalLines(sample, isKnownType);
940
+ }
941
+ };
942
+
943
+ // src/types/dots.ts
944
+ function createMCardDOTSMetadata(tightRefs = [], looseRefs = []) {
945
+ return {
946
+ role: "Carrier" /* CARRIER */,
947
+ eosRole: "InvariantContent" /* INVARIANT_CONTENT */,
948
+ plane: "Data" /* DATA */,
949
+ tightRefs,
950
+ looseRefs
951
+ };
952
+ }
953
+ function createPCardDOTSMetadata(isLens, tightRefs = [], looseRefs = []) {
954
+ return {
955
+ role: isLens ? "Lens" /* LENS */ : "Chart" /* CHART */,
956
+ eosRole: "GenerativeLens" /* GENERATIVE_LENS */,
957
+ plane: "Control" /* CONTROL */,
958
+ tightRefs,
959
+ looseRefs
960
+ };
961
+ }
962
+ function createVCardDOTSMetadata() {
963
+ return {
964
+ role: "Arena" /* ARENA */,
965
+ eosRole: "SovereignDecision" /* SOVEREIGN_DECISION */,
966
+ plane: "Application" /* APPLICATION */
967
+ };
968
+ }
969
+
970
+ // src/model/MCard.ts
971
+ var MCard = class _MCard {
972
+ content;
973
+ hash;
974
+ g_time;
975
+ contentType;
976
+ // Defaulting to specific string or null
977
+ hashFunction;
978
+ constructor(content, hash, g_time, contentType, hashFunction) {
979
+ this.content = content;
980
+ this.hash = hash;
981
+ this.g_time = g_time;
982
+ this.contentType = contentType;
983
+ this.hashFunction = hashFunction;
984
+ }
985
+ /**
986
+ * Create a new MCard from content
987
+ */
988
+ static async create(content, hashAlgorithm = "sha256") {
989
+ if (content === null || content === void 0) {
990
+ throw new Error("Content cannot be null or undefined");
991
+ }
992
+ const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
993
+ if (bytes.length === 0) {
994
+ throw new Error("Content cannot be empty");
995
+ }
996
+ const hash = await HashValidator.computeHash(bytes, hashAlgorithm);
997
+ const g_time = GTime.stampNow(hashAlgorithm);
998
+ const contentType = ContentTypeInterpreter.detect(bytes);
999
+ return new _MCard(bytes, hash, g_time, contentType, hashAlgorithm);
1000
+ }
1001
+ /**
1002
+ * Create an MCard from existing data (e.g., from database)
1003
+ */
1004
+ static fromData(content, hash, g_time) {
1005
+ const alg = GTime.getHashAlgorithm(g_time);
1006
+ const contentType = ContentTypeInterpreter.detect(content);
1007
+ return new _MCard(content, hash, g_time, contentType, alg);
1008
+ }
1009
+ /**
1010
+ * Get content as text (UTF-8 decoded)
1011
+ */
1012
+ getContentAsText() {
1013
+ return new TextDecoder().decode(this.content);
1014
+ }
1015
+ /**
1016
+ * Get content as raw bytes
1017
+ */
1018
+ getContent() {
1019
+ return this.content;
1020
+ }
1021
+ /**
1022
+ * Convert to plain object
1023
+ */
1024
+ toObject() {
1025
+ return {
1026
+ hash: this.hash,
1027
+ content: this.getContentAsText(),
1028
+ g_time: this.g_time,
1029
+ contentType: this.contentType,
1030
+ hashFunction: this.hashFunction
1031
+ };
1032
+ }
1033
+ /**
1034
+ * Get DOTS vocabulary metadata for this MCard
1035
+ *
1036
+ * Returns the DOTS role information that positions this MCard
1037
+ * in the Double Operadic Theory of Systems framework.
1038
+ *
1039
+ * MCard is always a CARRIER object in the Data Plane.
1040
+ *
1041
+ * @param tightRefs - Optional array of prerequisite MCard hashes (vertical composition)
1042
+ * @param looseRefs - Optional array of alternative MCard hashes (horizontal composition)
1043
+ * @returns DOTSMetadata describing this card's role in the compositional system
1044
+ *
1045
+ * @example
1046
+ * ```typescript
1047
+ * const card = await MCard.create('Hello World');
1048
+ * const meta = card.getDOTSMetadata();
1049
+ * console.log(meta.role); // 'Carrier'
1050
+ * console.log(meta.plane); // 'Data'
1051
+ * ```
1052
+ */
1053
+ getDOTSMetadata(tightRefs = [], looseRefs = []) {
1054
+ return createMCardDOTSMetadata(tightRefs, looseRefs);
1055
+ }
1056
+ };
1057
+
1058
+ export {
1059
+ DEFAULT_PAGE_SIZE,
1060
+ INDEXEDDB_DEFAULT_DB_NAME,
1061
+ INDEXEDDB_DEFAULT_DB_VERSION,
1062
+ SQLITE_BUSY_TIMEOUT_MS,
1063
+ DEFAULT_SQLJS_WASM_URL,
1064
+ ContentTypeInterpreter,
1065
+ createPCardDOTSMetadata,
1066
+ createVCardDOTSMetadata,
1067
+ MCard
1068
+ };