atmx-web 0.62.0 → 0.64.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 +394 -163
- package/dist/atmx.umd.js +3 -3
- package/dist/dom/lifecycle.d.ts +1 -1
- package/dist/index.d.ts +3 -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,67 +347,69 @@ 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
|
|
192
|
-
let n = t.trim().match(/^([\w
|
|
404
|
+
function j(e, t) {
|
|
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
|
-
|
|
197
|
-
|
|
409
|
+
if (e) {
|
|
410
|
+
let t = S(e), r = t.data || C(e);
|
|
411
|
+
i = Function("$data", "$state", `return (${n[2]});`)(r, t) || {};
|
|
412
|
+
} else i = Function(`return (${n[2]});`)() || {};
|
|
198
413
|
} catch (e) {
|
|
199
414
|
console.error(`ATMX Scope Error in "${t}":`, e);
|
|
200
415
|
}
|
|
@@ -203,61 +418,61 @@ function T(e, t) {
|
|
|
203
418
|
args: i
|
|
204
419
|
};
|
|
205
420
|
}
|
|
206
|
-
function
|
|
421
|
+
function M(e) {
|
|
207
422
|
let t = e.getAttribute("ax-query");
|
|
208
423
|
if (!t) return;
|
|
209
|
-
let n =
|
|
424
|
+
let n = j(e, t);
|
|
210
425
|
if (!n) return;
|
|
211
|
-
let r =
|
|
426
|
+
let r = a(n.target);
|
|
212
427
|
if (!r) {
|
|
213
|
-
|
|
428
|
+
w(e, {
|
|
214
429
|
state: "error",
|
|
215
430
|
error: { message: `Route not found: ${n.target}` }
|
|
216
431
|
});
|
|
217
432
|
return;
|
|
218
433
|
}
|
|
219
|
-
let
|
|
220
|
-
o || (o = new
|
|
221
|
-
|
|
434
|
+
let i = `${r.namespace}:${r.id}:${JSON.stringify(n.args)}`, o = D.get(i);
|
|
435
|
+
o || (o = new E(i, r, n.args), D.set(i, o)), e._axListener || (e._axListener = (t) => {
|
|
436
|
+
w(e, t), (t.state === "data" || t.state === "error") && (k(e, t.state), e.dispatchEvent(new CustomEvent(`atmx:${t.state}`, {
|
|
222
437
|
bubbles: !0,
|
|
223
438
|
detail: t.data || t.error
|
|
224
439
|
})));
|
|
225
440
|
}, o.subscribe(e._axListener)), o.fetch();
|
|
226
441
|
}
|
|
227
|
-
function
|
|
228
|
-
let
|
|
442
|
+
function N(e) {
|
|
443
|
+
let t = e.getAttribute("ax-mutate");
|
|
444
|
+
if (!t) return;
|
|
445
|
+
let n = j(e, t);
|
|
229
446
|
if (!n) return;
|
|
230
|
-
let r =
|
|
231
|
-
if (!r)
|
|
232
|
-
|
|
233
|
-
if (!a) {
|
|
234
|
-
v(e, {
|
|
447
|
+
let r = a(n.target);
|
|
448
|
+
if (!r) {
|
|
449
|
+
w(e, {
|
|
235
450
|
state: "error",
|
|
236
|
-
error: { message: `Route not found: ${
|
|
237
|
-
}),
|
|
451
|
+
error: { message: `Route not found: ${n.target}` }
|
|
452
|
+
}), k(e, "error");
|
|
238
453
|
return;
|
|
239
454
|
}
|
|
240
|
-
|
|
455
|
+
w(e, {
|
|
241
456
|
state: "mutating",
|
|
242
457
|
error: null,
|
|
243
458
|
data: null
|
|
244
|
-
}),
|
|
245
|
-
let
|
|
459
|
+
}), k(e, "mutating");
|
|
460
|
+
let i = {};
|
|
246
461
|
e instanceof HTMLFormElement && new FormData(e).forEach((t, n) => {
|
|
247
|
-
let r = e.elements.namedItem(n),
|
|
248
|
-
r instanceof HTMLInputElement ?
|
|
249
|
-
let
|
|
462
|
+
let r = e.elements.namedItem(n), a = !1;
|
|
463
|
+
r instanceof HTMLInputElement ? a = r.type === "number" : r instanceof RadioNodeList && r.length > 0 && (a = r[0].type === "number");
|
|
464
|
+
let o = a && t !== "" ? Number(t) : t;
|
|
250
465
|
if (n.includes(".")) {
|
|
251
|
-
let e = n.split("."), t =
|
|
466
|
+
let e = n.split("."), t = i;
|
|
252
467
|
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
|
|
468
|
+
t[e[e.length - 1]] = o;
|
|
469
|
+
} else i[n] = o;
|
|
255
470
|
});
|
|
256
|
-
let { path: s, remainingArgs: c } =
|
|
257
|
-
...
|
|
258
|
-
...
|
|
471
|
+
let { path: s, remainingArgs: c } = o(r, {
|
|
472
|
+
...i,
|
|
473
|
+
...n.args
|
|
259
474
|
}), l = c;
|
|
260
|
-
|
|
475
|
+
r.bodyParam && c[r.bodyParam] !== void 0 && (l = c[r.bodyParam]);
|
|
261
476
|
let u = {}, d = e.getAttribute("ax-headers");
|
|
262
477
|
if (d) try {
|
|
263
478
|
u = Function("return (" + d + ");")() || {};
|
|
@@ -270,118 +485,118 @@ function D(e) {
|
|
|
270
485
|
for (let [t, n] of Object.entries(l)) e.append(t, String(n));
|
|
271
486
|
p = new TextEncoder().encode(e.toString());
|
|
272
487
|
} else p = new TextEncoder().encode(JSON.stringify(l));
|
|
273
|
-
|
|
488
|
+
P(e, r.namespace, r.id, r.method, s, p, r.isStream, !0, u, f);
|
|
274
489
|
}
|
|
275
|
-
function
|
|
276
|
-
let m = ++
|
|
277
|
-
|
|
278
|
-
namespace:
|
|
279
|
-
endpointId:
|
|
280
|
-
method:
|
|
281
|
-
path:
|
|
490
|
+
function P(e, n, r, i, a, o, s, d, f = {}, p = !1) {
|
|
491
|
+
let m = ++O;
|
|
492
|
+
A("OUT", m, {
|
|
493
|
+
namespace: n,
|
|
494
|
+
endpointId: r,
|
|
495
|
+
method: i,
|
|
496
|
+
path: a,
|
|
282
497
|
headers: f,
|
|
283
|
-
payload:
|
|
284
|
-
}),
|
|
285
|
-
isStream:
|
|
286
|
-
onResponse: (t) =>
|
|
498
|
+
payload: o.length > 0 ? p ? new TextDecoder().decode(o) : JSON.parse(new TextDecoder().decode(o)) : null
|
|
499
|
+
}), t.set(m, {
|
|
500
|
+
isStream: s,
|
|
501
|
+
onResponse: (t) => F(e, t, d, m),
|
|
287
502
|
onComplete: () => {
|
|
288
|
-
|
|
503
|
+
H.debug && console.log(`%c✔ Stream Complete [#${m}]`, "color: #94a3b8;");
|
|
289
504
|
}
|
|
290
505
|
});
|
|
291
|
-
let h =
|
|
292
|
-
|
|
506
|
+
let h = u(n), g = u(i), _ = u(a), v = u(""), y = u(Object.keys(f).length > 0 ? JSON.stringify(f) : ""), b = l(o);
|
|
507
|
+
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
508
|
}
|
|
294
|
-
function
|
|
295
|
-
if (
|
|
296
|
-
eventType: n
|
|
297
|
-
data:
|
|
298
|
-
error:
|
|
299
|
-
}),
|
|
300
|
-
|
|
509
|
+
function F(t, n, r, i) {
|
|
510
|
+
if (A("IN", i, {
|
|
511
|
+
eventType: e[n.eventType],
|
|
512
|
+
data: n.data,
|
|
513
|
+
error: n.error
|
|
514
|
+
}), n.eventType === e.Error) {
|
|
515
|
+
w(t, {
|
|
301
516
|
state: "error",
|
|
302
|
-
error:
|
|
517
|
+
error: n.error,
|
|
303
518
|
isFetching: !1,
|
|
304
519
|
isMutating: !1
|
|
305
|
-
}),
|
|
520
|
+
}), k(t, "error"), t.dispatchEvent(new CustomEvent("atmx:error", {
|
|
306
521
|
bubbles: !0,
|
|
307
|
-
detail:
|
|
522
|
+
detail: n.error
|
|
308
523
|
}));
|
|
309
524
|
return;
|
|
310
525
|
}
|
|
311
|
-
if (
|
|
312
|
-
let
|
|
313
|
-
|
|
526
|
+
if (n.data) {
|
|
527
|
+
let i = "network", o = !1;
|
|
528
|
+
n.eventType === e.CacheHit ? i = "cache" : n.eventType === e.CacheHitAndFetching ? (i = "cache", o = !0) : n.eventType === e.NetworkSuccess && (i = "network");
|
|
314
529
|
let s = r ? "success" : "data";
|
|
315
|
-
if (
|
|
530
|
+
if (w(t, {
|
|
316
531
|
state: s,
|
|
317
|
-
data:
|
|
318
|
-
source:
|
|
532
|
+
data: n.data,
|
|
533
|
+
source: i,
|
|
319
534
|
isFetching: o,
|
|
320
535
|
isMutating: !1
|
|
321
536
|
}), r) {
|
|
322
|
-
let
|
|
323
|
-
if (
|
|
324
|
-
let n =
|
|
537
|
+
let e = t.getAttribute("ax-store-token");
|
|
538
|
+
if (e) {
|
|
539
|
+
let n = g(e, S(t));
|
|
325
540
|
if (n) {
|
|
326
|
-
let
|
|
327
|
-
|
|
541
|
+
let e = a(j(t, t.getAttribute("ax-mutate")).target), r = t.getAttribute("ax-token-header") || "Authorization";
|
|
542
|
+
H.setAuthToken(e?.namespace || "default", r, n);
|
|
328
543
|
}
|
|
329
544
|
}
|
|
330
|
-
if (
|
|
331
|
-
let
|
|
332
|
-
|
|
545
|
+
if (t.hasAttribute("ax-clear-token")) {
|
|
546
|
+
let e = a(j(t, t.getAttribute("ax-mutate")).target), n = t.getAttribute("ax-token-header") || "Authorization";
|
|
547
|
+
H.clearAuthToken(e?.namespace || "default", n);
|
|
333
548
|
}
|
|
334
|
-
let n =
|
|
549
|
+
let n = t.getAttribute("ax-refresh");
|
|
335
550
|
if (n) {
|
|
336
551
|
let e = n.split(",").map((e) => e.trim());
|
|
337
|
-
for (let [t, n] of
|
|
552
|
+
for (let [t, n] of D.entries()) {
|
|
338
553
|
let t = `${n.route.namespace}.${n.route.name}`;
|
|
339
554
|
e.includes(t) && n.fetch(!0);
|
|
340
555
|
}
|
|
341
556
|
}
|
|
342
557
|
}
|
|
343
|
-
|
|
558
|
+
k(t, s), t.dispatchEvent(new CustomEvent(r ? "atmx:success" : "atmx:data", {
|
|
344
559
|
bubbles: !0,
|
|
345
|
-
detail:
|
|
560
|
+
detail: n.data
|
|
346
561
|
}));
|
|
347
562
|
}
|
|
348
563
|
}
|
|
349
564
|
//#endregion
|
|
350
565
|
//#region src/dom/scanner.ts
|
|
351
|
-
var
|
|
566
|
+
var I = new IntersectionObserver((e) => {
|
|
352
567
|
e.forEach((e) => {
|
|
353
568
|
if (e.isIntersecting) {
|
|
354
569
|
let t = e.target;
|
|
355
|
-
t.hasAttribute("ax-query") &&
|
|
570
|
+
t.hasAttribute("ax-query") && M(t), I.unobserve(t);
|
|
356
571
|
}
|
|
357
572
|
});
|
|
358
573
|
});
|
|
359
|
-
function
|
|
574
|
+
function L(e) {
|
|
360
575
|
e.querySelectorAll("[\\:ax-query], [\\:ax-mutate]").forEach((e) => {
|
|
361
576
|
if (e.hasAttribute(":ax-query")) {
|
|
362
|
-
let t =
|
|
577
|
+
let t = g(e.getAttribute(":ax-query"), S(e));
|
|
363
578
|
t && e.setAttribute("ax-query", String(t)), e.removeAttribute(":ax-query");
|
|
364
579
|
}
|
|
365
580
|
if (e.hasAttribute(":ax-mutate")) {
|
|
366
|
-
let t =
|
|
581
|
+
let t = g(e.getAttribute(":ax-mutate"), S(e));
|
|
367
582
|
t && e.setAttribute("ax-mutate", String(t)), e.removeAttribute(":ax-mutate");
|
|
368
583
|
}
|
|
369
584
|
});
|
|
370
585
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
586
|
+
function R(e = document) {
|
|
587
|
+
L(e), e.querySelectorAll("[ax-query]").forEach((e) => {
|
|
373
588
|
let t = e;
|
|
374
|
-
|
|
589
|
+
w(t, {});
|
|
375
590
|
let n = t.getAttribute("ax-trigger") || "load";
|
|
376
|
-
n === "load" ?
|
|
377
|
-
e.preventDefault(),
|
|
591
|
+
n === "load" ? M(t) : n === "intersect" ? I.observe(t) : t.addEventListener(n, (e) => {
|
|
592
|
+
e.preventDefault(), M(t);
|
|
378
593
|
});
|
|
379
594
|
}), e.querySelectorAll("[ax-mutate]").forEach((e) => {
|
|
380
595
|
let t = e;
|
|
381
|
-
|
|
596
|
+
w(t, {});
|
|
382
597
|
let n = t.tagName === "FORM" ? "submit" : "click";
|
|
383
598
|
t.addEventListener(n, (e) => {
|
|
384
|
-
(t.tagName === "A" || t.tagName === "BUTTON" || t.tagName === "FORM") && e.preventDefault(),
|
|
599
|
+
(t.tagName === "A" || t.tagName === "BUTTON" || t.tagName === "FORM") && e.preventDefault(), N(t);
|
|
385
600
|
});
|
|
386
601
|
}), e.querySelectorAll("[ax-trigger=\"refresh\"]").forEach((e) => {
|
|
387
602
|
let t = e;
|
|
@@ -389,23 +604,23 @@ function M(e = document) {
|
|
|
389
604
|
e.preventDefault();
|
|
390
605
|
let n = t.closest("[ax-query]");
|
|
391
606
|
if (n) {
|
|
392
|
-
let e =
|
|
607
|
+
let e = j(n, n.getAttribute("ax-query"));
|
|
393
608
|
if (e) {
|
|
394
|
-
let t =
|
|
609
|
+
let t = a(e.target);
|
|
395
610
|
if (t) {
|
|
396
|
-
let r = `${t.namespace}:${t.id}:${JSON.stringify(e.args)}`, i =
|
|
397
|
-
i ? i.fetch(!0) :
|
|
611
|
+
let r = `${t.namespace}:${t.id}:${JSON.stringify(e.args)}`, i = D.get(r);
|
|
612
|
+
i ? i.fetch(!0) : M(n);
|
|
398
613
|
}
|
|
399
614
|
}
|
|
400
615
|
}
|
|
401
616
|
});
|
|
402
617
|
});
|
|
403
618
|
}
|
|
404
|
-
function
|
|
619
|
+
function z() {
|
|
405
620
|
new MutationObserver((e) => {
|
|
406
621
|
e.forEach((e) => {
|
|
407
622
|
e.addedNodes.forEach((e) => {
|
|
408
|
-
e instanceof HTMLElement &&
|
|
623
|
+
e instanceof HTMLElement && R(e);
|
|
409
624
|
});
|
|
410
625
|
});
|
|
411
626
|
}).observe(document.body, {
|
|
@@ -415,7 +630,7 @@ function N() {
|
|
|
415
630
|
}
|
|
416
631
|
//#endregion
|
|
417
632
|
//#region src/dom/components/engine-status.ts
|
|
418
|
-
var
|
|
633
|
+
var B = class extends HTMLElement {
|
|
419
634
|
constructor() {
|
|
420
635
|
super();
|
|
421
636
|
}
|
|
@@ -436,11 +651,11 @@ var P = class extends HTMLElement {
|
|
|
436
651
|
}) : (this.innerText = t, this.getAttribute("class") || (this.className = `text-xs font-bold ${n}`));
|
|
437
652
|
}
|
|
438
653
|
};
|
|
439
|
-
typeof window < "u" && !customElements.get("ax-engine-status") && customElements.define("ax-engine-status",
|
|
654
|
+
typeof window < "u" && !customElements.get("ax-engine-status") && customElements.define("ax-engine-status", B);
|
|
440
655
|
//#endregion
|
|
441
656
|
//#region src/index.ts
|
|
442
|
-
var
|
|
443
|
-
version =
|
|
657
|
+
var V = "0.64.0", H = new class {
|
|
658
|
+
version = V;
|
|
444
659
|
initialized = !1;
|
|
445
660
|
debug = !1;
|
|
446
661
|
async init(e) {
|
|
@@ -449,26 +664,42 @@ var F = "0.62.0", I = new class {
|
|
|
449
664
|
contracts: {},
|
|
450
665
|
initDurationMs: 0
|
|
451
666
|
};
|
|
452
|
-
let t = await
|
|
453
|
-
return t.ok ? (this.debug = e.debug || !1,
|
|
667
|
+
let t = await f(e);
|
|
668
|
+
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
669
|
}
|
|
455
670
|
triggerQuery(e) {
|
|
456
671
|
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
457
|
-
t && t instanceof HTMLElement && t.hasAttribute("ax-query") &&
|
|
672
|
+
t && t instanceof HTMLElement && t.hasAttribute("ax-query") && M(t);
|
|
458
673
|
}
|
|
459
674
|
on(e, t) {
|
|
460
675
|
document.addEventListener(`atmx:${e}`, t);
|
|
461
676
|
}
|
|
462
|
-
setAuthToken(t, n
|
|
463
|
-
e
|
|
677
|
+
setAuthToken(e, t, n) {
|
|
678
|
+
p(e, t, n);
|
|
464
679
|
}
|
|
465
680
|
sendStreamMessage(e, t) {
|
|
466
|
-
|
|
681
|
+
h(e, t);
|
|
467
682
|
}
|
|
468
683
|
clearAuthToken(e, t) {
|
|
469
|
-
|
|
684
|
+
m(e, t);
|
|
685
|
+
}
|
|
686
|
+
connect(e) {
|
|
687
|
+
let t = j(null, e);
|
|
688
|
+
if (!t) return;
|
|
689
|
+
let n = a(t.target);
|
|
690
|
+
if (!n) return;
|
|
691
|
+
let r = `${n.namespace}:${n.id}:${JSON.stringify(t.args)}`, i = D.get(r);
|
|
692
|
+
i || (i = new E(r, n, t.args), D.set(r, i)), i.fetch();
|
|
693
|
+
}
|
|
694
|
+
disconnect(e) {
|
|
695
|
+
let n = j(null, e);
|
|
696
|
+
if (!n) return;
|
|
697
|
+
let r = a(n.target);
|
|
698
|
+
if (!r) return;
|
|
699
|
+
let i = `${r.namespace}:${r.id}:${JSON.stringify(n.args)}`, o = D.get(i);
|
|
700
|
+
o && (o.currentReqId && t.delete(o.currentReqId), D.delete(i), this.debug && console.log(`🔌 ATMX Disconnected Stream: ${e}`));
|
|
470
701
|
}
|
|
471
702
|
}();
|
|
472
|
-
typeof window < "u" && (window.atmx =
|
|
703
|
+
typeof window < "u" && (window.atmx = H);
|
|
473
704
|
//#endregion
|
|
474
|
-
export {
|
|
705
|
+
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 };
|