render-core 1.0.100 → 1.0.102

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,6 +1,9 @@
1
1
  import { AppTip } from "../tips/appTip";
2
2
  export declare class AppController implements AppTip {
3
+ private fileds;
3
4
  constructor();
4
- setTheme(theme: string): void;
5
- getInstance(): AppController;
5
+ saveFileds(fileds: {}): void;
6
+ loadFileds(): void;
7
+ setFiled(filed: string, value: any): void;
8
+ getFiled(filed: string): any;
6
9
  }
@@ -1,21 +1,62 @@
1
1
  // @ts-ignore
2
- import { status_write } from "render-status";
2
+ import { status_read, status_write } from "render-status";
3
3
  import { reloadStyle } from "../../core/utility/styleUtility";
4
4
  var AppController = /** @class */ (function () {
5
5
  function AppController() {
6
+ this.fileds = {
7
+ them: {
8
+ data: "default",
9
+ react: true,
10
+ callback: function (value, context) {
11
+ reloadStyle(value);
12
+ context.setFiled("theme", value);
13
+ }
14
+ }
15
+ };
6
16
  }
7
- //更改会话样式
8
- AppController.prototype.setTheme = function (theme) {
17
+ AppController.prototype.saveFileds = function (fileds) {
18
+ for (var filedsKey in fileds) {
19
+ if (Reflect.has(this.fileds, filedsKey)) {
20
+ console.log("This filed is a systemed filed, please have a new name for the filed:" + filedsKey);
21
+ }
22
+ else {
23
+ Reflect.set(this.fileds, filedsKey, fileds[filedsKey]);
24
+ }
25
+ }
26
+ };
27
+ AppController.prototype.loadFileds = function () {
28
+ for (var filedsKey in this.fileds) {
29
+ if (this.fileds[filedsKey].react) {
30
+ if (status_read({
31
+ type: "local",
32
+ fields: [filedsKey]
33
+ })[filedsKey]) {
34
+ this.fileds[filedsKey].data = status_read({
35
+ type: "local",
36
+ fields: [filedsKey]
37
+ })[filedsKey];
38
+ }
39
+ }
40
+ }
41
+ };
42
+ AppController.prototype.setFiled = function (filed, value) {
9
43
  status_write({
10
- type: "session",
44
+ type: "local",
11
45
  fields: {
12
- theme: theme
46
+ theme: JSON.stringify(value)
13
47
  }
14
48
  });
15
- reloadStyle(theme);
49
+ this.loadFileds();
50
+ // @ts-ignore
51
+ this.fileds[filed].callback(value, window.context);
16
52
  };
17
- AppController.prototype.getInstance = function () {
18
- return this;
53
+ AppController.prototype.getFiled = function (filed) {
54
+ if (this.fileds[filed]) {
55
+ return this.fileds[filed].data;
56
+ }
57
+ else {
58
+ return null;
59
+ }
19
60
  };
20
61
  return AppController;
21
62
  }());
@@ -1,3 +1,10 @@
1
1
  export declare class ContextController {
2
+ private fileds;
3
+ private mixinData;
2
4
  constructor();
5
+ saveFileds(fileds: {}): void;
6
+ loadFileds(): void;
7
+ setFiled(filed: string, value: any): void;
8
+ getFiled(filed: string): any;
9
+ mixin(mix: {}): void;
3
10
  }
@@ -1,6 +1,66 @@
1
+ // @ts-ignore
2
+ import { status_read, status_write } from "render-status";
3
+ import { reloadStyle } from "../../core/utility/styleUtility";
1
4
  var ContextController = /** @class */ (function () {
2
5
  function ContextController() {
6
+ this.mixinData = {};
7
+ this.fileds = {
8
+ them: {
9
+ data: "default",
10
+ react: true,
11
+ callback: function (value, context) {
12
+ reloadStyle(value);
13
+ }
14
+ }
15
+ };
3
16
  }
17
+ ContextController.prototype.saveFileds = function (fileds) {
18
+ for (var filedsKey in fileds) {
19
+ if (Reflect.has(this.fileds, filedsKey)) {
20
+ console.log("This filed is a systemed filed, please have a new name for the filed:" + filedsKey);
21
+ }
22
+ else {
23
+ Reflect.set(this.fileds, filedsKey, fileds[filedsKey]);
24
+ }
25
+ }
26
+ };
27
+ ContextController.prototype.loadFileds = function () {
28
+ for (var filedsKey in this.fileds) {
29
+ if (this.fileds[filedsKey].react) {
30
+ if (status_read({
31
+ type: "session",
32
+ fields: [filedsKey]
33
+ })[filedsKey]) {
34
+ this.fileds[filedsKey].data = status_read({
35
+ type: "session",
36
+ fields: [filedsKey]
37
+ })[filedsKey];
38
+ }
39
+ }
40
+ }
41
+ };
42
+ ContextController.prototype.setFiled = function (filed, value) {
43
+ status_write({
44
+ type: "session",
45
+ fields: {
46
+ theme: JSON.stringify(value)
47
+ }
48
+ });
49
+ this.loadFileds();
50
+ // @ts-ignore
51
+ this.fileds[filed].callback(value, window.context);
52
+ };
53
+ ContextController.prototype.getFiled = function (filed) {
54
+ if (this.fileds[filed]) {
55
+ return this.fileds[filed].data;
56
+ }
57
+ else {
58
+ return null;
59
+ }
60
+ };
61
+ ContextController.prototype.mixin = function (mix) {
62
+ this.mixinData = mix;
63
+ };
4
64
  return ContextController;
5
65
  }());
6
66
  export { ContextController };
@@ -4,10 +4,12 @@ export declare class PageController {
4
4
  private currentTag;
5
5
  solt: Map<string, any>;
6
6
  raw_data: {};
7
+ private mixinData;
7
8
  to: ComponentController[];
8
9
  link: Map<string, {}>;
9
10
  constructor();
10
11
  receiver(method: string, ...args: any[]): void;
12
+ mixin(mix: {}): void;
11
13
  set crtTag(element: Element);
12
14
  get crtTag(): Element;
13
15
  }
@@ -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.mixinData = {};
10
11
  }
11
12
  //接收器
12
13
  PageController.prototype.receiver = function (method) {
@@ -14,6 +15,9 @@ 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);
19
+ };
20
+ PageController.prototype.mixin = function (mix) {
17
21
  };
18
22
  Object.defineProperty(PageController.prototype, "crtTag", {
19
23
  //返回当前页面的渲染元素
@@ -1,3 +1,2 @@
1
1
  export interface AppTip {
2
- getInstance(): any;
3
2
  }
@@ -1,3 +1,8 @@
1
1
  export interface RenderTip {
2
2
  use(callable: any): void;
3
+ configApp(config: {}): void;
4
+ configContext(cinfig: {}): void;
5
+ contextMixin(mix: {}): void;
6
+ pageMixin(mix: {}): any;
7
+ mount(): void;
3
8
  }
@@ -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
+ }
@@ -1,6 +1,4 @@
1
1
  import { loadStyle } from "../loader/loader";
2
- // @ts-ignore
3
- import { sessionStorageEngin_read } from "render-status/read/read";
4
2
  /**
5
3
  *
6
4
  * @param tag
@@ -38,7 +36,8 @@ export function themeStyle(component, styleLib) {
38
36
  * @param tag
39
37
  */
40
38
  export function styleResolve(tag) {
41
- var theme = sessionStorageEngin_read("theme");
39
+ // @ts-ignore
40
+ var theme = window.context.getFiled("theme");
42
41
  if (Reflect.get(window, "styleLib").get(tag.toUpperCase()).get(theme) === undefined) {
43
42
  console.log("tag:" + tag + " has no theme " + theme);
44
43
  }
package/index.d.ts CHANGED
@@ -11,8 +11,34 @@ 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
+ contextMixin(mix: {}): void;
37
+ /**
38
+ *
39
+ * @param mix
40
+ */
41
+ pageMixin(mix: {}): void;
16
42
  /**
17
43
  * If you want to hava a permission control to your application,you can
18
44
  * use our extra router moudle to define the router.
@@ -25,10 +51,9 @@ export declare class RenderJS implements RenderTip {
25
51
  */
26
52
  addTag(component: Component | Component[]): void;
27
53
  /**
28
- *
29
- * @param callable
54
+ * mount some base object
30
55
  */
31
- use(callable: any): void;
56
+ mount(): void;
32
57
  /**
33
58
  * This method is the boster method of the render.
34
59
  */
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,50 @@ var RenderJS = /** @class */ (function () {
15
13
  this.styleLib = new Map();
16
14
  //initiate the application controller
17
15
  this.application = new AppController();
16
+ //initiate the context controller
17
+ this.context = new ContextController();
18
18
  //initiate the page controller
19
19
  this.page = new PageController();
20
20
  //initiate the config object
21
21
  this.config = {};
22
- Reflect.set(this.config, "version", meta.version);
23
- Reflect.set(this.config, "theme", meta.style);
24
22
  }
23
+ /**
24
+ *
25
+ * @param config
26
+ */
27
+ RenderJS.prototype.configApp = function (config) {
28
+ this.application.saveFileds(config);
29
+ this.application.loadFileds();
30
+ };
31
+ /**
32
+ *
33
+ * @param cinfig
34
+ */
35
+ RenderJS.prototype.configContext = function (cinfig) {
36
+ this.context.saveFileds(cinfig);
37
+ this.context.loadFileds();
38
+ };
39
+ /**
40
+ *
41
+ * @param callable
42
+ */
43
+ RenderJS.prototype.use = function (callable) {
44
+ callable(this);
45
+ };
46
+ /**
47
+ *
48
+ * @param mix
49
+ */
50
+ RenderJS.prototype.contextMixin = function (mix) {
51
+ this.context.mixin(mix);
52
+ };
53
+ /**
54
+ *
55
+ * @param mix
56
+ */
57
+ RenderJS.prototype.pageMixin = function (mix) {
58
+ this.page.mixin(mix);
59
+ };
25
60
  /**
26
61
  * If you want to hava a permission control to your application,you can
27
62
  * use our extra router moudle to define the router.
@@ -38,34 +73,26 @@ var RenderJS = /** @class */ (function () {
38
73
  registerTagLib(this, component);
39
74
  };
40
75
  /**
41
- *
42
- * @param callable
76
+ * mount some base object
43
77
  */
44
- RenderJS.prototype.use = function (callable) {
45
- callable(this);
78
+ RenderJS.prototype.mount = function () {
79
+ Reflect.set(window, "tagLib", this.tagLib);
80
+ Reflect.set(window, "styleLib", this.styleLib);
81
+ Reflect.set(window, "page", this.page);
82
+ Reflect.set(window, "context", this.context);
83
+ Reflect.set(window, "appSite", this.application);
84
+ if (this.router) {
85
+ Reflect.set(window, "router", this.router);
86
+ }
46
87
  };
47
88
  /**
48
89
  * This method is the boster method of the render.
49
90
  */
50
91
  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
- }
92
+ //挂载对象
93
+ this.mount();
94
+ //execute
95
+ executor(this);
69
96
  };
70
97
  return RenderJS;
71
98
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.0.100",
3
+ "version": "1.0.102",
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
+ }