@lytjs/core 6.0.0 → 6.4.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/index.cjs +108 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -1
- package/dist/index.d.ts +84 -1
- package/dist/index.mjs +103 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,6 @@ var vdom = require('@lytjs/vdom');
|
|
|
6
6
|
var reactivity = require('@lytjs/reactivity');
|
|
7
7
|
var commonScheduler = require('@lytjs/common-scheduler');
|
|
8
8
|
var commonIs = require('@lytjs/common-is');
|
|
9
|
-
var scope = require('@lytjs/reactivity/scope');
|
|
10
9
|
var renderer = require('@lytjs/renderer');
|
|
11
10
|
var commonObject = require('@lytjs/common-object');
|
|
12
11
|
var compiler = require('@lytjs/compiler');
|
|
@@ -920,6 +919,9 @@ function createApp(rootComponent, rootProps = null, options) {
|
|
|
920
919
|
const app = {
|
|
921
920
|
config: createContextConfig(context),
|
|
922
921
|
use(plugin, ...options2) {
|
|
922
|
+
if (plugin == null) {
|
|
923
|
+
return app;
|
|
924
|
+
}
|
|
923
925
|
if (installedPlugins.has(plugin)) return app;
|
|
924
926
|
try {
|
|
925
927
|
if (typeof plugin !== "function" && "name" in plugin && typeof plugin.name === "string") {
|
|
@@ -952,7 +954,9 @@ function createApp(rootComponent, rootProps = null, options) {
|
|
|
952
954
|
return app;
|
|
953
955
|
}
|
|
954
956
|
}
|
|
955
|
-
plugin.install
|
|
957
|
+
if (typeof plugin.install === "function") {
|
|
958
|
+
plugin.install(app, ...options2);
|
|
959
|
+
}
|
|
956
960
|
pluginRegistry.markInstalled(enhancedPlugin.name);
|
|
957
961
|
if (enhancedPlugin.afterInstall) {
|
|
958
962
|
enhancedPlugin.afterInstall(app);
|
|
@@ -960,7 +964,7 @@ function createApp(rootComponent, rootProps = null, options) {
|
|
|
960
964
|
} else {
|
|
961
965
|
if (typeof plugin === "function") {
|
|
962
966
|
plugin(app, ...options2);
|
|
963
|
-
} else {
|
|
967
|
+
} else if (plugin && typeof plugin.install === "function") {
|
|
964
968
|
plugin.install(app, ...options2);
|
|
965
969
|
}
|
|
966
970
|
}
|
|
@@ -1610,7 +1614,7 @@ function useTemplateRef(key) {
|
|
|
1610
1614
|
},
|
|
1611
1615
|
{ immediate: true, flush: "pre" }
|
|
1612
1616
|
);
|
|
1613
|
-
|
|
1617
|
+
reactivity.onScopeDispose(stop);
|
|
1614
1618
|
}
|
|
1615
1619
|
return ref3;
|
|
1616
1620
|
}
|
|
@@ -1662,7 +1666,7 @@ function useCssVars(vars) {
|
|
|
1662
1666
|
};
|
|
1663
1667
|
component.onMounted(updateStyle);
|
|
1664
1668
|
const stop = reactivity.watchEffect(updateStyle);
|
|
1665
|
-
|
|
1669
|
+
reactivity.onScopeDispose(() => {
|
|
1666
1670
|
stop();
|
|
1667
1671
|
const el = instance.vnode?.el;
|
|
1668
1672
|
if (el) {
|
|
@@ -3231,6 +3235,93 @@ var init_common_integration = __esm({
|
|
|
3231
3235
|
_integrations = {};
|
|
3232
3236
|
}
|
|
3233
3237
|
});
|
|
3238
|
+
function setGlobalErrorReporter(reporter) {
|
|
3239
|
+
globalReporter = reporter;
|
|
3240
|
+
}
|
|
3241
|
+
function getGlobalErrorReporter() {
|
|
3242
|
+
return globalReporter;
|
|
3243
|
+
}
|
|
3244
|
+
function createElement(type, props, ...children) {
|
|
3245
|
+
return vdom.createVNode(type, props, children);
|
|
3246
|
+
}
|
|
3247
|
+
function ErrorBoundary(props) {
|
|
3248
|
+
props.maxRetries ?? 3;
|
|
3249
|
+
props.retryDelay ?? 1e3;
|
|
3250
|
+
const state = {
|
|
3251
|
+
resetKey: 0};
|
|
3252
|
+
return createElement("error-boundary-wrapper", {
|
|
3253
|
+
"data-error": "false",
|
|
3254
|
+
key: `reset-${state.resetKey}`
|
|
3255
|
+
}, null);
|
|
3256
|
+
}
|
|
3257
|
+
function useErrorHandler() {
|
|
3258
|
+
return (error3) => {
|
|
3259
|
+
throw error3;
|
|
3260
|
+
};
|
|
3261
|
+
}
|
|
3262
|
+
function useErrorBoundaryReset() {
|
|
3263
|
+
return () => {
|
|
3264
|
+
console.warn("useErrorBoundaryReset should be used within ErrorBoundary");
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
3267
|
+
var ConsoleErrorReporter, globalReporter, ErrorLogManager; exports.errorLogManager = void 0;
|
|
3268
|
+
var init_error_boundary = __esm({
|
|
3269
|
+
"src/error-boundary.ts"() {
|
|
3270
|
+
ConsoleErrorReporter = class {
|
|
3271
|
+
report(error3, context) {
|
|
3272
|
+
console.error("[LytJS ErrorBoundary]", {
|
|
3273
|
+
message: error3.message,
|
|
3274
|
+
stack: error3.stack,
|
|
3275
|
+
context
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3278
|
+
};
|
|
3279
|
+
globalReporter = new ConsoleErrorReporter();
|
|
3280
|
+
ErrorLogManager = class {
|
|
3281
|
+
constructor() {
|
|
3282
|
+
this.logs = [];
|
|
3283
|
+
this.maxLogs = 100;
|
|
3284
|
+
}
|
|
3285
|
+
addLog(log) {
|
|
3286
|
+
this.logs.unshift(log);
|
|
3287
|
+
if (this.logs.length > this.maxLogs) {
|
|
3288
|
+
this.logs = this.logs.slice(0, this.maxLogs);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
getLogs() {
|
|
3292
|
+
return [...this.logs];
|
|
3293
|
+
}
|
|
3294
|
+
clearLogs() {
|
|
3295
|
+
this.logs = [];
|
|
3296
|
+
}
|
|
3297
|
+
exportLogs() {
|
|
3298
|
+
return JSON.stringify(this.logs, null, 2);
|
|
3299
|
+
}
|
|
3300
|
+
getLogById(id) {
|
|
3301
|
+
return this.logs.find((log) => log.id === id);
|
|
3302
|
+
}
|
|
3303
|
+
getLogsByErrorType(errorType) {
|
|
3304
|
+
return this.logs.filter((log) => log.error.name === errorType);
|
|
3305
|
+
}
|
|
3306
|
+
getLogsByDateRange(start, end) {
|
|
3307
|
+
return this.logs.filter((log) => log.timestamp >= start && log.timestamp <= end);
|
|
3308
|
+
}
|
|
3309
|
+
getErrorStats() {
|
|
3310
|
+
const errorTypes = {};
|
|
3311
|
+
this.logs.forEach((log) => {
|
|
3312
|
+
const type = log.error.name || "Unknown";
|
|
3313
|
+
errorTypes[type] = (errorTypes[type] || 0) + 1;
|
|
3314
|
+
});
|
|
3315
|
+
return {
|
|
3316
|
+
totalErrors: this.logs.length,
|
|
3317
|
+
errorTypes,
|
|
3318
|
+
recentErrors: this.logs.slice(0, 10)
|
|
3319
|
+
};
|
|
3320
|
+
}
|
|
3321
|
+
};
|
|
3322
|
+
exports.errorLogManager = new ErrorLogManager();
|
|
3323
|
+
}
|
|
3324
|
+
});
|
|
3234
3325
|
|
|
3235
3326
|
// src/index.ts
|
|
3236
3327
|
var src_exports = {};
|
|
@@ -3239,6 +3330,7 @@ __export(src_exports, {
|
|
|
3239
3330
|
ConfigManager: () => exports.ConfigManager,
|
|
3240
3331
|
ConfigTransformer: () => exports.ConfigTransformer,
|
|
3241
3332
|
ConfigValidator: () => exports.ConfigValidator,
|
|
3333
|
+
ErrorBoundary: () => ErrorBoundary,
|
|
3242
3334
|
Fragment: () => vdom.Fragment,
|
|
3243
3335
|
PluginRegistry: () => exports.PluginRegistry,
|
|
3244
3336
|
PluginValidator: () => exports.PluginValidator,
|
|
@@ -3258,9 +3350,11 @@ __export(src_exports, {
|
|
|
3258
3350
|
defineModel: () => defineModel,
|
|
3259
3351
|
definePlugin: () => definePlugin,
|
|
3260
3352
|
effect: () => reactivity.effect,
|
|
3353
|
+
errorLogManager: () => exports.errorLogManager,
|
|
3261
3354
|
getCacheUtils: () => getCacheUtils,
|
|
3262
3355
|
getConfig: () => getConfig,
|
|
3263
3356
|
getGlobalConfig: () => getGlobalConfig,
|
|
3357
|
+
getGlobalErrorReporter: () => getGlobalErrorReporter,
|
|
3264
3358
|
getHttpClient: () => getHttpClient,
|
|
3265
3359
|
getQueryUtils: () => getQueryUtils,
|
|
3266
3360
|
getSecurityUtils: () => getSecurityUtils,
|
|
@@ -3291,12 +3385,15 @@ __export(src_exports, {
|
|
|
3291
3385
|
safeParseQueryString: () => safeParseQueryString,
|
|
3292
3386
|
setConfig: () => setConfig,
|
|
3293
3387
|
setGlobalConfig: () => setGlobalConfig,
|
|
3388
|
+
setGlobalErrorReporter: () => setGlobalErrorReporter,
|
|
3294
3389
|
testPluginInstall: () => testPluginInstall,
|
|
3295
3390
|
transformConfig: () => transformConfig,
|
|
3296
3391
|
transformPluginConfig: () => transformPluginConfig,
|
|
3297
3392
|
useAttrs: () => useAttrs,
|
|
3298
3393
|
useCssModule: () => useCssModule,
|
|
3299
3394
|
useCssVars: () => useCssVars,
|
|
3395
|
+
useErrorBoundaryReset: () => useErrorBoundaryReset,
|
|
3396
|
+
useErrorHandler: () => useErrorHandler,
|
|
3300
3397
|
useHost: () => useHost,
|
|
3301
3398
|
useId: () => useId,
|
|
3302
3399
|
useModel: () => useModel,
|
|
@@ -3330,6 +3427,7 @@ var init_src = __esm({
|
|
|
3330
3427
|
init_plugin_sdk();
|
|
3331
3428
|
init_config();
|
|
3332
3429
|
init_common_integration();
|
|
3430
|
+
init_error_boundary();
|
|
3333
3431
|
}
|
|
3334
3432
|
});
|
|
3335
3433
|
init_src();
|
|
@@ -3434,6 +3532,7 @@ Object.defineProperty(exports, "compile", {
|
|
|
3434
3532
|
enumerable: true,
|
|
3435
3533
|
get: function () { return compiler.compile; }
|
|
3436
3534
|
});
|
|
3535
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
3437
3536
|
exports.applyConfigPreset = applyConfigPreset;
|
|
3438
3537
|
exports.createApp = createApp;
|
|
3439
3538
|
exports.createElement = h;
|
|
@@ -3445,6 +3544,7 @@ exports.definePlugin = definePlugin;
|
|
|
3445
3544
|
exports.getCacheUtils = getCacheUtils;
|
|
3446
3545
|
exports.getConfig = getConfig;
|
|
3447
3546
|
exports.getGlobalConfig = getGlobalConfig;
|
|
3547
|
+
exports.getGlobalErrorReporter = getGlobalErrorReporter;
|
|
3448
3548
|
exports.getHttpClient = getHttpClient;
|
|
3449
3549
|
exports.getQueryUtils = getQueryUtils;
|
|
3450
3550
|
exports.getSecurityUtils = getSecurityUtils;
|
|
@@ -3460,12 +3560,15 @@ exports.safeEscapeHtml = safeEscapeHtml;
|
|
|
3460
3560
|
exports.safeParseQueryString = safeParseQueryString;
|
|
3461
3561
|
exports.setConfig = setConfig;
|
|
3462
3562
|
exports.setGlobalConfig = setGlobalConfig;
|
|
3563
|
+
exports.setGlobalErrorReporter = setGlobalErrorReporter;
|
|
3463
3564
|
exports.testPluginInstall = testPluginInstall;
|
|
3464
3565
|
exports.transformConfig = transformConfig;
|
|
3465
3566
|
exports.transformPluginConfig = transformPluginConfig;
|
|
3466
3567
|
exports.useAttrs = useAttrs;
|
|
3467
3568
|
exports.useCssModule = useCssModule;
|
|
3468
3569
|
exports.useCssVars = useCssVars;
|
|
3570
|
+
exports.useErrorBoundaryReset = useErrorBoundaryReset;
|
|
3571
|
+
exports.useErrorHandler = useErrorHandler;
|
|
3469
3572
|
exports.useHost = useHost;
|
|
3470
3573
|
exports.useId = useId;
|
|
3471
3574
|
exports.useModel = useModel;
|