@yoooloo42/joker 1.0.162 → 1.0.163

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.js CHANGED
@@ -16198,7 +16198,7 @@ const isNumber = typeOfTest('number');
16198
16198
  *
16199
16199
  * @returns {boolean} True if value is an Object, otherwise false
16200
16200
  */
16201
- const isObject = (thing) => thing !== null && typeof thing === 'object';
16201
+ const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
16202
16202
 
16203
16203
  /**
16204
16204
  * Determine if a value is a Boolean
@@ -16233,7 +16233,7 @@ const isPlainObject = (val) => {
16233
16233
  */
16234
16234
  const isEmptyObject = (val) => {
16235
16235
  // Early return for non-objects or Buffers to prevent RangeError
16236
- if (!isObject(val) || isBuffer$1(val)) {
16236
+ if (!isObject$1(val) || isBuffer$1(val)) {
16237
16237
  return false;
16238
16238
  }
16239
16239
 
@@ -16288,7 +16288,7 @@ const isFileList = kindOfTest('FileList');
16288
16288
  *
16289
16289
  * @returns {boolean} True if value is a Stream, otherwise false
16290
16290
  */
16291
- const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
16291
+ const isStream = (val) => isObject$1(val) && isFunction$1(val.pipe);
16292
16292
 
16293
16293
  /**
16294
16294
  * Determine if a value is a FormData
@@ -16739,7 +16739,7 @@ const toJSONObject = (obj) => {
16739
16739
 
16740
16740
  const visit = (source, i) => {
16741
16741
 
16742
- if (isObject(source)) {
16742
+ if (isObject$1(source)) {
16743
16743
  if (stack.indexOf(source) >= 0) {
16744
16744
  return;
16745
16745
  }
@@ -16773,7 +16773,7 @@ const toJSONObject = (obj) => {
16773
16773
  const isAsyncFn = kindOfTest('AsyncFunction');
16774
16774
 
16775
16775
  const isThenable = (thing) =>
16776
- thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
16776
+ thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
16777
16777
 
16778
16778
  // original code
16779
16779
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -16818,7 +16818,7 @@ var utils$1 = {
16818
16818
  isString,
16819
16819
  isNumber,
16820
16820
  isBoolean,
16821
- isObject,
16821
+ isObject: isObject$1,
16822
16822
  isPlainObject,
16823
16823
  isEmptyObject,
16824
16824
  isReadableStream,
@@ -22317,6 +22317,13 @@ function typeOfValue(value) {
22317
22317
  return className.toLowerCase();
22318
22318
  }
22319
22319
 
22320
+ /**
22321
+ * 判断是否为普通对象(排除 null 和 Array)
22322
+ */
22323
+ function isObject(val) {
22324
+ return typeof val === 'object' && val !== null && !Array.isArray(val);
22325
+ }
22326
+
22320
22327
  /**
22321
22328
  * 判断一个字符串是否是有效的 JSON 格式
22322
22329
  *
@@ -22572,47 +22579,66 @@ function getNodeValue(tree, nodeName) {
22572
22579
  }
22573
22580
 
22574
22581
  /**
22575
- * 深度非侵入式合并函数 (Deep Non-Destructive Merge)
22576
- * * 特点:
22577
- * 1. 深度递归地合并对象属性。
22578
- * 2. 源对象中缺失的属性不会删除或覆盖目标对象中已存在的对应属性。
22579
- * 3. 数组会被源对象中的数组完全覆盖。
22580
- * * @param {Object} target 目标对象(将被修改)
22582
+ * 深度合并 (Deep Merge)
22583
+ * 1. 深度递归地合并对象属性
22584
+ * 2. 目标对象中已存在的属性会被源对象中对应(同级、同名)的属性覆盖,缺失的,会从源对象中获取
22585
+ * 3. 数组视同简单值不进行递归处理
22586
+ * 适用场景:配置更新、状态同步
22587
+ * @param {Object} target 目标对象(将被修改)
22581
22588
  * @param {Object} source 源对象
22582
22589
  * @returns {Object} 修改后的目标对象
22583
22590
  */
22584
22591
  function deepMerge(target, source) {
22585
- // 确保源对象是一个有效的对象,如果不是则直接返回目标对象
22586
- if (typeof source !== 'object' || source === null) {
22587
- return target;
22588
- }
22592
+ if (!isObject(source)) return target;
22593
+ if (!isObject(target)) return source;
22589
22594
 
22590
22595
  for (const key in source) {
22591
- // 确保只处理源对象自身的属性
22592
22596
  if (Object.prototype.hasOwnProperty.call(source, key)) {
22593
22597
  const sourceValue = source[key];
22594
22598
  const targetValue = target[key];
22595
22599
 
22596
- // 1. 如果源属性的值是对象且目标属性的值也是对象,则递归合并
22597
- if (
22598
- typeof sourceValue === 'object' && sourceValue !== null &&
22599
- !Array.isArray(sourceValue) &&
22600
- typeof targetValue === 'object' && targetValue !== null &&
22601
- !Array.isArray(targetValue)
22602
- ) {
22603
- // 递归调用自身进行深度合并
22600
+ if (isObject(sourceValue) && isObject(targetValue)) {
22601
+ // 递归合并
22604
22602
  target[key] = deepMerge(targetValue, sourceValue);
22605
- }
22606
- // 2. 对于其他类型(基本类型、数组、null),直接覆盖
22607
- else {
22608
- // 这里的关键是:只有源对象中存在的属性,才会覆盖目标对象的属性。
22609
- // 如果源对象中不存在某个键(key),则不会进入此循环,
22610
- // 从而目标对象中已有的该属性得以保留。
22603
+ } else {
22604
+ // 覆盖:包含基本类型、数组或目标缺失的情况
22611
22605
  target[key] = sourceValue;
22612
22606
  }
22613
22607
  }
22614
22608
  }
22609
+ return target;
22610
+ }
22611
+
22612
+ /**
22613
+ * 深度默认值 (Deep Defaults)
22614
+ * 1. 深度递归地合并对象属性
22615
+ * 2. 目标对象中已存在的属性不会被源对象影响,缺失的,会从源对象中获取
22616
+ * 3. 数组视同简单值不进行递归处理
22617
+ * 适用场景:初始化配置,并确保目标对象结构的完整性
22618
+ * @param {Object} target 目标对象(将被修改)
22619
+ * @param {Object} source 源对象(提供默认值的参考对象)
22620
+ * @returns {Object} 修改后的目标对象
22621
+ */
22622
+ function deepDefaults(target, source) {
22623
+ if (!isObject(source)) return target;
22624
+ // 如果 target 不是对象,为了填充属性,需将其初始化为对象
22625
+ if (!isObject(target)) target = {};
22626
+
22627
+ for (const key in source) {
22628
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
22629
+ const sourceValue = source[key];
22630
+ const targetValue = target[key];
22615
22631
 
22632
+ if (!(key in target)) {
22633
+ // 目标完全没有这个键,直接取源的值
22634
+ target[key] = sourceValue;
22635
+ } else if (isObject(sourceValue) && isObject(targetValue)) {
22636
+ // 目标和源都有此对象,递归检查内部缺失
22637
+ deepDefaults(targetValue, sourceValue);
22638
+ }
22639
+ // 目标已有基本类型值或数组,跳过
22640
+ }
22641
+ }
22616
22642
  return target;
22617
22643
  }
22618
22644
  var deepClone = {
@@ -22624,7 +22650,8 @@ var deepClone = {
22624
22650
  arrayToTree,
22625
22651
  getLeafValue,
22626
22652
  getNodeValue,
22627
- deepMerge
22653
+ deepMerge,
22654
+ deepDefaults
22628
22655
  };
22629
22656
 
22630
22657
  var unclassified = {
@@ -24371,10 +24398,7 @@ const props = __props;
24371
24398
 
24372
24399
  // 顶层组件的props属性需做响应性包装,页面和js可以使用相同的命名
24373
24400
  let formData_box = vue.reactive(props.modelValue);
24374
- const formProps_box = vue.reactive(unclassified.deepClone.deepMerge(
24375
- unclassified.deepClone.deepClone(ly0default$3.myProps),
24376
- props.myProps
24377
- ));
24401
+ const formProps_box = vue.reactive(unclassified.deepClone.deepDefaults(props.myProps, ly0default$3.myProps));
24378
24402
  const scopeThis_box = vue.reactive(props.scopeThis);
24379
24403
 
24380
24404
  return (_ctx, _cache) => {
@@ -42144,7 +42168,6 @@ return (_ctx, _cache) => {
42144
42168
  }), 128 /* KEYED_FRAGMENT */))
42145
42169
  ], 4 /* STYLE */))
42146
42170
  : vue.createCommentVNode("v-if", true),
42147
- vue.createTextVNode(" " + vue.toDisplayString('测试loading: '+vue.unref(tableProps_box).table.loading.visible) + " ", 1 /* TEXT */),
42148
42171
  vue.createCommentVNode(" 表体 "),
42149
42172
  vue.withDirectives((vue.openBlock(), vue.createBlock(_component_el_table, {
42150
42173
  data: vue.unref(tableData_box).data,
@@ -42482,11 +42505,8 @@ var script$c = {
42482
42505
  const props = __props;
42483
42506
 
42484
42507
  // 顶层组件的props属性需做响应性包装,页面和js可以使用相同的命名
42485
- let tableData_box = vue.reactive(unclassified.deepClone.deepMerge(props.modelValue, ly0default$1.modelValue));
42486
- const tableProps_box = vue.reactive(unclassified.deepClone.deepMerge(props.myProps, ly0default$1.myProps));
42487
-
42488
- console.log('测试 000', tableData_box);
42489
- console.log('测试 111', tableProps_box);
42508
+ let tableData_box = vue.reactive(unclassified.deepClone.deepDefaults(props.modelValue, ly0default$1.modelValue));
42509
+ const tableProps_box = vue.reactive(unclassified.deepClone.deepDefaults(props.myProps, ly0default$1.myProps));
42490
42510
 
42491
42511
  const scopeThis_box = vue.reactive(props.scopeThis);
42492
42512