@lytjs/core 6.5.0 → 6.6.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.mjs CHANGED
@@ -968,7 +968,10 @@ function createApp(rootComponent, rootProps = null, options) {
968
968
  if (typeof plugin === "function") {
969
969
  plugin(app, ...options2);
970
970
  } else if (plugin && typeof plugin.install === "function") {
971
- plugin.install(app, ...options2);
971
+ plugin.install(
972
+ app,
973
+ ...options2
974
+ );
972
975
  }
973
976
  }
974
977
  installedPlugins.add(plugin);
@@ -1903,13 +1906,15 @@ var init_config_validator = __esm({
1903
1906
  if (value === void 0) {
1904
1907
  if (schema.required) {
1905
1908
  errors.push(this.createError(path, "required", "Value is required"));
1906
- } else if (schema.default !== void 0) ;
1909
+ }
1907
1910
  return { valid: errors.length === 0, errors, errorCount: errors.length, warningCount: 0 };
1908
1911
  }
1909
1912
  if (schema.validate) {
1910
1913
  const result = schema.validate(value, context);
1911
1914
  if (!result.valid) {
1912
- errors.push(this.createError(path, "custom_error", result.message || "Custom validation failed"));
1915
+ errors.push(
1916
+ this.createError(path, "custom_error", result.message || "Custom validation failed")
1917
+ );
1913
1918
  }
1914
1919
  }
1915
1920
  switch (schema.type) {
@@ -1923,7 +1928,9 @@ var init_config_validator = __esm({
1923
1928
  errors.push(...this.validateBoolean(value, schema, path));
1924
1929
  break;
1925
1930
  case "object":
1926
- errors.push(...this.validateObject(value, schema, path));
1931
+ errors.push(
1932
+ ...this.validateObject(value, schema, path)
1933
+ );
1927
1934
  break;
1928
1935
  case "array":
1929
1936
  errors.push(...this.validateArray(value, schema, path));
@@ -1954,54 +1961,72 @@ var init_config_validator = __esm({
1954
1961
  validateString(value, schema, path) {
1955
1962
  const errors = [];
1956
1963
  if (typeof value !== "string") {
1957
- errors.push(this.createError(path, "type_error", `Expected string, got ${typeof value}`, "string", value));
1964
+ errors.push(
1965
+ this.createError(
1966
+ path,
1967
+ "type_error",
1968
+ `Expected string, got ${typeof value}`,
1969
+ "string",
1970
+ value
1971
+ )
1972
+ );
1958
1973
  return errors;
1959
1974
  }
1960
1975
  const stringSchema = schema.string || {};
1961
1976
  if (stringSchema.minLength !== void 0 && value.length < stringSchema.minLength) {
1962
- errors.push(this.createError(
1963
- path,
1964
- "min_length",
1965
- `String must be at least ${stringSchema.minLength} characters`,
1966
- `minLength: ${stringSchema.minLength}`,
1967
- value.length
1968
- ));
1977
+ errors.push(
1978
+ this.createError(
1979
+ path,
1980
+ "min_length",
1981
+ `String must be at least ${stringSchema.minLength} characters`,
1982
+ `minLength: ${stringSchema.minLength}`,
1983
+ value.length
1984
+ )
1985
+ );
1969
1986
  }
1970
1987
  if (stringSchema.maxLength !== void 0 && value.length > stringSchema.maxLength) {
1971
- errors.push(this.createError(
1972
- path,
1973
- "max_length",
1974
- `String must be at most ${stringSchema.maxLength} characters`,
1975
- `maxLength: ${stringSchema.maxLength}`,
1976
- value.length
1977
- ));
1988
+ errors.push(
1989
+ this.createError(
1990
+ path,
1991
+ "max_length",
1992
+ `String must be at most ${stringSchema.maxLength} characters`,
1993
+ `maxLength: ${stringSchema.maxLength}`,
1994
+ value.length
1995
+ )
1996
+ );
1978
1997
  }
1979
1998
  if (stringSchema.pattern) {
1980
1999
  const pattern = typeof stringSchema.pattern === "string" ? new RegExp(stringSchema.pattern) : stringSchema.pattern;
1981
2000
  if (!pattern.test(value)) {
1982
- errors.push(this.createError(
1983
- path,
1984
- "pattern_mismatch",
1985
- `String does not match pattern: ${stringSchema.pattern}`,
1986
- String(stringSchema.pattern),
1987
- value
1988
- ));
2001
+ errors.push(
2002
+ this.createError(
2003
+ path,
2004
+ "pattern_mismatch",
2005
+ `String does not match pattern: ${stringSchema.pattern}`,
2006
+ String(stringSchema.pattern),
2007
+ value
2008
+ )
2009
+ );
1989
2010
  }
1990
2011
  }
1991
2012
  if (stringSchema.format && this.isStringType(value)) {
1992
2013
  const formatError = this.validateFormat(value, stringSchema.format);
1993
2014
  if (formatError) {
1994
- errors.push(this.createError(path, "format_error", formatError, stringSchema.format, value));
2015
+ errors.push(
2016
+ this.createError(path, "format_error", formatError, stringSchema.format, value)
2017
+ );
1995
2018
  }
1996
2019
  }
1997
2020
  if (stringSchema.enum && !stringSchema.enum.includes(value)) {
1998
- errors.push(this.createError(
1999
- path,
2000
- "enum_mismatch",
2001
- `Value must be one of: ${stringSchema.enum.join(", ")}`,
2002
- stringSchema.enum.join(" | "),
2003
- value
2004
- ));
2021
+ errors.push(
2022
+ this.createError(
2023
+ path,
2024
+ "enum_mismatch",
2025
+ `Value must be one of: ${stringSchema.enum.join(", ")}`,
2026
+ stringSchema.enum.join(" | "),
2027
+ value
2028
+ )
2029
+ );
2005
2030
  }
2006
2031
  return errors;
2007
2032
  }
@@ -2011,57 +2036,77 @@ var init_config_validator = __esm({
2011
2036
  validateNumber(value, schema, path) {
2012
2037
  const errors = [];
2013
2038
  if (typeof value !== "number" || Number.isNaN(value)) {
2014
- errors.push(this.createError(path, "type_error", `Expected number, got ${typeof value}`, "number", value));
2039
+ errors.push(
2040
+ this.createError(
2041
+ path,
2042
+ "type_error",
2043
+ `Expected number, got ${typeof value}`,
2044
+ "number",
2045
+ value
2046
+ )
2047
+ );
2015
2048
  return errors;
2016
2049
  }
2017
2050
  const numberSchema = schema.number || {};
2018
2051
  if (numberSchema.integer && !Number.isInteger(value)) {
2019
- errors.push(this.createError(path, "type_error", "Value must be an integer", "integer", value));
2052
+ errors.push(
2053
+ this.createError(path, "type_error", "Value must be an integer", "integer", value)
2054
+ );
2020
2055
  }
2021
2056
  if (numberSchema.minimum !== void 0 && value < numberSchema.minimum) {
2022
- errors.push(this.createError(
2023
- path,
2024
- "minimum",
2025
- `Value must be >= ${numberSchema.minimum}`,
2026
- `minimum: ${numberSchema.minimum}`,
2027
- value
2028
- ));
2057
+ errors.push(
2058
+ this.createError(
2059
+ path,
2060
+ "minimum",
2061
+ `Value must be >= ${numberSchema.minimum}`,
2062
+ `minimum: ${numberSchema.minimum}`,
2063
+ value
2064
+ )
2065
+ );
2029
2066
  }
2030
2067
  if (numberSchema.maximum !== void 0 && value > numberSchema.maximum) {
2031
- errors.push(this.createError(
2032
- path,
2033
- "maximum",
2034
- `Value must be <= ${numberSchema.maximum}`,
2035
- `maximum: ${numberSchema.maximum}`,
2036
- value
2037
- ));
2068
+ errors.push(
2069
+ this.createError(
2070
+ path,
2071
+ "maximum",
2072
+ `Value must be <= ${numberSchema.maximum}`,
2073
+ `maximum: ${numberSchema.maximum}`,
2074
+ value
2075
+ )
2076
+ );
2038
2077
  }
2039
2078
  if (numberSchema.exclusiveMinimum !== void 0 && value <= numberSchema.exclusiveMinimum) {
2040
- errors.push(this.createError(
2041
- path,
2042
- "minimum",
2043
- `Value must be > ${numberSchema.exclusiveMinimum}`,
2044
- `exclusiveMinimum: ${numberSchema.exclusiveMinimum}`,
2045
- value
2046
- ));
2079
+ errors.push(
2080
+ this.createError(
2081
+ path,
2082
+ "minimum",
2083
+ `Value must be > ${numberSchema.exclusiveMinimum}`,
2084
+ `exclusiveMinimum: ${numberSchema.exclusiveMinimum}`,
2085
+ value
2086
+ )
2087
+ );
2047
2088
  }
2048
2089
  if (numberSchema.exclusiveMaximum !== void 0 && value >= numberSchema.exclusiveMaximum) {
2049
- errors.push(this.createError(
2050
- path,
2051
- "maximum",
2052
- `Value must be < ${numberSchema.exclusiveMaximum}`,
2053
- `exclusiveMaximum: ${numberSchema.exclusiveMaximum}`,
2054
- value
2055
- ));
2090
+ errors.push(
2091
+ this.createError(
2092
+ path,
2093
+ "maximum",
2094
+ `Value must be < ${numberSchema.exclusiveMaximum}`,
2095
+ `exclusiveMaximum: ${numberSchema.exclusiveMaximum}`,
2096
+ value
2097
+ )
2098
+ );
2056
2099
  }
2057
2100
  if (numberSchema.enum && !numberSchema.enum.includes(value)) {
2058
- errors.push(this.createError(
2059
- path,
2060
- "enum_mismatch",
2061
- `Value must be one of: ${numberSchema.enum.join(", ")}`,
2062
- numberSchema.enum.join(" | "),
2063
- value
2064
- ));
2101
+ errors.push(
2102
+ this.createError(
2103
+ path,
2104
+ "enum_mismatch",
2105
+ `Value must be one of: ${numberSchema.enum.join(", ")}`,
2106
+ numberSchema.enum.join(" | "),
2107
+ value
2108
+ )
2109
+ );
2065
2110
  }
2066
2111
  return errors;
2067
2112
  }
@@ -2071,7 +2116,15 @@ var init_config_validator = __esm({
2071
2116
  validateBoolean(value, _schema, path) {
2072
2117
  const errors = [];
2073
2118
  if (typeof value !== "boolean") {
2074
- errors.push(this.createError(path, "type_error", `Expected boolean, got ${typeof value}`, "boolean", value));
2119
+ errors.push(
2120
+ this.createError(
2121
+ path,
2122
+ "type_error",
2123
+ `Expected boolean, got ${typeof value}`,
2124
+ "boolean",
2125
+ value
2126
+ )
2127
+ );
2075
2128
  }
2076
2129
  return errors;
2077
2130
  }
@@ -2081,7 +2134,15 @@ var init_config_validator = __esm({
2081
2134
  validateObject(value, schema, path) {
2082
2135
  const errors = [];
2083
2136
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
2084
- errors.push(this.createError(path, "type_error", `Expected object, got ${typeof value}`, "object", value));
2137
+ errors.push(
2138
+ this.createError(
2139
+ path,
2140
+ "type_error",
2141
+ `Expected object, got ${typeof value}`,
2142
+ "object",
2143
+ value
2144
+ )
2145
+ );
2085
2146
  return errors;
2086
2147
  }
2087
2148
  const objectSchema = schema.object;
@@ -2089,22 +2150,26 @@ var init_config_validator = __esm({
2089
2150
  const obj = value;
2090
2151
  const keys = Object.keys(obj);
2091
2152
  if (objectSchema.maxProperties !== void 0 && keys.length > objectSchema.maxProperties) {
2092
- errors.push(this.createError(
2093
- path,
2094
- "max_items",
2095
- `Object must have at most ${objectSchema.maxProperties} properties`,
2096
- `maxProperties: ${objectSchema.maxProperties}`,
2097
- keys.length
2098
- ));
2153
+ errors.push(
2154
+ this.createError(
2155
+ path,
2156
+ "max_items",
2157
+ `Object must have at most ${objectSchema.maxProperties} properties`,
2158
+ `maxProperties: ${objectSchema.maxProperties}`,
2159
+ keys.length
2160
+ )
2161
+ );
2099
2162
  }
2100
2163
  if (objectSchema.minProperties !== void 0 && keys.length < objectSchema.minProperties) {
2101
- errors.push(this.createError(
2102
- path,
2103
- "min_items",
2104
- `Object must have at least ${objectSchema.minProperties} properties`,
2105
- `minProperties: ${objectSchema.minProperties}`,
2106
- keys.length
2107
- ));
2164
+ errors.push(
2165
+ this.createError(
2166
+ path,
2167
+ "min_items",
2168
+ `Object must have at least ${objectSchema.minProperties} properties`,
2169
+ `minProperties: ${objectSchema.minProperties}`,
2170
+ keys.length
2171
+ )
2172
+ );
2108
2173
  }
2109
2174
  for (const [key, propertySchema] of Object.entries(objectSchema.properties || {})) {
2110
2175
  const propertyPath = path ? `${path}.${key}` : key;
@@ -2131,13 +2196,15 @@ var init_config_validator = __esm({
2131
2196
  }
2132
2197
  }
2133
2198
  if (!matchesPattern) {
2134
- errors.push(this.createError(
2135
- `${path}.${key}`,
2136
- "additional_properties",
2137
- `Additional property "${key}" is not allowed`,
2138
- key,
2139
- key
2140
- ));
2199
+ errors.push(
2200
+ this.createError(
2201
+ `${path}.${key}`,
2202
+ "additional_properties",
2203
+ `Additional property "${key}" is not allowed`,
2204
+ key,
2205
+ key
2206
+ )
2207
+ );
2141
2208
  }
2142
2209
  }
2143
2210
  }
@@ -2150,27 +2217,33 @@ var init_config_validator = __esm({
2150
2217
  validateArray(value, schema, path) {
2151
2218
  const errors = [];
2152
2219
  if (!Array.isArray(value)) {
2153
- errors.push(this.createError(path, "type_error", `Expected array, got ${typeof value}`, "array", value));
2220
+ errors.push(
2221
+ this.createError(path, "type_error", `Expected array, got ${typeof value}`, "array", value)
2222
+ );
2154
2223
  return errors;
2155
2224
  }
2156
2225
  const arraySchema = schema.array || {};
2157
2226
  if (arraySchema.minItems !== void 0 && value.length < arraySchema.minItems) {
2158
- errors.push(this.createError(
2159
- path,
2160
- "min_items",
2161
- `Array must have at least ${arraySchema.minItems} items`,
2162
- `minItems: ${arraySchema.minItems}`,
2163
- value.length
2164
- ));
2227
+ errors.push(
2228
+ this.createError(
2229
+ path,
2230
+ "min_items",
2231
+ `Array must have at least ${arraySchema.minItems} items`,
2232
+ `minItems: ${arraySchema.minItems}`,
2233
+ value.length
2234
+ )
2235
+ );
2165
2236
  }
2166
2237
  if (arraySchema.maxItems !== void 0 && value.length > arraySchema.maxItems) {
2167
- errors.push(this.createError(
2168
- path,
2169
- "max_items",
2170
- `Array must have at most ${arraySchema.maxItems} items`,
2171
- `maxItems: ${arraySchema.maxItems}`,
2172
- value.length
2173
- ));
2238
+ errors.push(
2239
+ this.createError(
2240
+ path,
2241
+ "max_items",
2242
+ `Array must have at most ${arraySchema.maxItems} items`,
2243
+ `maxItems: ${arraySchema.maxItems}`,
2244
+ value.length
2245
+ )
2246
+ );
2174
2247
  }
2175
2248
  if (arraySchema.uniqueItems) {
2176
2249
  const seen = /* @__PURE__ */ new Set();
@@ -2178,13 +2251,15 @@ var init_config_validator = __esm({
2178
2251
  const item = value[i];
2179
2252
  const key = JSON.stringify(item);
2180
2253
  if (seen.has(key)) {
2181
- errors.push(this.createError(
2182
- `${path}[${i}]`,
2183
- "unique_items",
2184
- `Duplicate item found at index ${i}`,
2185
- "uniqueItems",
2186
- item
2187
- ));
2254
+ errors.push(
2255
+ this.createError(
2256
+ `${path}[${i}]`,
2257
+ "unique_items",
2258
+ `Duplicate item found at index ${i}`,
2259
+ "uniqueItems",
2260
+ item
2261
+ )
2262
+ );
2188
2263
  }
2189
2264
  seen.add(key);
2190
2265
  }
@@ -2203,13 +2278,15 @@ var init_config_validator = __esm({
2203
2278
  errors.push(...itemReport.errors);
2204
2279
  }
2205
2280
  if (value.length !== arraySchema.tuple.length) {
2206
- errors.push(this.createError(
2207
- path,
2208
- "max_items",
2209
- `Tuple must have exactly ${arraySchema.tuple.length} items, got ${value.length}`,
2210
- `tuple length: ${arraySchema.tuple.length}`,
2211
- value.length
2212
- ));
2281
+ errors.push(
2282
+ this.createError(
2283
+ path,
2284
+ "max_items",
2285
+ `Tuple must have exactly ${arraySchema.tuple.length} items, got ${value.length}`,
2286
+ `tuple length: ${arraySchema.tuple.length}`,
2287
+ value.length
2288
+ )
2289
+ );
2213
2290
  }
2214
2291
  }
2215
2292
  return errors;
@@ -2221,13 +2298,15 @@ var init_config_validator = __esm({
2221
2298
  const errors = [];
2222
2299
  const enumSchema = schema.enum;
2223
2300
  if (!enumSchema.values.includes(value)) {
2224
- errors.push(this.createError(
2225
- path,
2226
- "enum_mismatch",
2227
- `Value must be one of: ${enumSchema.values.map((v) => JSON.stringify(v)).join(", ")}`,
2228
- enumSchema.values.map((v) => JSON.stringify(v)).join(" | "),
2229
- value
2230
- ));
2301
+ errors.push(
2302
+ this.createError(
2303
+ path,
2304
+ "enum_mismatch",
2305
+ `Value must be one of: ${enumSchema.values.map((v) => JSON.stringify(v)).join(", ")}`,
2306
+ enumSchema.values.map((v) => JSON.stringify(v)).join(" | "),
2307
+ value
2308
+ )
2309
+ );
2231
2310
  }
2232
2311
  return errors;
2233
2312
  }
@@ -2247,13 +2326,15 @@ var init_config_validator = __esm({
2247
2326
  }
2248
2327
  }
2249
2328
  if (!matched) {
2250
- errors.push(this.createError(
2251
- path,
2252
- "type_error",
2253
- "Value does not match any of the allowed types",
2254
- "union",
2255
- value
2256
- ));
2329
+ errors.push(
2330
+ this.createError(
2331
+ path,
2332
+ "type_error",
2333
+ "Value does not match any of the allowed types",
2334
+ "union",
2335
+ value
2336
+ )
2337
+ );
2257
2338
  }
2258
2339
  }
2259
2340
  if (unionSchema.oneOf) {
@@ -2265,13 +2346,15 @@ var init_config_validator = __esm({
2265
2346
  }
2266
2347
  }
2267
2348
  if (matchCount !== 1) {
2268
- errors.push(this.createError(
2269
- path,
2270
- "type_error",
2271
- `Value must match exactly one of the allowed types, matched ${matchCount}`,
2272
- "oneOf",
2273
- value
2274
- ));
2349
+ errors.push(
2350
+ this.createError(
2351
+ path,
2352
+ "type_error",
2353
+ `Value must match exactly one of the allowed types, matched ${matchCount}`,
2354
+ "oneOf",
2355
+ value
2356
+ )
2357
+ );
2275
2358
  }
2276
2359
  }
2277
2360
  return errors;
@@ -2427,20 +2510,32 @@ var init_config_transformer = __esm({
2427
2510
  }
2428
2511
  }
2429
2512
  if (schema.type === "object" && schema.object && typeof transformed === "object" && transformed !== null) {
2430
- const objectResult = this.transformObject(transformed, schema, path);
2513
+ const objectResult = this.transformObject(
2514
+ transformed,
2515
+ schema,
2516
+ path
2517
+ );
2431
2518
  transformed = objectResult.value;
2432
2519
  errors.push(...objectResult.errors);
2433
2520
  warnings.push(...objectResult.warnings);
2434
2521
  transforms.push(...objectResult.transforms);
2435
2522
  } else if (schema.type === "array" && schema.array && Array.isArray(transformed)) {
2436
- const arrayResult = this.transformArray(transformed, schema, path);
2523
+ const arrayResult = this.transformArray(
2524
+ transformed,
2525
+ schema,
2526
+ path
2527
+ );
2437
2528
  transformed = arrayResult.value;
2438
2529
  errors.push(...arrayResult.errors);
2439
2530
  warnings.push(...arrayResult.warnings);
2440
2531
  transforms.push(...arrayResult.transforms);
2441
2532
  }
2442
2533
  if (transformed !== void 0 && transformed !== null) {
2443
- const validationReport = this.validator.validate(transformed, schema, path);
2534
+ const validationReport = this.validator.validate(
2535
+ transformed,
2536
+ schema,
2537
+ path
2538
+ );
2444
2539
  errors.push(...validationReport.errors);
2445
2540
  }
2446
2541
  return {
@@ -2555,7 +2650,10 @@ var init_config_transformer = __esm({
2555
2650
  * @returns 合并后的配置
2556
2651
  */
2557
2652
  merge(defaults, overrides, schema) {
2558
- const merged = this.deepMerge(defaults, overrides);
2653
+ const merged = this.deepMerge(
2654
+ defaults,
2655
+ overrides
2656
+ );
2559
2657
  return this.transform(merged, schema);
2560
2658
  }
2561
2659
  /**
@@ -2566,7 +2664,10 @@ var init_config_transformer = __esm({
2566
2664
  for (const [key, value] of Object.entries(source)) {
2567
2665
  if (value !== void 0) {
2568
2666
  if (typeof value === "object" && value !== null && !Array.isArray(value) && typeof result[key] === "object" && result[key] !== null && !Array.isArray(result[key])) {
2569
- result[key] = this.deepMerge(result[key], value);
2667
+ result[key] = this.deepMerge(
2668
+ result[key],
2669
+ value
2670
+ );
2570
2671
  } else {
2571
2672
  result[key] = value;
2572
2673
  }
@@ -2588,7 +2689,11 @@ var init_config_transformer = __esm({
2588
2689
  if (key in configObj) {
2589
2690
  const propertySchema = schema.object?.properties?.[key];
2590
2691
  if (propertySchema) {
2591
- const propertyReport = this.transform(configObj[key], propertySchema, String(key));
2692
+ const propertyReport = this.transform(
2693
+ configObj[key],
2694
+ propertySchema,
2695
+ String(key)
2696
+ );
2592
2697
  if (propertyReport.success) {
2593
2698
  result[key] = propertyReport.config;
2594
2699
  }
@@ -3252,10 +3357,14 @@ function ErrorBoundary(props) {
3252
3357
  props.retryDelay ?? 1e3;
3253
3358
  const state = {
3254
3359
  resetKey: 0};
3255
- return createElement("error-boundary-wrapper", {
3256
- "data-error": "false",
3257
- key: `reset-${state.resetKey}`
3258
- }, null);
3360
+ return createElement(
3361
+ "error-boundary-wrapper",
3362
+ {
3363
+ "data-error": "false",
3364
+ key: `reset-${state.resetKey}`
3365
+ },
3366
+ null
3367
+ );
3259
3368
  }
3260
3369
  function useErrorHandler() {
3261
3370
  return (error3) => {