diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..7201fe2 --- /dev/null +++ b/.npmignore @@ -0,0 +1,7 @@ +.eslintrc.json +.gitignore +src/ +package-lock.json +tsconfig.json +tslint.json +rollup.config.js diff --git a/package-lock.json b/package-lock.json index 3964624..90db93a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trebor-tools", - "version": "0.0.2", + "version": "0.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 04fdf39..ae6fd13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "trebor-tools", - "version": "0.0.2", + "version": "0.0.3", "description": "", "main": "index.js", "scripts": { @@ -8,11 +8,21 @@ "build": "tsc -p . && rollup -c rollup.config.js" }, "keywords": [], - "author": "InDIOS", - "license": "MIT", "dependencies": {}, "devDependencies": { - "rollup": "^0.66.2", - "typescript": "^3.1.1" - } + "rollup": "^0.66.6", + "typescript": "^3.1.3" + }, + "author": "InDIOS", + "repository": { + "type": "git", + "url": "git+https://github.com/InDIOS/trebor-tools.git" + }, + "license": "MIT", + "contributors": [ + { + "email": "robert04siel@gmail.com", + "name": "Roberto Asiel Guevara CastaƱeda" + } + ] } diff --git a/src/baseComp.ts b/src/baseComp.ts index a9b1963..8aa38fd 100644 --- a/src/baseComp.ts +++ b/src/baseComp.ts @@ -1,8 +1,7 @@ import { _$List } from './list'; import { _$getValue } from './dom'; -import { _$each, _$define, PROP_MAP, TPS, _$assign, _$isType, _$isString, _$isFunction, _$hasProp, _$toType, _$directive, _$isArray, _$toPlainObject, _$accesor, _$subscribers, _$isValueAttr, _$toString, _$extends } from './utilities'; - -const PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; +import { PROPS, PROP_MAP, TPS } from './constants'; +import { _$each, _$define, _$assign, _$isType, _$isString, _$isFunction, _$hasProp, _$toType, _$directive, _$isArray, _$toPlainObject, _$accesor, _$subscribers, _$isValueAttr, _$toString, _$extends } from './utilities'; function _$BaseComponent(attrs: AttrParams, template: TemplateFn, options: ComponentOptions, parent: Component) { const self = this; diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..9529a7e --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,5 @@ +export const PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; + +export const PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' }; + +export const TPS: { options: ObjectLike, fn: PluginFn }[] = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); diff --git a/src/dom.ts b/src/dom.ts index 7ef71ef..76e7517 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -1,5 +1,6 @@ import { _$List } from './list'; -import { _$toString, _$isString, _$isType, _$isValueAttr, PROP_MAP, _$hasProp } from './utilities'; +import { PROP_MAP } from './constants'; +import { _$toString, _$isString, _$isType, _$isValueAttr, _$hasProp } from './utilities'; export function _$select(selector: string | Element, parent?: Element): HTMLElement { return _$isString(selector) ? (parent || document).querySelector(selector) : selector; diff --git a/src/list.ts b/src/list.ts index f717145..27889b8 100644 --- a/src/list.ts +++ b/src/list.ts @@ -1,4 +1,5 @@ -import { PROP_MAP, _$isType, _$isArray, _$define, _$assign, _$extends, _$dispatch } from './utilities'; +import { PROP_MAP } from './constants'; +import { _$isType, _$isArray, _$define, _$assign, _$extends, _$dispatch } from './utilities'; const array = Array[PROP_MAP.h]; export function _$toArgs(args: IArguments, start: number = 0): any[] { diff --git a/src/utilities.ts b/src/utilities.ts index b7a55dd..aa9ebe2 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -1,3 +1,4 @@ +import { PROP_MAP } from './constants'; import { _$toArgs, _$List } from './list'; import { _$el, _$getAttr, _$setAttr, _$select, _$assignEl, _$removeEl } from './dom'; @@ -8,16 +9,12 @@ function _$toLowerCase(str: string) { export function devlog(type: 'info' | 'warn' | 'error', ...msgs: any[]) { console[type](...msgs); } - -export const PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' }; -export const TPS: { options: ObjectLike, fn: PluginFn }[] = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); - export const _$assign = Object['assign'] || function (t: Object) { - for (let s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (const p in s) if (_$hasProp(s, p)) t[p] = s[p]; - } - return t; + for (let s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (const p in s) if (_$hasProp(s, p)) t[p] = s[p]; + } + return t; }; export function _$apply(callee: Function, args: any[], globs: any[], thisArg: any = null) { return callee.apply(thisArg, args.concat(globs)); @@ -252,7 +249,7 @@ export function _$componentUpdate(parent: Component, Ctor: ComponentConstructor, if (inst) { inst = _$addChild(parent, Ctor, attrs); inst.$create(); - inst.$mount(el, sibling); + inst.$mount(el || parent.$parentEl, sibling); } } return [inst, Ctor];