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

create-app

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-app - npm Package Compare versions

Comparing version 0.2.0 to 0.4.0

109

lib/client/createApp.js

@@ -74,16 +74,3 @@ 'use strict';

function ignoreInput(input) {
if (!currentLocation) {
return false;
}
var currentUrl = currentLocation.pathname + currentLocation.search + currentLocation.hash;
var targetUrl = typeof input === 'string' ? input : input.pathname + input.search + input.hash;
return currentUrl === targetUrl;
}
function render(targetPath) {
if (ignoreInput(targetPath)) {
return;
}
var location = typeof targetPath === 'string' ? history.createLocation(targetPath) : targetPath;

@@ -140,41 +127,6 @@ context.prevLocation = currentLocation;

}
// update view
// history apis
_createClass(WrapperController, [{
key: 'goReplace',
value: function goReplace(targetPath) {
if (ignoreInput(targetPath)) {
return;
}
history.replace(targetPath);
}
}, {
key: 'goTo',
value: function goTo(targetPath) {
if (ignoreInput(targetPath)) {
return;
}
history.push(targetPath);
}
}, {
key: 'goIndex',
value: function goIndex(index) {
history.go(index);
}
}, {
key: 'goBack',
value: function goBack() {
history.goBack();
}
}, {
key: 'goForward',
value: function goForward() {
history.goForward();
}
// update view
}, {
key: 'refreshView',

@@ -184,3 +136,2 @@ value: function refreshView() {

}
// get container node

@@ -193,3 +144,2 @@

}
// clear container

@@ -216,36 +166,7 @@

}
if (currentController instanceof Controller && currentController.update) {
currentController.location = location;
currentController.context = context;
currentController.update();
return;
}
destroyController();
var FinalController = getController(location.pattern, Controller);
var controller = currentController = new FinalController(location, context);
var unlistenBeforeLeave = null;
var unlistenBeforeUnload = null;
if (controller.beforeLeave) {
var beforeLeave = controller.beforeLeave.bind(controller);
unlistenBeforeLeave = history.listenBefore(beforeLeave);
}
if (controller.beforeUnload) {
var beforeUnload = controller.beforeUnload.bind(controller);
unlistenBeforeUnload = history.listenBeforeUnload(beforeUnload);
}
controller.$unlisten = function () {
if (unlistenBeforeLeave) {
unlistenBeforeLeave();
unlistenBeforeLeave = null;
}
if (unlistenBeforeUnload) {
unlistenBeforeUnload();
unlistenBeforeUnload = null;
}
};
var component = controller.init();

@@ -256,12 +177,14 @@

return null;
} else if (_.isThenable(component)) {
}
if (_.isThenable(component)) {
return component.then(function (result) {
if (currentLocation !== location) {
return;
if (currentLocation !== location || result == null) {
return null;
}
return renderToContainer(result);
});
} else {
return renderToContainer(component);
}
return renderToContainer(component);
};

@@ -271,3 +194,3 @@ }

function renderToContainer(component) {
return viewEngine.render(component, _getContainer(), currentLocation);
return viewEngine.render(component, _getContainer());
}

@@ -282,10 +205,6 @@

function destroyController() {
if (currentController) {
currentController.$unlisten();
if (currentController.destroy) {
currentController.destroy();
}
if (currentController && currentController.destroy) {
currentController.destroy();
currentController = null;
}
_clearContainer();
}

@@ -361,3 +280,5 @@

var create = _history2.default[settings.type];
create = _history2.default.useBasename(create);
if (settings.basename) {
create = _history2.default.useBasename(create);
}
create = _history2.default.useBeforeUnload(create);

@@ -364,0 +285,0 @@ create = _history2.default.useQueries(create);

32

lib/server/createApp.js

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

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

@@ -60,2 +58,4 @@

var context = finalAppSettings.context;
var _finalAppSettings$bas = finalAppSettings.basename;
var basename = _finalAppSettings$bas === undefined ? '' : _finalAppSettings$bas;

@@ -98,4 +98,12 @@

var component = controller.init();
if (component == null) {
return { controller: controller };
}
if (_.isThenable(component)) {
return component.then(function (component) {
if (component == null) {
return { controller: controller };
}
var content = renderToString(component);

@@ -164,18 +172,2 @@ return { content: content, controller: controller };

// history apis
_createClass(WrapperController, [{
key: 'goTo',
value: function goTo(targetPath) {
var controller = fetchController(targetPath);
return controller.init();
}
}, {
key: 'goReplace',
value: function goReplace(targetPath) {
return this.goTo(targetPath);
}
}]);
return WrapperController;

@@ -200,5 +192,7 @@ }(Controller);

var create = _createMemoryHistory2.default;
create = _history2.default.useBasename(create);
if (settings.basename) {
create = _history2.default.useBasename(create);
}
create = _history2.default.useQueries(create);
return create(settings);
}

@@ -9,2 +9,3 @@ 'use strict';

exports.extend = extend;
exports.isAbsoluteUrl = isAbsoluteUrl;
// util

@@ -31,4 +32,16 @@ function isThenable(obj) {

function isAbsoluteUrl(url) {
if (typeof url !== 'string') {
throw new Error('expected url to be a string');
}
if (url.charAt(0) === '/' && url.charAt(1) === '/') {
return true;
}
var str1 = url.charAt(0) + url.charAt(1);
var str2 = str1 + url.charAt(2) + url.charAt(3);
return str1 === '//' || str2 === 'http';
}
if (!Object.freeze) {
Object.freeze = identity;
}
{
"name": "create-app",
"version": "0.2.0",
"version": "0.4.0",
"description": "configuring once, rendering both client and server.",

@@ -63,5 +63,5 @@ "browser": "lib/client/index.js",

"dependencies": {
"create-history": "^1.0.0",
"create-history": "^1.0.1",
"path-to-regexp": "^1.5.3"
}
}
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