render-core 1.0.32 → 1.0.34
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/class/component.d.ts +4 -0
- package/class/component.js +11 -1
- package/core/render/updateRender.js +2 -0
- package/index.js +1 -2
- package/library/inject/inject.d.ts +1 -0
- package/library/inject/inject.js +3 -2
- package/library/render/render.js +25 -3
- package/package.json +1 -1
package/class/component.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface RenderBase {
|
|
2
2
|
getName(): string;
|
|
3
3
|
getTemplate(): string;
|
|
4
|
+
getBoxStyle(): {};
|
|
4
5
|
getProps(): {};
|
|
5
6
|
getData(): {};
|
|
6
7
|
getComputed(): {};
|
|
@@ -16,6 +17,7 @@ interface RenderBase {
|
|
|
16
17
|
export declare class Component implements RenderBase {
|
|
17
18
|
private readonly name;
|
|
18
19
|
private readonly template;
|
|
20
|
+
private readonly boxStyle?;
|
|
19
21
|
private readonly props?;
|
|
20
22
|
private readonly data?;
|
|
21
23
|
private readonly methods?;
|
|
@@ -30,6 +32,7 @@ export declare class Component implements RenderBase {
|
|
|
30
32
|
constructor(config: {
|
|
31
33
|
name: string;
|
|
32
34
|
template: string;
|
|
35
|
+
boxStyle?: {};
|
|
33
36
|
props?: {} | string[];
|
|
34
37
|
data?: {};
|
|
35
38
|
computed?: {};
|
|
@@ -44,6 +47,7 @@ export declare class Component implements RenderBase {
|
|
|
44
47
|
});
|
|
45
48
|
getName(): string;
|
|
46
49
|
getTemplate(): string;
|
|
50
|
+
getBoxStyle(): {};
|
|
47
51
|
getProps(): {};
|
|
48
52
|
getData(): {};
|
|
49
53
|
getMethods(): {};
|
package/class/component.js
CHANGED
|
@@ -4,6 +4,13 @@ var Component = /** @class */ (function () {
|
|
|
4
4
|
this.name = config.name;
|
|
5
5
|
//标签模板样式
|
|
6
6
|
this.template = config.template;
|
|
7
|
+
//添加box样式
|
|
8
|
+
if (typeof config.boxStyle === "undefined") {
|
|
9
|
+
this.boxStyle = {};
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
this.boxStyle = config.boxStyle;
|
|
13
|
+
}
|
|
7
14
|
//添加数据
|
|
8
15
|
if (typeof config.props === "undefined") {
|
|
9
16
|
this.props = [];
|
|
@@ -19,7 +26,7 @@ var Component = /** @class */ (function () {
|
|
|
19
26
|
this.data = config.data;
|
|
20
27
|
}
|
|
21
28
|
//添加计算属性
|
|
22
|
-
if (config.computed === "undefined") {
|
|
29
|
+
if (typeof config.computed === "undefined") {
|
|
23
30
|
this.computed = {};
|
|
24
31
|
}
|
|
25
32
|
else {
|
|
@@ -83,6 +90,9 @@ var Component = /** @class */ (function () {
|
|
|
83
90
|
Component.prototype.getTemplate = function () {
|
|
84
91
|
return this.template;
|
|
85
92
|
};
|
|
93
|
+
Component.prototype.getBoxStyle = function () {
|
|
94
|
+
return this.boxStyle;
|
|
95
|
+
};
|
|
86
96
|
Component.prototype.getProps = function () {
|
|
87
97
|
return this.props;
|
|
88
98
|
};
|
|
@@ -2,6 +2,7 @@ import { bindModelForUpdater } from "../utility/miscUtility";
|
|
|
2
2
|
import { findComponent } from "./initRender";
|
|
3
3
|
import { getTemplate } from "../../library/template/template";
|
|
4
4
|
import { cmdForUpdate } from "../../library/cmd/cmd";
|
|
5
|
+
import { injectProps } from "../../library/inject/inject";
|
|
5
6
|
export function updateRender(controller) {
|
|
6
7
|
//生成DOM
|
|
7
8
|
var tagTemplate = getTemplate(controller.proto);
|
|
@@ -29,6 +30,7 @@ export function updateRender(controller) {
|
|
|
29
30
|
//afterRender
|
|
30
31
|
var afterRender = controller.proto.getAfterRender().bind(controller.raw_data);
|
|
31
32
|
afterRender();
|
|
33
|
+
injectProps(controller, tagTemplate);
|
|
32
34
|
//获取定位
|
|
33
35
|
bindModelForUpdater(controller.root.children, controller.proxyForMethods);
|
|
34
36
|
//深度渲染
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from "./class/component";
|
|
2
2
|
import meta from "./meta/meta";
|
|
3
|
-
import {
|
|
3
|
+
import { renderHtml } from "./runtime/runtime";
|
|
4
4
|
import { themeStyle } from "./core/utility/styleUtility";
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import { redirect } from "render-security/utility/redirect";
|
|
@@ -76,7 +76,6 @@ var RenderJS = /** @class */ (function () {
|
|
|
76
76
|
Reflect.set(window, "router", this.routerC);
|
|
77
77
|
//开始渲染
|
|
78
78
|
renderHtml(document.body.children, this.page);
|
|
79
|
-
window.onload = reloadPage.bind(this);
|
|
80
79
|
};
|
|
81
80
|
return RenderJS;
|
|
82
81
|
}());
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Controller } from "../../class/controller";
|
|
2
2
|
import { Component } from "../../class/component";
|
|
3
3
|
export declare function inject(controller: Controller, tagTemplate: Element): void;
|
|
4
|
+
export declare function injectProps(controller: Controller, tagTemplate: Element): void;
|
|
4
5
|
export declare function injectMethod(controller: Controller, proto: Component): void;
|
|
5
6
|
export declare function injectWatcher(controller: Controller, proto: Component): void;
|
|
6
7
|
export declare function injectComputed(controller: Controller, proto: Component): void;
|
package/library/inject/inject.js
CHANGED
|
@@ -7,9 +7,10 @@ export function inject(controller, tagTemplate) {
|
|
|
7
7
|
getCodeSpaceForProps(controller.raw_data, resolveProps(Reflect.get(window, "context").crtTag, controller.proto.getProps()));
|
|
8
8
|
//注入query
|
|
9
9
|
getCodeSpaceForQuery(controller.raw_data, resolve_Queries());
|
|
10
|
-
|
|
10
|
+
}
|
|
11
|
+
export function injectProps(controller, tagTemplate) {
|
|
11
12
|
var refs = new Map();
|
|
12
|
-
resolver_Refs(
|
|
13
|
+
resolver_Refs(controller.root.children, refs);
|
|
13
14
|
getCodeSpaceForRef(controller.raw_data, refs);
|
|
14
15
|
}
|
|
15
16
|
export function injectMethod(controller, proto) {
|
package/library/render/render.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Controller } from "../../class/controller";
|
|
|
2
2
|
import { getCodeSpaceForCommit, getCodeSpaceForPublish, getCommitMethod, getPublishMethod } from "../../core/utility/injectUtility";
|
|
3
3
|
import { getProxyObject } from "../../core/proxy/getProxy";
|
|
4
4
|
import { findComponent } from "../../core/render/initRender";
|
|
5
|
-
import { inject, injectComputed, injectMethod, injectWatcher } from "../inject/inject";
|
|
5
|
+
import { inject, injectComputed, injectMethod, injectProps, injectWatcher } from "../inject/inject";
|
|
6
6
|
import { cmd } from "../cmd/cmd";
|
|
7
7
|
export function init_render(proto, parent, child, link, tagTemplate) {
|
|
8
8
|
//获取控制对象
|
|
@@ -32,6 +32,13 @@ export function init_render(proto, parent, child, link, tagTemplate) {
|
|
|
32
32
|
beforeMount();
|
|
33
33
|
//mount
|
|
34
34
|
var renderSpace = document.createElement("div");
|
|
35
|
+
//给box添加样式
|
|
36
|
+
for (var boxStyleKey in proto.getBoxStyle()) {
|
|
37
|
+
renderSpace["style"].setProperty(boxStyleKey, proto.getBoxStyle()[boxStyleKey]);
|
|
38
|
+
}
|
|
39
|
+
//指定渲染空间
|
|
40
|
+
controller.root = renderSpace;
|
|
41
|
+
//开始渲染
|
|
35
42
|
parent.replaceChild(renderSpace, child);
|
|
36
43
|
while (tagTemplate.hasChildNodes()) {
|
|
37
44
|
renderSpace.append(tagTemplate.firstChild);
|
|
@@ -39,8 +46,7 @@ export function init_render(proto, parent, child, link, tagTemplate) {
|
|
|
39
46
|
//afterRender
|
|
40
47
|
var afterRender = proto.getAfterRender().bind(controller.raw_data);
|
|
41
48
|
afterRender();
|
|
42
|
-
|
|
43
|
-
controller.root = renderSpace;
|
|
49
|
+
injectProps(controller, tagTemplate);
|
|
44
50
|
//将本控制对象保存到父控制对象的发布数组中
|
|
45
51
|
link.to.push(controller);
|
|
46
52
|
//将执行空间保存到父控制对象
|
|
@@ -76,7 +82,13 @@ export function post_render(proto, parent, child, link, tagTemplate) {
|
|
|
76
82
|
beforeMount();
|
|
77
83
|
//mount
|
|
78
84
|
var renderSpace = document.createElement("div");
|
|
85
|
+
//给box添加样式
|
|
86
|
+
for (var boxStyleKey in proto.getBoxStyle()) {
|
|
87
|
+
renderSpace["style"].setProperty(boxStyleKey, proto.getBoxStyle()[boxStyleKey]);
|
|
88
|
+
}
|
|
89
|
+
//指定渲染空间
|
|
79
90
|
controller.root = renderSpace;
|
|
91
|
+
//开始渲染
|
|
80
92
|
parent.replaceChild(renderSpace, child);
|
|
81
93
|
while (tagTemplate.hasChildNodes()) {
|
|
82
94
|
renderSpace.append(tagTemplate.firstChild);
|
|
@@ -84,7 +96,10 @@ export function post_render(proto, parent, child, link, tagTemplate) {
|
|
|
84
96
|
//afterRender
|
|
85
97
|
var afterRender = proto.getAfterRender().bind(controller.raw_data);
|
|
86
98
|
afterRender();
|
|
99
|
+
injectProps(controller, tagTemplate);
|
|
87
100
|
link.to.push(controller);
|
|
101
|
+
//将执行空间保存到父控制对象
|
|
102
|
+
link.link.set(child.getAttribute("name"), controller.raw_data);
|
|
88
103
|
//深度渲染
|
|
89
104
|
findComponent(controller.root.children, controller);
|
|
90
105
|
}
|
|
@@ -116,7 +131,13 @@ export function raw_render(proto, parent, child, link, tagTemplate) {
|
|
|
116
131
|
beforeMount();
|
|
117
132
|
//mount
|
|
118
133
|
var renderSpace = document.createElement("div");
|
|
134
|
+
//给box添加样式
|
|
135
|
+
for (var boxStyleKey in proto.getBoxStyle()) {
|
|
136
|
+
renderSpace["style"].setProperty(boxStyleKey, proto.getBoxStyle()[boxStyleKey]);
|
|
137
|
+
}
|
|
138
|
+
//指定渲染空间
|
|
119
139
|
controller.root = renderSpace;
|
|
140
|
+
//开始渲染
|
|
120
141
|
parent.replaceChild(renderSpace, child);
|
|
121
142
|
while (tagTemplate.hasChildNodes()) {
|
|
122
143
|
renderSpace.append(tagTemplate.firstChild);
|
|
@@ -124,6 +145,7 @@ export function raw_render(proto, parent, child, link, tagTemplate) {
|
|
|
124
145
|
//afterRender
|
|
125
146
|
var afterRender = proto.getAfterRender().bind(controller.raw_data);
|
|
126
147
|
afterRender();
|
|
148
|
+
injectProps(controller, tagTemplate);
|
|
127
149
|
link.to.push(controller);
|
|
128
150
|
//深度渲染
|
|
129
151
|
findComponent(controller.root.children, controller);
|