@helloiampau/components
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -1,21 +0,48 @@ | ||
class Element extends HTMLElement { | ||
"use strict"; | ||
constructor() { | ||
super(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
this._disposers = []; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
_onDispose(d) { | ||
this._disposers.push(d); | ||
} | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
disconnectedCallback() { | ||
this._disposers.forEach(function(d) { | ||
d(); | ||
}); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _CustomElement() { | ||
return Reflect.construct(HTMLElement, [], this.__proto__.constructor); | ||
} | ||
module.exports = Element; | ||
; | ||
Object.setPrototypeOf(_CustomElement.prototype, HTMLElement.prototype); | ||
Object.setPrototypeOf(_CustomElement, HTMLElement); | ||
var Element = function (_CustomElement2) { | ||
_inherits(Element, _CustomElement2); | ||
function Element() { | ||
_classCallCheck(this, Element); | ||
var _this = _possibleConstructorReturn(this, (Element.__proto__ || Object.getPrototypeOf(Element)).call(this)); | ||
_this._disposers = []; | ||
return _this; | ||
} | ||
_createClass(Element, [{ | ||
key: "_onDispose", | ||
value: function _onDispose(d) { | ||
this._disposers.push(d); | ||
} | ||
}, { | ||
key: "disconnectedCallback", | ||
value: function disconnectedCallback() { | ||
this._disposers.forEach(function (d) { | ||
d(); | ||
}); | ||
} | ||
}]); | ||
return Element; | ||
}(_CustomElement); | ||
module.exports = Element; |
@@ -1,9 +0,12 @@ | ||
const { patch } = require('incremental-dom'); | ||
'use strict'; | ||
module.exports = function(root, template) { | ||
return function() { | ||
patch(root, function() { | ||
var _require = require('incremental-dom'), | ||
patch = _require.patch; | ||
module.exports = function (root, template) { | ||
return function () { | ||
patch(root, function () { | ||
template(root); | ||
}); | ||
}; | ||
}; | ||
}; |
@@ -1,24 +0,26 @@ | ||
const _stores = {}; | ||
'use strict'; | ||
const factory = function() { | ||
const _actions = {}; | ||
var _stores = {}; | ||
let _data = {}; | ||
let _listeners = []; | ||
var factory = function factory() { | ||
var _actions = {}; | ||
const store = {}; | ||
var _data = {}; | ||
var _listeners = []; | ||
store.action = function(name, handler) { | ||
var store = {}; | ||
store.action = function (name, handler) { | ||
_actions[name] = handler; | ||
}; | ||
store.dispatch = function(name, payload) { | ||
if(typeof(_actions[name]) !== 'function') { | ||
store.dispatch = function (name, payload) { | ||
if (typeof _actions[name] !== 'function') { | ||
return; | ||
} | ||
const res = _actions[name](payload); | ||
var res = _actions[name](payload); | ||
return Promise.resolve(res).then(function(data) { | ||
if(data == null) { | ||
return Promise.resolve(res).then(function (data) { | ||
if (data == null) { | ||
return; | ||
@@ -29,3 +31,3 @@ } | ||
_listeners.forEach(function(l) { | ||
_listeners.forEach(function (l) { | ||
l(store.data()); | ||
@@ -36,7 +38,7 @@ }); | ||
store.subscribe = function(listener) { | ||
store.subscribe = function (listener) { | ||
_listeners.push(listener); | ||
return function() { | ||
_listeners = _listeners.filter(function(l) { | ||
return function () { | ||
_listeners = _listeners.filter(function (l) { | ||
return l !== listener; | ||
@@ -47,3 +49,3 @@ }); | ||
store.data = function() { | ||
store.data = function () { | ||
return Object.assign({}, _data); | ||
@@ -55,4 +57,4 @@ }; | ||
module.exports = function(name) { | ||
if(_stores[name] == null) { | ||
module.exports = function (name) { | ||
if (_stores[name] == null) { | ||
_stores[name] = factory(); | ||
@@ -62,2 +64,2 @@ } | ||
return _stores[name]; | ||
}; | ||
}; |
{ | ||
"name": "@helloiampau/components", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "My favourite js webapp framework based on web-components", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "eslint 'lib/**/*.js' 'test/**/*.test.js' && mocha", | ||
"precommit": "npm test", | ||
"preversion": "npm test", | ||
"version": "npm run build && npm add .", | ||
"test": "eslint 'src/**/*.js' 'test/**/*.test.js' && mocha", | ||
"build": "babel src -d lib", | ||
"develop": "nodemon --watch lib/ --watch test/ --exec npm test" | ||
@@ -21,4 +25,9 @@ }, | ||
"devDependencies": { | ||
"babel": "^6.23.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-plugin-transform-custom-element-classes": "^0.1.0", | ||
"babel-preset-env": "^1.7.0", | ||
"chai": "^4.1.2", | ||
"eslint": "^4.19.1", | ||
"husky": "^0.14.3", | ||
"mocha": "^5.2.0", | ||
@@ -25,0 +34,0 @@ "nodemon": "^1.17.5", |
@@ -1,1 +0,2 @@ | ||
# components | ||
# components | ||
[![Build Status](https://travis-ci.org/helloIAmPau/components.svg?branch=master)](https://travis-ci.org/helloIAmPau/components) |
@@ -12,3 +12,3 @@ const { expect } = require('chai'); | ||
mut = sm.require('../lib/element', { | ||
mut = sm.require('../src/element', { | ||
globals: { | ||
@@ -15,0 +15,0 @@ HTMLElement |
@@ -26,3 +26,3 @@ const chai = require('chai'); | ||
mut = sm.require('../lib/render', { | ||
mut = sm.require('../src/render', { | ||
requires: { | ||
@@ -29,0 +29,0 @@ 'incremental-dom': id |
@@ -9,3 +9,3 @@ const { expect } = require('chai'); | ||
beforeEach(function(done) { | ||
mut = sm.require('../lib/stores'); | ||
mut = sm.require('../src/stores'); | ||
@@ -12,0 +12,0 @@ done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10428
15
297
3
12