@camstack/core 0.1.10 → 0.1.12
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/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2698,6 +2698,14 @@ var EventBus = class {
|
|
|
2698
2698
|
var fs = __toESM(require("fs"));
|
|
2699
2699
|
var path = __toESM(require("path"));
|
|
2700
2700
|
var import_node_crypto = require("crypto");
|
|
2701
|
+
function buildHeaders(url) {
|
|
2702
|
+
const headers = { "User-Agent": "CamStack/1.0" };
|
|
2703
|
+
const hfToken = process.env["HF_TOKEN"] ?? process.env["HUGGING_FACE_HUB_TOKEN"];
|
|
2704
|
+
if (hfToken && url.includes("huggingface.co")) {
|
|
2705
|
+
headers["Authorization"] = `Bearer ${hfToken}`;
|
|
2706
|
+
}
|
|
2707
|
+
return headers;
|
|
2708
|
+
}
|
|
2701
2709
|
async function downloadFile(url, destPath, onProgress) {
|
|
2702
2710
|
if (fs.existsSync(destPath)) return destPath;
|
|
2703
2711
|
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
@@ -2705,7 +2713,7 @@ async function downloadFile(url, destPath, onProgress) {
|
|
|
2705
2713
|
try {
|
|
2706
2714
|
const response = await fetch(url, {
|
|
2707
2715
|
redirect: "follow",
|
|
2708
|
-
headers:
|
|
2716
|
+
headers: buildHeaders(url)
|
|
2709
2717
|
});
|
|
2710
2718
|
if (!response.ok) {
|
|
2711
2719
|
throw new Error(`HTTP ${response.status} downloading ${url}`);
|
|
@@ -2745,7 +2753,7 @@ async function downloadFile(url, destPath, onProgress) {
|
|
|
2745
2753
|
async function fetchJson(url) {
|
|
2746
2754
|
const response = await fetch(url, {
|
|
2747
2755
|
redirect: "follow",
|
|
2748
|
-
headers:
|
|
2756
|
+
headers: buildHeaders(url)
|
|
2749
2757
|
});
|
|
2750
2758
|
if (!response.ok) {
|
|
2751
2759
|
throw new Error(`HTTP ${response.status} fetching ${url}`);
|
|
@@ -5149,7 +5157,13 @@ var SystemEventBus = class {
|
|
|
5149
5157
|
this.ringBuffer.push(event);
|
|
5150
5158
|
for (const subscriber of this.subscribers) {
|
|
5151
5159
|
if (matchesFilter(event, subscriber.filter)) {
|
|
5152
|
-
|
|
5160
|
+
queueMicrotask(() => {
|
|
5161
|
+
try {
|
|
5162
|
+
subscriber.callback(event);
|
|
5163
|
+
} catch (err) {
|
|
5164
|
+
console.error(`[EventBus] Subscriber error for ${event.category}:`, err);
|
|
5165
|
+
}
|
|
5166
|
+
});
|
|
5153
5167
|
}
|
|
5154
5168
|
}
|
|
5155
5169
|
}
|