render-core 1.4.4 → 1.4.6

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/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { PluginGeneric } from "./tension/generic/plugin/PluginGeneric";
4
4
  import { HooksGeneric } from "./tension/generic/plugin/hooks/HooksGeneric";
5
5
  import { AbstractComponent } from "./tension/prototype/AbstractComponent";
6
6
  import { PrefaceGeneric } from "./tension/generic/plugin/preface/PrefaceGeneric";
7
+ import { RouterGeneric } from "./tension/generic/router/RouterGeneric";
7
8
  /**
8
9
  * This class is used to prototype the properties type
9
10
  */
@@ -17,14 +18,15 @@ export declare class PropertyType {
17
18
  /**
18
19
  *
19
20
  */
20
- export declare abstract class AbstractRenderJS implements RenderGeneric {
21
- use_plugin(plugin: AbstractPlugin): void;
21
+ export declare abstract class AbstractPlugin implements PluginGeneric {
22
+ plugin(preface: PrefaceGeneric, hooks: HooksGeneric): void;
22
23
  }
23
24
  /**
24
25
  *
25
26
  */
26
- export declare abstract class AbstractPlugin implements PluginGeneric {
27
- plugin(preface: PrefaceGeneric, hooks: HooksGeneric): void;
27
+ export declare abstract class AbstractRouter implements RouterGeneric {
28
+ getComponent(): Component;
29
+ getPathVariable(): Map<string, any>;
28
30
  }
29
31
  /**
30
32
  * Here is the template class for render component!
@@ -46,51 +48,37 @@ export declare class Component extends AbstractComponent {
46
48
  afterRender?: () => void;
47
49
  });
48
50
  }
51
+ /**
52
+ * This func is used to extend window environment
53
+ * @param on
54
+ * @param func
55
+ */
56
+ export declare function extend_window(on: string, func: any): void;
49
57
  /**
50
58
  * This proto is the application proto.
51
59
  */
52
- export declare class RenderJS extends AbstractRenderJS {
60
+ export declare class RenderJS implements RenderGeneric {
53
61
  contextController: ContextController;
54
62
  constructor();
55
63
  /**
56
- * Inject element to the window environment.
57
- * @param name
58
- * @param func
59
- */
60
- static registerElement(name: string, func: any): void;
61
- setRouteTable(value: {
62
- routeMode: string;
63
- table: [
64
- {
65
- path: string;
66
- component: Component;
67
- }
68
- ];
69
- }): void;
70
- /**
71
- * This func is the plugin entry to third vendor
64
+ * This func is used to execute plugins
72
65
  */
73
66
  use_plugin(plugin: PluginGeneric): void;
74
67
  /**
75
- * You can use the method to register your single component or an array of components.
68
+ * This unc is used to register component to system
76
69
  * @param component
77
70
  */
78
- addTag(component: Component | Component[]): void;
71
+ add_tag(component: Component): void;
79
72
  /**
80
- * This method is the booster method of the render.
81
- * @return void
73
+ * This func is used to work under the route mode
82
74
  */
83
- run(component?: Component, root?: string): void;
75
+ listen(): void;
84
76
  /**
85
- *
86
- * @param component
87
- * @private
77
+ * This func is used to work under the directive render mode
88
78
  */
89
- private spa_run;
79
+ render(component: Component, mounter: string): void;
90
80
  /**
91
- *
92
- * @param root
93
- * @private
81
+ * This func is used to work under the weave mode
94
82
  */
95
- private mpa_run;
83
+ weave(mounter: string): void;
96
84
  }
package/index.js CHANGED
@@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () {
13
13
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
14
  };
15
15
  })();
16
- import { render_for_mpa, render_for_spa } from "./xboot/entrance";
16
+ import { render_for_listen, render_for_render, render_for_weave } from "./xboot/entrance";
17
17
  import { registerTagLib } from "./xboot/tagProcessor";
18
18
  import { HooksAction } from "./tension/prototype/HooksAction";
19
19
  import { ContextController } from "./system/prototype/ContextController";
@@ -21,7 +21,6 @@ import { AbstractComponent } from "./tension/prototype/AbstractComponent";
21
21
  import { set_context_controller } from "./system/recorder/table0/system_func_0";
22
22
  import { PrefaceAction } from "./tension/prototype/PrefaceAction";
23
23
  import { SystemInitPlugin } from "./tension/SystemInitPlugin";
24
- import { get_route_mode, set_path_variable } from "./system/recorder/table1/system_func_1";
25
24
  /**
26
25
  * This class is used to prototype the properties type
27
26
  */
@@ -34,25 +33,29 @@ export { PropertyType };
34
33
  /**
35
34
  *
36
35
  */
37
- var AbstractRenderJS = /** @class */ (function () {
38
- function AbstractRenderJS() {
36
+ var AbstractPlugin = /** @class */ (function () {
37
+ function AbstractPlugin() {
39
38
  }
40
- AbstractRenderJS.prototype.use_plugin = function (plugin) {
39
+ AbstractPlugin.prototype.plugin = function (preface, hooks) {
41
40
  };
42
- return AbstractRenderJS;
41
+ return AbstractPlugin;
43
42
  }());
44
- export { AbstractRenderJS };
43
+ export { AbstractPlugin };
45
44
  /**
46
45
  *
47
46
  */
48
- var AbstractPlugin = /** @class */ (function () {
49
- function AbstractPlugin() {
47
+ var AbstractRouter = /** @class */ (function () {
48
+ function AbstractRouter() {
50
49
  }
51
- AbstractPlugin.prototype.plugin = function (preface, hooks) {
50
+ AbstractRouter.prototype.getComponent = function () {
51
+ return undefined;
52
52
  };
53
- return AbstractPlugin;
53
+ AbstractRouter.prototype.getPathVariable = function () {
54
+ return undefined;
55
+ };
56
+ return AbstractRouter;
54
57
  }());
55
- export { AbstractPlugin };
58
+ export { AbstractRouter };
56
59
  /**
57
60
  * Here is the template class for render component!
58
61
  */
@@ -64,72 +67,60 @@ var Component = /** @class */ (function (_super) {
64
67
  return Component;
65
68
  }(AbstractComponent));
66
69
  export { Component };
70
+ /**
71
+ * This func is used to extend window environment
72
+ * @param on
73
+ * @param func
74
+ */
75
+ export function extend_window(on, func) {
76
+ Reflect.set(window, on, func);
77
+ }
67
78
  /**
68
79
  * This proto is the application proto.
69
80
  */
70
- var RenderJS = /** @class */ (function (_super) {
71
- __extends(RenderJS, _super);
81
+ var RenderJS = /** @class */ (function () {
72
82
  function RenderJS() {
73
- var _this = _super.call(this) || this;
74
83
  /* initiate the page controller */
75
- _this.contextController = new ContextController({
84
+ this.contextController = new ContextController({
76
85
  boxMode: false,
77
86
  });
78
87
  /* init the basis extension */
79
- _this.use_plugin(new SystemInitPlugin());
80
- return _this;
88
+ this.use_plugin(new SystemInitPlugin());
81
89
  }
82
90
  /**
83
- * Inject element to the window environment.
84
- * @param name
85
- * @param func
86
- */
87
- RenderJS.registerElement = function (name, func) {
88
- Reflect.set(window, name, func);
89
- };
90
- RenderJS.prototype.setRouteTable = function (value) {
91
- set_path_variable(value);
92
- };
93
- /**
94
- * This func is the plugin entry to third vendor
91
+ * This func is used to execute plugins
95
92
  */
96
93
  RenderJS.prototype.use_plugin = function (plugin) {
97
94
  plugin.plugin(new PrefaceAction(), new HooksAction());
98
95
  };
99
96
  /**
100
- * You can use the method to register your single component or an array of components.
97
+ * This unc is used to register component to system
101
98
  * @param component
102
99
  */
103
- RenderJS.prototype.addTag = function (component) {
100
+ RenderJS.prototype.add_tag = function (component) {
104
101
  registerTagLib(component);
105
102
  };
106
103
  /**
107
- * This method is the booster method of the render.
108
- * @return void
104
+ * This func is used to work under the route mode
109
105
  */
110
- RenderJS.prototype.run = function (component, root) {
106
+ RenderJS.prototype.listen = function () {
111
107
  set_context_controller(this.contextController);
112
- if (get_route_mode())
113
- this.spa_run(component);
114
- else
115
- this.mpa_run(root);
108
+ render_for_listen();
116
109
  };
117
110
  /**
118
- *
119
- * @param component
120
- * @private
111
+ * This func is used to work under the directive render mode
121
112
  */
122
- RenderJS.prototype.spa_run = function (component) {
123
- render_for_spa(component);
113
+ RenderJS.prototype.render = function (component, mounter) {
114
+ set_context_controller(this.contextController);
115
+ render_for_render(component, mounter);
124
116
  };
125
117
  /**
126
- *
127
- * @param root
128
- * @private
118
+ * This func is used to work under the weave mode
129
119
  */
130
- RenderJS.prototype.mpa_run = function (root) {
131
- render_for_mpa(root);
120
+ RenderJS.prototype.weave = function (mounter) {
121
+ set_context_controller(this.contextController);
122
+ render_for_weave(mounter);
132
123
  };
133
124
  return RenderJS;
134
- }(AbstractRenderJS));
125
+ }());
135
126
  export { RenderJS };
@@ -1,6 +1,6 @@
1
1
  import { ContextController } from "../../system/prototype/ContextController";
2
2
  import { isUnKnown } from "../../system/utility/checkUtility";
3
- import { get_tag_library } from "../../system/recorder/table0/system_func_0";
3
+ import { get_tag_library, set_context_controller } from "../../system/recorder/table0/system_func_0";
4
4
  import { init_renderer } from "../renderer/initRender";
5
5
  import { post_renderer } from "../renderer/postRender";
6
6
  import { raw_renderer } from "../renderer/rawRender";
@@ -23,6 +23,7 @@ export function direct_delivery(protoTypeComponent) {
23
23
  var context = new ContextController({
24
24
  boxMode: true
25
25
  });
26
+ set_context_controller(context);
26
27
  var webview = document.querySelector("webview");
27
28
  raw_renderer(protoTypeComponent, webview.parentNode, webview, context);
28
29
  }
@@ -7,6 +7,6 @@ export declare function router_listener_with_router(view: HTMLElement): void;
7
7
  /**
8
8
  *
9
9
  * @param component
10
- * @param view
10
+ * @param mounter
11
11
  */
12
- export declare function router_listener_without_router(component: Component, view: HTMLElement): void;
12
+ export declare function router_listener_without_router(component: Component, mounter: HTMLElement): void;
@@ -7,26 +7,31 @@ import { set_path_variable } from "../../system/recorder/table1/system_func_1";
7
7
  * @param view
8
8
  */
9
9
  export function router_listener_with_router(view) {
10
- if (view !== null) {
11
- var controller = get_context_controller();
12
- var router = get_system_ext_router();
13
- var component = router.getComponent();
14
- set_path_variable(router.getPathVariable());
15
- spa_delivery(component, view.parentNode, view, controller);
10
+ if (!get_system_ext_router())
11
+ console.log("Router not supported");
12
+ else {
13
+ if (view !== null) {
14
+ var controller = get_context_controller();
15
+ var router = get_system_ext_router();
16
+ var component = router.getComponent();
17
+ var variable = router.getPathVariable();
18
+ set_path_variable(variable);
19
+ spa_delivery(component, view.parentNode, view, controller);
20
+ }
21
+ else
22
+ console.log("Without view element to render");
16
23
  }
17
- else
18
- console.log("Without view element to render");
19
24
  }
20
25
  /**
21
26
  *
22
27
  * @param component
23
- * @param view
28
+ * @param mounter
24
29
  */
25
- export function router_listener_without_router(component, view) {
26
- if (view !== null) {
30
+ export function router_listener_without_router(component, mounter) {
31
+ if (mounter !== null) {
27
32
  var controller = get_context_controller();
28
- spa_delivery(component, view.parentNode, view, controller);
33
+ spa_delivery(component, mounter.parentNode, mounter, controller);
29
34
  }
30
35
  else
31
- console.log("Without view element to render");
36
+ console.log("Without mounter element to render");
32
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "The extendable javascript web framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,4 +1,9 @@
1
- import { AbstractPlugin } from "../../../index";
1
+ import { PluginGeneric } from "../../../tension/generic/plugin/PluginGeneric";
2
+ import { Component } from "../../../index";
2
3
  export interface RenderGeneric {
3
- use_plugin(plugin: AbstractPlugin): void;
4
+ use_plugin(plugin: PluginGeneric): void;
5
+ add_tag(component: Component): void;
6
+ listen(): void;
7
+ render(component: Component, mounter: string): void;
8
+ weave(mounter: string): void;
4
9
  }
@@ -3,5 +3,6 @@ declare const _default: {
3
3
  routerMode: boolean;
4
4
  simpleRouteTable: any;
5
5
  getPathVariable: any;
6
+ userEnvironment: {};
6
7
  };
7
8
  export default _default;
@@ -2,5 +2,6 @@ export default {
2
2
  styleTheme: "default",
3
3
  routerMode: false,
4
4
  simpleRouteTable: null,
5
- getPathVariable: null
5
+ getPathVariable: null,
6
+ userEnvironment: {}
6
7
  };
@@ -3,9 +3,14 @@ import { Component } from "../index";
3
3
  * The entrance of render
4
4
  * @param root
5
5
  */
6
- export declare function render_for_mpa(root: string): void;
6
+ export declare function render_for_weave(root?: string): void;
7
+ /**
8
+ *
9
+ */
10
+ export declare function render_for_listen(): void;
7
11
  /**
8
12
  *
9
13
  * @param component
14
+ * @param mounter
10
15
  */
11
- export declare function render_for_spa(component?: Component): void;
16
+ export declare function render_for_render(component: Component, mounter: string): void;
package/xboot/Entrance.js CHANGED
@@ -6,7 +6,7 @@ import { router_listener_with_router, router_listener_without_router } from "../
6
6
  * The entrance of render
7
7
  * @param root
8
8
  */
9
- export function render_for_mpa(root) {
9
+ export function render_for_weave(root) {
10
10
  //获取styleLib对象
11
11
  get_tag_library().forEach(function (component) {
12
12
  themeStyle(component, get_style_library());
@@ -32,16 +32,23 @@ export function render_for_mpa(root) {
32
32
  }
33
33
  }
34
34
  }
35
+ /**
36
+ *
37
+ */
38
+ export function render_for_listen() {
39
+ get_tag_library().forEach(function (component) {
40
+ themeStyle(component, get_style_library());
41
+ });
42
+ router_listener_with_router(document.querySelector("webview"));
43
+ }
35
44
  /**
36
45
  *
37
46
  * @param component
47
+ * @param mounter
38
48
  */
39
- export function render_for_spa(component) {
49
+ export function render_for_render(component, mounter) {
40
50
  get_tag_library().forEach(function (component) {
41
51
  themeStyle(component, get_style_library());
42
52
  });
43
- if (component == null)
44
- router_listener_with_router(document.querySelector("webview"));
45
- else
46
- router_listener_without_router(component, document.querySelector("webview"));
53
+ router_listener_without_router(component, document.getElementById(mounter));
47
54
  }