New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dom-render

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-render - npm Package Compare versions

Comparing version

to
1.0.63

23

dist/events/EventManager.d.ts
import { Config } from '../Config';
export declare const eventManager: {
readonly attrPrefix: "dr-";
export declare class EventManager {
readonly attrPrefix = "dr-";
readonly eventNames: string[];
readonly eventParam: string;
readonly attrNames: string[];
findAttrElements(fragment: DocumentFragment | Element, config?: Config | undefined): Set<Element>;
applyEvent(obj: any, childNodes: Set<ChildNode> | Set<Element>, config?: Config | undefined): void;
changeVar(obj: any, elements: Set<Element> | Set<ChildNode>, varName?: string | undefined): void;
static readonly SCRIPTS_VARNAME = "$scripts";
static readonly FAG_VARNAME = "$fag";
static readonly RAWSET_VARNAME = "$rawset";
static readonly RANGE_VARNAME = "$range";
static readonly ELEMENT_VARNAME = "$element";
static readonly TARGET_VARNAME = "$target";
static readonly VARNAMES: string[];
constructor();
findAttrElements(fragment: DocumentFragment | Element, config?: Config): Set<Element>;
applyEvent(obj: any, childNodes: Set<ChildNode> | Set<Element>, config?: Config): void;
changeVar(obj: any, elements: Set<Element> | Set<ChildNode>, varName?: string): void;
addDrEvents(obj: any, eventName: string, elements: Set<Element> | Set<ChildNode>): void;
addDrEventPram(obj: any, attr: string, elements: Set<ChildNode> | Set<Element>): void;
procAttr<T extends Element = Element>(elements: Set<Element> | Set<ChildNode> | undefined, attrName: string, callBack: (h: T, value: string, attributes: any) => void): void;
getValue<T_1 = any>(obj: any, name: string, value?: any): T_1;
getValue<T = any>(obj: any, name: string, value?: any): T;
setValue(obj: any, name: string, value?: any): void;
isUsingThisVar(raws: string | null | undefined, varName: string | null | undefined): boolean;
};
}
export declare const eventManager: EventManager;

@@ -28,9 +28,2 @@ import { Config, TargetElement } from './Config';

static readonly DR_ATTRIBUTES: string[];
static readonly SCRIPTS_VARNAME = "$scripts";
static readonly FAG_VARNAME = "$fag";
static readonly RAWSET_VARNAME = "$rawset";
static readonly RANGE_VARNAME = "$range";
static readonly ELEMENT_VARNAME = "$element";
static readonly TARGET_VARNAME = "$target";
static readonly VARNAMES: string[];
constructor(uuid: string, point: {

@@ -37,0 +30,0 @@ start: Comment;

@@ -21,2 +21,3 @@ export declare type Valid<T = any, E = Element> = (value?: T, target?: E, event?: Event) => boolean;

setTarget(target: E | undefined): this;
private domRenderFinal;
get value(): T | undefined;

@@ -23,0 +24,0 @@ set value(value: T | undefined);

import { Config } from '../Config';
export declare const eventManager: {
readonly attrPrefix: "dr-";
export declare class EventManager {
readonly attrPrefix = "dr-";
readonly eventNames: string[];
readonly eventParam: string;
readonly attrNames: string[];
findAttrElements(fragment: DocumentFragment | Element, config?: Config | undefined): Set<Element>;
applyEvent(obj: any, childNodes: Set<ChildNode> | Set<Element>, config?: Config | undefined): void;
changeVar(obj: any, elements: Set<Element> | Set<ChildNode>, varName?: string | undefined): void;
static readonly SCRIPTS_VARNAME = "$scripts";
static readonly FAG_VARNAME = "$fag";
static readonly RAWSET_VARNAME = "$rawset";
static readonly RANGE_VARNAME = "$range";
static readonly ELEMENT_VARNAME = "$element";
static readonly TARGET_VARNAME = "$target";
static readonly VARNAMES: string[];
constructor();
findAttrElements(fragment: DocumentFragment | Element, config?: Config): Set<Element>;
applyEvent(obj: any, childNodes: Set<ChildNode> | Set<Element>, config?: Config): void;
changeVar(obj: any, elements: Set<Element> | Set<ChildNode>, varName?: string): void;
addDrEvents(obj: any, eventName: string, elements: Set<Element> | Set<ChildNode>): void;
addDrEventPram(obj: any, attr: string, elements: Set<ChildNode> | Set<Element>): void;
procAttr<T extends Element = Element>(elements: Set<Element> | Set<ChildNode> | undefined, attrName: string, callBack: (h: T, value: string, attributes: any) => void): void;
getValue<T_1 = any>(obj: any, name: string, value?: any): T_1;
getValue<T = any>(obj: any, name: string, value?: any): T;
setValue(obj: any, name: string, value?: any): void;
isUsingThisVar(raws: string | null | undefined, varName: string | null | undefined): boolean;
};
}
export declare const eventManager: EventManager;

@@ -30,5 +30,4 @@ var __read = (this && this.__read) || function (o, n) {

import { DomUtils } from '../utils/dom/DomUtils';
import { RawSet } from '../RawSet';
export var eventManager = new (function () {
function class_1() {
var EventManager = (function () {
function EventManager() {
var _this = this;

@@ -68,3 +67,3 @@ this.attrPrefix = 'dr-';

}
class_1.prototype.findAttrElements = function (fragment, config) {
EventManager.prototype.findAttrElements = function (fragment, config) {
var _a, _b;

@@ -80,3 +79,3 @@ var elements = new Set();

};
class_1.prototype.applyEvent = function (obj, childNodes, config) {
EventManager.prototype.applyEvent = function (obj, childNodes, config) {
var _this = this;

@@ -140,3 +139,3 @@ this.eventNames.forEach(function (it) {

};
class_1.prototype.changeVar = function (obj, elements, varName) {
EventManager.prototype.changeVar = function (obj, elements, varName) {
var _this = this;

@@ -296,3 +295,3 @@ this.procAttr(elements, this.attrPrefix + 'value-link', function (it, attribute) {

};
class_1.prototype.addDrEvents = function (obj, eventName, elements) {
EventManager.prototype.addDrEvents = function (obj, eventName, elements) {
var attr = this.attrPrefix + 'event-' + eventName;

@@ -310,3 +309,3 @@ this.procAttr(elements, attr, function (it, attribute) {

};
class_1.prototype.addDrEventPram = function (obj, attr, elements) {
EventManager.prototype.addDrEventPram = function (obj, attr, elements) {
this.procAttr(elements, attr, function (it, attribute, attributes) {

@@ -338,3 +337,3 @@ var bind = attributes[attr + ':bind'];

};
class_1.prototype.procAttr = function (elements, attrName, callBack) {
EventManager.prototype.procAttr = function (elements, attrName, callBack) {
if (elements === void 0) { elements = new Set(); }

@@ -362,3 +361,3 @@ var sets = new Set();

};
class_1.prototype.getValue = function (obj, name, value) {
EventManager.prototype.getValue = function (obj, name, value) {
var r = ScriptUtils.evalReturn(name, obj);

@@ -370,3 +369,3 @@ if (typeof r === 'function') {

};
class_1.prototype.setValue = function (obj, name, value) {
EventManager.prototype.setValue = function (obj, name, value) {
ScriptUtils.eval("this." + name + " = this.value", {

@@ -377,3 +376,3 @@ this: obj,

};
class_1.prototype.isUsingThisVar = function (raws, varName) {
EventManager.prototype.isUsingThisVar = function (raws, varName) {
if (varName && raws) {

@@ -383,3 +382,3 @@ if (varName.startsWith('this.')) {

}
RawSet.VARNAMES.forEach(function (it) {
EventManager.VARNAMES.forEach(function (it) {
raws = raws.replace(RegExp(it.replace('$', '\\$'), 'g'), "this?.___" + it);

@@ -392,3 +391,12 @@ });

};
return class_1;
}())();
EventManager.SCRIPTS_VARNAME = '$scripts';
EventManager.FAG_VARNAME = '$fag';
EventManager.RAWSET_VARNAME = '$rawset';
EventManager.RANGE_VARNAME = '$range';
EventManager.ELEMENT_VARNAME = '$element';
EventManager.TARGET_VARNAME = '$target';
EventManager.VARNAMES = [EventManager.SCRIPTS_VARNAME, EventManager.FAG_VARNAME, EventManager.RAWSET_VARNAME, EventManager.RANGE_VARNAME, EventManager.ELEMENT_VARNAME, EventManager.TARGET_VARNAME];
return EventManager;
}());
export { EventManager };
export var eventManager = new EventManager();
{
"name": "dom-render",
"version": "1.0.62",
"version": "1.0.63",
"main": "DomRender.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -28,9 +28,2 @@ import { Config, TargetElement } from './Config';

static readonly DR_ATTRIBUTES: string[];
static readonly SCRIPTS_VARNAME = "$scripts";
static readonly FAG_VARNAME = "$fag";
static readonly RAWSET_VARNAME = "$rawset";
static readonly RANGE_VARNAME = "$range";
static readonly ELEMENT_VARNAME = "$element";
static readonly TARGET_VARNAME = "$target";
static readonly VARNAMES: string[];
constructor(uuid: string, point: {

@@ -37,0 +30,0 @@ start: Comment;

@@ -51,3 +51,3 @@ var __assign = (this && this.__assign) || function () {

import { ScriptUtils } from './utils/script/ScriptUtils';
import { eventManager } from './events/EventManager';
import { EventManager, eventManager } from './events/EventManager';
import { Range } from './iterators/Range';

@@ -85,6 +85,6 @@ import { Validator } from './validators/Validator';

if (script) {
RawSet.VARNAMES.forEach(function (it) {
EventManager.VARNAMES.forEach(function (it) {
script = script.replace(RegExp(it.replace('$', '\\$'), 'g'), "this?.___" + it);
});
Array.from(ScriptUtils.getVariablePaths(script)).filter(function (it) { return !it.startsWith("___" + RawSet.SCRIPTS_VARNAME) && !it.startsWith("___" + RawSet.SCRIPTS_VARNAME); }).forEach(function (it) { return usingTriggerVariables.add(it); });
Array.from(ScriptUtils.getVariablePaths(script)).filter(function (it) { return !it.startsWith("___" + EventManager.SCRIPTS_VARNAME) && !it.startsWith("___" + EventManager.SCRIPTS_VARNAME); }).forEach(function (it) { return usingTriggerVariables.add(it); });
}

@@ -108,3 +108,3 @@ });

element: cNode,
bindScript: "\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n const " + RawSet.ELEMENT_VARNAME + " = this.__render.element;\n const " + RawSet.RANGE_VARNAME + " = this.__render.range;\n "
bindScript: "\n const " + EventManager.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + EventManager.RAWSET_VARNAME + " = this.__render.rawset;\n const " + EventManager.ELEMENT_VARNAME + " = this.__render.element;\n const " + EventManager.RANGE_VARNAME + " = this.__render.range;\n "
});

@@ -291,3 +291,3 @@ var fag = document.createDocumentFragment();

var newTemp = document.createElement('temp');
ScriptUtils.eval("\n " + __render.bindScript + "\n " + ((_0 = drAttr_1.drBeforeOption) !== null && _0 !== void 0 ? _0 : '') + "\n var i = 0; \n const repeat = " + drAttr_1.drRepeat + ";\n const repeatStr = `" + drAttr_1.drRepeat + "`;\n let range = repeat;\n if (typeof repeat === 'number') {\n range = " + RawSet.RANGE_VARNAME + "(repeat);\n } \n for(const it of range) {\n var destIt = it;\n if (range.isRange) {\n destIt = it;\n } else {\n destIt = repeatStr + '[' + i +']'\n }\n const n = this.__render.element.cloneNode(true);\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n i++;\n }\n " + ((_1 = drAttr_1.drAfterOption) !== null && _1 !== void 0 ? _1 : '') + "\n ", Object.assign(obj, {
ScriptUtils.eval("\n " + __render.bindScript + "\n " + ((_0 = drAttr_1.drBeforeOption) !== null && _0 !== void 0 ? _0 : '') + "\n var i = 0; \n const repeat = " + drAttr_1.drRepeat + ";\n const repeatStr = `" + drAttr_1.drRepeat + "`;\n let range = repeat;\n if (typeof repeat === 'number') {\n range = " + EventManager.RANGE_VARNAME + "(repeat);\n } \n for(const it of range) {\n var destIt = it;\n if (range.isRange) {\n destIt = it;\n } else {\n destIt = repeatStr + '[' + i +']'\n }\n const n = this.__render.element.cloneNode(true);\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n i++;\n }\n " + ((_1 = drAttr_1.drAfterOption) !== null && _1 !== void 0 ? _1 : '') + "\n ", Object.assign(obj, {
__render: Object.freeze(__assign({ fag: newTemp, drStripOption: drAttr_1.drStripOption }, __render))

@@ -352,3 +352,3 @@ }));

if (it.drCompleteOption) {
ScriptUtils.eval("\n const " + RawSet.FAG_VARNAME + " = this.__render.fag;\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n " + it.drCompleteOption + "\n ", Object.assign(obj, {
ScriptUtils.eval("\n const " + EventManager.FAG_VARNAME + " = this.__render.fag;\n const " + EventManager.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + EventManager.RAWSET_VARNAME + " = this.__render.rawset;\n " + it.drCompleteOption + "\n ", Object.assign(obj, {
__render: Object.freeze({

@@ -664,11 +664,4 @@ rawset: _this,

RawSet.DR_ATTRIBUTES = [RawSet.DR, RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR_FORM_NAME, RawSet.DR_PRE_NAME, RawSet.DR_INNERHTML_NAME, RawSet.DR_INNERTEXT_NAME, RawSet.DR_REPEAT_NAME];
RawSet.SCRIPTS_VARNAME = '$scripts';
RawSet.FAG_VARNAME = '$fag';
RawSet.RAWSET_VARNAME = '$rawset';
RawSet.RANGE_VARNAME = '$range';
RawSet.ELEMENT_VARNAME = '$element';
RawSet.TARGET_VARNAME = '$target';
RawSet.VARNAMES = [RawSet.SCRIPTS_VARNAME, RawSet.FAG_VARNAME, RawSet.RAWSET_VARNAME, RawSet.RANGE_VARNAME, RawSet.ELEMENT_VARNAME, RawSet.TARGET_VARNAME];
return RawSet;
}());
export { RawSet };

@@ -9,2 +9,5 @@ ![Single Page Application Framworks](assets/banner.png)

# [📄 introduction page [link]](https://simple-boot-front.github.io/#dom-render/introduction)
- [https://simple-boot-front.github.io/#dom-render/introduction](https://simple-boot-front.github.io/#dom-render/introduction)
# 🚀 Quick start

@@ -31,5 +34,5 @@ ```shell

```html
<div>${this.name}</div>
<div>${this.office.addr.first}, ${this.office.addr.last}, ${this.office.addr.street} (${this.office.name})</div>
<div dr="this.office.addr.street">${this.getOfficeFullAddr()}</div>
<div>${this.name}$</div>
<div>${this.office.addr.first}$, ${this.office.addr.last}$, ${this.office.addr.street}$ (${this.office.name}$)</div>
<div dr="this.office.addr.street">${this.getOfficeFullAddr()}$</div>
```

@@ -44,8 +47,8 @@ ## dr-if

<div dr-for="var i = 0; i < this.friends.length; i++"> friend</div>
<div dr-for-of="this.friends"> ${#it#.name}</div>
<div dr-for-of="$range(10, 20)"><div>${#it#}</div><div>
<div dr-for-of="this.friends"> ${#it#.name}$</div>
<div dr-for-of="$range(10, 20)"><div>${#it#}$</div><div>
<div dr-for="var i = 1 ; i <= 9 ; i++" dr-it="i">
${#it#} *
${#it#}$ *
<scope dr-for="var y = 1 ; y <= 9 ; y++" dr-it="y" dr-var="superIt=#it#" dr-strip="true">
#it# = ${var.superIt * #it#}
#it# = ${var.superIt * #it#}$
</scope>

@@ -156,3 +159,3 @@ </div>

<select dr-value-link="this.currentContry" dr-event-change="this.contryChange($event)">
<option dr-for-of="this.languages" dr-value="#it#.key" dr-complete="this.currentContry='defaultValue'">${#it#.title}</option>
<option dr-for-of="this.languages" dr-value="#it#.key" dr-complete="this.currentContry='defaultValue'">${#it#.title}$</option>
</select>

@@ -159,0 +162,0 @@ ```

@@ -21,2 +21,3 @@ export declare type Valid<T = any, E = Element> = (value?: T, target?: E, event?: Event) => boolean;

setTarget(target: E | undefined): this;
private domRenderFinal;
get value(): T | undefined;

@@ -23,0 +24,0 @@ set value(value: T | undefined);

@@ -17,3 +17,2 @@ var __read = (this && this.__read) || function (o, n) {

};
import { DomRenderProxy } from '../DomRenderProxy';
var Validator = (function () {

@@ -55,3 +54,3 @@ function Validator(_value, target, event, autoValid, autoValidAction) {

if (event) {
this._event = DomRenderProxy.final(event);
this._event = this.domRenderFinal(event);
}

@@ -65,6 +64,10 @@ return this;

if (target) {
this._target = DomRenderProxy.final(target);
this._target = this.domRenderFinal(target);
}
return this;
};
Validator.prototype.domRenderFinal = function (obj) {
obj._DomRender_isFinal = true;
return obj;
};
Object.defineProperty(Validator.prototype, "value", {

@@ -71,0 +74,0 @@ get: function () {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet