@joker.front/core 1.2.157 → 1.2.170
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 +33 -18
- package/dist/bundle.js +36 -17
- package/package.json +4 -3
- package/types/component.d.ts +2 -2
- package/types/index.d.ts +1 -0
- package/types/observer/dep.d.ts +3 -1
- package/types/observer/index.d.ts +3 -0
- package/types/parser/component.d.ts +3 -3
- package/types/parser/render.d.ts +1 -2
- package/types/parser/vnode.d.ts +3 -1
package/dist/bundle.es.js
CHANGED
|
@@ -313,6 +313,13 @@ function escape2Html(str) {
|
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
let otherWindowDeps = [];
|
|
317
|
+
function registerOtherWindowDep(dep) {
|
|
318
|
+
otherWindowDeps.push(dep);
|
|
319
|
+
}
|
|
320
|
+
function removeOtherWindowDep(dep) {
|
|
321
|
+
remove(otherWindowDeps, dep);
|
|
322
|
+
}
|
|
316
323
|
/**
|
|
317
324
|
* 作为观察者和对象代理中间的关系桥
|
|
318
325
|
* 数据变更时:Ob->dep->watcher
|
|
@@ -320,7 +327,7 @@ function escape2Html(str) {
|
|
|
320
327
|
*/
|
|
321
328
|
class Dep {
|
|
322
329
|
/**
|
|
323
|
-
* 关系id
|
|
330
|
+
* 关系id,仅在production模式下生效
|
|
324
331
|
*/
|
|
325
332
|
id = process.env.NODE_ENV === "production" ? "" : guid();
|
|
326
333
|
/**
|
|
@@ -340,6 +347,9 @@ class Dep {
|
|
|
340
347
|
*/
|
|
341
348
|
depend(key) {
|
|
342
349
|
Dep.target?.addDep(this, key);
|
|
350
|
+
otherWindowDeps.forEach((n) => {
|
|
351
|
+
n.target?.addDep(this, key);
|
|
352
|
+
});
|
|
343
353
|
}
|
|
344
354
|
/**
|
|
345
355
|
* 添加观察者
|
|
@@ -404,12 +414,12 @@ function notifyGroupDeps(list) {
|
|
|
404
414
|
/**
|
|
405
415
|
* 存放劫持对象的Dep的Key
|
|
406
416
|
*/
|
|
407
|
-
const OBJECTPROXY_DEPID = Symbol("
|
|
408
|
-
const OBJECTPROXY_DATA_KEY = Symbol("
|
|
417
|
+
const OBJECTPROXY_DEPID = Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__");
|
|
418
|
+
const OBJECTPROXY_DATA_KEY = Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__");
|
|
409
419
|
/**
|
|
410
420
|
* 针对深度劫持关系时,需要给该对象做一个虚拟劫持的关系Key,方便事件传播
|
|
411
421
|
*/
|
|
412
|
-
const OBJECTPROXY_DEPLEVE_ID = Symbol("
|
|
422
|
+
const OBJECTPROXY_DEPLEVE_ID = Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");
|
|
413
423
|
/**
|
|
414
424
|
* 检测是否允许劫持代理
|
|
415
425
|
* @param data
|
|
@@ -423,8 +433,9 @@ function checkEnableProxy(data) {
|
|
|
423
433
|
//非冻结
|
|
424
434
|
!Object.isFrozen(data) &&
|
|
425
435
|
!(data instanceof Element) &&
|
|
426
|
-
!(
|
|
427
|
-
!(
|
|
436
|
+
!(JOKER_VNODE_TAG in data) &&
|
|
437
|
+
!(JOKER_SHALLOW_OBSERVER_TAG in data) &&
|
|
438
|
+
!(JOKER_COMPONENT_TAG in data));
|
|
428
439
|
}
|
|
429
440
|
function proxyData(data) {
|
|
430
441
|
let proxyDepTarget = getProxyDep(data);
|
|
@@ -520,7 +531,7 @@ function getProxyDep(data) {
|
|
|
520
531
|
//@ts-ignore
|
|
521
532
|
if (isObject(data)) {
|
|
522
533
|
let dep = Reflect.get(data, OBJECTPROXY_DEPID);
|
|
523
|
-
if (dep
|
|
534
|
+
if (dep) {
|
|
524
535
|
//@ts-ignore
|
|
525
536
|
return dep;
|
|
526
537
|
}
|
|
@@ -585,12 +596,14 @@ function defineObserverProperty(target, key, value) {
|
|
|
585
596
|
}
|
|
586
597
|
});
|
|
587
598
|
}
|
|
599
|
+
const JOKER_SHALLOW_OBSERVER_TAG = Symbol.for("JOKER_SHALLOW_OBSERVER");
|
|
588
600
|
/**
|
|
589
601
|
* 浅劫持监听,不污染数据源,只对根值监听,不对属性监听
|
|
590
602
|
* @returns
|
|
591
603
|
*/
|
|
592
604
|
class ShallowObserver {
|
|
593
605
|
data;
|
|
606
|
+
[JOKER_SHALLOW_OBSERVER_TAG] = true;
|
|
594
607
|
dep = new Dep();
|
|
595
608
|
constructor(data) {
|
|
596
609
|
this.data = data;
|
|
@@ -730,7 +743,7 @@ class Watcher {
|
|
|
730
743
|
if (expOrFn === undefined) {
|
|
731
744
|
this.getter = (obj) => obj;
|
|
732
745
|
}
|
|
733
|
-
else if (expOrFn
|
|
746
|
+
else if (typeof expOrFn === "function") {
|
|
734
747
|
this.getter = expOrFn;
|
|
735
748
|
}
|
|
736
749
|
else {
|
|
@@ -866,6 +879,7 @@ var IContainer;
|
|
|
866
879
|
IContainer.get = get;
|
|
867
880
|
})(IContainer || (IContainer = {}));
|
|
868
881
|
|
|
882
|
+
const JOKER_VNODE_TAG = Symbol.for("JOKER_VNODE_TAG");
|
|
869
883
|
/**
|
|
870
884
|
* 虚拟DOM
|
|
871
885
|
*
|
|
@@ -873,12 +887,13 @@ var IContainer;
|
|
|
873
887
|
*/
|
|
874
888
|
var VNode;
|
|
875
889
|
(function (VNode) {
|
|
876
|
-
VNode.PARSERKEY = Symbol("JOKER_PARSER_KEY");
|
|
890
|
+
VNode.PARSERKEY = Symbol.for("JOKER_PARSER_KEY");
|
|
877
891
|
/**
|
|
878
892
|
* VNode 基类
|
|
879
893
|
*/
|
|
880
894
|
class Node {
|
|
881
895
|
parent;
|
|
896
|
+
[JOKER_VNODE_TAG] = true;
|
|
882
897
|
/**
|
|
883
898
|
* 是否是静态节点,非动态节点。例如:element、text、comment等
|
|
884
899
|
*/
|
|
@@ -1140,7 +1155,7 @@ var Render;
|
|
|
1140
1155
|
/**
|
|
1141
1156
|
* 注入TagId
|
|
1142
1157
|
*/
|
|
1143
|
-
Render.IRENDERIOCTAGID = Symbol("JOKER_IRENDERIOC_TAGID");
|
|
1158
|
+
Render.IRENDERIOCTAGID = Symbol.for("JOKER_IRENDERIOC_TAGID");
|
|
1144
1159
|
/**
|
|
1145
1160
|
* 默认Render,采用H5-DOM模式进行输出
|
|
1146
1161
|
*/
|
|
@@ -2975,13 +2990,13 @@ function isPropsType(propOption) {
|
|
|
2975
2990
|
}
|
|
2976
2991
|
|
|
2977
2992
|
const LOGTAG = "组件";
|
|
2978
|
-
const PROPS_DATA_KEY = Symbol("JOKER_PROPS_DATA_KEY");
|
|
2979
|
-
const PROPS_DATA_PROXY = Symbol("JOKER_PROPS_DATA_PROXY");
|
|
2980
|
-
const PRIVATE_WATCHERS = Symbol("JOKER_PRIVATE_WATCHERS");
|
|
2981
|
-
const EVENT_DATA_KEY = Symbol("JOKER_EVENT_DATA_KEY");
|
|
2982
|
-
const PARSER_TEMPLATE_TARGET = Symbol("JOKER_PARSER_TEMPLATE_TARGET");
|
|
2983
|
-
const SCOPE_ID = Symbol("JOKER_SCOPE_ID");
|
|
2984
|
-
const JOKER_COMPONENT_TAG = Symbol("JOKER_COMPONENT_TAG");
|
|
2993
|
+
const PROPS_DATA_KEY = Symbol.for("JOKER_PROPS_DATA_KEY");
|
|
2994
|
+
const PROPS_DATA_PROXY = Symbol.for("JOKER_PROPS_DATA_PROXY");
|
|
2995
|
+
const PRIVATE_WATCHERS = Symbol.for("JOKER_PRIVATE_WATCHERS");
|
|
2996
|
+
const EVENT_DATA_KEY = Symbol.for("JOKER_EVENT_DATA_KEY");
|
|
2997
|
+
const PARSER_TEMPLATE_TARGET = Symbol.for("JOKER_PARSER_TEMPLATE_TARGET");
|
|
2998
|
+
const SCOPE_ID = Symbol.for("JOKER_SCOPE_ID");
|
|
2999
|
+
const JOKER_COMPONENT_TAG = Symbol.for("JOKER_COMPONENT_TAG");
|
|
2985
3000
|
/**
|
|
2986
3001
|
* Joker组件
|
|
2987
3002
|
*/
|
|
@@ -3615,4 +3630,4 @@ class EventBus {
|
|
|
3615
3630
|
}
|
|
3616
3631
|
}
|
|
3617
3632
|
|
|
3618
|
-
export { Component, ComponentContainer, EventBus, IContainer, JOKER_COMPONENT_TAG, OBJECTPROXY_DEPID, ParserTemplate, SCOPE_ID, ShallowObserver, Template, VNode, Watcher, __JOKER_HMR_RUNTIME, combinedReply, defineObserverProperty, getGlobalComponent, isObserverData, observer, registerGlobalComponent, registerGlobalFunction };
|
|
3633
|
+
export { Component, ComponentContainer, Dep, EventBus, IContainer, JOKER_COMPONENT_TAG, JOKER_VNODE_TAG, OBJECTPROXY_DEPID, ParserTemplate, SCOPE_ID, ShallowObserver, Template, VNode, Watcher, __JOKER_HMR_RUNTIME, combinedReply, defineObserverProperty, getGlobalComponent, isObserverData, observer, registerGlobalComponent, registerGlobalFunction, registerOtherWindowDep, removeOtherWindowDep };
|
package/dist/bundle.js
CHANGED
|
@@ -314,6 +314,13 @@ function escape2Html(str) {
|
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
let otherWindowDeps = [];
|
|
318
|
+
function registerOtherWindowDep(dep) {
|
|
319
|
+
otherWindowDeps.push(dep);
|
|
320
|
+
}
|
|
321
|
+
function removeOtherWindowDep(dep) {
|
|
322
|
+
remove(otherWindowDeps, dep);
|
|
323
|
+
}
|
|
317
324
|
/**
|
|
318
325
|
* 作为观察者和对象代理中间的关系桥
|
|
319
326
|
* 数据变更时:Ob->dep->watcher
|
|
@@ -321,7 +328,7 @@ function escape2Html(str) {
|
|
|
321
328
|
*/
|
|
322
329
|
class Dep {
|
|
323
330
|
/**
|
|
324
|
-
* 关系id
|
|
331
|
+
* 关系id,仅在production模式下生效
|
|
325
332
|
*/
|
|
326
333
|
id = process.env.NODE_ENV === "production" ? "" : guid();
|
|
327
334
|
/**
|
|
@@ -341,6 +348,9 @@ class Dep {
|
|
|
341
348
|
*/
|
|
342
349
|
depend(key) {
|
|
343
350
|
Dep.target?.addDep(this, key);
|
|
351
|
+
otherWindowDeps.forEach((n) => {
|
|
352
|
+
n.target?.addDep(this, key);
|
|
353
|
+
});
|
|
344
354
|
}
|
|
345
355
|
/**
|
|
346
356
|
* 添加观察者
|
|
@@ -405,12 +415,12 @@ function notifyGroupDeps(list) {
|
|
|
405
415
|
/**
|
|
406
416
|
* 存放劫持对象的Dep的Key
|
|
407
417
|
*/
|
|
408
|
-
const OBJECTPROXY_DEPID = Symbol("
|
|
409
|
-
const OBJECTPROXY_DATA_KEY = Symbol("
|
|
418
|
+
const OBJECTPROXY_DEPID = Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__");
|
|
419
|
+
const OBJECTPROXY_DATA_KEY = Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__");
|
|
410
420
|
/**
|
|
411
421
|
* 针对深度劫持关系时,需要给该对象做一个虚拟劫持的关系Key,方便事件传播
|
|
412
422
|
*/
|
|
413
|
-
const OBJECTPROXY_DEPLEVE_ID = Symbol("
|
|
423
|
+
const OBJECTPROXY_DEPLEVE_ID = Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");
|
|
414
424
|
/**
|
|
415
425
|
* 检测是否允许劫持代理
|
|
416
426
|
* @param data
|
|
@@ -424,8 +434,9 @@ function checkEnableProxy(data) {
|
|
|
424
434
|
//非冻结
|
|
425
435
|
!Object.isFrozen(data) &&
|
|
426
436
|
!(data instanceof Element) &&
|
|
427
|
-
!(
|
|
428
|
-
!(
|
|
437
|
+
!(JOKER_VNODE_TAG in data) &&
|
|
438
|
+
!(JOKER_SHALLOW_OBSERVER_TAG in data) &&
|
|
439
|
+
!(JOKER_COMPONENT_TAG in data));
|
|
429
440
|
}
|
|
430
441
|
function proxyData(data) {
|
|
431
442
|
let proxyDepTarget = getProxyDep(data);
|
|
@@ -521,7 +532,7 @@ function getProxyDep(data) {
|
|
|
521
532
|
//@ts-ignore
|
|
522
533
|
if (isObject(data)) {
|
|
523
534
|
let dep = Reflect.get(data, OBJECTPROXY_DEPID);
|
|
524
|
-
if (dep
|
|
535
|
+
if (dep) {
|
|
525
536
|
//@ts-ignore
|
|
526
537
|
return dep;
|
|
527
538
|
}
|
|
@@ -586,12 +597,14 @@ function defineObserverProperty(target, key, value) {
|
|
|
586
597
|
}
|
|
587
598
|
});
|
|
588
599
|
}
|
|
600
|
+
const JOKER_SHALLOW_OBSERVER_TAG = Symbol.for("JOKER_SHALLOW_OBSERVER");
|
|
589
601
|
/**
|
|
590
602
|
* 浅劫持监听,不污染数据源,只对根值监听,不对属性监听
|
|
591
603
|
* @returns
|
|
592
604
|
*/
|
|
593
605
|
class ShallowObserver {
|
|
594
606
|
data;
|
|
607
|
+
[JOKER_SHALLOW_OBSERVER_TAG] = true;
|
|
595
608
|
dep = new Dep();
|
|
596
609
|
constructor(data) {
|
|
597
610
|
this.data = data;
|
|
@@ -731,7 +744,7 @@ class Watcher {
|
|
|
731
744
|
if (expOrFn === undefined) {
|
|
732
745
|
this.getter = (obj) => obj;
|
|
733
746
|
}
|
|
734
|
-
else if (expOrFn
|
|
747
|
+
else if (typeof expOrFn === "function") {
|
|
735
748
|
this.getter = expOrFn;
|
|
736
749
|
}
|
|
737
750
|
else {
|
|
@@ -867,6 +880,7 @@ exports.IContainer = void 0;
|
|
|
867
880
|
IContainer.get = get;
|
|
868
881
|
})(exports.IContainer || (exports.IContainer = {}));
|
|
869
882
|
|
|
883
|
+
const JOKER_VNODE_TAG = Symbol.for("JOKER_VNODE_TAG");
|
|
870
884
|
/**
|
|
871
885
|
* 虚拟DOM
|
|
872
886
|
*
|
|
@@ -874,12 +888,13 @@ exports.IContainer = void 0;
|
|
|
874
888
|
*/
|
|
875
889
|
exports.VNode = void 0;
|
|
876
890
|
(function (VNode) {
|
|
877
|
-
VNode.PARSERKEY = Symbol("JOKER_PARSER_KEY");
|
|
891
|
+
VNode.PARSERKEY = Symbol.for("JOKER_PARSER_KEY");
|
|
878
892
|
/**
|
|
879
893
|
* VNode 基类
|
|
880
894
|
*/
|
|
881
895
|
class Node {
|
|
882
896
|
parent;
|
|
897
|
+
[JOKER_VNODE_TAG] = true;
|
|
883
898
|
/**
|
|
884
899
|
* 是否是静态节点,非动态节点。例如:element、text、comment等
|
|
885
900
|
*/
|
|
@@ -1141,7 +1156,7 @@ var Render;
|
|
|
1141
1156
|
/**
|
|
1142
1157
|
* 注入TagId
|
|
1143
1158
|
*/
|
|
1144
|
-
Render.IRENDERIOCTAGID = Symbol("JOKER_IRENDERIOC_TAGID");
|
|
1159
|
+
Render.IRENDERIOCTAGID = Symbol.for("JOKER_IRENDERIOC_TAGID");
|
|
1145
1160
|
/**
|
|
1146
1161
|
* 默认Render,采用H5-DOM模式进行输出
|
|
1147
1162
|
*/
|
|
@@ -2976,13 +2991,13 @@ function isPropsType(propOption) {
|
|
|
2976
2991
|
}
|
|
2977
2992
|
|
|
2978
2993
|
const LOGTAG = "组件";
|
|
2979
|
-
const PROPS_DATA_KEY = Symbol("JOKER_PROPS_DATA_KEY");
|
|
2980
|
-
const PROPS_DATA_PROXY = Symbol("JOKER_PROPS_DATA_PROXY");
|
|
2981
|
-
const PRIVATE_WATCHERS = Symbol("JOKER_PRIVATE_WATCHERS");
|
|
2982
|
-
const EVENT_DATA_KEY = Symbol("JOKER_EVENT_DATA_KEY");
|
|
2983
|
-
const PARSER_TEMPLATE_TARGET = Symbol("JOKER_PARSER_TEMPLATE_TARGET");
|
|
2984
|
-
const SCOPE_ID = Symbol("JOKER_SCOPE_ID");
|
|
2985
|
-
const JOKER_COMPONENT_TAG = Symbol("JOKER_COMPONENT_TAG");
|
|
2994
|
+
const PROPS_DATA_KEY = Symbol.for("JOKER_PROPS_DATA_KEY");
|
|
2995
|
+
const PROPS_DATA_PROXY = Symbol.for("JOKER_PROPS_DATA_PROXY");
|
|
2996
|
+
const PRIVATE_WATCHERS = Symbol.for("JOKER_PRIVATE_WATCHERS");
|
|
2997
|
+
const EVENT_DATA_KEY = Symbol.for("JOKER_EVENT_DATA_KEY");
|
|
2998
|
+
const PARSER_TEMPLATE_TARGET = Symbol.for("JOKER_PARSER_TEMPLATE_TARGET");
|
|
2999
|
+
const SCOPE_ID = Symbol.for("JOKER_SCOPE_ID");
|
|
3000
|
+
const JOKER_COMPONENT_TAG = Symbol.for("JOKER_COMPONENT_TAG");
|
|
2986
3001
|
/**
|
|
2987
3002
|
* Joker组件
|
|
2988
3003
|
*/
|
|
@@ -3654,8 +3669,10 @@ Object.defineProperty(exports, 'createText', {
|
|
|
3654
3669
|
});
|
|
3655
3670
|
exports.Component = Component;
|
|
3656
3671
|
exports.ComponentContainer = ComponentContainer;
|
|
3672
|
+
exports.Dep = Dep;
|
|
3657
3673
|
exports.EventBus = EventBus;
|
|
3658
3674
|
exports.JOKER_COMPONENT_TAG = JOKER_COMPONENT_TAG;
|
|
3675
|
+
exports.JOKER_VNODE_TAG = JOKER_VNODE_TAG;
|
|
3659
3676
|
exports.OBJECTPROXY_DEPID = OBJECTPROXY_DEPID;
|
|
3660
3677
|
exports.ParserTemplate = ParserTemplate;
|
|
3661
3678
|
exports.SCOPE_ID = SCOPE_ID;
|
|
@@ -3670,3 +3687,5 @@ exports.isObserverData = isObserverData;
|
|
|
3670
3687
|
exports.observer = observer;
|
|
3671
3688
|
exports.registerGlobalComponent = registerGlobalComponent;
|
|
3672
3689
|
exports.registerGlobalFunction = registerGlobalFunction;
|
|
3690
|
+
exports.registerOtherWindowDep = registerOtherWindowDep;
|
|
3691
|
+
exports.removeOtherWindowDep = removeOtherWindowDep;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joker.front/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.170",
|
|
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/
|
|
23
|
+
"test:temp": "jest test/parser/cmd.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/"
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"type": "git"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
|
-
"joker"
|
|
34
|
+
"joker",
|
|
35
|
+
"front"
|
|
35
36
|
],
|
|
36
37
|
"homepage": "jokers.pub",
|
|
37
38
|
"dependencies": {
|
package/types/component.d.ts
CHANGED
|
@@ -73,12 +73,12 @@ export declare class Component<T extends DefaultKeyVal = {}> implements ICompone
|
|
|
73
73
|
* 主动声明接受的参数
|
|
74
74
|
* @returns
|
|
75
75
|
*/
|
|
76
|
-
get props(): Readonly<
|
|
76
|
+
get props(): Readonly<T>;
|
|
77
77
|
/**
|
|
78
78
|
* 挂载
|
|
79
79
|
* @param root
|
|
80
80
|
*/
|
|
81
|
-
$mount(root: any | VNode.Component
|
|
81
|
+
$mount(root: any | VNode.Component): this;
|
|
82
82
|
/**
|
|
83
83
|
* 节点动画,仅支持 element及组件节点
|
|
84
84
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./component";
|
|
|
3
3
|
export * from "./parser/vnode";
|
|
4
4
|
export { ParserTemplate, NodeChangeType } from "./parser/index";
|
|
5
5
|
export * from "./observer/watcher";
|
|
6
|
+
export { Dep, registerOtherWindowDep, removeOtherWindowDep } from "./observer/dep";
|
|
6
7
|
export * from "./observer/index";
|
|
7
8
|
export * from "./utils/DI";
|
|
8
9
|
export * from "./hmr";
|
package/types/observer/dep.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Watcher } from "./watcher";
|
|
2
|
+
export declare function registerOtherWindowDep(dep: typeof Dep): void;
|
|
3
|
+
export declare function removeOtherWindowDep(dep: typeof Dep): void;
|
|
2
4
|
/**
|
|
3
5
|
* 作为观察者和对象代理中间的关系桥
|
|
4
6
|
* 数据变更时:Ob->dep->watcher
|
|
@@ -6,7 +8,7 @@ import { Watcher } from "./watcher";
|
|
|
6
8
|
*/
|
|
7
9
|
export declare class Dep {
|
|
8
10
|
/**
|
|
9
|
-
* 关系id
|
|
11
|
+
* 关系id,仅在production模式下生效
|
|
10
12
|
*/
|
|
11
13
|
id: string;
|
|
12
14
|
/**
|
|
@@ -18,12 +18,14 @@ export declare function observer<T extends Object>(data: T, clone?: boolean): T;
|
|
|
18
18
|
* @param value
|
|
19
19
|
*/
|
|
20
20
|
export declare function defineObserverProperty(target: any, key: string | symbol, value: any): void;
|
|
21
|
+
declare const JOKER_SHALLOW_OBSERVER_TAG: unique symbol;
|
|
21
22
|
/**
|
|
22
23
|
* 浅劫持监听,不污染数据源,只对根值监听,不对属性监听
|
|
23
24
|
* @returns
|
|
24
25
|
*/
|
|
25
26
|
export declare class ShallowObserver<T> {
|
|
26
27
|
private data;
|
|
28
|
+
[JOKER_SHALLOW_OBSERVER_TAG]: boolean;
|
|
27
29
|
private dep;
|
|
28
30
|
constructor(data: T);
|
|
29
31
|
/**
|
|
@@ -44,3 +46,4 @@ export declare function combinedReply(func: Function): void;
|
|
|
44
46
|
* 判断一个值是否是已被数据代理劫持
|
|
45
47
|
*/
|
|
46
48
|
export declare function isObserverData(data: any): boolean;
|
|
49
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AST
|
|
1
|
+
import { AST } from "@joker.front/ast";
|
|
2
2
|
import { IParser } from "./parser";
|
|
3
3
|
import { Component } from "../component";
|
|
4
4
|
import { VNode } from "./vnode";
|
|
5
5
|
export declare function checkIsComponent(tagName: string, ob: Component): boolean;
|
|
6
6
|
export declare class ParserComponent extends IParser<(AST.Element | AST.Component) & {
|
|
7
|
-
node?: VNode.Component
|
|
8
|
-
}, VNode.Component
|
|
7
|
+
node?: VNode.Component;
|
|
8
|
+
}, VNode.Component> {
|
|
9
9
|
parser(): void;
|
|
10
10
|
/**
|
|
11
11
|
* 是否允许重载
|
package/types/parser/render.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { VNode } from "./vnode";
|
|
2
|
-
import { IComponent } from "@joker.front/ast";
|
|
3
2
|
type TransitionType = "transition" | "animation";
|
|
4
3
|
export declare namespace Render {
|
|
5
4
|
/**
|
|
@@ -72,7 +71,7 @@ export declare namespace Render {
|
|
|
72
71
|
destroy(): void;
|
|
73
72
|
elementToEnter(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
74
73
|
elementToLeave(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
75
|
-
triggerEvent(node: VNode.Component
|
|
74
|
+
triggerEvent(node: VNode.Component, _eventName: string, _e: VNode.Event): void | false;
|
|
76
75
|
private transitionFrame;
|
|
77
76
|
private renderNode;
|
|
78
77
|
private initElementEvents;
|
package/types/parser/vnode.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Component as ComponentClass } from "../component";
|
|
|
3
3
|
import { ObType } from ".";
|
|
4
4
|
import { SectionType } from "../component";
|
|
5
5
|
import { IParser } from "./parser";
|
|
6
|
+
export declare const JOKER_VNODE_TAG: unique symbol;
|
|
6
7
|
/**
|
|
7
8
|
* 虚拟DOM
|
|
8
9
|
*
|
|
@@ -15,6 +16,7 @@ export declare namespace VNode {
|
|
|
15
16
|
*/
|
|
16
17
|
class Node {
|
|
17
18
|
parent?: Node | undefined;
|
|
19
|
+
[JOKER_VNODE_TAG]: boolean;
|
|
18
20
|
/**
|
|
19
21
|
* 是否是静态节点,非动态节点。例如:element、text、comment等
|
|
20
22
|
*/
|
|
@@ -127,7 +129,7 @@ export declare namespace VNode {
|
|
|
127
129
|
/**
|
|
128
130
|
* 组件节点
|
|
129
131
|
*/
|
|
130
|
-
class Component<T extends
|
|
132
|
+
class Component<T extends ComponentClass = ComponentClass<any> & Record<string, any>> extends Node {
|
|
131
133
|
/** 组件名(template标签名) */
|
|
132
134
|
name?: string;
|
|
133
135
|
/** 组件实例 */
|