@mdfriday/foundry 26.2.5 → 26.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/worker/pool-manager.js +34 -1
- package/dist/worker/worker-node.js +34 -1
- package/package.json +1 -1
|
@@ -96338,11 +96338,26 @@ var init_pool_manager = __esm({
|
|
|
96338
96338
|
}
|
|
96339
96339
|
/**
|
|
96340
96340
|
* 检测当前运行环境
|
|
96341
|
+
*
|
|
96342
|
+
* 优先检测 Worker 支持能力,而不仅仅依赖 process 对象的存在
|
|
96343
|
+
* 这样可以正确识别 Electron/Obsidian 环境(有 Node.js API 但只支持 Web Workers)
|
|
96341
96344
|
*/
|
|
96342
96345
|
detectEnvironment() {
|
|
96346
|
+
if (typeof Worker !== "undefined" && typeof globalThis.window !== "undefined") {
|
|
96347
|
+
log62.debug("Detected Web Worker support (browser/Electron environment)");
|
|
96348
|
+
return "browser";
|
|
96349
|
+
}
|
|
96343
96350
|
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
96344
|
-
|
|
96351
|
+
try {
|
|
96352
|
+
require.resolve("worker_threads");
|
|
96353
|
+
log62.debug("Detected Node.js Worker Threads support");
|
|
96354
|
+
return "node";
|
|
96355
|
+
} catch {
|
|
96356
|
+
log62.debug("Node.js detected but worker_threads unavailable, falling back to browser mode");
|
|
96357
|
+
return "browser";
|
|
96358
|
+
}
|
|
96345
96359
|
}
|
|
96360
|
+
log62.debug("Using browser mode as default");
|
|
96346
96361
|
return "browser";
|
|
96347
96362
|
}
|
|
96348
96363
|
/**
|
|
@@ -96359,6 +96374,9 @@ var init_pool_manager = __esm({
|
|
|
96359
96374
|
}
|
|
96360
96375
|
/**
|
|
96361
96376
|
* 初始化 Worker 池
|
|
96377
|
+
*
|
|
96378
|
+
* 包含回退机制:如果 Node.js Worker Threads 初始化失败,
|
|
96379
|
+
* 自动回退到 Web Workers(用于 Electron/Obsidian 等环境)
|
|
96362
96380
|
*/
|
|
96363
96381
|
async initialize() {
|
|
96364
96382
|
if (this.pool) {
|
|
@@ -96377,6 +96395,21 @@ var init_pool_manager = __esm({
|
|
|
96377
96395
|
log62.info(`\u2705 Worker pool initialized in ${duration.toFixed(2)}ms`);
|
|
96378
96396
|
} catch (error) {
|
|
96379
96397
|
const message = error instanceof Error ? error.message : String(error);
|
|
96398
|
+
if (this.environment === "node") {
|
|
96399
|
+
log62.warn(`\u274C Node worker pool initialization failed: ${message}`);
|
|
96400
|
+
log62.warn("\u{1F504} Attempting fallback to browser workers...");
|
|
96401
|
+
try {
|
|
96402
|
+
this.environment = "browser";
|
|
96403
|
+
await this.initializeBrowserPool();
|
|
96404
|
+
const duration = performance.now() - startTime;
|
|
96405
|
+
log62.info(`\u2705 Successfully initialized browser worker pool as fallback in ${duration.toFixed(2)}ms`);
|
|
96406
|
+
return;
|
|
96407
|
+
} catch (fallbackError) {
|
|
96408
|
+
const fallbackMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
96409
|
+
log62.error(`\u274C Fallback to browser workers also failed: ${fallbackMessage}`);
|
|
96410
|
+
throw new Error(`Worker pool initialization failed. Node: ${message}, Browser: ${fallbackMessage}`);
|
|
96411
|
+
}
|
|
96412
|
+
}
|
|
96380
96413
|
log62.error(`\u274C Failed to initialize worker pool: ${message}`);
|
|
96381
96414
|
throw error;
|
|
96382
96415
|
}
|
|
@@ -95236,11 +95236,26 @@ var init_pool_manager = __esm({
|
|
|
95236
95236
|
}
|
|
95237
95237
|
/**
|
|
95238
95238
|
* 检测当前运行环境
|
|
95239
|
+
*
|
|
95240
|
+
* 优先检测 Worker 支持能力,而不仅仅依赖 process 对象的存在
|
|
95241
|
+
* 这样可以正确识别 Electron/Obsidian 环境(有 Node.js API 但只支持 Web Workers)
|
|
95239
95242
|
*/
|
|
95240
95243
|
detectEnvironment() {
|
|
95244
|
+
if (typeof Worker !== "undefined" && typeof globalThis.window !== "undefined") {
|
|
95245
|
+
log57.debug("Detected Web Worker support (browser/Electron environment)");
|
|
95246
|
+
return "browser";
|
|
95247
|
+
}
|
|
95241
95248
|
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
95242
|
-
|
|
95249
|
+
try {
|
|
95250
|
+
require.resolve("worker_threads");
|
|
95251
|
+
log57.debug("Detected Node.js Worker Threads support");
|
|
95252
|
+
return "node";
|
|
95253
|
+
} catch {
|
|
95254
|
+
log57.debug("Node.js detected but worker_threads unavailable, falling back to browser mode");
|
|
95255
|
+
return "browser";
|
|
95256
|
+
}
|
|
95243
95257
|
}
|
|
95258
|
+
log57.debug("Using browser mode as default");
|
|
95244
95259
|
return "browser";
|
|
95245
95260
|
}
|
|
95246
95261
|
/**
|
|
@@ -95257,6 +95272,9 @@ var init_pool_manager = __esm({
|
|
|
95257
95272
|
}
|
|
95258
95273
|
/**
|
|
95259
95274
|
* 初始化 Worker 池
|
|
95275
|
+
*
|
|
95276
|
+
* 包含回退机制:如果 Node.js Worker Threads 初始化失败,
|
|
95277
|
+
* 自动回退到 Web Workers(用于 Electron/Obsidian 等环境)
|
|
95260
95278
|
*/
|
|
95261
95279
|
async initialize() {
|
|
95262
95280
|
if (this.pool) {
|
|
@@ -95275,6 +95293,21 @@ var init_pool_manager = __esm({
|
|
|
95275
95293
|
log57.info(`\u2705 Worker pool initialized in ${duration.toFixed(2)}ms`);
|
|
95276
95294
|
} catch (error) {
|
|
95277
95295
|
const message = error instanceof Error ? error.message : String(error);
|
|
95296
|
+
if (this.environment === "node") {
|
|
95297
|
+
log57.warn(`\u274C Node worker pool initialization failed: ${message}`);
|
|
95298
|
+
log57.warn("\u{1F504} Attempting fallback to browser workers...");
|
|
95299
|
+
try {
|
|
95300
|
+
this.environment = "browser";
|
|
95301
|
+
await this.initializeBrowserPool();
|
|
95302
|
+
const duration = performance.now() - startTime;
|
|
95303
|
+
log57.info(`\u2705 Successfully initialized browser worker pool as fallback in ${duration.toFixed(2)}ms`);
|
|
95304
|
+
return;
|
|
95305
|
+
} catch (fallbackError) {
|
|
95306
|
+
const fallbackMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
95307
|
+
log57.error(`\u274C Fallback to browser workers also failed: ${fallbackMessage}`);
|
|
95308
|
+
throw new Error(`Worker pool initialization failed. Node: ${message}, Browser: ${fallbackMessage}`);
|
|
95309
|
+
}
|
|
95310
|
+
}
|
|
95278
95311
|
log57.error(`\u274C Failed to initialize worker pool: ${message}`);
|
|
95279
95312
|
throw error;
|
|
95280
95313
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdfriday/foundry",
|
|
3
|
-
"version": "26.2.
|
|
3
|
+
"version": "26.2.6",
|
|
4
4
|
"description": "The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|