Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

skatejs

Package Overview
Dependencies
Maintainers
8
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skatejs - npm Package Compare versions

Comparing version 5.0.0-alpha.12 to 5.0.0-alpha.13

node/define.js

8

esnext/define.js

@@ -0,4 +1,8 @@

'use strict';
export function define(Ctor) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.define = define;
function define(Ctor) {
const registry = customElements;

@@ -5,0 +9,0 @@ const is = Ctor.is;

@@ -0,3 +1,12 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.emit = emit;
const defs = {

@@ -9,3 +18,3 @@ bubbles: true,

export function emit(elem, name, opts) {
function emit(elem, name, opts) {
opts = _extends({}, defs, opts);

@@ -12,0 +21,0 @@ let e;

@@ -1,7 +0,89 @@

export * from './define.js';
export * from './emit.js';
export * from './link.js';
export * from './with-component.js';
export * from './with-props.js';
export * from './with-render.js';
export * from './with-unique.js';
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _define = require('./define.js');
Object.keys(_define).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _define[key];
}
});
});
var _emit = require('./emit.js');
Object.keys(_emit).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _emit[key];
}
});
});
var _link = require('./link.js');
Object.keys(_link).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _link[key];
}
});
});
var _withComponent = require('./with-component.js');
Object.keys(_withComponent).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _withComponent[key];
}
});
});
var _withProps = require('./with-props.js');
Object.keys(_withProps).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _withProps[key];
}
});
});
var _withRender = require('./with-render.js');
Object.keys(_withRender).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _withRender[key];
}
});
});
var _withUnique = require('./with-unique.js');
Object.keys(_withUnique).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _withUnique[key];
}
});
});

@@ -0,3 +1,9 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.link = link;
function getValue(elem) {

@@ -11,3 +17,3 @@ const { checked, type, value } = elem;

export function link(elem, target) {
function link(elem, target) {
return e => {

@@ -14,0 +20,0 @@ // TODO revisit once all browsers have native support.

@@ -0,1 +1,11 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.dashCase = dashCase;
exports.debounce = debounce;
exports.keys = keys;
exports.sym = sym;
exports.uniqueId = uniqueId;
const Mo = typeof MutationObserver === 'function' ? MutationObserver : class {

@@ -20,3 +30,3 @@ constructor(func) {

export function dashCase(str) {
function dashCase(str) {
return str.split(/([_A-Z])/).reduce((one, two, idx) => {

@@ -29,3 +39,3 @@ const dash = !one || idx % 2 === 0 ? '' : '-';

export function debounce(cbFunc) {
function debounce(cbFunc) {
let scheduled = false;

@@ -50,5 +60,5 @@ let i = 0;

export const empty = val => val == null;
const empty = exports.empty = val => val == null;
export function keys(obj) {
function keys(obj) {
obj = obj || {};

@@ -59,7 +69,7 @@ const names = Object.getOwnPropertyNames(obj);

export function sym(description) {
function sym(description) {
return typeof Symbol === 'function' ? Symbol(description ? String(description) : undefined) : uniqueId(description);
}
export function uniqueId(description) {
function uniqueId(description) {
return (description ? String(description) : '') + 'xxxxxxxx'.replace(/[xy]/g, c => {

@@ -66,0 +76,0 @@ const r = Math.random() * 16 | 0;

@@ -0,6 +1,17 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import { dashCase } from './index.js';
exports.normaliseAttributeDefinition = normaliseAttributeDefinition;
exports.normalisePropertyDefinition = normalisePropertyDefinition;
exports.syncAttributeToProperty = syncAttributeToProperty;
exports.syncPropertyToAttribute = syncPropertyToAttribute;
export function normaliseAttributeDefinition(name, prop) {
var _index = require('./index.js');
function normaliseAttributeDefinition(name, prop) {
const { attribute } = prop;

@@ -12,6 +23,6 @@ const obj = typeof attribute === 'object' ? _extends({}, attribute) : {

if (obj.source === true) {
obj.source = dashCase(name);
obj.source = (0, _index.dashCase)(name);
}
if (obj.target === true) {
obj.target = dashCase(name);
obj.target = (0, _index.dashCase)(name);
}

@@ -21,3 +32,3 @@ return obj;

export function normalisePropertyDefinition(name, prop) {
function normalisePropertyDefinition(name, prop) {
const { coerce, default: def, deserialize, serialize } = prop;

@@ -33,3 +44,3 @@ return {

export function syncAttributeToProperty(elem, name, value) {
function syncAttributeToProperty(elem, name, value) {
if (elem._syncingPropertyToAttribute) {

@@ -49,3 +60,3 @@ return;

export function syncPropertyToAttribute(elem, target, serialize, val) {
function syncPropertyToAttribute(elem, target, serialize, val) {
if (target && elem._syncingAttributeToProperty !== target) {

@@ -52,0 +63,0 @@ const serialized = serialize(val);

@@ -0,8 +1,14 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatName = formatName;
exports.generateName = generateName;
import { dashCase } from './index.js';
var _index = require('./index.js');
let suffix = 0;
export function formatName(prefix, suffix) {
function formatName(prefix, suffix) {
prefix = prefix || 'element';

@@ -12,5 +18,5 @@ return (prefix.indexOf('-') === -1 ? `x-${prefix}` : prefix) + (suffix ? `-${suffix}` : '');

export function generateName(Ctor) {
function generateName(Ctor) {
const registry = customElements;
const prefix = dashCase(Ctor.name);
const prefix = (0, _index.dashCase)(Ctor.name);
while (registry.get(formatName(prefix, suffix))) {

@@ -17,0 +23,0 @@ suffix++;

@@ -1,10 +0,20 @@

import { h, render } from '../../node_modules/preact/dist/preact.esm.js';
import { withProps } from './with-props.js';
import { withRender } from './with-render.js';
import { withUnique } from './with-unique.js';
'use strict';
export const withComponent = (Base = HTMLElement) => {
return class extends withRender(withUnique(withProps(Base))) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.h = exports.Component = exports.withComponent = undefined;
var _preactEsm = require('../../node_modules/preact/dist/preact.esm.js');
var _withProps = require('./with-props.js');
var _withRender = require('./with-render.js');
var _withUnique = require('./with-unique.js');
const withComponent = exports.withComponent = (Base = HTMLElement) => {
return class extends (0, _withRender.withRender)((0, _withUnique.withUnique)((0, _withProps.withProps)(Base))) {
rendererCallback(shadowRoot, renderCallback) {
this._preactDom = render(renderCallback(), shadowRoot, this._preactDom || shadowRoot.children[0]);
this._preactDom = (0, _preactEsm.render)(renderCallback(), shadowRoot, this._preactDom || shadowRoot.children[0]);
}

@@ -14,3 +24,3 @@ };

export const Component = withComponent(typeof window === 'undefined' ? class {} : HTMLElement);
export { h };
const Component = exports.Component = withComponent(typeof window === 'undefined' ? class {} : HTMLElement);
exports.h = _preactEsm.h;

@@ -0,8 +1,14 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.props = exports.withProps = undefined;
exports.prop = prop;
import { debounce, empty, keys, sym } from './util/index.js';
var _index = require('./util/index.js');
import { normalisePropertyDefinition, syncAttributeToProperty, syncPropertyToAttribute } from './util/with-props.js';
var _withProps = require('./util/with-props.js');
export function prop(definition) {
function prop(definition) {
const propertyDefinition = definition || {};

@@ -12,4 +18,4 @@

const func = function ({ constructor }, name) {
const normalised = normalisePropertyDefinition(name, propertyDefinition);
const _value = sym(name);
const normalised = (0, _withProps.normalisePropertyDefinition)(name, propertyDefinition);
const _value = (0, _index.sym)(name);

@@ -31,3 +37,3 @@ // Cache the value so we can reference when syncing the attribute to the property.

this[_value] = normalised.coerce(val);
syncPropertyToAttribute(this, normalised.attribute.target, normalised.serialize, val);
(0, _withProps.syncPropertyToAttribute)(this, normalised.attribute.target, normalised.serialize, val);
this._updateDebounced();

@@ -44,3 +50,3 @@ }

export const withProps = (Base = HTMLElement) => {
const withProps = exports.withProps = (Base = HTMLElement) => {
var _class, _temp;

@@ -63,3 +69,3 @@

static set props(props) {
keys(props).forEach(name => {
(0, _index.keys)(props).forEach(name => {
let func = props[name];

@@ -72,3 +78,3 @@ if (typeof func !== 'function') func = prop(func);

get props() {
return keys(this.constructor.props).reduce((prev, curr) => {
return (0, _index.keys)(this.constructor.props).reduce((prev, curr) => {
prev[curr] = this[curr];

@@ -81,3 +87,3 @@ return prev;

const ctorProps = this.constructor.props;
keys(props).forEach(k => k in ctorProps && (this[k] = props[k]));
(0, _index.keys)(props).forEach(k => k in ctorProps && (this[k] = props[k]));
}

@@ -112,3 +118,3 @@

this._constructed = true;
this._updateDebounced = debounce(this._updateCallback);
this._updateDebounced = (0, _index.debounce)(this._updateCallback);
}

@@ -139,3 +145,3 @@

propsUpdatedCallback(next, prev) {
return !prev || keys(prev).some(k => prev[k] !== next[k]);
return !prev || (0, _index.keys)(prev).some(k => prev[k] !== next[k]);
}

@@ -146,3 +152,3 @@

if (super.attributeChangedCallback) super.attributeChangedCallback(name, oldValue, newValue);
syncAttributeToProperty(this, name, newValue);
(0, _withProps.syncAttributeToProperty)(this, name, newValue);
}

@@ -156,3 +162,3 @@

const attribute = Object.freeze({ source: true });
const zeroOrNumber = val => empty(val) ? 0 : Number(val);
const zeroOrNumber = val => (0, _index.empty)(val) ? 0 : Number(val);

@@ -165,3 +171,3 @@ const any = prop({

attribute,
coerce: val => Array.isArray(val) ? val : empty(val) ? null : [val],
coerce: val => Array.isArray(val) ? val : (0, _index.empty)(val) ? null : [val],
default: Object.freeze([]),

@@ -176,3 +182,3 @@ deserialize: parse,

default: false,
deserialize: val => !empty(val),
deserialize: val => !(0, _index.empty)(val),
serialize: val => val ? '' : null

@@ -186,3 +192,3 @@ });

deserialize: zeroOrNumber,
serialize: val => empty(val) ? null : String(Number(val))
serialize: val => (0, _index.empty)(val) ? null : String(Number(val))
});

@@ -201,6 +207,6 @@

coerce: String,
serialize: val => empty(val) ? null : String(val)
serialize: val => (0, _index.empty)(val) ? null : String(val)
});
export const props = {
const props = exports.props = {
any,

@@ -207,0 +213,0 @@ array,

@@ -0,1 +1,6 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
const attachShadowOptions = { mode: 'open' };

@@ -7,3 +12,3 @@

export const withRender = (Base = HTMLElement) => {
const withRender = exports.withRender = (Base = HTMLElement) => {
return class extends Base {

@@ -10,0 +15,0 @@

@@ -1,8 +0,15 @@

import { generateName } from './util/with-unique.js';
'use strict';
export const withUnique = (Base = HTMLElement) => {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withUnique = undefined;
var _withUnique = require('./util/with-unique.js');
const withUnique = exports.withUnique = (Base = HTMLElement) => {
return class extends Base {
static get is() {
return this._is || (this._is = generateName(this));
return this._is || (this._is = (0, _withUnique.generateName)(this));
}

@@ -9,0 +16,0 @@ static set is(is) {

{
"name": "skatejs",
"version": "5.0.0-alpha.12",
"version": "5.0.0-alpha.13",
"description": "Skate is a library built on top of the W3C web component specs that enables you to write functional and performant web components with a very small footprint.",

@@ -11,3 +11,4 @@ "license": "MIT",

},
"main": "umd/skatejs.js",
"browser": "umd/skatejs.js",
"main": "node/index.js",
"module": "es/index.js",

@@ -29,2 +30,3 @@ "esnext": "esnext/index.js",

"es",
"node",
"src",

@@ -43,2 +45,3 @@ "umd"

"babel-plugin-modules-web-compat": "1.1.0",
"babel-preset-env": "1.6.0",
"babel-preset-es2016": "6.24.1",

@@ -54,5 +57,5 @@ "babel-preset-es2017": "6.24.1",

"jest": "20.0.4",
"lint-staged": "4.0.2",
"preact": "*",
"semantic-release": "6.3.2",
"semistandard": "10.0.0",
"typescript": "2.3.3",

@@ -69,10 +72,11 @@ "typescript-formatter": "5.2.0",

"scripts": {
"build:esnext": "babel src --out-dir esnext --presets=$(pwd)/config/babel.esnext",
"build:node": "babel src --out-dir node --presets=$(pwd)/config/babel.node",
"commitmsg": "validate-commit-msg",
"docs:build": "gitbook install && gitbook build",
"docs:watch": "gitbook install && gitbook serve",
"precommit": "semistandard",
"build:esnext": "babel src --out-dir esnext --no-babelrc --presets=stage-0,es2017,es2016,react,$(pwd)/config/esnext.babel",
"prepublish": "nwb build && npm run build:esnext",
"prepublish": "nwb build && npm run build:esnext && npm run build:node",
"precommit": "lint-staged",
"release": "git push && git push --tags && npm publish",
"test": "semistandard && npm run prepublish && npm run test:ts && node umd/skatejs.js && jest",
"test": "npm run prepublish && npm run test:ts && node umd/skatejs.js && jest",
"test:watch": "jest --watch",

@@ -82,2 +86,8 @@ "test:ts": "tsc -p ./",

},
"lint-staged": {
"*.(js|json)": [
"prettier --write",
"git add"
]
},
"config": {

@@ -106,23 +116,3 @@ "commitizen": {

"testEnvironment": "@skatejs/ssr/jest"
},
"semistandard": {
"globals": [
"Class",
"CustomEvent",
"customElements",
"CustomElementRegistry",
"Event",
"EventTarget",
"HTMLElement",
"MutationObserver",
"Node"
],
"ignore": [
"flow-typed"
],
"parser": "babel-eslint",
"plugins": [
"flowtype"
]
}
}
/*!
* skatejs v5.0.0-alpha.12
* skatejs v5.0.0-alpha.13
* MIT Licensed

@@ -4,0 +4,0 @@ */

/*!
* skatejs v5.0.0-alpha.12
* skatejs v5.0.0-alpha.13
* MIT Licensed

@@ -4,0 +4,0 @@ */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc