render-core 1.0.100 → 1.0.101

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.
@@ -1,3 +1,4 @@
1
1
  export declare class ContextController {
2
+ mixin: {};
2
3
  constructor();
3
4
  }
@@ -1,5 +1,6 @@
1
1
  var ContextController = /** @class */ (function () {
2
2
  function ContextController() {
3
+ this.mixin = {};
3
4
  }
4
5
  return ContextController;
5
6
  }());
@@ -4,6 +4,7 @@ export declare class PageController {
4
4
  private currentTag;
5
5
  solt: Map<string, any>;
6
6
  raw_data: {};
7
+ mixin: {};
7
8
  to: ComponentController[];
8
9
  link: Map<string, {}>;
9
10
  constructor();
@@ -7,6 +7,7 @@ var PageController = /** @class */ (function () {
7
7
  this.to = Array();
8
8
  this.crtTag = null;
9
9
  this.solt = new Map();
10
+ this.mixin = {};
10
11
  }
11
12
  //接收器
12
13
  PageController.prototype.receiver = function (method) {
@@ -14,6 +15,7 @@ var PageController = /** @class */ (function () {
14
15
  for (var _i = 1; _i < arguments.length; _i++) {
15
16
  args[_i - 1] = arguments[_i];
16
17
  }
18
+ this.methods[method].call(args);
17
19
  };
18
20
  Object.defineProperty(PageController.prototype, "crtTag", {
19
21
  //返回当前页面的渲染元素
@@ -1,3 +1,7 @@
1
1
  export interface RenderTip {
2
2
  use(callable: any): void;
3
+ configApp(config: {}): void;
4
+ configContext(cinfig: {}): void;
5
+ mixin(mix: {}): void;
6
+ mount(): void;
3
7
  }
@@ -1,3 +1,4 @@
1
+ import { compositionend, compositionstart, listerner } from "../../utility/modelUtility";
1
2
  /**
2
3
  * 绑定数据模型
3
4
  * @param nodes
@@ -11,31 +12,7 @@ export function resolver_model(nodes, data) {
11
12
  var tagName = nodes[i].tagName;
12
13
  nodes[i].setAttribute("name", dataName);
13
14
  if (tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA" || tagName === "DATALIST") {
14
- var listener = function (evt) {
15
- if (!evt.target.hasAttribute("flag")) {
16
- //Get the event element
17
- var element = evt.target;
18
- //Get the name attribute
19
- var dataName_1 = element.name;
20
- Reflect.set(this, "origin", {
21
- cpn: element.getAttribute("cpn"),
22
- tag: element.nodeName,
23
- name: element.getAttribute("name")
24
- });
25
- //Update the value
26
- this[dataName_1] = element.value;
27
- }
28
- };
29
- var compositionstart = function (evt) {
30
- evt.target.setAttribute("flag", "false");
31
- };
32
- var compositionend = function (evt) {
33
- evt.target.setAttribute("flag", "true");
34
- var element = evt.target;
35
- var dataName = element.name;
36
- this[dataName] = element.value;
37
- };
38
- nodes[i].addEventListener("input", listener.bind(data));
15
+ nodes[i].addEventListener("input", listerner.bind(data));
39
16
  nodes[i].addEventListener("compositionstart", compositionstart);
40
17
  nodes[i].addEventListener("compositionend", compositionend.bind(data));
41
18
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param evt
4
+ */
5
+ export declare function compositionstart(evt: any): void;
6
+ /**
7
+ *
8
+ * @param evt
9
+ */
10
+ export declare function listerner(evt: any): void;
11
+ /**
12
+ *
13
+ * @param evt
14
+ */
15
+ export declare function compositionend(evt: any): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ *
3
+ * @param evt
4
+ */
5
+ export function compositionstart(evt) {
6
+ evt.target.setAttribute("flag", "false");
7
+ }
8
+ /**
9
+ *
10
+ * @param evt
11
+ */
12
+ export function listerner(evt) {
13
+ if (!evt.target.hasAttribute("flag")) {
14
+ //Get the event element
15
+ var element = evt.target;
16
+ //Get the name attribute
17
+ var dataName = element.name;
18
+ Reflect.set(this, "origin", {
19
+ cpn: element.getAttribute("cpn"),
20
+ tag: element.nodeName,
21
+ name: element.getAttribute("name")
22
+ });
23
+ //Update the value
24
+ this[dataName] = element.value;
25
+ }
26
+ }
27
+ /**
28
+ *
29
+ * @param evt
30
+ */
31
+ export function compositionend(evt) {
32
+ evt.target.setAttribute("flag", "true");
33
+ var element = evt.target;
34
+ var dataName = element.name;
35
+ this[dataName] = element.value;
36
+ }
package/index.d.ts CHANGED
@@ -11,8 +11,29 @@ export declare class RenderJS implements RenderTip {
11
11
  readonly styleLib: Map<string, Map<string, string>>;
12
12
  router: routerController;
13
13
  private application;
14
+ private context;
14
15
  page: PageController;
15
16
  constructor();
17
+ /**
18
+ *
19
+ * @param config
20
+ */
21
+ configApp(config: {}): void;
22
+ /**
23
+ *
24
+ * @param cinfig
25
+ */
26
+ configContext(cinfig: {}): void;
27
+ /**
28
+ *
29
+ * @param callable
30
+ */
31
+ use(callable: any): void;
32
+ /**
33
+ *
34
+ * @param mix
35
+ */
36
+ mixin(mix: {}): void;
16
37
  /**
17
38
  * If you want to hava a permission control to your application,you can
18
39
  * use our extra router moudle to define the router.
@@ -25,10 +46,9 @@ export declare class RenderJS implements RenderTip {
25
46
  */
26
47
  addTag(component: Component | Component[]): void;
27
48
  /**
28
- *
29
- * @param callable
49
+ * mount some base object
30
50
  */
31
- use(callable: any): void;
51
+ mount(): void;
32
52
  /**
33
53
  * This method is the boster method of the render.
34
54
  */
package/index.js CHANGED
@@ -1,9 +1,7 @@
1
- import meta from "./meta/meta";
2
- // @ts-ignore
3
- import { redirect } from "render-security/utility/redirect";
4
1
  import { PageController } from "./class/controller/pageController";
5
- import { registerTagLib, render } from "./runtime/tools";
2
+ import { executor, registerTagLib } from "./runtime/tools";
6
3
  import { AppController } from "./class/controller/appController";
4
+ import { ContextController } from "./class/controller/contextController";
7
5
  /**
8
6
  * This class is the application class.
9
7
  */
@@ -15,13 +13,40 @@ var RenderJS = /** @class */ (function () {
15
13
  this.styleLib = new Map();
16
14
  //initiate the application controller
17
15
  this.application = new AppController();
16
+ this.context = new ContextController();
18
17
  //initiate the page controller
19
18
  this.page = new PageController();
20
19
  //initiate the config object
21
20
  this.config = {};
22
- Reflect.set(this.config, "version", meta.version);
23
- Reflect.set(this.config, "theme", meta.style);
24
21
  }
22
+ /**
23
+ *
24
+ * @param config
25
+ */
26
+ RenderJS.prototype.configApp = function (config) {
27
+ throw new Error("Method not implemented.");
28
+ };
29
+ /**
30
+ *
31
+ * @param cinfig
32
+ */
33
+ RenderJS.prototype.configContext = function (cinfig) {
34
+ throw new Error("Method not implemented.");
35
+ };
36
+ /**
37
+ *
38
+ * @param callable
39
+ */
40
+ RenderJS.prototype.use = function (callable) {
41
+ callable(this);
42
+ };
43
+ /**
44
+ *
45
+ * @param mix
46
+ */
47
+ RenderJS.prototype.mixin = function (mix) {
48
+ this.page.mixin = mix;
49
+ };
25
50
  /**
26
51
  * If you want to hava a permission control to your application,you can
27
52
  * use our extra router moudle to define the router.
@@ -38,34 +63,26 @@ var RenderJS = /** @class */ (function () {
38
63
  registerTagLib(this, component);
39
64
  };
40
65
  /**
41
- *
42
- * @param callable
66
+ * mount some base object
43
67
  */
44
- RenderJS.prototype.use = function (callable) {
45
- callable(this);
68
+ RenderJS.prototype.mount = function () {
69
+ Reflect.set(window, "tagLib", this.tagLib);
70
+ Reflect.set(window, "styleLib", this.styleLib);
71
+ Reflect.set(window, "appSite", this.application);
72
+ Reflect.set(window, "context", this.context);
73
+ Reflect.set(window, "page", this.page);
74
+ if (this.router) {
75
+ Reflect.set(window, "router", this.router);
76
+ }
46
77
  };
47
78
  /**
48
79
  * This method is the boster method of the render.
49
80
  */
50
81
  RenderJS.prototype.run = function () {
51
- if (this.router) {
52
- this.router.data.beforeRouter();
53
- if (typeof this.router.getRule(location.href) === "boolean") {
54
- render(this);
55
- }
56
- else {
57
- if (this.router.getRule(location.href).beforeRouter()) {
58
- render(this);
59
- }
60
- else {
61
- redirect("/http/400.html");
62
- }
63
- }
64
- this.router.data.afterRouter();
65
- }
66
- else {
67
- render(this);
68
- }
82
+ //挂载对象
83
+ this.mount();
84
+ //execute
85
+ executor(this);
69
86
  };
70
87
  return RenderJS;
71
88
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.0.100",
3
+ "version": "1.0.101",
4
4
  "description": "The core of render-js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -12,3 +12,7 @@ export declare function registerTagLib(application: RenderJS, component: Compone
12
12
  * @param renderjs
13
13
  */
14
14
  export declare function render(renderjs: RenderJS): void;
15
+ /**
16
+ *
17
+ */
18
+ export declare function executor(renderjs: RenderJS): void;
package/runtime/tools.js CHANGED
@@ -2,6 +2,7 @@ import { Component } from "../class/component/component";
2
2
  import { themeStyle } from "../core/utility/styleUtility";
3
3
  import { AppController } from "../class/controller/appController";
4
4
  import { renderHtml } from "./runtime";
5
+ import { redirect } from "render-security/utility/redirect";
5
6
  /**
6
7
  * This function is used to save the protype component class in the window object.
7
8
  * So, you can hava a tip that we customed a property named 'tagLib' in the window object.
@@ -48,3 +49,31 @@ export function render(renderjs) {
48
49
  //开始渲染
49
50
  renderHtml(document.body.children, renderjs.page);
50
51
  }
52
+ /**
53
+ *
54
+ */
55
+ export function executor(renderjs) {
56
+ // @ts-ignore
57
+ if (window.router) {
58
+ // @ts-ignore
59
+ window.router.data.beforeRouter();
60
+ // @ts-ignore
61
+ if (typeof window.router.getRule(location.href) === "boolean") {
62
+ render(renderjs);
63
+ }
64
+ else {
65
+ // @ts-ignore
66
+ if (window.router.getRule(location.href).beforeRouter()) {
67
+ render(renderjs);
68
+ }
69
+ else {
70
+ redirect("/http/400.html");
71
+ }
72
+ }
73
+ // @ts-ignore
74
+ window.router.data.afterRouter();
75
+ }
76
+ else {
77
+ render(renderjs);
78
+ }
79
+ }