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

@stackflow/plugin-history-sync

Package Overview
Dependencies
Maintainers
3
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackflow/plugin-history-sync - npm Package Compare versions

Comparing version 1.6.0-canary.0 to 1.6.0

19

dist/index.js

@@ -248,5 +248,22 @@ "use strict";

// src/sortActivityRoutes.ts
var paramRe = /^:[\w-]+$/;
var dynamicSegmentValue = 3;
var emptySegmentValue = 1;
var staticSegmentValue = 10;
var splatPenalty = -2;
var isSplat = (s) => s === "*";
function computeScore(path) {
const segments = path.split("/");
let initialScore = segments.length;
if (segments.some(isSplat)) {
initialScore += splatPenalty;
}
return segments.filter((s) => !isSplat(s)).reduce(
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
initialScore
);
}
function sortActivityRoutes(routes) {
return [...routes].sort(
(a, b) => makeTemplate(a).variableCount - makeTemplate(b).variableCount
(a, b) => computeScore(b.path) - computeScore(a.path)
);

@@ -253,0 +270,0 @@ }

6

package.json
{
"name": "@stackflow/plugin-history-sync",
"version": "1.6.0-canary.0",
"version": "1.6.0",
"repository": {

@@ -48,6 +48,6 @@ "type": "git",

"devDependencies": {
"@stackflow/config": "^1.0.1-canary.0",
"@stackflow/config": "^1.1.0",
"@stackflow/core": "^1.0.13",
"@stackflow/esbuild-config": "^1.0.3",
"@stackflow/react": "^1.2.0-canary.0",
"@stackflow/react": "^1.2.0",
"@swc/core": "^1.6.6",

@@ -54,0 +54,0 @@ "@swc/jest": "^0.2.36",

@@ -38,7 +38,7 @@ import { sortActivityRoutes } from "./sortActivityRoutes";

expect(routes).toStrictEqual([
{ activityName: "C", path: "/:hello/:world/:foo/:bar" },
{ activityName: "A", path: "/detailed/*" },
{ activityName: "B", path: "/:hello/:world" },
{ activityName: "C", path: "/:hello/:world/:foo/:bar" },
{ activityName: "A", path: "*" },
]);
});
import type { ActivityRoute } from "./ActivityRoute";
import { makeTemplate } from "./makeTemplate";
const paramRe = /^:[\w-]+$/;
const dynamicSegmentValue = 3;
const emptySegmentValue = 1;
const staticSegmentValue = 10;
const splatPenalty = -2;
const isSplat = (s: string) => s === "*";
/**
* https://github.com/remix-run/react-router/blob/0f2b167e9b862d5e6b3425438787c8e7b39197f4/packages/router/utils.ts#L742-L773
*/
function computeScore(path: string): number {
const segments = path.split("/");
let initialScore = segments.length;
if (segments.some(isSplat)) {
initialScore += splatPenalty;
}
return segments
.filter((s) => !isSplat(s))
.reduce(
(score, segment) =>
score +
(paramRe.test(segment)
? dynamicSegmentValue
: segment === ""
? emptySegmentValue
: staticSegmentValue),
initialScore,
);
}
export function sortActivityRoutes<T>(

@@ -8,4 +38,4 @@ routes: ActivityRoute<T>[],

return [...routes].sort(
(a, b) => makeTemplate(a).variableCount - makeTemplate(b).variableCount,
(a, b) => computeScore(b.path) - computeScore(a.path),
);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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