atmx-web 0.62.0 → 0.63.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.
- package/dist/atmx.es.js +374 -161
- package/dist/atmx.umd.js +3 -3
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/wasm-BF1CGBqM.js +0 -230
package/dist/atmx.es.js
CHANGED
|
@@ -1,6 +1,219 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/core/types.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e[e.Complete = 0] = "Complete", e[e.NetworkSuccess = 1] = "NetworkSuccess", e[e.CacheHit = 2] = "CacheHit", e[e.CacheHitAndFetching = 3] = "CacheHitAndFetching", e[e.Error = 4] = "Error", e;
|
|
4
|
+
}({}), t = /* @__PURE__ */ new Map();
|
|
5
|
+
function n(n) {
|
|
6
|
+
window.axiom_web_callback = (r, i, a, o, s, c, l) => {
|
|
7
|
+
let u = t.get(r);
|
|
8
|
+
if (!u) {
|
|
9
|
+
o && n.axiom_free_memory(o, s), c && n.axiom_free_memory(c, l);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
let d = null, f = null;
|
|
13
|
+
if (o !== 0 && s > 0) {
|
|
14
|
+
let e = new Uint8Array(n.memory.buffer);
|
|
15
|
+
d = new Uint8Array(e.subarray(o, o + s)), n.axiom_free_memory(o, s);
|
|
16
|
+
}
|
|
17
|
+
if (c !== 0 && l > 0) {
|
|
18
|
+
let e = new Uint8Array(n.memory.buffer), t = new Uint8Array(e.subarray(c, c + l));
|
|
19
|
+
f = new TextDecoder().decode(t), n.axiom_free_memory(c, l);
|
|
20
|
+
}
|
|
21
|
+
if (i === e.Complete) {
|
|
22
|
+
u.onComplete(), t.delete(r);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (i === e.Error) {
|
|
26
|
+
let e;
|
|
27
|
+
if (f) try {
|
|
28
|
+
e = JSON.parse(f);
|
|
29
|
+
} catch (t) {
|
|
30
|
+
e = {
|
|
31
|
+
stage: "ffiBoundary",
|
|
32
|
+
category: "runtime",
|
|
33
|
+
code: "JsonParseFailure",
|
|
34
|
+
message: `Parse failed: ${t}`,
|
|
35
|
+
retryable: !1
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else e = {
|
|
39
|
+
stage: "runtime",
|
|
40
|
+
category: "unknown",
|
|
41
|
+
code: a.toString(),
|
|
42
|
+
message: "Internal Wasm error",
|
|
43
|
+
retryable: !1
|
|
44
|
+
};
|
|
45
|
+
u.onResponse({
|
|
46
|
+
eventType: i,
|
|
47
|
+
error: e
|
|
48
|
+
}), u.onComplete(), t.delete(r);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (d) try {
|
|
52
|
+
let n = new TextDecoder().decode(d), a = JSON.parse(n);
|
|
53
|
+
u.onResponse({
|
|
54
|
+
eventType: i,
|
|
55
|
+
data: a,
|
|
56
|
+
isFetching: i === e.CacheHitAndFetching,
|
|
57
|
+
isStreamChunk: u.isStream
|
|
58
|
+
}), !u.isStream && i === e.NetworkSuccess && (u.onComplete(), t.delete(r));
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error("ATMX: Failed to parse JSON response from Axiom", e);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/core/router.ts
|
|
66
|
+
var r = /* @__PURE__ */ new Map();
|
|
67
|
+
function i(e, t) {
|
|
68
|
+
let n = t?.ir?.endpoints;
|
|
69
|
+
if (!n) return;
|
|
70
|
+
let i = Array.isArray(n) ? n : Object.values(n);
|
|
71
|
+
i.forEach((t) => {
|
|
72
|
+
let n = `${e}.${t.name}`, i = t.parameters?.find((e) => e.source === "body")?.name || null;
|
|
73
|
+
r.set(n, {
|
|
74
|
+
id: t.id,
|
|
75
|
+
namespace: e,
|
|
76
|
+
name: t.name,
|
|
77
|
+
method: t.method ? t.method.toUpperCase() : "GET",
|
|
78
|
+
pathTemplate: t.path,
|
|
79
|
+
isStream: t.isStream || !1,
|
|
80
|
+
auth: t.auth || null,
|
|
81
|
+
bodyParam: i
|
|
82
|
+
});
|
|
83
|
+
}), console.log(`🛣️ ATMX Router: Mapped ${i.length} endpoints for '${e}'.`);
|
|
84
|
+
}
|
|
85
|
+
function a(e) {
|
|
86
|
+
return r.get(e.trim()) || null;
|
|
87
|
+
}
|
|
88
|
+
function o(e, t) {
|
|
89
|
+
let n = e.pathTemplate, r = { ...t }, i = n.match(/\{([^}]+)\}/g);
|
|
90
|
+
if (i && i.forEach((e) => {
|
|
91
|
+
let t = e.replace(/[{}]/g, "");
|
|
92
|
+
r[t] !== void 0 && (n = n.replace(e, encodeURIComponent(String(r[t]))), delete r[t]);
|
|
93
|
+
}), e.method === "GET" && Object.keys(r).length > 0) {
|
|
94
|
+
let e = new URLSearchParams();
|
|
95
|
+
for (let [t, n] of Object.entries(r)) n != null && e.append(t, String(n));
|
|
96
|
+
let t = n.includes("?") ? "&" : "?";
|
|
97
|
+
n += `${t}${e.toString()}`;
|
|
98
|
+
for (let e of Object.keys(r)) delete r[e];
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
path: n,
|
|
102
|
+
remainingArgs: r
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/core/vendor/axiom_runtime.js?raw
|
|
107
|
+
var s = "let wasm_bindgen = (function(exports) {\n let script_src;\n if (typeof document !== 'undefined' && document.currentScript !== null) {\n script_src = new URL(document.currentScript.src, location.href).toString();\n }\n function __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff: function(arg0) {\n const v = getObject(arg0);\n const ret = typeof(v) === 'boolean' ? v : undefined;\n return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;\n },\n __wbg___wbindgen_debug_string_ab4b34d23d6778bd: function(arg0, arg1) {\n const ret = debugString(getObject(arg1));\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_is_function_3baa9db1a987f47d: function(arg0) {\n const ret = typeof(getObject(arg0)) === 'function';\n return ret;\n },\n __wbg___wbindgen_is_object_63322ec0cd6ea4ef: function(arg0) {\n const val = getObject(arg0);\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n },\n __wbg___wbindgen_is_string_6df3bf7ef1164ed3: function(arg0) {\n const ret = typeof(getObject(arg0)) === 'string';\n return ret;\n },\n __wbg___wbindgen_is_undefined_29a43b4d42920abd: function(arg0) {\n const ret = getObject(arg0) === undefined;\n return ret;\n },\n __wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = typeof(obj) === 'string' ? obj : undefined;\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n var len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg__wbg_cb_unref_b46c9b5a9f08ec37: function(arg0) {\n getObject(arg0)._wbg_cb_unref();\n },\n __wbg_abort_4ce5b484434ef6fd: function(arg0) {\n getObject(arg0).abort();\n },\n __wbg_append_e8fc56ce7c00e874: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {\n getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));\n }, arguments); },\n __wbg_arrayBuffer_848c392b70c67d3d: function() { return handleError(function (arg0) {\n const ret = getObject(arg0).arrayBuffer();\n return addHeapObject(ret);\n }, arguments); },\n __wbg_axiom_web_callback_da6bff810821623d: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {\n axiom_web_callback(arg0, arg1, arg2, arg3 >>> 0, arg4 >>> 0, arg5 >>> 0, arg6 >>> 0);\n },\n __wbg_body_0c3a51aec038a31a: function(arg0) {\n const ret = getObject(arg0).body;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n },\n __wbg_buffer_d0f5ea0926a691fd: function(arg0) {\n const ret = getObject(arg0).buffer;\n return addHeapObject(ret);\n },\n __wbg_call_14b169f759b26747: function() { return handleError(function (arg0, arg1) {\n const ret = getObject(arg0).call(getObject(arg1));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_call_a24592a6f349a97e: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_clearInterval_16e8cbbce92291d0: function(arg0) {\n const ret = clearInterval(takeObject(arg0));\n return addHeapObject(ret);\n },\n __wbg_clearTimeout_113b1cde814ec762: function(arg0) {\n const ret = clearTimeout(takeObject(arg0));\n return addHeapObject(ret);\n },\n __wbg_crypto_38df2bab126b63dc: function(arg0) {\n const ret = getObject(arg0).crypto;\n return addHeapObject(ret);\n },\n __wbg_data_bb9dffdd1e99cf2d: function(arg0) {\n const ret = getObject(arg0).data;\n return addHeapObject(ret);\n },\n __wbg_done_9158f7cc8751ba32: function(arg0) {\n const ret = getObject(arg0).done;\n return ret;\n },\n __wbg_error_2001591ad2463697: function(arg0) {\n console.error(getObject(arg0));\n },\n __wbg_fetch_0d322c0aed196b8b: function(arg0, arg1) {\n const ret = getObject(arg0).fetch(getObject(arg1));\n return addHeapObject(ret);\n },\n __wbg_fetch_8d9b732df7467c44: function(arg0) {\n const ret = fetch(getObject(arg0));\n return addHeapObject(ret);\n },\n __wbg_fetch_fda7bc27c982b1f3: function(arg0) {\n const ret = fetch(getObject(arg0));\n return addHeapObject(ret);\n },\n __wbg_getItem_7fe1351b9ea3b2f3: function() { return handleError(function (arg0, arg1, arg2, arg3) {\n const ret = getObject(arg1).getItem(getStringFromWasm0(arg2, arg3));\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n var len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n }, arguments); },\n __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {\n getObject(arg0).getRandomValues(getObject(arg1));\n }, arguments); },\n __wbg_getReader_9094ac3b37a7d171: function(arg0) {\n const ret = getObject(arg0).getReader();\n return addHeapObject(ret);\n },\n __wbg_get_1affdbdd5573b16a: function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.get(getObject(arg0), getObject(arg1));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_get_6011fa3a58f61074: function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.get(getObject(arg0), getObject(arg1));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_has_880f1d472f7cecba: function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.has(getObject(arg0), getObject(arg1));\n return ret;\n }, arguments); },\n __wbg_headers_6022deb4e576fb8e: function(arg0) {\n const ret = getObject(arg0).headers;\n return addHeapObject(ret);\n },\n __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3: function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof ArrayBuffer;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_Error_6872d63ba7922898: function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Error;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_ReadableStreamDefaultReader_02bfe747638fa274: function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof ReadableStreamDefaultReader;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_Response_9b2d111407865ff2: function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Response;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_Window_cc64c86c8ef9e02b: function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Window;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_iterator_013bc09ec998c2a7: function() {\n const ret = Symbol.iterator;\n return addHeapObject(ret);\n },\n __wbg_length_9f1775224cf1d815: function(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n },\n __wbg_localStorage_f5f66b1ffd2486bc: function() { return handleError(function (arg0) {\n const ret = getObject(arg0).localStorage;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n }, arguments); },\n __wbg_log_0c201ade58bb55e1: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.log(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7));\n } finally {\n wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_log_7e1aa9064a1dbdbd: function(arg0) {\n console.log(getObject(arg0));\n },\n __wbg_log_ce2c4456b290c5e7: function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.log(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_mark_b4d943f3bc2d2404: function(arg0, arg1) {\n performance.mark(getStringFromWasm0(arg0, arg1));\n },\n __wbg_measure_84362959e621a2c1: function() { return handleError(function (arg0, arg1, arg2, arg3) {\n let deferred0_0;\n let deferred0_1;\n let deferred1_0;\n let deferred1_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n deferred1_0 = arg2;\n deferred1_1 = arg3;\n performance.measure(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));\n } finally {\n wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);\n wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);\n }\n }, arguments); },\n __wbg_message_cb4f84ee66e5e341: function(arg0) {\n const ret = getObject(arg0).message;\n return addHeapObject(ret);\n },\n __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {\n const ret = getObject(arg0).msCrypto;\n return addHeapObject(ret);\n },\n __wbg_name_d3c35622d14bb080: function(arg0) {\n const ret = getObject(arg0).name;\n return addHeapObject(ret);\n },\n __wbg_new_0c7403db6e782f19: function(arg0) {\n const ret = new Uint8Array(getObject(arg0));\n return addHeapObject(ret);\n },\n __wbg_new_15a4889b4b90734d: function() { return handleError(function () {\n const ret = new Headers();\n return addHeapObject(ret);\n }, arguments); },\n __wbg_new_2a6e9133304ae2bf: function() { return handleError(function (arg0, arg1) {\n const ret = new WebSocket(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_new_4331d3ba658c037d: function() { return handleError(function () {\n const ret = new URLSearchParams();\n return addHeapObject(ret);\n }, arguments); },\n __wbg_new_490db15a0a09fb24: function() { return handleError(function (arg0, arg1) {\n const ret = new URL(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_new_98c22165a42231aa: function() { return handleError(function () {\n const ret = new AbortController();\n return addHeapObject(ret);\n }, arguments); },\n __wbg_new_aa8d0fa9762c29bd: function() {\n const ret = new Object();\n return addHeapObject(ret);\n },\n __wbg_new_from_slice_b5ea43e23f6008c0: function(arg0, arg1) {\n const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));\n return addHeapObject(ret);\n },\n __wbg_new_with_length_8c854e41ea4dae9b: function(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return addHeapObject(ret);\n },\n __wbg_new_with_str_5f3ca98523ee76ef: function() { return handleError(function (arg0, arg1) {\n const ret = new Request(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_new_with_str_and_init_897be1708e42f39d: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_next_0340c4ae324393c3: function() { return handleError(function (arg0) {\n const ret = getObject(arg0).next();\n return addHeapObject(ret);\n }, arguments); },\n __wbg_next_7646edaa39458ef7: function(arg0) {\n const ret = getObject(arg0).next;\n return addHeapObject(ret);\n },\n __wbg_node_84ea875411254db1: function(arg0) {\n const ret = getObject(arg0).node;\n return addHeapObject(ret);\n },\n __wbg_now_a9b7df1cbee90986: function() {\n const ret = Date.now();\n return ret;\n },\n __wbg_now_cace042f68c814d8: function(arg0) {\n const ret = getObject(arg0).now();\n return ret;\n },\n __wbg_performance_5fc5a6563dcd33de: function(arg0) {\n const ret = getObject(arg0).performance;\n return addHeapObject(ret);\n },\n __wbg_process_44c7a14e11e9f69e: function(arg0) {\n const ret = getObject(arg0).process;\n return addHeapObject(ret);\n },\n __wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {\n Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));\n },\n __wbg_queueMicrotask_5d15a957e6aa920e: function(arg0) {\n queueMicrotask(getObject(arg0));\n },\n __wbg_queueMicrotask_f8819e5ffc402f36: function(arg0) {\n const ret = getObject(arg0).queueMicrotask;\n return addHeapObject(ret);\n },\n __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {\n getObject(arg0).randomFillSync(takeObject(arg1));\n }, arguments); },\n __wbg_read_ddc2d178d2e57272: function(arg0) {\n const ret = getObject(arg0).read();\n return addHeapObject(ret);\n },\n __wbg_removeItem_487c385a3066a8ed: function() { return handleError(function (arg0, arg1, arg2) {\n getObject(arg0).removeItem(getStringFromWasm0(arg1, arg2));\n }, arguments); },\n __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {\n const ret = module.require;\n return addHeapObject(ret);\n }, arguments); },\n __wbg_resolve_e6c466bc1052f16c: function(arg0) {\n const ret = Promise.resolve(getObject(arg0));\n return addHeapObject(ret);\n },\n __wbg_search_98479a9dd6b1643e: function(arg0, arg1) {\n const ret = getObject(arg1).search;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_send_15358dbe221c6258: function() { return handleError(function (arg0, arg1, arg2) {\n getObject(arg0).send(getStringFromWasm0(arg1, arg2));\n }, arguments); },\n __wbg_send_9ee7ecd8802698d0: function() { return handleError(function (arg0, arg1) {\n getObject(arg0).send(getObject(arg1));\n }, arguments); },\n __wbg_setInterval_84b64f01452a246e: function() { return handleError(function (arg0, arg1) {\n const ret = setInterval(getObject(arg0), arg1);\n return addHeapObject(ret);\n }, arguments); },\n __wbg_setItem_e6399d3faae141dc: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {\n getObject(arg0).setItem(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));\n }, arguments); },\n __wbg_setTimeout_ef24d2fc3ad97385: function() { return handleError(function (arg0, arg1) {\n const ret = setTimeout(getObject(arg0), arg1);\n return addHeapObject(ret);\n }, arguments); },\n __wbg_set_1ffc463d4c541483: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {\n getObject(arg0).set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));\n }, arguments); },\n __wbg_set_binaryType_770e68648ca5e83d: function(arg0, arg1) {\n getObject(arg0).binaryType = __wbindgen_enum_BinaryType[arg1];\n },\n __wbg_set_body_be11680f34217f75: function(arg0, arg1) {\n getObject(arg0).body = getObject(arg1);\n },\n __wbg_set_credentials_6577be90e0e85eb6: function(arg0, arg1) {\n getObject(arg0).credentials = __wbindgen_enum_RequestCredentials[arg1];\n },\n __wbg_set_headers_50fc01786240a440: function(arg0, arg1) {\n getObject(arg0).headers = getObject(arg1);\n },\n __wbg_set_method_c9f1f985f6b6c427: function(arg0, arg1, arg2) {\n getObject(arg0).method = getStringFromWasm0(arg1, arg2);\n },\n __wbg_set_mode_5e08d503428c06b9: function(arg0, arg1) {\n getObject(arg0).mode = __wbindgen_enum_RequestMode[arg1];\n },\n __wbg_set_onclose_17fa3bbcc4ba3541: function(arg0, arg1) {\n getObject(arg0).onclose = getObject(arg1);\n },\n __wbg_set_onerror_da99c4232662a084: function(arg0, arg1) {\n getObject(arg0).onerror = getObject(arg1);\n },\n __wbg_set_onmessage_c1db358b9c38e3f1: function(arg0, arg1) {\n getObject(arg0).onmessage = getObject(arg1);\n },\n __wbg_set_search_2982fabf5212b32d: function(arg0, arg1, arg2) {\n getObject(arg0).search = getStringFromWasm0(arg1, arg2);\n },\n __wbg_set_signal_1d4e73c2305a0e7c: function(arg0, arg1) {\n getObject(arg0).signal = getObject(arg1);\n },\n __wbg_signal_fdc54643b47bf85b: function(arg0) {\n const ret = getObject(arg0).signal;\n return addHeapObject(ret);\n },\n __wbg_static_accessor_GLOBAL_8cfadc87a297ca02: function() {\n const ret = typeof global === 'undefined' ? null : global;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n },\n __wbg_static_accessor_GLOBAL_THIS_602256ae5c8f42cf: function() {\n const ret = typeof globalThis === 'undefined' ? null : globalThis;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n },\n __wbg_static_accessor_SELF_e445c1c7484aecc3: function() {\n const ret = typeof self === 'undefined' ? null : self;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n },\n __wbg_static_accessor_WINDOW_f20e8576ef1e0f17: function() {\n const ret = typeof window === 'undefined' ? null : window;\n return isLikeNone(ret) ? 0 : addHeapObject(ret);\n },\n __wbg_status_43e0d2f15b22d69f: function(arg0) {\n const ret = getObject(arg0).status;\n return ret;\n },\n __wbg_stringify_91082ed7a5a5769e: function() { return handleError(function (arg0) {\n const ret = JSON.stringify(getObject(arg0));\n return addHeapObject(ret);\n }, arguments); },\n __wbg_subarray_f8ca46a25b1f5e0d: function(arg0, arg1, arg2) {\n const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n },\n __wbg_then_792e0c862b060889: function(arg0, arg1, arg2) {\n const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n },\n __wbg_then_8e16ee11f05e4827: function(arg0, arg1) {\n const ret = getObject(arg0).then(getObject(arg1));\n return addHeapObject(ret);\n },\n __wbg_toString_306ed0b9f320c1ca: function(arg0) {\n const ret = getObject(arg0).toString();\n return addHeapObject(ret);\n },\n __wbg_toString_6dc1a94e0bdba378: function(arg0) {\n const ret = getObject(arg0).toString();\n return addHeapObject(ret);\n },\n __wbg_url_2bf741820e6563a0: function(arg0, arg1) {\n const ret = getObject(arg1).url;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_url_94ef047be3ab790a: function(arg0, arg1) {\n const ret = getObject(arg1).url;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_value_ee3a06f4579184fa: function(arg0) {\n const ret = getObject(arg0).value;\n return addHeapObject(ret);\n },\n __wbg_versions_276b2795b1c6a219: function(arg0) {\n const ret = getObject(arg0).versions;\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 198, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.\n const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2406);\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000002: function(arg0, arg1) {\n // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref(\"Event\")], shim_idx: 62, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.\n const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2239);\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000003: function(arg0, arg1) {\n // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref(\"MessageEvent\")], shim_idx: 62, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.\n const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2239_2);\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000004: function(arg0, arg1) {\n // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 111, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.\n const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2246);\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000005: function(arg0, arg1) {\n // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref(\"Uint8Array\")`.\n const ret = getArrayU8FromWasm0(arg0, arg1);\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000006: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n },\n __wbindgen_object_clone_ref: function(arg0) {\n const ret = getObject(arg0);\n return addHeapObject(ret);\n },\n __wbindgen_object_drop_ref: function(arg0) {\n takeObject(arg0);\n },\n };\n return {\n __proto__: null,\n \"./axiom_runtime_bg.js\": import0,\n };\n }\n\n function __wasm_bindgen_func_elem_2246(arg0, arg1) {\n wasm.__wasm_bindgen_func_elem_2246(arg0, arg1);\n }\n\n function __wasm_bindgen_func_elem_2239(arg0, arg1, arg2) {\n wasm.__wasm_bindgen_func_elem_2239(arg0, arg1, addHeapObject(arg2));\n }\n\n function __wasm_bindgen_func_elem_2239_2(arg0, arg1, arg2) {\n wasm.__wasm_bindgen_func_elem_2239_2(arg0, arg1, addHeapObject(arg2));\n }\n\n function __wasm_bindgen_func_elem_2406(arg0, arg1, arg2) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.__wasm_bindgen_func_elem_2406(retptr, arg0, arg1, addHeapObject(arg2));\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n if (r1) {\n throw takeObject(r0);\n }\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n\n\n const __wbindgen_enum_BinaryType = [\"blob\", \"arraybuffer\"];\n\n\n const __wbindgen_enum_RequestCredentials = [\"omit\", \"same-origin\", \"include\"];\n\n\n const __wbindgen_enum_RequestMode = [\"same-origin\", \"no-cors\", \"cors\", \"navigate\"];\n\n function addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n }\n\n const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(state => wasm.__wbindgen_export5(state.a, state.b));\n\n function debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches && builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n }\n\n function dropObject(idx) {\n if (idx < 1028) return;\n heap[idx] = heap_next;\n heap_next = idx;\n }\n\n function getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n }\n\n let cachedDataViewMemory0 = null;\n function getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n }\n\n function getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n }\n\n let cachedUint8ArrayMemory0 = null;\n function getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n }\n\n function getObject(idx) { return heap[idx]; }\n\n function handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n wasm.__wbindgen_export3(addHeapObject(e));\n }\n }\n\n let heap = new Array(1024).fill(undefined);\n heap.push(undefined, null, true, false);\n\n let heap_next = heap.length;\n\n function isLikeNone(x) {\n return x === undefined || x === null;\n }\n\n function makeMutClosure(arg0, arg1, f) {\n const state = { a: arg0, b: arg1, cnt: 1 };\n const real = (...args) => {\n\n // First up with a closure we increment the internal reference\n // count. This ensures that the Rust closure environment won't\n // be deallocated while we're invoking it.\n state.cnt++;\n const a = state.a;\n state.a = 0;\n try {\n return f(a, state.b, ...args);\n } finally {\n state.a = a;\n real._wbg_cb_unref();\n }\n };\n real._wbg_cb_unref = () => {\n if (--state.cnt === 0) {\n wasm.__wbindgen_export5(state.a, state.b);\n state.a = 0;\n CLOSURE_DTORS.unregister(state);\n }\n };\n CLOSURE_DTORS.register(real, state, state);\n return real;\n }\n\n function passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n }\n\n function takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n }\n\n let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n function decodeText(ptr, len) {\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n }\n\n const cachedTextEncoder = new TextEncoder();\n\n if (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n }\n\n let WASM_VECTOR_LEN = 0;\n\n let wasmModule, wasm;\n function __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n return wasm;\n }\n\n async function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n }\n\n function initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n }\n\n async function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined && script_src !== undefined) {\n module_or_path = script_src.replace(/\\.js$/, \"_bg.wasm\");\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n }\n\n return Object.assign(__wbg_init, { initSync }, exports);\n})({ __proto__: null });\n", c = null;
|
|
108
|
+
function l(e) {
|
|
109
|
+
if (e.length === 0) return 0;
|
|
110
|
+
let t = c.axiom_malloc(e.length);
|
|
111
|
+
return new Uint8Array(c.memory.buffer).set(e, t), t;
|
|
112
|
+
}
|
|
113
|
+
function u(e) {
|
|
114
|
+
if (!e) return {
|
|
115
|
+
ptr: 0,
|
|
116
|
+
len: 0
|
|
117
|
+
};
|
|
118
|
+
let t = new TextEncoder().encode(e);
|
|
119
|
+
return {
|
|
120
|
+
ptr: l(t),
|
|
121
|
+
len: t.length
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function d() {
|
|
125
|
+
return "https://atmx.axiomcore.dev/latest/axiom_runtime.wasm";
|
|
126
|
+
}
|
|
127
|
+
async function f(e) {
|
|
128
|
+
let t = performance.now(), r = {
|
|
129
|
+
ok: !1,
|
|
130
|
+
contracts: {},
|
|
131
|
+
initDurationMs: 0
|
|
132
|
+
};
|
|
133
|
+
try {
|
|
134
|
+
if (!window.wasm_bindgen) {
|
|
135
|
+
let e = document.createElement("script");
|
|
136
|
+
e.type = "text/javascript", e.text = `${s}\nwindow.wasm_bindgen = wasm_bindgen;`, document.head.appendChild(e);
|
|
137
|
+
}
|
|
138
|
+
let t = window.wasm_bindgen, a = `${d()}?t=${Date.now()}`;
|
|
139
|
+
try {
|
|
140
|
+
c = await t(fetch(a));
|
|
141
|
+
} catch (e) {
|
|
142
|
+
throw {
|
|
143
|
+
stage: "ffiBoundary",
|
|
144
|
+
category: "network",
|
|
145
|
+
code: "WasmFetchFailed",
|
|
146
|
+
message: `Failed to download WASM engine: ${e.message}`,
|
|
147
|
+
retryable: !0
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
n(c), setInterval(() => {
|
|
151
|
+
c && c.axiom_process_responses();
|
|
152
|
+
}, 16);
|
|
153
|
+
let o = u(""), f = c.axiom_wasm_initialize(o.ptr, o.len);
|
|
154
|
+
if (c.axiom_free_memory(o.ptr, o.len), f !== 0) throw {
|
|
155
|
+
stage: "runtime",
|
|
156
|
+
category: "server",
|
|
157
|
+
code: "InitFailed",
|
|
158
|
+
message: `Engine init failed (Code: ${f})`,
|
|
159
|
+
retryable: !1
|
|
160
|
+
};
|
|
161
|
+
for (let [t, n] of Object.entries(e.contracts)) try {
|
|
162
|
+
let a = await fetch(n.contractUrl);
|
|
163
|
+
if (!a.ok) throw Error(`HTTP ${a.status}`);
|
|
164
|
+
let o = await a.arrayBuffer(), s = 0;
|
|
165
|
+
try {
|
|
166
|
+
let e = new TextDecoder().decode(o), n = JSON.parse(e), r = n?.ir?.endpoints;
|
|
167
|
+
r && (s = Array.isArray(r) ? r.length : Object.keys(r).length), i(t, n);
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.error(`ATMX: Failed to parse .axiom contract for '${t}'`, e);
|
|
170
|
+
}
|
|
171
|
+
let d = new Uint8Array(o), f = l(d), p = u(t), m = u(n.baseUrl), h = c.axiom_wasm_load_contract(p.ptr, p.len, m.ptr, m.len, f, d.length, 0, 0, 0, 0);
|
|
172
|
+
if (c.axiom_free_memory(f, d.length), c.axiom_free_memory(p.ptr, p.len), c.axiom_free_memory(m.ptr, m.len), h !== 0 && h !== -1) throw Error(`Load error (Code: ${h})`);
|
|
173
|
+
e.debug && console.log(`%c🔒 Axiom Contract Loaded: ${t} (${s} endpoints)`, "color: #10b981; font-weight: bold;"), r.contracts[t] = {
|
|
174
|
+
loaded: !0,
|
|
175
|
+
endpointCount: s
|
|
176
|
+
}, document.dispatchEvent(new CustomEvent("atmx:contract-loaded", { detail: {
|
|
177
|
+
namespace: t,
|
|
178
|
+
endpointCount: s
|
|
179
|
+
} }));
|
|
180
|
+
} catch (e) {
|
|
181
|
+
r.contracts[t] = {
|
|
182
|
+
loaded: !1,
|
|
183
|
+
endpointCount: 0,
|
|
184
|
+
error: e.message
|
|
185
|
+
}, console.error(`ATMX: Contract failed for ${t}`, e);
|
|
186
|
+
}
|
|
187
|
+
r.ok = !0;
|
|
188
|
+
} catch (e) {
|
|
189
|
+
r.ok = !1, r.error = e.stage ? e : {
|
|
190
|
+
stage: "runtime",
|
|
191
|
+
category: "unknown",
|
|
192
|
+
code: "FatalError",
|
|
193
|
+
message: e.message || String(e),
|
|
194
|
+
retryable: !1
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return r.initDurationMs = Math.round(performance.now() - t), r;
|
|
198
|
+
}
|
|
199
|
+
function p(e, t, n) {
|
|
200
|
+
if (!c) return;
|
|
201
|
+
let r = u(e), i = u(t), a = u(n);
|
|
202
|
+
c.axiom_wasm_set_auth_token(r.ptr, r.len, i.ptr, i.len, a.ptr, a.len), c.axiom_free_memory(r.ptr, r.len), c.axiom_free_memory(i.ptr, i.len), c.axiom_free_memory(a.ptr, a.len);
|
|
203
|
+
}
|
|
204
|
+
function m(e, t) {
|
|
205
|
+
if (!c) return;
|
|
206
|
+
let n = u(e), r = u(t);
|
|
207
|
+
c.axiom_wasm_clear_auth_token(n.ptr, n.len, r.ptr, r.len), c.axiom_free_memory(n.ptr, n.len), c.axiom_free_memory(r.ptr, r.len);
|
|
208
|
+
}
|
|
209
|
+
function h(e, t) {
|
|
210
|
+
if (!c) return;
|
|
211
|
+
let n = new TextEncoder().encode(JSON.stringify(t)), r = l(n);
|
|
212
|
+
c.axiom_wasm_send_stream_message(e, r, n.length), c.axiom_free_memory(r, n.length);
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
2
215
|
//#region src/resolver/evaluator.ts
|
|
3
|
-
function
|
|
216
|
+
function g(e, t, n = {}) {
|
|
4
217
|
if (e) try {
|
|
5
218
|
let r = Object.keys(n), i = Object.values(n);
|
|
6
219
|
return Function("$data", "$error", "$state", ...r, `return (${e});`)(t.data || {}, t.error || {}, t, ...i);
|
|
@@ -9,7 +222,7 @@ function u(e, t, n = {}) {
|
|
|
9
222
|
return;
|
|
10
223
|
}
|
|
11
224
|
}
|
|
12
|
-
function
|
|
225
|
+
function _(e, t, n = {}) {
|
|
13
226
|
if (e) try {
|
|
14
227
|
let r = Object.keys(n), i = Object.values(n);
|
|
15
228
|
Function("$data", "$error", "$state", ...r, e)(t.data || {}, t.error || {}, t, ...i);
|
|
@@ -19,17 +232,17 @@ function d(e, t, n = {}) {
|
|
|
19
232
|
}
|
|
20
233
|
//#endregion
|
|
21
234
|
//#region src/resolver/render.ts
|
|
22
|
-
function
|
|
23
|
-
|
|
235
|
+
function v(e, t) {
|
|
236
|
+
y(e, t, !0, {});
|
|
24
237
|
}
|
|
25
|
-
function
|
|
238
|
+
function y(e, t, n, r) {
|
|
26
239
|
if (!(!n && (e.hasAttribute("ax-query") || e.hasAttribute("ax-mutate")))) {
|
|
27
240
|
if (e.hasAttribute("ax-for")) {
|
|
28
|
-
|
|
241
|
+
b(e, t, r);
|
|
29
242
|
return;
|
|
30
243
|
}
|
|
31
|
-
if (e.hasAttribute("ax-when") && (e.getAttribute("ax-when").split(",").map((e) => e.trim()).includes(t.state) ? (e.removeAttribute("hidden"), e.style.removeProperty("display")) : (e.setAttribute("hidden", "true"), e.style.setProperty("display", "none", "important"))), e.hasAttribute("ax-if") && (
|
|
32
|
-
let n =
|
|
244
|
+
if (e.hasAttribute("ax-when") && (e.getAttribute("ax-when").split(",").map((e) => e.trim()).includes(t.state) ? (e.removeAttribute("hidden"), e.style.removeProperty("display")) : (e.setAttribute("hidden", "true"), e.style.setProperty("display", "none", "important"))), e.hasAttribute("ax-if") && (g(e.getAttribute("ax-if"), t, r) ? (e.removeAttribute("hidden"), e.style.removeProperty("display")) : (e.setAttribute("hidden", ""), e.style.setProperty("display", "none", "important"))), e.hasAttribute("ax-text")) {
|
|
245
|
+
let n = g(e.getAttribute("ax-text"), t, r);
|
|
33
246
|
e.textContent = n == null ? "" : String(n);
|
|
34
247
|
}
|
|
35
248
|
if (e.hasAttribute("ax-error-for")) {
|
|
@@ -45,71 +258,71 @@ function p(e, t, n, r) {
|
|
|
45
258
|
}
|
|
46
259
|
Array.from(e.attributes).forEach((n) => {
|
|
47
260
|
if (n.name.startsWith("ax-bind:")) {
|
|
48
|
-
let i = n.name.substring(8), a =
|
|
261
|
+
let i = n.name.substring(8), a = g(n.value, t, r);
|
|
49
262
|
a === !1 || a == null ? e.removeAttribute(i) : e.setAttribute(i, a === !0 ? i : String(a));
|
|
50
263
|
}
|
|
51
264
|
}), Array.from(e.children).forEach((e) => {
|
|
52
|
-
|
|
265
|
+
y(e, t, !1, r);
|
|
53
266
|
});
|
|
54
267
|
}
|
|
55
268
|
}
|
|
56
|
-
function
|
|
269
|
+
function b(e, t, n) {
|
|
57
270
|
e.style.display = "none", e.hasAttribute("data-ax-for-id") || e.setAttribute("data-ax-for-id", Math.random().toString(36).substr(2, 9));
|
|
58
271
|
let r = e.getAttribute("data-ax-for-id"), i = e.getAttribute("ax-for").match(/^\s*(?:(?:\(\s*([\w\$]+)\s*,\s*([\w\$]+)\s*\))|([\w\$]+))\s+in\s+(.+)$/);
|
|
59
272
|
if (!i) return;
|
|
60
|
-
let a = i[1] || i[3], o = i[2], s = i[4], c =
|
|
273
|
+
let a = i[1] || i[3], o = i[2], s = i[4], c = g(s, t, n), l = e.parentElement;
|
|
61
274
|
if (!l) return;
|
|
62
|
-
let
|
|
275
|
+
let u = Array.from(l.querySelectorAll(`[data-ax-clone-of="${r}"]`));
|
|
63
276
|
if (!c || !Array.isArray(c)) {
|
|
64
|
-
|
|
277
|
+
u.forEach((e) => e.remove());
|
|
65
278
|
return;
|
|
66
279
|
}
|
|
67
|
-
let
|
|
280
|
+
let d = e.getAttribute("ax-key"), f = [];
|
|
68
281
|
c.forEach((i, s) => {
|
|
69
282
|
let c = {
|
|
70
283
|
...n,
|
|
71
284
|
[a]: i
|
|
72
285
|
};
|
|
73
286
|
o && (c[o] = s);
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
|
|
287
|
+
let p = String(s);
|
|
288
|
+
d && (p = String(g(d, t, c)));
|
|
289
|
+
let m = u.find((e) => e.getAttribute("data-ax-key") === p);
|
|
290
|
+
m || (m = e.cloneNode(!0), m.removeAttribute("ax-for"), m.style.removeProperty("display"), m.style.length === 0 && m.removeAttribute("style"), m.setAttribute("data-ax-clone-of", r), m.setAttribute("data-ax-key", p)), l.insertBefore(m, e), y(m, t, !1, c), f.push(m);
|
|
291
|
+
}), u.forEach((e) => {
|
|
292
|
+
f.includes(e) || e.remove();
|
|
80
293
|
});
|
|
81
294
|
}
|
|
82
295
|
//#endregion
|
|
83
296
|
//#region src/core/context.ts
|
|
84
|
-
var
|
|
85
|
-
function
|
|
86
|
-
return
|
|
297
|
+
var x = /* @__PURE__ */ new WeakMap();
|
|
298
|
+
function S(e) {
|
|
299
|
+
return x.has(e) || x.set(e, {
|
|
87
300
|
state: "idle",
|
|
88
301
|
isFetching: !1,
|
|
89
302
|
isMutating: !1,
|
|
90
303
|
source: null,
|
|
91
304
|
data: null,
|
|
92
305
|
error: null
|
|
93
|
-
}),
|
|
306
|
+
}), x.get(e);
|
|
94
307
|
}
|
|
95
|
-
function
|
|
308
|
+
function C(e) {
|
|
96
309
|
let t = e.parentElement;
|
|
97
310
|
for (; t;) {
|
|
98
311
|
if (t.hasAttribute("ax-query") || t.hasAttribute("ax-mutate")) {
|
|
99
|
-
let e =
|
|
312
|
+
let e = x.get(t);
|
|
100
313
|
if (e && e.data) return e.data;
|
|
101
314
|
}
|
|
102
315
|
t = t.parentElement;
|
|
103
316
|
}
|
|
104
317
|
return {};
|
|
105
318
|
}
|
|
106
|
-
function
|
|
107
|
-
let n =
|
|
108
|
-
Object.assign(n, t), t.state === "loading" && (n.isFetching = !0), t.state === "mutating" && (n.isMutating = !0), (t.state === "success" || t.state === "data" && t.isFetching === !1) && (n.isFetching = !1, n.isMutating = !1),
|
|
319
|
+
function w(e, t) {
|
|
320
|
+
let n = S(e);
|
|
321
|
+
Object.assign(n, t), t.state === "loading" && (n.isFetching = !0), t.state === "mutating" && (n.isMutating = !0), (t.state === "success" || t.state === "data" && t.isFetching === !1) && (n.isFetching = !1, n.isMutating = !1), x.set(e, n), v(e, n);
|
|
109
322
|
}
|
|
110
323
|
//#endregion
|
|
111
324
|
//#region src/core/query.ts
|
|
112
|
-
var
|
|
325
|
+
var T = 0, E = class {
|
|
113
326
|
key;
|
|
114
327
|
route;
|
|
115
328
|
args;
|
|
@@ -134,66 +347,66 @@ var y = 0, b = class {
|
|
|
134
347
|
...e
|
|
135
348
|
}, this.listeners.forEach((e) => e(this.state));
|
|
136
349
|
}
|
|
137
|
-
fetch(
|
|
138
|
-
if (this.state.isFetching && !
|
|
350
|
+
fetch(n = !1) {
|
|
351
|
+
if (this.state.isFetching && !n) return;
|
|
139
352
|
this.update({
|
|
140
353
|
state: this.state.data ? "data" : "loading",
|
|
141
354
|
isFetching: !0,
|
|
142
355
|
error: null
|
|
143
356
|
});
|
|
144
|
-
let r = ++
|
|
357
|
+
let r = ++T;
|
|
145
358
|
this.currentReqId = r;
|
|
146
|
-
let { path: i, remainingArgs:
|
|
147
|
-
Object.keys(
|
|
359
|
+
let { path: i, remainingArgs: a } = o(this.route, this.args), s = new Uint8Array();
|
|
360
|
+
Object.keys(a).length > 0 && (s = new TextEncoder().encode(JSON.stringify(a))), H.debug && (console.groupCollapsed(`%c➔ WASM QUERY [#${r}]`, "color: #7c3aed; font-weight: bold;"), console.log("Namespace:", this.route.namespace), console.log("Endpoint ID:", this.route.id), console.log("Path:", i), console.groupEnd()), t.set(r, {
|
|
148
361
|
isStream: this.route.isStream,
|
|
149
|
-
onResponse: (
|
|
362
|
+
onResponse: (t) => {
|
|
150
363
|
if (this.currentReqId === r) {
|
|
151
|
-
if (
|
|
152
|
-
let
|
|
153
|
-
console.groupCollapsed(`%c← WASM RESP [#${r}]`, "color: #059669; font-weight: bold;"), console.log("Event Type:",
|
|
364
|
+
if (H.debug) {
|
|
365
|
+
let e = t.eventType === 1 ? "NetworkSuccess" : t.eventType === 2 ? "CacheHit" : t.eventType === 3 ? "CacheHitAndFetching" : t.eventType === 4 ? "Error" : "Complete";
|
|
366
|
+
console.groupCollapsed(`%c← WASM RESP [#${r}]`, "color: #059669; font-weight: bold;"), console.log("Event Type:", e), t.data && console.log("Data:", t.data), t.error && console.log("Error:", t.error), console.groupEnd();
|
|
154
367
|
}
|
|
155
|
-
if (
|
|
368
|
+
if (t.eventType === e.Error) {
|
|
156
369
|
this.update({
|
|
157
370
|
state: "error",
|
|
158
|
-
error:
|
|
371
|
+
error: t.error,
|
|
159
372
|
isFetching: !1
|
|
160
373
|
});
|
|
161
374
|
return;
|
|
162
375
|
}
|
|
163
|
-
if (
|
|
164
|
-
let
|
|
165
|
-
|
|
376
|
+
if (t.data) {
|
|
377
|
+
let n = "network", r = !1;
|
|
378
|
+
t.eventType === e.CacheHit ? (n = "cache", r = !1) : t.eventType === e.CacheHitAndFetching ? (n = "cache", r = !0) : t.eventType === e.NetworkSuccess && (n = "network", r = !1), this.update({
|
|
166
379
|
state: "data",
|
|
167
|
-
data:
|
|
168
|
-
source:
|
|
380
|
+
data: t.data,
|
|
381
|
+
source: n,
|
|
169
382
|
isFetching: r
|
|
170
383
|
});
|
|
171
384
|
}
|
|
172
385
|
}
|
|
173
386
|
},
|
|
174
387
|
onComplete: () => {
|
|
175
|
-
this.currentReqId === r && (
|
|
388
|
+
this.currentReqId === r && (H.debug && console.log(`%c✔ Stream Complete [#${r}]`, "color: #94a3b8;"), this.update({ isFetching: !1 }));
|
|
176
389
|
}
|
|
177
390
|
});
|
|
178
|
-
let d =
|
|
179
|
-
|
|
391
|
+
let d = u(this.route.namespace), f = u(this.route.method), p = u(i), m = l(s), h = u(""), g = u("");
|
|
392
|
+
c.axiom_wasm_call(r, d.ptr, d.len, this.route.id, f.ptr, f.len, p.ptr, p.len, h.ptr, h.len, g.ptr, g.len, m, s.length), c.axiom_free_memory(d.ptr, d.len), c.axiom_free_memory(f.ptr, f.len), c.axiom_free_memory(p.ptr, p.len), c.axiom_free_memory(h.ptr, h.len), c.axiom_free_memory(g.ptr, g.len);
|
|
180
393
|
}
|
|
181
|
-
},
|
|
182
|
-
function
|
|
394
|
+
}, D = /* @__PURE__ */ new Map(), O = 0;
|
|
395
|
+
function k(e, t) {
|
|
183
396
|
let n = `ax-on:${t}`;
|
|
184
|
-
e.hasAttribute(n) &&
|
|
397
|
+
e.hasAttribute(n) && _(e.getAttribute(n), S(e));
|
|
185
398
|
}
|
|
186
|
-
function
|
|
187
|
-
if (!
|
|
399
|
+
function A(e, t, n) {
|
|
400
|
+
if (!H.debug) return;
|
|
188
401
|
let r = e === "OUT" ? "#7c3aed" : "#059669";
|
|
189
402
|
console.groupCollapsed(`%c${e === "OUT" ? "➔ WASM CALL" : "← WASM RESP"} [#${t}]`, `color: ${r}; font-weight: bold;`), console.log("Details:", n), console.groupEnd();
|
|
190
403
|
}
|
|
191
|
-
function
|
|
404
|
+
function j(e, t) {
|
|
192
405
|
let n = t.trim().match(/^([\w\.]+)(?:\((.*)\))?$/);
|
|
193
406
|
if (!n) return null;
|
|
194
407
|
let r = n[1], i = {};
|
|
195
408
|
if (n[2] && n[2].trim() !== "") try {
|
|
196
|
-
let t =
|
|
409
|
+
let t = S(e), r = t.data || C(e);
|
|
197
410
|
i = Function("$data", "$state", `return (${n[2]});`)(r, t) || {};
|
|
198
411
|
} catch (e) {
|
|
199
412
|
console.error(`ATMX Scope Error in "${t}":`, e);
|
|
@@ -203,61 +416,61 @@ function T(e, t) {
|
|
|
203
416
|
args: i
|
|
204
417
|
};
|
|
205
418
|
}
|
|
206
|
-
function
|
|
419
|
+
function M(e) {
|
|
207
420
|
let t = e.getAttribute("ax-query");
|
|
208
421
|
if (!t) return;
|
|
209
|
-
let n =
|
|
422
|
+
let n = j(e, t);
|
|
210
423
|
if (!n) return;
|
|
211
|
-
let r =
|
|
424
|
+
let r = a(n.target);
|
|
212
425
|
if (!r) {
|
|
213
|
-
|
|
426
|
+
w(e, {
|
|
214
427
|
state: "error",
|
|
215
428
|
error: { message: `Route not found: ${n.target}` }
|
|
216
429
|
});
|
|
217
430
|
return;
|
|
218
431
|
}
|
|
219
|
-
let
|
|
220
|
-
o || (o = new
|
|
221
|
-
|
|
432
|
+
let i = `${r.namespace}:${r.id}:${JSON.stringify(n.args)}`, o = D.get(i);
|
|
433
|
+
o || (o = new E(i, r, n.args), D.set(i, o)), e._axListener || (e._axListener = (t) => {
|
|
434
|
+
w(e, t), (t.state === "data" || t.state === "error") && (k(e, t.state), e.dispatchEvent(new CustomEvent(`atmx:${t.state}`, {
|
|
222
435
|
bubbles: !0,
|
|
223
436
|
detail: t.data || t.error
|
|
224
437
|
})));
|
|
225
438
|
}, o.subscribe(e._axListener)), o.fetch();
|
|
226
439
|
}
|
|
227
|
-
function
|
|
228
|
-
let
|
|
440
|
+
function N(e) {
|
|
441
|
+
let t = e.getAttribute("ax-mutate");
|
|
442
|
+
if (!t) return;
|
|
443
|
+
let n = j(e, t);
|
|
229
444
|
if (!n) return;
|
|
230
|
-
let r =
|
|
231
|
-
if (!r)
|
|
232
|
-
|
|
233
|
-
if (!a) {
|
|
234
|
-
v(e, {
|
|
445
|
+
let r = a(n.target);
|
|
446
|
+
if (!r) {
|
|
447
|
+
w(e, {
|
|
235
448
|
state: "error",
|
|
236
|
-
error: { message: `Route not found: ${
|
|
237
|
-
}),
|
|
449
|
+
error: { message: `Route not found: ${n.target}` }
|
|
450
|
+
}), k(e, "error");
|
|
238
451
|
return;
|
|
239
452
|
}
|
|
240
|
-
|
|
453
|
+
w(e, {
|
|
241
454
|
state: "mutating",
|
|
242
455
|
error: null,
|
|
243
456
|
data: null
|
|
244
|
-
}),
|
|
245
|
-
let
|
|
457
|
+
}), k(e, "mutating");
|
|
458
|
+
let i = {};
|
|
246
459
|
e instanceof HTMLFormElement && new FormData(e).forEach((t, n) => {
|
|
247
|
-
let r = e.elements.namedItem(n),
|
|
248
|
-
r instanceof HTMLInputElement ?
|
|
249
|
-
let
|
|
460
|
+
let r = e.elements.namedItem(n), a = !1;
|
|
461
|
+
r instanceof HTMLInputElement ? a = r.type === "number" : r instanceof RadioNodeList && r.length > 0 && (a = r[0].type === "number");
|
|
462
|
+
let o = a && t !== "" ? Number(t) : t;
|
|
250
463
|
if (n.includes(".")) {
|
|
251
|
-
let e = n.split("."), t =
|
|
464
|
+
let e = n.split("."), t = i;
|
|
252
465
|
for (let n = 0; n < e.length - 1; n++) t[e[n]] || (t[e[n]] = {}), t = t[e[n]];
|
|
253
|
-
t[e[e.length - 1]] =
|
|
254
|
-
} else
|
|
466
|
+
t[e[e.length - 1]] = o;
|
|
467
|
+
} else i[n] = o;
|
|
255
468
|
});
|
|
256
|
-
let { path: s, remainingArgs: c } =
|
|
257
|
-
...
|
|
258
|
-
...
|
|
469
|
+
let { path: s, remainingArgs: c } = o(r, {
|
|
470
|
+
...i,
|
|
471
|
+
...n.args
|
|
259
472
|
}), l = c;
|
|
260
|
-
|
|
473
|
+
r.bodyParam && c[r.bodyParam] !== void 0 && (l = c[r.bodyParam]);
|
|
261
474
|
let u = {}, d = e.getAttribute("ax-headers");
|
|
262
475
|
if (d) try {
|
|
263
476
|
u = Function("return (" + d + ");")() || {};
|
|
@@ -270,118 +483,118 @@ function D(e) {
|
|
|
270
483
|
for (let [t, n] of Object.entries(l)) e.append(t, String(n));
|
|
271
484
|
p = new TextEncoder().encode(e.toString());
|
|
272
485
|
} else p = new TextEncoder().encode(JSON.stringify(l));
|
|
273
|
-
|
|
486
|
+
P(e, r.namespace, r.id, r.method, s, p, r.isStream, !0, u, f);
|
|
274
487
|
}
|
|
275
|
-
function
|
|
276
|
-
let m = ++
|
|
277
|
-
|
|
278
|
-
namespace:
|
|
279
|
-
endpointId:
|
|
280
|
-
method:
|
|
281
|
-
path:
|
|
488
|
+
function P(e, n, r, i, a, o, s, d, f = {}, p = !1) {
|
|
489
|
+
let m = ++O;
|
|
490
|
+
A("OUT", m, {
|
|
491
|
+
namespace: n,
|
|
492
|
+
endpointId: r,
|
|
493
|
+
method: i,
|
|
494
|
+
path: a,
|
|
282
495
|
headers: f,
|
|
283
|
-
payload:
|
|
284
|
-
}),
|
|
285
|
-
isStream:
|
|
286
|
-
onResponse: (t) =>
|
|
496
|
+
payload: o.length > 0 ? p ? new TextDecoder().decode(o) : JSON.parse(new TextDecoder().decode(o)) : null
|
|
497
|
+
}), t.set(m, {
|
|
498
|
+
isStream: s,
|
|
499
|
+
onResponse: (t) => F(e, t, d, m),
|
|
287
500
|
onComplete: () => {
|
|
288
|
-
|
|
501
|
+
H.debug && console.log(`%c✔ Stream Complete [#${m}]`, "color: #94a3b8;");
|
|
289
502
|
}
|
|
290
503
|
});
|
|
291
|
-
let h =
|
|
292
|
-
|
|
504
|
+
let h = u(n), g = u(i), _ = u(a), v = u(""), y = u(Object.keys(f).length > 0 ? JSON.stringify(f) : ""), b = l(o);
|
|
505
|
+
c.axiom_wasm_call(m, h.ptr, h.len, r, g.ptr, g.len, _.ptr, _.len, v.ptr, v.len, y.ptr, y.len, b, o.length), c.axiom_free_memory(h.ptr, h.len), c.axiom_free_memory(g.ptr, g.len), c.axiom_free_memory(_.ptr, _.len), c.axiom_free_memory(v.ptr, v.len), c.axiom_free_memory(y.ptr, y.len), b && c.axiom_free_memory(b, o.length);
|
|
293
506
|
}
|
|
294
|
-
function
|
|
295
|
-
if (
|
|
296
|
-
eventType: n
|
|
297
|
-
data:
|
|
298
|
-
error:
|
|
299
|
-
}),
|
|
300
|
-
|
|
507
|
+
function F(t, n, r, i) {
|
|
508
|
+
if (A("IN", i, {
|
|
509
|
+
eventType: e[n.eventType],
|
|
510
|
+
data: n.data,
|
|
511
|
+
error: n.error
|
|
512
|
+
}), n.eventType === e.Error) {
|
|
513
|
+
w(t, {
|
|
301
514
|
state: "error",
|
|
302
|
-
error:
|
|
515
|
+
error: n.error,
|
|
303
516
|
isFetching: !1,
|
|
304
517
|
isMutating: !1
|
|
305
|
-
}),
|
|
518
|
+
}), k(t, "error"), t.dispatchEvent(new CustomEvent("atmx:error", {
|
|
306
519
|
bubbles: !0,
|
|
307
|
-
detail:
|
|
520
|
+
detail: n.error
|
|
308
521
|
}));
|
|
309
522
|
return;
|
|
310
523
|
}
|
|
311
|
-
if (
|
|
312
|
-
let
|
|
313
|
-
|
|
524
|
+
if (n.data) {
|
|
525
|
+
let i = "network", o = !1;
|
|
526
|
+
n.eventType === e.CacheHit ? i = "cache" : n.eventType === e.CacheHitAndFetching ? (i = "cache", o = !0) : n.eventType === e.NetworkSuccess && (i = "network");
|
|
314
527
|
let s = r ? "success" : "data";
|
|
315
|
-
if (
|
|
528
|
+
if (w(t, {
|
|
316
529
|
state: s,
|
|
317
|
-
data:
|
|
318
|
-
source:
|
|
530
|
+
data: n.data,
|
|
531
|
+
source: i,
|
|
319
532
|
isFetching: o,
|
|
320
533
|
isMutating: !1
|
|
321
534
|
}), r) {
|
|
322
|
-
let
|
|
323
|
-
if (
|
|
324
|
-
let n =
|
|
535
|
+
let e = t.getAttribute("ax-store-token");
|
|
536
|
+
if (e) {
|
|
537
|
+
let n = g(e, S(t));
|
|
325
538
|
if (n) {
|
|
326
|
-
let
|
|
327
|
-
|
|
539
|
+
let e = a(j(t, t.getAttribute("ax-mutate")).target), r = t.getAttribute("ax-token-header") || "Authorization";
|
|
540
|
+
H.setAuthToken(e?.namespace || "default", r, n);
|
|
328
541
|
}
|
|
329
542
|
}
|
|
330
|
-
if (
|
|
331
|
-
let
|
|
332
|
-
|
|
543
|
+
if (t.hasAttribute("ax-clear-token")) {
|
|
544
|
+
let e = a(j(t, t.getAttribute("ax-mutate")).target), n = t.getAttribute("ax-token-header") || "Authorization";
|
|
545
|
+
H.clearAuthToken(e?.namespace || "default", n);
|
|
333
546
|
}
|
|
334
|
-
let n =
|
|
547
|
+
let n = t.getAttribute("ax-refresh");
|
|
335
548
|
if (n) {
|
|
336
549
|
let e = n.split(",").map((e) => e.trim());
|
|
337
|
-
for (let [t, n] of
|
|
550
|
+
for (let [t, n] of D.entries()) {
|
|
338
551
|
let t = `${n.route.namespace}.${n.route.name}`;
|
|
339
552
|
e.includes(t) && n.fetch(!0);
|
|
340
553
|
}
|
|
341
554
|
}
|
|
342
555
|
}
|
|
343
|
-
|
|
556
|
+
k(t, s), t.dispatchEvent(new CustomEvent(r ? "atmx:success" : "atmx:data", {
|
|
344
557
|
bubbles: !0,
|
|
345
|
-
detail:
|
|
558
|
+
detail: n.data
|
|
346
559
|
}));
|
|
347
560
|
}
|
|
348
561
|
}
|
|
349
562
|
//#endregion
|
|
350
563
|
//#region src/dom/scanner.ts
|
|
351
|
-
var
|
|
564
|
+
var I = new IntersectionObserver((e) => {
|
|
352
565
|
e.forEach((e) => {
|
|
353
566
|
if (e.isIntersecting) {
|
|
354
567
|
let t = e.target;
|
|
355
|
-
t.hasAttribute("ax-query") &&
|
|
568
|
+
t.hasAttribute("ax-query") && M(t), I.unobserve(t);
|
|
356
569
|
}
|
|
357
570
|
});
|
|
358
571
|
});
|
|
359
|
-
function
|
|
572
|
+
function L(e) {
|
|
360
573
|
e.querySelectorAll("[\\:ax-query], [\\:ax-mutate]").forEach((e) => {
|
|
361
574
|
if (e.hasAttribute(":ax-query")) {
|
|
362
|
-
let t =
|
|
575
|
+
let t = g(e.getAttribute(":ax-query"), S(e));
|
|
363
576
|
t && e.setAttribute("ax-query", String(t)), e.removeAttribute(":ax-query");
|
|
364
577
|
}
|
|
365
578
|
if (e.hasAttribute(":ax-mutate")) {
|
|
366
|
-
let t =
|
|
579
|
+
let t = g(e.getAttribute(":ax-mutate"), S(e));
|
|
367
580
|
t && e.setAttribute("ax-mutate", String(t)), e.removeAttribute(":ax-mutate");
|
|
368
581
|
}
|
|
369
582
|
});
|
|
370
583
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
584
|
+
function R(e = document) {
|
|
585
|
+
L(e), e.querySelectorAll("[ax-query]").forEach((e) => {
|
|
373
586
|
let t = e;
|
|
374
|
-
|
|
587
|
+
w(t, {});
|
|
375
588
|
let n = t.getAttribute("ax-trigger") || "load";
|
|
376
|
-
n === "load" ?
|
|
377
|
-
e.preventDefault(),
|
|
589
|
+
n === "load" ? M(t) : n === "intersect" ? I.observe(t) : t.addEventListener(n, (e) => {
|
|
590
|
+
e.preventDefault(), M(t);
|
|
378
591
|
});
|
|
379
592
|
}), e.querySelectorAll("[ax-mutate]").forEach((e) => {
|
|
380
593
|
let t = e;
|
|
381
|
-
|
|
594
|
+
w(t, {});
|
|
382
595
|
let n = t.tagName === "FORM" ? "submit" : "click";
|
|
383
596
|
t.addEventListener(n, (e) => {
|
|
384
|
-
(t.tagName === "A" || t.tagName === "BUTTON" || t.tagName === "FORM") && e.preventDefault(),
|
|
597
|
+
(t.tagName === "A" || t.tagName === "BUTTON" || t.tagName === "FORM") && e.preventDefault(), N(t);
|
|
385
598
|
});
|
|
386
599
|
}), e.querySelectorAll("[ax-trigger=\"refresh\"]").forEach((e) => {
|
|
387
600
|
let t = e;
|
|
@@ -389,23 +602,23 @@ function M(e = document) {
|
|
|
389
602
|
e.preventDefault();
|
|
390
603
|
let n = t.closest("[ax-query]");
|
|
391
604
|
if (n) {
|
|
392
|
-
let e =
|
|
605
|
+
let e = j(n, n.getAttribute("ax-query"));
|
|
393
606
|
if (e) {
|
|
394
|
-
let t =
|
|
607
|
+
let t = a(e.target);
|
|
395
608
|
if (t) {
|
|
396
|
-
let r = `${t.namespace}:${t.id}:${JSON.stringify(e.args)}`, i =
|
|
397
|
-
i ? i.fetch(!0) :
|
|
609
|
+
let r = `${t.namespace}:${t.id}:${JSON.stringify(e.args)}`, i = D.get(r);
|
|
610
|
+
i ? i.fetch(!0) : M(n);
|
|
398
611
|
}
|
|
399
612
|
}
|
|
400
613
|
}
|
|
401
614
|
});
|
|
402
615
|
});
|
|
403
616
|
}
|
|
404
|
-
function
|
|
617
|
+
function z() {
|
|
405
618
|
new MutationObserver((e) => {
|
|
406
619
|
e.forEach((e) => {
|
|
407
620
|
e.addedNodes.forEach((e) => {
|
|
408
|
-
e instanceof HTMLElement &&
|
|
621
|
+
e instanceof HTMLElement && R(e);
|
|
409
622
|
});
|
|
410
623
|
});
|
|
411
624
|
}).observe(document.body, {
|
|
@@ -415,7 +628,7 @@ function N() {
|
|
|
415
628
|
}
|
|
416
629
|
//#endregion
|
|
417
630
|
//#region src/dom/components/engine-status.ts
|
|
418
|
-
var
|
|
631
|
+
var B = class extends HTMLElement {
|
|
419
632
|
constructor() {
|
|
420
633
|
super();
|
|
421
634
|
}
|
|
@@ -436,11 +649,11 @@ var P = class extends HTMLElement {
|
|
|
436
649
|
}) : (this.innerText = t, this.getAttribute("class") || (this.className = `text-xs font-bold ${n}`));
|
|
437
650
|
}
|
|
438
651
|
};
|
|
439
|
-
typeof window < "u" && !customElements.get("ax-engine-status") && customElements.define("ax-engine-status",
|
|
652
|
+
typeof window < "u" && !customElements.get("ax-engine-status") && customElements.define("ax-engine-status", B);
|
|
440
653
|
//#endregion
|
|
441
654
|
//#region src/index.ts
|
|
442
|
-
var
|
|
443
|
-
version =
|
|
655
|
+
var V = "0.63.0", H = new class {
|
|
656
|
+
version = V;
|
|
444
657
|
initialized = !1;
|
|
445
658
|
debug = !1;
|
|
446
659
|
async init(e) {
|
|
@@ -449,26 +662,26 @@ var F = "0.62.0", I = new class {
|
|
|
449
662
|
contracts: {},
|
|
450
663
|
initDurationMs: 0
|
|
451
664
|
};
|
|
452
|
-
let t = await
|
|
453
|
-
return t.ok ? (this.debug = e.debug || !1,
|
|
665
|
+
let t = await f(e);
|
|
666
|
+
return t.ok ? (this.debug = e.debug || !1, z(), R(document.body), this.initialized = !0, this.debug && console.log("%c🚀 ATMX Debug Mode: Enabled", "color: #2563eb; font-weight: bold;"), console.log(`✅ ATMX v${this.version} Online (${t.initDurationMs}ms). Reactive Engine Started.`), document.dispatchEvent(new CustomEvent("atmx:ready", { detail: t }))) : (console.error("❌ ATMX Initialization Failed:", t.error), document.dispatchEvent(new CustomEvent("atmx:error", { detail: t.error }))), t;
|
|
454
667
|
}
|
|
455
668
|
triggerQuery(e) {
|
|
456
669
|
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
457
|
-
t && t instanceof HTMLElement && t.hasAttribute("ax-query") &&
|
|
670
|
+
t && t instanceof HTMLElement && t.hasAttribute("ax-query") && M(t);
|
|
458
671
|
}
|
|
459
672
|
on(e, t) {
|
|
460
673
|
document.addEventListener(`atmx:${e}`, t);
|
|
461
674
|
}
|
|
462
|
-
setAuthToken(t, n
|
|
463
|
-
e
|
|
675
|
+
setAuthToken(e, t, n) {
|
|
676
|
+
p(e, t, n);
|
|
464
677
|
}
|
|
465
678
|
sendStreamMessage(e, t) {
|
|
466
|
-
|
|
679
|
+
h(e, t);
|
|
467
680
|
}
|
|
468
681
|
clearAuthToken(e, t) {
|
|
469
|
-
|
|
682
|
+
m(e, t);
|
|
470
683
|
}
|
|
471
684
|
}();
|
|
472
|
-
typeof window < "u" && (window.atmx =
|
|
685
|
+
typeof window < "u" && (window.atmx = H);
|
|
473
686
|
//#endregion
|
|
474
|
-
export {
|
|
687
|
+
export { V as ATMX_VERSION, l as allocBytes, u as allocString, H as atmx, o as buildRequestPath, m as clearAuthToken, f as initWasm, t as pendingRequests, a as resolveRoute, p as setAuthToken, c as wasmEngine };
|