render-core 1.3.12 → 1.3.13

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.
@@ -3,28 +3,33 @@ import { AppTip } from "../tips/appTip";
3
3
  * This class is associated with localStorage.
4
4
  */
5
5
  export declare class AppController implements AppTip {
6
- private readonly fileds;
6
+ private readonly fields;
7
7
  constructor();
8
8
  /**
9
- * This method is used to add customed data.
10
- * @param fileds
9
+ * This method is used to add custom data.
10
+ * @param fields
11
11
  */
12
- saveFileds(fileds: {}): void;
12
+ saveFields(fields: {}): void;
13
13
  /**
14
14
  * 更新数据
15
15
  * @private
16
16
  */
17
- loadFileds(): void;
17
+ loadFields(): void;
18
18
  /**
19
19
  * store fields
20
20
  */
21
- storeFileds(): void;
22
- setFiled(filed: string, value: any): void;
21
+ storeFields(): void;
22
+ /**
23
+ *
24
+ * @param field
25
+ * @param value
26
+ */
27
+ setField(field: string, value: any): void;
23
28
  /**
24
29
  * 获取数据
25
- * @param filed
30
+ * @param field
26
31
  */
27
- getFiled(filed: string): any;
32
+ getField(field: string): any;
28
33
  /**
29
34
  * 资源定向
30
35
  * @param url
@@ -6,27 +6,21 @@ import { status_read, status_write } from "../../index";
6
6
  var AppController = /** @class */ (function () {
7
7
  //系统变量
8
8
  function AppController() {
9
- this.fileds = {
10
- system_theme: {
11
- data: "default",
12
- react: true,
13
- callback: function (value, context) {
14
- context.setFiled("system_theme", value);
15
- }
16
- }
9
+ this.fields = {
10
+ system_theme: "default"
17
11
  };
18
12
  }
19
13
  /**
20
- * This method is used to add customed data.
21
- * @param fileds
14
+ * This method is used to add custom data.
15
+ * @param fields
22
16
  */
23
- AppController.prototype.saveFileds = function (fileds) {
24
- for (var filedsKey in fileds) {
25
- if (Reflect.has(this.fileds, filedsKey)) {
26
- console.log("This filed is a systemed filed, please have a new name for the filed:" + filedsKey);
17
+ AppController.prototype.saveFields = function (fields) {
18
+ for (var fieldsKey in fields) {
19
+ if (Reflect.has(this.fields, fieldsKey)) {
20
+ console.log("This filed is a system filed, please have a new name for the filed:" + fieldsKey);
27
21
  }
28
22
  else {
29
- Reflect.set(this.fileds, filedsKey, fileds[filedsKey]);
23
+ Reflect.set(this.fields, fieldsKey, fields[fieldsKey]);
30
24
  }
31
25
  }
32
26
  };
@@ -34,17 +28,17 @@ var AppController = /** @class */ (function () {
34
28
  * 更新数据
35
29
  * @private
36
30
  */
37
- AppController.prototype.loadFileds = function () {
38
- for (var filedsKey in this.fileds) {
39
- if (this.fileds[filedsKey].react) {
31
+ AppController.prototype.loadFields = function () {
32
+ for (var fieldsKey in this.fields) {
33
+ if (this.fields[fieldsKey].react) {
40
34
  if (status_read({
41
35
  type: "local",
42
- fields: [filedsKey]
43
- })[filedsKey]) {
44
- this.fileds[filedsKey].data = status_read({
36
+ fields: [fieldsKey]
37
+ })[fieldsKey]) {
38
+ this.fields[fieldsKey].data = status_read({
45
39
  type: "local",
46
- fields: [filedsKey]
47
- })[filedsKey];
40
+ fields: [fieldsKey]
41
+ })[fieldsKey];
48
42
  }
49
43
  }
50
44
  }
@@ -52,39 +46,44 @@ var AppController = /** @class */ (function () {
52
46
  /**
53
47
  * store fields
54
48
  */
55
- AppController.prototype.storeFileds = function () {
56
- for (var filedsKey in this.fileds) {
49
+ AppController.prototype.storeFields = function () {
50
+ for (var fieldsKey in this.fields) {
57
51
  var data = {};
58
- Reflect.set(data, filedsKey, this.fileds[filedsKey]);
52
+ Reflect.set(data, fieldsKey, this.fields[fieldsKey]);
59
53
  status_write({
60
54
  type: "local",
61
55
  fields: data
62
56
  });
63
57
  }
64
58
  };
65
- AppController.prototype.setFiled = function (filed, value) {
59
+ /**
60
+ *
61
+ * @param field
62
+ * @param value
63
+ */
64
+ AppController.prototype.setField = function (field, value) {
66
65
  var data = {};
67
- Reflect.set(data, filed, value);
66
+ Reflect.set(data, field, value);
68
67
  //写入数
69
68
  status_write({
70
69
  type: "local",
71
70
  fields: data
72
71
  });
73
72
  //更新数据
74
- this.loadFileds();
73
+ this.loadFields();
75
74
  //执行回调
76
- if (this.fileds[filed].callback) {
75
+ if (this.fields[field].react) {
77
76
  // @ts-ignore
78
77
  this.fileds[filed].callback(value, window.context);
79
78
  }
80
79
  };
81
80
  /**
82
81
  * 获取数据
83
- * @param filed
82
+ * @param field
84
83
  */
85
- AppController.prototype.getFiled = function (filed) {
86
- if (this.fileds[filed]) {
87
- return this.fileds[filed].data;
84
+ AppController.prototype.getField = function (field) {
85
+ if (this.fields[field]) {
86
+ return this.fields[field].data;
88
87
  }
89
88
  else {
90
89
  return null;
@@ -1,24 +1,18 @@
1
1
  export declare class ContextController {
2
- private readonly fileds;
3
- private meta;
2
+ private readonly fields;
4
3
  constructor();
5
- saveFileds(fileds: {}): void;
6
- loadFileds(): void;
7
- storeFileds(): void;
4
+ saveFields(fields: {}): void;
5
+ loadFields(): void;
6
+ storeFields(): void;
8
7
  /**
9
8
  * 写入数据
10
- * @param filed
9
+ * @param field
11
10
  * @param value
12
11
  */
13
- setFiled(filed: string, value: any): void;
12
+ setField(field: string, value: any): void;
14
13
  /**
15
14
  * 获取数据
16
- * @param filed
15
+ * @param field
17
16
  */
18
- getFiled(filed: string): any;
19
- /**
20
- * 返回系统数据
21
- * @param filed
22
- */
23
- getMeta(filed: string): string;
17
+ getField(field: string): any;
24
18
  }
@@ -1,48 +1,39 @@
1
- import { reloadStyle } from "../../core/utility/styleUtility";
2
- import meta from "../../meta/meta";
3
1
  import { status_read, status_write } from "../../index";
4
2
  var ContextController = /** @class */ (function () {
5
3
  function ContextController() {
6
- this.fileds = {
7
- system_theme: {
8
- data: "default",
9
- react: true,
10
- callback: function (value) {
11
- reloadStyle(value);
12
- }
13
- }
4
+ this.fields = {
5
+ system_theme: "default"
14
6
  };
15
- this.meta = meta;
16
7
  }
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);
8
+ ContextController.prototype.saveFields = function (fields) {
9
+ for (var fieldsKey in fields) {
10
+ if (Reflect.has(this.fields, fieldsKey)) {
11
+ console.log("This field is a system field, please have a new name for the field:" + fieldsKey);
21
12
  }
22
13
  else {
23
- Reflect.set(this.fileds, filedsKey, fileds[filedsKey]);
14
+ Reflect.set(this.fields, fieldsKey, fields[fieldsKey]);
24
15
  }
25
16
  }
26
17
  };
27
- ContextController.prototype.loadFileds = function () {
28
- for (var filedsKey in this.fileds) {
29
- if (this.fileds[filedsKey].react) {
18
+ ContextController.prototype.loadFields = function () {
19
+ for (var fieldsKey in this.fields) {
20
+ if (this.fields[fieldsKey].react) {
30
21
  if (status_read({
31
22
  type: "session",
32
- fields: [filedsKey]
33
- })[filedsKey]) {
34
- this.fileds[filedsKey].data = status_read({
23
+ fields: [fieldsKey]
24
+ })[fieldsKey]) {
25
+ this.fields[fieldsKey].data = status_read({
35
26
  type: "session",
36
- fields: [filedsKey]
37
- })[filedsKey];
27
+ fields: [fieldsKey]
28
+ })[fieldsKey];
38
29
  }
39
30
  }
40
31
  }
41
32
  };
42
- ContextController.prototype.storeFileds = function () {
43
- for (var filedsKey in this.fileds) {
33
+ ContextController.prototype.storeFields = function () {
34
+ for (var fieldsKey in this.fields) {
44
35
  var data = {};
45
- Reflect.set(data, filedsKey, this.fileds[filedsKey]);
36
+ Reflect.set(data, fieldsKey, this.fields[fieldsKey]);
46
37
  status_write({
47
38
  type: "session",
48
39
  fields: data
@@ -51,12 +42,12 @@ var ContextController = /** @class */ (function () {
51
42
  };
52
43
  /**
53
44
  * 写入数据
54
- * @param filed
45
+ * @param field
55
46
  * @param value
56
47
  */
57
- ContextController.prototype.setFiled = function (filed, value) {
48
+ ContextController.prototype.setField = function (field, value) {
58
49
  var data = {};
59
- Reflect.set(data, filed, value);
50
+ Reflect.set(data, field, value);
60
51
  //写入数据
61
52
  status_write({
62
53
  type: "session",
@@ -64,32 +55,25 @@ var ContextController = /** @class */ (function () {
64
55
  });
65
56
  //更新数据
66
57
  // @ts-ignore
67
- this.loadFileds();
58
+ this.loadfields();
68
59
  //数据回调
69
- if (this.fileds[filed]) {
60
+ if (this.fields[field].react) {
70
61
  // @ts-ignore
71
- this.fileds[filed].callback(value, window.appSite);
62
+ this.fields[field].callback(value, window.appSite);
72
63
  }
73
64
  };
74
65
  /**
75
66
  * 获取数据
76
- * @param filed
67
+ * @param field
77
68
  */
78
- ContextController.prototype.getFiled = function (filed) {
79
- if (this.fileds[filed]) {
80
- return this.fileds[filed].data;
69
+ ContextController.prototype.getField = function (field) {
70
+ if (this.fields[field]) {
71
+ return this.fields[field].data;
81
72
  }
82
73
  else {
83
74
  return null;
84
75
  }
85
76
  };
86
- /**
87
- * 返回系统数据
88
- * @param filed
89
- */
90
- ContextController.prototype.getMeta = function (filed) {
91
- return this.meta[filed];
92
- };
93
77
  return ContextController;
94
78
  }());
95
79
  export { ContextController };
@@ -8,13 +8,16 @@ export declare class PageController {
8
8
  to: ComponentController[];
9
9
  link: Map<string, {}>;
10
10
  constructor();
11
+ /**
12
+ *
13
+ * @param method
14
+ * @param args
15
+ */
11
16
  receiver(method: string, ...args: any[]): void;
12
- set crtTag(element: Element);
13
- get crtTag(): Element;
14
17
  /**
15
- * Change the tag theme
16
- * @param tag
17
- * @param style
18
+ *
19
+ * @param element
18
20
  */
19
- changeTheme(tag: any, style: string): void;
21
+ set crtTag(element: Element);
22
+ get crtTag(): Element;
20
23
  }
@@ -1,4 +1,3 @@
1
- import { changeStyle } from "../../core/utility/styleUtility";
2
1
  var PageController = /** @class */ (function () {
3
2
  //构造函数
4
3
  function PageController() {
@@ -9,34 +8,33 @@ var PageController = /** @class */ (function () {
9
8
  this.crtTag = null;
10
9
  this.solt = new Map();
11
10
  }
12
- //接收器
11
+ /**
12
+ *
13
+ * @param method
14
+ * @param args
15
+ */
13
16
  PageController.prototype.receiver = function (method) {
14
17
  var args = [];
15
18
  for (var _i = 1; _i < arguments.length; _i++) {
16
19
  args[_i - 1] = arguments[_i];
17
20
  }
18
- this.methods[method].call(window, args);
21
+ Reflect.get(window, method).call(window, args);
19
22
  };
20
23
  Object.defineProperty(PageController.prototype, "crtTag", {
21
24
  //返回当前页面的渲染元素
22
25
  get: function () {
23
26
  return this.currentTag;
24
27
  },
25
- //设置当前页面的渲染元素
28
+ /**
29
+ *
30
+ * @param element
31
+ */
26
32
  set: function (element) {
27
33
  this.currentTag = element;
28
34
  },
29
35
  enumerable: false,
30
36
  configurable: true
31
37
  });
32
- /**
33
- * Change the tag theme
34
- * @param tag
35
- * @param style
36
- */
37
- PageController.prototype.changeTheme = function (tag, style) {
38
- changeStyle(tag, style);
39
- };
40
38
  return PageController;
41
39
  }());
42
40
  export { PageController };
@@ -26,3 +26,4 @@ export declare function reloadStyle(theme: string): void;
26
26
  * @param theme
27
27
  */
28
28
  export declare function changeStyle(tag: string, theme: string): void;
29
+ export declare function changeTheme(theme: string): void;
@@ -94,3 +94,21 @@ export function changeStyle(tag, theme) {
94
94
  head.replaceChild(style, target);
95
95
  }
96
96
  }
97
+ export function changeTheme(theme) {
98
+ Reflect.get(window, "styleLib").forEach(function (value, key) {
99
+ var styles = document.getElementsByTagName("style");
100
+ for (var i = 0; i < styles.length; i++) {
101
+ if (styles[i].getAttribute("tag") === key) {
102
+ var style = document.createElement('style');
103
+ if (value.get(theme.toUpperCase())) {
104
+ var text = document.createTextNode(value.get(theme.toUpperCase()));
105
+ style.appendChild(text);
106
+ style.setAttribute("tag", key.toUpperCase());
107
+ style.setAttribute("theme", theme.toUpperCase());
108
+ var head = document.getElementsByTagName('head')[0];
109
+ head.replaceChild(style, styles[i]);
110
+ }
111
+ }
112
+ }
113
+ });
114
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ * @param tag
4
+ * @param theme
5
+ */
6
+ export declare function changeTagTheme(tag: string, theme: string): void;
7
+ /**
8
+ *
9
+ * @param theme
10
+ */
11
+ export declare function changeSessionTheme(theme: string): void;
12
+ /**
13
+ *
14
+ * @param theme
15
+ */
16
+ export declare function changeApplicationTheme(theme: string): void;
package/func/Theme.js ADDED
@@ -0,0 +1,45 @@
1
+ import { changeStyle, changeTheme } from "../core/utility/styleUtility";
2
+ /**
3
+ *
4
+ * @param tag
5
+ * @param theme
6
+ */
7
+ export function changeTagTheme(tag, theme) {
8
+ changeStyle(tag, theme);
9
+ }
10
+ /**
11
+ *
12
+ * @param theme
13
+ */
14
+ export function changeSessionTheme(theme) {
15
+ var application = Reflect.get(window, "context");
16
+ application.setField("system_theme", {
17
+ data: theme,
18
+ react: true,
19
+ callback: function (value, context) {
20
+ context.setFiled("system_theme", {
21
+ data: value,
22
+ react: false
23
+ });
24
+ }
25
+ });
26
+ changeTheme(application.getField("system_theme"));
27
+ }
28
+ /**
29
+ *
30
+ * @param theme
31
+ */
32
+ export function changeApplicationTheme(theme) {
33
+ var application = Reflect.get(window, "appSite");
34
+ application.setField("system_theme", {
35
+ data: theme,
36
+ react: true,
37
+ callback: function (value, context) {
38
+ context.setFiled("system_theme", {
39
+ data: value,
40
+ react: false
41
+ });
42
+ }
43
+ });
44
+ changeTheme(application.getField("system_theme"));
45
+ }
package/index.d.ts CHANGED
@@ -8,8 +8,8 @@ export declare class RenderJS implements RenderTip {
8
8
  readonly config: {};
9
9
  readonly tagLib: Map<string, Component>;
10
10
  readonly styleLib: Map<string, Map<string, string>>;
11
- private application;
12
- private context;
11
+ private readonly application;
12
+ private readonly context;
13
13
  page: PageController;
14
14
  constructor();
15
15
  /**
@@ -37,9 +37,15 @@ export declare class RenderJS implements RenderTip {
37
37
  */
38
38
  private mount;
39
39
  /**
40
- * This method is the boster method of the render.
40
+ * This method is the booster method of the render.
41
41
  */
42
42
  run(): void;
43
+ /**
44
+ *
45
+ * @param name
46
+ * @param func
47
+ */
48
+ registerElements(name: string, func: any): void;
43
49
  }
44
50
  /**
45
51
  * The tool to register element to window
package/index.js CHANGED
@@ -27,18 +27,18 @@ var RenderJS = /** @class */ (function () {
27
27
  * @param config
28
28
  */
29
29
  RenderJS.prototype.configApp = function (config) {
30
- this.application.saveFileds(config);
31
- this.application.storeFileds();
32
- this.application.loadFileds();
30
+ this.application.saveFields(config);
31
+ this.application.storeFields();
32
+ this.application.loadFields();
33
33
  };
34
34
  /**
35
35
  *
36
36
  * @param config
37
37
  */
38
38
  RenderJS.prototype.configContext = function (config) {
39
- this.context.saveFileds(config);
40
- this.context.storeFileds();
41
- this.context.loadFileds();
39
+ this.context.saveFields(config);
40
+ this.context.storeFields();
41
+ this.context.loadFields();
42
42
  };
43
43
  /**
44
44
  *
@@ -65,7 +65,7 @@ var RenderJS = /** @class */ (function () {
65
65
  Reflect.set(window, "page", this.page);
66
66
  };
67
67
  /**
68
- * This method is the boster method of the render.
68
+ * This method is the booster method of the render.
69
69
  */
70
70
  RenderJS.prototype.run = function () {
71
71
  //挂载对象
@@ -73,6 +73,14 @@ var RenderJS = /** @class */ (function () {
73
73
  //execute
74
74
  render(this);
75
75
  };
76
+ /**
77
+ *
78
+ * @param name
79
+ * @param func
80
+ */
81
+ RenderJS.prototype.registerElements = function (name, func) {
82
+ Reflect.set(window, name, func);
83
+ };
76
84
  return RenderJS;
77
85
  }());
78
86
  export { RenderJS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "The core of render-js",
5
5
  "keywords": [
6
6
  "render",
@@ -1,14 +1,14 @@
1
1
  import { Component } from "../class/component/component";
2
2
  import { RenderJS } from "../index";
3
3
  /**
4
- * This function is used to save the protype component class in the window object.
5
- * So, you can hava a tip that we customed a property named 'tagLib' in the window object.
4
+ * This function is used to save the prototype component class in the window object.
5
+ * So, you can hava a tip that we custom a property named 'tagLib' in the window object.
6
6
  * @param application
7
7
  * @param component
8
8
  */
9
9
  export declare function registerTagLib(application: RenderJS, component: Component | Component[]): void;
10
10
  /**
11
- * The entrancy of render
11
+ * The entrance of render
12
12
  * @param renderjs
13
13
  */
14
14
  export declare function render(renderjs: RenderJS): void;
package/runtime/tools.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Component } from "../class/component/component";
2
2
  import { themeStyle } from "../core/utility/styleUtility";
3
3
  import { renderHtml } from "./runtime";
4
+ import { changeApplicationTheme, changeSessionTheme, changeTagTheme } from "../func/Theme";
4
5
  /**
5
- * This function is used to save the protype component class in the window object.
6
- * So, you can hava a tip that we customed a property named 'tagLib' in the window object.
6
+ * This function is used to save the prototype component class in the window object.
7
+ * So, you can hava a tip that we custom a property named 'tagLib' in the window object.
7
8
  * @param application
8
9
  * @param component
9
10
  */
@@ -30,7 +31,7 @@ export function registerTagLib(application, component) {
30
31
  }
31
32
  }
32
33
  /**
33
- * The entrancy of render
34
+ * The entrance of render
34
35
  * @param renderjs
35
36
  */
36
37
  export function render(renderjs) {
@@ -38,6 +39,9 @@ export function render(renderjs) {
38
39
  renderjs.tagLib.forEach(function (component) {
39
40
  themeStyle(component, renderjs.styleLib);
40
41
  });
42
+ renderjs.registerElements("changeTagTheme", changeTagTheme);
43
+ renderjs.registerElements("changeSessionTheme", changeSessionTheme);
44
+ renderjs.registerElements("changeApplicationTheme", changeApplicationTheme);
41
45
  //开始渲染
42
46
  renderHtml(document.body.children, renderjs.page);
43
47
  }
@@ -1,10 +1,10 @@
1
1
  /**
2
- * This function is used to get vaule from sessionStorage.
2
+ * This function is used to get value from sessionStorage.
3
3
  * @param filed
4
4
  */
5
5
  export declare function sessionStorageEngin_read(filed: string): any;
6
6
  /**
7
- * This function is used to get vaule from localStorage.
7
+ * This function is used to get value from localStorage.
8
8
  * @param filed
9
9
  */
10
10
  export declare function localStorageEngine_read(filed: string): any;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * This function is used to get vaule from sessionStorage.
2
+ * This function is used to get value from sessionStorage.
3
3
  * @param filed
4
4
  */
5
5
  export function sessionStorageEngin_read(filed) {
@@ -12,7 +12,7 @@ export function sessionStorageEngin_read(filed) {
12
12
  }
13
13
  }
14
14
  /**
15
- * This function is used to get vaule from localStorage.
15
+ * This function is used to get value from localStorage.
16
16
  * @param filed
17
17
  */
18
18
  export function localStorageEngine_read(filed) {