render-core 1.4.20 → 1.4.21
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/kernel/proxyer/getProxy.js +35 -20
- package/kernel/renderer/updateRender.d.ts +1 -1
- package/kernel/renderer/updateRender.js +1 -1
- package/package.json +1 -1
- package/system/lifecycle/lifeCycle.d.ts +2 -2
- package/system/lifecycle/lifeCycle.js +2 -2
- package/system/lifecycle/mount.d.ts +1 -1
- package/system/lifecycle/mount.js +1 -1
- package/lint/directive-linter.d.ts +0 -16
- package/lint/directive-linter.js +0 -123
- package/system/output/error.d.ts +0 -0
- package/system/output/error.js +0 -4
|
@@ -5,27 +5,42 @@ import { locateInputAddress } from "../../system/utility/react/sectionUtility";
|
|
|
5
5
|
* @param updater
|
|
6
6
|
*/
|
|
7
7
|
export function get_proxy_for_method(data, updater) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param updater
|
|
14
|
-
*/
|
|
15
|
-
function get_setter_for_method_proxy(updater) {
|
|
16
|
-
var setter = function (obj, prop, value) {
|
|
17
|
-
Reflect.set(obj, prop, value);
|
|
18
|
-
update_Render(this);
|
|
19
|
-
try {
|
|
20
|
-
this.watcher[prop](obj[prop], value);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
8
|
+
var proxyCache = new WeakMap();
|
|
9
|
+
function createDeepProxy(target) {
|
|
10
|
+
if (proxyCache.has(target)) {
|
|
11
|
+
return proxyCache.get(target);
|
|
23
12
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
var proxy = new Proxy(target, {
|
|
14
|
+
set: function (obj, prop, value) {
|
|
15
|
+
if (value !== null && typeof value === 'object') {
|
|
16
|
+
value = createDeepProxy(value);
|
|
17
|
+
}
|
|
18
|
+
Reflect.set(obj, prop, value);
|
|
19
|
+
update_Render(updater);
|
|
20
|
+
try {
|
|
21
|
+
if (updater.watcher && typeof updater.watcher[prop] === 'function') {
|
|
22
|
+
updater.watcher[prop](obj[prop], value);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
// silently ignore missing watchers
|
|
27
|
+
}
|
|
28
|
+
locateInputAddress(updater);
|
|
29
|
+
Reflect.deleteProperty(updater, 'origin');
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
get: function (obj, prop) {
|
|
33
|
+
var value = Reflect.get(obj, prop);
|
|
34
|
+
if (value !== null && typeof value === 'object') {
|
|
35
|
+
return createDeepProxy(value);
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
proxyCache.set(target, proxy);
|
|
41
|
+
return proxy;
|
|
42
|
+
}
|
|
43
|
+
return createDeepProxy(data);
|
|
29
44
|
}
|
|
30
45
|
/**
|
|
31
46
|
* @param origin
|
|
@@ -4,7 +4,7 @@ import { findComponent } from "../delivery/delivery";
|
|
|
4
4
|
import { getTemplate } from "../../system/utility/initiate/templateUtility";
|
|
5
5
|
import { archive_mount, mountForUpdate } from "../../system/lifecycle/mount";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Method for upgrade
|
|
8
8
|
* @param currentController
|
|
9
9
|
*/
|
|
10
10
|
export function update_Render(currentController) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ContextController } from "../prototype/ContextController";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This function handles pre-render operations
|
|
4
4
|
* @param currenController
|
|
5
5
|
* @param child
|
|
6
6
|
* @param parentController
|
|
7
7
|
*/
|
|
8
8
|
export declare function after_process_for_init(currenController: ContextController, child: ChildNode, parentController: ContextController): void;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* This function handles post-render operations
|
|
11
11
|
* @param currentController
|
|
12
12
|
* @param parentController
|
|
13
13
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* This function handles pre-render operations
|
|
3
3
|
* @param currenController
|
|
4
4
|
* @param child
|
|
5
5
|
* @param parentController
|
|
@@ -11,7 +11,7 @@ export function after_process_for_init(currenController, child, parentController
|
|
|
11
11
|
parentController.lazyComponent.set(child.getAttribute("name"), controller.originalData);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* This function handles post-render operations
|
|
15
15
|
* @param currentController
|
|
16
16
|
* @param parentController
|
|
17
17
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContextController } from "../prototype/ContextController";
|
|
2
2
|
import { Component } from "../../index";
|
|
3
3
|
/**
|
|
4
|
-
* This function is used to mount the dom to the
|
|
4
|
+
* This function is used to mount the dom to the HTML document.
|
|
5
5
|
* @param controller
|
|
6
6
|
* @param proto
|
|
7
7
|
* @param parent
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Component } from "../index";
|
|
2
|
-
export interface DirectiveLocation {
|
|
3
|
-
directive: string;
|
|
4
|
-
expression: string;
|
|
5
|
-
element: string;
|
|
6
|
-
line: number;
|
|
7
|
-
column: number;
|
|
8
|
-
}
|
|
9
|
-
export interface LintError {
|
|
10
|
-
rule: string;
|
|
11
|
-
message: string;
|
|
12
|
-
line: number;
|
|
13
|
-
column: number;
|
|
14
|
-
}
|
|
15
|
-
export declare function lintComponent(component: Component): LintError[];
|
|
16
|
-
export declare function lintComponents(components: Component[]): Map<string, LintError[]>;
|
package/lint/directive-linter.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
var BOOLEAN_CONDITION_DIRECTIVES = ["@if", "@show"];
|
|
2
|
-
var ARRAY_ITERATION_DIRECTIVES = ["@for", "@map"];
|
|
3
|
-
var MODEL_ELEMENT = ["INPUT", "SELECT", "TEXTAREA"];
|
|
4
|
-
function parseTemplateForDirectives(template) {
|
|
5
|
-
var directives = [];
|
|
6
|
-
var lines = template.split("\n");
|
|
7
|
-
for (var lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
8
|
-
var line = lines[lineIndex];
|
|
9
|
-
var directiveRegex = /@(\w+)(?:\s*=\s*"([^"]*)"|\s*=\s*'([^']*)')?/g;
|
|
10
|
-
var match = void 0;
|
|
11
|
-
while ((match = directiveRegex.exec(line)) !== null) {
|
|
12
|
-
var directiveName = match[1];
|
|
13
|
-
var expression = match[2] || match[3] || "";
|
|
14
|
-
var elementMatch = line.match(/<(\w+)/);
|
|
15
|
-
var element = elementMatch ? elementMatch[1] : "unknown";
|
|
16
|
-
directives.push({
|
|
17
|
-
directive: "@".concat(directiveName),
|
|
18
|
-
expression: expression,
|
|
19
|
-
element: element.toUpperCase(),
|
|
20
|
-
line: lineIndex + 1,
|
|
21
|
-
column: match.index + 1
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return directives;
|
|
26
|
-
}
|
|
27
|
-
function inferType(value) {
|
|
28
|
-
if (value === true || value === false)
|
|
29
|
-
return "boolean";
|
|
30
|
-
if (Array.isArray(value))
|
|
31
|
-
return "array";
|
|
32
|
-
if (typeof value === "number")
|
|
33
|
-
return "number";
|
|
34
|
-
if (typeof value === "string")
|
|
35
|
-
return "string";
|
|
36
|
-
if (typeof value === "object" && value !== null)
|
|
37
|
-
return "object";
|
|
38
|
-
if (value === null)
|
|
39
|
-
return "null";
|
|
40
|
-
return "unknown";
|
|
41
|
-
}
|
|
42
|
-
function getDataTypes(component) {
|
|
43
|
-
var types = new Map();
|
|
44
|
-
var data = component.getData();
|
|
45
|
-
if (data && typeof data === "object") {
|
|
46
|
-
Object.keys(data).forEach(function (key) {
|
|
47
|
-
types.set(key, inferType(data[key]));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return types;
|
|
51
|
-
}
|
|
52
|
-
function validateBooleanCondition(directive, component) {
|
|
53
|
-
var dataTypes = getDataTypes(component);
|
|
54
|
-
var actualType = dataTypes.get(directive.expression);
|
|
55
|
-
if (actualType && actualType !== "boolean") {
|
|
56
|
-
return {
|
|
57
|
-
rule: "boolean-condition",
|
|
58
|
-
message: "Directive '".concat(directive.directive, "' expects boolean but '").concat(directive.expression, "' is ").concat(actualType),
|
|
59
|
-
line: directive.line,
|
|
60
|
-
column: directive.column
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
function validateArrayIteration(directive, component) {
|
|
66
|
-
var dataTypes = getDataTypes(component);
|
|
67
|
-
var actualType = dataTypes.get(directive.expression);
|
|
68
|
-
if (actualType && actualType !== "array") {
|
|
69
|
-
return {
|
|
70
|
-
rule: "array-iteration",
|
|
71
|
-
message: "Directive '".concat(directive.directive, "' expects array but '").concat(directive.expression, "' is ").concat(actualType),
|
|
72
|
-
line: directive.line,
|
|
73
|
-
column: directive.column
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
function validateModelElement(directive, component) {
|
|
79
|
-
if (MODEL_ELEMENT.indexOf(directive.element) === -1) {
|
|
80
|
-
return {
|
|
81
|
-
rule: "valid-model-element",
|
|
82
|
-
message: "Directive '@model' can only be used on INPUT, SELECT, or TEXTAREA, but found '".concat(directive.element, "'"),
|
|
83
|
-
line: directive.line,
|
|
84
|
-
column: directive.column
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
export function lintComponent(component) {
|
|
90
|
-
var errors = [];
|
|
91
|
-
var template = component.getTemplate();
|
|
92
|
-
var directives = parseTemplateForDirectives(template);
|
|
93
|
-
for (var _i = 0, directives_1 = directives; _i < directives_1.length; _i++) {
|
|
94
|
-
var directive = directives_1[_i];
|
|
95
|
-
if (BOOLEAN_CONDITION_DIRECTIVES.indexOf(directive.directive) !== -1) {
|
|
96
|
-
var error = validateBooleanCondition(directive, component);
|
|
97
|
-
if (error)
|
|
98
|
-
errors.push(error);
|
|
99
|
-
}
|
|
100
|
-
if (ARRAY_ITERATION_DIRECTIVES.indexOf(directive.directive) !== -1) {
|
|
101
|
-
var error = validateArrayIteration(directive, component);
|
|
102
|
-
if (error)
|
|
103
|
-
errors.push(error);
|
|
104
|
-
}
|
|
105
|
-
if (directive.directive === "@model") {
|
|
106
|
-
var error = validateModelElement(directive, component);
|
|
107
|
-
if (error)
|
|
108
|
-
errors.push(error);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return errors;
|
|
112
|
-
}
|
|
113
|
-
export function lintComponents(components) {
|
|
114
|
-
var allErrors = new Map();
|
|
115
|
-
for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
|
|
116
|
-
var component = components_1[_i];
|
|
117
|
-
var errors = lintComponent(component);
|
|
118
|
-
if (errors.length > 0) {
|
|
119
|
-
allErrors.set(component.getName(), errors);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return allErrors;
|
|
123
|
-
}
|
package/system/output/error.d.ts
DELETED
|
File without changes
|
package/system/output/error.js
DELETED