@gravito/core 2.0.3 → 2.0.6

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.
@@ -0,0 +1,71 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, {
40
+ get: all[name],
41
+ enumerable: true,
42
+ configurable: true,
43
+ set: __exportSetter.bind(all, name)
44
+ });
45
+ };
46
+ var __require = import.meta.require;
47
+
48
+ // src/compat/async-local-storage.browser.ts
49
+ class AsyncLocalStorage {
50
+ store;
51
+ run(store, fn) {
52
+ const prev = this.store;
53
+ this.store = store;
54
+ try {
55
+ return fn();
56
+ } finally {
57
+ this.store = prev;
58
+ }
59
+ }
60
+ getStore() {
61
+ return this.store;
62
+ }
63
+ disable() {
64
+ this.store = undefined;
65
+ }
66
+ }
67
+ export {
68
+ AsyncLocalStorage
69
+ };
70
+
71
+ //# debugId=1CD94D2F311BBD0564756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/compat/async-local-storage.browser.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Browser-safe AsyncLocalStorage mock\n */\nexport class AsyncLocalStorage<T> {\n private store: T | undefined\n\n run<R>(store: T, fn: () => R): R {\n const prev = this.store\n this.store = store\n try {\n return fn()\n } finally {\n this.store = prev\n }\n }\n\n getStore(): T | undefined {\n return this.store\n }\n\n disable(): void {\n this.store = undefined\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,kBAAqB;AAAA,EACxB;AAAA,EAER,GAAM,CAAC,OAAU,IAAgB;AAAA,IAC/B,MAAM,OAAO,KAAK;AAAA,IAClB,KAAK,QAAQ;AAAA,IACb,IAAI;AAAA,MACF,OAAO,GAAG;AAAA,cACV;AAAA,MACA,KAAK,QAAQ;AAAA;AAAA;AAAA,EAIjB,QAAQ,GAAkB;AAAA,IACxB,OAAO,KAAK;AAAA;AAAA,EAGd,OAAO,GAAS;AAAA,IACd,KAAK,QAAQ;AAAA;AAEjB;",
8
+ "debugId": "1CD94D2F311BBD0564756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,94 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, {
40
+ get: all[name],
41
+ enumerable: true,
42
+ configurable: true,
43
+ set: __exportSetter.bind(all, name)
44
+ });
45
+ };
46
+ var __require = import.meta.require;
47
+
48
+ // src/compat/async-local-storage.ts
49
+ var AsyncLocalStorageClass;
50
+ var tryGetNodeAsyncHooks = () => {
51
+ try {
52
+ if (typeof window === "undefined" && typeof process !== "undefined" && true) {
53
+ try {
54
+ const module = __require("async_hooks");
55
+ return module.AsyncLocalStorage;
56
+ } catch (_e1) {
57
+ try {
58
+ return eval("require")("node:async_hooks").AsyncLocalStorage;
59
+ } catch (_e2) {
60
+ return null;
61
+ }
62
+ }
63
+ }
64
+ } catch (_e) {
65
+ return null;
66
+ }
67
+ };
68
+ AsyncLocalStorageClass = tryGetNodeAsyncHooks();
69
+ if (!AsyncLocalStorageClass) {
70
+ AsyncLocalStorageClass = class AsyncLocalStorage {
71
+ store;
72
+ run(store, fn) {
73
+ const prev = this.store;
74
+ this.store = store;
75
+ try {
76
+ return fn();
77
+ } finally {
78
+ this.store = prev;
79
+ }
80
+ }
81
+ getStore() {
82
+ return this.store;
83
+ }
84
+ disable() {
85
+ this.store = undefined;
86
+ }
87
+ };
88
+ }
89
+ var AsyncLocalStorage = AsyncLocalStorageClass;
90
+ export {
91
+ AsyncLocalStorage
92
+ };
93
+
94
+ //# debugId=AEC51513D62BFF6864756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/compat/async-local-storage.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Universal AsyncLocalStorage wrapper.\n * Automatically switches between node:async_hooks and a browser mock.\n */\n\nlet AsyncLocalStorageClass: any\n\n// Try to load Node.js AsyncLocalStorage\nconst tryGetNodeAsyncHooks = () => {\n try {\n if (\n typeof window === 'undefined' &&\n typeof process !== 'undefined' &&\n !(process as any).browser\n ) {\n // Try direct import for Bun/Node.js ESM compatibility\n try {\n const module = require('node:async_hooks')\n return module.AsyncLocalStorage\n } catch (_e1) {\n // Fallback to eval for CommonJS require hiding\n try {\n // biome-ignore lint/security/noGlobalEval: specialized case for hiding node built-ins\n return eval('require')('node:async_hooks').AsyncLocalStorage\n } catch (_e2) {\n return null\n }\n }\n }\n } catch (_e) {\n return null\n }\n}\n\nAsyncLocalStorageClass = tryGetNodeAsyncHooks()\n\nif (!AsyncLocalStorageClass) {\n /**\n * Browser-safe AsyncLocalStorage mock.\n * Note: This mock only works with synchronous functions.\n * For proper async support, ensure Node.js AsyncLocalStorage is available.\n */\n AsyncLocalStorageClass = class AsyncLocalStorage<T> {\n private store: T | undefined\n\n run<R>(store: T, fn: () => R): R {\n const prev = this.store\n this.store = store\n try {\n return fn()\n } finally {\n this.store = prev\n }\n }\n\n getStore(): T | undefined {\n return this.store\n }\n\n disable(): void {\n this.store = undefined\n }\n }\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: generic class mock\nexport const AsyncLocalStorage: { new <_T>(): any } = AsyncLocalStorageClass\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAI;AAGJ,IAAM,uBAAuB,MAAM;AAAA,EACjC,IAAI;AAAA,IACF,IACE,OAAO,WAAW,eAClB,OAAO,YAAY,eACnB,MACA;AAAA,MAEA,IAAI;AAAA,QACF,MAAM;AAAA,QACN,OAAO,OAAO;AAAA,QACd,OAAO,KAAK;AAAA,QAEZ,IAAI;AAAA,UAEF,OAAO,KAAK,SAAS,EAAE,kBAAkB,EAAE;AAAA,UAC3C,OAAO,KAAK;AAAA,UACZ,OAAO;AAAA;AAAA;AAAA,IAGb;AAAA,IACA,OAAO,IAAI;AAAA,IACX,OAAO;AAAA;AAAA;AAIX,yBAAyB,qBAAqB;AAE9C,IAAI,CAAC,wBAAwB;AAAA,EAM3B,yBAAyB,MAAM,kBAAqB;AAAA,IAC1C;AAAA,IAER,GAAM,CAAC,OAAU,IAAgB;AAAA,MAC/B,MAAM,OAAO,KAAK;AAAA,MAClB,KAAK,QAAQ;AAAA,MACb,IAAI;AAAA,QACF,OAAO,GAAG;AAAA,gBACV;AAAA,QACA,KAAK,QAAQ;AAAA;AAAA;AAAA,IAIjB,QAAQ,GAAkB;AAAA,MACxB,OAAO,KAAK;AAAA;AAAA,IAGd,OAAO,GAAS;AAAA,MACd,KAAK,QAAQ;AAAA;AAAA,EAEjB;AACF;AAGO,IAAM,oBAAyC;",
8
+ "debugId": "AEC51513D62BFF6864756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,91 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, {
40
+ get: all[name],
41
+ enumerable: true,
42
+ configurable: true,
43
+ set: __exportSetter.bind(all, name)
44
+ });
45
+ };
46
+ var __require = import.meta.require;
47
+
48
+ // src/compat/crypto.browser.ts
49
+ var randomUUID = () => {
50
+ if (typeof globalThis.crypto?.randomUUID === "function") {
51
+ return globalThis.crypto.randomUUID();
52
+ }
53
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
54
+ const r = Math.random() * 16 | 0;
55
+ const v = c === "x" ? r : r & 3 | 8;
56
+ return v.toString(16);
57
+ });
58
+ };
59
+ var randomBytes = (size) => {
60
+ const bytes = new Uint8Array(size);
61
+ if (typeof globalThis.crypto?.getRandomValues === "function") {
62
+ globalThis.crypto.getRandomValues(bytes);
63
+ } else {
64
+ for (let i = 0;i < size; i++) {
65
+ bytes[i] = Math.floor(Math.random() * 256);
66
+ }
67
+ }
68
+ return {
69
+ length: size,
70
+ [Symbol.iterator]: () => bytes[Symbol.iterator](),
71
+ toString: (encoding) => {
72
+ if (encoding === "base64") {
73
+ let binary = "";
74
+ for (let i = 0;i < bytes.byteLength; i++) {
75
+ binary += String.fromCharCode(bytes[i]);
76
+ }
77
+ return btoa(binary);
78
+ }
79
+ if (encoding === "hex") {
80
+ return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
81
+ }
82
+ return "";
83
+ }
84
+ };
85
+ };
86
+ export {
87
+ randomUUID,
88
+ randomBytes
89
+ };
90
+
91
+ //# debugId=DA2B8600ADBAB27E64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/compat/crypto.browser.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Browser-safe crypto mock\n */\nexport const randomUUID = () => {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID()\n }\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0\n const v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16)\n })\n}\n\nexport const randomBytes = (size: number) => {\n const bytes = new Uint8Array(size)\n if (typeof globalThis.crypto?.getRandomValues === 'function') {\n globalThis.crypto.getRandomValues(bytes)\n } else {\n for (let i = 0; i < size; i++) {\n bytes[i] = Math.floor(Math.random() * 256)\n }\n }\n\n // Basic Buffer-like object for Str.ts compatibility\n return {\n length: size,\n [Symbol.iterator]: () => bytes[Symbol.iterator](),\n toString: (encoding: string) => {\n if (encoding === 'base64') {\n let binary = ''\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i])\n }\n return btoa(binary)\n }\n if (encoding === 'hex') {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n }\n return ''\n },\n } as unknown as Buffer\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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names": []
10
+ }
@@ -0,0 +1,111 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, {
40
+ get: all[name],
41
+ enumerable: true,
42
+ configurable: true,
43
+ set: __exportSetter.bind(all, name)
44
+ });
45
+ };
46
+ var __require = import.meta.require;
47
+
48
+ // src/compat/crypto.ts
49
+ var randomUUIDFn;
50
+ var randomBytesFn;
51
+ var tryGetNodeCrypto = () => {
52
+ try {
53
+ if (typeof window === "undefined" && typeof process !== "undefined" && true) {
54
+ return eval("require")("node:crypto");
55
+ }
56
+ } catch (_e) {
57
+ return null;
58
+ }
59
+ };
60
+ var nodeCrypto = tryGetNodeCrypto();
61
+ if (nodeCrypto) {
62
+ randomUUIDFn = nodeCrypto.randomUUID;
63
+ randomBytesFn = nodeCrypto.randomBytes;
64
+ } else {
65
+ randomUUIDFn = () => {
66
+ if (typeof globalThis.crypto?.randomUUID === "function") {
67
+ return globalThis.crypto.randomUUID();
68
+ }
69
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
70
+ const r = Math.random() * 16 | 0;
71
+ const v = c === "x" ? r : r & 3 | 8;
72
+ return v.toString(16);
73
+ });
74
+ };
75
+ randomBytesFn = (size) => {
76
+ const bytes = new Uint8Array(size);
77
+ if (typeof globalThis.crypto?.getRandomValues === "function") {
78
+ globalThis.crypto.getRandomValues(bytes);
79
+ } else {
80
+ for (let i = 0;i < size; i++) {
81
+ bytes[i] = Math.floor(Math.random() * 256);
82
+ }
83
+ }
84
+ return {
85
+ ...Array.from(bytes),
86
+ length: size,
87
+ [Symbol.iterator]: () => bytes[Symbol.iterator](),
88
+ toString: (encoding) => {
89
+ if (encoding === "base64") {
90
+ let binary = "";
91
+ for (let i = 0;i < bytes.byteLength; i++) {
92
+ binary += String.fromCharCode(bytes[i]);
93
+ }
94
+ return btoa(binary);
95
+ }
96
+ if (encoding === "hex") {
97
+ return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
98
+ }
99
+ return "";
100
+ }
101
+ };
102
+ };
103
+ }
104
+ var randomUUID = randomUUIDFn;
105
+ var randomBytes = randomBytesFn;
106
+ export {
107
+ randomUUID,
108
+ randomBytes
109
+ };
110
+
111
+ //# debugId=90A5E907AAB9EDB264756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/compat/crypto.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Universal Crypto wrapper.\n * Automatically switches between node:crypto and globalThis.crypto.\n */\n\nlet randomUUIDFn: () => string\nlet randomBytesFn: (size: number) => any\n\nconst tryGetNodeCrypto = () => {\n try {\n if (\n typeof window === 'undefined' &&\n typeof process !== 'undefined' &&\n !(process as any).browser\n ) {\n // biome-ignore lint/security/noGlobalEval: specialized case for hiding node built-ins\n return eval('require')('node:crypto')\n }\n } catch (_e) {\n return null\n }\n}\n\nconst nodeCrypto = tryGetNodeCrypto()\n\nif (nodeCrypto) {\n randomUUIDFn = nodeCrypto.randomUUID\n randomBytesFn = nodeCrypto.randomBytes\n} else {\n // Browser implementations\n randomUUIDFn = () => {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID()\n }\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0\n const v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16)\n })\n }\n\n randomBytesFn = (size: number) => {\n const bytes = new Uint8Array(size)\n if (typeof globalThis.crypto?.getRandomValues === 'function') {\n globalThis.crypto.getRandomValues(bytes)\n } else {\n for (let i = 0; i < size; i++) {\n bytes[i] = Math.floor(Math.random() * 256)\n }\n }\n // Return a Buffer-like object\n return {\n ...Array.from(bytes),\n length: size,\n [Symbol.iterator]: () => bytes[Symbol.iterator](),\n toString: (encoding: string) => {\n if (encoding === 'base64') {\n let binary = ''\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i])\n }\n return btoa(binary)\n }\n if (encoding === 'hex') {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n }\n return ''\n },\n }\n }\n}\n\nexport const randomUUID = randomUUIDFn\nexport const randomBytes = randomBytesFn\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAI;AACJ,IAAI;AAEJ,IAAM,mBAAmB,MAAM;AAAA,EAC7B,IAAI;AAAA,IACF,IACE,OAAO,WAAW,eAClB,OAAO,YAAY,eACnB,MACA;AAAA,MAEA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tB,OAAO,MAAM,KAAK,KAAK,EACpB,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AAAA,QACZ;AAAA,QACA,OAAO;AAAA;AAAA,IAEX;AAAA;AAAA;AAIG,IAAM,aAAa;AACnB,IAAM,cAAc;",
8
+ "debugId": "90A5E907AAB9EDB264756E2164756E21",
9
+ "names": []
10
+ }
@@ -2,6 +2,14 @@
2
2
  * 原生加速器統一入口
3
3
  * 遵循 Galaxy Architecture 的運行時自適應模式
4
4
  * 與 RuntimeAdapter 模式保持一致
5
+ *
6
+ * 📍 FFI 暫時禁用
7
+ * Bun 的構建系統在生成 ffi/index.js 時會產生 CJS compatibility helpers,
8
+ * 這些 helpers 與 ESM export 語句導致模組解析失敗。
9
+ * 即使使用 ESM import 也無法避免此問題(Bun 內部機制)。
10
+ *
11
+ * 解決方案:禁用 FFI,使用 JavaScript fallback(性能影響極小)
12
+ * TODO: 當 Bun 改進其 ESM 模組構建時重新啟用
5
13
  */
6
14
  import type { CborAccelerator, NativeAcceleratorStatus } from './types';
7
15
  /**
@@ -12,7 +20,6 @@ import type { CborAccelerator, NativeAcceleratorStatus } from './types';
12
20
  */
13
21
  export declare class NativeAccelerator {
14
22
  private static readonly DEBUG_ENV;
15
- private static readonly DISABLE_ENV;
16
23
  /**
17
24
  * FFI 可用性緩存
18
25
  * null: 未檢測, true: 可用, false: 不可用
@@ -28,10 +35,7 @@ export declare class NativeAccelerator {
28
35
  private static status;
29
36
  /**
30
37
  * 檢測原生 FFI 是否可用
31
- * 偵測邏輯:
32
- * 1. 檢查 GRAVITO_FFI_DISABLE 環境變數
33
- * 2. 檢查 Bun 運行時可用性
34
- * 3. 檢查 bun:ffi 的 cc() 是否可用
38
+ * ⚠️ 當前全部返回 false(FFI 已禁用)
35
39
  */
36
40
  static isAvailable(): boolean;
37
41
  /**
@@ -47,17 +51,6 @@ export declare class NativeAccelerator {
47
51
  * 重置加速器狀態(用於測試)
48
52
  */
49
53
  static reset(): void;
50
- /**
51
- * 解析 C 原始碼路徑
52
- * 支援從原始碼目錄或 npm 套件的 src/ffi/native 目錄載入
53
- */
54
- private static resolveCSourcePath;
55
- /**
56
- * 載入原生 C 實現
57
- * 使用 bun:ffi 的 cc() 動態編譯 C 代碼
58
- * 優先從檔案載入完整實現,避免內聯限制
59
- */
60
- private static loadNativeImplementation;
61
54
  /**
62
55
  * 檢查是否啟用調試模式
63
56
  */