From 1d4a5e64238f659cdffda10ccc876283657b2ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramirez=20Vargas=2C=20Jos=C3=A9=20Pablo?= Date: Mon, 1 Sep 2025 11:13:18 -0600 Subject: [PATCH 1/7] chore: Clean things up after navigation feature - Export new functions from core only. - Have Link component type hash using the Hash type. --- src/lib/Link/Link.svelte | 4 ++-- src/lib/LinkContext/LinkContext.svelte | 14 +++++++------- src/lib/core/index.test.ts | 1 - src/lib/core/index.ts | 1 - src/lib/index.test.ts | 2 -- src/lib/index.ts | 2 -- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/lib/Link/Link.svelte b/src/lib/Link/Link.svelte index 744d5d6..aac7e6f 100644 --- a/src/lib/Link/Link.svelte +++ b/src/lib/Link/Link.svelte @@ -5,7 +5,7 @@ import { resolveHashValue } from '$lib/core/RouterEngine.svelte.js'; import { getLinkContext, type ILinkContext } from '$lib/LinkContext/LinkContext.svelte'; import { getRouterContext } from '$lib/Router/Router.svelte'; - import type { ActiveState, RouteStatus } from '$lib/types.js'; + import type { ActiveState, Hash, RouteStatus } from '$lib/types.js'; import { type Snippet } from 'svelte'; import type { HTMLAnchorAttributes } from 'svelte/elements'; @@ -41,7 +41,7 @@ * route becomes active. * - The `prependBasePath` property: It depends on the parent router to set the base path for the link. */ - hash?: boolean | string; + hash?: Hash; /** * Sets the URL to navigate to. Never use a full URL; always use relative or absolute paths. */ diff --git a/src/lib/LinkContext/LinkContext.svelte b/src/lib/LinkContext/LinkContext.svelte index 0c6ce3c..2510644 100644 --- a/src/lib/LinkContext/LinkContext.svelte +++ b/src/lib/LinkContext/LinkContext.svelte @@ -36,18 +36,18 @@ }; class _LinkContext implements ILinkContext { - replace = $state(false); - prependBasePath = $state(false); - preserveQuery = $state(false); + replace; + prependBasePath; + preserveQuery; constructor( replace: boolean, prependBasePath: boolean, - preserveQuery: ILinkContext['preserveQuery'] + preserveQuery: PreserveQuery ) { - this.replace = replace; - this.prependBasePath = prependBasePath; - this.preserveQuery = preserveQuery; + this.replace = $state(replace); + this.prependBasePath = $state(prependBasePath); + this.preserveQuery = $state(preserveQuery); } } diff --git a/src/lib/core/index.test.ts b/src/lib/core/index.test.ts index fb8372c..7315e1b 100644 --- a/src/lib/core/index.test.ts +++ b/src/lib/core/index.test.ts @@ -8,7 +8,6 @@ describe('index', () => { 'RouterEngine', 'joinPaths', 'isConformantState', - 'dissectHrefs', 'calculateHref', 'calculateState', ]; diff --git a/src/lib/core/index.ts b/src/lib/core/index.ts index e070237..fc7a3a0 100644 --- a/src/lib/core/index.ts +++ b/src/lib/core/index.ts @@ -1,6 +1,5 @@ export { location } from "./Location.js"; export { RouterEngine, joinPaths } from "./RouterEngine.svelte.js"; export { isConformantState } from "./isConformantState.js"; -export { dissectHrefs } from "./dissectHrefs.js"; export { calculateHref } from "./calculateHref.js"; export { calculateState } from "./calculateState.svelte.js"; diff --git a/src/lib/index.test.ts b/src/lib/index.test.ts index 7e2227e..72276cb 100644 --- a/src/lib/index.test.ts +++ b/src/lib/index.test.ts @@ -15,8 +15,6 @@ describe('index', () => { 'getRouterContext', 'setRouterContext', 'isConformantState', - 'calculateHref', - 'calculateState', ]; // Act. diff --git a/src/lib/index.ts b/src/lib/index.ts index e2453d4..b646bb0 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -52,7 +52,5 @@ export { default as Fallback } from "$lib/Fallback/Fallback.svelte"; export type * from "./types.js"; export { location } from "./core/Location.js"; export { isConformantState } from "./core/isConformantState.js"; -export { calculateHref } from "./core/calculateHref.js"; -export { calculateState } from "./core/calculateState.svelte.js"; export * from './RouterTrace/RouterTrace.svelte'; export { default as RouterTrace } from './RouterTrace/RouterTrace.svelte'; From 2b28f15bbb71ee42b09afb4b97e3c98fc387ded9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramirez=20Vargas=2C=20Jos=C3=A9=20Pablo?= Date: Mon, 1 Sep 2025 12:52:01 -0600 Subject: [PATCH 2/7] chore: Rename calculateHref.svelte.ts to calculateHref.ts - No longer using runes in this function. --- src/lib/Link/Link.svelte | 2 +- src/lib/core/LocationLite.svelte.ts | 2 +- src/lib/core/calculateHref.ts | 2 +- src/lib/core/calculateState.test.ts | 2 +- src/lib/core/{calculateState.svelte.ts => calculateState.ts} | 0 src/lib/core/index.ts | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename src/lib/core/{calculateState.svelte.ts => calculateState.ts} (100%) diff --git a/src/lib/Link/Link.svelte b/src/lib/Link/Link.svelte index aac7e6f..348326a 100644 --- a/src/lib/Link/Link.svelte +++ b/src/lib/Link/Link.svelte @@ -1,6 +1,6 @@