@joker.front/core 1.2.149 → 1.2.153

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/bundle.es.js CHANGED
@@ -432,10 +432,9 @@ function proxyData(data) {
432
432
  if (proxyDepTarget) {
433
433
  return data;
434
434
  }
435
- //@ts-ignore
436
- if (data[OBJECTPROXY_DATA_KEY]) {
437
- //@ts-ignore
438
- return data[OBJECTPROXY_DATA_KEY];
435
+ let readiedData = Reflect.get(data, OBJECTPROXY_DATA_KEY);
436
+ if (readiedData) {
437
+ return readiedData;
439
438
  }
440
439
  let dep = new Dep();
441
440
  //首次重置值
@@ -455,7 +454,7 @@ function proxyData(data) {
455
454
  if (key === OBJECTPROXY_DEPLEVE_ID) {
456
455
  return undefined;
457
456
  }
458
- let result = target[key];
457
+ let result = Reflect.get(target, key);
459
458
  if (hasProperty(target, key) === false && key !== "length") {
460
459
  return result;
461
460
  }
@@ -469,8 +468,7 @@ function proxyData(data) {
469
468
  },
470
469
  set(target, key, value) {
471
470
  if (resetData) {
472
- //@ts-ignore
473
- target[key] = value;
471
+ Reflect.set(target, key, value);
474
472
  return true;
475
473
  }
476
474
  if (checkEnableProxy(value)) {
@@ -478,8 +476,7 @@ function proxyData(data) {
478
476
  value = observer(value);
479
477
  }
480
478
  let isNewProperty = hasOwnProperty(target, key) === false;
481
- //@ts-ignore
482
- target[key] = value;
479
+ Reflect.set(target, key, value);
483
480
  notifyDep(dep, key);
484
481
  //数组长度变更,属于数组change,则对该对象做change广播
485
482
  if (Array.isArray(target)) {
@@ -492,8 +489,7 @@ function proxyData(data) {
492
489
  return true;
493
490
  },
494
491
  deleteProperty(target, key) {
495
- //@ts-ignore
496
- delete target[key];
492
+ Reflect.deleteProperty(target, key);
497
493
  //操作成功 && 非数组,删除属性时,要进行广播
498
494
  if (Array.isArray(target) === false) {
499
495
  notifyDep(dep, OBJECTPROXY_DEPLEVE_ID);
@@ -522,9 +518,12 @@ function proxyData(data) {
522
518
  */
523
519
  function getProxyDep(data) {
524
520
  //@ts-ignore
525
- if (isObject(data) && data?.[OBJECTPROXY_DEPID] && data[OBJECTPROXY_DEPID] instanceof Dep) {
526
- //@ts-ignore
527
- return data[OBJECTPROXY_DEPID];
521
+ if (isObject(data)) {
522
+ let dep = Reflect.get(data, OBJECTPROXY_DEPID);
523
+ if (dep && dep instanceof Dep) {
524
+ //@ts-ignore
525
+ return dep;
526
+ }
528
527
  }
529
528
  }
530
529
  /**
@@ -2301,10 +2300,16 @@ class ParserRenderSection extends IParser {
2301
2300
  *
2302
2301
  * 渲染出来的子集属于组件的子集
2303
2302
  */
2304
- this.node.ob = Object.create(this.node.section.ob || this.ob);
2305
- this.node.section.params?.forEach((item, index) => {
2306
- defineObserverProperty(this.node.ob, item, this.node.params[index]);
2307
- });
2303
+ if (this.node.section.params) {
2304
+ this.node.ob = Object.create(this.node.section.ob || this.ob);
2305
+ this.node.section.params?.forEach((item, index) => {
2306
+ defineObserverProperty(this.node.ob, item, this.node.params[index]);
2307
+ });
2308
+ }
2309
+ else {
2310
+ //无参数 不需要创建新的对象,避免性能开销
2311
+ this.node.ob = this.node.section.ob || this.ob;
2312
+ }
2308
2313
  //使用之前的node.parser去渲染
2309
2314
  (this.node.section.parser || this.ext).parserNodes(this.node.section.asts, this.node, this.node.ob);
2310
2315
  }
@@ -2433,7 +2438,7 @@ class ParserComponent extends IParser {
2433
2438
  //事件触发时,主动获取,不需要做数据劫持监听
2434
2439
  eventParams = this.runExpress(`[${event.functionParam}]`, this.ob);
2435
2440
  }
2436
- eventCallBack.call(this.ob, e, ...eventParams);
2441
+ eventCallBack.call(this.ext.ob, e, ...eventParams);
2437
2442
  }
2438
2443
  }
2439
2444
  ]);
@@ -2540,7 +2545,7 @@ class ParserComponent extends IParser {
2540
2545
  }
2541
2546
  transformPropValue(val) {
2542
2547
  if (typeof val === "function" && !(JOKER_COMPONENT_TAG in val)) {
2543
- return val.bind(this.ob);
2548
+ return val.bind(this.ext.ob);
2544
2549
  }
2545
2550
  return val;
2546
2551
  }
@@ -2599,7 +2604,7 @@ class ParserElement extends IParser {
2599
2604
  eventParams = this.runExpress(`[${event.functionParam}]`, this.ob);
2600
2605
  }
2601
2606
  if (eventCallBack) {
2602
- eventCallBack.call(this.ob, e, ...eventParams);
2607
+ eventCallBack.call(this.ext.ob, e, ...eventParams);
2603
2608
  }
2604
2609
  }
2605
2610
  }
package/dist/bundle.js CHANGED
@@ -433,10 +433,9 @@ function proxyData(data) {
433
433
  if (proxyDepTarget) {
434
434
  return data;
435
435
  }
436
- //@ts-ignore
437
- if (data[OBJECTPROXY_DATA_KEY]) {
438
- //@ts-ignore
439
- return data[OBJECTPROXY_DATA_KEY];
436
+ let readiedData = Reflect.get(data, OBJECTPROXY_DATA_KEY);
437
+ if (readiedData) {
438
+ return readiedData;
440
439
  }
441
440
  let dep = new Dep();
442
441
  //首次重置值
@@ -456,7 +455,7 @@ function proxyData(data) {
456
455
  if (key === OBJECTPROXY_DEPLEVE_ID) {
457
456
  return undefined;
458
457
  }
459
- let result = target[key];
458
+ let result = Reflect.get(target, key);
460
459
  if (hasProperty(target, key) === false && key !== "length") {
461
460
  return result;
462
461
  }
@@ -470,8 +469,7 @@ function proxyData(data) {
470
469
  },
471
470
  set(target, key, value) {
472
471
  if (resetData) {
473
- //@ts-ignore
474
- target[key] = value;
472
+ Reflect.set(target, key, value);
475
473
  return true;
476
474
  }
477
475
  if (checkEnableProxy(value)) {
@@ -479,8 +477,7 @@ function proxyData(data) {
479
477
  value = observer(value);
480
478
  }
481
479
  let isNewProperty = hasOwnProperty(target, key) === false;
482
- //@ts-ignore
483
- target[key] = value;
480
+ Reflect.set(target, key, value);
484
481
  notifyDep(dep, key);
485
482
  //数组长度变更,属于数组change,则对该对象做change广播
486
483
  if (Array.isArray(target)) {
@@ -493,8 +490,7 @@ function proxyData(data) {
493
490
  return true;
494
491
  },
495
492
  deleteProperty(target, key) {
496
- //@ts-ignore
497
- delete target[key];
493
+ Reflect.deleteProperty(target, key);
498
494
  //操作成功 && 非数组,删除属性时,要进行广播
499
495
  if (Array.isArray(target) === false) {
500
496
  notifyDep(dep, OBJECTPROXY_DEPLEVE_ID);
@@ -523,9 +519,12 @@ function proxyData(data) {
523
519
  */
524
520
  function getProxyDep(data) {
525
521
  //@ts-ignore
526
- if (isObject(data) && data?.[OBJECTPROXY_DEPID] && data[OBJECTPROXY_DEPID] instanceof Dep) {
527
- //@ts-ignore
528
- return data[OBJECTPROXY_DEPID];
522
+ if (isObject(data)) {
523
+ let dep = Reflect.get(data, OBJECTPROXY_DEPID);
524
+ if (dep && dep instanceof Dep) {
525
+ //@ts-ignore
526
+ return dep;
527
+ }
529
528
  }
530
529
  }
531
530
  /**
@@ -2302,10 +2301,16 @@ class ParserRenderSection extends IParser {
2302
2301
  *
2303
2302
  * 渲染出来的子集属于组件的子集
2304
2303
  */
2305
- this.node.ob = Object.create(this.node.section.ob || this.ob);
2306
- this.node.section.params?.forEach((item, index) => {
2307
- defineObserverProperty(this.node.ob, item, this.node.params[index]);
2308
- });
2304
+ if (this.node.section.params) {
2305
+ this.node.ob = Object.create(this.node.section.ob || this.ob);
2306
+ this.node.section.params?.forEach((item, index) => {
2307
+ defineObserverProperty(this.node.ob, item, this.node.params[index]);
2308
+ });
2309
+ }
2310
+ else {
2311
+ //无参数 不需要创建新的对象,避免性能开销
2312
+ this.node.ob = this.node.section.ob || this.ob;
2313
+ }
2309
2314
  //使用之前的node.parser去渲染
2310
2315
  (this.node.section.parser || this.ext).parserNodes(this.node.section.asts, this.node, this.node.ob);
2311
2316
  }
@@ -2434,7 +2439,7 @@ class ParserComponent extends IParser {
2434
2439
  //事件触发时,主动获取,不需要做数据劫持监听
2435
2440
  eventParams = this.runExpress(`[${event.functionParam}]`, this.ob);
2436
2441
  }
2437
- eventCallBack.call(this.ob, e, ...eventParams);
2442
+ eventCallBack.call(this.ext.ob, e, ...eventParams);
2438
2443
  }
2439
2444
  }
2440
2445
  ]);
@@ -2541,7 +2546,7 @@ class ParserComponent extends IParser {
2541
2546
  }
2542
2547
  transformPropValue(val) {
2543
2548
  if (typeof val === "function" && !(JOKER_COMPONENT_TAG in val)) {
2544
- return val.bind(this.ob);
2549
+ return val.bind(this.ext.ob);
2545
2550
  }
2546
2551
  return val;
2547
2552
  }
@@ -2600,7 +2605,7 @@ class ParserElement extends IParser {
2600
2605
  eventParams = this.runExpress(`[${event.functionParam}]`, this.ob);
2601
2606
  }
2602
2607
  if (eventCallBack) {
2603
- eventCallBack.call(this.ob, e, ...eventParams);
2608
+ eventCallBack.call(this.ext.ob, e, ...eventParams);
2604
2609
  }
2605
2610
  }
2606
2611
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joker.front/core",
3
- "version": "1.2.149",
3
+ "version": "1.2.153",
4
4
  "description": "",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.es.js",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "test": "jest",
23
- "test:temp": "jest test/parser/html.spec.ts",
23
+ "test:temp": "jest test/other/ob-source.spec.ts",
24
24
  "build": "joker_build_library --sourcemap=false",
25
25
  "release": "npm run test && npm run build && joker_release_library",
26
26
  "release:prod": "npm run test && npm run build && npm publish --access public --registry https://registry.npmjs.org/"
@@ -0,0 +1,2 @@
1
+ export declare function createObject(source: Object): any;
2
+ export declare function getObjectRootProtorype(source: any): Object;