dom-render 1.0.25 → 1.0.29
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/DomRenderProxy.js +4 -3
- package/README.MD +5 -1
- package/RawSet.d.ts +0 -12
- package/RawSet.js +4 -32
- package/Shield.d.ts +3 -0
- package/Shield.js +9 -0
- package/dist/dom-render.js +13 -38
- package/events/EventManager.js +0 -3
- package/package.json +1 -1
package/DomRenderProxy.js
CHANGED
@@ -4,6 +4,7 @@ exports.DomRenderProxy = void 0;
|
|
4
4
|
var RawSet_1 = require("./RawSet");
|
5
5
|
var EventManager_1 = require("./events/EventManager");
|
6
6
|
var ScriptUtils_1 = require("./utils/script/ScriptUtils");
|
7
|
+
var Shield_1 = require("./Shield");
|
7
8
|
var DomRenderProxy = (function () {
|
8
9
|
function DomRenderProxy(_domRender_origin, target, config) {
|
9
10
|
this._domRender_origin = _domRender_origin;
|
@@ -33,7 +34,7 @@ var DomRenderProxy = (function () {
|
|
33
34
|
Object.keys(obj).forEach(function (it) {
|
34
35
|
var _a, _b, _c;
|
35
36
|
var target = obj[it];
|
36
|
-
if (target !== undefined && target !== null && typeof target === 'object' && !DomRenderProxy.isFinal(target) && !Object.isFrozen(target)) {
|
37
|
+
if (target !== undefined && target !== null && typeof target === 'object' && !DomRenderProxy.isFinal(target) && !Object.isFrozen(target) && !(obj instanceof Shield_1.Shield)) {
|
37
38
|
var filter = (_c = (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeTyps) === null || _b === void 0 ? void 0 : _b.filter(function (it) { return target instanceof it; })) !== null && _c !== void 0 ? _c : [];
|
38
39
|
if (filter.length === 0) {
|
39
40
|
var proxyAfter = _this.proxy(objProxy, target, it);
|
@@ -150,14 +151,14 @@ var DomRenderProxy = (function () {
|
|
150
151
|
return p === '_DomRender_isProxy' || p in target;
|
151
152
|
};
|
152
153
|
DomRenderProxy.prototype.proxy = function (parentProxy, obj, p) {
|
153
|
-
if (obj !== undefined && obj !== null && typeof obj === 'object' && !('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj)) {
|
154
|
+
if (obj !== undefined && obj !== null && typeof obj === 'object' && !('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield_1.Shield)) {
|
154
155
|
var domRender = new DomRenderProxy(obj, undefined, this.config);
|
155
156
|
domRender.addRef(parentProxy, p);
|
156
157
|
var proxy = new Proxy(obj, domRender);
|
157
158
|
domRender.run(proxy);
|
158
159
|
return proxy;
|
159
160
|
}
|
160
|
-
if (obj !== undefined && obj !== null && typeof obj === 'object' && ('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj)) {
|
161
|
+
if (obj !== undefined && obj !== null && typeof obj === 'object' && ('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield_1.Shield)) {
|
161
162
|
var d = obj._DomRender_proxy;
|
162
163
|
d.addRef(this._domRender_proxy, p);
|
163
164
|
return obj;
|
package/README.MD
CHANGED
package/RawSet.d.ts
CHANGED
@@ -29,18 +29,6 @@ export declare class RawSet {
|
|
29
29
|
childAllRemove(): void;
|
30
30
|
static drItOtherEncoding(element: Element | DocumentFragment): string;
|
31
31
|
static drItOtherDecoding(element: Element | DocumentFragment, random: string): void;
|
32
|
-
static drDVarEncoding(element: Element, drVarOption: string): {
|
33
|
-
name: string;
|
34
|
-
value: string;
|
35
|
-
regex: RegExp;
|
36
|
-
random: string;
|
37
|
-
}[];
|
38
|
-
static drDVarDecoding(element: Element, vars: {
|
39
|
-
name: string;
|
40
|
-
value: string;
|
41
|
-
regex: RegExp;
|
42
|
-
random: string;
|
43
|
-
}[]): void;
|
44
32
|
static drThisEncoding(element: Element, drThis: string): string;
|
45
33
|
static drThisDecoding(element: Element, thisRandom: string): void;
|
46
34
|
static drVarEncoding(element: Element, drVarOption: string): {
|
package/RawSet.js
CHANGED
@@ -266,47 +266,19 @@ var RawSet = (function () {
|
|
266
266
|
RawSet.drItOtherEncoding = function (element) {
|
267
267
|
var random = RandomUtils_1.RandomUtils.uuid();
|
268
268
|
var regex = /#it#/g;
|
269
|
-
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "]").forEach(function (it) {
|
269
|
+
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
|
270
270
|
it.innerHTML = it.innerHTML.replace(regex, random);
|
271
271
|
});
|
272
272
|
return random;
|
273
273
|
};
|
274
274
|
RawSet.drItOtherDecoding = function (element, random) {
|
275
|
-
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "]").forEach(function (it) {
|
275
|
+
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
|
276
276
|
it.innerHTML = it.innerHTML.replace(RegExp(random, 'g'), '#it#');
|
277
277
|
});
|
278
278
|
};
|
279
|
-
RawSet.drDVarEncoding = function (element, drVarOption) {
|
280
|
-
var _a;
|
281
|
-
var vars = ((_a = drVarOption === null || drVarOption === void 0 ? void 0 : drVarOption.split(',')) !== null && _a !== void 0 ? _a : []).map(function (it) {
|
282
|
-
var s = it.trim().split('=');
|
283
|
-
return {
|
284
|
-
name: s[0],
|
285
|
-
value: s[1],
|
286
|
-
regex: RegExp('(?<!(dr-|\\.))var\\.' + s[0] + '(?=.?)', 'g'),
|
287
|
-
random: RandomUtils_1.RandomUtils.uuid()
|
288
|
-
};
|
289
|
-
});
|
290
|
-
element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
|
291
|
-
vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
|
292
|
-
it.innerHTML = it.innerHTML.replace(vit.regex, vit.random);
|
293
|
-
});
|
294
|
-
});
|
295
|
-
vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
|
296
|
-
element.innerHTML = element.innerHTML.replace(vit.regex, vit.value);
|
297
|
-
});
|
298
|
-
return vars;
|
299
|
-
};
|
300
|
-
RawSet.drDVarDecoding = function (element, vars) {
|
301
|
-
element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
|
302
|
-
vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
|
303
|
-
it.innerHTML = it.innerHTML.replace(RegExp(vit.random, 'g'), vit.value);
|
304
|
-
});
|
305
|
-
});
|
306
|
-
};
|
307
279
|
RawSet.drThisEncoding = function (element, drThis) {
|
308
280
|
var thisRandom = RandomUtils_1.RandomUtils.uuid();
|
309
|
-
var thisRegex = /(
|
281
|
+
var thisRegex = /[^(dr\-)]this(?=.?)/g;
|
310
282
|
element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
|
311
283
|
it.innerHTML = it.innerHTML.replace(thisRegex, thisRandom);
|
312
284
|
});
|
@@ -325,7 +297,7 @@ var RawSet = (function () {
|
|
325
297
|
return {
|
326
298
|
name: s[0],
|
327
299
|
value: s[1],
|
328
|
-
regex: RegExp('
|
300
|
+
regex: RegExp('var\\.' + s[0] + '(?=.?)', 'g'),
|
329
301
|
random: RandomUtils_1.RandomUtils.uuid()
|
330
302
|
};
|
331
303
|
});
|
package/Shield.d.ts
ADDED
package/Shield.js
ADDED
package/dist/dom-render.js
CHANGED
@@ -242,7 +242,6 @@ var eventManager = new (function () {
|
|
242
242
|
};
|
243
243
|
class_1.prototype.applyEvent = function (obj, childNodes, config) {
|
244
244
|
var _this = this;
|
245
|
-
console.log('eventManager applyEvent==>', obj, childNodes, config);
|
246
245
|
this.eventNames.forEach(function (it) {
|
247
246
|
_this.addDrEvent(obj, it, childNodes);
|
248
247
|
});
|
@@ -257,7 +256,6 @@ var eventManager = new (function () {
|
|
257
256
|
});
|
258
257
|
this.procAttr(childNodes, this.attrPrefix + 'window-event-popstate', function (it, attribute) {
|
259
258
|
it.obj = obj;
|
260
|
-
console.log('-->', it, it.obj);
|
261
259
|
});
|
262
260
|
this.procAttr(childNodes, this.attrPrefix + 'on-init', function (it, varName) {
|
263
261
|
if (varName) {
|
@@ -365,7 +363,6 @@ var eventManager = new (function () {
|
|
365
363
|
class_1.prototype.addDrEvent = function (obj, eventName, elements) {
|
366
364
|
var attr = this.attrPrefix + 'event-' + eventName;
|
367
365
|
this.procAttr(elements, attr, function (it, attribute) {
|
368
|
-
console.log('-------?', elements, it);
|
369
366
|
var script = attribute;
|
370
367
|
it.addEventListener(eventName, function (event) {
|
371
368
|
var _a;
|
@@ -683,47 +680,19 @@ var RawSet = (function () {
|
|
683
680
|
RawSet.drItOtherEncoding = function (element) {
|
684
681
|
var random = RandomUtils.uuid();
|
685
682
|
var regex = /#it#/g;
|
686
|
-
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "]").forEach(function (it) {
|
683
|
+
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
|
687
684
|
it.innerHTML = it.innerHTML.replace(regex, random);
|
688
685
|
});
|
689
686
|
return random;
|
690
687
|
};
|
691
688
|
RawSet.drItOtherDecoding = function (element, random) {
|
692
|
-
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "]").forEach(function (it) {
|
689
|
+
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
|
693
690
|
it.innerHTML = it.innerHTML.replace(RegExp(random, 'g'), '#it#');
|
694
691
|
});
|
695
692
|
};
|
696
|
-
RawSet.drDVarEncoding = function (element, drVarOption) {
|
697
|
-
var _a;
|
698
|
-
var vars = ((_a = drVarOption === null || drVarOption === void 0 ? void 0 : drVarOption.split(',')) !== null && _a !== void 0 ? _a : []).map(function (it) {
|
699
|
-
var s = it.trim().split('=');
|
700
|
-
return {
|
701
|
-
name: s[0],
|
702
|
-
value: s[1],
|
703
|
-
regex: RegExp('(?<!(dr-|\\.))var\\.' + s[0] + '(?=.?)', 'g'),
|
704
|
-
random: RandomUtils.uuid()
|
705
|
-
};
|
706
|
-
});
|
707
|
-
element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
|
708
|
-
vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
|
709
|
-
it.innerHTML = it.innerHTML.replace(vit.regex, vit.random);
|
710
|
-
});
|
711
|
-
});
|
712
|
-
vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
|
713
|
-
element.innerHTML = element.innerHTML.replace(vit.regex, vit.value);
|
714
|
-
});
|
715
|
-
return vars;
|
716
|
-
};
|
717
|
-
RawSet.drDVarDecoding = function (element, vars) {
|
718
|
-
element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
|
719
|
-
vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
|
720
|
-
it.innerHTML = it.innerHTML.replace(RegExp(vit.random, 'g'), vit.value);
|
721
|
-
});
|
722
|
-
});
|
723
|
-
};
|
724
693
|
RawSet.drThisEncoding = function (element, drThis) {
|
725
694
|
var thisRandom = RandomUtils.uuid();
|
726
|
-
var thisRegex = /(
|
695
|
+
var thisRegex = /[^(dr\-)]this(?=.?)/g;
|
727
696
|
element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
|
728
697
|
it.innerHTML = it.innerHTML.replace(thisRegex, thisRandom);
|
729
698
|
});
|
@@ -742,7 +711,7 @@ var RawSet = (function () {
|
|
742
711
|
return {
|
743
712
|
name: s[0],
|
744
713
|
value: s[1],
|
745
|
-
regex: RegExp('
|
714
|
+
regex: RegExp('var\\.' + s[0] + '(?=.?)', 'g'),
|
746
715
|
random: RandomUtils.uuid()
|
747
716
|
};
|
748
717
|
});
|
@@ -791,6 +760,12 @@ var RawSet = (function () {
|
|
791
760
|
return RawSet;
|
792
761
|
}());
|
793
762
|
|
763
|
+
var Shield = (function () {
|
764
|
+
function Shield() {
|
765
|
+
}
|
766
|
+
return Shield;
|
767
|
+
}());
|
768
|
+
|
794
769
|
var DomRenderProxy = (function () {
|
795
770
|
function DomRenderProxy(_domRender_origin, target, config) {
|
796
771
|
this._domRender_origin = _domRender_origin;
|
@@ -820,7 +795,7 @@ var DomRenderProxy = (function () {
|
|
820
795
|
Object.keys(obj).forEach(function (it) {
|
821
796
|
var _a, _b, _c;
|
822
797
|
var target = obj[it];
|
823
|
-
if (target !== undefined && target !== null && typeof target === 'object' && !DomRenderProxy.isFinal(target) && !Object.isFrozen(target)) {
|
798
|
+
if (target !== undefined && target !== null && typeof target === 'object' && !DomRenderProxy.isFinal(target) && !Object.isFrozen(target) && !(obj instanceof Shield)) {
|
824
799
|
var filter = (_c = (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeTyps) === null || _b === void 0 ? void 0 : _b.filter(function (it) { return target instanceof it; })) !== null && _c !== void 0 ? _c : [];
|
825
800
|
if (filter.length === 0) {
|
826
801
|
var proxyAfter = _this.proxy(objProxy, target, it);
|
@@ -937,14 +912,14 @@ var DomRenderProxy = (function () {
|
|
937
912
|
return p === '_DomRender_isProxy' || p in target;
|
938
913
|
};
|
939
914
|
DomRenderProxy.prototype.proxy = function (parentProxy, obj, p) {
|
940
|
-
if (obj !== undefined && obj !== null && typeof obj === 'object' && !('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj)) {
|
915
|
+
if (obj !== undefined && obj !== null && typeof obj === 'object' && !('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
|
941
916
|
var domRender = new DomRenderProxy(obj, undefined, this.config);
|
942
917
|
domRender.addRef(parentProxy, p);
|
943
918
|
var proxy = new Proxy(obj, domRender);
|
944
919
|
domRender.run(proxy);
|
945
920
|
return proxy;
|
946
921
|
}
|
947
|
-
if (obj !== undefined && obj !== null && typeof obj === 'object' && ('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj)) {
|
922
|
+
if (obj !== undefined && obj !== null && typeof obj === 'object' && ('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
|
948
923
|
var d = obj._DomRender_proxy;
|
949
924
|
d.addRef(this._domRender_proxy, p);
|
950
925
|
return obj;
|
package/events/EventManager.js
CHANGED
@@ -42,7 +42,6 @@ exports.eventManager = new (function () {
|
|
42
42
|
};
|
43
43
|
class_1.prototype.applyEvent = function (obj, childNodes, config) {
|
44
44
|
var _this = this;
|
45
|
-
console.log('eventManager applyEvent==>', obj, childNodes, config);
|
46
45
|
this.eventNames.forEach(function (it) {
|
47
46
|
_this.addDrEvent(obj, it, childNodes);
|
48
47
|
});
|
@@ -57,7 +56,6 @@ exports.eventManager = new (function () {
|
|
57
56
|
});
|
58
57
|
this.procAttr(childNodes, this.attrPrefix + 'window-event-popstate', function (it, attribute) {
|
59
58
|
it.obj = obj;
|
60
|
-
console.log('-->', it, it.obj);
|
61
59
|
});
|
62
60
|
this.procAttr(childNodes, this.attrPrefix + 'on-init', function (it, varName) {
|
63
61
|
if (varName) {
|
@@ -165,7 +163,6 @@ exports.eventManager = new (function () {
|
|
165
163
|
class_1.prototype.addDrEvent = function (obj, eventName, elements) {
|
166
164
|
var attr = this.attrPrefix + 'event-' + eventName;
|
167
165
|
this.procAttr(elements, attr, function (it, attribute) {
|
168
|
-
console.log('-------?', elements, it);
|
169
166
|
var script = attribute;
|
170
167
|
it.addEventListener(eventName, function (event) {
|
171
168
|
var _a;
|