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