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

@bjornlu/svelte-router

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bjornlu/svelte-router - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

335

dist/svelte-router.umd.js

@@ -55,5 +55,2 @@ (function (global, factory) {

}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function subscribe(store, ...callbacks) {

@@ -103,9 +100,2 @@ if (store == null) {

}
function update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {
const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);
if (slot_changes) {
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
slot.p(slot_context, slot_changes);
}
}
function exclude_internal_props(props) {

@@ -161,6 +151,3 @@ const result = {};

}
else if (key === '__value') {
node.value = node[key] = attributes[key];
}
else if (descriptors[key] && descriptors[key].set) {
else if (key === '__value' || descriptors[key] && descriptors[key].set) {
node[key] = attributes[key];

@@ -382,4 +369,3 @@ }

callbacks: blank_object(),
dirty,
skip_bound: false
dirty
};

@@ -391,3 +377,3 @@ let ready = false;

if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i])
if ($$.bound[i])
$$.bound[i](value);

@@ -437,8 +423,4 @@ if (ready)

}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
$set() {
// overridden by instance, if it has props
}

@@ -893,3 +875,3 @@ }

/* dist/components/RouterView.svelte generated by Svelte v3.24.1 */
/* dist/components/RouterView.svelte generated by Svelte v3.20.0 */

@@ -905,3 +887,3 @@ function create_if_block(ctx) {

function select_block_type(ctx, dirty) {
if (/*component*/ ctx[1] != null) return 0;
if (/*component*/ ctx[2] != null) return 0;
if (/*hasChildren*/ ctx[3]) return 1;

@@ -981,11 +963,7 @@ return -1;

// (39:24)
// (35:24)
function create_if_block_3(ctx) {
let routerview;
let current;
const routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } });
routerview = new RouterView({
props: { nextMatched: /*matched*/ ctx[2].slice(1) }
});
return {

@@ -1001,3 +979,3 @@ c() {

const routerview_changes = {};
if (dirty & /*matched*/ 4) routerview_changes.nextMatched = /*matched*/ ctx[2].slice(1);
if (dirty & /*depth*/ 1) routerview_changes.depth = /*depth*/ ctx[0] + 1;
routerview.$set(routerview_changes);

@@ -1020,83 +998,19 @@ },

// (31:2) {#if component != null}
// (29:2) {#if component != null}
function create_if_block_1(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block_2, create_else_block];
const if_blocks = [];
function select_block_type_1(ctx, dirty) {
if (/*hasChildren*/ ctx[3]) return 0;
return 1;
}
current_block_type_index = select_block_type_1(ctx);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
return {
c() {
if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(ctx, dirty) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type_1(ctx);
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
if_block = if_blocks[current_block_type_index];
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block.c();
}
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
i(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if_blocks[current_block_type_index].d(detaching);
if (detaching) detach(if_block_anchor);
}
};
}
// (36:4) {:else}
function create_else_block(ctx) {
let switch_instance;
let switch_instance_anchor;
let current;
var switch_value = /*component*/ ctx[1];
var switch_value = /*component*/ ctx[2];
function switch_props(ctx) {
return {};
return {
props: {
$$slots: { default: [create_default_slot] },
$$scope: { ctx }
}
};
}
if (switch_value) {
switch_instance = new switch_value(switch_props());
var switch_instance = new switch_value(switch_props(ctx));
}

@@ -1118,3 +1032,9 @@

p(ctx, dirty) {
if (switch_value !== (switch_value = /*component*/ ctx[1])) {
const switch_instance_changes = {};
if (dirty & /*$$scope, depth, hasChildren*/ 73) {
switch_instance_changes.$$scope = { dirty, ctx };
}
if (switch_value !== (switch_value = /*component*/ ctx[2])) {
if (switch_instance) {

@@ -1132,3 +1052,3 @@ group_outros();

if (switch_value) {
switch_instance = new switch_value(switch_props());
switch_instance = new switch_value(switch_props(ctx));
create_component(switch_instance.$$.fragment);

@@ -1140,2 +1060,4 @@ transition_in(switch_instance.$$.fragment, 1);

}
} else if (switch_value) {
switch_instance.$set(switch_instance_changes);
}

@@ -1159,78 +1081,31 @@ },

// (32:4) {#if hasChildren}
// (31:6) {#if hasChildren}
function create_if_block_2(ctx) {
let switch_instance;
let switch_instance_anchor;
let current;
var switch_value = /*component*/ ctx[1];
const routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } });
function switch_props(ctx) {
return {
props: {
$$slots: { default: [create_default_slot] },
$$scope: { ctx }
}
};
}
if (switch_value) {
switch_instance = new switch_value(switch_props(ctx));
}
return {
c() {
if (switch_instance) create_component(switch_instance.$$.fragment);
switch_instance_anchor = empty();
create_component(routerview.$$.fragment);
},
m(target, anchor) {
if (switch_instance) {
mount_component(switch_instance, target, anchor);
}
insert(target, switch_instance_anchor, anchor);
mount_component(routerview, target, anchor);
current = true;
},
p(ctx, dirty) {
const switch_instance_changes = {};
if (dirty & /*$$scope, matched*/ 260) {
switch_instance_changes.$$scope = { dirty, ctx };
}
if (switch_value !== (switch_value = /*component*/ ctx[1])) {
if (switch_instance) {
group_outros();
const old_component = switch_instance;
transition_out(old_component.$$.fragment, 1, 0, () => {
destroy_component(old_component, 1);
});
check_outros();
}
if (switch_value) {
switch_instance = new switch_value(switch_props(ctx));
create_component(switch_instance.$$.fragment);
transition_in(switch_instance.$$.fragment, 1);
mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
} else {
switch_instance = null;
}
} else if (switch_value) {
switch_instance.$set(switch_instance_changes);
}
const routerview_changes = {};
if (dirty & /*depth*/ 1) routerview_changes.depth = /*depth*/ ctx[0] + 1;
routerview.$set(routerview_changes);
},
i(local) {
if (current) return;
if (switch_instance) transition_in(switch_instance.$$.fragment, local);
transition_in(routerview.$$.fragment, local);
current = true;
},
o(local) {
if (switch_instance) transition_out(switch_instance.$$.fragment, local);
transition_out(routerview.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) detach(switch_instance_anchor);
if (switch_instance) destroy_component(switch_instance, detaching);
destroy_component(routerview, detaching);
}

@@ -1240,35 +1115,51 @@ };

// (33:6) <svelte:component this={component}>
// (30:4) <svelte:component this={component}>
function create_default_slot(ctx) {
let routerview;
let if_block_anchor;
let current;
let if_block = /*hasChildren*/ ctx[3] && create_if_block_2(ctx);
routerview = new RouterView({
props: { nextMatched: /*matched*/ ctx[2].slice(1) }
});
return {
c() {
create_component(routerview.$$.fragment);
if (if_block) if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
mount_component(routerview, target, anchor);
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(ctx, dirty) {
const routerview_changes = {};
if (dirty & /*matched*/ 4) routerview_changes.nextMatched = /*matched*/ ctx[2].slice(1);
routerview.$set(routerview_changes);
if (/*hasChildren*/ ctx[3]) {
if (if_block) {
if_block.p(ctx, dirty);
transition_in(if_block, 1);
} else {
if_block = create_if_block_2(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros();
transition_out(if_block, 1, 1, () => {
if_block = null;
});
check_outros();
}
},
i(local) {
if (current) return;
transition_in(routerview.$$.fragment, local);
transition_in(if_block);
current = true;
},
o(local) {
transition_out(routerview.$$.fragment, local);
transition_out(if_block);
current = false;
},
d(detaching) {
destroy_component(routerview, detaching);
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
}

@@ -1281,3 +1172,3 @@ };

let current;
let if_block = /*canRender*/ ctx[0] && create_if_block(ctx);
let if_block = /*canRender*/ ctx[1] && create_if_block(ctx);

@@ -1295,9 +1186,6 @@ return {

p(ctx, [dirty]) {
if (/*canRender*/ ctx[0]) {
if (/*canRender*/ ctx[1]) {
if (if_block) {
if_block.p(ctx, dirty);
if (dirty & /*canRender*/ 1) {
transition_in(if_block, 1);
}
transition_in(if_block, 1);
} else {

@@ -1337,35 +1225,31 @@ if_block = create_if_block(ctx);

let $route;
component_subscribe($$self, route, $$value => $$invalidate(7, $route = $$value));
var _a, _b;
let { nextMatched = undefined } = $$props;
component_subscribe($$self, route, $$value => $$invalidate(5, $route = $$value));
let { depth = 0 } = $$props;
let canRender;
let component;
$$self.$$set = $$props => {
if ("nextMatched" in $$props) $$invalidate(4, nextMatched = $$props.nextMatched);
$$self.$set = $$props => {
if ("depth" in $$props) $$invalidate(0, depth = $$props.depth);
};
let matched;
let match;
let hasChildren;
$$self.$$.update = () => {
if ($$self.$$.dirty & /*nextMatched, $route*/ 144) {
$$invalidate(2, matched = nextMatched !== null && nextMatched !== void 0
? nextMatched
: $route.matched);
if ($$self.$$.dirty & /*$route, depth*/ 33) {
$$invalidate(4, match = $route.matched[depth]);
}
if ($$self.$$.dirty & /*matched*/ 4) {
$$invalidate(3, hasChildren = matched.length > 1);
if ($$self.$$.dirty & /*depth, $route*/ 33) {
$$invalidate(3, hasChildren = depth + 1 < $route.matched.length);
}
if ($$self.$$.dirty & /*matched, _a*/ 36) {
if ($$self.$$.dirty & /*match*/ 16) {
{
$$invalidate(0, canRender = false);
$$invalidate(1, canRender = false);
handlePromisable(
handleThunk($$invalidate(5, _a = matched[0]) === null || _a === void 0
handleThunk(match === null || match === void 0
? void 0
: _a.redirect),
: match.redirect),
result => {

@@ -1375,3 +1259,3 @@ if (result != null) {

} else {
$$invalidate(0, canRender = true);
$$invalidate(1, canRender = true);
}

@@ -1383,12 +1267,12 @@ }

if ($$self.$$.dirty & /*matched, _b*/ 68) {
if ($$self.$$.dirty & /*match*/ 16) {
{
$$invalidate(1, component = undefined);
$$invalidate(2, component = undefined);
handlePromisable(
handleComponentThunk($$invalidate(6, _b = matched[0]) === null || _b === void 0
handleComponentThunk(match === null || match === void 0
? void 0
: _b.component),
: match.component),
result => {
$$invalidate(1, component = typeof result === "object" ? result.default : result);
$$invalidate(2, component = typeof result === "object" ? result.default : result);
}

@@ -1400,3 +1284,3 @@ );

return [canRender, component, matched, hasChildren, nextMatched];
return [depth, canRender, component, hasChildren];
}

@@ -1407,14 +1291,11 @@

super();
init(this, options, instance, create_fragment, safe_not_equal, { nextMatched: 4 });
init(this, options, instance, create_fragment, safe_not_equal, { depth: 0 });
}
}
/* dist/components/Link.svelte generated by Svelte v3.24.1 */
/* dist/components/Link.svelte generated by Svelte v3.20.0 */
function create_fragment$1(ctx) {
let a;
let a_href_value;
let a_aria_current_value;
let current;
let mounted;
let dispose;

@@ -1426,7 +1307,5 @@ const default_slot_template = /*$$slots*/ ctx[7].default;

/*$$restProps*/ ctx[3],
{ href: /*$link*/ ctx[1].href },
{
href: a_href_value = /*$link*/ ctx[1].href
},
{
"aria-current": a_aria_current_value = /*$link*/ ctx[1].isExactActive ? "page" : undefined
"aria-current": /*$link*/ ctx[1].isExactActive ? "page" : undefined
}

@@ -1449,3 +1328,3 @@ ];

},
m(target, anchor) {
m(target, anchor, remount) {
insert(target, a, anchor);

@@ -1458,7 +1337,4 @@

current = true;
if (!mounted) {
dispose = listen(a, "click", /*handleClick*/ ctx[2]);
mounted = true;
}
if (remount) dispose();
dispose = listen(a, "click", /*handleClick*/ ctx[2]);
},

@@ -1468,10 +1344,12 @@ p(ctx, [dirty]) {

if (default_slot.p && dirty & /*$$scope*/ 64) {
update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[6], dirty, null, null);
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[6], null), get_slot_changes(default_slot_template, /*$$scope*/ ctx[6], dirty, null));
}
}
set_attributes(a, a_data = get_spread_update(a_levels, [
set_attributes(a, get_spread_update(a_levels, [
dirty & /*$$restProps*/ 8 && /*$$restProps*/ ctx[3],
(!current || dirty & /*$link*/ 2 && a_href_value !== (a_href_value = /*$link*/ ctx[1].href)) && { href: a_href_value },
(!current || dirty & /*$link*/ 2 && a_aria_current_value !== (a_aria_current_value = /*$link*/ ctx[1].isExactActive ? "page" : undefined)) && { "aria-current": a_aria_current_value }
dirty & /*$link*/ 2 && { href: /*$link*/ ctx[1].href },
dirty & /*$link, undefined*/ 2 && {
"aria-current": /*$link*/ ctx[1].isExactActive ? "page" : undefined
}
]));

@@ -1494,3 +1372,2 @@

if (default_slot) default_slot.d(detaching);
mounted = false;
dispose();

@@ -1525,3 +1402,3 @@ }

$$self.$$set = $$new_props => {
$$self.$set = $$new_props => {
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));

@@ -1528,0 +1405,0 @@ $$invalidate(3, $$restProps = compute_rest_props($$props, omit_props_names));

{
"name": "@bjornlu/svelte-router",
"description": "An easy-to-use SPA router for Svelte",
"version": "0.3.2",
"version": "0.4.0",
"main": "dist/svelte-router.umd.js",

@@ -80,3 +80,3 @@ "module": "dist/index.js",

"start-server-and-test": "^1.11.3",
"svelte": "^3.24.1",
"svelte": "3.20.0",
"svelte-preprocess": "^4.2.1",

@@ -83,0 +83,0 @@ "ts-jest": "^26.3.0",

Sorry, the diff of this file is not supported yet

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