@flaxia/node 0.3.2 → 0.3.3
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/assets/ai-inference.js +21 -23
- package/dist/assets/nudenet.js +1 -1
- package/dist/assets/vector-embed.js +2 -1
- package/dist/client/SignalingClient.d.ts.map +1 -1
- package/dist/consent/storage.d.ts +13 -0
- package/dist/consent/storage.d.ts.map +1 -1
- package/dist/index.js +100 -63
- package/dist/workloads/__tests__/wasm-threads.test.d.ts +2 -0
- package/dist/workloads/__tests__/wasm-threads.test.d.ts.map +1 -0
- package/dist/workloads/ai-inference.d.ts.map +1 -1
- package/dist/workloads/nudenet.d.ts +1 -0
- package/dist/workloads/nudenet.d.ts.map +1 -1
- package/dist/workloads/vector-embed.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -36,43 +36,41 @@ var r = [
|
|
|
36
36
|
return (e) => {
|
|
37
37
|
n += e, r ||= setTimeout(a, i);
|
|
38
38
|
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let p = `${l}:${u}`, m = i.get(p);
|
|
47
|
-
if (!m) {
|
|
39
|
+
};
|
|
40
|
+
t.backends?.onnx?.wasm && (t.backends.onnx.wasm.numThreads = 1, t.backends.onnx.wasm.proxy = !1);
|
|
41
|
+
var c = async (t, o) => {
|
|
42
|
+
let { task: c, model: l, input: u, options: d = {} } = t;
|
|
43
|
+
if (!r.includes(c)) throw Error(`Invalid or unsupported task: ${c}. Supported tasks are: ${r.join(", ")}`);
|
|
44
|
+
let f = `${c}:${l}`, p = i.get(f);
|
|
45
|
+
if (!p) {
|
|
48
46
|
if (i.size >= a) {
|
|
49
47
|
let e = i.keys().next().value;
|
|
50
48
|
i.delete(e);
|
|
51
49
|
}
|
|
52
50
|
let e = {
|
|
53
|
-
dtype:
|
|
54
|
-
device:
|
|
51
|
+
dtype: d.dtype ?? "q4f16",
|
|
52
|
+
device: d.device
|
|
55
53
|
}, t = performance.now();
|
|
56
|
-
console.log(`[flaxia-node] ai-inference: loading pipeline task=${
|
|
54
|
+
console.log(`[flaxia-node] ai-inference: loading pipeline task=${c} model=${l} dtype=${e.dtype} device=${e.device ?? "wasm"}`);
|
|
57
55
|
try {
|
|
58
|
-
|
|
56
|
+
p = await n(c, l, e);
|
|
59
57
|
} catch (t) {
|
|
60
|
-
if (
|
|
61
|
-
else throw console.error(`[flaxia-node] ai-inference: pipeline load FAILED task=${
|
|
58
|
+
if (d.device && d.device !== "wasm") console.warn(`[AiInference] ${d.device} failed, falling back to wasm:`, t), e.device = "wasm", p = await n(c, l, e);
|
|
59
|
+
else throw console.error(`[flaxia-node] ai-inference: pipeline load FAILED task=${c} model=${l} error=${t instanceof Error ? t.message : String(t)}`), t;
|
|
62
60
|
}
|
|
63
|
-
console.log(`[flaxia-node] ai-inference: pipeline ready task=${
|
|
61
|
+
console.log(`[flaxia-node] ai-inference: pipeline ready task=${c} model=${l} loadMs=${Math.round(performance.now() - t)}`), i.set(f, p);
|
|
64
62
|
}
|
|
65
|
-
let
|
|
66
|
-
max_new_tokens:
|
|
67
|
-
do_sample:
|
|
63
|
+
let m = {
|
|
64
|
+
max_new_tokens: d.max_new_tokens ?? 128,
|
|
65
|
+
do_sample: d.do_sample ?? !1
|
|
68
66
|
};
|
|
69
|
-
|
|
67
|
+
d.temperature != null && (m.temperature = d.temperature), d.top_p != null && (m.top_p = d.top_p), d.top_k != null && (m.top_k = d.top_k), d.repetition_penalty != null && (m.repetition_penalty = d.repetition_penalty), d.src_lang != null && (m.src_lang = d.src_lang), d.tgt_lang != null && (m.tgt_lang = d.tgt_lang), o && p.tokenizer && (m.streamer = new e(p.tokenizer, {
|
|
70
68
|
skip_prompt: !0,
|
|
71
69
|
skip_special_tokens: !0,
|
|
72
|
-
callback_function: s(
|
|
70
|
+
callback_function: s(o, d)
|
|
73
71
|
}));
|
|
74
|
-
let
|
|
75
|
-
return console.log(`[flaxia-node] ai-inference: done task=${
|
|
72
|
+
let h = performance.now(), g = await p(u, m);
|
|
73
|
+
return console.log(`[flaxia-node] ai-inference: done task=${c} model=${l} execMs=${Math.round(performance.now() - h)} inputLen=${String(u).length}`), { output: g };
|
|
76
74
|
};
|
|
77
75
|
//#endregion
|
|
78
76
|
export { c as handleAiInference, o as releaseCache };
|
package/dist/assets/nudenet.js
CHANGED
|
@@ -13947,7 +13947,7 @@ var yd = 320, bd = "1.26.0", xd = "https://huggingface.co/deepghs/nudenet_onnx/r
|
|
|
13947
13947
|
"BUTTOCKS_COVERED"
|
|
13948
13948
|
], wd = !1;
|
|
13949
13949
|
function Td() {
|
|
13950
|
-
wd ||= (S.wasm.wasmPaths = `https://cdn.jsdelivr.net/npm/onnxruntime-web@${bd}/dist/`, !0);
|
|
13950
|
+
wd ||= (S.wasm.wasmPaths = `https://cdn.jsdelivr.net/npm/onnxruntime-web@${bd}/dist/`, S.wasm.numThreads = 1, S.wasm.proxy = !1, !0);
|
|
13951
13951
|
}
|
|
13952
13952
|
var Ed = /* @__PURE__ */ new Map();
|
|
13953
13953
|
function Dd(e) {
|
|
@@ -7,7 +7,8 @@ async function n(t) {
|
|
|
7
7
|
if (!e) {
|
|
8
8
|
let t = performance.now();
|
|
9
9
|
console.log("[flaxia-node] vector-embed: loading pipeline model=onnx-community/Qwen3-Embedding-0.6B-ONNX device=wasm");
|
|
10
|
-
let { pipeline: n } = await import("./transformers.web.js");
|
|
10
|
+
let { pipeline: n, env: r } = await import("./transformers.web.js");
|
|
11
|
+
r?.backends?.onnx?.wasm && (r.backends.onnx.wasm.numThreads = 1, r.backends.onnx.wasm.proxy = !1);
|
|
11
12
|
try {
|
|
12
13
|
e = await n("feature-extraction", "onnx-community/Qwen3-Embedding-0.6B-ONNX", { device: "wasm" });
|
|
13
14
|
} catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignalingClient.d.ts","sourceRoot":"","sources":["../../src/client/SignalingClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignalingClient.d.ts","sourceRoot":"","sources":["../../src/client/SignalingClient.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK5D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA2QD,eAAO,MAAM,cAAc,GAAI,QAAQ,UAAU,SAsBhD,CAAC"}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
declare function safeGet(key: string): string | null;
|
|
2
|
+
declare function safeSet(key: string, value: string): void;
|
|
3
|
+
declare function safeRemove(key: string): void;
|
|
1
4
|
export declare const hasConsent: () => boolean;
|
|
2
5
|
export declare const saveConsent: () => void;
|
|
6
|
+
export declare const safeLocalStorageGet: typeof safeGet;
|
|
7
|
+
export declare const safeLocalStorageSet: typeof safeSet;
|
|
8
|
+
export declare const safeLocalStorageRemove: typeof safeRemove;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a UUID, falling back to a random v4 when `crypto.randomUUID` is
|
|
11
|
+
* unavailable (older browsers, or non-secure contexts where `crypto.randomUUID`
|
|
12
|
+
* is undefined on mobile Chrome). Never throws.
|
|
13
|
+
*/
|
|
14
|
+
export declare const safeRandomUUID: () => string;
|
|
15
|
+
export {};
|
|
3
16
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/consent/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/consent/storage.ts"],"names":[],"mappings":"AAWA,iBAAS,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM3C;AAED,iBAAS,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMjD;AAED,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAMrC;AAED,eAAO,MAAM,UAAU,QAAO,OAgB7B,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,IAG9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBAAU,CAAC;AAC3C,eAAO,MAAM,mBAAmB,gBAAU,CAAC;AAC3C,eAAO,MAAM,sBAAsB,mBAAa,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,MAajC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -39,17 +39,47 @@ var e = class {
|
|
|
39
39
|
c.remove(), t();
|
|
40
40
|
}), this.shadow.appendChild(s), this.shadow.appendChild(c);
|
|
41
41
|
}
|
|
42
|
-
}, t = "flaxia_consent_granted", n = "flaxia_consent_expiry", r = 720 * 60 * 60 * 1e3, i = ()
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
}, t = "flaxia_consent_granted", n = "flaxia_consent_expiry", r = 720 * 60 * 60 * 1e3, i = /* @__PURE__ */ new Map();
|
|
43
|
+
function a(e) {
|
|
44
|
+
try {
|
|
45
|
+
return localStorage.getItem(e);
|
|
46
|
+
} catch {
|
|
47
|
+
return i.get(e) ?? null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function o(e, t) {
|
|
51
|
+
try {
|
|
52
|
+
localStorage.setItem(e, t);
|
|
53
|
+
} catch {
|
|
54
|
+
i.set(e, t);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function s(e) {
|
|
58
|
+
try {
|
|
59
|
+
localStorage.removeItem(e);
|
|
60
|
+
} catch {
|
|
61
|
+
i.delete(e);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
var c = () => {
|
|
65
|
+
if (a(t) !== "true") return !1;
|
|
66
|
+
let e = a(n);
|
|
45
67
|
if (e) {
|
|
46
68
|
let r = parseInt(e, 10);
|
|
47
|
-
if (Date.now() > r) return
|
|
69
|
+
if (!Number.isFinite(r) || Date.now() > r) return s(t), s(n), !1;
|
|
48
70
|
}
|
|
49
71
|
return !0;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
},
|
|
72
|
+
}, l = () => {
|
|
73
|
+
o(t, "true"), o(n, String(Date.now() + r));
|
|
74
|
+
}, u = a, d = o, f = () => {
|
|
75
|
+
try {
|
|
76
|
+
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
77
|
+
} catch {}
|
|
78
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
79
|
+
let t = Math.random() * 16 | 0;
|
|
80
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
81
|
+
});
|
|
82
|
+
}, p = (...e) => console.log("[flaxia-node]", ...e), m = class {
|
|
53
83
|
constructor(e, t = 3e5) {
|
|
54
84
|
this.worker = null, this.queue = [], this.active = null, this._lastCpuLoad = 0, this.workerUrl = e || "/worker.js", this.defaultTimeoutMs = t, this.initWorker();
|
|
55
85
|
}
|
|
@@ -63,66 +93,66 @@ var e = class {
|
|
|
63
93
|
}, this.worker = e;
|
|
64
94
|
}
|
|
65
95
|
run(e, t, n, r, i, a) {
|
|
66
|
-
return new Promise((
|
|
96
|
+
return new Promise((o, s) => {
|
|
67
97
|
if (!this.worker) {
|
|
68
|
-
|
|
98
|
+
s(/* @__PURE__ */ Error("Worker not available"));
|
|
69
99
|
return;
|
|
70
100
|
}
|
|
71
|
-
let
|
|
72
|
-
this.active ? (
|
|
101
|
+
let c = () => this.execute(e, t, n, r, i, a, o, s);
|
|
102
|
+
this.active ? (p(`task queued id=${e} workload=${t} (active task running)`), this.queue.push(c)) : c();
|
|
73
103
|
});
|
|
74
104
|
}
|
|
75
|
-
execute(e, t, n, r, i, a,
|
|
76
|
-
let
|
|
77
|
-
if (!
|
|
78
|
-
|
|
105
|
+
execute(e, t, n, r, i, a, o, s) {
|
|
106
|
+
let c = this.worker;
|
|
107
|
+
if (!c) {
|
|
108
|
+
s(/* @__PURE__ */ Error("Worker not available")), this.dequeue();
|
|
79
109
|
return;
|
|
80
110
|
}
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
|
|
111
|
+
let l = r ?? this.defaultTimeoutMs, u = !1, d = performance.now();
|
|
112
|
+
p(`task start id=${e} workload=${t} timeoutMs=${l}`);
|
|
113
|
+
let f = (e) => {
|
|
114
|
+
if (u) return;
|
|
115
|
+
u = !0;
|
|
86
116
|
let t = this.active;
|
|
87
117
|
t && (clearTimeout(t.timer), t.removeListener()), this.active = null, e(), this.dequeue();
|
|
88
118
|
}, m = (n) => {
|
|
89
|
-
let { id: r, type: a, result:
|
|
119
|
+
let { id: r, type: a, result: c, error: l, token: u, cpuLoad: m } = n.data;
|
|
90
120
|
if (r === e) {
|
|
91
121
|
if (a === "token") {
|
|
92
|
-
i?.(
|
|
122
|
+
i?.(u);
|
|
93
123
|
return;
|
|
94
124
|
}
|
|
95
125
|
if (a === "heartbeat") {
|
|
96
126
|
typeof m == "number" && Number.isFinite(m) && (this._lastCpuLoad = Math.min(1, Math.max(0, m)));
|
|
97
127
|
return;
|
|
98
128
|
}
|
|
99
|
-
a === "done" ? (
|
|
129
|
+
a === "done" ? (p(`task done id=${e} workload=${t} durationMs=${Math.round(performance.now() - d)}`), f(() => o(c))) : a === "error" ? (p(`task failed id=${e} workload=${t} error=${l}`), f(() => s(Error(l)))) : (p(`task unknown-message id=${e} type=${String(a)}`), f(() => s(/* @__PURE__ */ Error(`Unknown message type: ${String(a)}`))));
|
|
100
130
|
}
|
|
101
|
-
}, h = () =>
|
|
102
|
-
|
|
103
|
-
},
|
|
131
|
+
}, h = () => c.removeEventListener("message", m), g = setTimeout(() => {
|
|
132
|
+
p(`task timeout id=${e} workload=${t} (worker terminated after ${l}ms)`), this.cleanupWorker(), f(() => s(/* @__PURE__ */ Error("TIMEOUT")));
|
|
133
|
+
}, l);
|
|
104
134
|
this.active = {
|
|
105
135
|
id: e,
|
|
106
|
-
resolve:
|
|
107
|
-
reject:
|
|
136
|
+
resolve: o,
|
|
137
|
+
reject: s,
|
|
108
138
|
timer: g,
|
|
109
|
-
worker:
|
|
139
|
+
worker: c,
|
|
110
140
|
removeListener: h
|
|
111
|
-
},
|
|
141
|
+
}, c.addEventListener("message", m);
|
|
112
142
|
try {
|
|
113
|
-
|
|
143
|
+
c.postMessage({
|
|
114
144
|
id: e,
|
|
115
145
|
workload: t,
|
|
116
146
|
payload: n,
|
|
117
|
-
timeoutMs:
|
|
147
|
+
timeoutMs: l,
|
|
118
148
|
config: a
|
|
119
149
|
});
|
|
120
150
|
} catch (e) {
|
|
121
|
-
|
|
151
|
+
f(() => s(e instanceof Error ? e : Error(String(e))));
|
|
122
152
|
}
|
|
123
153
|
}
|
|
124
154
|
handleWorkerError(e) {
|
|
125
|
-
|
|
155
|
+
p(`worker error error=${e.message}`);
|
|
126
156
|
let t = this.active;
|
|
127
157
|
this.cleanupWorker(), t && (clearTimeout(t.timer), this.active = null, t.reject(e), this.dequeue());
|
|
128
158
|
}
|
|
@@ -142,13 +172,13 @@ var e = class {
|
|
|
142
172
|
get lastCpuLoad() {
|
|
143
173
|
return this._lastCpuLoad;
|
|
144
174
|
}
|
|
145
|
-
},
|
|
175
|
+
}, h = (...e) => console.log("[flaxia-node]", ...e), g = (...e) => console.error("[flaxia-node]", ...e), _ = "flaxia_node_id", v = "flaxia_node_token", y = class {
|
|
146
176
|
constructor(e, t, n) {
|
|
147
177
|
this.config = e, this.workerPool = t, this.nodeId = n, this.ws = null, this.reconnectAttempts = 0, this.MAX_RECONNECT_DELAY = 3e4, this.destroyed = !1, this.suspended = !1, this.visibilityHandler = null, this.inflightTasks = /* @__PURE__ */ new Set();
|
|
148
178
|
}
|
|
149
179
|
async connect() {
|
|
150
180
|
if (this.destroyed) return;
|
|
151
|
-
if (
|
|
181
|
+
if (h(`connect nodeId=${this.nodeId}`), this.ws) {
|
|
152
182
|
let e = this.ws;
|
|
153
183
|
e.onclose = null;
|
|
154
184
|
try {
|
|
@@ -159,14 +189,14 @@ var e = class {
|
|
|
159
189
|
this.setupVisibilityHandler();
|
|
160
190
|
let e = await this.obtainToken();
|
|
161
191
|
if (!e) {
|
|
162
|
-
|
|
192
|
+
g("token acquisition failed; scheduling reconnect"), this.scheduleReconnect();
|
|
163
193
|
return;
|
|
164
194
|
}
|
|
165
195
|
let t = this.config.orchestratorUrl.replace(/\/+$/, "").replace(/^http/, "ws"), n = new URL(`${t}/crowd/signal`);
|
|
166
196
|
n.searchParams.set("token", e.token);
|
|
167
197
|
let r = new WebSocket(n.toString());
|
|
168
198
|
this.ws = r, r.onopen = () => {
|
|
169
|
-
this.reconnectAttempts = 0,
|
|
199
|
+
this.reconnectAttempts = 0, h(`signal connected ${n.toString()}`);
|
|
170
200
|
}, r.onmessage = async (e) => {
|
|
171
201
|
let t;
|
|
172
202
|
try {
|
|
@@ -183,12 +213,12 @@ var e = class {
|
|
|
183
213
|
}
|
|
184
214
|
if (t.type === "task") {
|
|
185
215
|
let e = t;
|
|
186
|
-
|
|
216
|
+
h(`task received taskId=${e.taskId} workload=${e.workload} timeoutMs=${e.timeoutMs ?? "default"}`);
|
|
187
217
|
try {
|
|
188
218
|
await this.handleTask(e);
|
|
189
219
|
} catch (n) {
|
|
190
220
|
let r = n instanceof Error ? n.message : String(n);
|
|
191
|
-
|
|
221
|
+
g(`task failed taskId=${e.taskId} workload=${e.workload} error=${r}`), this.send({
|
|
192
222
|
type: "error",
|
|
193
223
|
taskId: String(t.taskId ?? ""),
|
|
194
224
|
error: r
|
|
@@ -196,7 +226,7 @@ var e = class {
|
|
|
196
226
|
}
|
|
197
227
|
}
|
|
198
228
|
}, r.onclose = () => {
|
|
199
|
-
r.onclose = null, this.ws === r && (this.ws = null, !this.destroyed && (
|
|
229
|
+
r.onclose = null, this.ws === r && (this.ws = null, !this.destroyed && (h(`signal disconnected; scheduling reconnect attempt=${this.reconnectAttempts + 1}`), this.scheduleReconnect()));
|
|
200
230
|
};
|
|
201
231
|
}
|
|
202
232
|
scheduleReconnect() {
|
|
@@ -206,15 +236,21 @@ var e = class {
|
|
|
206
236
|
}, e);
|
|
207
237
|
}
|
|
208
238
|
disconnect() {
|
|
209
|
-
|
|
239
|
+
h(`disconnect nodeId=${this.nodeId}`), this.destroyed = !0, this.suspended = !1, this.removeVisibilityHandler();
|
|
210
240
|
try {
|
|
211
241
|
this.ws?.close();
|
|
212
242
|
} catch {}
|
|
213
243
|
this.ws = null;
|
|
244
|
+
try {
|
|
245
|
+
delete window[x];
|
|
246
|
+
} catch {}
|
|
247
|
+
try {
|
|
248
|
+
this.workerPool.terminate();
|
|
249
|
+
} catch {}
|
|
214
250
|
}
|
|
215
251
|
suspend() {
|
|
216
252
|
if (!(this.suspended || this.destroyed)) {
|
|
217
|
-
if (
|
|
253
|
+
if (h("suspended (visibility or manual)"), this.suspended = !0, this.ws) {
|
|
218
254
|
let e = this.ws;
|
|
219
255
|
e.onclose = null;
|
|
220
256
|
try {
|
|
@@ -226,14 +262,14 @@ var e = class {
|
|
|
226
262
|
}
|
|
227
263
|
}
|
|
228
264
|
resume() {
|
|
229
|
-
!this.suspended || this.destroyed || (
|
|
265
|
+
!this.suspended || this.destroyed || (h("resumed"), this.suspended = !1, this.workerPool.resume(), this.connect());
|
|
230
266
|
}
|
|
231
267
|
async obtainToken() {
|
|
232
268
|
try {
|
|
233
|
-
let e =
|
|
269
|
+
let e = u(v);
|
|
234
270
|
if (e) try {
|
|
235
271
|
let t = JSON.parse(e);
|
|
236
|
-
if (t.token && t.nodeId && t.expiresAt > Date.now() + 6e4) return
|
|
272
|
+
if (t.token && t.nodeId && t.expiresAt > Date.now() + 6e4) return h(`token cached nodeId=${t.nodeId} expiresIn=${Math.round((t.expiresAt - Date.now()) / 1e3)}s`), t;
|
|
237
273
|
} catch {}
|
|
238
274
|
let t = this.config.orchestratorUrl.replace(/\/+$/, ""), n = await fetch(`${t}/crowd/nodes/register`, {
|
|
239
275
|
method: "POST",
|
|
@@ -245,16 +281,16 @@ var e = class {
|
|
|
245
281
|
deviceMemory: typeof navigator.deviceMemory == "number" ? navigator.deviceMemory : null
|
|
246
282
|
})
|
|
247
283
|
});
|
|
248
|
-
if (!n.ok) return
|
|
284
|
+
if (!n.ok) return g(`node register failed HTTP ${n.status} (${t}/crowd/nodes/register)`), null;
|
|
249
285
|
let r = await n.json();
|
|
250
|
-
if (!r.token) return
|
|
251
|
-
|
|
286
|
+
if (!r.token) return g("node register returned no token"), null;
|
|
287
|
+
h(`node registered nodeId=${this.nodeId} expiresIn=${Math.round((r.expiresAt - Date.now()) / 1e3)}s`);
|
|
252
288
|
try {
|
|
253
|
-
|
|
289
|
+
d(v, JSON.stringify(r));
|
|
254
290
|
} catch {}
|
|
255
291
|
return r;
|
|
256
292
|
} catch (e) {
|
|
257
|
-
return
|
|
293
|
+
return g("node register threw", e instanceof Error ? e.message : e), null;
|
|
258
294
|
}
|
|
259
295
|
}
|
|
260
296
|
send(e) {
|
|
@@ -276,7 +312,7 @@ var e = class {
|
|
|
276
312
|
type: "result",
|
|
277
313
|
taskId: e.taskId,
|
|
278
314
|
payload: r
|
|
279
|
-
}),
|
|
315
|
+
}), h(`task result sent taskId=${e.taskId} workload=${e.workload} durationMs=${Math.round(performance.now() - t)}`);
|
|
280
316
|
} finally {
|
|
281
317
|
this.inflightTasks.delete(e.taskId);
|
|
282
318
|
}
|
|
@@ -289,22 +325,23 @@ var e = class {
|
|
|
289
325
|
removeVisibilityHandler() {
|
|
290
326
|
this.visibilityHandler &&= (document.removeEventListener("visibilitychange", this.visibilityHandler), null);
|
|
291
327
|
}
|
|
292
|
-
},
|
|
293
|
-
let t = window[
|
|
328
|
+
}, b = "__flaxia_node_signal_client", x = "__flaxia_node_init_started", S = (e) => {
|
|
329
|
+
let t = window[b];
|
|
294
330
|
t && t.disconnect();
|
|
295
|
-
let n = new URL("./worker.js", "" + import.meta.url).href, r = new
|
|
296
|
-
i || (i =
|
|
297
|
-
let a = new
|
|
298
|
-
window[
|
|
299
|
-
},
|
|
300
|
-
if (
|
|
301
|
-
|
|
331
|
+
let n = new URL("./worker.js", "" + import.meta.url).href, r = new m(n), i = u(_);
|
|
332
|
+
i || (i = f(), d(_, i));
|
|
333
|
+
let a = new y(e, r, i);
|
|
334
|
+
window[b] = a, a.connect();
|
|
335
|
+
}, C = (t) => {
|
|
336
|
+
if (window[x]) return;
|
|
337
|
+
if (window[x] = !0, c()) {
|
|
338
|
+
S(t);
|
|
302
339
|
return;
|
|
303
340
|
}
|
|
304
341
|
let n = document.createElement("div");
|
|
305
342
|
n.id = "flaxia-consent-container", document.body.appendChild(n), new e(n, t.consent, () => {
|
|
306
|
-
|
|
343
|
+
l(), n.remove(), S(t);
|
|
307
344
|
});
|
|
308
345
|
};
|
|
309
346
|
//#endregion
|
|
310
|
-
export {
|
|
347
|
+
export { C as initFlaxiaNode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-threads.test.d.ts","sourceRoot":"","sources":["../../../src/workloads/__tests__/wasm-threads.test.ts"],"names":[],"mappings":"AAuBA,OAAO,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-inference.d.ts","sourceRoot":"","sources":["../../src/workloads/ai-inference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAC;AAe7F;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-inference.d.ts","sourceRoot":"","sources":["../../src/workloads/ai-inference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAC;AAe7F;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAuCF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,kBAAkB,EAC3B,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,KAChC,OAAO,CAAC,iBAAiB,CAoE3B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NudeNetPayload, NudeNetResult } from '@flaxia/sdk';
|
|
2
|
+
export declare function configureOrt(): void;
|
|
2
3
|
export declare const handleNudeNet: (payload: NudeNetPayload) => Promise<NudeNetResult>;
|
|
3
4
|
export declare function releaseCache(): void;
|
|
4
5
|
//# sourceMappingURL=nudenet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nudenet.d.ts","sourceRoot":"","sources":["../../src/workloads/nudenet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"nudenet.d.ts","sourceRoot":"","sources":["../../src/workloads/nudenet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoCnF,wBAAgB,YAAY,IAAI,IAAI,CAUnC;AAuID,eAAO,MAAM,aAAa,GAAU,SAAS,cAAc,KAAG,OAAO,CAAC,aAAa,CA6BlF,CAAC;AAEF,wBAAgB,YAAY,IAAI,IAAI,CAEnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-embed.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIzE,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"vector-embed.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIzE,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiD/F"}
|