Socket
Socket
Sign inDemoInstall

bobril

Package Overview
Dependencies
Maintainers
1
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bobril - npm Package Compare versions

Comparing version 17.1.0 to 17.2.0

5

CHANGELOG.md
# CHANGELOG
## 17.2.0
Router now allows to store additional state in browser history not visible in URL.
Use this new method to get state `getActiveState()`. `createRedirectPush` and `createRedirectReplace` have new 3rd parameter to set state with transition, if new state is not provided current state is preserved.
## 17.1.0

@@ -4,0 +9,0 @@

2

package.json
{
"name": "bobril",
"version": "17.1.0",
"version": "17.2.0",
"description": "Component Oriented MVC Framework with virtual DOM and CSS",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -63,2 +63,3 @@ import {

params: Params | undefined;
state: any;
distance?: number;

@@ -109,8 +110,9 @@ }

function push(path: string, inApp: boolean): void {
function push(path: string, inApp: boolean, state?: any): void {
var l = window.location;
if (inApp) {
programPath = path;
activeState = state;
historyDeepness++;
history().pushState({ historyDeepness }, "", path);
history().pushState({ historyDeepness, state }, "", path);
invalidate();

@@ -122,7 +124,8 @@ } else {

function replace(path: string, inApp: boolean) {
function replace(path: string, inApp: boolean, state?: any) {
var l = window.location;
if (inApp) {
programPath = path;
history().replaceState({ historyDeepness }, "", path);
activeState = state;
history().replaceState({ historyDeepness, state }, "", path);
invalidate();

@@ -294,2 +297,3 @@ } else {

let activeParams: Params = newHashObj();
let activeState: any = undefined;
let nodesArray: (IBobrilCacheNode | undefined)[] = [];

@@ -333,2 +337,3 @@ let setterOfNodesArray: ((node: IBobrilCacheNode | undefined) => void)[] = [];

if (newHistoryDeepness != undefined) {
activeState = ev.state.state;
if (newHistoryDeepness != historyDeepness) invalidate();

@@ -344,3 +349,3 @@ historyDeepness = newHistoryDeepness;

if (history().state == undefined && historyDeepness != undefined) {
history().replaceState({ historyDeepness: historyDeepness }, "");
history().replaceState({ historyDeepness: historyDeepness, state: activeState }, "");
}

@@ -359,2 +364,3 @@ let browserPath = window.location.hash;

params: undefined,
state: undefined,
};

@@ -515,3 +521,3 @@ transitionState = -1;

const activeStyleDef = styleDef("active");
export const activeStyleDef = styleDef("active");

@@ -521,2 +527,3 @@ export function Link(data: {

params?: Params;
state?: any;
replace?: boolean;

@@ -533,3 +540,5 @@ style?: IBobrilStyles;

onClick() {
runTransition((data.replace ? createRedirectReplace : createRedirectPush)(data.name, data.params));
runTransition(
(data.replace ? createRedirectReplace : createRedirectPush)(data.name, data.params, data.state)
);
return true;

@@ -549,6 +558,7 @@ },

export function link(node: IBobrilNode, name: string, params?: Params): IBobrilNode {
export function link(node: IBobrilNode, name: string, params?: Params, state?: any): IBobrilNode {
node.data = node.data || {};
node.data.routeName = name;
node.data.routeParams = params;
node.data.routeState = state;
postEnhance(node, {

@@ -568,3 +578,3 @@ render(ctx: any, me: IBobrilNode) {

let data = ctx.data;
runTransition(createRedirectPush(data.routeName, data.routeParams));
runTransition(createRedirectPush(data.routeName, data.routeParams, data.routeState));
return true;

@@ -576,3 +586,3 @@ },

export function createRedirectPush(name: string, params?: Params): IRouteTransition {
export function createRedirectPush(name: string, params?: Params, state?: any): IRouteTransition {
return {

@@ -583,6 +593,7 @@ inApp: isInApp(name),

params: params || {},
state: state ?? activeState,
};
}
export function createRedirectReplace(name: string, params?: Params): IRouteTransition {
export function createRedirectReplace(name: string, params?: Params, state?: any): IRouteTransition {
return {

@@ -593,2 +604,3 @@ inApp: isInApp(name),

params: params || {},
state: state ?? activeState,
};

@@ -604,2 +616,3 @@ }

params: {},
state: undefined,
distance,

@@ -616,6 +629,6 @@ };

case RouteTransitionType.Push:
push(urlOfRoute(transition.name!, transition.params), transition.inApp);
push(urlOfRoute(transition.name!, transition.params), transition.inApp, transition.state);
break;
case RouteTransitionType.Replace:
replace(urlOfRoute(transition.name!, transition.params), transition.inApp);
replace(urlOfRoute(transition.name!, transition.params), transition.inApp, transition.state);
break;

@@ -831,1 +844,5 @@ case RouteTransitionType.Pop:

}
export function getActiveState() {
return activeState;
}

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