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

xander

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xander - npm Package Compare versions

Comparing version 0.14.2 to 0.15.0

lib/loadable.js

42

lib/connect.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,14 +7,9 @@ Object.defineProperty(exports, "__esModule", {

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; };
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; }; }();
exports.connectStore = connectStore;
exports.connect = connect;
var _react = require("react");
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _fluxury = require('fluxury');
var _fluxury = require("fluxury");

@@ -27,5 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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 _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; } /**
* Copyright (c) 2015-2018, JC Fisher
*/
function _connect(getState, subscribe, Composed) {
function connect(Composed) {
return function (_React$PureComponent) {

@@ -39,3 +36,3 @@ _inherits(Connect, _React$PureComponent);

_this.state = getState();
_this.state = (0, _fluxury.getState)();
_this.handleChange = _this.handleChange.bind(_this);

@@ -46,10 +43,10 @@ return _this;

_createClass(Connect, [{
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {
this.token = subscribe(this.handleChange);
this.token = (0, _fluxury.subscribe)(this.handleChange);
}
}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (typeof this.token === 'function') {
if (typeof this.token === "function") {
this.token();

@@ -59,3 +56,3 @@ }

}, {
key: 'handleChange',
key: "handleChange",
value: function handleChange(state) {

@@ -65,5 +62,5 @@ this.setState(state);

}, {
key: 'render',
key: "render",
value: function render() {
return _react2.default.createElement(Composed, _extends({}, this.state, this.props));
return (0, _react.createElement)(Composed, Object.assign({}, this.state, this.props));
}

@@ -76,8 +73,3 @@ }]);

function connectStore(store, Composed) {
return _connect(store.getState, store.subscribe, Composed);
}
function connect(Composed) {
return _connect(_fluxury.getState, _fluxury.subscribe, Composed);
}
exports.default = connect;
module.exports = exports["default"];

@@ -7,4 +7,2 @@ "use strict";

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; };
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; }; }();

@@ -23,6 +21,5 @@

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; } /**
* Copyright (c) 2015, JC Fisher
*/
* Copyright (c) 2015, JC Fisher
*/
var Container = function (_React$Component) {

@@ -54,3 +51,5 @@ _inherits(Container, _React$Component);

// render the content for the route!
return _react2.default.createElement(Content, _extends({ router: router, location: router.location }, this.props));
return (0, _react.createElement)(Content, Object.assign({}, this.props, {
location: router.location
}));
}

@@ -57,0 +56,0 @@ }]);

@@ -21,3 +21,5 @@ "use strict";

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 _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; } /**
* Copyright (c) 2015-2018, JC Fisher
*/

@@ -36,7 +38,3 @@ var Eval = function (_React$Component) {

value: function render() {
return _react2.default.createElement(
"div",
{ style: this.props.style, className: this.props.className },
(0, _formula.RUN)(this.props.exp, this.props.values || {})
);
return (0, _react.createElement)("div", this.props, (0, _formula.RUN)(this.props.exp, this.props.values || {}));
}

@@ -43,0 +41,0 @@ }]);

@@ -9,21 +9,34 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _router = require("./router");
// Copyright 2017 JC Fisher
var _router2 = _interopRequireDefault(_router);
var router = require("./router");
var _fluxury = require("fluxury");
var _require = require("fluxury"),
getState = _require.getState,
getStores = _require.getStores,
subscribe = _require.subscribe,
createStore = _require.createStore,
dispatch = _require.dispatch,
promiseAction = _require.promiseAction,
replaceReducer = _require.replaceReducer;
var _loadable = require("./loadable");
var Container = require("./container");
var connectStore = require("./connect").connectStore;
var connect = require("./connect").connect;
var _loadable2 = _interopRequireDefault(_loadable);
var _container = require("./container");
var _container2 = _interopRequireDefault(_container);
var _connect = require("./connect");
var _connect2 = _interopRequireDefault(_connect);
var _link = require("./link");
var _link2 = _interopRequireDefault(_link);
var _eval = require("./eval");
var _eval2 = _interopRequireDefault(_eval);
var _rule = require("./rule");
var _rule2 = _interopRequireDefault(_rule);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var xander = function xander(_ref) {

@@ -34,8 +47,8 @@ var routes = _ref.routes,

// load the routes
if (routes) router.loadRoutes(routes);
if (routes) _router2.default.loadRoutes(routes);
// enable console tools when debug enabled.
if (debug === true) {
window.router = router;
subscribe(function (state, action) {
window.router = _router2.default;
(0, _fluxury.subscribe)(function (state, action) {
return console.log("action", action);

@@ -45,31 +58,33 @@ });

return connect(Container);
};
return (0, _connect2.default)(_container2.default);
}; /**
* Copyright (c) 2015-2018, JC Fisher
*/
xander.boot = function (options) {
var App = xander(options);
(0, _reactDom.render)(_react2.default.createElement(App, null), options.rootEl || document.body);
(0, _reactDom.render)(_react2.default.createElement(App), options.rootEl || document.body);
};
// Export static functions
xander.Link = require("./link");
xander.Eval = require("./eval");
xander.Rule = require("./rule");
xander.Container = Container;
xander.connect = connect;
xander.connectStore = connectStore;
xander.createStore = createStore;
xander.dispatch = dispatch;
xander.subscribe = subscribe;
xander.getState = getState;
xander.replaceReducer = replaceReducer;
xander.getStores = getStores;
xander.promiseAction = promiseAction;
xander.router = router;
xander.loadRoutes = router.loadRoutes;
xander.Link = _link2.default;
xander.Eval = _eval2.default;
xander.Rule = _rule2.default;
xander.loadable = _loadable2.default;
xander.Container = _container2.default;
xander.connect = _connect2.default;
xander.createStore = _fluxury.createStore;
xander.dispatch = _fluxury.dispatch;
xander.subscribe = _fluxury.subscribe;
xander.getState = _fluxury.getState;
xander.replaceReducer = _fluxury.replaceReducer;
xander.getStores = _fluxury.getStores;
xander.promiseAction = _fluxury.promiseAction;
xander.router = _router2.default;
xander.loadRoutes = _router2.default.loadRoutes;
xander.default = xander;
xander.openPath = function (path) {
return router.open(path);
return _router2.default.open(path);
};
module.exports = xander;

@@ -23,3 +23,5 @@ "use strict";

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 _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; } /**
* Copyright (c) 2015-2018, JC Fisher
*/

@@ -57,3 +59,3 @@ function isLeftClickEvent(event) {

event.preventDefault();
createElement;
this.props.action ? this.props.action(event) : _router2.default.open(this.props.to);

@@ -64,26 +66,9 @@ }

value: function render() {
if (this.props.type === "button") {
return _react2.default.createElement(
"button",
{
disabled: this.props.disabled,
className: this.props.className,
style: this.props.style,
onClick: this.handleClick
},
this.props.children
);
}
return _react2.default.createElement(
"a",
{
disabled: this.props.disabled,
className: this.props.className,
style: this.props.style,
onClick: this.handleClick,
href: this.props.to
},
this.props.children
);
return (0, _react.createElement)(this.props.tagName || "a", {
disabled: this.props.disabled,
className: this.props.className,
style: this.props.style,
onClick: this.handleClick,
href: this.props.to
}, this.props.children);
}

@@ -90,0 +75,0 @@ }]);

@@ -1,3 +0,7 @@

'use strict';
"use strict";
/**
* Copyright (c) 2015-2018, JC Fisher
*/
// Borrowed from very old version of pathToRegexp library

@@ -9,2 +13,3 @@ /**

module.exports = pathtoRegexp;
// Copyright 2017 JC Fisher

@@ -34,11 +39,11 @@ /**

if (path instanceof RegExp) return path;
if (path instanceof Array) path = '(' + path.join('|') + ')';
if (path instanceof Array) path = "(" + path.join("|") + ")";
path = path.concat(strict ? '' : '/?').replace(/\/\(/g, '(?:/').replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?(\*)?/g, function (_, slash, format, key, capture, optional, star) {
path = path.concat(strict ? "" : "/?").replace(/\/\(/g, "(?:/").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?(\*)?/g, function (_, slash, format, key, capture, optional, star) {
keys.push({ name: key, optional: !!optional });
slash = slash || '';
return '' + (optional ? '' : slash) + '(?:' + (optional ? slash : '') + (format || '') + (capture || format && '([^/.]+?)' || '([^/]+?)') + ')' + (optional || '') + (star ? '(/*)?' : '');
}).replace(/([\/.])/g, '\\$1').replace(/\*/g, '(.*)');
slash = slash || "";
return "" + (optional ? "" : slash) + "(?:" + (optional ? slash : "") + (format || "") + (capture || format && "([^/.]+?)" || "([^/]+?)") + ")" + (optional || "") + (star ? "(/*)?" : "");
}).replace(/([\/.])/g, "\\$1").replace(/\*/g, "(.*)");
return new RegExp('^' + path + '$', sensitive ? '' : 'i');
};
return new RegExp("^" + path + "$", sensitive ? "" : "i");
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Copyright (c) 2015-2018, JC Fisher
*/
var createStore = require("fluxury").createStore;

@@ -45,3 +52,3 @@ var dispatch = require("fluxury").dispatch;

// A list of routes that specify a URL path and an action that must return a promise to the page content.
module.exports = createStore("router", function () {
var store = createStore("router", function () {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { location: readLocation(), routes: [] };

@@ -82,4 +89,5 @@ var action = arguments[1];

// console.log('current path', pathname)
// Copyright 2017 JC Fisher
// Match routes
// Match routesstore
var found = match(routes, pathname);

@@ -97,2 +105,4 @@

if (!route) {
// Copyright 2017 JC Fisher
console.warn("no route!");

@@ -120,20 +130,2 @@ return state;

content = route.component;
} else if (found && route && route.load) {
// console.log('ASYNC', route, content)
// run the action method defined by the router
var loader = route.load;
if (isfunction(loader)) {
// console.log("THUNK", route, typeof route.load)
loader = route.load(params);
}
if (isfunction(loader)) {
content = loader;
} else if (isobject(loader) && loader.then) {
// console.log("THEN", route)
loader.then(function (cmp) {
return dispatch("loadContent", cmp);
});
}
}

@@ -163,2 +155,5 @@

dispatch("windowPopState");
});
});
exports.default = store;
module.exports = exports["default"];

@@ -21,3 +21,5 @@ "use strict";

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 _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; } /**
* Copyright (c) 2015-2018, JC Fisher
*/

@@ -44,30 +46,8 @@ var key = 0;

function renderFunction(config, f, depth) {
return _react2.default.createElement(
"div",
{
style: (config.renderFunctionStyle || function () {})(f, depth),
className: "xander-rules-section xander-rules-function"
},
_react2.default.createElement(
"span",
null,
_react2.default.createElement(
"span",
{ className: "xander-rules-function-begin" },
config.renderFunctionBegin(config, f, depth)
),
_react2.default.createElement(
"div",
{ className: "xander-rules-args" },
f.args.map(function (d) {
return config.renderRule(config, d, depth + 1);
})
),
_react2.default.createElement(
"span",
{ className: "xander-rules-function-end " },
config.renderFunctionEnd(config, f, depth)
)
)
);
return (0, _react.createElement)("div", {
style: (config.renderFunctionStyle || function () {})(f, depth),
className: "xander-rules-section xander-rules-function"
}, (0, _react.createElement)("span", null, (0, _react.createElement)("span", { className: "xander-rules-function-begin" }, config.renderFunctionBegin(config, f, depth)), (0, _react.createElement)("div", { className: "xander-rules-args" }, f.args.map(function (d) {
return config.renderRule(config, d, depth + 1);
})), (0, _react.createElement)("span", { className: "xander-rules-function-end " }, config.renderFunctionEnd(config, f, depth))));
}

@@ -79,72 +59,31 @@

return _react2.default.createElement(
"div",
{
return (0, _react.createElement)("div", {
style: (config.renderOperatorStyle || function () {})(o, depth),
className: "xander-rules-section xander-rules-operator"
}, (0, _formula.IF)(operands.length === 1, function () {
return (0, _react.createElement)("div", {
style: (config.renderOperatorStyle || function () {})(o, depth),
className: "xander-rules-section xander-rules-operator"
},
(0, _formula.IF)(operands.length === 1, function () {
return _react2.default.createElement(
"div",
{
style: (config.renderOperatorStyle || function () {})(o, depth),
className: "xander-rules-operator"
},
_react2.default.createElement(
"span",
{
style: (config.renderPrefixStyle || function () {})(o, depth),
className: "xander-rules-operator-" + subtype
},
(0, _formula.IF)(subtype == "prefix-minus", config.labelPrefixMINUS || "-", subtype == "prefix-plus", config.labelPrefixPLUS || "+")
),
_react2.default.createElement(
"span",
{
className: "xander-rules-rhs",
style: (config.renderRHSStyle || function () {})(o, depth)
},
config.renderRule(config, operands[0], depth + 1)
)
);
}, operands.length === 2, function () {
return _react2.default.createElement(
"div",
{
style: (config.renderOperatorStyle || function () {})(o, depth),
className: "xander-rules-operator"
},
_react2.default.createElement(
"span",
{
style: (config.renderLHSStyle || function () {})(o, depth),
className: "xander-rules-lhs"
},
renderRule(config, operands[0], depth + 1)
),
" ",
_react2.default.createElement(
"span",
{
style: (config.rendeInfixStyle || function () {})(o, depth),
className: "xander-rules-operator-" + subtype
},
(0, _formula.IF)(subtype == "infix-eq", config.labelEQ || "=", subtype == "infix-ne", config.labelNE || "<>", subtype == "infix-gt", config.labelGT || "<", subtype == "infix-gte", config.labelGTE || "<=", subtype == "infix-lt", config.labelLE || ">", subtype == "infix-lte", config.labelLTE || ">=", subtype == "infix-add", config.labelADD || "+", subtype == "infix-subtract", config.labelSUB || "-", subtype == "infix-multiply", config.labelMUL || "*", subtype == "infix-divide", config.labelDIV || "/", subtype == "infix-power", config.labelMUL || "^", subtype == "infix-concat", config.labelMUL || "&", config.labelDefault || "huh?")
),
" ",
_react2.default.createElement(
"span",
{
style: (config.renderRHSStyle || function () {})(o, depth),
className: "xander-rules-rhs"
},
renderRule(config, operands[1], depth + 1)
)
);
}, _react2.default.createElement(
"div",
null,
"unexpected number of operands!"
))
);
className: "xander-rules-operator"
}, (0, _react.createElement)("span", {
style: (config.renderPrefixStyle || function () {})(o, depth),
className: "xander-rules-operator-" + subtype
}, (0, _formula.IF)(subtype == "prefix-minus", config.labelPrefixMINUS || "-", subtype == "prefix-plus", config.labelPrefixPLUS || "+")), (0, _react.createElement)("span", {
className: "xander-rules-rhs",
style: (config.renderRHSStyle || function () {})(o, depth)
}, config.renderRule(config, operands[0], depth + 1)));
}, operands.length === 2, function () {
return (0, _react.createElement)("div", {
style: (config.renderOperatorStyle || function () {})(o, depth),
className: "xander-rules-operator"
}, (0, _react.createElement)("span", {
style: (config.renderLHSStyle || function () {})(o, depth),
className: "xander-rules-lhs"
}, renderRule(config, operands[0], depth + 1)), " ", (0, _react.createElement)("span", {
style: (config.rendeInfixStyle || function () {})(o, depth),
className: "xander-rules-operator-" + subtype
}, (0, _formula.IF)(subtype == "infix-eq", config.labelEQ || "=", subtype == "infix-ne", config.labelNE || "<>", subtype == "infix-gt", config.labelGT || "<", subtype == "infix-gte", config.labelGTE || "<=", subtype == "infix-lt", config.labelLE || ">", subtype == "infix-lte", config.labelLTE || ">=", subtype == "infix-add", config.labelADD || "+", subtype == "infix-subtract", config.labelSUB || "-", subtype == "infix-multiply", config.labelMUL || "*", subtype == "infix-divide", config.labelDIV || "/", subtype == "infix-power", config.labelMUL || "^", subtype == "infix-concat", config.labelMUL || "&", config.labelDefault || "huh?")), " ", (0, _react.createElement)("span", {
style: (config.renderRHSStyle || function () {})(o, depth),
className: "xander-rules-rhs"
}, renderRule(config, operands[1], depth + 1)));
}, (0, _react.createElement)("div", null, "unexpected number of operands!")));
}

@@ -161,66 +100,36 @@

return _react2.default.createElement(
"div",
{
style: (config.renderOperandStyle || function () {})(o, depth),
className: "xander-rules-section xander-rules-value xander-rules-value-" + subtype
},
(0, _formula.IF)(subtype === "string", function () {
return config.renderString(value);
}, subtype === "number", function () {
return config.renderNumber(value);
}, subtype === "boolean", function () {
return config.renderBoolean(value);
}, subtype === "array", function () {
return _react2.default.createElement(
"span",
null,
"[",
items.map(function (d) {
return _react2.default.createElement(
"div",
{
key: key++,
className: "xander-rules-value xander-rules-array"
},
config.renderRule(config, d, depth + 1)
);
}),
"]"
);
}, "Other")
);
return (0, _react.createElement)("div", {
style: (config.renderOperandStyle || function () {})(o, depth),
className: "xander-rules-section xander-rules-value xander-rules-value-" + subtype
}, (0, _formula.IF)(subtype === "string", function () {
return config.renderString(value);
}, subtype === "number", function () {
return config.renderNumber(value);
}, subtype === "boolean", function () {
return config.renderBoolean(value);
}, subtype === "array", function () {
return (0, _react.createElement)("span", null, "[", items.map(function (d) {
return (0, _react.createElement)("div", {
key: key++,
className: "xander-rules-value xander-rules-array"
}, config.renderRule(config, d, depth + 1));
}), "]");
}, "Other"));
}
function renderGroup(config, g, depth) {
return _react2.default.createElement(
"div",
{
key: key++,
style: (config.renderRangeStyle || function () {})(g, depth),
className: "xander-rules-section xander-rules-group"
},
"(",
config.renderRule(g.exp, depth + 1),
")"
);
return (0, _react.createElement)("div", {
key: key++,
style: (config.renderRangeStyle || function () {})(g, depth),
className: "xander-rules-section xander-rules-group"
}, "(", config.renderRule(g.exp, depth + 1), ")");
}
function renderRange(config, r, depth) {
return _react2.default.createElement(
"div",
{
style: (config.renderRangeStyle || function () {})(r, depth),
className: "xander-rules-section xander-rules-range"
},
(0, _formula.IF)(config.hasOwnProperty("renderRange"), function () {
return config.renderRange(r, depth);
}, _react2.default.createElement(
"span",
null,
renderVariable(r.topLeft),
":",
renderVariable(r.topLeft)
))
);
return (0, _react.createElement)("div", {
style: (config.renderRangeStyle || function () {})(r, depth),
className: "xander-rules-section xander-rules-range"
}, (0, _formula.IF)(config.hasOwnProperty("renderRange"), function () {
return config.renderRange(r, depth);
}, (0, _react.createElement)("span", null, renderVariable(r.topLeft), ":", renderVariable(r.topLeft))));
}

@@ -232,10 +141,7 @@

return _react2.default.createElement(
"div",
{
style: (config.renderVariableStyle || function () {})(v, depth),
className: "xander-rules-section xander-rules-variable-name"
},
_formula.WALKERCONFIGDEFAULT.renderVariable(config, v, depth)
);
return (0, _react.createElement)("div", {
style: (config.renderVariableStyle || function () {})(v, depth),
className: "xander-rules-section xander-rules-variable-name"
}, _formula.WALKERCONFIGDEFAULT.renderVariable(config, v, depth));
}

@@ -248,10 +154,7 @@

return _react2.default.createElement(
"div",
{
style: (config.renderRuleStyle || function () {})(ast, depth),
className: "xander-rules-block xander-rules-block-" + type + " xander-rules-block-" + subtype + " xander-rules-depth-" + depth
},
_formula.WALKERCONFIGDEFAULT.renderRule(config, ast, depth)
);
return (0, _react.createElement)("div", {
style: (config.renderRuleStyle || function () {})(ast, depth),
className: "xander-rules-block xander-rules-block-" + type + " xander-rules-block-" + subtype + " xander-rules-depth-" + depth
}, _formula.WALKERCONFIGDEFAULT.renderRule(config, ast, depth));
}

@@ -270,7 +173,3 @@

return _react2.default.createElement(
"div",
{ className: "xander-rules-formula" },
renderRule(newConfig, ast)
);
return (0, _react.createElement)("div", { className: "xander-rules-formula" }, renderRule(newConfig, ast));
}

@@ -277,0 +176,0 @@ }]);

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,3 +7,3 @@ Object.defineProperty(exports, "__esModule", {

var _fluxury = require('fluxury');
var _fluxury = require("fluxury");

@@ -17,5 +17,7 @@ var getWindow = function getWindow() {

};
};
}; /**
* Copyright (c) 2015-2018, JC Fisher
*/
var windowStore = (0, _fluxury.createStore)('window', {
var windowStore = (0, _fluxury.createStore)("window", {
getInitialState: getWindow,

@@ -31,7 +33,7 @@ windowOnResize: function windowOnResize(state, data) {

function resize() {
(0, _fluxury.dispatch)('windowOnResize', getWindow());
(0, _fluxury.dispatch)("windowOnResize", getWindow());
}
function scroll() {
(0, _fluxury.dispatch)('windowOnScroll', getWindow());
(0, _fluxury.dispatch)("windowOnScroll", getWindow());
}

@@ -43,2 +45,2 @@

exports.default = windowStore;
module.exports = exports['default'];
module.exports = exports["default"];
{
"name": "xander",
"version": "0.14.2",
"version": "0.15.0",
"description": "Single page app framework",

@@ -11,5 +11,3 @@ "repository": "git+https://github.com/FormBucket/xander.git",

},
"keywords": [
"flux"
],
"keywords": ["flux", "react"],
"homepage": "https://github.com/FormBucket/xander#readme",

@@ -33,3 +31,3 @@ "devDependencies": {

"license": "MIT",
"peerDependencies" : {
"peerDependencies": {
"react": "^15.6.2 || ^16.0.0"

@@ -36,0 +34,0 @@ },

@@ -7,4 +7,11 @@ # xander

Framework for browser apps with uncompromising configuration.
Single Page App framework for React and [formula](https://github.com/FormBucket/formula).
* State management
* Router
* Link Component
* Container Component
* Rule Component
* Formula Evaluation Component
## Usage

@@ -17,3 +24,5 @@

```
## Examples
### Quick start

@@ -24,12 +33,16 @@

```js
import {boot, Rule, Eval} from 'xander';
import {boot, Loadable, Rule, Eval} from 'xander';
// Calling constructor function return React component.
boot({
debug: false, // optional, enables logging actions to console.
rootEl: document.body, // optional, determine root node for application.
routes: [{
path: '/',
component: (props) => <div>Hello, World.</div>
component: (props) => <div>Hello, World.</div>
}, {
path: '/page-splitting',
component: Loadable({
loader: () => import('./page-to-your-component'),
loading: (props) => <div>My Loader Code</div>
})
}, {
path: '/test_rules',

@@ -75,14 +88,16 @@ component: (props) => (

A minimalist routers, supports history API.
A minimal router, only supports history API.
```js
import {router} from 'xander'
router.open('/buckets/1')
import { router } from "xander";
router.open("/buckets/1");
```
Use `redirect` to change the URL without adding an entry to the history state.
```js
router.redirect('/buckets')
router.redirect("/buckets");
```
#### Load Routes
#### Load Routes

@@ -92,6 +107,8 @@ Load routes and related configuration.

```js
loadRoutes([{
path: '/',
load: loadContent( System.import('./pages/home') )
}])
loadRoutes([
{
path: "/",
component: require("./pages/home")
}
]);
```

@@ -104,6 +121,6 @@

```js
import {createStore} from 'xander'
createStore(name, reducerOrSpec, actionsAndQueries)
import { createStore } from "xander";
createStore(name, reducerOrSpec, actionsAndQueries);
```
For more examples see [fluxury](https://github.com/formula/fluxury).

@@ -83,19 +83,19 @@ // mock browser globals

path: "/",
load: () => testComponent
component: testComponent
},
{
path: "/buckets",
load: () => testComponent
component: testComponent
},
{
path: "/buckets/:account_id",
load: () => testComponent
component: testComponent
},
{
path: "/buckets/:account_id/settings",
load: () => testComponent
component: testComponent
},
{
path: "*",
load: () => pageNotFound
component: pageNotFound
}

@@ -226,7 +226,7 @@ ];

path: "/",
load: () => testComponent
component: testComponent
},
{
path: "/foo",
load: () => testComponent
component: testComponent
},

@@ -246,2 +246,3 @@ {

);
t.equal(str, "<div>path: /foo. params: {}. search: </div>");

@@ -263,3 +264,3 @@

var { connectStore } = require("../src/index");
var { connect } = require("../src/index");
var { createStore, dispatch } = require("fluxury");

@@ -270,3 +271,3 @@

t.equals(typeof connectStore, "function");
t.equals(typeof connect, "function");
});

@@ -291,7 +292,7 @@

<div>
{props.foo} - {props.count}
{props.foo} - {props.CounterStore.count}
</div>
);
var EnhancedCounterView = connectStore(CounterStore, CounterView);
var EnhancedCounterView = connect(CounterView);

@@ -298,0 +299,0 @@ var str = ReactDom.renderToStaticMarkup(<EnhancedCounterView foo="bar" />);

// mock browser globals
var parseURL = require('url').parse;
var historyQueue = []
var parseURL = require("url").parse;
var historyQueue = [];
let windowCallbacks = {}
let windowCallbacks = {};
global.window = {
location: {
pathname: '/',
search: '',
hash: ''
pathname: "/",
search: "",
hash: ""
},
addEventListener: (name, cb) => {
windowCallbacks[name] = cb
windowCallbacks[name] = cb;
}
}
};
function* goBack() {
//console.log(historyQueue.length)
var current = historyQueue.pop()
var previous = historyQueue.pop()
window.location.pathname = previous.pathname
window.location.search = previous.search
window.location.hash = previous.hash
windowCallbacks.popstate(previous)
var current = historyQueue.pop();
var previous = historyQueue.pop();
window.location.pathname = previous.pathname;
window.location.search = previous.search;
window.location.hash = previous.hash;
windowCallbacks.popstate(previous);
}
global.document = {
title: 'test'
}
title: "test"
};
global.history = {
pushState: (state, title, url) => {
window.location = parseURL(url)
window.location = parseURL(url);
historyQueue.push(window.location);
},
replaceState: (state, title, url) => {
window.location = parseURL(url)
},
}
window.location = parseURL(url);
}
};
// run tests
var test = require('tape-async');
var React = require('react')
var ReactDom = require('react-dom/server')
var test = require("tape-async");
var React = require("react");
var ReactDom = require("react-dom/server");
var testComponent = (props) => <div>path: {props.location.pathname}. params: {JSON.stringify(props.router.params)}. search: {props.location.search}</div>
var testComponent2 = (props) => <div>2</div>
var testComponent3 = (props) => <div>3</div>
var testComponent4 = (props) => <div>4</div>
var pageNotFound = (props) => <div>not found</div>
var testComponent = props => (
<div>
path: {props.location.pathname}. params:{" "}
{JSON.stringify(props.router.params)}. search: {props.location.search}
</div>
);
var testComponent2 = props => <div>2</div>;
var testComponent3 = props => <div>3</div>;
var testComponent4 = props => <div>4</div>;
var pageNotFound = props => <div>not found</div>;
var { createStore, dispatch, promiseAction, subscribe } = require('fluxury')
var { createStore, dispatch, promiseAction, subscribe } = require("fluxury");
// subscribe((state, action) => console.log('action', action))
var { router, replaceRoutes, loadContent, loadRoutes } = require('../src/index');
var {
router,
replaceRoutes,
loadContent,
loadRoutes
} = require("../src/index");
loadRoutes([{
path: '/',
load: Promise.resolve(testComponent)
}, {
path: '/admin',
load: () => Promise.resolve(testComponent) // Promise resolves to component
}, {
path: '/admin2',
load: () => Promise.resolve({ default: testComponent2 }) // Promise resolves to ES6 default.
}, {
path: '/admin3',
component: testComponent3
}, {
path: '/admin4',
component: testComponent4
}, {
path: '/page/:num',
loadRoutes([
{
path: "/",
component: testComponent
},
{
path: "/admin",
component: testComponent
},
{
path: "/admin2",
component: testComponent2
},
{
path: "/admin3",
component: testComponent3
},
{
path: "/admin4",
component: testComponent4
}, {
path: '*',
component: testComponent
}])
},
{
path: "/page/:num",
component: testComponent4
},
{
path: "*",
component: testComponent
}
]);
test( 'Exports are correct type', function(t) {
t.plan(3)
t.equal(typeof router, 'object')
t.equal(typeof router.open, 'function')
t.equal(typeof router.redirect, 'function')
})
test("Exports are correct type", function(t) {
t.plan(3);
t.equal(typeof router, "object");
t.equal(typeof router.open, "function");
t.equal(typeof router.redirect, "function");
});
test( 'Router includes valid exports', function(t) {
t.plan(2)
t.equal(typeof router.loadContent, 'function')
t.equal(7, router.getState().routes.length)
})
test("Router includes valid exports", function(t) {
t.plan(2);
t.equal(typeof router.loadContent, "function");
t.equal(7, router.getState().routes.length);
});
test( 'location.open(path) works correctly', function* (t) {
t.plan(16)
test("location.open(path) works correctly", function*(t) {
t.plan(16);
var result = yield router.open("/admin");
var result = yield router.open('/admin')
t.equal(window.location.pathname, "/admin");
t.equal( window.location.pathname, '/admin')
var result = yield router.open("/admin?foo=1#456");
var result = yield router.open('/admin?foo=1#456')
t.equal(window.location.pathname, "/admin");
t.equal(window.location.search, "?foo=1");
t.equal(window.location.hash, "#456");
t.equal( window.location.pathname, '/admin')
t.equal( window.location.search, '?foo=1')
t.equal( window.location.hash, '#456')
var result = yield router.open("/");
var result = yield router.open('/')
var rs = router.getState;
var result = yield router.open('/admin')
t.equal( rs().route.path, '/admin' );
t.equal( rs().content, testComponent );
var result = yield router.open("/admin");
t.equal(rs().route.path, "/admin");
t.equal(rs().content, testComponent);
var result = yield router.open('/admin2?foo=bar')
t.equal( rs().route.path, '/admin2' );
t.equal( rs().content, testComponent2 );
var result = yield router.open("/admin2?foo=bar");
t.equal(rs().route.path, "/admin2");
t.equal(rs().content, testComponent2);
var result = yield router.open('/admin3')
t.equal( rs().route.path, '/admin3' );
t.equal( rs().content, testComponent3 );
var result = yield router.open("/admin3");
t.equal(rs().route.path, "/admin3");
t.equal(rs().content, testComponent3);
var result = yield router.open('/admin4')
t.equal( rs().route.path, '/admin4' );
t.equal( rs().content, testComponent4 );
var result = yield router.open("/admin4");
t.equal(rs().route.path, "/admin4");
t.equal(rs().content, testComponent4);
var result = yield router.open('/page/1')
t.equal( rs().route.path, '/page/:num' );
t.deepEqual( rs().params, { num: '1' })
var result = yield router.open("/page/1");
t.equal(rs().route.path, "/page/:num");
t.deepEqual(rs().params, { num: "1" });
var result = yield router.open('/page/2')
t.equal( rs().route.path, '/page/:num' );
t.deepEqual( rs().params, { num: '2' })
var result = yield router.open("/page/2");
t.equal(rs().route.path, "/page/:num");
t.deepEqual(rs().params, { num: "2" });
});
test( 'goBack works correctly', function*(t) {
t.plan(3)
var result = yield router.open('/admin?foo=1#bar')
test("goBack works correctly", function*(t) {
t.plan(3);
var result = yield router.open("/admin?foo=1#bar");
yield router.open('/admin2')
yield router.open("/admin2");

@@ -148,6 +163,5 @@ yield goBack();

t.equal( state.pathname, '/admin')
t.equal( state.search, '?foo=1')
t.equal( state.hash, '#bar')
t.equal(state.pathname, "/admin");
t.equal(state.search, "?foo=1");
t.equal(state.hash, "#bar");
});
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